- Joined
- Nov 30, 2007
- Messages
- 1,202
Trying this again today but alas I just can't seem to get my rect/regions in order...
I want to search the grids around the green building for destructables. In the Image provided the ones marked in red should be removed. I just can't get a reaction from the function Search. Please explain and sorry for spamming forums today.
I want to search the grids around the green building for destructables. In the Image provided the ones marked in red should be removed. I just can't get a reaction from the function Search. Please explain and sorry for spamming forums today.
JASS:
/*function Trig_Kill_Func001A takes nothing returns nothing
call RemoveDestructable( GetEnumDestructable() )
endfunction
function Trig_Kill_Actions takes nothing returns nothing
call EnumDestructablesInRectAll( RectFromCenterSizeBJ(GetRectCenter(gg_rct_Region_001), 64.00, 64.00), function Trig_Kill_Func001A )
endfunction
*/
scope WallBuilder initializer Init
globals
private real array xGrid
private real array yGrid
private integer nGrid
private rect grid
endglobals
private function AddGridToSearch takes real x, real y returns nothing
set xGrid[nGrid] = x
set yGrid[nGrid] = y
set nGrid = nGrid + 1
endfunction
private function Search takes nothing returns nothing
call BJDebugMsg("Found")
call RemoveDestructable(GetEnumDestructable())
endfunction
private function Main takes nothing returns boolean
local integer i = 0
local unit u = GetFilterUnit()
local real x0 = GetUnitX(u)
local real y0 = GetUnitY(u)
local real x
local real y
loop
set x = x0 + xGrid[i]
set y = y0 + yGrid[i]
call MoveRectTo(grid,x,y)
call EnumDestructablesInRectAll( RectFromCenterSizeBJ(Location(x, y), 128.00, 128.00), function Search )
//call EnumDestructablesInRect(grid, null, function Search)
set i = i + 1
exitwhen i == nGrid
endloop
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
local real k = 128*0.5
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_CONSTRUCT_FINISH, Filter(function Main))
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call AddGridToSearch(0,128)
call AddGridToSearch(0,-128)
call AddGridToSearch(128,0)
call AddGridToSearch(-128,0)
set grid = Rect(-k,-k,k,k)
endfunction
endscope