Skip to content

Commit

Permalink
Fast MAI: bug fix for error when attacker runs into ambush
Browse files Browse the repository at this point in the history
If the move of the attacker toward the target is interrupted by an
ambush, the attack action previously caused an error, because the
attacker did  not get to its target.
  • Loading branch information
mattsc authored and mattsc committed Feb 12, 2015
1 parent b790712 commit 448e300
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions data/ai/micro_ais/cas/ca_fast_combat.lua
Expand Up @@ -63,9 +63,11 @@ function ca_fast_combat:execution(ai, cfg, self)
local unit = self.data.fast_combat_units[self.data.fast_combat_unit_i]
AH.movefull_outofway_stopunit(ai, unit, self.data.fast_dst.x, self.data.fast_dst.y)

if unit and unit.valid and self.data.fast_target and self.data.fast_target.valid then
AH.checked_attack(ai, unit, self.data.fast_target)
end
if (not unit) or (not unit.valid) then return end
if (not self.data.fast_target) or (not self.data.fast_target.valid) then return end
if (H.distance_between(unit.x, unit.y, self.data.fast_target.x, self.data.fast_target.y) ~= 1) then return end

AH.checked_attack(ai, unit, self.data.fast_target)

self.data.fast_combat_units[self.data.fast_combat_unit_i] = nil
end
Expand Down

0 comments on commit 448e300

Please sign in to comment.