- Joined
- Jul 18, 2010
- Messages
- 2,377
JASS:
function TimerExpires takes nothing returns nothing
local integer timerID = GetHandleId( GetExpiredTimer ())
local unit u = LoadUnitHandle (udg_Hash, timerID, 1)
local location currentLoc
local location newLoc
//Break - Unit is doing something
if (GetUnitCurrentOrder (u) == 0) then
//Which Mod
if ( LoadInteger(udg_Hash,timerID,0) == 0) then
//Order Move + Snow
set currentLoc = GetUnitLoc(u)
set newLoc = PolarProjectionBJ (currentLoc, GetRandomReal(500, 1500), GetRandomReal(0,360))
call IssuePointOrderLoc(u, "Move", newLoc)
//Terain Change
call SaveInteger(udg_Hash,timerID,3, GetTerrainType(GetLocationX(newLoc),GetLocationY(newLoc)) )
call SaveLocationHandle(udg_Hash,timerID,2,newLoc)
call SetTerrainType(GetLocationX(newLoc),GetLocationY(newLoc), 'Nsnw', 0, 1, 0)
call RemoveLocation(currentLoc)
call SaveInteger(udg_Hash,timerID,0,1)
else
//Point Reached
set newLoc = LoadLocationHandle(udg_Hash,timerID,2)
call SetTerrainType(GetLocationX(newLoc),GetLocationY(newLoc), LoadInteger(udg_Hash,timerID,3), 0, 1, 0)
call RemoveLocation(newLoc)
call SaveInteger(udg_Hash,timerID,0,0)
endif
set newLoc = null
set currentLoc = null
endif
set u = null
endfunction
//===========================================================================
function InitTrig_Wanderer2 takes nothing returns nothing
local timer t = CreateTimer()
local integer timerID = GetHandleId(t)
set udg_Hash = InitHashtable()
call TimerStart (t, 0.2, true, function TimerExpires)
call SaveInteger(udg_Hash,timerID,0,0)
call SaveUnitHandle(udg_Hash,timerID,1,CreateUnit ( Player(0), 'hgry', 0, 0, 270))
set t = null
endfunction