• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [TFS 1.2] Burn condition formula working weirdly

Siegh

Thronar Developer
Joined
Mar 12, 2011
Messages
1,276
Solutions
1
Reaction score
635
Location
Brazil
Hello!

LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, 8)
combat:setParameter(COMBAT_PARAM_EFFECT, 14)

function onCastSpell(creature, variant)
    local burn = Condition(CONDITION_FIRE, CONDITIONID_COMBAT)
    burn:setParameter(CONDITION_PARAM_DELAYED, true)
    burn:addDamage(10, 1000, -((creature:getMagicLevel()*0.3)+(creature:getLevel()*3))) 
    burn:setParameter(CONDITION_PARAM_SUBID, 161)
    combat:setCondition(burn)
    --
    combat:execute(creature, variant)
    return true
end

I have this spell where it applies a burn DoT to enemies. The burn values increase according to a formula considering the caster's level and magic level.

The issue is: after someone in the server cast this spell, the highest value a player has reached with it will be applied to every single other cast of the spell (???). For example: me with magic level 30 cast it, apply X damage. Every player who also cast it, even if they have 0 magic level, will apply the same X damage on their spells.

I've tried adding SUBID and CONDITIONID_COMBAT on it in order to prevent it from happening without any success.

How can I make sure the calculation is unique to every singular cast of the spell?
 
Remove
LUA:
((creature:getMagicLevel()*0.3)+(creature:getLevel()*3)))
Put value ex: -30


LUA:
burn:addDamage(10, 1000, -30)

That won't have the damage scaling with the player values but make it fixed, which is not my intention.
 
That won't have the damage scaling with the player values but make it fixed, which is not my intention.
Oh ok, add callback functiom if enter parameter "callbackfunc(value)" recalculate.
And add condition owner player id for secury without bug.
LUA:
condition:setParameter(CONDITION_PARAM_OWNER, player:getId())
 
LUA:
    function setBurnDamage(creature, target)  
        local burn = Condition(CONDITION_FIRE, CONDITIONID_COMBAT)
        burn:setParameter(CONDITION_PARAM_DELAYED, true)
        burn:addDamage(10, 1000, -(((creature:getMagicLevel()*0.3)+(creature:getLevel()*3))*multiplier))  
        burn:setParameter(CONDITION_PARAM_SUBID, 161)
        burn:setParameter(CONDITION_PARAM_OWNER, creature:getId())
        combat:setCondition(burn)
        return true
    end
    combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "setBurnDamage")

I've tried it like this but still experiencing the same issue, future casts still seem to remember my previous one even though I had a different magic level.
 
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)

local SPELL_SUBID = 161
local TICKS = 10
local INTERVAL = 1000

local function recallBurn(cid, targetId, tick)
    local player = Player(cid)
    local target = Creature(targetId)

    if not player or not target then
        return
    end

    if target:getCondition(CONDITION_FIRE, CONDITIONID_COMBAT, SPELL_SUBID) then
        local ml = player:getMagicLevel()
        local level = player:getLevel()

        local damage = math.floor(((ml * 0.4) + (level * 2)) * tick)

        doTargetCombatHealth(
            player,
            target,
            COMBAT_FIREDAMAGE,
            -damage,
            -damage,
            CONST_ME_HITBYFIRE
        )

        addEvent(recallBurn, INTERVAL, cid, targetId, tick + 1)
    end
end

function onTargetCreature(creature, target)
    if not creature or not target then
        return true
    end

    local condition = Condition(CONDITION_FIRE)
    condition:setParameter(CONDITION_PARAM_SUBID, SPELL_SUBID)
    condition:setParameter(CONDITION_PARAM_OWNER, creature:getId())
    condition:setParameter(CONDITION_PARAM_DELAYED, true)
    condition:setTicks(TICKS * INTERVAL)

    target:addCondition(condition)

    addEvent(recallBurn, INTERVAL, creature:getId(), target:getId(), 1)
    return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
Sorry is addEvent!
 
Back
Top