TriggerRegisterEnterRegion

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 enters a region.

note

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

note

Units can enter a region by walking, being dispositioned by other game mechanisms, or programmatically (SetUnitX, SetUnitY, SetUnitPosition), or when they are created. Hidden, dead, and locust units can enter as well.

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 enters 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 enter 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 inside the region at this point in time, in case that is a wanted assumption.

note

Adding cells to the region so that units that were previously outside are now inside does not fire the trigger nor the filter. But those units will then be considered inside and can fire leave events (see TriggerRegisterLeaveRegion) 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 TriggerRegisterEnterRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event