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

TFS 1.X+ Spells onTargetCreature not found

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,339
Solutions
68
Reaction score
1,023
TFS 1.4.2/1.5

Lua:
local combats = {}


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

for i = 1, 4 do
    combats[i] = Combat()
    combats[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combats[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
    combats[i]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
    combats[i]:setArea(createCombatArea({
    {0, 1, 0},
    {1, 2, 1},
    {0, 1, 0}
    }))
  
    combats[i]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, string.format("onGetFormulaValues%s", i))
end

local function castSpell(combat, creature, variant)
    creature = Creature(creature)
    if creature and variant then
        local min = (creature:getLevel() / 80) + (creature:getMagicLevel() * 0.3) + 2
        local max = (creature:getLevel() / 80) + (creature:getMagicLevel() * 0.6) + 4
        local damage = math.random(math.floor(min), math.floor(max))
        local seconds = 5
        local count = 1
      
        local targets = combat:getTargets(creature, variant)
        if targets and #targets > 0 then
            for _, target in ipairs(combat:getTargets(creature, variant)) do
                if target and target:isPlayer() then
                    creature:addDamageCondition(target, CONDITION_FIRE, DAMAGELIST_CONSTANT_PERIOD, damage, seconds, count)
                end
            end
        end
  
        combat:execute(creature, variant)
    end
end

function onCastSpell(creature, variant)
    for i = 1, 4 do
        addEvent(castSpell, (i - 1) * 1000, combats[i], creature, variant)
    end
    return true
end

1713752402786.png

Any ideas? Its not line 40

The spell casts fine, does damage on initial hits but should add a condition when it hits for burn damage. The burn damage doesn't work which these errors are clearly linked too.

Something in this part
Lua:
 local targets = combat:getTargets(creature, variant)
        if targets and #targets > 0 then
            for _, target in ipairs(combat:getTargets(creature, variant)) do
                if target and target:isPlayer() then
                    creature:addDamageCondition(target, CONDITION_FIRE, DAMAGELIST_CONSTANT_PERIOD, damage, seconds, count)
                end
            end
        end
Post automatically merged:

Solved
Lua:
local combats = {}
local conditions = {}
local combatCount = 4

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

for i = 1, combatCount do
    combats[i] = Combat()
    combats[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combats[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE)
    combats[i]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
    combats[i]:setArea(createCombatArea({
    {0, 1, 0},
    {1, 2, 1},
    {0, 1, 0}
    }))
    
    combats[i]:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, string.format("onGetFormulaValues%s", i))
    
    conditions[i] = Condition(CONDITION_FIRE)
    conditions[i]:setTicks(5000)
    conditions[i]:setParameter(CONDITION_PARAM_SUBID, 1)
    conditions[i]:setParameter(CONDITION_PARAM_TICKINTERVAL, 1000)
    
end

local function castSpell(combat, creature, variant)
    if creature and variant then
        combat:execute(creature, variant)
    end
end

function onCastSpell(creature, variant)
    local min = (creature:getLevel() / 80) + (creature:getMagicLevel() * 0.3) + 2
    local max = (creature:getLevel() / 80) + (creature:getMagicLevel() * 0.6) + 4

    for i = 1, combatCount do
        conditions[i]:setParameter(CONDITION_PARAM_PERIODICDAMAGE, math.random(min,max))
        combats[i]:addCondition(conditions[i])
        addEvent(castSpell, (i - 1) * 1000, combats[i], creature, variant)
    end
    return true
end
 
Last edited:
Back
Top