- Joined
- Dec 14, 2005
- Messages
- 10,532
Less efficient than normal grouping functions, significantly, but...
-GroupEnumLocusts... functions ONLY pick up locusts
-GroupEnum...Ex functions pick up locusts and normal
-GroupEnumNormal... functions ONLY pick up non-locusts. (For GroupEnumUnitsOfPlayer and GroupEnumUnitsOfType)
Improvement suggestions and such are appreciated.
Requires JNGP
-GroupEnumLocusts... functions ONLY pick up locusts
-GroupEnum...Ex functions pick up locusts and normal
-GroupEnumNormal... functions ONLY pick up non-locusts. (For GroupEnumUnitsOfPlayer and GroupEnumUnitsOfType)
Improvement suggestions and such are appreciated.
Requires JNGP
JASS:
library LocustEnumerators
globals
private group G = CreateGroup()
endglobals
private function AntiLeak takes nothing returns boolean
return true
endfunction
function GroupEnumLocustsInRange takes group g, real x, real y, real radius, boolexpr filter returns nothing
local integer i = 0
local unit u
if filter == null then
set filter = Filter( function AntiLeak )
endif
loop
exitwhen i > 11
call GroupEnumUnitsOfPlayer( G, Player( i ), filter )
loop
set u = FirstOfGroup(G)
exitwhen u == null
if IsUnitInRangeXY( u, x, y, radius ) and GetUnitAbilityLevel(u,'Aloc') > 0 then
call GroupAddUnit( g, u )
endif
call GroupRemoveUnit(G,u)
endloop
set i = i + 1
endloop
endfunction
function GroupEnumUnitsInRangeEx takes group g, real x, real y, real radius, boolexpr filter returns nothing
local integer i = 0
local unit u
if filter == null then
set filter = Filter( function AntiLeak )
endif
loop
exitwhen i > 11
call GroupEnumUnitsOfPlayer( G, Player( i ), filter )
loop
set u = FirstOfGroup(G)
exitwhen u == null
if IsUnitInRangeXY( u, x, y, radius ) then
call GroupAddUnit( g, u )
endif
call GroupRemoveUnit(G,u)
endloop
set i = i + 1
endloop
endfunction
function GroupEnumLocustsInRect takes group g, rect r, boolexpr filter returns nothing
local integer i = 0
local unit u
local region re = CreateRegion()
call RegionAddRect( re, r )
if filter == null then
set filter = Filter( function AntiLeak )
endif
loop
exitwhen i > 11
call GroupEnumUnitsOfPlayer( G, Player( i ), filter )
loop
set u = FirstOfGroup(G)
exitwhen u == null
if GetUnitAbilityLevel( u, 'Aloc' ) > 0 and IsUnitInRegion( re, u ) then
call GroupAddUnit( g, u )
endif
call GroupRemoveUnit(G,u)
endloop
set i = i + 1
endloop
call RegionClearRect( re, r )
call RemoveRegion( re )
set re = null
endfunction
function GroupEnumUnitsInRectEx takes group g, rect r, boolexpr filter returns nothing
local integer i = 0
local unit u
local region re = CreateRegion()
call RegionAddRect( re, r )
if filter == null then
set filter = Filter( function AntiLeak )
endif
loop
exitwhen i > 11
call GroupEnumUnitsOfPlayer( G, Player( i ), filter )
loop
set u = FirstOfGroup(G)
exitwhen u == null
if IsUnitInRegion( re, u ) then
call GroupAddUnit( g, u )
endif
call GroupRemoveUnit(G,u)
endloop
set i = i + 1
endloop
call RegionClearRect( re, r )
call RemoveRegion( re )
set re = null
endfunction
function GroupEnumNormalUnitsOfPlayer takes group g, player p, boolexpr filter returns nothing
local unit u
if filter == null then
set filter = Filter( function AntiLeak )
endif
call GroupEnumUnitsOfPlayer( G, p, filter )
loop
set u = FirstOfGroup( G )
exitwhen u == null
if GetUnitAbilityLevel( u, 'Aloc' ) == 0 then
call GroupAddUnit( g, u )
endif
call GroupRemoveUnit( G, u )
endloop
endfunction
function GroupEnumNormalUnitsOfType takes group g, string unitName, boolexpr filter returns nothing
local unit u
if filter == null then
set filter = Filter( function AntiLeak )
endif
call GroupEnumUnitsOfType( G, unitName, filter )
loop
set u = FirstOfGroup( G )
exitwhen u == null
if GetUnitAbilityLevel( u, 'Aloc' ) == 0 then
call GroupAddUnit( g, u )
endif
call GroupRemoveUnit( G, u )
endloop
endfunction
endlibrary
Last edited: