- Joined
- Feb 22, 2013
- Messages
- 161
I created a simple custom event for damage detection, but I dont know how to make it accessible from other triggers as usage of like a TriggerRegister type thing for another trigger. How can I do this?
JASS:
library DamageDetection initializer DamageDetectionInit
globals
trigger damageEvent = CreateTrigger()
endglobals
function DetectDamage takes nothing returns nothing
local unit damageSource = GetEventDamageSource()
set damageSource = null
endfunction
function MapInit takes nothing returns nothing
local unit enumUnit = GetEnumUnit()
call TriggerRegisterUnitEvent(damageEvent, enumUnit, EVENT_UNIT_DAMAGED)
set enumUnit = null
endfunction
function UnitEnters takes nothing returns nothing
local unit triggerUnit = GetTriggerUnit()
call TriggerRegisterUnitEvent(damageEvent, triggerUnit, EVENT_UNIT_DAMAGED)
set triggerUnit = null
endfunction
function DamageDetectionInit takes nothing returns nothing
local trigger unitsEnterMap = CreateTrigger()
local region playableMap = CreateRegion()
local group initialUnitGroup = CreateGroup()
call GroupEnumUnitsInRect(initialUnitGroup, bj_mapInitialPlayableArea, null)
call ForGroup(initialUnitGroup, function MapInit)
call RegionAddRect(playableMap, bj_mapInitialPlayableArea)
call TriggerRegisterEnterRegion(unitsEnterMap, playableMap, null)
call TriggerAddAction(unitsEnterMap, function UnitEnters)
call TriggerAddAction(damageEvent, function DetectDamage)
call DestroyGroup(initialUnitGroup)
set initialUnitGroup = null
endfunction
endlibrary