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:
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function OnOrder)
And the code is really this short:
private trigger array t
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)
call TriggerAddCondition(t[i], Filter(c))