Skip to content

Commit

Permalink
Lurkers MAI: bug fix for attack error when lurker runs into ambush
Browse files Browse the repository at this point in the history
If the lurker move is interrupted by an ambush, the attack action
previously sometimes caused an error, because the lurker might not get
to its target.
  • Loading branch information
mattsc committed Nov 28, 2014
1 parent ad43d71 commit 77f8837
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog
Expand Up @@ -2,6 +2,7 @@ Version 1.12.0+dev:
* AI:
* Big Animals Micro AI: bug fix for units not attacking when [avoid_unit] is
not set
* Lurkers MAI: bug fix for attack error when lurker runs into ambush
* Editor:
* Fixed falcon race missing an icon due to having incorrectly-named image
files.
Expand Down
3 changes: 3 additions & 0 deletions data/ai/micro_ais/cas/ca_lurkers.lua
@@ -1,5 +1,6 @@
local LS = wesnoth.require "lua/location_set.lua"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local H = wesnoth.require "lua/helper.lua"

local function get_lurker(cfg)
-- We simply pick the first of the lurkers, they have no strategy
Expand Down Expand Up @@ -58,6 +59,8 @@ function ca_lurkers:execution(ai, cfg)

AH.movefull_stopunit(ai, lurker, dst[rand])
if (not lurker) or (not lurker.valid) then return end
if (not target) or (not target.valid) then return end
if (H.distance_between(lurker.x, lurker.y, target.x, target.y) ~= 1) then return end

AH.checked_attack(ai, lurker, target)
return
Expand Down

0 comments on commit 77f8837

Please sign in to comment.