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

Cast spell effect three times with different x,y,z

SixNine

Active Member
Joined
Dec 12, 2018
Messages
484
Reaction score
46
TFS 1.2
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)


local area = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}

combat:setArea(createCombatArea(area))

function onGetFormulaValues(player, level, maglevel)
    local min = (level * 10) + (maglevel * 15.5) + 25
    local max = (level * 10) + (maglevel * 25) + 50
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    sendCustomMagicEffect(creature:getPosition(), 47, 2, 0)
    return combat:execute(creature, variant)
end
I need to call this same effect
sendCustomMagicEffect(creature:getPosition(), 47, 2, 0)
three times with different posistions and keep same hit range
 
Solution
can be done much simpler
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(orig_pos, 47, 2, 0)
sendCustomMagicEffect(orig_pos + Position(0, 1, 0), 47, 2, 0)
sendCustomMagicEffect(orig_pos + Position(0, -1, 0), 47, 2, 0)
"I guess" :D First of all i already knew how to call effect on every area that has value 1 so you taught me nothing. Call effect three times and apply different x,y,z for each of them and still be able to keep same hit range its not even similar, but still i appreciate that zero help.
Don't know why you started a new thread for the same issue, so I just quoted your last comment in the previous thread.

Be courteous to those attempting to help you.

---------------------

I know how to do this in 0.3.7.. but I can't find any good resources with some quick searching on how to use positional data properly in tfs 1.2
Probably because I don't know what to search for though.

This is my best guess without a server to test code with
might error, I dunno
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2], orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] + 1, orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] - 1, orig_pos[3]), 47, 2, 0)
 
Don't know why you started a new thread for the same issue, so I just quoted your last comment in the previous thread.

Be courteous to those attempting to help you.

---------------------

I know how to do this in 0.3.7.. but I can't find any good resources with some quick searching on how to use positional data properly in tfs 1.2
Probably because I don't know what to search for though.

This is my best guess without a server to test code with
might error, I dunno
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2], orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] + 1, orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] - 1, orig_pos[3]), 47, 2, 0)
My last post was deleted by admin due (bumping thread without waiting 24 hours which is false). I will try it out.

Edit:
Untitled.png
 
Last edited:
The problem is with this:
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2], orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] + 1, orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] - 1, orig_pos[3]), 47, 2, 0)

Rather with two last lines. It doesn't perform arithmetic calculation on an empty value.

Try:
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(Position(orig_pos[1].x, orig_pos[2].y, orig_pos[3].z), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1].x, orig_pos[2].y + 1, orig_pos[3].z), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1].x, orig_pos[2].y - 1, orig_pos[3].z), 47, 2, 0)
 
The problem is with this:
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2], orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] + 1, orig_pos[3]), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1], orig_pos[2] - 1, orig_pos[3]), 47, 2, 0)

Rather with two last lines. It doesn't perform arithmetic calculation on an empty value.

Try:
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(Position(orig_pos[1].x, orig_pos[2].y, orig_pos[3].z), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1].x, orig_pos[2].y + 1, orig_pos[3].z), 47, 2, 0)
sendCustomMagicEffect(Position(orig_pos[1].x, orig_pos[2].y - 1, orig_pos[3].z), 47, 2, 0)
attempt to index a nil value stack traceback
 
can be done much simpler
LUA:
local orig_pos = creature:getPosition()
sendCustomMagicEffect(orig_pos, 47, 2, 0)
sendCustomMagicEffect(orig_pos + Position(0, 1, 0), 47, 2, 0)
sendCustomMagicEffect(orig_pos + Position(0, -1, 0), 47, 2, 0)
 
Solution

Similar threads

Back
Top