[Change] Improved scout AI behaviour somewhat.
This commit is contained in:
parent
f346126976
commit
47791ea3dd
@ -1,8 +1,8 @@
|
||||
include("../scripts/ai/include/basic.lua")
|
||||
|
||||
-- Variables.
|
||||
planet_dist = 1000 -- Distance to keep from planets.
|
||||
enemy_dist = 700 -- Distance to keep from enemies.
|
||||
planet_dist = 1500 -- Distance to keep from planets.
|
||||
enemy_dist = 800 -- Distance to keep from enemies.
|
||||
|
||||
-- Required control rate.
|
||||
control_rate = 2
|
||||
@ -23,7 +23,9 @@ function control()
|
||||
|
||||
-- Nothing to do so check if we are too far from the planet.
|
||||
-- (If there is one).
|
||||
mem.approach = ai.rndplanet()
|
||||
if mem.approach == nil then
|
||||
mem.approach = ai.rndplanet()
|
||||
end
|
||||
planet = mem.approach
|
||||
|
||||
if planet ~= nil then
|
||||
@ -90,8 +92,16 @@ end
|
||||
|
||||
-- Approaches the target.
|
||||
function approach()
|
||||
target = mem.approach
|
||||
ai.face(target)
|
||||
ai.accel()
|
||||
target = mem.approach
|
||||
dir = ai.face(target)
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user