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..04060cc2da8 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -12447,6 +12447,13 @@ void ai_process_subobjects(int objnum) } } } + } + // 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))) { + aip->submode = SM_ATTACK; + aip->submode_start_time = Missiontime; } }