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

Delay effect | spell

Salvus

Well-Known Member
Joined
Feb 7, 2019
Messages
102
Solutions
1
Reaction score
69
How can i add delay on the second effect on this spell?

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 16)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 22)
combat2:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat2:setParameter(COMBAT_PARAM_USECHARGES, true)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 1) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    combat2:execute(creature, var)
    return true
end
 
Solution
How can i add delay on the second effect on this spell?

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 16)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 22)
combat2:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat2:setParameter(COMBAT_PARAM_USECHARGES, true)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 1) + (maglevel * 3) + 32
    local max =...
How can i add delay on the second effect on this spell?

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 16)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 22)
combat2:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat2:setParameter(COMBAT_PARAM_USECHARGES, true)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 1) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    combat:execute(creature, var)
    combat2:execute(creature, var)
    return true
end
Not tested and could be written better but i kept it this way to keep it simple.
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 16)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 22)
combat2:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat2:setParameter(COMBAT_PARAM_USECHARGES, true)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

-- callback function for combat
function onGetFormulaValues1(player, level, maglevel)
    local min = (level / 1) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

-- callback function for combat2
function onGetFormulaValues2(player, level, maglevel)
    local min = (level / 1) + (maglevel * 3) + 32
    local max = (level / 5) + (maglevel * 9) + 40
    return -min, -max
end

-- execute the callback functions after casting the spell for both combat & combat2 respectfully
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues1")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

-- 2 second delay
local delay = 1000 * 2

function onCastSpell(creature, var)
    -- if the spell casts successfully then continue
    if combat:execute(creature, var) then
        -- will execute when the delay time is reached
        addEvent(function(cid, v)
            -- check if the creature exists
            local c = Creature(cid)
            if c then
                -- execute if it does
                combat2:execute(c, v)
            end
            -- parameters the delay time, the creature id (cid) and var (v)
        end, delay, creature:getId(), var)
        -- return true (show the words above the player's head emote or regular text)
        return true
    end
    -- if it doesn't cast successfully then return false and don't show any text
    return false
end
Credits to @Apollos for the:
Lua:
if combat:execute(creature, var) then
 
Last edited:
Solution
Keep in mind, if you use delayed combats executions, never reload spells via the command. If the spell is in progress it will crash your server, cause combat object is getting reinitalized, which means old one does not exist.

„doTargetCombatHealth” approach is safer.
 
Just wanted to test if the server really crashed if I reloaded the spells. But yes, it did.

How can i do it with doTargetCombatHealth? Can you give me a example? @Nekiro
 
Last edited:

Similar threads

Back
Top