From 76bea0092c2ef7c5494eb95d5fa157384e594373 Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 19 Nov 2013 00:27:09 +0000 Subject: [PATCH] [Add] Created an 'idle' task to run when idle for easy to change idle behaviours. --- scripts/ai/tpl/generic.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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