Romek
Super Moderator
- Reaction score
- 963
Enum Functions
By Romek
By Romek
Introduction:
I've believed until a few hours ago that all the GroupEnum functions do not overwrite the group which is passed to them.
After a bit of testing, however, I found that the group is actually cleared before the units are added to it. Artificial confirmed this.
These are just some simple functions which allow you to enum units without clearing the target group. I suggest you only use these if you really need to keep the units in the group as the natives are considerably faster.
Functions:
JASS:
JASS:
JASS:
JASS:
JASS:
JASS:
JASS:
JASS:
JASS:
The Code:
JASS:
library EnumUnits
// ============================
// Enum Functions - By Romek
// ============================
globals
private group G = CreateGroup()
private group TempG
endglobals
private function Enum takes nothing returns nothing
call GroupAddUnit(TempG, GetEnumUnit())
endfunction
function EnumUnitsInRange takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing
call GroupEnumUnitsInRange(G, x, y, radius, filter)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsInRangeCounted takes group whichGroup, real x, real y, real radius, boolexpr filter, integer limit returns nothing
call GroupEnumUnitsInRangeCounted(G, x, y, radius, filter, limit)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsInRangeOfLoc takes group whichGroup, location loc, real radius, boolexpr filter returns nothing
call GroupEnumUnitsInRangeOfLoc(G, loc, radius, filter)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsInRangeOfLocCounted takes group whichGroup, location loc, real radius, boolexpr filter, integer limit returns nothing
call GroupEnumUnitsInRangeOfLocCounted(G, loc, radius, filter, limit)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsInRect takes group whichGroup, rect whichRect, boolexpr filter returns nothing
call GroupEnumUnitsInRect(G, whichRect, filter)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsInRectCounted takes group whichGroup, rect whichRect, boolexpr filter, integer limit returns nothing
call GroupEnumUnitsInRectCounted(G, whichRect, filter, limit)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsOfPlayer takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
call GroupEnumUnitsOfPlayer(G, whichPlayer, filter)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsOfType takes group whichGroup, string name, boolexpr filter returns nothing
call GroupEnumUnitsOfType(G, name, filter)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
function EnumUnitsOfTypeCounted takes group whichGroup, string name, boolexpr filter, integer limit returns nothing
call GroupEnumUnitsOfTypeCounted(G, name, filter, limit)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
// EnumUnitsSelected() name was taken by a BJ ¬_¬
function EnumSelectedUnits takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
call GroupEnumUnitsSelected(G, whichPlayer, filter)
set TempG = whichGroup
call ForGroup(G, function Enum)
call GroupClear(G)
endfunction
endlibrary