[Change] Moved hyperspace() to scripts/ai/include/basic.lua
This commit is contained in:
parent
79411d240e
commit
afa05f0ff8
@ -84,10 +84,3 @@ function land()
|
||||
end
|
||||
end
|
||||
|
||||
function hyperspace()
|
||||
dir = ai.face(-1) -- Face away from (0,0)
|
||||
if(dir < 10) then
|
||||
ai.accel()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,3 +59,20 @@ function runaway()
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
-- Start heading away to try to hyperspace.
|
||||
--
|
||||
-- Will need the following in control() to work:
|
||||
--
|
||||
-- task = ai.taskname()
|
||||
-- if task == "hyperspace" then
|
||||
-- ai.hyperspace() -- Try to hyperspace.
|
||||
-- end
|
||||
--]]
|
||||
function hyperspace()
|
||||
dir = ai.facr(-1) -- Face away from (0,0).
|
||||
if(dir < 10) then
|
||||
ai.accel()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -94,11 +94,3 @@ function land()
|
||||
end
|
||||
end
|
||||
|
||||
-- Go to hyperspace YEAAAHHH!!
|
||||
function hyperspace()
|
||||
dir = ai.face(-1) -- Face away from (0,0)
|
||||
if(dir < 10) then
|
||||
ai.accel()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -7,13 +7,22 @@ control_rate = 2
|
||||
function control()
|
||||
task = ai.taskname()
|
||||
|
||||
if task == "hyperspace" then
|
||||
ai.hyperspace() -- Try to hyperspace.
|
||||
|
||||
-- Running pilot has healed up some.
|
||||
if task == "runaway" then
|
||||
elseif task == "runaway" then
|
||||
if ai.parmour() == 100 then
|
||||
-- "attack" should be called after "runaway".
|
||||
ai.poptask()
|
||||
elseif ai.dist(ai.pos(ai.targetid())) > 300 then
|
||||
ai.hyperspace()
|
||||
end
|
||||
|
||||
-- Hurt pilot wants to run away.
|
||||
elseif task == "attack" then
|
||||
if ai.parmour() < 80 then
|
||||
ai.pushtask(0, "runaway", ai.targetid())
|
||||
end
|
||||
|
||||
-- Nothing to do.
|
||||
@ -22,7 +31,7 @@ function control()
|
||||
enemy = ai.getenemy()
|
||||
if ai.parmour() == 100 and enemy ~= 0 then
|
||||
-- Taunts.
|
||||
num = rnd.int(0,4)
|
||||
num = rnd.int(0,5)
|
||||
if num == 0 then msg = "Prepare to be boarded!"
|
||||
elseif num == 1 then msg = "Whoa! Lookie what we found here!"
|
||||
elseif num == 2 then msg = "What's a ship like you doing in a place like this?"
|
||||
@ -37,7 +46,7 @@ function control()
|
||||
ai.pushtask(0, "attack", enemy) -- Begin the attack.
|
||||
-- Nothing to attack.
|
||||
else
|
||||
ai.pushtask(0, "fly")
|
||||
ai.pushtask(0, "hyperspace")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user