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

Remove Condition

Hertus

New Member
Joined
Jul 28, 2018
Messages
42
Reaction score
2
When I die, I want to remove all conditions. Condition: CONDITION POISON still stays. Please help.


Lua:
boss.removeConditions = function(self, player)

    local conditions = {
        CONDITION_POISON, CONDITION_FIRE,
        CONDITION_ENERGY, CONDITION_PARALYZE,
        CONDITION_DRUNK, CONDITION_DROWN,
        CONDITION_FREEZING, CONDITION_DAZZLED,
        CONDITION_BLEEDING, CONDITION_CURSED, CONDITION_INFIGHT
    }

    for _, condition in ipairs(conditions) do
        if player:getCondition(condition) then
            player:removeCondition(condition)
        end
    end
    return true
end
 
When I die, I want to remove all conditions. Condition: CONDITION POISON still stays. Please help.


Lua:
boss.removeConditions = function(self, player)

    local conditions = {
        CONDITION_POISON, CONDITION_FIRE,
        CONDITION_ENERGY, CONDITION_PARALYZE,
        CONDITION_DRUNK, CONDITION_DROWN,
        CONDITION_FREEZING, CONDITION_DAZZLED,
        CONDITION_BLEEDING, CONDITION_CURSED, CONDITION_INFIGHT
    }

    for _, condition in ipairs(conditions) do
        if player:getCondition(condition) then
            player:removeCondition(condition)
        end
    end
    return true
end
change ipairs to pairs
 
Doesn't work. CONDITION_POISON sometimes stays on the player.
Lua:
local prepareDeath = CreatureEvent("PrepareDeath")
function prepareDeath.onPrepareDeath(player, lastHitKiller, mostDamageKiller)
    if player:isPlayer() then
        if player:getStorageValue(boss.config.storageJoined) > 0  then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have been killed.")
            boss:removeConditions(player)
            if boss:countPlayers() <= 0 then
                if isInArray({EVENT_STARTED}, boss:getEventState()) then
                    Game.broadcastMessage("Gaz'haragoth killed all the players in the event.", MESSAGE_EVENT_ADVANCE)
                    boss:stopEvent()
                end
            end
        end
    end
return true
end
prepareDeath:register()
 
When I enter teleport all CONDITIONS are properly removed. In the onPrepareDeath function sometimes it doesn't remove the CONDITION_POISON.
 
Try it @Hertus
Lua:
function prepareDeath.onPrepareDeath(player, lastHitKiller, mostDamageKiller)
    if player:isPlayer() then
        if player:getStorageValue(boss.config.storageJoined) > 0  then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have been killed.")
            
            -- Remove all conditions except for CONDITION_POISON
            for _, condition in ipairs(player:getConditions()) do
                if condition.type ~= CONDITION_POISON then
                    player:removeCondition(condition.type, condition.subType, condition.duration, true)
                end
            end
            
            -- If the player is still affected by CONDITION_POISON, remove it specifically
            if player:hasCondition(CONDITION_POISON, CONDITIONID_COMBAT, nil, true) then
                player:removeCondition(CONDITION_POISON, CONDITIONID_COMBAT, nil, true)
            end
            
            -- Check if there are no more players in the event and stop it if necessary
            if boss:countPlayers() <= 0 then
                if isInArray({EVENT_STARTED}, boss:getEventState()) then
                    Game.broadcastMessage("Gaz'haragoth killed all the players in the event.", MESSAGE_EVENT_ADVANCE)
                    boss:stopEvent()
                end
            end
        end
    end
    return true
end
 
Lua:
local conditions = {
    CONDITION_POISON,
    CONDITION_FIRE,
    CONDITION_ENERGY,
    CONDITION_BLEEDING,
    CONDITION_HASTE,
    CONDITION_PARALYZE,
    CONDITION_OUTFIT,
    CONDITION_INVISIBLE,
    CONDITION_LIGHT,
    CONDITION_MANASHIELD,
    CONDITION_MANASHIELD_BREAKABLE,
    CONDITION_INFIGHT,
    CONDITION_DRUNK,
    CONDITION_EXHAUST_WEAPON,
    CONDITION_REGENERATION,
    CONDITION_SOUL,
    CONDITION_DROWN,
    CONDITION_MUTED,
    CONDITION_CHANNELMUTEDTICKS,
    CONDITION_YELLTICKS,
    CONDITION_ATTRIBUTES,
    CONDITION_FREEZING,
    CONDITION_DAZZLED,
    CONDITION_CURSED,
    CONDITION_EXHAUST_COMBAT,
    CONDITION_EXHAUST_HEAL,
    CONDITION_PACIFIED,
    CONDITION_SPELLCOOLDOWN,
    CONDITION_SPELLGROUPCOOLDOWN,
    CONDITION_ROOT
}
Lua:
for _, condition in pairs(conditions) do
    player:removeCondition(condition)
end
 
Lua:
player:teleportTo(player:getTown():getTemplePosition())
player:getTown():getTemplePosition():sendMagicEffect(CONST_ME_TELEPORT)

After returning from the onPrepareDeath event, the player sometimes has CONDITION POISON.
The functions work fine in other methods. The player's onPrepareDeath condition is not removed.
 
Last edited:
Back
Top