• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Football codes TFS [1.x]

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,285
Location
Sweden?
Hello,

lE2lyqEVB.gif


well i may make the full game event later. But here is football code:

Go to movements and add this in the movements.xml
Code:
<movevent event="StepIn" itemid="2109" script="football.lua" />

Now go into movements/scripts and create lua and name it: football.lua and paste this:

Code:
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

Now go to talkactions and add this in talkactions.xml
Code:
<talkaction words="!football" separator=" " script="football.lua" />

Now in talkactions/scripts and create lua and name it: football.lua and paste this:

Code:
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))

function onSay(player, words, param)
        local position = player:getPosition()
        position:getNextPosition(player:getDirection())

    if param == "shoot" then
        local tile = Tile(position)
        if not tile then
            return false
        end

        local football = tile:getItemById(2109)
        if football then
            position:sendMagicEffect(CONST_ME_GROUNDSHAKER)
            for i = 1, 3 do
                position:getNextPosition(player:getDirection())
                if position:isWalkable(true) then
                    football:moveTo(position)
                else
                    break
                end
            end

            player:say("SHOOT!", TALKTYPE_MONSTER_SAY)
        end
    elseif param == "powershoot" then
        powerShoot:execute(player, positionToVariant(position))
    end
    return false
end

Here is the lib:
Code:
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

Commands:

Code:
!football shoot
!football powershoot
 
Last edited:
Use "powershot" instead of "powershoot". It feels more right and proper grammar, if i'm not mistaken.

Anyways, good release! :)
 
@Printer
Your ideas for each script is the best!
 
Neat idea. I think the "shot" and "powershot" abilities should have a random chance to lose accuracy (ie. fly in a totally incorrect direction.)

Anyway, nice contribution!
Red
 
What if it gets stuck on a wall?

Edit: could you make it so if the player walks on it from the same direction that would teleport it into the wall it will "bouce" behind him.
 
Last edited:
What if it gets stuck on a wall?

Edit: could you make it so if the player walks on it from the same direction that would teleport it into the wall it will "bouce" behind him.
So make it bounce and show your version.
 
Back
Top