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

TFS 1.X+ TFS 1.2 How to achieve spiked or bladed rotating trap

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
914
Solutions
2
Reaction score
50
Hey i have a sprite of this spiked or bladed rotating trap that has 51 frames and im thinking how can i achieve this bladed rotating trap, that you would need to cross otherwise you get one tapped if you touch the blade.
1734444244254.webp
 
I guess that depends on whether or not the 51 frames is a global rotating cycle, and not client rendered.

If it's global rotating cycle, then onStartUp, you could start an onThink event, that changes 1-2 global variable / storage values, and have like 5 actionId's along the length of the saw track (or however long the track is).

Then when the player steps on the tile, check the global variable to see if they get damaged.

It'll be a little finnicky to setup, as you'll have to do manual testing for the timing, and probably use a couple of addEvents alongside the onThink..
But it should work out pretty well.
 
I guess that depends on whether or not the 51 frames is a global rotating cycle, and not client rendered.

If it's global rotating cycle, then onStartUp, you could start an onThink event, that changes 1-2 global variable / storage values, and have like 5 actionId's along the length of the saw track (or however long the track is).

Then when the player steps on the tile, check the global variable to see if they get damaged.

It'll be a little finnicky to setup, as you'll have to do manual testing for the timing, and probably use a couple of addEvents alongside the onThink..
But it should work out pretty well.
by global rotatitng cycle you mean when its not on the loop from client side?
 
Basically if the animation matches for all players, then it's global.

If each player sees the saw blades differently, then it's client rendered.
Pretty sure it matches for all players because everyone is using same client that has this animation frames
Post automatically merged:

Fuck cant get the timing correct and for some reason it ignores starting position aswell well im sharing this sprite obd for anyone that wants to try to play with it. Leaving the script aswell i wrote probably the script is shit but w/e
LUA:
local SAW_STORAGE_KEY = 7777
local POSITION_TIMINGS = {
    {pos = 1, duration = 1600}, -- Tile 1: Frame 43–51, 1–8
    {pos = 2, duration = 900},  -- Tile 2: Frame 9–17
    {pos = 3, duration = 1500}, -- Tile 3: Frame 18–32
    {pos = 2, duration = 1000}, -- Tile 2: Frame 33–42
}

local currentIndex = 1

function updateSawBlade()
    local currentPos = POSITION_TIMINGS[currentIndex].pos
    local duration = POSITION_TIMINGS[currentIndex].duration
    setGlobalStorageValue(SAW_STORAGE_KEY, currentPos)
    currentIndex = (currentIndex % #POSITION_TIMINGS) + 1
    addEvent(updateSawBlade, duration)
end

function onStartup()
    setGlobalStorageValue(SAW_STORAGE_KEY, 1)
    currentIndex = 1                      
    addEvent(updateSawBlade, 100)            
end
LUA:
local DAMAGE = 100      
local SAW_STORAGE_KEY = 7777

function onStepIn(player, item, position, fromPosition)
    if not player:isPlayer() then
        return true
    end

    local activePosition = getGlobalStorageValue(SAW_STORAGE_KEY)

    if item.actionid == 1400 + activePosition then
        player:addHealth(-DAMAGE)
        position:sendMagicEffect(CONST_ME_DRAWBLOOD)
        player:say("You were sliced", TALKTYPE_MONSTER_SAY)
    end
    return true
end
 

Attachments

Last edited:
Back
Top