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

Solved TFS 1.2 - Condition Drown bug

darkjav

Senior Developer
Joined
Apr 29, 2008
Messages
195
Reaction score
12
Location
Mexico City
Hello,

The drowning condition not dissapear later of step in or step out, on few floors ,under water.

This only dissapear when player logout, but if the player have pk, so this become infinite:

https://imgur.com/a/6esQo

I use the same file that repository on Github of TFS 1.2


Code:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

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

    if math.random(1, 10) == 1 then
        position:sendMagicEffect(CONST_ME_BUBBLES)
    end
    player:addCondition(condition)
    return true
end

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

    player:removeCondition(CONDITION_DROWN)
    return true
end


So i have this file identical:

https://www.diffchecker.com/Gfns8UHo

I think that problem is also in movements.xml, on this lines:

http://pastebin.com/wRsnPJb4

Please anybody can check it? I try to fix adding more type items of floor, but not possible.

Thanks!
 
I use:

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

    if Tile(toPosition):getItemById(1387) then
        player:removeCondition(CONDITION_DROWN)
        return true
    end
end

and:

Code:
<movevent event="StepIn" itemid="1387" script="teleport_drown.lua" />

is correct?
 
Last edited:
I use:

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

    if Tile(toPosition):getItemById(1387) then
        player:removeCondition(CONDITION_DROWN)
        return true
    end
end

and:

Code:
<movevent event="StepIn" itemid="1387" script="teleport_drown.lua" />

is correct?
.. no
use the official tfs script
that script wont work for any other tiles + your toPosition is called position in your function args for some reason so the tile will be nil
 
Ok, and now?
Code:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

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

   if Tile(toPosition):getItemById(1387) then
        player:removeCondition(CONDITION_DROWN)
        return true
    end

    if math.random(1, 10) == 1 then
        position:sendMagicEffect(CONST_ME_BUBBLES)
    end
    player:addCondition(condition)
    return true
end

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

    player:removeCondition(CONDITION_DROWN)
    return true
end
 
Ok, and now?
Code:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

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

   if Tile(toPosition):getItemById(1387) then
        player:removeCondition(CONDITION_DROWN)
        return true
    end

    if math.random(1, 10) == 1 then
        position:sendMagicEffect(CONST_ME_BUBBLES)
    end
    player:addCondition(condition)
    return true
end

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

    player:removeCondition(CONDITION_DROWN)
    return true
end
instead of asking me each step, test it and tell me if you get an error
otherwise, it is solved.
 
@darkjav my code is it:
Code:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end
    if item:getPosition() == Position(31913, 32713, 12) then -- HERE I CHECK THE POSITIONS, YOU NEED EDIT IT TO FILL YOUR NEEDS 
        player:removeCondition(CONDITION_DROWN)
        return true
    end
    if math.random(10) == 1 then
        position:sendMagicEffect(CONST_ME_BUBBLES)
    end
    player:addCondition(condition)
    return true
end

function onStepOut(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end

    player:removeCondition(CONDITION_DROWN)
    return true
end
 
@darkjav my code is it:
Code:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end
    if item:getPosition() == Position(31913, 32713, 12) then -- HERE I CHECK THE POSITIONS, YOU NEED EDIT IT TO FILL YOUR NEEDS
        player:removeCondition(CONDITION_DROWN)
        return true
    end
    if math.random(10) == 1 then
        position:sendMagicEffect(CONST_ME_BUBBLES)
    end
    player:addCondition(condition)
    return true
end

function onStepOut(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end

    player:removeCondition(CONDITION_DROWN)
    return true
end
that code wont even work
you can't compare two tables:
t = {1} t2 = {1} if t == t2 then
 
@Xeraphus, this code not work:

Code:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

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

   if Tile(toPosition):getItemById(1387) then
        player:removeCondition(CONDITION_DROWN)
        return true
    end

    if math.random(1, 10) == 1 then
        position:sendMagicEffect(CONST_ME_BUBBLES)
    end
    player:addCondition(condition)
    return true
end

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

    player:removeCondition(CONDITION_DROWN)
    return true
end

i get this error:
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/drowning.lua:onStepIn
data/movements/scripts/drowning.lua:12: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/drowning.lua:12: in function <data/movements/scripts/drowning.lua:6>

@silveralol, and yes work with:
Code:
    if item:getPosition() == Position(31913, 32713, 12) then -- HERE I CHECK THE POSITIONS, YOU NEED EDIT IT TO FILL YOUR NEEDS
        player:removeCondition(CONDITION_DROWN)
        return true
    end

@Xeraphus, So, what code you recommended, and how fix the first? Thanks!
 
Last edited:
@Tarek1337 Yes, i use it, with the changes that they said me.

Well, now has been resolved, thanks to all. :D
i told you to just use the regular script cause onstepout for the tile will remove the player's condition if you have it correct in the xml, you don't need to specify a position and check it each time for stepIn
 
Back
Top