globals
unit footman
endglobals
function print takes string s returns nothing
call DisplayTimedTextToPlayer(Player(0), 0, 0, 10, s)
endfunction
function Trig_Example_Actions takes nothing returns nothing
local real x = GetRandomReal(0, 9999)
local real y = GetRandomReal(0, 9999)
if GetUnitCurrentOrder(footman) == 0 then
call IssuePointOrder(footman, "attack", x, y)
endif
endfunction
function CheckMovement takes nothing returns nothing
if IsUnitMoving(footman) then
call print(GetUnitName(footman) + " is moving.")
else
call print(GetUnitName(footman) + " is not moving.")
endif
endfunction
//===========================================================================
function InitTrig_Example takes nothing returns nothing
set footman = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
//Register unit to system
call SensorAddUnit(footman)
call TimerStart(CreateTimer(), 1.0, true, function CheckMovement)
call TimerStart(CreateTimer(), 1.0, true, function Trig_Example_Actions)
endfunction