[Add] Simple ai for mission pilots that need to escort the player.
This commit is contained in:
parent
7344f88916
commit
7bbad458e0
28
scripts/ai/escort_player.lua
Normal file
28
scripts/ai/escort_player.lua
Normal file
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user