[Change] Improved scout AI behaviour somewhat.

This commit is contained in:
Allanis 2014-06-04 21:22:51 +01:00
parent f346126976
commit 47791ea3dd

View File

@ -1,8 +1,8 @@
include("../scripts/ai/include/basic.lua") include("../scripts/ai/include/basic.lua")
-- Variables. -- Variables.
planet_dist = 1000 -- Distance to keep from planets. planet_dist = 1500 -- Distance to keep from planets.
enemy_dist = 700 -- Distance to keep from enemies. enemy_dist = 800 -- Distance to keep from enemies.
-- Required control rate. -- Required control rate.
control_rate = 2 control_rate = 2
@ -23,7 +23,9 @@ function control()
-- Nothing to do so check if we are too far from the planet. -- Nothing to do so check if we are too far from the planet.
-- (If there is one). -- (If there is one).
mem.approach = ai.rndplanet() if mem.approach == nil then
mem.approach = ai.rndplanet()
end
planet = mem.approach planet = mem.approach
if planet ~= nil then if planet ~= nil then
@ -90,8 +92,16 @@ end
-- Approaches the target. -- Approaches the target.
function approach() function approach()
target = mem.approach target = mem.approach
ai.face(target) dir = ai.face(target)
ai.accel() dist = ai.dist(target)
-- See if we should accel or brake.
if dist > planet_dist then
ai.accel()
else
ai.poptask()
ai.pushtask(0, "idle")
end
end end