FS2_Open
Open source remastering of the Freespace 2 engine
aicode.cpp File Reference
#include "ai/ai.h"
#include "ai/ai_profiles.h"
#include "ai/aibig.h"
#include "ai/aigoals.h"
#include "ai/aiinternal.h"
#include "asteroid/asteroid.h"
#include "autopilot/autopilot.h"
#include "cmeasure/cmeasure.h"
#include "debugconsole/console.h"
#include "freespace2/freespace.h"
#include "gamesequence/gamesequence.h"
#include "gamesnd/gamesnd.h"
#include "globalincs/linklist.h"
#include "hud/hud.h"
#include "hud/hudets.h"
#include "hud/hudlock.h"
#include "iff_defs/iff_defs.h"
#include "io/joy_ff.h"
#include "io/timer.h"
#include "localization/localize.h"
#include "math/fvi.h"
#include "math/staticrand.h"
#include "mission/missiongoals.h"
#include "mission/missionlog.h"
#include "mission/missionmessage.h"
#include "mission/missionparse.h"
#include "mission/missiontraining.h"
#include "model/model.h"
#include "network/multi.h"
#include "network/multimsgs.h"
#include "network/multiutil.h"
#include "object/deadobjectdock.h"
#include "object/objcollide.h"
#include "object/object.h"
#include "object/objectdock.h"
#include "object/objectshield.h"
#include "object/waypoint.h"
#include "parse/parselo.h"
#include "physics/physics.h"
#include "playerman/player.h"
#include "render/3d.h"
#include "ship/afterburner.h"
#include "ship/awacs.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#include "ship/shiphit.h"
#include "weapon/beam.h"
#include "weapon/flak.h"
#include "weapon/swarm.h"
#include "weapon/weapon.h"
#include <map>
#include <limits.h>

Go to the source code of this file.

Classes

struct  huge_fire_info
 
struct  eval_nearest_objnum
 
struct  sgoal
 
struct  ai_render_stuff
 

Macros

#define UNINITIALIZED_VALUE   -99999.9f
 
#define INSTRUCTOR_SHIP_NAME   NOX("instructor")
 
#define AICODE_SMALL_MAGNITUDE   0.001f
 
#define NEXT_REARM_TIMESTAMP   (60*1000)
 
#define CIRCLE_STRAFE_MAX_DIST   300.0f
 
#define SM_SF_AHEAD   0
 
#define SM_SF_BEHIND   1
 
#define SM_SF_BAIL   2
 
#define SM_SS_SET_GOAL   -1
 
#define SM_SS_BOX0   0
 
#define SM_SS_LR   1
 
#define SM_SS_UL   2
 
#define SM_SS_BOX1   3
 
#define SM_SS_UR   4
 
#define SM_SS_LL   5
 
#define SM_SS_BOX2   6
 
#define SM_SS_DONE   7
 
#define REARM_SOUND_DELAY   (3*F1_0)
 
#define REARM_BREAKOFF_DELAY   (3*F1_0)
 
#define MIN_DIST_TO_WAYPOINT_GOAL   5.0f
 
#define MAX_GUARD_DIST   250.0f
 
#define BIG_GUARD_RADIUS   500.0f
 
#define MAX_EVADE_TIME   (15 * 1000)
 
#define MAX_REPAIR_SPEED   25.0f
 
#define MAX_UNDOCK_ABORT_SPEED   2.0f
 
#define MAX_EMP_INACCURACY   50.0f
 
#define MAX_STEALTH_INACCURACY   50.0f
 
#define STEALTH_MAX_VIEW_DIST   400
 
#define STEALTH_VIEW_CONE_DOT   0.707
 
#define DELAY_TARGET_TIME   (12*1000)
 
#define AI_CLASS_INCREMENT   10
 
#define STEALTH_NOT_IN_FRUSTUM   0
 
#define STEALTH_IN_FRUSTUM   1
 
#define STEALTH_FULLY_TARGETABLE   2
 
#define BIGNUM   100000.0f
 
#define MAX_AI_DEBUG_RENDER_STUFF   100
 
#define DEFAULT_WING_X_DELTA   1.0f
 
#define DEFAULT_WING_Y_DELTA   0.25f
 
#define DEFAULT_WING_Z_DELTA   0.75f
 
#define DEFAULT_WING_MAG   (fl_sqrt(DEFAULT_WING_X_DELTA*DEFAULT_WING_X_DELTA + DEFAULT_WING_Y_DELTA*DEFAULT_WING_Y_DELTA + DEFAULT_WING_Z_DELTA*DEFAULT_WING_Z_DELTA))
 
#define MAX_FORMATION_ROWS   4
 
#define CHASE_CIRCLE_DIST   100.0f
 
#define SHIELD_BALANCE_RATE   0.2f
 
#define EVADE_SHOCKWAVE_DAMAGE_THRESHOLD   100.0f
 
#define FRIENDLY_DAMAGE_THRESHOLD   50.0f
 

Typedefs

typedef struct eval_nearest_objnum eval_nearest_objnum
 
typedef struct ai_render_stuff ai_render_stuff
 

Functions

objectget_wing_leader (int wingnum)
 
int get_wing_index (object *objp, int wingnum)
 
const char * Skill_level_names (int level, int translate)
 
int ai_return_path_num_from_dockbay (object *dockee_objp, int dockbay_index)
 
void create_model_exit_path (object *pl_objp, object *mobjp, int path_num, int count=1)
 
void copy_xlate_model_path_points (object *objp, model_path *mp, int dir, int count, int path_num, pnode *pnp, int randomize_pnt=-1)
 
void ai_cleanup_rearm_mode (object *objp)
 
void ai_cleanup_dock_mode_subjective (object *objp)
 
void ai_cleanup_dock_mode_objective (object *objp)
 
void ai_set_rearm_status (int team, int time)
 
int ai_good_time_to_rearm (object *objp)
 
void ai_good_secondary_time (int team, int weapon_index, int max_fire_count, char *shipname)
 
int is_preferred_weapon (int weapon_num, object *firer_objp, object *target_objp)
 
void ai_init_secondary_info ()
 
void garbage_collect_path_points ()
 
int hash (unsigned int curval, int newval)
 
int create_object_hash (object *objp)
 
void free_ai_stuff ()
 
void init_ai_class (ai_class *aicp)
 
void set_aic_flag (ai_class *aicp, char *name, int flag, int type)
 
void parse_ai_class ()
 
void reset_ai_class_names ()
 
void parse_aitbl ()
 
void ai_init ()
 
void ai_level_init ()
 
bool is_object_stealth_ship (object *objp)
 
void init_ai_stealth_info (ai_info *aip, object *stealth_objp)
 
float get_skill_stealth_dist_scaler ()
 
float get_skill_stealth_dot_scaler ()
 
int ai_is_stealth_visible (object *viewer_objp, object *stealth_objp)
 
float compute_dots (object *objp, object *other_objp, float *to_dot, float *from_dot)
 
void update_ai_stealth_info_with_error (ai_info *aip)
 
void ai_update_danger_weapon (int attacked_objnum, int weapon_objnum)
 
void ai_turn_towards_vector (vec3d *dest, object *objp, float frametime, float turn_time, vec3d *slide_vec, vec3d *rel_pos, float bank_override, int flags, vec3d *rvec, int sexp_flags)
 
int set_target_objnum (ai_info *aip, int objnum)
 
int ai_select_primary_weapon (object *objp, object *other_objp, int flags)
 
ship_subsysset_targeted_subsys (ai_info *aip, ship_subsys *new_subsys, int parent_objnum)
 
void ai_object_init (object *obj, int ai_index)
 
void adjust_accel_for_docking (ai_info *aip)
 
void accelerate_ship (ai_info *aip, float accel)
 
void change_acceleration (ai_info *aip, float delta_accel)
 
void set_accel_for_target_speed (object *objp, float tspeed)
 
void project_point_to_perimeter (vec3d *perim_point, vec3d *pos, float radius, vec3d *vp)
 
void get_tangent_point (vec3d *tan1, vec3d *p0, vec3d *centerp, vec3d *p1, float radius)
 
void turn_towards_point (object *objp, vec3d *point, vec3d *slide_vec, float bank_override)
 
void turn_away_from_point (object *objp, vec3d *point, float bank_override)
 
float turn_towards_tangent (object *objp, vec3d *point, float radius)
 
float turn_toward_tangent_with_axis (object *objp, object *center_objp, float radius)
 
void get_tangent_point (vec3d *goal_point, object *objp, vec3d *point, float radius)
 
int object_is_targetable (object *target, ship *viewer)
 
int num_enemies_attacking (int objnum)
 
float get_wing_lowest_max_speed (object *objp)
 
float get_wing_lowest_av_ab_speed (object *objp)
 
int is_ignore_object_sub (int *ignore_objnum, int *ignore_signature, int objnum)
 
int find_ignore_new_object_index (ai_info *aip, int objnum)
 
int is_ignore_object (ai_info *aip, int objnum, int just_the_original=0)
 
void evaluate_object_as_nearest_objnum (eval_nearest_objnum *eno)
 
int get_nearest_objnum (int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers)
 
int find_nearby_threat (int objnum, int enemy_team_mask, float range, int *count)
 
int num_turrets_attacking (object *turret_parent, int target_objnum)
 
int get_enemy_timestamp ()
 
int find_enemy (int objnum, float range, int max_attackers)
 
void ai_set_goal_maybe_abort_dock (object *objp, ai_info *aip)
 
void force_avoid_player_check (object *objp, ai_info *aip)
 
void ai_attack_object (object *attacker, object *attacked, ship_subsys *ssp)
 
void ai_attack_wing (object *attacker, int wingnum)
 
void ai_evade_object (object *evader, object *evaded)
 
int compact_ignore_new_objects (ai_info *aip, int force=0)
 
void ai_ignore_object (object *ignorer, object *ignored, int ignore_new)
 
void ai_ignore_wing (object *ignorer, int wingnum)
 
void add_path_point (vec3d *pos, int path_num, int path_index, int modify_index)
 
void bisect_chord (vec3d *p0, vec3d *p1, vec3d *centerp, float radius)
 
void create_path_to_point (vec3d *curpos, vec3d *goalpos, object *curobjp, object *goalobjp, int subsys_path)
 
void create_model_path (object *pl_objp, object *mobjp, int path_num, int subsys_path)
 
int pp_collide_any (vec3d *curpos, vec3d *goalpos, float radius, object *ignore_objp1, object *ignore_objp2, int big_only_flag)
 
void ai_find_path (object *pl_objp, int objnum, int path_num, int exit_flag, int subsys_path)
 
int vector_object_collision (vec3d *start_pos, vec3d *end_pos, object *objp, float radius_scale)
 
int maybe_avoid_player (object *objp, vec3d *goal_pos)
 
void ai_stay_still (object *still_objp, vec3d *view_pos)
 
void ai_do_objects_docked_stuff (object *docker, int docker_point, object *dockee, int dockee_point, bool update_clients)
 
void ai_do_objects_undocked_stuff (object *docker, object *dockee)
 
void ai_dock_with_object (object *docker, int docker_index, object *dockee, int dockee_index, int dock_type)
 
void ai_start_fly_to_ship (object *objp, int shipnum)
 
void ai_start_waypoints (object *objp, waypoint_list *wp_list, int wp_flags)
 
void ai_do_stay_near (object *objp, object *other_objp, float dist)
 
void ai_do_safety (object *objp)
 
void ai_form_on_wing (object *objp, object *goal_objp)
 
int ai_formation_object_get_slotnum (int objnum, object *objp)
 
float compute_collision_time (vec3d *targpos, vec3d *targvel, vec3d *attackpos, float weapon_speed)
 
float compute_time_to_enemy (float dist_to_enemy, object *pobjp)
 
void fds_aux (float *dot, float *tts, vec3d *pos, float dtime, object *objp)
 
void ai_set_positions (object *pl_objp, object *en_objp, ai_info *aip, vec3d *player_pos, vec3d *enemy_pos)
 
void ai_update_aim (ai_info *aip)
 
int get_base_path_info (int path_cur, int goal_objnum, model_path **pmp, mp_vert **pmpv)
 
void modify_model_path_points (object *objp)
 
float ai_matrix_dist (matrix *mat1, matrix *mat2)
 
float maybe_recreate_path (object *objp, ai_info *aip, int force_recreate_flag, int override_hash=0)
 
void set_accel_for_docking (object *objp, ai_info *aip, float dot, float dot_to_next, float dist_to_next, float dist_to_goal, ship_info *sip, float max_allowed_speed, object *gobjp)
 
float ai_path_0 ()
 
float ai_path_1 ()
 
float ai_path ()
 
void update_min_max (float val, float *min, float *max)
 
int get_enemy_team_range (object *my_objp, float range, int enemy_team_mask, vec3d *min_vec, vec3d *max_vec)
 
void ai_safety_pick_spot (object *objp)
 
float ai_safety_goto_spot (object *objp)
 
void ai_safety_circle_spot (object *objp)
 
void ai_safety ()
 
void ai_fly_to_target_position (vec3d *target_pos, bool *pl_done_p=NULL, bool *pl_treat_as_ship_p=NULL)
 
void ai_waypoints ()
 
void ai_fly_to_ship ()
 
void avoid_ship ()
 
int maybe_resume_previous_mode (object *objp, ai_info *aip)
 
int static_rand_timed (int num, int modulus)
 
int ai_maybe_fire_afterburner (object *objp, ai_info *aip)
 
void maybe_afterburner_after_ship_hit (object *objp, ai_info *aip, object *en_objp)
 
int is_instructor (object *objp)
 
void evade_weapon ()
 
void slide_face_ship ()
 
void evade_ship ()
 
void ai_evade ()
 
int ai_select_primary_weapon_OLD (object *objp, object *other_objp, int flags)
 
void set_primary_weapon_linkage (object *objp)
 
int ai_fire_primary_weapon (object *objp)
 
int num_nearby_fighters (int enemy_team_mask, vec3d *pos, float threshold)
 
void ai_select_secondary_weapon (object *objp, ship_weapon *swp, int priority1=-1, int priority2=-1, int wif2_priority1=-1, int wif2_priority2=-1)
 
int compute_num_homing_objects (object *target_objp)
 
void ai_maybe_announce_shockwave_weapon (object *firing_objp, int weapon_index)
 
float compute_incoming_payload (object *target_objp)
 
int check_ok_to_fire (int objnum, int target_objnum, weapon_info *wip)
 
int ai_fire_secondary_weapon (object *objp, int priority1, int priority2)
 
int might_collide_with_ship (object *obj1, object *obj2, float dot_to_enemy, float dist_to_enemy, float duration)
 
int might_hit_teammate (object *firing_objp)
 
void render_all_ship_bay_paths (object *objp)
 
void render_all_subsys_paths (object *objp)
 
void render_path_points (object *objp)
 
float ai_get_weapon_dist (ship_weapon *swp)
 
float ai_get_weapon_speed (ship_weapon *swp)
 
weapon_infoai_get_weapon (ship_weapon *swp)
 
void set_predicted_enemy_pos_turret (vec3d *predicted_enemy_pos, vec3d *gun_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, float weapon_speed, float time_enemy_in_range)
 
void set_predicted_enemy_pos (vec3d *predicted_enemy_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, ai_info *aip)
 
void ai_chase_ct ()
 
void ai_chase_eb (ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float dist_to_enemy)
 
float ai_endangered_time (object *ship_objp, object *weapon_objp)
 
float ai_endangered_by_weapon (ai_info *aip)
 
int ai_near_full_strength (object *objp)
 
void do_random_sidethrust (ai_info *aip, ship_info *sip)
 
void attack_set_accel (ai_info *aip, ship_info *sip, float dist_to_enemy, float dot_to_enemy, float dot_from_enemy)
 
void get_behind_ship (ai_info *aip, ship_info *sip, float dist_to_enemy)
 
int avoid_player (object *objp, vec3d *goal_pos)
 
int will_collide_pp (vec3d *p0, vec3d *p1, float radius, object *big_objp, vec3d *collision_point)
 
int will_collide_with_big_ship (object *objp, vec3d *goal_point, object *big_objp, vec3d *collision_point, float delta_time)
 
int will_collide_with_big_ship_all (object *objp, object *ignore_objp, vec3d *goal_point, vec3d *collision_point, float *distance, float delta_time)
 
void mabs_pick_goal_point (object *objp, object *big_objp, vec3d *collision_point, vec3d *avoid_pos)
 
int maybe_avoid_big_ship (object *objp, object *ignore_objp, ai_info *aip, vec3d *goal_point, float delta_time)
 
void compute_desired_rvec (vec3d *rvec, vec3d *goal_pos, vec3d *cur_pos)
 
void ai_stealth_find ()
 
void ai_stealth_sweep ()
 
void ai_chase_attack (ai_info *aip, ship_info *sip, vec3d *predicted_enemy_pos, float dist_to_enemy, int modelnum)
 
void ai_chase_es (ai_info *aip, ship_info *sip)
 
void ai_chase_ga (ai_info *aip, ship_info *sip)
 
int ai_set_attack_subsystem (object *objp, int subnum)
 
void ai_set_guard_vec (object *objp, object *guard_objp)
 
void ai_set_guard_wing (object *objp, int wingnum)
 
void ai_set_evade_object (object *objp, object *other_objp)
 
void ai_set_guard_object (object *objp, object *other_objp)
 
void update_aspect_lock_information (ai_info *aip, vec3d *vec_to_enemy, float dist_to_enemy, float enemy_radius)
 
void ai_chase_fly_away (object *objp, ai_info *aip)
 
int has_preferred_secondary (object *objp, object *en_objp, ship_weapon *swp)
 
void ai_choose_secondary_weapon (object *objp, ai_info *aip, object *en_objp)
 
float set_secondary_fire_delay (ai_info *aip, ship *shipp, weapon_info *swip, bool burst)
 
void ai_chase_big_approach_set_goal (vec3d *goal_pos, object *attack_objp, object *target_objp, float *accel)
 
void ai_chase_big_circle_set_goal (vec3d *goal_pos, object *attack_objp, object *target_objp, float *accel)
 
void ai_chase_big_get_separations (object *attack_objp, object *target_objp, vec3d *horz_vec_to_target, float *desired_separation, float *cur_separation)
 
void ai_chase_big_parallel_set_goal (vec3d *goal_pos, object *attack_objp, object *target_objp, float *accel)
 
void ai_cruiser_chase_set_goal_pos (vec3d *goal_pos, object *pl_objp, object *en_objp)
 
int maybe_hack_cruiser_chase_abort ()
 
void ai_cruiser_chase ()
 
void ai_chase ()
 
float dock_move_towards_point (object *objp, vec3d *start, vec3d *finish, float speed_scale, float other_obj_speed=0.0f, rotating_dockpoint_info *rdinfo=NULL)
 
void set_goal_dock_orient (matrix *dom, vec3d *docker_p0, vec3d *docker_p1, vec3d *docker_p0_norm, matrix *docker_orient, vec3d *dockee_p0, vec3d *dockee_p1, vec3d *dockee_p0_norm, matrix *dockee_orient)
 
int find_parent_rotating_submodel (polymodel *pm, int dock_index)
 
void find_adjusted_dockpoint_info (vec3d *global_p0, vec3d *global_p1, vec3d *global_p0_norm, object *objp, polymodel *pm, int modelnum, int submodel, int dock_index)
 
float dock_orient_and_approach (object *docker_objp, int docker_index, object *dockee_objp, int dockee_index, int dock_mode, rotating_dockpoint_info *rdinfo)
 
void debug_find_guard_object ()
 
int num_ships_attacking (int target_objnum)
 
void remove_farthest_attacker (int objnum)
 
int ai_maybe_limit_attackers (int attacked_objnum)
 
void guard_object_was_hit (object *guard_objp, object *hitter_objp)
 
void maybe_update_guard_object (object *hit_objp, object *hitter_objp)
 
int ai_guard_find_nearby_bomb (object *guarding_objp, object *guarded_objp)
 
void ai_guard_find_nearby_ship (object *guarding_objp, object *guarded_objp)
 
void ai_guard_find_nearby_asteroid (object *guarding_objp, object *guarded_objp)
 
void ai_guard_find_nearby_object ()
 
float get_cylinder_points (object *other_objp, object *cyl_objp, vec3d *axis_pt, vec3d *r_vec, float *radius)
 
void ai_big_guard ()
 
void ai_guard ()
 
void ai_do_objects_repairing_stuff (object *repaired_objp, object *repair_objp, int how)
 
void ai_get_dock_goal_indexes (object *objp, ai_info *aip, ai_goal *aigp, object *goal_objp, int &docker_index, int &dockee_index)
 
void ai_still ()
 
void ai_stay_near ()
 
int maybe_dock_obstructed (object *cur_objp, object *goal_objp, int big_only_flag)
 
void ai_dock ()
 
void ai_debug_render_stuff ()
 
void process_subobjects (int objnum)
 
void get_wing_delta (vec3d *_delta_vec, int wing_index)
 
float gwlr_1 (object *objp, ai_info *aip)
 
float gwlr_object_1 (object *objp, ai_info *aip)
 
float get_wing_largest_radius (object *objp, int formation_object_flag)
 
void get_absolute_wing_pos (vec3d *result_pos, object *leader_objp, int wing_index, int formation_object_flag)
 
void get_absolute_wing_pos_autopilot (vec3d *result_pos, object *leader_objp, int wing_index, int formation_object_flag)
 
void render_wing_phantoms (object *objp)
 
void render_wing_phantoms_all ()
 
void ai_fly_in_formation (int wingnum)
 
void ai_disband_formation (int wingnum)
 
int formation_is_leader_chaotic (object *objp)
 
void ai_most_massive_object_of_its_wing_of_all_docked_objects_helper (object *objp, dock_function_info *infop)
 
int ai_formation ()
 
void ai_do_repair_frame (object *objp, ai_info *aip, float frametime)
 
void call_doa (object *child, object *parent)
 
void ai_maybe_launch_cmeasure (object *objp, ai_info *aip)
 
void ai_preprocess_ignore_objnum (object *objp, ai_info *aip)
 
void ai_chase_circle (object *objp)
 
void ai_transfer_shield (object *objp, int quadrant_num)
 
void ai_balance_shield (object *objp)
 
void ai_manage_shield (object *objp, ai_info *aip)
 
void ai_maybe_evade_locked_missile (object *objp, ai_info *aip)
 
void maybe_evade_dumbfire_weapon (ai_info *aip)
 
void ai_manage_bay_doors (object *pl_objp, ai_info *aip, bool done)
 
int ai_acquire_emerge_path (object *pl_objp, int parent_objnum, int allowed_path_mask, vec3d *pos, vec3d *fvec)
 
void ai_emerge_bay_path_cleanup (ai_info *aip)
 
void ai_bay_emerge ()
 
int ai_find_closest_depart_path (ai_info *aip, polymodel *pm, int allowed_path_mask)
 
int ai_acquire_depart_path (object *pl_objp, int parent_objnum, int allowed_path_mask)
 
void ai_bay_depart ()
 
void ai_sentrygun ()
 
void ai_execute_behavior (ai_info *aip)
 
int mrs_subsystem (ship *shipp, int type)
 
int num_allies_rearming (object *objp)
 
int maybe_request_support (object *objp)
 
void ai_set_mode_warp_out (object *objp, ai_info *aip)
 
void ai_maybe_depart (object *objp)
 
void ai_warp_out (object *objp)
 
int ai_find_shockwave_weapon (object *objp, ai_info *aip)
 
void ai_announce_ship_dying (object *dying_objp)
 
int ai_find_shockwave_ship (object *objp, ai_info *aip)
 
int aas_1 (object *objp, ai_info *aip, vec3d *safe_pos)
 
int ai_avoid_shockwave (object *objp, ai_info *aip)
 
int ai_await_repair_frame (object *objp, ai_info *aip)
 
void ai_maybe_self_destruct (object *objp, ai_info *aip)
 
int ai_need_new_target (object *pl_objp, int target_objnum)
 
int maybe_big_ship_collide_recover_frame (object *objp, ai_info *aip)
 
void validate_mode_submode (ai_info *aip)
 
void ai_frame (int objnum)
 
void ai_control_info_check (object *obj, ai_info *aip)
 
void ai_process (object *obj, int ai_index, float frametime)
 
void init_ai_object (int objnum)
 
void init_ai_system ()
 
int combine_flags (int base_flags, int override_flags, int override_set)
 
void init_aip_from_class_and_profile (ai_info *aip, ai_class *aicp, ai_profile_t *profile)
 
void ai_do_default_behavior (object *obj)
 
void process_friendly_hit_message (int message, object *objp)
 
void ship_set_subsystem_strength (ship *shipp, int type, float strength)
 
void maybe_process_friendly_hit (object *objp_hitter, object *objp_hit, object *objp_weapon)
 
void maybe_set_dynamic_chase (ai_info *aip, int hitter_objnum)
 
int firing_aspect_seeking_bomb (object *objp)
 
void big_ship_collide_recover_start (object *objp, object *big_objp, vec3d *collide_pos, vec3d *collision_normal)
 
void ai_update_lethality (object *pship_obj, object *other_obj, float damage)
 
void ai_ship_hit (object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal)
 
void ai_ship_destroy (int shipnum, int method)
 
void ai_deathroll_start (object *dying_objp)
 
int ai_abort_rearm_request (object *requester_objp)
 
void ai_add_rearm_goal (object *requester_objp, object *support_objp)
 
int ai_issue_rearm_request (object *requester_objp)
 
void ai_rearm_repair (object *objp, int docker_index, object *goal_objp, int dockee_index)
 
void cheat_fire_synaptic (object *objp, ship *shipp, ai_info *aip)
 
void maybe_cheat_fire_synaptic (object *objp, ai_info *aip)
 

Variables

char * Mode_text [MAX_AI_BEHAVIORS]
 
char * Submode_text []
 
char * Strafe_submode_text [5]
 
control_info AI_ci
 
objectPl_objp
 
objectEn_objp
 
ai_classAi_classes = NULL
 
int Ai_firing_enabled = 1
 
int Num_ai_classes
 
int Num_alloced_ai_classes
 
int AI_FrameCount = 0
 
int AI_watch_object = 0
 
int Mission_all_attack = 0
 
ai_flag_name Ai_flag_names []
 
pnode Path_points [MAX_PATH_POINTS]
 
pnodePpfp
 
float AI_frametime
 
char ** Ai_class_names = NULL
 
SCP_vector< huge_fire_infoAi_huge_fire_info
 
int Ai_last_arrive_path
 
objectAutopilot_flight_leader = NULL
 
LOCAL int ai_inited = 0
 
int Player_attacking_enabled = 1
 
int Debug_k = 0
 
float G_collision_time
 
vec3d G_predicted_pos
 
vec3d G_fire_pos
 
ai_render_stuff AI_debug_render_stuff [MAX_AI_DEBUG_RENDER_STUFF]
 
int Num_AI_debug_render_stuff = 0
 
float Wing_y_scale = 2.0f
 
float Wing_scale = 1.0f
 
int Debug_render_wing_phantoms
 
float Leader_chaos = 0.0f
 
int Chaos_frame = -1
 
int Last_ai_obj = -1
 
float max_lethality = 0.0f
 

Detailed Description

Contains the actual AI code that does interesting stuff to objects.

The code in Ai.cpp is just for bookkeeping, allocating AI slots and linking them to ships.

Definition in file aicode.cpp.

Macro Definition Documentation

#define AI_CLASS_INCREMENT   10

Definition at line 783 of file aicode.cpp.

#define AICODE_SMALL_MAGNITUDE   0.001f

Definition at line 83 of file aicode.cpp.

#define BIG_GUARD_RADIUS   500.0f

Definition at line 177 of file aicode.cpp.

#define BIGNUM   100000.0f

Definition at line 3351 of file aicode.cpp.

#define CHASE_CIRCLE_DIST   100.0f

Definition at line 12184 of file aicode.cpp.

#define CIRCLE_STRAFE_MAX_DIST   300.0f

Definition at line 87 of file aicode.cpp.

#define DEFAULT_WING_X_DELTA   1.0f

Definition at line 11289 of file aicode.cpp.

#define DEFAULT_WING_Y_DELTA   0.25f

Definition at line 11290 of file aicode.cpp.

#define DEFAULT_WING_Z_DELTA   0.75f

Definition at line 11291 of file aicode.cpp.

#define DELAY_TARGET_TIME   (12*1000)

Definition at line 261 of file aicode.cpp.

#define EVADE_SHOCKWAVE_DAMAGE_THRESHOLD   100.0f

Definition at line 13501 of file aicode.cpp.

#define FRIENDLY_DAMAGE_THRESHOLD   50.0f

Definition at line 14604 of file aicode.cpp.

#define INSTRUCTOR_SHIP_NAME   NOX("instructor")

Definition at line 81 of file aicode.cpp.

#define MAX_AI_DEBUG_RENDER_STUFF   100

Definition at line 11071 of file aicode.cpp.

#define MAX_EMP_INACCURACY   50.0f

Definition at line 186 of file aicode.cpp.

#define MAX_EVADE_TIME   (15 * 1000)

Definition at line 179 of file aicode.cpp.

#define MAX_FORMATION_ROWS   4

Definition at line 11294 of file aicode.cpp.

#define MAX_GUARD_DIST   250.0f

Definition at line 176 of file aicode.cpp.

#define MAX_REPAIR_SPEED   25.0f

Definition at line 182 of file aicode.cpp.

#define MAX_STEALTH_INACCURACY   50.0f

Definition at line 189 of file aicode.cpp.

#define MAX_UNDOCK_ABORT_SPEED   2.0f

Definition at line 183 of file aicode.cpp.

#define MIN_DIST_TO_WAYPOINT_GOAL   5.0f

Definition at line 175 of file aicode.cpp.

#define NEXT_REARM_TIMESTAMP   (60*1000)

Definition at line 85 of file aicode.cpp.

#define REARM_BREAKOFF_DELAY   (3*F1_0)

Definition at line 173 of file aicode.cpp.

#define REARM_SOUND_DELAY   (3*F1_0)

Definition at line 172 of file aicode.cpp.

#define SHIELD_BALANCE_RATE   0.2f

Definition at line 12237 of file aicode.cpp.

#define SM_SF_AHEAD   0

Definition at line 91 of file aicode.cpp.

#define SM_SF_BAIL   2

Definition at line 93 of file aicode.cpp.

#define SM_SF_BEHIND   1

Definition at line 92 of file aicode.cpp.

#define SM_SS_BOX0   0

Definition at line 97 of file aicode.cpp.

#define SM_SS_BOX1   3

Definition at line 100 of file aicode.cpp.

#define SM_SS_BOX2   6

Definition at line 103 of file aicode.cpp.

#define SM_SS_DONE   7

Definition at line 104 of file aicode.cpp.

#define SM_SS_LL   5

Definition at line 102 of file aicode.cpp.

#define SM_SS_LR   1

Definition at line 98 of file aicode.cpp.

#define SM_SS_SET_GOAL   -1

Definition at line 96 of file aicode.cpp.

#define SM_SS_UL   2

Definition at line 99 of file aicode.cpp.

#define SM_SS_UR   4

Definition at line 101 of file aicode.cpp.

#define STEALTH_FULLY_TARGETABLE   2

Definition at line 908 of file aicode.cpp.

#define STEALTH_IN_FRUSTUM   1

Definition at line 907 of file aicode.cpp.

#define STEALTH_MAX_VIEW_DIST   400

Definition at line 190 of file aicode.cpp.

#define STEALTH_NOT_IN_FRUSTUM   0

Definition at line 906 of file aicode.cpp.

#define STEALTH_VIEW_CONE_DOT   0.707

Definition at line 191 of file aicode.cpp.

#define UNINITIALIZED_VALUE   -99999.9f

Definition at line 79 of file aicode.cpp.

Typedef Documentation

Function Documentation

int aas_1 ( object objp,
ai_info aip,
vec3d safe_pos 
)

Definition at line 13568 of file aicode.cpp.

void accelerate_ship ( ai_info aip,
float  accel 
)

Definition at line 1370 of file aicode.cpp.

void add_path_point ( vec3d pos,
int  path_num,
int  path_index,
int  modify_index 
)

Add a path point in the global buffer Path_points.

If modify_index == -1, then create a new point. If a new point is created (ie, modify_index == -1), then Ppfp is updated.

Parameters
posPosition in vector space
path_numPath numbers
path_indexIndex into path
modify_indexIndex in Path_points at which to store path point.

Definition at line 2512 of file aicode.cpp.

void adjust_accel_for_docking ( ai_info aip)

If *aip is docked, set max acceleration to A->mass/(A->mass + B->mass) where A is *aip and B is dock object

Definition at line 1346 of file aicode.cpp.

int ai_abort_rearm_request ( object requester_objp)

Definition at line 15338 of file aicode.cpp.

int ai_acquire_depart_path ( object pl_objp,
int  parent_objnum,
int  allowed_path_mask 
)

Definition at line 12883 of file aicode.cpp.

int ai_acquire_emerge_path ( object pl_objp,
int  parent_objnum,
int  allowed_path_mask,
vec3d pos,
vec3d fvec 
)

Definition at line 12632 of file aicode.cpp.

void ai_add_rearm_goal ( object requester_objp,
object support_objp 
)

Definition at line 15421 of file aicode.cpp.

void ai_announce_ship_dying ( object dying_objp)

Definition at line 13506 of file aicode.cpp.

void ai_attack_object ( object attacker,
object attacked,
ship_subsys ssp 
)

Set *attacked as object to attack for object *attacker

If attacked == NULL, then attack any enemy object. Attack point *rel_pos on object. This is for supporting attacking subsystems.

Definition at line 2257 of file aicode.cpp.

void ai_attack_wing ( object attacker,
int  wingnum 
)

Set *attacked as object to attack for object *attacker Attack point *rel_pos on object. This is for supporting attacking subsystems.

Definition at line 2326 of file aicode.cpp.

int ai_avoid_shockwave ( object objp,
ai_info aip 
)

Definition at line 13711 of file aicode.cpp.

int ai_await_repair_frame ( object objp,
ai_info aip 
)

Definition at line 13765 of file aicode.cpp.

void ai_balance_shield ( object objp)

Definition at line 12271 of file aicode.cpp.

void ai_bay_depart ( )

Handler for AIM_BAY_DEPART

Definition at line 12956 of file aicode.cpp.

void ai_bay_emerge ( )

Handler for AIM_BAY_EMERGE

Definition at line 12748 of file aicode.cpp.

void ai_big_guard ( )

Definition at line 9804 of file aicode.cpp.

void ai_chase ( )

Make object Pl_objp chase object En_objp

Definition at line 8148 of file aicode.cpp.

void ai_chase_attack ( ai_info aip,
ship_info sip,
vec3d predicted_enemy_pos,
float  dist_to_enemy,
int  modelnum 
)

ATTACK submode handler for chase mode.

Definition at line 7227 of file aicode.cpp.

void ai_chase_big_approach_set_goal ( vec3d goal_pos,
object attack_objp,
object target_objp,
float accel 
)

Definition at line 7813 of file aicode.cpp.

void ai_chase_big_circle_set_goal ( vec3d goal_pos,
object attack_objp,
object target_objp,
float accel 
)

Definition at line 7831 of file aicode.cpp.

void ai_chase_big_get_separations ( object attack_objp,
object target_objp,
vec3d horz_vec_to_target,
float desired_separation,
float cur_separation 
)

Get the current and desired horizontal separations between target

Definition at line 7841 of file aicode.cpp.

void ai_chase_big_parallel_set_goal ( vec3d goal_pos,
object attack_objp,
object target_objp,
float accel 
)

Definition at line 7874 of file aicode.cpp.

void ai_chase_circle ( object objp)

Definition at line 12186 of file aicode.cpp.

void ai_chase_ct ( )

Handler of submode for Chase. Go into a continuous turn for awhile.

Definition at line 6505 of file aicode.cpp.

void ai_chase_eb ( ai_info aip,
ship_info sip,
vec3d predicted_enemy_pos,
float  dist_to_enemy 
)

ATTACK submode handler for chase mode.

Definition at line 6544 of file aicode.cpp.

void ai_chase_es ( ai_info aip,
ship_info sip 
)

Definition at line 7285 of file aicode.cpp.

void ai_chase_fly_away ( object objp,
ai_info aip 
)

Definition at line 7643 of file aicode.cpp.

void ai_chase_ga ( ai_info aip,
ship_info sip 
)

Trying to get away from opponent.

Definition at line 7319 of file aicode.cpp.

void ai_choose_secondary_weapon ( object objp,
ai_info aip,
object en_objp 
)

Definition at line 7700 of file aicode.cpp.

void ai_cleanup_dock_mode_objective ( object objp)

Definition at line 10481 of file aicode.cpp.

void ai_cleanup_dock_mode_subjective ( object objp)

Definition at line 10417 of file aicode.cpp.

void ai_cleanup_rearm_mode ( object objp)

Definition at line 10491 of file aicode.cpp.

void ai_control_info_check ( object obj,
ai_info aip 
)

Definition at line 14181 of file aicode.cpp.

void ai_cruiser_chase ( )

Definition at line 7987 of file aicode.cpp.

void ai_cruiser_chase_set_goal_pos ( vec3d goal_pos,
object pl_objp,
object en_objp 
)

Definition at line 7940 of file aicode.cpp.

void ai_deathroll_start ( object dying_objp)

Do stuff at start of deathroll.

Definition at line 15299 of file aicode.cpp.

void ai_debug_render_stuff ( )

Definition at line 11081 of file aicode.cpp.

void ai_disband_formation ( int  wingnum)

Definition at line 11556 of file aicode.cpp.

void ai_do_default_behavior ( object obj)

Definition at line 14564 of file aicode.cpp.

void ai_do_objects_docked_stuff ( object docker,
int  docker_point,
object dockee,
int  dockee_point,
bool  update_clients 
)

Definition at line 3008 of file aicode.cpp.

void ai_do_objects_repairing_stuff ( object repaired_objp,
object repair_objp,
int  how 
)

Definition at line 10186 of file aicode.cpp.

void ai_do_objects_undocked_stuff ( object docker,
object dockee 
)

Definition at line 3054 of file aicode.cpp.

void ai_do_repair_frame ( object objp,
ai_info aip,
float  frametime 
)

If object *objp is being repaired, deal with it!

Definition at line 11996 of file aicode.cpp.

void ai_do_safety ( object objp)

Definition at line 3273 of file aicode.cpp.

void ai_do_stay_near ( object objp,
object other_objp,
float  dist 
)

Make *objp stay within dist units of *other_objp

Definition at line 3254 of file aicode.cpp.

void ai_dock ( )

Definition at line 10613 of file aicode.cpp.

void ai_dock_with_object ( object docker,
int  docker_index,
object dockee,
int  dockee_index,
int  dock_type 
)

Definition at line 3098 of file aicode.cpp.

void ai_emerge_bay_path_cleanup ( ai_info aip)

Clean up path data used for emerging from a fighter bay

Definition at line 12737 of file aicode.cpp.

float ai_endangered_by_weapon ( ai_info aip)

Definition at line 6584 of file aicode.cpp.

float ai_endangered_time ( object ship_objp,
object weapon_objp 
)

Definition at line 6565 of file aicode.cpp.

void ai_evade ( )

Definition at line 5205 of file aicode.cpp.

void ai_evade_object ( object evader,
object evaded 
)

Set *evaded as object for *evader to evade.

Definition at line 2362 of file aicode.cpp.

void ai_execute_behavior ( ai_info aip)

Execute behavior given by aip->mode.

Todo:
Complete the AIM_GET_BEHIND option

Definition at line 13029 of file aicode.cpp.

int ai_find_closest_depart_path ( ai_info aip,
polymodel pm,
int  allowed_path_mask 
)

Definition at line 12824 of file aicode.cpp.

void ai_find_path ( object pl_objp,
int  objnum,
int  path_num,
int  exit_flag,
int  subsys_path 
)

Definition at line 2875 of file aicode.cpp.

int ai_find_shockwave_ship ( object objp,
ai_info aip 
)

Definition at line 13532 of file aicode.cpp.

int ai_find_shockwave_weapon ( object objp,
ai_info aip 
)

Definition at line 13466 of file aicode.cpp.

int ai_fire_primary_weapon ( object objp)

Definition at line 5626 of file aicode.cpp.

int ai_fire_secondary_weapon ( object objp,
int  priority1,
int  priority2 
)

Definition at line 6050 of file aicode.cpp.

void ai_fly_in_formation ( int  wingnum)

Definition at line 11532 of file aicode.cpp.

void ai_fly_to_ship ( )

Definition at line 4607 of file aicode.cpp.

void ai_fly_to_target_position ( vec3d target_pos,
bool *  pl_done_p = NULL,
bool *  pl_treat_as_ship_p = NULL 
)

Definition at line 4247 of file aicode.cpp.

void ai_form_on_wing ( object objp,
object goal_objp 
)

Make object *objp form on wing of object *goal_objp

Definition at line 3290 of file aicode.cpp.

int ai_formation ( )

Definition at line 11639 of file aicode.cpp.

int ai_formation_object_get_slotnum ( int  objnum,
object objp 
)

Given an object and an object on whose wing to form, return slot to use.

Todo:
This function is called per object in formation per frame. Should store slot in ai_info struct.

Definition at line 3332 of file aicode.cpp.

void ai_frame ( int  objnum)

Process AI object "objnum".

Definition at line 13970 of file aicode.cpp.

void ai_get_dock_goal_indexes ( object objp,
ai_info aip,
ai_goal aigp,
object goal_objp,
int docker_index,
int dockee_index 
)

Definition at line 10360 of file aicode.cpp.

weapon_info* ai_get_weapon ( ship_weapon swp)

Definition at line 6321 of file aicode.cpp.

float ai_get_weapon_dist ( ship_weapon swp)

Return the distance that the current AI weapon will travel

Definition at line 6288 of file aicode.cpp.

float ai_get_weapon_speed ( ship_weapon swp)

Definition at line 6304 of file aicode.cpp.

void ai_good_secondary_time ( int  team,
int  weapon_index,
int  max_fire_count,
char *  shipname 
)

Entry point from sexpression code to set internal data for use by AI code.

Definition at line 326 of file aicode.cpp.

int ai_good_time_to_rearm ( object objp)

"safe" is currently defined by the mission designer using the good/bad time to rearm sexpressions. This status is currently team based.

Returns
true(1) or false(0) if it is "safe" for the given object to rearm.
Todo:
This function could be easily expended to further the definition of "safe"

Definition at line 313 of file aicode.cpp.

void ai_guard ( )

Definition at line 9983 of file aicode.cpp.

void ai_guard_find_nearby_asteroid ( object guarding_objp,
object guarded_objp 
)

Definition at line 9704 of file aicode.cpp.

int ai_guard_find_nearby_bomb ( object guarding_objp,
object guarded_objp 
)

Definition at line 9614 of file aicode.cpp.

void ai_guard_find_nearby_object ( )

Scan potential harmful objects and see if one is near enough to guard object to be pursued.

Definition at line 9744 of file aicode.cpp.

void ai_guard_find_nearby_ship ( object guarding_objp,
object guarded_objp 
)

Scan enemy ships and see if one is near enough to guard object to be pursued.

Definition at line 9663 of file aicode.cpp.

void ai_ignore_object ( object ignorer,
object ignored,
int  ignore_new 
)

Ignore some object without changing mode.

Definition at line 2440 of file aicode.cpp.

void ai_ignore_wing ( object ignorer,
int  wingnum 
)

Ignore some object without changing mode.

Definition at line 2485 of file aicode.cpp.

void ai_init ( void  )

Called once at game start-up

Definition at line 828 of file aicode.cpp.

void ai_init_secondary_info ( )

Clear out secondary firing information between levels

Definition at line 388 of file aicode.cpp.

int ai_is_stealth_visible ( object viewer_objp,
object stealth_objp 
)

Definition at line 966 of file aicode.cpp.

int ai_issue_rearm_request ( object requester_objp)

Definition at line 15446 of file aicode.cpp.

void ai_level_init ( void  )

This inits the AI. You should be able to call this between levels to reset everything.

Definition at line 853 of file aicode.cpp.

void ai_manage_bay_doors ( object pl_objp,
ai_info aip,
bool  done 
)

Definition at line 12581 of file aicode.cpp.

void ai_manage_shield ( object objp,
ai_info aip 
)

Definition at line 12312 of file aicode.cpp.

float ai_matrix_dist ( matrix mat1,
matrix mat2 
)

Definition at line 3562 of file aicode.cpp.

void ai_maybe_announce_shockwave_weapon ( object firing_objp,
int  weapon_index 
)

Definition at line 5939 of file aicode.cpp.

void ai_maybe_depart ( object objp)

Definition at line 13313 of file aicode.cpp.

void ai_maybe_evade_locked_missile ( object objp,
ai_info aip 
)

Definition at line 12350 of file aicode.cpp.

int ai_maybe_fire_afterburner ( object objp,
ai_info aip 
)

Maybe fire afterburner based on AI class

Definition at line 4825 of file aicode.cpp.

void ai_maybe_launch_cmeasure ( object objp,
ai_info aip 
)

Definition at line 12086 of file aicode.cpp.

int ai_maybe_limit_attackers ( int  attacked_objnum)

Definition at line 9449 of file aicode.cpp.

void ai_maybe_self_destruct ( object objp,
ai_info aip 
)

Definition at line 13813 of file aicode.cpp.

void ai_most_massive_object_of_its_wing_of_all_docked_objects_helper ( object objp,
dock_function_info infop 
)

Definition at line 11609 of file aicode.cpp.

int ai_near_full_strength ( object objp)

Definition at line 6604 of file aicode.cpp.

int ai_need_new_target ( object pl_objp,
int  target_objnum 
)

Determine if pl_objp needs a new target, called from ai_frame()

Definition at line 13850 of file aicode.cpp.

void ai_object_init ( object obj,
int  ai_index 
)

Called to init the data for single ai object.

At this point, the ship and the object and the ai_info are are correctly linked together. Ai_info[ai_index].shipnum is the only valid field in ai_info.

 This is called right when the object is parsed, so you can't assume much
 has been initialized.  For example, wings, waypoints, goals are probably
 not yet loaded. --MK, 10/8/96

Definition at line 1330 of file aicode.cpp.

float ai_path ( )

Definition at line 4087 of file aicode.cpp.

float ai_path_0 ( )

Definition at line 3780 of file aicode.cpp.

float ai_path_1 ( )

Definition at line 3924 of file aicode.cpp.

void ai_preprocess_ignore_objnum ( object objp,
ai_info aip 
)

Definition at line 12159 of file aicode.cpp.

void ai_process ( object obj,
int  ai_index,
float  frametime 
)

Definition at line 14232 of file aicode.cpp.

void ai_rearm_repair ( object objp,
int  docker_index,
object goal_objp,
int  dockee_index 
)

Make objp rearm and repair goal_objp

Definition at line 15493 of file aicode.cpp.

int ai_return_path_num_from_dockbay ( object dockee_objp,
int  dockbay_index 
)

Definition at line 15516 of file aicode.cpp.

void ai_safety ( )

Definition at line 4210 of file aicode.cpp.

void ai_safety_circle_spot ( object objp)

Definition at line 4195 of file aicode.cpp.

float ai_safety_goto_spot ( object objp)

Definition at line 4172 of file aicode.cpp.

void ai_safety_pick_spot ( object objp)

Definition at line 4147 of file aicode.cpp.

int ai_select_primary_weapon ( object objp,
object other_objp,
int  flags 
)

Etc. Etc. This is like the 4th rewrite of the code here. Special thanks to Bobboau for finding the get_shield_strength function.

The AI will now intelligently choose the best weapon to use based on the overall shield status of the target.

Definition at line 5296 of file aicode.cpp.

int ai_select_primary_weapon_OLD ( object objp,
object other_objp,
int  flags 
)

Definition at line 5223 of file aicode.cpp.

void ai_select_secondary_weapon ( object objp,
ship_weapon swp,
int  priority1 = -1,
int  priority2 = -1,
int  wif2_priority1 = -1,
int  wif2_priority2 = -1 
)

Definition at line 5801 of file aicode.cpp.

void ai_sentrygun ( )

Handler for AIM_SENTRYGUN. This AI mode is for sentry guns only (ie floating turrets).

Definition at line 13019 of file aicode.cpp.

int ai_set_attack_subsystem ( object objp,
int  subnum 
)

Definition at line 7359 of file aicode.cpp.

void ai_set_evade_object ( object objp,
object other_objp 
)

Definition at line 7505 of file aicode.cpp.

void ai_set_goal_maybe_abort_dock ( object objp,
ai_info aip 
)

If issued an order to a ship that's awaiting repair, abort that process. However, do not abort process for an object that is currently being repaired – let it finish.

Definition at line 2229 of file aicode.cpp.

void ai_set_guard_object ( object objp,
object other_objp 
)

Definition at line 7532 of file aicode.cpp.

void ai_set_guard_vec ( object objp,
object guard_objp 
)

Definition at line 7411 of file aicode.cpp.

void ai_set_guard_wing ( object objp,
int  wingnum 
)

Definition at line 7450 of file aicode.cpp.

void ai_set_mode_warp_out ( object objp,
ai_info aip 
)

Definition at line 13301 of file aicode.cpp.

void ai_set_positions ( object pl_objp,
object en_objp,
ai_info aip,
vec3d player_pos,
vec3d enemy_pos 
)

Definition at line 3469 of file aicode.cpp.

void ai_set_rearm_status ( int  team,
int  time 
)

Sets the timestamp used to tell is it is a good time for this team to rearm. Once the timestamp is no longer valid, then rearming is not a "good time"

Parameters
teamTeam (friendly, hostile, neutral)
timeTime to rearm

Definition at line 300 of file aicode.cpp.

void ai_ship_destroy ( int  shipnum,
int  method 
)

Definition at line 15234 of file aicode.cpp.

void ai_ship_hit ( object objp_ship,
object hit_objp,
vec3d hitpos,
int  shield_quadrant,
vec3d hit_normal 
)

Object *objp_ship was hit by either weapon *objp_weapon or collided into by ship hit_objp at point *hitpos.

Definition at line 14934 of file aicode.cpp.

void ai_start_fly_to_ship ( object objp,
int  shipnum 
)

Definition at line 3186 of file aicode.cpp.

void ai_start_waypoints ( object objp,
waypoint_list wp_list,
int  wp_flags 
)

Definition at line 3215 of file aicode.cpp.

void ai_stay_near ( )

Definition at line 10535 of file aicode.cpp.

void ai_stay_still ( object still_objp,
vec3d view_pos 
)

Definition at line 2982 of file aicode.cpp.

void ai_stealth_find ( )

Handler for stealth find submode of Chase.

Definition at line 7010 of file aicode.cpp.

void ai_stealth_sweep ( )

Try to find stealth ship by sweeping an area

Definition at line 7095 of file aicode.cpp.

void ai_still ( )

Definition at line 10518 of file aicode.cpp.

void ai_transfer_shield ( object objp,
int  quadrant_num 
)

Transfer shield energy to most recently hit section from others.

Definition at line 12242 of file aicode.cpp.

void ai_turn_towards_vector ( vec3d dest,
object objp,
float  frametime,
float  turn_time,
vec3d slide_vec,
vec3d rel_pos,
float  bank_override,
int  flags,
vec3d rvec,
int  sexp_flags 
)

Definition at line 1131 of file aicode.cpp.

void ai_update_aim ( ai_info aip)

Updates AI aim automatically based on targetted enemy.

Parameters
aipPointer to AI info

Definition at line 3490 of file aicode.cpp.

void ai_update_danger_weapon ( int  attacked_objnum,
int  weapon_objnum 
)

Update danger_weapon_objnum and signature in ai_info to say this weapon is to be avoided.

Definition at line 1056 of file aicode.cpp.

void ai_update_lethality ( object pship_obj,
object other_obj,
float  damage 
)

Definition at line 14881 of file aicode.cpp.

void ai_warp_out ( object objp)

Warp this ship out.

Definition at line 13368 of file aicode.cpp.

void ai_waypoints ( )

Definition at line 4556 of file aicode.cpp.

void attack_set_accel ( ai_info aip,
ship_info sip,
float  dist_to_enemy,
float  dot_to_enemy,
float  dot_from_enemy 
)

Set acceleration while in attack mode.

Definition at line 6637 of file aicode.cpp.

int avoid_player ( object objp,
vec3d goal_pos 
)

Definition at line 6772 of file aicode.cpp.

void avoid_ship ( )

Definition at line 4686 of file aicode.cpp.

void big_ship_collide_recover_start ( object objp,
object big_objp,
vec3d collide_pos,
vec3d collision_normal 
)

Definition at line 14843 of file aicode.cpp.

void bisect_chord ( vec3d p0,
vec3d p1,
vec3d centerp,
float  radius 
)

Given two points on a sphere, the center of the sphere and the radius, return a point on the vector through the midpoint of the chord on the sphere.

Definition at line 2534 of file aicode.cpp.

void call_doa ( object child,
object parent 
)

Definition at line 12072 of file aicode.cpp.

void change_acceleration ( ai_info aip,
float  delta_accel 
)

Definition at line 1377 of file aicode.cpp.

void cheat_fire_synaptic ( object objp,
ship shipp,
ai_info aip 
)

Actually go ahead and fire the synaptics.

Definition at line 15554 of file aicode.cpp.

int check_ok_to_fire ( int  objnum,
int  target_objnum,
weapon_info wip 
)

Definition at line 5993 of file aicode.cpp.

int combine_flags ( int  base_flags,
int  override_flags,
int  override_set 
)

Definition at line 14463 of file aicode.cpp.

int compact_ignore_new_objects ( ai_info aip,
int  force = 0 
)

Returns total number of ignored objects.

Parameters
aipAI info
forceMeans we forget the oldest object

Definition at line 2389 of file aicode.cpp.

float compute_collision_time ( vec3d targpos,
vec3d targvel,
vec3d attackpos,
float  weapon_speed 
)

Given an attacker's position and a target's position and velocity, compute the time of intersection of a weapon fired by the attacker with speed weapon_speed.

Return this value. Return value of 0.0f means no collision is possible.

Definition at line 3361 of file aicode.cpp.

void compute_desired_rvec ( vec3d rvec,
vec3d goal_pos,
vec3d cur_pos 
)

Set desired right vector for ships flying towards another ship. Since this is governed only by vector to target, it causes ships to align bank and look less chaotic.

Definition at line 6995 of file aicode.cpp.

float compute_dots ( object objp,
object other_objp,
float to_dot,
float from_dot 
)

Compute dot product of direction vector and forward vector. Direction vector is vector from one object to other object. Forward vector is the forward vector of the ship. If from_dot == NULL, don't fill it in.

Definition at line 1017 of file aicode.cpp.

float compute_incoming_payload ( object target_objp)

Return total payload of all incoming missiles.

Definition at line 5966 of file aicode.cpp.

int compute_num_homing_objects ( object target_objp)
Returns
number of objects homing on object *target_objp

Definition at line 5919 of file aicode.cpp.

float compute_time_to_enemy ( float  dist_to_enemy,
object pobjp 
)

Definition at line 3403 of file aicode.cpp.

void copy_xlate_model_path_points ( object objp,
model_path mp,
int  dir,
int  count,
int  path_num,
pnode pnp,
int  randomize_pnt 
)

Given an object and a model path, globalize the points on the model and copy into the global path list. If pnp != NULL, then modify, in place, the path points. This is used to create new globalized points when the base object has moved.

Parameters
objpObject pointer
mpModel path
dirDirectory type
countCount of items
path_numPath number
pnpNode on a path
randomize_pntOptional parameter (default value -1), add random vector in sphere to this path point

Definition at line 2621 of file aicode.cpp.

void create_model_exit_path ( object pl_objp,
object mobjp,
int  path_num,
int  count 
)

For pl_objp, create a path along path path_num into mobjp.

The tricky part of this problem is creating the entry to the first point on the predefined path. The points on this entry path are based on the location of pl_objp relative to the start of the path.

Definition at line 2800 of file aicode.cpp.

void create_model_path ( object pl_objp,
object mobjp,
int  path_num,
int  subsys_path 
)

For pl_objp, create a path along path path_num into mobjp. The tricky part of this problem is creating the entry to the first point on the predefined path. The points on this entry path are based on the location of Pl_objp relative to the start of the path.

Parameters
pl_objpPlayer object
mobjpModel object
path_numNumber of path
subsys_pathOptional param (default 0), indicating this is a path to a subsystem

Definition at line 2706 of file aicode.cpp.

int create_object_hash ( object objp)

Hash some information in an object together. On 2/20/97, the information is position and orientation.

Definition at line 493 of file aicode.cpp.

void create_path_to_point ( vec3d curpos,
vec3d goalpos,
object curobjp,
object goalobjp,
int  subsys_path 
)

Create a path from the current position to a goal position.

The current position is in the current object and the goal position is in the goal object. It is ok to intersect the current object, but not the goal object. This function is useful for creating a path to an initial point near a large object.

Parameters
curposCurrent position in vector space
goalposGoal position in vector space
curobjpCurrent object pointer
goalobjpGoal object pointer
subsys_pathOptional param (default 0), indicates this is a path to a subsystem

Definition at line 2571 of file aicode.cpp.

void debug_find_guard_object ( )

Definition at line 9326 of file aicode.cpp.

void do_random_sidethrust ( ai_info aip,
ship_info sip 
)

Definition at line 6609 of file aicode.cpp.

float dock_move_towards_point ( object objp,
vec3d start,
vec3d finish,
float  speed_scale,
float  other_obj_speed = 0.0f,
rotating_dockpoint_info rdinfo = NULL 
)

Make the object *objp move so that the point *start moves towards the point *finish.

Returns
distance.

Definition at line 8905 of file aicode.cpp.

float dock_orient_and_approach ( object docker_objp,
int  docker_index,
object dockee_objp,
int  dockee_index,
int  dock_mode,
rotating_dockpoint_info rdinfo 
)

Definition at line 9070 of file aicode.cpp.

void evade_ship ( )

Definition at line 5087 of file aicode.cpp.

void evade_weapon ( )

Definition at line 4904 of file aicode.cpp.

void evaluate_object_as_nearest_objnum ( eval_nearest_objnum eno)

Definition at line 1923 of file aicode.cpp.

void fds_aux ( float dot,
float tts,
vec3d pos,
float  dtime,
object objp 
)

Definition at line 3444 of file aicode.cpp.

void find_adjusted_dockpoint_info ( vec3d global_p0,
vec3d global_p1,
vec3d global_p0_norm,
object objp,
polymodel pm,
int  modelnum,
int  submodel,
int  dock_index 
)

Definition at line 9025 of file aicode.cpp.

int find_enemy ( int  objnum,
float  range,
int  max_attackers 
)

Return objnum if enemy found, else return -1;

Parameters
objnumObject number
rangeRange within which to look
max_attackersDon't attack a ship that already has at least max_attackers attacking it.

Definition at line 2186 of file aicode.cpp.

int find_ignore_new_object_index ( ai_info aip,
int  objnum 
)

Definition at line 1877 of file aicode.cpp.

int find_nearby_threat ( int  objnum,
int  enemy_team_mask,
float  range,
int count 
)

Given an object and an enemy team, return the index of the nearest enemy object.

Unlike find_enemy or find_nearest_objnum, this doesn't care about things like the protected flag or number of enemies attacking. It is used to find the nearest enemy to determine things like whether to rearm.

Definition at line 2092 of file aicode.cpp.

int find_parent_rotating_submodel ( polymodel pm,
int  dock_index 
)

Definition at line 8994 of file aicode.cpp.

int firing_aspect_seeking_bomb ( object objp)

Definition at line 14813 of file aicode.cpp.

void force_avoid_player_check ( object objp,
ai_info aip 
)

Definition at line 2244 of file aicode.cpp.

int formation_is_leader_chaotic ( object objp)

Definition at line 11580 of file aicode.cpp.

void free_ai_stuff ( )

Definition at line 516 of file aicode.cpp.

void garbage_collect_path_points ( )

Garbage collect the Path_points buffer.

Scans all objects, looking for used Path_points records. Compresses Path_points buffer, updating aip->path_start and aip->path_cur indices. Updates Ppfp to point to first free record. This function is fairly fast. Its worst-case running time is proportional to 3*MAX_PATH_POINTS + MAX_OBJECTS

Todo:
Things to do to optimize this function:
  1. if (t != 0) xlt++; can be replaced by xlt += t; assuming t can only be 0 or 1.
  2. When pp_xlate is getting stuffed the first time, note highest index and use that instead of MAX_PATH_POINTS in following two for loops.

Definition at line 407 of file aicode.cpp.

void get_absolute_wing_pos ( vec3d result_pos,
object leader_objp,
int  wing_index,
int  formation_object_flag 
)

Given a wing leader and a position in the wing formation, return the desired absolute location to fly to.

Returns
result in *result_pos.

Definition at line 11409 of file aicode.cpp.

void get_absolute_wing_pos_autopilot ( vec3d result_pos,
object leader_objp,
int  wing_index,
int  formation_object_flag 
)

Definition at line 11432 of file aicode.cpp.

int get_base_path_info ( int  path_cur,
int  goal_objnum,
model_path **  pmp,
mp_vert **  pmpv 
)

Definition at line 3509 of file aicode.cpp.

void get_behind_ship ( ai_info aip,
ship_info sip,
float  dist_to_enemy 
)

Definition at line 6752 of file aicode.cpp.

float get_cylinder_points ( object other_objp,
object cyl_objp,
vec3d axis_pt,
vec3d r_vec,
float radius 
)

Gets closest point on extended axis of cylinder, r_vec, and radius of cylinder

Returns
z of axis_point in cyl_objp reference frame

Definition at line 9771 of file aicode.cpp.

int get_enemy_team_range ( object my_objp,
float  range,
int  enemy_team_mask,
vec3d min_vec,
vec3d max_vec 
)

Definition at line 4115 of file aicode.cpp.

int get_enemy_timestamp ( )

Return timestamp until a ship can find an enemy.

Definition at line 2174 of file aicode.cpp.

int get_nearest_objnum ( int  objnum,
int  enemy_team_mask,
int  enemy_wing,
float  range,
int  max_attackers 
)

Given an object and an enemy team, return the index of the nearest enemy object. Unless aip->targeted_subsys != NULL, don't allow to attack objects with OF_PROTECTED bit set.

Parameters
objnumObject number
enemy_team_maskMask to apply to enemy team
enemy_wingEnemy wing chosen
rangeShip must be within range "range".
max_attackersDon't attack a ship that already has at least max_attackers attacking it.

Definition at line 2029 of file aicode.cpp.

float get_skill_stealth_dist_scaler ( )

Return dist scaler based on skill level

Definition at line 913 of file aicode.cpp.

float get_skill_stealth_dot_scaler ( )

Return multiplier on dot based on skill level

Definition at line 941 of file aicode.cpp.

void get_tangent_point ( vec3d tan1,
vec3d p0,
vec3d centerp,
vec3d p1,
float  radius 
)

Stuff tan1 with tangent point on sphere.

Parameters
tan1is point nearer to *p1
*p0is point through which tangents pass.
*centerpis center of sphere.
*p1is another point in space to define the plane in which tan1, tan2 reside.
radiusis the radius of the sphere.

Note, this is a very approximate function just for AI. Note also: On 12/26/96, p1 is used to define the plane perpendicular to that which contains the tangent point.

Definition at line 1457 of file aicode.cpp.

void get_tangent_point ( vec3d goal_point,
object objp,
vec3d point,
float  radius 
)

Returns a point radius units away from *point that *objp should turn towards to orbit *point

Definition at line 1609 of file aicode.cpp.

void get_wing_delta ( vec3d _delta_vec,
int  wing_index 
)

Definition at line 11299 of file aicode.cpp.

int get_wing_index ( object objp,
int  wingnum 
)

Definition at line 11230 of file aicode.cpp.

float get_wing_largest_radius ( object objp,
int  formation_object_flag 
)

For the wing that *objp is part of, return the largest ship radius in that wing.

Definition at line 11374 of file aicode.cpp.

object * get_wing_leader ( int  wingnum)

Definition at line 11251 of file aicode.cpp.

float get_wing_lowest_av_ab_speed ( object objp)

Scan all the ships in *objp's wing. Return the lowest average speed with afterburner of a ship in the wing.

Definition at line 1769 of file aicode.cpp.

float get_wing_lowest_max_speed ( object objp)

Scan all the ships in *objp's wing. Return the lowest maximum speed of a ship in the wing.

Current maximum speed (based on energy settings) is shipp->current_max_speed

Definition at line 1719 of file aicode.cpp.

void guard_object_was_hit ( object guard_objp,
object hitter_objp 
)

Object being guarded by object *guard_objp was hit by object *hitter_objp

Definition at line 9471 of file aicode.cpp.

float gwlr_1 ( object objp,
ai_info aip 
)

Compute the largest radius of a ship in a *objp's wing.

Definition at line 11329 of file aicode.cpp.

float gwlr_object_1 ( object objp,
ai_info aip 
)

Compute the largest radius of a ship forming on *objp's wing.

Definition at line 11353 of file aicode.cpp.

int has_preferred_secondary ( object objp,
object en_objp,
ship_weapon swp 
)

Definition at line 7679 of file aicode.cpp.

int hash ( unsigned int  curval,
int  newval 
)

Hash two values together, return result. Hash function: curval shifted right circular by one, newval xored in.

Definition at line 477 of file aicode.cpp.

void init_ai_class ( ai_class aicp)

Initialize an AI class's nonrequired values to defaults Boolean overrides are unset, others initialized to FLT_MIN or INT_MIN (used as the "not set" state)

Definition at line 529 of file aicode.cpp.

void init_ai_object ( int  objnum)

Initialize ai_info struct of object objnum.

Definition at line 14300 of file aicode.cpp.

void init_ai_stealth_info ( ai_info aip,
object stealth_objp 
)

Init necessary AI info for new stealth target

Definition at line 894 of file aicode.cpp.

void init_ai_system ( void  )

Definition at line 14458 of file aicode.cpp.

void init_aip_from_class_and_profile ( ai_info aip,
ai_class aicp,
ai_profile_t profile 
)

Definition at line 14490 of file aicode.cpp.

int is_ignore_object ( ai_info aip,
int  objnum,
int  just_the_original = 0 
)

Definition at line 1891 of file aicode.cpp.

int is_ignore_object_sub ( int ignore_objnum,
int ignore_signature,
int  objnum 
)

Determine if object objnum is supposed to be ignored by object with ai_info *aip.

Returns
TRUE if objnum is aip->ignore_objnum (and signatures match) or objnum is in ignore wing
FALSE otherwise

Definition at line 1843 of file aicode.cpp.

int is_instructor ( object objp)

Is an instructor if name begins INSTRUCTOR_SHIP_NAME else not.

Returns
true if object *objp is an instructor.

Definition at line 4895 of file aicode.cpp.

bool is_object_stealth_ship ( object objp)

Check if object is a stealth ship

Definition at line 879 of file aicode.cpp.

int is_preferred_weapon ( int  weapon_num,
object firer_objp,
object target_objp 
)

Called internally to the AI code to tell whether or not weapon_num can be fired from firer_objp at target_objp. This function will resolve the team for the firer.

Returns
-1 when conditions don't allow firer to fire weapon_num on target_objp
>=0 when conditions allow firer to fire. Return value is max number of weapon_nums which can be fired on target_objp

Definition at line 348 of file aicode.cpp.

void mabs_pick_goal_point ( object objp,
object big_objp,
vec3d collision_point,
vec3d avoid_pos 
)

Definition at line 6889 of file aicode.cpp.

void maybe_afterburner_after_ship_hit ( object objp,
ai_info aip,
object en_objp 
)

Maybe engage afterburner after being hit by an object.

Definition at line 4872 of file aicode.cpp.

int maybe_avoid_big_ship ( object objp,
object ignore_objp,
ai_info aip,
vec3d goal_point,
float  delta_time 
)

Return true if a large ship is being ignored.

Definition at line 6955 of file aicode.cpp.

int maybe_avoid_player ( object objp,
vec3d goal_pos 
)

Definition at line 2911 of file aicode.cpp.

int maybe_big_ship_collide_recover_frame ( object objp,
ai_info aip 
)

If *objp is recovering from a collision with a big ship, handle it.

Returns
true if recovering.

Definition at line 13887 of file aicode.cpp.

void maybe_cheat_fire_synaptic ( object objp,
ai_info aip 
)

Definition at line 15575 of file aicode.cpp.

int maybe_dock_obstructed ( object cur_objp,
object goal_objp,
int  big_only_flag 
)

Definition at line 10584 of file aicode.cpp.

void maybe_evade_dumbfire_weapon ( ai_info aip)

Definition at line 12456 of file aicode.cpp.

int maybe_hack_cruiser_chase_abort ( )

Definition at line 7965 of file aicode.cpp.

void maybe_process_friendly_hit ( object objp_hitter,
object objp_hit,
object objp_weapon 
)

Object *objp_weapon, fired by *objp_hitter, hit object *objp_ship.

Definition at line 14651 of file aicode.cpp.

float maybe_recreate_path ( object objp,
ai_info aip,
int  force_recreate_flag,
int  override_hash = 0 
)

Definition at line 3579 of file aicode.cpp.

int maybe_request_support ( object objp)

Definition at line 13182 of file aicode.cpp.

int maybe_resume_previous_mode ( object objp,
ai_info aip 
)

Definition at line 4757 of file aicode.cpp.

void maybe_set_dynamic_chase ( ai_info aip,
int  hitter_objnum 
)

Maybe make ship with ai_info *aip attack hitter_objnum as a dynamic goal

Definition at line 14782 of file aicode.cpp.

void maybe_update_guard_object ( object hit_objp,
object hitter_objp 
)

Definition at line 9590 of file aicode.cpp.

int might_collide_with_ship ( object obj1,
object obj2,
float  dot_to_enemy,
float  dist_to_enemy,
float  duration 
)

Return true if it looks like obj1, if continuing to move along current vector, will collide with obj2.

Definition at line 6108 of file aicode.cpp.

int might_hit_teammate ( object firing_objp)

Return true if ship *objp firing a laser believes it will hit a teammate.

Definition at line 6120 of file aicode.cpp.

void modify_model_path_points ( object objp)

Definition at line 3533 of file aicode.cpp.

int mrs_subsystem ( ship shipp,
int  type 
)

Definition at line 13139 of file aicode.cpp.

int num_allies_rearming ( object objp)

Return number of ships on *objp's team that are currently rearming.

Definition at line 13155 of file aicode.cpp.

int num_enemies_attacking ( int  objnum)

Return number of enemies attacking object objnum

Definition at line 1676 of file aicode.cpp.

int num_nearby_fighters ( int  enemy_team_mask,
vec3d pos,
float  threshold 
)

Definition at line 5765 of file aicode.cpp.

int num_ships_attacking ( int  target_objnum)

Given an object number, return the number of ships attacking it.

Definition at line 9346 of file aicode.cpp.

int num_turrets_attacking ( object turret_parent,
int  target_objnum 
)

Number of live turrets with target_objnum

Definition at line 2137 of file aicode.cpp.

int object_is_targetable ( object target,
ship viewer 
)

Determine whether an object is targetable within a nebula

Definition at line 1643 of file aicode.cpp.

void parse_ai_class ( )

Definition at line 596 of file aicode.cpp.

void parse_aitbl ( )

Definition at line 784 of file aicode.cpp.

int pp_collide_any ( vec3d curpos,
vec3d goalpos,
float  radius,
object ignore_objp1,
object ignore_objp2,
int  big_only_flag 
)

Return true if the vector from curpos to goalpos intersects with any ship other than the ignore objects. Calls pp_collide()

Definition at line 2842 of file aicode.cpp.

void process_friendly_hit_message ( int  message,
object objp 
)

Definition at line 14608 of file aicode.cpp.

void process_subobjects ( int  objnum)

Definition at line 11120 of file aicode.cpp.

void project_point_to_perimeter ( vec3d perim_point,
vec3d pos,
float  radius,
vec3d vp 
)

Stuff perim_point with a point on the perimeter of the sphere defined by object *objp on the vector from the center of *objp through the point *vp.

Definition at line 1424 of file aicode.cpp.

void remove_farthest_attacker ( int  objnum)

Definition at line 9384 of file aicode.cpp.

void render_all_ship_bay_paths ( object objp)

Definition at line 6145 of file aicode.cpp.

void render_all_subsys_paths ( object objp)

Debug function to show all path points associated with an object

Definition at line 6190 of file aicode.cpp.

void render_path_points ( object objp)

Definition at line 6230 of file aicode.cpp.

void render_wing_phantoms ( object objp)

Definition at line 11448 of file aicode.cpp.

void render_wing_phantoms_all ( )

Definition at line 11490 of file aicode.cpp.

void reset_ai_class_names ( )

Definition at line 772 of file aicode.cpp.

void set_accel_for_docking ( object objp,
ai_info aip,
float  dot,
float  dot_to_next,
float  dist_to_next,
float  dist_to_goal,
ship_info sip,
float  max_allowed_speed,
object gobjp 
)

Set acceleration for ai_dock().

Definition at line 3643 of file aicode.cpp.

void set_accel_for_target_speed ( object objp,
float  tspeed 
)

Definition at line 1400 of file aicode.cpp.

void set_aic_flag ( ai_class aicp,
char *  name,
int  flag,
int  type 
)

Definition at line 575 of file aicode.cpp.

void set_goal_dock_orient ( matrix dom,
vec3d docker_p0,
vec3d docker_p1,
vec3d docker_p0_norm,
matrix docker_orient,
vec3d dockee_p0,
vec3d dockee_p1,
vec3d dockee_p0_norm,
matrix dockee_orient 
)

Definition at line 8953 of file aicode.cpp.

void set_predicted_enemy_pos ( vec3d predicted_enemy_pos,
object pobjp,
vec3d enemy_pos,
vec3d enemy_vel,
ai_info aip 
)

Definition at line 6397 of file aicode.cpp.

void set_predicted_enemy_pos_turret ( vec3d predicted_enemy_pos,
vec3d gun_pos,
object pobjp,
vec3d enemy_pos,
vec3d enemy_vel,
float  weapon_speed,
float  time_enemy_in_range 
)

Definition at line 6344 of file aicode.cpp.

void set_primary_weapon_linkage ( object objp)

Maybe link primary weapons.

Definition at line 5496 of file aicode.cpp.

float set_secondary_fire_delay ( ai_info aip,
ship shipp,
weapon_info swip,
bool  burst 
)

Return time, in seconds, at which this ship can next fire its current secondary weapon.

Definition at line 7785 of file aicode.cpp.

int set_target_objnum ( ai_info aip,
int  objnum 
)

Definition at line 1250 of file aicode.cpp.

ship_subsys* set_targeted_subsys ( ai_info aip,
ship_subsys new_subsys,
int  parent_objnum 
)

Make new_subsys the targeted subsystem of ship *aip.

Definition at line 1289 of file aicode.cpp.

void ship_set_subsystem_strength ( ship shipp,
int  type,
float  strength 
)

Set the strength of a subsystem on a given ship.

The strength passed as a parameter is between 0.0 and 1.0

NOTE: this function was made to be called by the debug function dcf_set_subsys(). If you want to use this, be sure that you test it for all cases.

Definition at line 13500 of file ship.cpp.

const char* Skill_level_names ( int  level,
int  translate 
)

Definition at line 208 of file aicode.cpp.

void slide_face_ship ( )

Definition at line 5019 of file aicode.cpp.

int static_rand_timed ( int  num,
int  modulus 
)

Definition at line 4808 of file aicode.cpp.

void turn_away_from_point ( object objp,
vec3d point,
float  bank_override 
)

Given an object and a point, turn away from the point, resulting in avoidance behavior. Note: Turn away at full speed, not scaled down by skill level.

Definition at line 1513 of file aicode.cpp.

float turn_toward_tangent_with_axis ( object objp,
object center_objp,
float  radius 
)

Definition at line 1558 of file aicode.cpp.

void turn_towards_point ( object objp,
vec3d point,
vec3d slide_vec,
float  bank_override 
)

Given an object and a point, turn towards the point, resulting in approach behavior.

Definition at line 1491 of file aicode.cpp.

float turn_towards_tangent ( object objp,
vec3d point,
float  radius 
)

Definition at line 1533 of file aicode.cpp.

void update_ai_stealth_info_with_error ( ai_info aip)

Update estimated stealth info

This is a "cheat" update. Error increases with time not seen, true distance away, dot to enemy this is done only if we can not see the stealth target need to infer its position either by weapon fire pos or last know pos

Definition at line 1039 of file aicode.cpp.

void update_aspect_lock_information ( ai_info aip,
vec3d vec_to_enemy,
float  dist_to_enemy,
float  enemy_radius 
)

Definition at line 7576 of file aicode.cpp.

void update_min_max ( float  val,
float min,
float max 
)

Definition at line 4104 of file aicode.cpp.

void validate_mode_submode ( ai_info aip)

Definition at line 13927 of file aicode.cpp.

int vector_object_collision ( vec3d start_pos,
vec3d end_pos,
object objp,
float  radius_scale 
)

Definition at line 713 of file objcollide.cpp.

int will_collide_pp ( vec3d p0,
vec3d p1,
float  radius,
object big_objp,
vec3d collision_point 
)

Definition at line 6792 of file aicode.cpp.

int will_collide_with_big_ship ( object objp,
vec3d goal_point,
object big_objp,
vec3d collision_point,
float  delta_time 
)

Definition at line 6822 of file aicode.cpp.

int will_collide_with_big_ship_all ( object objp,
object ignore_objp,
vec3d goal_point,
vec3d collision_point,
float distance,
float  delta_time 
)

Definition at line 6846 of file aicode.cpp.

Variable Documentation

control_info AI_ci

Definition at line 167 of file aicode.cpp.

char** Ai_class_names = NULL

Definition at line 268 of file aicode.cpp.

ai_class* Ai_classes = NULL

Definition at line 193 of file aicode.cpp.

Definition at line 11077 of file aicode.cpp.

int Ai_firing_enabled = 1

Definition at line 194 of file aicode.cpp.

ai_flag_name Ai_flag_names[]
Initial value:
= {
{AIF_NO_DYNAMIC, "no-dynamic", 1, },
{AIF_FREE_AFTERBURNER_USE, "free-afterburner-use", 1, },
}
#define AIF_FREE_AFTERBURNER_USE
Definition: ai.h:67
#define AIF_NO_DYNAMIC
Definition: ai.h:56

Definition at line 203 of file aicode.cpp.

int AI_FrameCount = 0

Definition at line 198 of file aicode.cpp.

float AI_frametime

Definition at line 266 of file aicode.cpp.

SCP_vector<huge_fire_info> Ai_huge_fire_info

Definition at line 277 of file aicode.cpp.

LOCAL int ai_inited = 0

Definition at line 821 of file aicode.cpp.

int Ai_last_arrive_path

Definition at line 279 of file aicode.cpp.

int AI_watch_object = 0

Definition at line 199 of file aicode.cpp.

object* Autopilot_flight_leader = NULL

Definition at line 291 of file aicode.cpp.

int Chaos_frame = -1

Definition at line 11576 of file aicode.cpp.

int Debug_k = 0

Definition at line 3353 of file aicode.cpp.

int Debug_render_wing_phantoms

Definition at line 11446 of file aicode.cpp.

object* En_objp

Definition at line 170 of file aicode.cpp.

float G_collision_time

Definition at line 5211 of file aicode.cpp.

vec3d G_fire_pos

Definition at line 5212 of file aicode.cpp.

vec3d G_predicted_pos

Definition at line 5212 of file aicode.cpp.

int Last_ai_obj = -1

Definition at line 14230 of file aicode.cpp.

float Leader_chaos = 0.0f

Definition at line 11575 of file aicode.cpp.

float max_lethality = 0.0f

Definition at line 14879 of file aicode.cpp.

int Mission_all_attack = 0

Definition at line 200 of file aicode.cpp.

char* Mode_text[MAX_AI_BEHAVIORS]
Initial value:
= {
"CHASE",
"EVADE",
"GET_BEHIND",
"CHASE_LONG",
"SQUIGGLE",
"GUARD",
"AVOID",
"WAYPOINTS",
"DOCK",
"NONE",
"BIGSHIP",
"PATH",
"BE_REARMED",
"SAFETY",
"EV_WEAPON",
"STRAFE",
"PLAY_DEAD",
"BAY_EMERGE",
"BAY_DEPART",
"SENTRYGUN",
"WARP_OUT",
}

Definition at line 108 of file aicode.cpp.

int Num_ai_classes

Definition at line 195 of file aicode.cpp.

int Num_AI_debug_render_stuff = 0

Definition at line 11079 of file aicode.cpp.

int Num_alloced_ai_classes

Definition at line 196 of file aicode.cpp.

pnode Path_points[MAX_PATH_POINTS]

Definition at line 263 of file aicode.cpp.

object* Pl_objp

Definition at line 169 of file aicode.cpp.

int Player_attacking_enabled = 1

Definition at line 1638 of file aicode.cpp.

pnode* Ppfp

Definition at line 264 of file aicode.cpp.

char* Strafe_submode_text[5]
Initial value:
= {
"ATTACK",
"AVOID",
"RETREAT1",
"RETREAT2",
"POSITION"
}

Definition at line 154 of file aicode.cpp.

char* Submode_text[]
Initial value:
= {
"undefined",
"CONT_TURN",
"ATTACK ",
"E_SQUIG ",
"E_BRAKE ",
"EVADE ",
"SUP_ATTAK",
"AVOID ",
"BEHIND ",
"GET_AWAY ",
"E_WEAPON ",
"FLY_AWAY ",
"ATK_4EVER",
"STLTH_FND",
"STLTH_SWP",
"BIG_APPR",
"BIG_CIRC",
"BIG_PARL"
}

Definition at line 133 of file aicode.cpp.

float Wing_scale = 1.0f

Definition at line 11394 of file aicode.cpp.

float Wing_y_scale = 2.0f

Definition at line 11393 of file aicode.cpp.