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

Lua Utori [Damage Over Time] Spells

domyno2837

Member
Joined
Oct 28, 2013
Messages
168
Reaction score
5
It is possible to make the utori spells magic level based? i tryed much with that script but don't get it :/

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 25, 1000, -450)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

Thanks when anyone can help! :)
 
Unfortunately there is no implemented support in the source for that task. All damage over time conditions have static damage in real tibia.

However, there is a method in LUA to solve this, you can put the combat in an array with keys identified with a magic level through a loop, example:

Code:
local combat = []
local condition = []
for i=0,200 do
    combat[i] = createCombatObject()
    setCombatParam(combat[i], COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
    setCombatParam(combat[i], COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
    setCombatParam(combat[i], COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

    condition[i] = createConditionObject(CONDITION_ENERGY)
    setConditionParam(condition[i], CONDITION_PARAM_DELAYED, 1)
    addDamageCondition(condition[i], 25, 1000, -(50 + i * 10))
    setCombatCondition(combat[i], condition[i])
end

function onCastSpell(cid, var)
    magLevel = getPlayerMagLevel(cid)
    return doCombat(cid, combat[magLevel], var)
end

This method might seem unethical, but it won't affect the performance of your server negatively, only delay the server start length with merely miliseconds.
The formula -(50 + i * 10) will then be 50 + magic level * 10

I haven't tested it out, and the magic level function might differ depending on your TFS version,
I hope it helps

Ignazio
 
Try this:

Code:
function onCastSpell(cid, var)
local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

local value = getPlayerMagLevel(cid)*2.5 + getPlayerLevel(cid) -- Define your formula here
local ticks= 3 -- Enter the amount of seconds between each damage tick
local repeats = 25 -- Enter the amount of times you want this damage to repeat

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, repeats, ticks*1000, -value)
setCombatCondition(combat, condition)

return doCombat(cid, combat, var)
end

Edit: In order to be able to use player's data in your formula, you need your formula and your setConditionParam to be under a function that contains (cid) as a parameter instead of being outside of it.
 
Try this:

Code:
function onCastSpell(cid, var)
local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

local value = getPlayerMagLevel(cid)*2.5 + getPlayerLevel(cid) -- Define your formula here
local ticks= 3 -- Enter the amount of seconds between each damage tick
local repeats = 25 -- Enter the amount of times you want this damage to repeat

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, repeats, ticks*1000, -value)
setCombatCondition(combat, condition)

return doCombat(cid, combat, var)
end

Edit: In order to be able to use player's data in your formula, you need your formula and your setConditionParam to be under a function that contains (cid) as a parameter instead of being outside of it.

Even if this would work, which on the older TFS it shouldn't, redefining combat objects every time the spell is cast is a bad standard. The combat definitions are as a standard written outside the function for this sole purpose.
 
Even if this would work, which on the older TFS it shouldn't, redefining combat objects every time the spell is cast is a bad standard. The combat definitions are as a standard written outside the function for this sole purpose.

Why exactly? I've done it more than a couple of times on my 0.3.6 TFS and it works and I saw no complications. I haven't bothered to research deeper into it as it gave me no problems, but let me know if there's something really that wrong with it and why it is that way.
(I did actually wonder why all the combats in spells are defined out of the function, seemed pretty odd)
 
Why exactly? I've done it more than a couple of times on my 0.3.6 TFS and it works and I saw no complications. I haven't bothered to research deeper into it as it gave me no problems, but let me know if there's something really that wrong with it and why it is that way.
(I did actually wonder why all the combats in spells are defined out of the function, seemed pretty odd)
It actually worked? When I programmed OT's they restricted defining combat objects inside the function, I see.
Well, it's a standard. Defining them inside the onCastSpell function might not be noticed, but it should be avoided because it is unnecessary.

Logically, the onCastSpell function is called upon when a player casts a spell, if the object definition is inside that function, it will be defined (make calculations and be generally slower) every time a player casts a spell, whilist if defined outside of the onCastSpell function the combat object will be defined only once; when starting the server. In this case, it isn't reloaded every time a player casts a spell, thus making the script lighter and faster. It's the same standard when loading monsters and items, they are read once and loaded instead of loaded every time an item is created or a monster is summoned.

I hope it makes sense.
Ignazio
 
its not worked..

the whole error:

faila.jpg


With that Script:

Code:
function onCastSpell(cid, var)
local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

local value = getPlayerMagLevel(cid)*2.5 + getPlayerLevel(cid) -- Define your formula here
local ticks= 3 -- Enter the amount of seconds between each damage tick
local repeats = 25 -- Enter the amount of times you want this damage to repeat

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, repeats, ticks*1000, -value)
setCombatCondition(combat, condition)

return doCombat(cid, combat, var)
end

For Remeber its for TFS 1.0
 
its not worked..

the whole error:

faila.jpg


With that Script:

Code:
function onCastSpell(cid, var)
local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

local value = getPlayerMagLevel(cid)*2.5 + getPlayerLevel(cid) -- Define your formula here
local ticks= 3 -- Enter the amount of seconds between each damage tick
local repeats = 25 -- Enter the amount of times you want this damage to repeat

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, repeats, ticks*1000, -value)
setCombatCondition(combat, condition)

return doCombat(cid, combat, var)
end

For Remeber its for TFS 1.0


I guess it can't be done that way on 1.0.
Works for me on 0.3.6 as you can see here for example:

Code:
function onCastSpell(cid, var)

    if getSwordsmanMark(cid) == MARK_OF_BLOOD then
        local damagevalue = getPlayerWeaponAttack(cid)
       
        local combat = createCombatObject()
        setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
        setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
        setCombatParam(combat, COMBAT_PARAM_EFFECT, 0)

        local condition = createConditionObject(CONDITION_BLEEDING)
        setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
        addDamageCondition(condition, 10, 2000, -damagevalue)
        setCombatCondition(combat, condition)
       
        doEff(getThingPos(getCreatureTarget(cid)), 182)
        doEff(getThingPos(getCreatureTarget(cid)), 220)
        doEff(getThingPos(getCreatureTarget(cid)), 219)
        return doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, "You can only activate this spell while [Mark of Blood] is active.")
    end
   
end

But eh, I guess someone else will have to give you a solution for that :(
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)

local condition = Condition(CONDITION_ENERGY)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)

local ticks = 3 -- Enter the amount of seconds between each damage tick
local repeats = 25 -- Enter the amount of times you want this damage to repeat

function onCastSpell(creature, var)
    local value = (creature:getMagicLevel() * 2.5) + creature:getLevel() -- Define your formula here
    condition:addDamage(repeats, ticks * 1000, -value)
    combat:setCondition(condition)
    return combat:execute(creature, var)
end
 
Back
Top