From 213bb08385410a7527a3eeadb93ca98b7a95b0e9 Mon Sep 17 00:00:00 2001 From: Allanis Date: Thu, 13 Mar 2014 19:30:54 +0000 Subject: [PATCH] [Add] Added a small enter delay to ships when entering a system with no planets. --- scripts/ai/tpl/generic.lua | 10 +++++++++- scripts/ai/tpl/merchant.lua | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/ai/tpl/generic.lua b/scripts/ai/tpl/generic.lua index 0bfdda2..d003263 100644 --- a/scripts/ai/tpl/generic.lua +++ b/scripts/ai/tpl/generic.lua @@ -91,7 +91,8 @@ function idle() planet = ai.landplanet() -- Planet must exist. if planet == nil or land_planet == false then - ai.pushtask(0, "hyperspace") + ai.settimer(0, rnd.int(1000, 3000)) + ai.pushtask(0, "enterdelay") else mem.land = planet ai.pushtask(0, "hyperspace") @@ -99,6 +100,13 @@ function idle() end end +-- Delays the ship when entering systems so that it doesn't leave right away. +function enterdelay() + if ai.timeup(0) then + ai.pushtask(0, "hyperspace") + end +end + function create() attack_choose() end diff --git a/scripts/ai/tpl/merchant.lua b/scripts/ai/tpl/merchant.lua index 14f845c..b4a4beb 100644 --- a/scripts/ai/tpl/merchant.lua +++ b/scripts/ai/tpl/merchant.lua @@ -30,7 +30,8 @@ function control() planet = ai.landplanet() -- Planet must exist. if planet == nil then - ai.pushtask(0, "hyperspace") + ai.settimer(0, rnd.int(1000, 3000)) + ai.pushtask(0, "enterdelay") else mem.land = planet ai.pushtask(0, "hyperspace") @@ -39,6 +40,13 @@ function control() end end +-- Delay the ship when entering systems so that it doesn't leave right away. +function entedelay() + if ai.timeup(0) then + ai.pushtask(0, "hyperspace") + end +end + function sos() end