• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Detect Max Life and Mana change

Status
Not open for further replies.
Hello there, reader.

I thought of a certain approach on how to properly detect change in max life.
Now, I'm not sure if this will work, since I don't have my test environment up and running at the moment, but here's the script:

JASS:
library UnitMaxStateDetect

    //# +nosemanticerror
    private function I2F takes integer i returns real
        set i = i
        return i
    endfunction

    //# +nosemanticerror
    private function F2I takes real r returns integer
        set r = r
        return r
    endfunction

    private function clearInt takes integer i returns integer
        set i = i
        return i
    endfunction

    private function clearReal takes real r returns real
        set r = r
        return r
    endfunction

    function TriggerRegisterUnitMaxLifeEvent takes trigger t, unit u, limitop operation returns event
        return TriggerRegisterUnitStateEvent(t, u, UNIT_STATE_MAX_LIFE, operation, clearReal(I2F(R2I(GetUnitState(u, UNIT_STATE_MAX_LIFE)))) )
    endfunction

    function TriggerRegisterUnitMaxManaEvent takes trigger t, unit u, limitop operation returns event
        return TriggerRegisterUnitStateEvent(t, u, UNIT_STATE_MAX_MANA, operation, clearReal(I2F(R2I(GetUnitState(u, UNIT_STATE_MAX_MANA)))) )
    endfunction
endlibrary
 
Last edited:
Status
Not open for further replies.
Top