diff --git a/changelog b/changelog index 5fd555de44a6..bd5c367468e0 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,11 @@ Version 1.11.10+dev: * Add-ons server: * Filenames with whitespace in them are no longer allowed. + * AI: + * Non-default multiplayer and Micro AIs: + * Fixed bugs which could lead to the AIs being disabled for the rest of the + turn if WML events removed or changed units during the AI turn + * Improved error reporting of invalid AI actions * Campaigns: * Eastern Invasion: * Updated maps for scenario 8, 11, 12, 14, 16 and 17a. diff --git a/data/ai/lua/generic_recruit_engine.lua b/data/ai/lua/generic_recruit_engine.lua index 0d17134f318c..a469043fbb86 100644 --- a/data/ai/lua/generic_recruit_engine.lua +++ b/data/ai/lua/generic_recruit_engine.lua @@ -559,7 +559,7 @@ return { until recruit_type ~= nil if wesnoth.unit_types[recruit_type].cost <= wesnoth.sides[wesnoth.current.side].gold then - ai.recruit(recruit_type, recruit_data.recruit.best_hex[1], recruit_data.recruit.best_hex[2]) + AH.checked_recruit(ai, recruit_type, recruit_data.recruit.best_hex[1], recruit_data.recruit.best_hex[2]) -- If the recruited unit cannot reach the target hex, return it to the pool of targets if recruit_data.recruit.target_hex ~= nil and recruit_data.recruit.target_hex[1] ~= nil then diff --git a/data/ai/lua/generic_rush_engine.lua b/data/ai/lua/generic_rush_engine.lua index d73c7df5de96..b034c6311a7c 100644 --- a/data/ai/lua/generic_rush_engine.lua +++ b/data/ai/lua/generic_rush_engine.lua @@ -254,7 +254,7 @@ return { if AH.print_exec() then print_time(' Executing castle_switch CA') end if AH.show_messages() then W.message { speaker = leader.id, message = 'Switching castles' } end - ai.move(leader, self.data.leader_target[1], self.data.leader_target[2]) + AH.checked_move(ai, leader, self.data.leader_target[1], self.data.leader_target[2]) self.data.leader_target = nil end @@ -493,12 +493,14 @@ return { local defender = wesnoth.get_unit(self.data.attack.target.x, self.data.attack.target.y) AH.movefull_stopunit(ai, attacker, self.data.attack.dst.x, self.data.attack.dst.y) + if (not attacker) or (not attacker.valid) then return end + if (not defender) or (not defender.valid) then return end -- Find the poison weapon -- If several attacks have poison, this will always find the last one local is_poisoner, poison_weapon = AH.has_weapon_special(attacker, "poison") - ai.attack(attacker, defender, poison_weapon) + AH.checked_attack(ai, attacker, defender, poison_weapon) self.data.attack = nil end @@ -604,7 +606,7 @@ return { if target then local x, y = wesnoth.find_vacant_tile(target[1], target[2], unit) local dest = AH.next_hop(unit, x, y) - ai.move(unit, dest[1], dest[2]) + AH.checked_move(ai, unit, dest[1], dest[2]) end end diff --git a/data/ai/lua/move_to_any_target.lua b/data/ai/lua/move_to_any_target.lua index 4df572afd859..ef732b7ff9e0 100644 --- a/data/ai/lua/move_to_any_target.lua +++ b/data/ai/lua/move_to_any_target.lua @@ -44,7 +44,7 @@ return { end function move_to_any_target:move_to_enemy_exec() - ai.move(self.data.unit, self.data.destination[1], self.data.destination[2]) + AH.checked_move(ai, self.data.unit, self.data.destination[1], self.data.destination[2]) end return move_to_any_target diff --git a/src/ai/configuration.cpp b/src/ai/configuration.cpp index a823e8a9af43..07789918937d 100644 --- a/src/ai/configuration.cpp +++ b/src/ai/configuration.cpp @@ -402,7 +402,7 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side BOOST_FOREACH(const config &aitarget, aiparam.child_range("target")) { - lg::wml_error << deprecate_wml_key_warning("target", "1.12.0") << "\n"; + lg::wml_error << deprecate_wml_key_warning("target", "1.13.0") << "\n"; config aigoal; transfer_turns_and_time_of_day_data(aiparam,aigoal); @@ -421,7 +421,7 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side BOOST_FOREACH(config &ai_protect_unit, aiparam.child_range("protect_unit")) { - lg::wml_error << deprecate_wml_key_warning("protect_unit", "1.12.0") << "\n"; + lg::wml_error << deprecate_wml_key_warning("protect_unit", "1.13.0") << "\n"; transfer_turns_and_time_of_day_data(aiparam,ai_protect_unit); upgrade_protect_goal_config_from_1_07_02_to_1_07_03(side,ai_protect_unit,parsed_cfg,true); } @@ -429,7 +429,7 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side BOOST_FOREACH(config &ai_protect_location, aiparam.child_range("protect_location")) { - lg::wml_error << deprecate_wml_key_warning("protect_location", "1.12.0") << "\n"; + lg::wml_error << deprecate_wml_key_warning("protect_location", "1.13.0") << "\n"; transfer_turns_and_time_of_day_data(aiparam,ai_protect_location); upgrade_protect_goal_config_from_1_07_02_to_1_07_03(side,ai_protect_location,parsed_cfg,false); } @@ -438,14 +438,14 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side if (const config::attribute_value *v = aiparam.get("protect_leader")) { - lg::wml_error << deprecate_wml_key_warning("protect_leader", "1.12.0") << "\n"; + lg::wml_error << deprecate_wml_key_warning("protect_leader", "1.13.0") << "\n"; config c; c["value"] = *v; c["canrecruit"] = true; c["side_number"] = side; transfer_turns_and_time_of_day_data(aiparam,c); if (const config::attribute_value *v = aiparam.get("protect_leader_radius")) { - lg::wml_error << deprecate_wml_key_warning("protect_leader_radius", "1.12.0") << "\n"; + lg::wml_error << deprecate_wml_key_warning("protect_leader_radius", "1.13.0") << "\n"; c["radius"] = *v; }