form-on-wing and stay-still updates
Various goal enhancements requested by FotG. The original ai-form-on-wing and ai-stay-still goals automatically cleared all other goals assigned to the same ship or wing, which is not always desired. This adds several flags to goals and ai_profiles to provide more fine-grained control over these behaviors.
Also removes AI_GOAL_PLACEHOLDER_1 since it is not needed; goals higher than AI_GOAL_NONE do not need to be a specific value.
Supersedes #6520. In draft pending testing.
Testing all works as expected with both new behavior and current existing behavior if flags are off, thanks for all the work on this!
@Goober5000 @wookieejedi I looked into whether multi is OK, and I think it is.
When the player sends orders like "Form on my wing" in multi, the result is a call to send_player_order_packet() to notify the server.
The server handles the order in process_player_order_packet(), in which the server calls either hud_squadmsg_send_ship_command() for an order the player sent to a ship or hud_squadmsg_send_wing_command() for an order the player sent to a wing. These are the same functions used to handle the order in single player. So AFAICT the server should handle the new AI flags correctly.
@Goober5000 @wookieejedi I'm confused on how this PR meshes with existing priority code for form-on-wing in ai_add_goal_sub_player() (aigoals.cpp:781-783)
// Goober5000 - same with form-on-wing, since it's a type of staying near
else if ( mode == AI_GOAL_FORM_ON_WING )
aigp->priority = PLAYER_PRIORITY_SUPPORT_LOW;
Shouldn't we be setting aigp->priority to The_mission.ai_profile->default_form_on_wing_priority instead?
This would be quite a behavior change WRT priority boost, though, since PLAYER_PRIORITY_SUPPORT_LOW is just 10.
One idea: set the priority to The_mission.ai_profile->default_form_on_wing_priority if the goal was added via player-issued order (see this comment), otherwise fall back to PLAYER_PRIORITY_SUPPORT_LOW.
As an aside, I wonder if the above code snippet explains why it always felt like issuing a "Form on my wing" order had no effect back when I used to play.
Semi-related: strange that the switch block in error_check_initial_orders() in fredview.cpp doesn't include a case for AI_GOAL_FORM_ON_WING. I wonder why. Ditto for CFred_mission_save::save_ai_goals() in missionsave.cpp and ShipGoalsDlg::initialize() (and other functions) in shipgoalsdlg.cpp. I guess it's because FSO automatically sets "form on wing" as the default AI goal if a ship has none.
error_check_initial_orders
Added a case for this in FRED and qtFRED.
save_ai_goals
Added save code
(functions in shipgoalsdlg.cpp)
Done, plus the equivalent in qtFRED
The
giveOrderLua function doesn't support using The_mission.ai_profile->default_form_on_wing_priority with form-on-wing orders. Should it?
Hmm, it probably should.
@Goober5000 @wookieejedi I'm confused on how this PR meshes with existing priority code for form-on-wing in
ai_add_goal_sub_player()(aigoals.cpp:781-783)// Goober5000 - same with form-on-wing, since it's a type of staying near else if ( mode == AI_GOAL_FORM_ON_WING ) aigp->priority = PLAYER_PRIORITY_SUPPORT_LOW;Shouldn't we be setting
aigp->prioritytoThe_mission.ai_profile->default_form_on_wing_priorityinstead?
Not necessarily, because that is intended for orders given specifically via sexp. In the messaging system, orders always had different priorities:
This would be quite a behavior change WRT priority boost, though, since
PLAYER_PRIORITY_SUPPORT_LOWis just 10.
That itself is a behavior change from retail, as those lines were added in 09d116f667. I think the best thing to do is remove those lines to restore the original squad-commanded behavior. Presumably with the fixes to the codebase over the years and in this PR, it will cause form-on-wing to work properly, but we'll test it.
As an aside, I wonder if the above code snippet explains why it always felt like issuing a "Form on my wing" order had no effect back when I used to play.
Those lines were intended to fix that exact bug, but if the order had no effect for you, they probably didn't do their job.
Alrighty, at long last the PR is ready for review :D