SpellHeal LUA

Creating the Spells and Abilities for EQ2Emulator

Moderator: Team Members

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

SpellHeal LUA

Post by Jabantiz » Thu Dec 05, 2013 5:28 pm

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

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: SpellHeal LUA

Post by Zcoretri » Thu Dec 05, 2013 8:20 pm

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.

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: SpellHeal LUA

Post by thefoof » Thu Dec 05, 2013 8:23 pm

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.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: SpellHeal LUA

Post by Jabantiz » Thu Dec 05, 2013 8:37 pm

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.

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: SpellHeal LUA

Post by thefoof » Thu Dec 05, 2013 8:40 pm

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

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: SpellHeal LUA

Post by Jabantiz » Thu Dec 05, 2013 8:59 pm

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)

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: SpellHeal LUA

Post by thefoof » Thu Dec 05, 2013 9:06 pm

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.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: SpellHeal LUA

Post by Jabantiz » Thu Dec 05, 2013 11:13 pm

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)

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: SpellHeal LUA

Post by John Adams » Fri Dec 06, 2013 6:54 am

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?

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: SpellHeal LUA

Post by Jabantiz » Fri Dec 06, 2013 8:40 am

"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.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: SpellHeal LUA

Post by John Adams » Fri Dec 06, 2013 9:13 am

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?

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: SpellHeal LUA

Post by Jabantiz » Fri Dec 06, 2013 12:39 pm

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.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: SpellHeal LUA

Post by John Adams » Fri Dec 06, 2013 12:52 pm

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" :mrgreen: I'd just like to try and understand.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: SpellHeal LUA

Post by Jabantiz » Fri Dec 06, 2013 1:04 pm

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.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: SpellHeal LUA

Post by John Adams » Fri Dec 06, 2013 1:27 pm

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).

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests