-- Star Wars Empire at War: Secrets of a Fallen Empire -- Lua Script: //Scripts/GameObject/ObjectScript_Canderous.lua -- Author: Galyana -- Updated: 23 December, 2023 require("PGStateMachine") require("PGBase") function Definitions() ServiceRate = 1 Define_State("State_Init", State_Init); Define_State("State_AI_Autofire", State_AI_Autofire) Define_State("State_Human_No_Autofire", State_Human_No_Autofire) ability_name = "LURE" end function State_Init(message) if message == OnEnter then -- prevent this from doing anything in galactic mode if Get_Game_Mode() ~= "Land" then ScriptExit() end if Object.Get_Owner().Is_Human() then Set_Next_State("State_Human_No_Autofire") else Set_Next_State("State_AI_Autofire") end end end function State_AI_Autofire(message) if message == OnUpdate then if Object.Get_Rate_Of_Damage_Taken() > 8.0 and (Object.Get_Shield() < 0.65 or Object.Get_Health() < 0.75) then if Object.Is_Ability_Ready(ability_name) then Object.Activate_Ability(ability_name, true) end end --Land units can change hands if Object.Get_Owner().Is_Human() then Set_Next_State("State_Human_No_Autofire") end end end function State_Human_No_Autofire(message) if message == OnUpdate then --Land units can change hands if Object.Get_Owner().Is_Human() then Sleep(1) else Set_Next_State("State_AI_Autofire") end end end