• 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 Is there a way to stop drowning in spots?

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
365
Solutions
5
Reaction score
86
Location
Mexico Missouri
Im working on my 10.77 RPG map. There is a rook on this server.

TESTING THIS ON A LEVEL 1 CHAR.

My problem is I have 1 spot in rook where players must pass underwater a total of 5 steps. The problem is that by the time I took 5 steps, I was dead. Is there a way to stop the drowning process in this 1 area?

I have tried setting the area as a PZ zone and No PVP zone, and it does not stop me from drowning and dying. Is there a way around this in the mapping stage, or will I have to do some sort of StepIn/StepOut functions?

My other alternative would be to make this part of a quest, at which I think would be annoying to some players.


Any help is appreciated.
Thanks for your time,
Justin
 
Solution
test this one

Lua:
local damage = {
    [2] = -1,
    [3] = -4,
    [5] = -6
}

local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)
function onStepIn(creature, item, position, fromPosition)

    local player, value = creature:getPlayer(), -1
    if player == nil then
        return true
    end
    for level, dmg in pairs(damage) do
        if player:getLevel() <= level then
            value = dmg
            break
        end
    end
    condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, value)
    if math.random(1, 10) == 1 then
        position:sendMagicEffect(CONST_ME_BUBBLES)
    end
    player:addCondition(condition)...
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
 
something like changing it to -1 will solve it, example:
Lua:
local condition = Condition(CONDITION_DROWN)
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
   
    local damage = player:getLevel() >= 4 and -20 or -1
    condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, damage)
    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
 
Wow man. You are awesome. That was fast and super appreciated. Is there a way to add more variables to it? Say a level 1 loses 2hp per tick, a level 2 loses 4 hp per tick, and so on?

Is that possible, or just too much of a pain? I am not that great with lua yet, but still trying to learn it.
 
test this one

Lua:
local damage = {
    [2] = -1,
    [3] = -4,
    [5] = -6
}

local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)
function onStepIn(creature, item, position, fromPosition)

    local player, value = creature:getPlayer(), -1
    if player == nil then
        return true
    end
    for level, dmg in pairs(damage) do
        if player:getLevel() <= level then
            value = dmg
            break
        end
    end
    condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, value)
    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
 
Solution
Back
Top