diff --git a/scripts/ai/tpl/generic.lua b/scripts/ai/tpl/generic.lua index 0a432a3..7e9e67c 100644 --- a/scripts/ai/tpl/generic.lua +++ b/scripts/ai/tpl/generic.lua @@ -55,14 +55,7 @@ function control() elseif task == "hyperspace" then ai.hyperspace() -- Try to hyperspace. else -- Get new task. - planet = ai.landplanet() - -- Planet must exist. - if planet == nil or land_planet == false then - ai.pushtask(0, "hyperspace") - else - ai.pushtask(0, "hyperspace") - ai.pushtask(0, "land", planet) - end + idle() end end @@ -82,6 +75,18 @@ function attacked(attacker) end end +-- Default task to run when idle. +function idle() + planet = ai.landplanet() + -- Planet must exist. + if planet == nil or land_planet == false then + ai.pushtask(0, "hyperspace") + else + ai.pushtask(0, "hyperspace") + ai.pushtask(0, "land", planet) + end +end + function create() -- Empty stub. end