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
13 changes: 13 additions & 0 deletions code/ai/ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "parse/sexp.h"
#include "physics/physics.h"
#include "ship/ship_flags.h"
#include "utils/RandomRange.h"

class ship_weapon;
class ship_subsys;
Expand Down Expand Up @@ -142,6 +143,12 @@ typedef struct ai_class {
float ai_secondary_range_mult[NUM_SKILL_LEVELS];
bool ai_class_autoscale; //Defaults to true, but can be turned off in order to disable extra scaling of some AI behaviors
//based on AI class index
::util::ParsedRandomFloatRange primary_select_delay[NUM_SKILL_LEVELS];
::util::ParsedRandomFloatRange primary_select_delay_on_change[NUM_SKILL_LEVELS];
::util::ParsedRandomFloatRange primary_selection_random_factor[NUM_SKILL_LEVELS];
float primary_selection_oneshot_modifier[NUM_SKILL_LEVELS];
float primary_selection_status_quo_bias[NUM_SKILL_LEVELS];

} ai_class;

// Submode definitions.
Expand Down Expand Up @@ -340,6 +347,7 @@ typedef struct ai_info {
float prev_dot_to_goal; // dot of fvec to goal last frame, used to see if making progress towards goal.
vec3d goal_point; // Used in AIM_SAFETY, AIM_STILL and in circling.
vec3d prev_goal_point; // Previous location of goal point, used at least for evading.
bool enemy_shield_is_down;

//Values copied from the AI class
float ai_accuracy, ai_evasion, ai_courage, ai_patience;
Expand Down Expand Up @@ -373,6 +381,11 @@ typedef struct ai_info {
int ai_chance_to_use_missiles_on_plr;
float ai_max_aim_update_delay;
float ai_turret_max_aim_update_delay;
::util::ParsedRandomFloatRange primary_select_delay;
::util::ParsedRandomFloatRange primary_select_delay_on_change;
::util::ParsedRandomFloatRange primary_selection_random_factor;
float primary_selection_oneshot_modifier;
float primary_selection_status_quo_bias;
flagset<AI::Profile_Flags> ai_profile_flags; //Holds AI_Profiles flags (possibly overriden by AI class) that actually apply to AI

ship_subsys* targeted_subsys; // Targeted subobject on current target. NULL if none;
Expand Down
1 change: 1 addition & 0 deletions code/ai/ai_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ namespace AI {
Require_turret_to_have_target_in_fov,
Shockwaves_damage_small_ship_subsystems,
Smart_afterburner_management,
Configurable_primary_weapon_selection,
Smart_primary_weapon_selection,
Smart_secondary_weapon_selection,
Smart_shield_management,
Expand Down
17 changes: 17 additions & 0 deletions code/ai/ai_profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ void parse_ai_profiles_tbl(const char *filename)
if (optional_string("$AI In Range Time:"))
parse_float_list(profile->in_range_time, NUM_SKILL_LEVELS);

if (optional_string("$Primary select delay:")) {
for (auto& entry : profile->primary_select_delay) {
entry = ::util::ParsedRandomFloatRange::parseRandomRange();
}
}

if (optional_string("$Primary select delay on target change:")) {
for (auto& entry : profile->primary_select_delay_on_change) {
entry = ::util::ParsedRandomFloatRange::parseRandomRange();
}
}

if (optional_string("$AI Always Links Ammo Weapons:"))
parse_float_list(profile->link_ammo_levels_always, NUM_SKILL_LEVELS);

Expand Down Expand Up @@ -382,6 +394,8 @@ void parse_ai_profiles_tbl(const char *filename)

set_flag(profile, "$big ships can attack beam turrets on untargeted ships:", AI::Profile_Flags::Big_ships_can_attack_beam_turrets_on_untargeted_ships);

set_flag(profile, "$configurable primary weapon selection:", AI::Profile_Flags::Configurable_primary_weapon_selection);

set_flag(profile, "$smart primary weapon selection:", AI::Profile_Flags::Smart_primary_weapon_selection);

set_flag(profile, "$smart secondary weapon selection:", AI::Profile_Flags::Smart_secondary_weapon_selection);
Expand Down Expand Up @@ -920,6 +934,9 @@ void ai_profile_t::reset()
delay_bomb_arm_timer[i] = 0;
chance_to_use_missiles_on_plr[i] = 0;
player_autoaim_fov[i] = 0;

primary_select_delay[i] = ::util::UniformFloatRange(5.0f);
primary_select_delay_on_change[i] = ::util::UniformFloatRange(9999.0f);
}

for (int i = 0; i <= MAX_DETAIL_VALUE; ++i) {
Expand Down
3 changes: 3 additions & 0 deletions code/ai/ai_profiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "globalincs/pstypes.h"
#include "globalincs/systemvars.h"
#include "ai/ai_flags.h"
#include "utils/RandomRange.h"

// AI Path types
#define AI_PATH_MODE_NORMAL 0
Expand Down Expand Up @@ -69,6 +70,8 @@ class ai_profile_t {
float stalemate_dist_thresh[NUM_SKILL_LEVELS]; // SUSHI: The maximum distance the AI and target must be within for a stalemate
float max_aim_update_delay[NUM_SKILL_LEVELS]; // SUSHI: The maximum delay before the AI updates their aim against small ships
float turret_max_aim_update_delay[NUM_SKILL_LEVELS]; // SUSHI: As above, but for turrets updating their aim
::util::ParsedRandomFloatRange primary_select_delay[NUM_SKILL_LEVELS]; // Time in seconds before next time the AI updates its primary weapon choice
::util::ParsedRandomFloatRange primary_select_delay_on_change[NUM_SKILL_LEVELS]; // Same, but for special updates taking place when the target ship or subsystem changes, or target's shields change

// Multiplicative delay factors for increasing skill levels.
float ship_fire_delay_scale_hostile[NUM_SKILL_LEVELS];
Expand Down
Loading
Loading