From bc6b43f541c34fa82841bda5f4647ef995d1d628 Mon Sep 17 00:00:00 2001 From: wookieejedi Date: Mon, 13 Jul 2026 09:09:15 -0400 Subject: [PATCH 1/4] draft both options --- code/ai/ai_flags.h | 1 + code/ai/ai_profiles.cpp | 2 ++ code/ai/aicode.cpp | 11 +++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/code/ai/ai_flags.h b/code/ai/ai_flags.h index f8ad90d8344..432f0ade558 100644 --- a/code/ai/ai_flags.h +++ b/code/ai/ai_flags.h @@ -195,6 +195,7 @@ namespace AI { Fix_big_ship_waypoint_completion, // a) big ships complete a waypoint within their radius rather than sqrt(radius); // b) completion no longer requires moving 0.1m in a single frame (framerate-dependent) Fix_shockwave_expire_before_do_damage, // shockwaves whose lifetime is shorter than one frame apply their area damage at least once before expiring + Fix_small_ai_recover_after_engines_repaired, // ensure small ship AI can switch back to useful AI modes if engines get repaired NUM_VALUES }; diff --git a/code/ai/ai_profiles.cpp b/code/ai/ai_profiles.cpp index 6b2ca079e55..a35a0bd0df4 100644 --- a/code/ai/ai_profiles.cpp +++ b/code/ai/ai_profiles.cpp @@ -755,6 +755,7 @@ void parse_ai_profiles_tbl(const char *filename) set_flag(profile, "$fix shockwave expiring before dealing damage:", AI::Profile_Flags::Fix_shockwave_expire_before_do_damage); + set_flag(profile, "$fix fighter/bomber AI recovers after engines repaired:", AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired); // end of options ---------------------------------------- @@ -985,5 +986,6 @@ void ai_profile_t::reset() flags.set(AI::Profile_Flags::Kamikaze_no_collision_avoidance); flags.set(AI::Profile_Flags::Fix_big_ship_waypoint_completion); flags.set(AI::Profile_Flags::Fix_shockwave_expire_before_do_damage); + flags.set(AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired); } } diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index f171da4e701..a78d3a528a7 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -12431,7 +12431,7 @@ void ai_process_subobjects(int objnum) } // Deal with a ship with blown out engines. - if (ship_subsystems_blown(shipp, SUBSYSTEM_ENGINE)) { + if (!The_mission.ai_profile->flags[AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired] && ship_subsystems_blown(shipp, SUBSYSTEM_ENGINE)) { // Karajorma - if Player_use_ai is ever fixed to work on multiplayer it should be checked that any player ships // aren't under AI control here if ((!(objp->flags[Object::Object_Flags::Player_ship])) && (sip->is_fighter_bomber()) && !(shipp->flags[Ship::Ship_Flags::Dying])) { @@ -12445,7 +12445,14 @@ void ai_process_subobjects(int objnum) aip->submode = SM_ATTACK_FOREVER; // Never leave attack submode, don't avoid, evade, etc. aip->submode_start_time = Missiontime; } - } + } + } + // Goober5000 - conversely, if the engines are no longer blown (e.g. after repair), resume normal chase behavior. + // The rest of the AI assumes SM_ATTACK_FOREVER implies blown engines, + // so don't leave the submode set after the engines recover, or the ship will never evade and will ignore being hit. + else if (The_mission.ai_profile->flags[AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired] && ((aip->mode == AIM_CHASE) && (aip->submode == SM_ATTACK_FOREVER))) { + aip->submode = SM_ATTACK; + aip->submode_start_time = Missiontime; } } } From ff771c42ee2a8ba9bb5ff49f26be2df308394d43 Mon Sep 17 00:00:00 2001 From: wookieejedi Date: Tue, 14 Jul 2026 22:24:31 -0400 Subject: [PATCH 2/4] cleanup --- code/ai/aicode.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index a78d3a528a7..79b25dc519f 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -12431,7 +12431,7 @@ void ai_process_subobjects(int objnum) } // Deal with a ship with blown out engines. - if (!The_mission.ai_profile->flags[AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired] && ship_subsystems_blown(shipp, SUBSYSTEM_ENGINE)) { + if (ship_subsystems_blown(shipp, SUBSYSTEM_ENGINE)) { // Karajorma - if Player_use_ai is ever fixed to work on multiplayer it should be checked that any player ships // aren't under AI control here if ((!(objp->flags[Object::Object_Flags::Player_ship])) && (sip->is_fighter_bomber()) && !(shipp->flags[Ship::Ship_Flags::Dying])) { @@ -12447,13 +12447,13 @@ void ai_process_subobjects(int objnum) } } } - // Goober5000 - conversely, if the engines are no longer blown (e.g. after repair), resume normal chase behavior. - // The rest of the AI assumes SM_ATTACK_FOREVER implies blown engines, - // so don't leave the submode set after the engines recover, or the ship will never evade and will ignore being hit. - else if (The_mission.ai_profile->flags[AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired] && ((aip->mode == AIM_CHASE) && (aip->submode == SM_ATTACK_FOREVER))) { - aip->submode = SM_ATTACK; - aip->submode_start_time = Missiontime; - } + } + // Goober5000 - conversely, if the engines are no longer blown (e.g. after repair), resume normal chase behavior. + // The rest of the AI assumes SM_ATTACK_FOREVER implies blown engines, + // so don't leave the submode set after the engines recover, or the ship will never evade and will ignore being hit. + else if (The_mission.ai_profile->flags[AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired] && ((aip->mode == AIM_CHASE) && (aip->submode == SM_ATTACK_FOREVER))) { + aip->submode = SM_ATTACK; + aip->submode_start_time = Missiontime; } } From bc01ed374eceae536cfeaea39a3bc9d52c9dc5d5 Mon Sep 17 00:00:00 2001 From: wookieejedi Date: Tue, 14 Jul 2026 22:26:10 -0400 Subject: [PATCH 3/4] authors --- code/ai/aicode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index 79b25dc519f..3eca55598fd 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -12448,7 +12448,7 @@ void ai_process_subobjects(int objnum) } } } - // Goober5000 - conversely, if the engines are no longer blown (e.g. after repair), resume normal chase behavior. + // Goober5000 and wookieejedi - conversely, if the engines are no longer blown (e.g. after repair), resume normal chase behavior. // The rest of the AI assumes SM_ATTACK_FOREVER implies blown engines, // so don't leave the submode set after the engines recover, or the ship will never evade and will ignore being hit. else if (The_mission.ai_profile->flags[AI::Profile_Flags::Fix_small_ai_recover_after_engines_repaired] && ((aip->mode == AIM_CHASE) && (aip->submode == SM_ATTACK_FOREVER))) { From ddb068ef24d827c417c09cc3b24180b245bf65ad Mon Sep 17 00:00:00 2001 From: wookieejedi Date: Wed, 15 Jul 2026 22:57:09 -0400 Subject: [PATCH 4/4] whitespace --- code/ai/aicode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index 3eca55598fd..04060cc2da8 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -12445,7 +12445,7 @@ void ai_process_subobjects(int objnum) aip->submode = SM_ATTACK_FOREVER; // Never leave attack submode, don't avoid, evade, etc. aip->submode_start_time = Missiontime; } - } + } } } // Goober5000 and wookieejedi - conversely, if the engines are no longer blown (e.g. after repair), resume normal chase behavior.