UniquePower : OnHit, targeting problem
badstrref
Member Posts: 124
I'm trying to build special weapons with unique (scripted) on-hits effects, so far I had not stumbled upon any problem as long as the target was always single, the direct target of the attacker.
I have no idea why, maybe its a small error from me that I cannot understand atm, but in essence : targeting creatures through loops, from tagbased UniquePower-OnHit scripts reveals to be problematic and the list of creatures returned in the map are not always complete, thus not reliable.
This problem specifically happen in on-hit scripts, the very same verbatim script copied and used in a spell script and cast normally, or onActivate item will run without any problem and all creatures will be targeted successfully.
I've tested cursesong, chain lightning on on-hit weapons just for testing purposes, and they had the same targeting problems while working correctly in spells scripts.
This is very strange to me, maybe I'm too close to the thing that I'm blinded and the problem is ridiculously simple?
I have no idea why, maybe its a small error from me that I cannot understand atm, but in essence : targeting creatures through loops, from tagbased UniquePower-OnHit scripts reveals to be problematic and the list of creatures returned in the map are not always complete, thus not reliable.
This problem specifically happen in on-hit scripts, the very same verbatim script copied and used in a spell script and cast normally, or onActivate item will run without any problem and all creatures will be targeted successfully.
I've tested cursesong, chain lightning on on-hit weapons just for testing purposes, and they had the same targeting problems while working correctly in spells scripts.
This is very strange to me, maybe I'm too close to the thing that I'm blinded and the problem is ridiculously simple?
1
Comments
you can try a simple
and see, as in the picture : a limited amount of target are found and targeted (sometimes just one)
Another problem I've found but can't reproduce (without on-hit weapons but using simple dev crit), if I attack target A and then cancel and then attack target B, if i dev crit target B, target A dies. not sure if related but all these problems set me off developping further my module.
1 secondary target per level is struck for 1d6 / 2 caster levels.
Probably nothing to do with it, but thought I'd throw it out there.
-JFK
that character is level 31,
here another test with
4 out of 6 targets are cursed :
And a simple custom on-hit weapon used in my first post :
Thanks for your help!
Somehow your code gives better results, only 1-2 are avoided now, still the problem persist
I noticed that you had a few placeables circled in your screenshots, you will need to change OBJECT_TYPE_CREATURE to OBJECT_TYPE_ALL to include them.
Where any of the creatures dying? Perhaps that messed it up.
Try this and let me know what happens.
but that failed for some reason, so i tried with GetFirstObjectInArea & build up
@driller : results for your script (btw they are not placeables but CEP golems)
Here is a version using chat command : (note their scritped on hit (single target) works perfectly)
Here using on activate item : (first it finds everything, then fails)
At one point, I had commented out your function and used my own and it worked. I then changed my function a line at a time(trying to pinpoint the issue) to match yours and it stilled worked and yours wouldn't even though they were identical.
Very interesting bug going on here.
What I like to do, is in the onphysicallyattacked script, have a function that checks the attacker's weapon for a string variable, and if it exists run a script with the corresponding string. That way you can cleanly pass the attacker and the attackee to the script, and then in the script itself you can acquire more targets etc as needed.
This also allows you to put in a 'chance' of the on hit effect, instead of having super-mega-god-beam-firestorms every single time the player attacks the target. Also allows for instantly easy replacement of onhit skills just by changing the LocalVariableString on the weapon.
I needed this also for PvP, and it worked before, I didnt bother any further, I will reinstall if I have an interest bump for this game again,
thanks for your help