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

break beetwen two different combat onCastSpell()

pacan123

New Member
Joined
Oct 5, 2012
Messages
32
Reaction score
2
Hello guys i have problem
i want to make break 100ms between combat and combat2 in function onCastSpell() maybe you know how can i do this?

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
combat:setArea(createCombatArea(AREA_WAVE5, AREADIAGONAL_WAVE4))


local combat2 = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
combat:setArea(createCombatArea(AREA_WAVE5, AREADIAGONAL_WAVE4))


function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2) + 12
    return -min, -max
end


combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


function onCastSpell(creature, variant)
    combat:execute(creature, variant)
    combat2:execute(creature, variant)
    return true
end
 
Solution
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)...
Code:
function onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(combat2:execute, 100, creature, variant)
    return true
end
or
Code:
function onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(combat2.execute, 100, creature, variant)
    return true
end

I don't know exactly - im using outdated 0.X xD
 
Lua Script Error: [Spell Interface]
data/spells/scripts/WaveOwn.lua:eek:nCastSpell
luaAddEvent(). Argument #3 is unsafe
stack traceback:
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
combat:setArea(createCombatArea(AREA_WAVE5, AREADIAGONAL_WAVE4))
function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2) + 12
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
combat2:setArea(createCombatArea(AREA_WAVE5, AREADIAGONAL_WAVE4))
function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2) + 12
    return -min, -max
end
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function safeByPass(cid, var)
    local player = Player(cid)
    if not player then
        return
    end
    local variant = Variant(var)
    if variant then
        combat2:execute(player, variant)
    end
end

function onCastSpell(creature, variant)
    local player = Player(creature)
    if not player then
        return false
    end
    combat:execute(creature, variant)
    addEventsafeByPas, 100, player:getId(), variant:getNumber())
    return true
end
 
Last edited:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues2(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

function onCastSpell(creature, variant, isHotkey)
        if combat:execute(creature,variant) then
        addEvent(function()
            combat2:execute(creature,variant)
        end,1000)
        return true
    end
end

Just change the effect as you want
 
Solution
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues2(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

function onCastSpell(creature, variant, isHotkey)
        if combat:execute(creature,variant) then
        addEvent(function()
            combat2:execute(creature,variant)
        end,1000)
        return true
    end
end

Just change the effect as you want
Thanks

AngeLOT

!!! i dont know that i need to pass function inside addEvent... Great
 
Last edited:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat2:setArea(createCombatArea(AREA_CIRCLE3X3))

function onGetFormulaValues2(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.2) + 7
    local max = (level / 5) + (magicLevel * 2.85) + 16
    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

function onCastSpell(creature, variant, isHotkey)
        if combat:execute(creature,variant) then
        addEvent(function()
            combat2:execute(creature,variant)
        end,1000)
        return true
    end
end

Just change the effect as you want
Unsafe, creature can no longer exist on execution.

Lua:
function doCombat2(cid, variant)
  local creature = Creature(cid)
  if creature then
    combat2:execute(creature, variant)
  end
end

function onCastSpell(creature, variant, isHotkey)
  if combat:execute(creature, variant) then
    addEvent(doCombat2, 1000, creature:getId(), variant)
    return true
  end
end
 
Unsafe, creature can no longer exist on execution.

Lua:
function doCombat2(cid, variant)
  local creature = Creature(cid)
  if creature then
    combat2:execute(creature, variant)
  end
end

function onCastSpell(creature, variant, isHotkey)
  if combat:execute(creature, variant) then
    addEvent(doCombat2, 1000, creature:getId(), variant)
    return true
  end
end

Good to know thanks
 
Unsafe, creature can no longer exist on execution.

Lua:
function doCombat2(cid, variant)
  local creature = Creature(cid)
  if creature then
    combat2:execute(creature, variant)
  end
end

function onCastSpell(creature, variant, isHotkey)
  if combat:execute(creature, variant) then
    addEvent(doCombat2, 1000, creature:getId(), variant)
    return true
  end
end

I've tried calling a function like this before and not sure why it didn't work. I also took it as a function and passed the id and then based on it I created an object exactly like you did and it didn't work for me. I'm going to try to do it again and let you know if it works.
 
Back
Top