From c45302d2b33b8993288050e44cac93b1ba3f2eb9 Mon Sep 17 00:00:00 2001 From: wookieejedi Date: Sat, 18 Jul 2026 08:58:34 -0400 Subject: [PATCH 1/2] Fix AI Bug with Strafing Bug: When a fighter or bomber enters strafe mode attacking a large ship, that large ship may die or depart, which results in the fighter/bomber AI slowing down to 0 and then not moving until another order is issued. This is most apparent in mods that force strafe to be used more via the ai profile flags (such as FotG). Cause: This bug is caused by the following. A fighter/bomber whose strafe target is destroyed drops to AIM_NONE (see ai_execute_behavior) with its active_goal still set, so a standing order like attack-any is never re-processed and the ship slows to zero and remains still until another order is issued. Fix: If we're chasing or strafing against large ship but have lost our target, we need to clear the active goal to ensure ai_process_mission_orders() re-evaluates our orders next frame. Of course gate this behind a flag. Tested and update fixes the issue. We are very much hoping this can be a part of a point-release since it is substantially needed for FotG missions and we want to release in the next month or so. Happy to answer any questions or discuss, too! --- code/ai/ai_flags.h | 1 + code/ai/ai_profiles.cpp | 2 ++ code/ai/aicode.cpp | 9 +++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/code/ai/ai_flags.h b/code/ai/ai_flags.h index 432f0ade558..427ec5f8395 100644 --- a/code/ai/ai_flags.h +++ b/code/ai/ai_flags.h @@ -176,6 +176,7 @@ namespace AI { Dont_limit_change_in_speed_due_to_physics_whack, Guards_ignore_protected_attackers, Fix_standard_strafe, + Fix_target_updating_with_strafe, Standard_strafe_used_more, Unify_usage_ai_shield_manage_delay, Fix_AI_shield_management_bug, diff --git a/code/ai/ai_profiles.cpp b/code/ai/ai_profiles.cpp index a35a0bd0df4..8180beb867b 100644 --- a/code/ai/ai_profiles.cpp +++ b/code/ai/ai_profiles.cpp @@ -677,6 +677,8 @@ void parse_ai_profiles_tbl(const char *filename) set_flag(profile, "$fix standard strafe:", AI::Profile_Flags::Fix_standard_strafe); + set_flag(profile, "$fix target updating with strafe:", AI::Profile_Flags::Fix_target_updating_with_strafe); + set_flag(profile, "$standard strafe used more:", AI::Profile_Flags::Standard_strafe_used_more); if (optional_string("$standard strafe triggers under this speed:")) { diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index 04060cc2da8..ea7e0b29f86 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -15513,8 +15513,13 @@ void ai_frame(int objnum) En_objp = NULL; } - if (aip->mode == AIM_CHASE) { - if (En_objp == NULL) { + if (aip->mode == AIM_CHASE || ((The_mission.ai_profile->flags[AI::Profile_Flags::Fix_target_updating_with_strafe]) && aip->mode == AIM_STRAFE)) { + // If we're chasing or strafing against large ship but have lost our target, clear the active goal + // to ensure ai_process_mission_orders() re-evaluates our orders next frame. + // Without this fighter/bomber whose strafe target is destroyed drops to AIM_NONE (see ai_execute_behavior) + // with its active_goal still set, so a standing order like attack-any is never re-processed + // and the ship slows to zero and remains still until another order is issued. + if (En_objp == nullptr) { aip->active_goal = -1; } } From 699edf18569bff86dfda309272d5c897e30162b3 Mon Sep 17 00:00:00 2001 From: wookieejedi Date: Sat, 18 Jul 2026 20:12:03 -0400 Subject: [PATCH 2/2] target 26.2 --- code/ai/ai_profiles.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/ai/ai_profiles.cpp b/code/ai/ai_profiles.cpp index 8180beb867b..d65ba45ecfc 100644 --- a/code/ai/ai_profiles.cpp +++ b/code/ai/ai_profiles.cpp @@ -989,5 +989,7 @@ void ai_profile_t::reset() 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); + flags.set(AI::Profile_Flags::Fix_standard_strafe); + flags.set(AI::Profile_Flags::Fix_target_updating_with_strafe); } }