function Trig_Harvester_bot_Actions takes nothing returns nothing
local integer i = 0
local integer targetid
local integer mat_filter
local unit u
local integer cv
local real gtime = GetFloatGameState(GAME_STATE_TIME_OF_DAY)
local string s
//temp string
loop
exitwhen i > udg_H_Max_Bot
set u = udg_HarvesterBot[i]
set cv = GetUnitUserData( u )
if udg_H_Channel[cv] then
set s = " Channel"
else
set s = " Not Channel"
endif
call DisplayTextToPlayer( Player(0),0,0, "1"+GetUnitName(u) + I2S(udg_H_Action[cv]) + GetUnitName(udg_H_Target[cv]) + s )
if udg_H_Action[cv] != 0 and gtime < 18.00 and gtime > 6.00 then
set udg_H_Action[cv] = 0
call PauseUnit ( udg_HarvesterBot[i], false )
call ShowUnit( udg_HarvesterBot[i], true )
call DestroyEffect ( udg_H_SF[cv] )
set udg_H_Target[cv] = null
elseif udg_H_Action[cv] == 0 and udg_H_Target[cv] == null then
set mat_filter = udg_H_Job[cv]
set targetid = SearchUnitInMatList ( mat_filter, cv )
if targetid != - 1 and not udg_H_Channel[cv] then
set udg_H_Target[cv] = udg_H_HUA[targetid]
call IssueTargetOrder( udg_HarvesterBot[i], "smart", udg_H_Target[cv] )
elseif not udg_H_Channel[cv] then
set udg_H_Action[cv] = 1
set udg_H_Target[cv] = null
call IssuePointOrder ( u, "move" , GetUnitX( udg_H_Home[cv] ), GetUnitY( udg_H_Home[cv] ) )
endif
endif
call DisplayTextToPlayer( Player(0),0,0, "2"+GetUnitName(u) + I2S(udg_H_Action[cv]) + GetUnitName(udg_H_Target[cv]) + s )
if not udg_H_Channel[cv] and udg_H_Target[cv] != null and udg_H_Action[cv] == 0 then
call IssueTargetOrder( u, "smart", udg_H_Target[cv] )
endif
if ((( gtime > 18.00 or gtime < 6.00 ) and udg_H_Target[cv] == null and udg_H_Action[cv] == 0) and not udg_H_Channel[cv]) or (udg_H_Action[cv] == 1 and udg_H_Target[cv] == null and not udg_H_Channel[cv]) then
set udg_H_Action[cv] = 1
call IssuePointOrder ( u, "move" , GetUnitX( udg_H_Home[cv] ), GetUnitY( udg_H_Home[cv] ) )
endif
call DisplayTextToPlayer( Player(0),0,0, "3"+GetUnitName(u) + I2S(udg_H_Action[cv]) + GetUnitName(udg_H_Target[cv]) + s )
set i = i + 1
endloop
set u = null
endfunction
//===========================================================================
function InitTrig_Harvester_bot takes nothing returns nothing
set gg_trg_Harvester_bot = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Harvester_bot, 3.00, true)
call TriggerAddAction( gg_trg_Harvester_bot, function Trig_Harvester_bot_Actions )
endfunction