Snippet Global Damage

Dirac

22710180
Reaction score
147
JASS:
library GlobalDamage uses/*

*/  Damage  /* thehelper.net/forums/showthread.php/168144-Damage-Struct

//  Use if you wish to have a function that fires every time damage is dealt
//  besides from the specific unit event firing.

***********************************************************************

    API:
    
    function RegisterGlobalDamage takes code func returns nothing
//      Runs after damage mods and unit damage events. Function should
//      return false

**********************************************************************/

//! textmacro GLOBAL_DAMAGE_EX1
    globals
        private trigger  GlobalTrig =CreateTrigger()
        private boolexpr GlobalCond =null
    endglobals
    
    function RegisterGlobalDamage takes code func returns nothing
        if GlobalCond==null then
            set GlobalCond=Filter(func)
        else
            set GlobalCond=Or(Filter(func),GlobalCond)
            call TriggerClearConditions(GlobalTrig)
        endif
        call TriggerAddCondition(GlobalTrig,GlobalCond)
    endfunction
//! endtextmacro

//! textmacro GLOBAL_DAMAGE_EX2
    call TriggerEvaluate(GlobalTrig)
//! endtextmacro

endlibrary
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
This should be part of Damage IMO. It falls under the same category of that system's prime intent and no one will want to use a separate library for something that is a common feature of damage systems. :)
 
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