TriggerRegisterLeaveRegion

Parameters
whichTrigger trigger

The trigger to add the event to.

whichRegion region

The region of the event.

filter boolexpr

An additional filter to determine what units will fire the trigger.

comment

Registers when a unit leaves a region.

note

Only reacts to the origin of units. Their collision sizes are not considered.

note

Units can leave a region by walking, being dispositioned by other game mechanisms, or programmatically (SetUnitX, SetUnitY, SetUnitPosition). Hidden, dead, and locust units can leave as well. Removing a unit will not fire the trigger nor the filter.

note

The filter can be null to allow any unit to fire the trigger. If there is a filter, the filter will be fired when a unit leaves the region. In this case, the trigger will only be fired if the filter returns true (a truthy value in Lua) and GetFilterUnit can be used to refer to the unit in this scope.

note

When moving a unit by trigger and causing the unit to leave the region, the filter will be fired instantly but the trigger will be fired in a deferred fashion (using a 0-timer). The trigger will not fire if the trigger, region, or unit have been destroyed in the meantime. Due to the deferment, it may be good to use IsUnitInRegion when the trigger fires to check if the unit is actually still outside the region at this point in time, in case that is a wanted assumption.

note

Removing cells from the region so that units that were previously inside are now outside does not fire the trigger nor the filter. But those units will then be considered outside and can fire leave events (see TriggerRegisterEnterRegion) again when they cross the boundaries of the region.

note

When the region is destroyed, the filter and trigger will not be fired anymore.

patch

1.00

Source
common.j
return type
event
Source code
native TriggerRegisterLeaveRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event