[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")
|
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).
|
||||||
|
if mem.approach == nil then
|
||||||
mem.approach = ai.rndplanet()
|
mem.approach = ai.rndplanet()
|
||||||
|
end
|
||||||
planet = mem.approach
|
planet = mem.approach
|
||||||
|
|
||||||
if planet ~= nil then
|
if planet ~= nil then
|
||||||
@ -91,7 +93,15 @@ end
|
|||||||
-- Approaches the target.
|
-- Approaches the target.
|
||||||
function approach()
|
function approach()
|
||||||
target = mem.approach
|
target = mem.approach
|
||||||
ai.face(target)
|
dir = ai.face(target)
|
||||||
|
dist = ai.dist(target)
|
||||||
|
|
||||||
|
-- See if we should accel or brake.
|
||||||
|
if dist > planet_dist then
|
||||||
ai.accel()
|
ai.accel()
|
||||||
|
else
|
||||||
|
ai.poptask()
|
||||||
|
ai.pushtask(0, "idle")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user