View Single Post
Old 10-03-2011, 03:36 PM   #1
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default RegisterPlayerUnitEvent

To reduce the cumbersome amount of handles generated by registering a player unit event for each player, this system localizes it all and groups everything together.

This function is more than a wrapper for TriggerRegisterAnyUnitEventBJ, it is also the replacement.

The API is as simple as this:

Collapse JASS:
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath)
...
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function OnOrder)

And the code is really this short:

Collapse JASS:
library RegisterPlayerUnitEvent
    globals
        private trigger array t
    endglobals
    function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
        local integer i = GetHandleId(p)
        if t[i] == null then
            set t[i] = CreateTrigger()
            call TriggerRegisterAnyUnitEventBJ(t[i], p)
        endif
        call TriggerAddCondition(t[i], Filter(c))
    endfunction
endlibrary
Bribe is offline   Reply With Quote
Sponsored Links - Login to hide this ad!