From 7bbad458e0c3322d4a3b3181730e22ff25e10d60 Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 19 Nov 2013 21:33:15 +0000 Subject: [PATCH] [Add] Simple ai for mission pilots that need to escort the player. --- scripts/ai/escort_player.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/ai/escort_player.lua diff --git a/scripts/ai/escort_player.lua b/scripts/ai/escort_player.lua new file mode 100644 index 0000000..a9c0a7b --- /dev/null +++ b/scripts/ai/escort_player.lua @@ -0,0 +1,28 @@ +include("../scripts/tpl/generic.lua") + +-- Settings +armour_run = 40 +armour_return = 70 +aggressive = true + +function create() + -- Escorts have nothing on them. +end + +-- When pilot is idle she'll escort the player. +function idle() + ai.pushtask(0, "escort", ai.getPlayer()) +end + +-- Escort the target. +function escort() + target = ai.targetid() + + dir = ai.face(target) + dist = ai.dist(ai.pos(target)) + + if dir < 10 and dist > 200 then + ai.accel() + end +end +