AI: ensure all CAs respect passive_leader aspect

Most of the former Experimental AI CAs did already (or don't use the leader in the first place), but not quite all of them.
This commit is contained in:
mattsc 2019-12-04 06:54:33 -08:00
parent 1e01df84ff
commit 64e969af11
2 changed files with 7 additions and 3 deletions

View file

@ -50,7 +50,9 @@ function retreat_functions.retreat_injured_units(units, avoid_map)
-- Split units into those that regenerate and those that do not
local regen, regen_amounts, non_regen = {}, {}, {}
for i,u in ipairs(units) do
if u.hitpoints < retreat_functions.min_hp(u) then
if (u.hitpoints < retreat_functions.min_hp(u))
and ((not u.canrecruit) or (not ai.aspects.passive_leader))
then
if u:ability('regenerate') then
-- Find the best regeneration ability and use it to estimate hp regained by regeneration
local abilities = wml.get_child(u.__cfg, "abilities")

View file

@ -19,8 +19,10 @@ function ca_healer_move:evaluation(cfg, data)
local healers, healers_noMP = {}, {}
for _,healer in ipairs(all_healers) do
-- For the purpose of this evaluation, guardians count as units without moves
if (healer.moves > 0) and (not healer.status.guardian) then
-- For the purpose of this evaluation, guardians count as units without moves, as do passive leaders
if (healer.moves > 0) and (not healer.status.guardian)
and ((not healer.canrecruit) or (not ai.aspects.passive_leader))
then
table.insert(healers, healer)
else
table.insert(healers_noMP, healer)