- Joined
- Jan 29, 2007
- Messages
- 98
Sorry for the long title, and also for that really long and annoying function name... Couldn't think of a better one
Anyways, this is something I cooked up now but I'm unsure if it already exists :S
It uses GroupEnumUnitsOfPlayer to do all other stuff like the one in the title, and here's the code:
So, I'm just wondering:
Is this efficient to do it this way :S
If not, then is there another more efficient way of doing it ?
Has it been done before ?
Anyways, this is something I cooked up now but I'm unsure if it already exists :S
It uses GroupEnumUnitsOfPlayer to do all other stuff like the one in the title, and here's the code:
JASS:
library LocustGroup
globals
private group ENUM = CreateGroup()
private group TEMP
private real range = 0.0
private real xe
private real ye
private real xe1
private real ye1
endglobals
private function EnumActions_Range takes nothing returns nothing
local unit u = GetEnumUnit()
if IsUnitInRangeXY( u, xe, ye, range ) then
call GroupAddUnit( TEMP, u )
endif
set u = null
endfunction
private function EnumActions_Rect takes nothing returns nothing
local unit u = GetEnumUnit()
if ( GetUnitX( u ) <= xe1 or GetUnitX( u ) >= xe ) and ( GetUnitY( u ) <= ye1 or GetUnitY( u ) >= ye ) then
call GroupAddUnit( TEMP, u )
endif
set u = null
endfunction
function GroupEnumUnitsInRangeOfXYEx takes group g, real x, real y, real r, boolexpr b returns nothing
local integer i = 0
set range = r
set xe = x
set ye = y
set TEMP = g
loop
call GroupEnumUnitsOfPlayer( ENUM, Player( i ), b )
call ForGroup( ENUM, function EnumActions_Range )
set i = i + 1
exitwhen i >= 16
endloop
set TEMP = null
endfunction
function GroupEnumUnitsInRangeOfLocEx takes group g, location l, real r, boolexpr b returns nothing
local integer i = 0
if l != null then
set range = r
set xe = GetLocationX( l )
set ye = GetLocationY( l )
set TEMP = g
loop
call GroupEnumUnitsOfPlayer( ENUM, Player( i ), b )
call ForGroup( ENUM, function EnumActions_Range )
set i = i + 1
exitwhen i >= 16
endloop
set TEMP = null
endif
endfunction
function GroupEnumUnitsInRangeOfUnitEx takes group g, unit u, real r, boolexpr b returns nothing
local integer i = 0
if u != null then
set range = r
set xe = GetUnitX( u )
set ye = GetUnitY( u )
set TEMP = g
loop
call GroupEnumUnitsOfPlayer( ENUM, Player( i ), b )
call ForGroup( ENUM, function EnumActions_Range )
set i = i + 1
exitwhen i >= 16
endloop
set TEMP = null
endif
endfunction
function GroupEnumUnitsInRectEx takes group g, rect r, boolexpr b returns nothing
local integer i = 0
if r != null then
set xe = GetRectMinX( r )
set ye = GetRectMinY( r )
set xe1 = GetRectMaxX( r )
set ye1 = GetRectMaxY( r )
set TEMP = g
loop
call GroupEnumUnitsOfPlayer( ENUM, Player( i ), b )
call ForGroup( ENUM, function EnumActions_Rect )
set i = i + 1
exitwhen i >= 16
endloop
set TEMP = null
endif
endfunction
endlibrary
So, I'm just wondering:
Is this efficient to do it this way :S
If not, then is there another more efficient way of doing it ?
Has it been done before ?