GroupEnumUnitsInRect

Parameters
whichGroup group

The group to be modified.

r rect

The rect in which units are considered.

filter boolexpr

A filter function that is run for each considered unit.

comment

Clears a group and then adds units located within given rect to it.

note

Does not consider locust units. Locust units cannot be spatially enumerated.

note

Within the filter function, the considered unit can be accessed with GetFilterUnit.

note

The filter function must return true (a truthy value in Lua) in order to add the unit to the group.

note

If the filter function is null (nil in Lua), all considered units will be added to the group.

note

The units are added consecutively to the group between filter runs, not in bulk after all filter runs were processed.

note

In terms of running the filter function, units are processed in a certain order. The playing field is divided into sectors of 256x256, i.e., {[minX=0, minY=0, maxX=256, maxY=256], [minX=256, minY=0, maxX=512, maxY=256], [minX=0, minY=256, maxX=256, maxY=512], [minX=256, minY=256, maxX=512, maxY=512], ...}. The game keeps track what units are in what sector and the order in which they were added. The filters run from bottom to top sectors as an outer loop and from left to right sectors as an inner loop. Within each sector, the units are processed in reverse order in which they were added to the sector.

note

The origin of the unit must be within the bounds to be considered. The collision size of the unit does not matter.

bug

There is an off-by-one error with the rect bounds. The unit's origin must be within [minX+32, minY+32, maxX, maxY], i.e., the minimum bounds are off by one cell.

note

Hidden units are not enumerated with this function.

patch

1.00

Source
common.j
return type
nothing
Source code
native GroupEnumUnitsInRect                 takes group whichGroup, rect r, boolexpr filter returns nothing