• 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.3 Spell 'getTargetPosition' (a nil value)

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
TFS 1.3

Guys, I need a little help with this spell I'm trying to create.

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 47)
setCombatArea(combat0_Brush,createCombatArea({{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}))

function onGetFormulaValues(player, level, magicLevel)
    local min = ((level / 5) + (magicLevel * 1.4) + 8)
    local max = ((level / 5) + (magicLevel * 2.2) + 14)
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, cid, variant)
local parameters = { cid = cid, var = var}

local position = {x=getTargetPosition(cid).x, y=getTargetPosition(cid).y, z=getTargetPosition(cid).z}
doSendMagicEffect(position, 79)
    return combat:execute(creature, cid, variant)
end

I'm trying to make the effect to appear on the target with the position x,y,z, but it keep appearing this error:

Lua Script Error: [Spell Interface]
data/spells/scripts/attack/explosivaeelectricaaranea.lua:eek:nCastSpell
data/spells/scripts/attack/explosivaeelectricaaranea.lua:23: attempt to call global 'getTargetPosition' (a nil value)
stack traceback:
[C]: in function 'getTargetPosition'
data/spells/scripts/attack/explosivaeelectricaaranea.lua:23: in function <data/spells/scripts/attack/explosivaeelectricaaranea.lua:20>

I also tried:

Lua:
local parameters = { cid = cid, var = var}

local position = {x=getCreaturePosition(cid).x, y=getCreaturePosition(cid).y, z=getCreaturePosition(cid).z}
doSendMagicEffect(position, 79)
 
Solution
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 47)
setCombatArea(combat0_Brush,createCombatArea({{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}))

function onGetFormulaValues(player, level, magicLevel)
    local min = ((level / 5) + (magicLevel * 1.4) + 8)
    local max = ((level / 5) + (magicLevel * 2.2) + 14)
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, cid, variant)
local parameters = { cid = cid, var = var}

local target = creature:getTarget()
if...

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,514
Solutions
116
Reaction score
1,775
local target = creature:getTarget()
If target then
local pos = target:getPosition()
pos:sendMagicEffect(79)
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
[Warning - Event::checkScript] Can not load script: scripts/attack/explosivaeelectricaaranea.lua
data/spells/scripts/attack/explosivaeelectricaaranea.lua:23: '=' expected near 'target'
I probably didn't do it right:

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 47)
setCombatArea(combat0_Brush,createCombatArea({{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}))

function onGetFormulaValues(player, level, magicLevel)
    local min = ((level / 5) + (magicLevel * 1.4) + 8)
    local max = ((level / 5) + (magicLevel * 2.2) + 14)
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, cid, variant)

local target = creature:getTarget()
If target then
local position = {x=getTargetPosition(cid).x, y=getTargetPosition(cid).y, z=getTargetPosition(cid).z}
doSendMagicEffect(position, 79)
    return combat:execute(creature, cid, variant)
end
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
8,039
Solutions
215
Reaction score
3,884
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 47)
Combat.setArea(combat0_Brush,createCombatArea({{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


function onCastSpell(creature, variant)
    local target = creature:getTarget()
    if target then
        local pos = target:getPosition()
        pos:sendMagicEffect(79)
    end
    return combat:execute(creature, variant)
end
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
295
Solutions
1
Reaction score
37
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 47)
Combat.setArea(combat0_Brush,createCombatArea({{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


function onCastSpell(creature, variant)
    local target = creature:getTarget()
    if target then
        local pos = target:getPosition()
        pos:sendMagicEffect(79)
    end
    return combat:execute(creature, variant)
end
It worked, but I need to change position x,y,z, because I'm using sprite bigger than 32x32. So I use this line to center the effect when I use in other script
local parameters = { cid = cid, var = var}

local position = {x=getTargetPosition(cid).x, y=getTargetPosition(cid).y, z=getTargetPosition(cid).z}
doSendMagicEffect(position, 79)
The way you put it, I can't change position of the effect
Post automatically merged:

I have this script working for exura and I use position x,y,z:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 1.8) + 11
    return min, max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}

local position = {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
doSendMagicEffect(position, 126)
    return combat:execute(cid, var)
end

I just edited this spell so the effect appear on target, but it won't work
Post automatically merged:

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 47)
Combat.setArea(combat0_Brush,createCombatArea({{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")


function onCastSpell(creature, variant)
local parameters = { cid = cid, var = var}

local position = {x=getCreaturePosition(cid).x, y=getCreaturePosition(cid).y, z=getCreaturePosition(cid).z}
doSendMagicEffect(position, 126)
    return combat:execute(creature, variant)
end

Lua Script Error: [Spell Interface]
data/spells/scripts/attack/explosivaeelectricaaranea.lua:eek:nCastSpell
data/spells/scripts/attack/explosivaeelectricaaranea.lua:24: attempt to index a boolean value
stack traceback:
[C]: in function '__index'
data/spells/scripts/attack/explosivaeelectricaaranea.lua:24: in function <data/spells/scripts/attack/explosivaeelectricaaranea.lua:21>
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,802
Solutions
35
Reaction score
1,002
Location
Germany
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 47)
setCombatArea(combat0_Brush,createCombatArea({{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}}))

function onGetFormulaValues(player, level, magicLevel)
    local min = ((level / 5) + (magicLevel * 1.4) + 8)
    local max = ((level / 5) + (magicLevel * 2.2) + 14)
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, cid, variant)
local parameters = { cid = cid, var = var}

local target = creature:getTarget()
if target then
local position = {x=target:getPosition(cid).x+1, y=target:getPosition(cid).y-1, z=target:getPosition(cid).z}
doSendMagicEffect(position, 79)
end
    return combat:execute(creature, cid, variant)
end
 
Solution
Top