• 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+ Spell Interface fuction getTargets a nil value

olekpro

Member
Joined
Nov 1, 2014
Messages
121
Reaction score
6
TFS 1.2

Lua Script Error: [Spell Interface]
data/spells/scripts/monster/silencer_skill_reducer.lua:eek:nCastSpell
data/spells/scripts/monster/silencer_skill_reducer.lua:14: attempt to call method 'getTargets' (a nil value)
stack traceback:
[C]: in function 'getTargets'
data/spells/scripts/monster/silencer_skill_reducer.lua:14: in function <data/spells/scripts/monster/silencer_skill_reducer.lua:11>




Lua Script Error: [Spell Interface]
data/spells/scripts/monster/shock_head_skill_reducer_1.lua:eek:nCastSpell
data/spells/scripts/monster/shock_head_skill_reducer_1.lua:12: attempt to call method 'getTargets' (a nil value)
stack traceback:
[C]: in function 'getTargets'
data/spells/scripts/monster/shock_head_skill_reducer_1.lua:12: in function <data/spells/scripts/monster/shock_head_skill_reducer_1.lua:11>



Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
combat:setArea(createCombatArea(AREA_CIRCLE2X2))

local parameters = {
    {key = CONDITION_PARAM_TICKS, value = 6 * 1000},
    {key = CONDITION_PARAM_SKILL_SHIELDPERCENT, value = 65}
}

function onCastSpell(creature, variant)
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        target:addAttributeCondition(parameters)
    end
    return true
end

How to fix it?
 
Solution
That is the main one from TFS 1.2, its supposed to work.
Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 6000)
condition:setParameter(CONDITION_PARAM_SKILL_SHIELDPERCENT, 65)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
combat:setArea(createCombatArea(AREA_CIRCLE2X2))
combat:setCondition(condition)

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
That is the main one from TFS 1.2, its supposed to work.
Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 6000)
condition:setParameter(CONDITION_PARAM_SKILL_SHIELDPERCENT, 65)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
combat:setArea(createCombatArea(AREA_CIRCLE2X2))
combat:setCondition(condition)

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
 
Solution
It looks like he's using newish code as a Google search leads to this where we can see combat:getTargets being a thing. I'll have to look at it further. But I'm guessing he's using /data that's newer than his compiled executable.

Your solution M0ustafa should certainly stop the error.

update: I'm almost certain now, as the current code for that file is what he put in the OP.
 
Last edited:
Back
Top