Ir para conteúdo

Football codes TFS [1.x]


kaleudd

Posts Recomendados

Author:Printer

 

Como funciona:

lE2lyqEVB.gif

 

Esse é somente um código,e não o evento em si:

Vamos a instalação;

vá em movements.xml e adicione:

<movevent event="StepIn" itemid="2109" script="football.lua" />

Agora em movements/script crie um arquivo e renomeie para football.lua e bote dentro dele:

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player == nil then
        return true
    end

        local nextPosition = player:getPosition()
        nextPosition:getNextPosition(player:getDirection())

    if nextPosition:isWalkable(false) then
        position:sendMagicEffect(CONST_ME_POFF)
        item:moveTo(nextPosition)
    end

    return true
end

Agora vá em talkactions.xml e adicione essa linha:

<talkaction words="!football" separator=" " script="football.lua" />

Agora em talkactions/scripts crie um arquivo e renomeie para football.lua e bote dentro dele:

function onTargetTile(creature, position)
    local tile = Tile(position)
    if not tile then
        return false
    end

    local football = tile:getItemById(2109)
    if football then
        local playerPosition, footballPosition = creature:getPosition(), football:getPosition()
        playerPosition:sendDistanceEffect(footballPosition, CONST_ANI_WHIRLWINDCLUB)
        footballPosition:sendMagicEffect(CONST_ME_HITAREA)

        local distance = playerPosition:getDistance(footballPosition)
        local nextPosition = footballPosition
        for i = 1, (6 - distance) do
            nextPosition:getNextPosition(creature:getDirection())
            if nextPosition:isWalkable(false) then
                football:moveTo(nextPosition)
            else
                break
            end
        end

        creature:say("POWER SHOOT!", TALKTYPE_MONSTER_SAY)
    end  
end

local powerShoot = Combat()
powerShoot:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
powerShoot:setArea(createCombatArea(AREA_SHOOTRANGE, AREADIAGONAL_SHOOTRANGE))

Aqui é o lib:

AREA_SHOOTRANGE = {
    {1},
    {1},
    {1},
    {3}
}

AREADIAGONAL_SHOOTRANGE = {
    {0, 1, 0, 0, 0},
    {0, 0, 1, 0, 0},
    {0, 0, 0, 1, 0},
    {0, 0, 0, 0, 3}
}

function Position.isWalkable(position, playerBlock)
    local tile = Tile(position)
    if not tile then
        return false
    end

    if playerBlock and tile:getCreatureCount() ~= 0 then
        return false
    end

    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, tile:getItemCount() do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end

    return true
end

Comandos:

!football shoot
!football powershoot

Author:Printer

 

Editado por kaleudd
Link para o comentário
Compartilhar em outros sites

  • 1 month later...
×
×
  • Criar Novo...