Lua SPell targeting Discussion
Moderator: Team Members
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Lua SPell targeting Discussion
this post is to discuss the issues with lua spell targeting, I know [mention]Cynnar[/mention] and [mention]Jabantiz[/mention] mention some to me but i think it would be good to have a specific place to discuss whats wrong with it
please be specific with the issue, ie when i target mob A with Spell B it damges MOB B ype of thing so we can recreate and do whats neccary to fix it
we need the target you are targeting, the spell name, and the lua script at a minimum along with the description of the problem
thanks
please be specific with the issue, ie when i target mob A with Spell B it damges MOB B ype of thing so we can recreate and do whats neccary to fix it
we need the target you are targeting, the spell name, and the lua script at a minimum along with the description of the problem
thanks
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: Lua SPell targeting Discussion
did some checking, and this is the way i undrstand as coded
when you cast a spell and the spell is processed ( before it runs the spell script)
the target list for the spell is created based on the settings of the spelland what you are targeting so a blue aoe with max targets of 8 will be the targets vector for the spell, a green AOE will have the target enimies group in the targets vector
if you are casting a single target spell
when you cast a damage spell is will use that list of enemies as it should, in normal situations
the target sent to the lua script is the specific target you have targeted,
there is more
truthfully i thinkit jsut needs a little twekaing and making sure spell are enter correclty
when you cast a spell and the spell is processed ( before it runs the spell script)
the target list for the spell is created based on the settings of the spelland what you are targeting so a blue aoe with max targets of 8 will be the targets vector for the spell, a green AOE will have the target enimies group in the targets vector
if you are casting a single target spell
when you cast a damage spell is will use that list of enemies as it should, in normal situations
the target sent to the lua script is the specific target you have targeted,
there is more
truthfully i thinkit jsut needs a little twekaing and making sure spell are enter correclty
- Cynnar
- Project Leader
- Posts: 738
- Joined: Sat Sep 27, 2014 1:22 am
- EQ2Emu Server: Eq2emulator
- Characters: Vlash
Veinlash
Taragak
Cynnar
Re: Lua SPell targeting Discussion
I don't know much about it except [mention]Jabantiz[/mention] and I were discussing that whatever is put in the spells Lua it's replaced with target. A Lua function that this is noted on is the AddSpellBonus().
That and the freaking pet taking damage when casting on a mob.
That and the freaking pet taking damage when casting on a mob.
[ 01000011 01111001 01101110 01101110 01100001 01110010 ]
Follow on:
Twitter Facebook
Contact me:
PM Discord chat email
Hardware: the parts of a computer that can be kicked
Follow on:
Twitter Facebook
Contact me:
PM Discord chat email
Hardware: the parts of a computer that can be kicked
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: Lua SPell targeting Discussion
if you want to add a spellbonus to the specific target and ignore the targets the spell is selecting for you , than useCynnar wrote: Thu May 02, 2019 10:22 pm I don't know much about it except @Jabantiz and I were discussing that whatever is put in the spells Lua it's replaced with target. A Lua function that this is noted on is the AddSpellBonus().
That and the freaking pet taking damage when casting on a mob.
AddSpawnSpellBonus(Caster, 0, 12)
Same as AddSpellBonus() however it will only apply to the given spawn and will ignore the spells targets.
still as far as i can tell AddSpellBonus() is working correctly by changing the target to the target list based on the spell and the selected target
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: Lua SPell targeting Discussion
lua spell SpellDamage() also will use the spells target, this is be design and how it should work, unless there is a specific case for sowmthing different
from the wikia, and confirmed in code
If used in a spell script it will attempt to use the spells targets to do the damage
from the wikia, and confirmed in code
If used in a spell script it will attempt to use the spells targets to do the damage
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: Lua SPell targeting Discussion
Yea that was our work around to get around the target parameter being overwritten. I seem to remember doing weird stuff to SpellHeal in order to override the targets as well.
The issue is not all spells apply to the targets of the spell, for example a life tap that damages the target and then heals the caster, this is why we had to screw with SpellHeal because we couldn't just pass caster as the target.
I believe most spells that add procs like a damage shield also suffer from the same problem as the caster and target when the proc triggers is completely different, I think we even came up with a special function for that (ProcDamage?) just so we could get around the targeting issue.
Pretty much we are just adding on hacky code to get around the fact that target parameter of spells our overridden.
The issue is not all spells apply to the targets of the spell, for example a life tap that damages the target and then heals the caster, this is why we had to screw with SpellHeal because we couldn't just pass caster as the target.
I believe most spells that add procs like a damage shield also suffer from the same problem as the caster and target when the proc triggers is completely different, I think we even came up with a special function for that (ProcDamage?) just so we could get around the targeting issue.
Pretty much we are just adding on hacky code to get around the fact that target parameter of spells our overridden.
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: Lua SPell targeting Discussion
well since the spell dictates the target (plus what your targeting, i believe you need those extra luas, or another way to say that you want a non standard target
remember when the Lua commands were designed no one really new all the different combos we need so
just becuase you had to throw together another lua function does not mean it is a bad thing
but an idea would be, to do this
if it is a spell you want to use a specific non standard target(not a spell based target) then we but the spawn id,
if you want it to use the spell based targeting , then we could set the target to 0,
then if target = 0 or null then use spell target if target = target 0r caster then use that
but truth fully i thing an additonal lua function might be better
less if statements in the function
remember when the Lua commands were designed no one really new all the different combos we need so
just becuase you had to throw together another lua function does not mean it is a bad thing
but an idea would be, to do this
if it is a spell you want to use a specific non standard target(not a spell based target) then we but the spawn id,
if you want it to use the spell based targeting , then we could set the target to 0,
then if target = 0 or null then use spell target if target = target 0r caster then use that
but truth fully i thing an additonal lua function might be better
less if statements in the function
- Cynnar
- Project Leader
- Posts: 738
- Joined: Sat Sep 27, 2014 1:22 am
- EQ2Emu Server: Eq2emulator
- Characters: Vlash
Veinlash
Taragak
Cynnar
Re: Lua SPell targeting Discussion
So why do we have the overwrite in place?Jabantiz wrote: Fri May 03, 2019 3:24 pm Pretty much we are just adding on hacky code to get around the fact that target parameter of spells our overridden.
Seems to me we should use the parameter like it's designed. If I want to use on a target then we use Target, if I want to use on player then I use Caster.
[ 01000011 01111001 01101110 01101110 01100001 01110010 ]
Follow on:
Twitter Facebook
Contact me:
PM Discord chat email
Hardware: the parts of a computer that can be kicked
Follow on:
Twitter Facebook
Contact me:
PM Discord chat email
Hardware: the parts of a computer that can be kicked
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: Lua SPell targeting Discussion
becuase when you cast a spell and target a mob not all spells are single target, you have group spells, green AOE(up to 6 targets (24 if raid)Cynnar wrote: Fri May 03, 2019 4:01 pmSo why do we have the overwrite in place?Jabantiz wrote: Fri May 03, 2019 3:24 pm Pretty much we are just adding on hacky code to get around the fact that target parameter of spells our overridden.
Seems to me we should use the parameter like it's designed. If I want to use on a target then we use Target, if I want to use on player then I use Caster.
blue AOE's any thing in area with range and # of targets, we cannot determine those targets in lua so when the lua spell is built it determines most of the targets based on the spell parameters
i mean we could if we wanted pass the target list to the script, and then parse that target list and put a spelldamage function for each one of them but why do we want more work(and more chances of a mistake in the script when what we have just needs tweaking or another function that is direct
and just because we add anothe function doesnt neccesarily mean its a hack job, if its written properly and does what it is supposed to do
- Cynnar
- Project Leader
- Posts: 738
- Joined: Sat Sep 27, 2014 1:22 am
- EQ2Emu Server: Eq2emulator
- Characters: Vlash
Veinlash
Taragak
Cynnar
Re: Lua SPell targeting Discussion
So this is the reason that we convert the target parameter to Target instead of what is used in the list function?Ememjr wrote: Fri May 03, 2019 4:04 pm becuase when you cast a spell and target a mob not all spells are single target
[ 01000011 01111001 01101110 01101110 01100001 01110010 ]
Follow on:
Twitter Facebook
Contact me:
PM Discord chat email
Hardware: the parts of a computer that can be kicked
Follow on:
Twitter Facebook
Contact me:
PM Discord chat email
Hardware: the parts of a computer that can be kicked
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: Lua SPell targeting Discussion
That is how it has always been even before I started helping on the project. I don't think there were really any spells back then either so at the time who ever made it that way probably didn't realize how complicated spells can get in this game. Hell I didn't realize it either until I tried scripting a few.
This is what I was debating changing with Cynnar but we haven't decided on anything yet.Ememjr wrote: Fri May 03, 2019 4:04 pm becuase when you cast a spell and target a mob not all spells are single target, you have group spells, green AOE(up to 6 targets (24 if raid)
blue AOE's any thing in area with range and # of targets, we cannot determine those targets in lua so when the lua spell is built it determines most of the targets based on the spell parameters
Basically I see two options for a change like this, we either pass the target parameter as an array of Spawns instead of just a single spawn like we do now, this means LUA code would have to be rewritten for all spells to handle the target parameter as an array.
The other option was to call the cast/tick/remove function with a single target like we do now but call it once for every spell target. It seems like this way may be a performance hit but I couldn't find any info about the cost to call a lua script. This way would let us keep the spell scripts as they are.
Either way it would require all spell lua functions to be reworked to not override the target parameter.
Again these were just ideas and we may not even go through with them and continue to work around the targets being overwritten.
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: Lua SPell targeting Discussion
IMHO if the spell is in the db correct as in the correct target_type, and correct options, as in friendly, affects raid, only affects group, and group spell
most of the spells work correctly with the
add spell bonus, heals, and damage
we use the current function allready made for spellspawn damage when we need to use a direct spawn its easy and its theier, and not to much changing needed
it gets all the intended targets
we do the same with a heal
most of the spells work correctly with the
add spell bonus, heals, and damage
we use the current function allready made for spellspawn damage when we need to use a direct spawn its easy and its theier, and not to much changing needed
it gets all the intended targets
we do the same with a heal
-
tyrbo
- Team Member
- Posts: 271
- Joined: Thu Feb 18, 2016 12:33 pm
Re: Lua SPell targeting Discussion
In my C++ version, I just called the script for each target of the spell.
In my Rust rewrite, I'm presently passing in an array of targets.
With calling the functions with each target of a spell, it worked pretty well. You do run into some complicated spells like Holy Circle, which does AOE damage and a group heal. In situations like that, you might have to split up the spell in to multiple spells to handle the different friendly / hostile behaviors.
In my Rust rewrite, I'm presently passing in an array of targets.
With calling the functions with each target of a spell, it worked pretty well. You do run into some complicated spells like Holy Circle, which does AOE damage and a group heal. In situations like that, you might have to split up the spell in to multiple spells to handle the different friendly / hostile behaviors.
- Ememjr
- Team Member
- Posts: 975
- Joined: Wed Mar 15, 2017 9:41 am
- EQ2Emu Server: Perseverance
Re: Lua SPell targeting Discussion
another option, looking through the codetheir seems to be a spot for initial target, we could make use of and then if it works things will work like we want without to much change
it appears that inital target is set during the building of the target list
so you have target 1 (an enemy) targeted and cast an AOE that builds a target list of 6 enemies
your script is sent the target(1)(which is inital target and caster like usual
you use spell damage to the target (1) the exisitng code will still work, but with a check to compare the target that you typed to the existing target
if you do not change it it will work as normal
if you changed the target to anything else then the function will not change to the target list and keep the target you typed
so you do a spell damage to target 2 when target 1 was the inital target then the damage goes to target 2 like you want
so to recap
you specify target 1 in spelldamage and it is = inital target then apply damage to target list like usual
you specify a different target in spell damage and it is not equal to inital target then aplly damage to the different target
the same would work for heals and or spell bonus
your toon is targeting enemy 1
spell script get target of enemy1 and targetlist had 1 enemy of enmy1
you do you spell damage to enemy1
now you want to heal caster
well caster becomes the target, and since the target is nolonger = to the initial target it will cast the heal on the caster
this way from what i am seeing, would be the easiest to implement, and would not require many existing working scripts to change, jus the one that are not working
I still believe running the script for each target is a bad idea how do you handle damage 8 mobs and heal caster, you would run the script 8 times, and yes it would damage each mob 1 but would it not heal the caster 8 times
nor tdo i like the idea of having the script parse the target list and apply damge to each target, that would involve rewritting most of the scripts that now work, and lead the way to bad scripts
it appears that inital target is set during the building of the target list
so you have target 1 (an enemy) targeted and cast an AOE that builds a target list of 6 enemies
your script is sent the target(1)(which is inital target and caster like usual
you use spell damage to the target (1) the exisitng code will still work, but with a check to compare the target that you typed to the existing target
if you do not change it it will work as normal
if you changed the target to anything else then the function will not change to the target list and keep the target you typed
so you do a spell damage to target 2 when target 1 was the inital target then the damage goes to target 2 like you want
so to recap
you specify target 1 in spelldamage and it is = inital target then apply damage to target list like usual
you specify a different target in spell damage and it is not equal to inital target then aplly damage to the different target
the same would work for heals and or spell bonus
your toon is targeting enemy 1
spell script get target of enemy1 and targetlist had 1 enemy of enmy1
you do you spell damage to enemy1
now you want to heal caster
well caster becomes the target, and since the target is nolonger = to the initial target it will cast the heal on the caster
this way from what i am seeing, would be the easiest to implement, and would not require many existing working scripts to change, jus the one that are not working
I still believe running the script for each target is a bad idea how do you handle damage 8 mobs and heal caster, you would run the script 8 times, and yes it would damage each mob 1 but would it not heal the caster 8 times
nor tdo i like the idea of having the script parse the target list and apply damge to each target, that would involve rewritting most of the scripts that now work, and lead the way to bad scripts
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: Lua SPell targeting Discussion
I like this idea as it would only require rewriting the spell LUA functions and wouldn't make multiple calls to the scriptEmemjr wrote: Mon May 06, 2019 10:21 am another option, looking through the codetheir seems to be a spot for initial target, we could make use of
Yea I didn't really like this idea either because there is bound to be a performance impact, may not be noticeable at first but if a server ever gets a lot of players and they all happen to be casting aoe spells the call count to the script would be insane.Ememjr wrote: Mon May 06, 2019 10:21 am I still believe running the script for each target is a bad idea how do you handle damage 8 mobs and heal caster, you would run the script 8 times, and yes it would damage each mob 1 but would it not heal the caster 8 times
It would actually mean rewriting all scripts as the parameter would be an array now and not just a single pointer so even single target spells would need to be changed to handle the array.Ememjr wrote: Mon May 06, 2019 10:21 am nor do i like the idea of having the script parse the target list and apply damge to each target, that would involve rewritting most of the scripts that now work, and lead the way to bad scripts
Who is online
Users browsing this forum: No registered users and 1 guest