- Joined
- Mar 10, 2009
- Messages
- 5,016
Hi guys, I wonder why the DamageDetection cannot register units manually without using Units that are preplaced nor entering the map?...
Manually means this:
But this is OK:
JASS:
library DamageDetect
struct DamageDetect
trigger t
static method damageReg takes nothing returns boolean
call BJDebugMsg(GetUnitName(GetTriggerUnit()))
call BJDebugMsg(GetUnitName(GetEventDamageSource()))
call BJDebugMsg("DAMAGE=="+R2S(GetEventDamage()))
return false
endmethod
static method create takes unit u returns thistype
local thistype this = allocate()
set .t = CreateTrigger()
call TriggerRegisterUnitEvent(.t, u, EVENT_UNIT_DAMAGED)
call TriggerAddCondition(.t, function thistype.damageReg)
//it registers the trigger and the condition but NOT manually
return this
endmethod
endstruct
endlibrary
Manually means this:
JASS:
call DamageDetect.create(UNIT1)
call DamageDetect.create(UNIT2)
But this is OK:
JASS:
static method FilterDamageUnitEvent takes nothing returns boolean
call DamageDetect.create(GetFilterUnit())
return false
endmethod
static method onInit takes nothing returns nothing
local trigger t
local region r
call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, function thistype.FilterDamageUnitEvent)
set t= CreateTrigger()
set r = CreateRegion()
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterEnterRegion(t, r, function thistype.FilterDamageUnitEvent)
set t = null
set r = null
endmethod