How else to code unit with buff takes damage

shiFt

Member
Reaction score
8
Does this not fire everytime a unit takes damage? Is there not a more efficient way or is this fine?
 

shiFt

Member
Reaction score
8
no thats not the problem I was trying to figure out if there was a more efficient way of detecting it, rather than a unit takes damage event, as it checks evrytime a unit takes damage... right?
 

the Immortal

I know, I know...
Reaction score
51
No, as even if there was (for example on spell cast add 'unit takes damage' for the target) you can't remove events from triggers. Which would mean you need to manually destroy/create them. Which is what Damage does anyways, so it actually becomes slower.

Also 'any unit takes damage' with [lJASS]GetUnitAbilityLevel()[/lJASS] doesn't create any performance issues so it's pretty safe to use...
 

Jesus4Lyf

Good Idea™
Reaction score
397
One thing. If you use BuffStruct for your buff, it comes with this for free:
JASS:
method onDamageReceived takes nothing returns nothing
    // do things like: call Damage_Pure(this.unit, GetEventDamageSource(), GetEventDamage()) // <-- would reflect all damage.
endmethod

This is more efficient as it hashes based on the unit instead of firing all possibilities and checking. It's also faster to code. Either approach is fine (especially if you didn't use BuffStruct for the buff, this is more on the off chance that you did).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top