Skip to content

Commit 2820532

Browse files
authored
Expose value of idle circling with 'attack-any' (scp-fs2open#7011)
* Expose value of idle circling with 'attack-any' The attack-any order is extremely useful and utilized order, and there was one aspect that was ripe for exposure to modders: the `CHASE_CIRCLE_DIST` that was used to determine how big of a circle to fly around while the AI waited for new hostiles to arrive. For ships with high speeds, like FotG and others, the default radius of 200 m was a bit on the small side, which lead to ships flying in tight circles. This was was counterproductive to goals of tuning the AI to have a more cinematic style, such as where AI would fly around in large distances while waiting for enemies to arrive. Fortunately, this value is easy to expose and allow modders to tune with just a new ai_profiles value. Tested and works as expected. * improve name and use correct distance
1 parent 32084cf commit 2820532

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

code/ai/ai_profiles.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,10 @@ void parse_ai_profiles_tbl(const char *filename)
699699
}
700700
}
701701

702+
if (optional_string("$attack-any idle circle distance:")) {
703+
stuff_float(&profile->attack_any_idle_circle_distance);
704+
}
705+
702706
set_flag(profile, "$unify usage of AI Shield Manage Delay:", AI::Profile_Flags::Unify_usage_ai_shield_manage_delay);
703707

704708
set_flag(profile, "$fix AI shield management bug:", AI::Profile_Flags::Fix_AI_shield_management_bug);
@@ -815,6 +819,7 @@ void ai_profile_t::reset()
815819

816820
guard_big_orbit_above_target_radius = 500.0f;
817821
guard_big_orbit_max_speed_percent = 1.0f;
822+
attack_any_idle_circle_distance = 100.0f;
818823

819824
for (int i = 0; i < NUM_SKILL_LEVELS; ++i) {
820825
max_incoming_asteroids[i] = 0;

code/ai/ai_profiles.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class ai_profile_t {
144144
float guard_big_orbit_above_target_radius; // Radius of guardee that triggers ai_big_guard()
145145
float guard_big_orbit_max_speed_percent; // Max percent of forward speed that is used in ai_big_guard()
146146

147+
// AI attack any option --wookieejedi
148+
float attack_any_idle_circle_distance; // Radius that AI circles around a point while waiting for new enemies in attack-any mode
149+
147150
void reset();
148151
};
149152

code/ai/aicode.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13244,8 +13244,6 @@ static void ai_preprocess_ignore_objnum(ai_info *aip)
1324413244
aip->target_objnum = -1;
1324513245
}
1324613246

13247-
#define CHASE_CIRCLE_DIST 100.0f
13248-
1324913247
void ai_chase_circle(object *objp)
1325013248
{
1325113249
float dist_to_goal;
@@ -13266,11 +13264,11 @@ void ai_chase_circle(object *objp)
1326613264
if (aip->ignore_objnum == UNUSED_OBJNUM) {
1326713265
dist_to_goal = vm_vec_dist_quick(&aip->goal_point, &objp->pos);
1326813266

13269-
if (dist_to_goal > 2*CHASE_CIRCLE_DIST) {
13267+
if (dist_to_goal > 2 * The_mission.ai_profile->attack_any_idle_circle_distance) {
1327013268
vec3d vec_to_goal;
1327113269
// Too far from circle goal, create a new goal point.
1327213270
vm_vec_normalized_dir(&vec_to_goal, &aip->goal_point, &objp->pos);
13273-
vm_vec_scale_add(&aip->goal_point, &objp->pos, &vec_to_goal, CHASE_CIRCLE_DIST);
13271+
vm_vec_scale_add(&aip->goal_point, &objp->pos, &vec_to_goal, The_mission.ai_profile->attack_any_idle_circle_distance);
1327413272
}
1327513273

1327613274
goal_point = aip->goal_point;

0 commit comments

Comments
 (0)