I get an errormessage on this line:
Cannot convert nothing to region.
It seems like it reads that Condition before the Sandbox[0-11] is defined, but after it is declared.
Is there any way to define the rects before Conditions are read?
JASS:
set reg = RegionAddRect(reg, Sandbox)
It seems like it reads that Condition before the Sandbox[0-11] is defined, but after it is declared.
Is there any way to define the rects before Conditions are read?
JASS:
globals
rect array Sandbox [11]
real array SandboxCenterX [11]
real array SandboxCenterY [11]
force TeamWest
force TeamEast
endglobals
scope setVariables initializer setThis
private function setThis takes nothing returns nothing
local integer i = 0
//-----------------
// Set Sandbox Rects
//-----------------
set Sandbox[0] = gg_rct_SandBoxP1
set Sandbox[1] = gg_rct_SandBoxP2
set Sandbox[2] = gg_rct_SandBoxP3
set Sandbox[3] = gg_rct_SandBoxP4
set Sandbox[4] = gg_rct_SandBoxP5
set Sandbox[5] = gg_rct_SandBoxP6
set Sandbox[6] = gg_rct_SandBoxP7
set Sandbox[7] = gg_rct_SandBoxP8
set Sandbox[8] = gg_rct_SandBoxP9
set Sandbox[9] = gg_rct_SandBoxP10
set Sandbox[10] = gg_rct_SandBoxP11
set Sandbox[11] = gg_rct_SandBoxP12
//-----------------
// Set Team Sandbox Rects
//-----------------
set i = 0
loop
exitwhen i > 11
set SandboxCenterX[i] = GetRectCenterX(Sandbox[i])
set SandboxCenterY[i] = GetRectCenterY(Sandbox[i])
set i = i + 1
endloop
endfunction
endscope
scope easyMove initializer Init
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local location loc = GetOrderPointLoc()
call IssueImmediateOrder(u, "stop")
call SetUnitPositionLoc(u, loc)
call RemoveLocation(loc)
set u = null
set loc = null
endfunction
private function Conditions takes nothing returns boolean
local integer p = GetPlayerId(GetTriggerPlayer())
local region reg = CreateRegion()
local boolean result
set reg = RegionAddRect(reg, Sandbox)
set result = ( (GetUnitAbilityLevel(GetTriggerUnit(), 'Sand') > 0) and IsPointInRegion(reg, GetOrderPointX(), GetOrderPointY()) )
call RemoveRegion(reg)
set reg = null
return result
endfunction
private function Init takes nothing returns nothing
local trigger Trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( Trig, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddCondition( Trig, Condition( function Conditions ) )
call TriggerAddAction( Trig, function Actions )
endfunction
endscope