Page 1 of 2
SpellHeal LUA
Posted: Thu Dec 05, 2013 5:28 pm
by Jabantiz
Working on paladin spells first spell
Faith Strike is damage to target and heal to caster. The way spell heal works is it will use the spell's target, not the provided target param, so it actually heals the enemy and not the caster. A lot of spell related lua does the same, and it is needed in some cases for AE targets. How should we handle situations like this? a new param to force the use of the target we provided? only use the spells targets if the target param is null?
Here is the script for reference
Code: Select all
function cast(Caster, Target, DDType, MinDmg, MaxDmg, HealAmt)
-- DD Component
if MaxDmg ~= nil and MinDmg < MaxDmg then
dmgAmount = math.random(MinDmg, MaxDmg)
SpellDamage(Target, DDType, dmgAmount)
else
SpellDamage(Target, DDType, MinDmg)
end
-- Heal Component
if HealAmt ~= nil then
SpellHeal(Caster, "Heal", HealAmt, HealAmt)
end
end
Re: SpellHeal LUA
Posted: Thu Dec 05, 2013 8:20 pm
by Zcoretri
I don't think there is server support for spells that are set to 'Enemy' or 'Any' and have a beneficial spell land on the caster.
Re: SpellHeal LUA
Posted: Thu Dec 05, 2013 8:23 pm
by thefoof
I would say just switch the if that checks for the target param first and the elseif to use the luaspell's targets. The only reason I made SpellHeal the way it is, is because that's how SpellDamage was setup, doesn't make much sense to do it that way looking at it now lol.
Re: SpellHeal LUA
Posted: Thu Dec 05, 2013 8:37 pm
by Jabantiz
thefoof wrote:The only reason I made SpellHeal the way it is, is because that's how SpellDamage was setup, doesn't make much sense to do it that way looking at it now lol.
There are several others besides SpellDamage that do the same, and I understand why, lua script will only be called once for an AE spell and doing it like this allows the effect to be applied to all targets of the spell, instead of looping through the targets and calling the lua multiple times.
I don't know how often this function has been used so not sure if flipping the if like you suggested will break other scripts or cause unintended effects.
Re: SpellHeal LUA
Posted: Thu Dec 05, 2013 8:40 pm
by thefoof
Oh I know, it's just weird that you supply the target at all if 99% of the time it doesn't get used it what I mean. This has to be used from a spellscript to work properly I believe so I can't really see a situation where the luaspell's targets wouldn't be > 0
Re: SpellHeal LUA
Posted: Thu Dec 05, 2013 8:59 pm
by Jabantiz
Went ahead and flipped the if like you suggested and committed the code.
For every one else if you want to heal a specific target that doesn't match the spell's targets you would call it like we have been.
Code: Select all
SpellHeal(Caster, "Heal", HealAmt, HealAmt)
If you want it to heal the spell's targets you would pass a 0 or nil as the first param
Code: Select all
SpellHeal(0, "Heal", HealAmt, HealAmt)
Re: SpellHeal LUA
Posted: Thu Dec 05, 2013 9:06 pm
by thefoof
Another thing to add, SpellHeal will be used on THIS exact target if set, implied target makes it's calculations before the cast actually gets sent to it's spellscript.
Re: SpellHeal LUA
Posted: Thu Dec 05, 2013 11:13 pm
by Jabantiz
Moved the target param to the end as it is now an optional param, new format would be
Code: Select all
SpellHeal("Heal", HealAmt, HealAmt)
or
SpellHeal("Heal", HealAmt, HealAmt, Caster)
Re: SpellHeal LUA
Posted: Fri Dec 06, 2013 6:54 am
by John Adams
I am getting massively confused here. First, the params: If the function is called SpellHEAL.... why does there need to be a text value "Heal" passed along? And why 2 HealAmt's, if they are both always the same?
Original functionality, if I am a caster in a GROUP, and I cast a GROUP heal spell, and my target is my tank OR an NPC... the cast_type of GROUP should determine I do not mean to heal the NPC.
Lastly, if I am in a group/raid and I have a tank targeted, and the detrimental part of the spell is a damage, shouldn't Implied Target pass the damage through my targeted tank onto the NPC? or for that matter, any IsEnemy() target if it is AoE?
Are we over-engineering something, or do I just not understand what the problem is here?
Re: SpellHeal LUA
Posted: Fri Dec 06, 2013 8:40 am
by Jabantiz
"Heal" is the type, can also have "Power" and any more we add later that requires the use of the heal packets, it could easily be a int8 where 1 = heal 2 = power and so on. It will also do some calculations based off the casters stats.
The problem we have is the spell we are casting from is a hostile spell, a life tap type spell, we do damage to the target, however we also need to heal the caster. With out the changes made SpellHeal() would heal your target as that was the target of the spell.
I believe I have also run into the same issue with SpellDamage, a self buff with a proc, calling SpellDamage from the proc function appears to damage the caster, target of the spell, I hesitate to change the param order of this function as it has been used a lot already.
Re: SpellHeal LUA
Posted: Fri Dec 06, 2013 9:13 am
by John Adams
Jabantiz wrote:The problem we have is the spell we are casting from is a hostile spell, a life tap type spell, we do damage to the target, however we also need to heal the caster. With out the changes made SpellHeal() would heal your target as that was the target of the spell.
Even if in the LUA script, we use Caster as the parameter for the heal component, it still heals the Target? That doesn't make sense.
Ie, my Faith Strike I did when I did level 1's for all classes:
Code: Select all
--[[
Script Name : Spells/Fighter/Crusader/Paladin/FaithStrike.lua
Script Author : John Adams
Script Date : 2013.11.17 06:11:09
Script Purpose : DD + Heal
:
--]]
function cast(Caster, Target, DDType, MinDmg, MaxDmg, HealAmt)
-- DD Component
if MaxDmg ~= nil and MinDmg < MaxDmg then
dmgAmount = math.random(MinDmg, MaxDmg)
SpellDamage(Target, DDType, dmgAmount)
else
SpellDamage(Target, DDType, MinDmg)
end
-- Heal Component
if HealAmt ~= nil then
ModifyHP(Caster, HealAmt)
end
end
You saying that ModifyHP(Caster, HealAmt) does not put the HealAmt on the one who cast the spell?
Re: SpellHeal LUA
Posted: Fri Dec 06, 2013 12:39 pm
by Jabantiz
ModifyHP will work, but it won't send the packets like SpellHeal does, live sends the heal packets. Also will still have the same issue with SpellDamage for procs in buffs.
Re: SpellHeal LUA
Posted: Fri Dec 06, 2013 12:52 pm
by John Adams
Oh, I must have missed the conversation about the Heal packet. Can you either point me to it, or tell me why we needed it? (I mean vs. just modifying HP as the Heal... is there some UI magic that happens differently?)
It's okay to do things "correctly"

I'd just like to try and understand.
Re: SpellHeal LUA
Posted: Fri Dec 06, 2013 1:04 pm
by Jabantiz
All the packet does is cause the numbers to show overhead as far as I know. Forgot to mention doing a heal through SpellHeal also takes stats into consideration so potency, crits, and all that other stuff.
Also forgot to answer this earlier
And why 2 HealAmt's, if they are both always the same?
It is min/max amounts, in the case of this spell it only has 1 heal amount is passed. The server will do the random so you don't have to in lua.
Re: SpellHeal LUA
Posted: Fri Dec 06, 2013 1:27 pm
by John Adams
Jabantiz wrote:All the packet does is cause the numbers to show overhead as far as I know. Forgot to mention doing a heal through SpellHeal also takes stats into consideration so potency, crits, and all that other stuff.
Ahh, okay that makes more sense. I'll just follow your lead on this one
However, this:
Jabantiz wrote:And why 2 HealAmt's, if they are both always the same?
It is min/max amounts, in the case of this spell it only has 1 heal amount is passed. The server will do the random so you don't have to in lua.
I have to disagree with changing how min/max is handled from LUA. We do not need 2 different ways of handling this, all our scripts should be consistently one way or the other. Things are confusing enough, I do not want to tell people when you do one thing, math.random() it, but if you use this one newer function, send the same value twice. Makes no sense.
Either we do math.random() in LUA (which I am happier with, more control), or we bury the option in code with no possibility to offset a calculation should I feel like getting fancy in my LUA (custom server options).