package DamageDetection import MapBounds import OnUnitEnterLeave constant SWAP_TIMEOUT = 600. boolexpr array func integer funcNext = 0 trigger current = null trigger toDestroy = null /** CONFIGURATION: Add any conditions before the Register-Call to keep units from being registered to the damage event. */ function unit.detectAddFilter() TriggerRegisterUnitEvent(current, this, EVENT_UNIT_DAMAGED) /** Add a Condition(Action) to the damage Event. */ public function addOnDamageFunc(boolexpr cf) current.addCondition(cf) func[funcNext] = cf funcNext++ /** Disables the damage events */ public function disableDamageDetect() DisableTrigger(current) /** Enables the damage events */ public function enableDamageDetect() EnableTrigger(current) /** Periodic Cleanup-Function */ function swap() boolean b = IsTriggerEnabled(current) current.disable() if toDestroy != null DestroyTrigger(toDestroy) toDestroy = current current = CreateTrigger() if not(b) DisableTrigger(current) GroupEnumUnitsInRect(ENUM_GROUP, boundRect, Filter(() -> GetFilterUnit().detectAddFilter())) for i = 0 to funcNext-1 current.addCondition(func[i]) init current = CreateTrigger() for i = 0 to funcNext-1 current.addCondition(func[i]) onEnter(() -> getEnterLeaveUnit().detectAddFilter()) GroupEnumUnitsInRect(ENUM_GROUP, boundRect, Filter(() -> GetFilterUnit().detectAddFilter())) CreateTimer().startPeriodic(SWAP_TIMEOUT, function swap)