Skip to content

Commit 897429e

Browse files
authored
Merge pull request #6630 from Goober5000/form_on_wing_and_stay_still_updates
form-on-wing and stay-still updates
2 parents 7124916 + 0c736b7 commit 897429e

File tree

16 files changed

+336
-124
lines changed

16 files changed

+336
-124
lines changed

code/ai/ai_flags.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ namespace AI {
4444
Goal_on_hold, // when set, this goal cannot currently be satisfied, although it could be in the future
4545
Subsys_needs_fixup, // when set, the subsystem index (for a destroy subsystem goal) is invalid and must be gotten from the subsys name stored in docker.name field!!
4646
Goal_override, // paired with ai_goal_type::DYNAMIC to mean this goal overrides any other goal
47+
Want_override, // a goal should set this flag if Goal_override should be assigned when the goal is achievable
4748
Purge, // purge this goal next time we process
48-
Goals_purged, // this goal has already caused other goals to get purged
49+
Purge_when_new_goal_added, // this goal is perpetual until any other goal is added, at which time it sets its own Purge flag
50+
Goals_purged, // this goal has already caused other goals to get purged (because it is something like ai-disarm that renders other goals invalid)
4951
Depart_sound_played,// Goober5000 - replacement for AL's hack ;)
5052
Target_own_team, // this attack goal is allowed to target friendlies
5153
Afterburn_hard, // afterburn as hard as possible to the goal
5254
Waypoints_in_reverse, // decrement instead of increment
55+
Clear_all_goals_first, // this goal wipes all goals (including itself) before it runs (handled separately, and in a different place, from purging invalid goals)
5356

5457
NUM_VALUES
5558
};
@@ -181,6 +184,10 @@ namespace AI {
181184
ETS_uses_power_output,
182185
ETS_energy_same_regardless_of_system_presence,
183186
Dont_form_on_wing_at_mission_start,
187+
Do_not_clear_goals_when_running_form_on_wing,
188+
Do_not_clear_goals_when_running_stay_still,
189+
Do_not_set_override_when_assigning_form_on_wing,
190+
Purge_player_issued_form_on_wing_after_subsequent_order,
184191

185192
NUM_VALUES
186193
};

code/ai/ai_profiles.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,24 @@ void parse_ai_profiles_tbl(const char *filename)
721721

722722
set_flag(profile, "$don't issue form-on-wing goals at mission start:", AI::Profile_Flags::Dont_form_on_wing_at_mission_start);
723723

724+
if (optional_string("$default form-on-wing priority:")) {
725+
int priority;
726+
stuff_int(&priority);
727+
if (priority > 0) {
728+
profile->default_form_on_wing_priority = priority;
729+
} else {
730+
mprintf(("Warning: $default form-on-wing priority: should be > 0 (read %d). Value will not be used.\n", priority));
731+
}
732+
}
733+
734+
set_flag(profile, "$do not clear goals when running form-on-wing:", AI::Profile_Flags::Do_not_clear_goals_when_running_form_on_wing);
735+
736+
set_flag(profile, "$do not clear goals when running stay-still:", AI::Profile_Flags::Do_not_clear_goals_when_running_stay_still);
737+
738+
set_flag(profile, "$do not set override when assigning form-on-wing:", AI::Profile_Flags::Do_not_set_override_when_assigning_form_on_wing);
739+
740+
set_flag(profile, "$purge player-issued form-on-wing after subsequent order:", AI::Profile_Flags::Purge_player_issued_form_on_wing_after_subsequent_order);
741+
724742

725743
// end of options ----------------------------------------
726744

@@ -825,6 +843,8 @@ void ai_profile_t::reset()
825843
guard_big_orbit_max_speed_percent = 1.0f;
826844
attack_any_idle_circle_distance = 100.0f;
827845

846+
default_form_on_wing_priority = 99; // as originally assigned in ai_add_goal_sub_sexp()
847+
828848
for (int i = 0; i < NUM_SKILL_LEVELS; ++i) {
829849
max_incoming_asteroids[i] = 0;
830850
max_allowed_player_homers[i] = 0;
@@ -938,5 +958,6 @@ void ai_profile_t::reset()
938958
}
939959
if (mod_supports_version(25, 0, 0)) {
940960
flags.set(AI::Profile_Flags::Fix_avoid_shockwave_bugs);
961+
flags.set(AI::Profile_Flags::Purge_player_issued_form_on_wing_after_subsequent_order);
941962
}
942963
}

code/ai/ai_profiles.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ class ai_profile_t {
147147
// AI attack any option --wookieejedi
148148
float attack_any_idle_circle_distance; // Radius that AI circles around a point while waiting for new enemies in attack-any mode
149149

150+
int default_form_on_wing_priority; // the priority used if not specified in the sexp
151+
150152
void reset();
151153
};
152154

code/ai/aicode.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3677,6 +3677,14 @@ void ai_form_on_wing(object *objp, object *goal_objp)
36773677
aip->ai_flags.remove(AI::AI_Flags::Formation_wing);
36783678
aip->ai_flags.set(AI::AI_Flags::Formation_object);
36793679

3680+
// if this goal is going to stick around for a while, change the mode
3681+
if (The_mission.ai_profile->flags[AI::Profile_Flags::Do_not_clear_goals_when_running_form_on_wing])
3682+
{
3683+
aip->mode = AIM_NONE;
3684+
aip->submode = -1;
3685+
aip->submode_start_time = Missiontime;
3686+
}
3687+
36803688
aip->goal_objnum = OBJ_INDEX(goal_objp);
36813689

36823690
ai_formation_object_recalculate_slotnums(aip->goal_objnum);

0 commit comments

Comments
 (0)