- Joined
- Jan 1, 2011
- Messages
- 1,534
JASS:
library Wanderer initializer Init
globals
hashtable h = InitHashtable()
endglobals
private function Periodic takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetHandleId(t)
local unit u = LoadUnitHandle(h, i, 0)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real a = GetRandomReal(0, 360) * bj_DEGTORAD
local real d = GetRandomReal(500, 1500)
local real xx = x + d * Cos(a)
local real yy = y + d * Sin(a)
call IssuePointOrder(u, "move", xx, yy)
call SetTerrainType(LoadReal(h, i, 1), LoadReal(h, i, 2), LoadInteger(h, i, 3), LoadInteger(h, i, 4), 1, 0)
call SaveReal(h, i, 1, x)
call SaveReal(h, i, 2, y)
call SaveInteger(h, i, 3, GetTerrainType(x, y))
call SaveInteger(h, i, 4, GetTerrainVariance(x, y))
call SetTerrainType(x, y, 'Nsnw', 0, 1, 0)
call TimerStart(t, d / GetUnitMoveSpeed(u), false, function Periodic)
set t = null
set u = null
endfunction
function Wander takes unit u returns nothing
local timer t = CreateTimer()
local integer i = GetHandleId(t)
call SaveUnitHandle(h, i, 0, u)
call TimerStart(t, 0, false, function Periodic)
set t = null
endfunction
private function Init takes nothing returns nothing
local unit u = CreateUnit(Player(0), 'hgry', 0, 0, 0)
call Wander(u)
set u = null
endfunction
endlibrary
//Code indented using The_Witcher's Script Language Aligner
//Download the newest version and report bugs at www.hiveworkshop.com
Attachments
Last edited: