Lephisto/scripts/ai/test.lua
Allanis eac16dacdd [Fix] control_rate is now applied properly.
[Fix] Targetted now renders over the pilot's below.
2013-02-09 16:11:53 +00:00

60 lines
1.1 KiB
Lua

-- Required control rate.
control_rate = 2
-- Required "control" function.
function control()
if taskname() == "none" then
pushtask(0, "fly")
end
end
-- Required "attacked" function.
function attacked(attacker)
if taskname() ~= "attack" and task ~= "runaway" then
-- Let's have some taunts.
if attacker == player then
msg = rng(0,4)
if msg == 0 then say("You will never kill me!")
elseif msg == 1 then say("DIE!")
elseif msg == 2 then say("You won't survive!")
elseif msg == 3 then say("I hate you!")
end
end
pushtask(0, "attack", attacker)
end
end
-- Runs away.
function runaway()
target = gettargetid()
dir = face(target, 1)
accel()
end
-- Attack
function attack()
target = gettargetid()
dir = face(target)
dist = getdist(getpos(target))
if parmor() < 70 then
poptask()
pushtask(0, "runaway", target)
elseif dir < 10 and dist > 300 then
accel()
elseif dir < 10 and dist < 300 then
shoot()
end
end
-- Fly to the player.
function fly()
target = 0
dir = face(target)
dist = getdist(getpos(target))
if dir < 10 and dist > 300 then
accel()
end
end