boby psaico
Member
- Joined
- Oct 17, 2009
- Messages
- 84
- Reaction score
- 5
Hello,
I made a script of a new heal spell like exura sio where the caster is healed at the same time the target is (blocker for example).
The problem is: doesn't matter where the target is located, behind a wall or far away from caster, the spell is ignoring the distance or walls.
I'm not sure about the difference between onCastSpell and onGetFormulaValues functions. My spell uses onCastSpell, the only one that worked well.
On spells.xml:
Here I removed needtarget="1" because if I use it, the server get an error
Could someone help me to develop this spell better?
I guess TFS is 1.0, I couldn't compile a TFS 1.3 yet.
I made a script of a new heal spell like exura sio where the caster is healed at the same time the target is (blocker for example).
The problem is: doesn't matter where the target is located, behind a wall or far away from caster, the spell is ignoring the distance or walls.
I'm not sure about the difference between onCastSpell and onGetFormulaValues functions. My spell uses onCastSpell, the only one that worked well.
Lua:
function onCastSpell(creature, variant)
local level = getPlayerLevel(creature)
local maglevel = getPlayerMagLevel(creature)
local min = (level / 20) + (maglevel * 6.3) + 45
local max = (level / 20) + (maglevel * 14.4) + 90
local heal = math.random(min,max)
--friend
local target = Player(variant:getString())
local targetPosition = target:getPosition() --friend
local creaturePosition = creature:getPosition() --druid
if target:getName() == creature:getName() then --druid
doCreatureAddHealth(creature,heal)
doSendMagicEffect(getThingPos(creature), CONST_ME_MAGIC_BLUE)
else
targetPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
creaturePosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
doCreatureAddHealth(creature,heal)
doCreatureAddHealth(target,heal)
end
return true
end
On spells.xml:
XML:
<instant group="healing" spellid="84" name="Heal Self Friend" words="exura gran sio" lvl="18" mana="200" prem="1" aggressive="0" blockwalls="1" playernameparam="1" params="1" exhaustion="1000" groupcooldown="1000" needlearn="0" script="healing/heal self friend.lua">
<vocation name="Druid" />
<vocation name="Elder Druid" />
</instant>
Here I removed needtarget="1" because if I use it, the server get an error
Code:
attempt to index local 'target' (a nil value)
Could someone help me to develop this spell better?
I guess TFS is 1.0, I couldn't compile a TFS 1.3 yet.