• 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!

Lua Football System

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
932
Solutions
23
Reaction score
444
Location
Santiago - Chile
Hi! I use TFS 1.4 8.6 by nekiros and would like to request a simple football system.

  • First, I will set the pickupable flag off the football item so players won't be able to pick the ball in their inventories.
  • The football item is going to have a custom ID registered on items.otb and .xml
  • The idea is to have a frompos - topos area that limits the football field (red)
  • If the football item gets out of the frompos - to pos area , the ball will be automatically teleported to the middle of the field (yellow)
  • There's no need to set a limit to blue area, it only refers to space that is outside red area
  • The grey marked areas are going to have "nothing special" floor so balls won't be able to be thrown there
  • The light blue can be moveevent tiles that sends the football item to the middle with a different effect (ex. "goal!") (a good example as moveevent can be scarab tokens script from ankrahmun tombs)
  • There's also something important, players shouldn't be able to throw items inside red area
  • Player should only be able to move football item 1 SQM, not sure if function onMoveItem can be usefull here
1630430147639.png

In advance, thanks
Regards!
 
Last edited:
Solution
View attachment bandicam 2021-09-01 07-07-30-436.mp4
Quick video to show functionality.
  • Items that are not the football cannot be thrown into the arena
  • football can only be thrown 1 sqm
  • football goal area, and out of bounds area
  • tiles directly adjacent to the goal area have 'nothing special', and therefore don't trigger the out of bounds rule

data/scripts/eventcallbacks/player/football_onMoveItem.lua
Lua:
local footballId = 10522
local gameArea = {
    main = {
        from = Position(241, 238, 7),
        to = Position(253, 246, 7)
    },
    goals = {
        top = {
            from = Position(240, 241, 7),
            to = Position(240, 243, 7)
        },
        bottom = {
            from = Position(254, 241, 7)...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,669
Solutions
405
Reaction score
3,782
View attachment bandicam 2021-09-01 07-07-30-436.mp4
Quick video to show functionality.
  • Items that are not the football cannot be thrown into the arena
  • football can only be thrown 1 sqm
  • football goal area, and out of bounds area
  • tiles directly adjacent to the goal area have 'nothing special', and therefore don't trigger the out of bounds rule

data/scripts/eventcallbacks/player/football_onMoveItem.lua
Lua:
local footballId = 10522
local gameArea = {
    main = {
        from = Position(241, 238, 7),
        to = Position(253, 246, 7)
    },
    goals = {
        top = {
            from = Position(240, 241, 7),
            to = Position(240, 243, 7)
        },
        bottom = {
            from = Position(254, 241, 7),
            to = Position(254, 243, 7)
        }
    },
    middle = Position(247, 242, 7)
}

local football = EventCallback

football.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    -- disable players from throwing items in gameArea
    if item:getId() ~= footballId then
        if toPosition:isInRange(gameArea.main.from, gameArea.main.to) then
            return false
        end
        if toPosition:isInRange(gameArea.goals.top.from, gameArea.goals.top.to) then
            return false
        end
        if toPosition:isInRange(gameArea.goals.bottom.from, gameArea.goals.bottom.to) then
            return false
        end
        return true
    end
    -- distance check
    if fromPosition:getDistance(toPosition) > 1 then
        return false
    end
    -- goal check
    if toPosition:isInRange(gameArea.goals.top.from, gameArea.goals.top.to) or toPosition:isInRange(gameArea.goals.bottom.from, gameArea.goals.bottom.to) then
        item:moveTo(gameArea.middle)
        self:say("Goal!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
        toPosition:sendMagicEffect(CONST_ME_FIREAREA)
        return false
    end
    -- out of bounds check
    if not toPosition:isInRange(gameArea.main.from, gameArea.main.to) and Tile(toPosition):isWalkable() then
        item:moveTo(gameArea.middle)
        self:say("Out of Bounds!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
        return false
    end
    return true
end

football:register()
 
Solution

Adorius Black

Well-Known Member
Joined
Mar 31, 2020
Messages
142
Solutions
3
Reaction score
62
View attachment 61705
Quick video to show functionality.
  • Items that are not the football cannot be thrown into the arena
  • football can only be thrown 1 sqm
  • football goal area, and out of bounds area
  • tiles directly adjacent to the goal area have 'nothing special', and therefore don't trigger the out of bounds rule

data/scripts/eventcallbacks/player/football_onMoveItem.lua
Lua:
local footballId = 10522
local gameArea = {
    main = {
        from = Position(241, 238, 7),
        to = Position(253, 246, 7)
    },
    goals = {
        top = {
            from = Position(240, 241, 7),
            to = Position(240, 243, 7)
        },
        bottom = {
            from = Position(254, 241, 7),
            to = Position(254, 243, 7)
        }
    },
    middle = Position(247, 242, 7)
}

local football = EventCallback

football.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    -- disable players from throwing items in gameArea
    if item:getId() ~= footballId then
        if toPosition:isInRange(gameArea.main.from, gameArea.main.to) then
            return false
        end
        if toPosition:isInRange(gameArea.goals.top.from, gameArea.goals.top.to) then
            return false
        end
        if toPosition:isInRange(gameArea.goals.bottom.from, gameArea.goals.bottom.to) then
            return false
        end
        return true
    end
    -- distance check
    if fromPosition:getDistance(toPosition) > 1 then
        return false
    end
    -- goal check
    if toPosition:isInRange(gameArea.goals.top.from, gameArea.goals.top.to) or toPosition:isInRange(gameArea.goals.bottom.from, gameArea.goals.bottom.to) then
        item:moveTo(gameArea.middle)
        self:say("Goal!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
        toPosition:sendMagicEffect(CONST_ME_FIREAREA)
        return false
    end
    -- out of bounds check
    if not toPosition:isInRange(gameArea.main.from, gameArea.main.to) and Tile(toPosition):isWalkable() then
        item:moveTo(gameArea.middle)
        self:say("Out of Bounds!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
        return false
    end
    return true
end

football:register()

I have this error. TFS 1.3 OTG PREMIUM. Anyway nice script :)

aaa.png
 
Top