• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Alternative To EVENT_PLAYER_UNIT_ATTACKED

Status
Not open for further replies.
Level 7
Joined
Mar 6, 2006
Messages
282
In my map, it's possible to dodge targeted spells. I'm wondering what's the most efficient way to check if a unit was stuck by a spell.

The obvious way is to make a new trigger with the event EVENT_PLAYER_UNIT_ATTACKED and a condition checking for the specific spell. But wouldn't that run WAY too often? Units are constantly being attacked.. so I was wondering if this was better:

On the actual spell's trigger, it would start a timer, constantly checking if the targeted unit was hit by the spell (with a buff or something). The timer would turn off after like 3 seconds (or however long, based on the nature of the spell), if the target was never hit.

So which way is better?



Side Question: what's faster, IssueTargetOrder or IssueTargetOrderById ?
 
In my map, it's possible to dodge targeted spells. I'm wondering what's the most efficient way to check if a unit was stuck by a spell.

The obvious way is to make a new trigger with the event EVENT_PLAYER_UNIT_ATTACKED and a condition checking for the specific spell. But wouldn't that run WAY too often? Units are constantly being attacked.. so I was wondering if this was better:

On the actual spell's trigger, it would start a timer, constantly checking if the targeted unit was hit by the spell (with a buff or something). The timer would turn off after like 3 seconds (or however long, based on the nature of the spell), if the target was never hit.

So which way is better?

EVENT_PLAYER_UNIT_ATTACKEDisn't accurate afaik, because you can cancel the attack before any damage is done.
What's wrong withEVENT_PLAYER_UNIT_SPELL_EFFECT or using a damage detection system.

If your spell gives the unit a buff I would check for that.

Side Question: what's faster, IssueTargetOrder or IssueTargetOrderById ?

Most likelyIssueTargetOrderById
I could test if you really cared
 
Level 7
Joined
Mar 6, 2006
Messages
282
EVENT_PLAYER_UNIT_ATTACKEDisn't accurate afaik, because you can cancel the attack before any damage is done.
What's wrong withEVENT_PLAYER_UNIT_SPELL_EFFECT or using a damage detection system.

If your spell gives the unit a buff I would check for that.



Most likelyIssueTargetOrderById
I could test if you really cared

I guess I'll be using a detection system then, ty.

Also yeah, it does seem like ById would be faster, I just thought it might be publicly known or something. I thought of it because I see most people use integers, and I was using strings for readability, but I'll switch to integers. That should be part of the jasshelper compiler! Change all the order strings to their respective integers!
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
I'd go with a damage detection, since it's hard to detect an aoe spell damage or a triggered damage since it's not targetted.
 
Status
Not open for further replies.
Top