Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/ai/ai_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ namespace AI {
// b) a dynamic chase saves previous_mode/previous_submode; it and strafe entry leave them alone during an ongoing dynamic goal (evading a weapon still overwrites them, which is harmless since the evade resume re-processes orders);
// c) resuming guard duty discards any subsystem target and path left over from the interruption;
// d) a ship ordered to guard itself, or to guard a wing it leads (including one that becomes leader mid-mission), treats that goal as unachievable instead of holding it forever
Player_wing_orders_same_priority_as_ship_orders, // player orders to a wing get the same goal priority as orders to an individual ship, rather than a lower one

NUM_VALUES
};
Expand Down
2 changes: 2 additions & 0 deletions code/ai/ai_profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ void parse_ai_profiles_tbl(const char *filename)

set_flag(profile, "$fix stale AI order state:", AI::Profile_Flags::Fix_stale_ai_order_state);

set_flag(profile, "$player wing orders have same priority as ship orders:", AI::Profile_Flags::Player_wing_orders_same_priority_as_ship_orders);

// end of options ----------------------------------------

// if we've been through once already and are at the same place, force a move
Expand Down
11 changes: 8 additions & 3 deletions code/ai/aigoals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
submode = remove_goalp->ai_submode;
priority = remove_goalp->priority;
name = remove_goalp->target_name;
auto type = remove_goalp->type;

// if player wing orders share the priority of ship orders, priority alone can no longer tell a wing's copy
// of a goal apart from an identical order given to one of its ships, so compare the goal type as well
bool match_type = The_mission.ai_profile->flags[AI::Profile_Flags::Player_wing_orders_same_priority_as_ship_orders];

Assert ( name ); // should not be NULL!!!!

Expand All @@ -459,7 +464,7 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->target_name )
continue;

if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->target_name) ) {
if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && (!match_type || aigp->type == type) && !stricmp(name, aigp->target_name) ) {
ai_remove_ship_goal( aip, j );
ai_do_default_behavior( &Objects[Ships[aip->shipnum].objnum] ); // do the default behavior
break; // we are all done
Expand All @@ -473,7 +478,7 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp )
if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->target_name )
continue;

if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->target_name) ) {
if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && (!match_type || aigp->type == type) && !stricmp(name, aigp->target_name) ) {
ai_goal_reset(aigp);
break;
}
Expand Down Expand Up @@ -813,7 +818,7 @@ void ai_add_goal_sub_player(ai_goal_type type, ai_goal_mode mode, int submode, c
if ( (mode == AI_GOAL_STAY_NEAR_SHIP) || (mode == AI_GOAL_KEEP_SAFE_DISTANCE) )
aigp->priority = PLAYER_PRIORITY_SUPPORT_LOW;

else if ( aigp->type == ai_goal_type::PLAYER_WING ) // NOLINT(readability-braces-around-statements)
else if ( aigp->type == ai_goal_type::PLAYER_WING && !The_mission.ai_profile->flags[AI::Profile_Flags::Player_wing_orders_same_priority_as_ship_orders] ) // NOLINT(readability-braces-around-statements)
aigp->priority = PLAYER_PRIORITY_WING; // player wing goals not as high as ship goals
else
aigp->priority = PLAYER_PRIORITY_SHIP;
Expand Down
Loading
Loading