From ee259281cc298c5bd51c77400bb927c6145ca717 Mon Sep 17 00:00:00 2001 From: Allanis Date: Fri, 7 Mar 2014 17:49:33 +0000 Subject: [PATCH] [Change] AI improvments, they should be much nicer now. --- scripts/ai/include/attack_generic.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/ai/include/attack_generic.lua b/scripts/ai/include/attack_generic.lua index 81873e8..59c9eb7 100644 --- a/scripts/ai/include/attack_generic.lua +++ b/scripts/ai/include/attack_generic.lua @@ -56,7 +56,7 @@ function atk_g() atk_g_ranged(target, dist) elseif dist > range * atk_aim then - if ai.relvel(target) < 0 then + if ai.relvel(target) > -10 then atk_g_ranged(target, dist) else atk_g_aim(target, dist) @@ -110,6 +110,7 @@ end function atk_g_melee(target, dist) secondary, special = ai.secondary("melee") dir = ai.aim(target) -- We aim instead of face. + range = ai.getweaprange() -- Fire non-smart secondary weapons. if(secondary == "Launcher" and special ~= "Smart") or @@ -119,6 +120,12 @@ function atk_g_melee(target, dist) end end + -- Drifting away we'll want to get closer. + if dir < 10 and dist > 0.5*range and ai.relvel(target) > -10 then + ai.accel() + end + + -- Shoot if should be shooting. if(dir < 10 and dist < range) or ai.hasturrets() then ai.shoot() end