From 18b5d5159e0b3ec8a79a48e2f6d74f54880c3939 Mon Sep 17 00:00:00 2001 From: mattsc Date: Thu, 5 Dec 2019 07:09:35 -0800 Subject: [PATCH] AI castle switch: bug fix for units on keep check --- data/ai/lua/ca_castle_switch.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/data/ai/lua/ca_castle_switch.lua b/data/ai/lua/ca_castle_switch.lua index dc90ed1f03e..3edeadf034d 100644 --- a/data/ai/lua/ca_castle_switch.lua +++ b/data/ai/lua/ca_castle_switch.lua @@ -170,7 +170,7 @@ function ca_castle_switch:evaluation(cfg, data, filter_own) end - -- if we're on a keep, wait until there are no movable units on the castle before moving off + -- if we're on a keep, wait until there are no movable non-leader units on the castle before moving off local leader_score = 195000 if wesnoth.get_terrain_info(wesnoth.get_terrain(leader.x, leader.y)).keep then local castle = AH.get_locations_no_borders { @@ -182,9 +182,7 @@ function ca_castle_switch:evaluation(cfg, data, filter_own) local should_wait = false for i,loc in ipairs(castle) do local unit = wesnoth.units.get(loc[1], loc[2]) - if (not AH.is_visible_unit(wesnoth.current.side, unit)) then - should_wait = false - elseif unit.moves > 0 then + if unit and (unit.side == wesnoth.current.side) and (not unit.canrecruit) and (unit.moves > 0) then should_wait = true break end