[Change] Minor AI tweaks.

This commit is contained in:
Allanis 2014-04-29 17:25:54 +01:00
parent d6b0ab0e16
commit 0811f18dd7
3 changed files with 9 additions and 2 deletions

View File

@ -85,9 +85,11 @@ end
--Attack target. --Attack target.
function e_attack(target) function e_attack(target)
if command then if command then
if target ~= nil then
ai.pushtask(0, "attack", target) ai.pushtask(0, "attack", target)
end end
end end
end
-- Hold position. -- Hold position.
function e_hold() function e_hold()

View File

@ -83,6 +83,11 @@ function attacked(attacker)
if ai.target() ~= attacker then if ai.target() ~= attacker then
ai.pushtask(0, "attack", attacker) ai.pushtask(0, "attack", attacker)
end end
elseif task == "runaway" then
if ai.target() ~= attacker then
ai.poptask()
ai.pushtask(0, "runaway", attacker)
end
end end
end end

View File

@ -14,7 +14,7 @@ function control()
enemy = ai.getenemy() enemy = ai.getenemy()
-- There is an enemy. -- There is an enemy.
if enemy ~= 0 then if enemy ~= nil then
if ai.dist(enemy) < enemy_dist or ai.haslockon() then if ai.dist(enemy) < enemy_dist or ai.haslockon() then
ai.pushtask(0, "runaway", enemy) ai.pushtask(0, "runaway", enemy)
return return