fs2open.github.com icon indicating copy to clipboard operation
fs2open.github.com copied to clipboard

form-on-wing and stay-still updates

Open Goober5000 opened this issue 11 months ago • 4 comments

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.

Goober5000 avatar Mar 11 '25 04:03 Goober5000

Testing all works as expected with both new behavior and current existing behavior if flags are off, thanks for all the work on this!

wookieejedi avatar Apr 06 '25 18:04 wookieejedi

@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.

jg18 avatar May 30 '25 06:05 jg18

@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.

jg18 avatar Jun 09 '25 02:06 jg18

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.

jg18 avatar Jun 09 '25 02:06 jg18

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 giveOrder Lua 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 avatar Aug 25 '25 02:08 Goober5000

@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?

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_LOW is 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.

Goober5000 avatar Sep 01 '25 20:09 Goober5000

Alrighty, at long last the PR is ready for review :D

wookieejedi avatar Sep 21 '25 19:09 wookieejedi