Open source remastering of the Freespace 2 engine
ai.h File Reference

Go to the source code of this file.


struct  ai_flag_name
struct  ai_goal
struct  ai_class
struct  pnode
struct  ai_info
struct  rotating_dockpoint_info


#define AI_DEFAULT_CLASS   3
#define MAX_AI_FLAG_NAMES   2
#define AIF_FORMATION_WING   (1 << 0)
#define AIF_AWAITING_REPAIR   (1 << 1)
#define AIF_BEING_REPAIRED   (1 << 2)
#define AIF_REPAIRING   (1 << 3)
#define AIF_SEEK_LOCK   (1 << 4)
#define AIF_FORMATION_OBJECT   (1 << 5)
#define AIF_TEMPORARY_IGNORE   (1 << 6)
#define AIF_USE_EXIT_PATH   (1 << 7)
#define AIF_USE_STATIC_PATH   (1 << 8)
#define AIF_TARGET_COLLISION   (1 << 9)
#define AIF_UNLOAD_SECONDARIES   (1 << 10)
#define AIF_ON_SUBSYS_PATH   (1 << 11)
#define AIF_AVOID_SHOCKWAVE_SHIP   (1 << 12)
#define AIF_AVOID_SHOCKWAVE_WEAPON   (1 << 13)
#define AIF_ATTACK_SLOWLY   (1 << 15)
#define AIF_REPAIR_OBSTRUCTED   (1 << 16)
#define AIF_KAMIKAZE   (1 << 17)
#define AIF_NO_DYNAMIC   (1 << 18)
#define AIF_AVOIDING_SMALL_SHIP   (1 << 19)
#define AIF_AVOIDING_BIG_SHIP   (1 << 20)
#define AIF_BIG_SHIP_COLLIDE_RECOVER_1   (1 << 21)
#define AIF_BIG_SHIP_COLLIDE_RECOVER_2   (1 << 22)
#define AIF_STEALTH_PURSUIT   (1 << 23)
#define AIF_UNLOAD_PRIMARIES   (1 << 24)
#define AIF_FREE_AFTERBURNER_USE   (1 << 26)
#define DOA_APPROACH   1
#define DOA_DOCK   2
#define DOA_UNDOCK_1   3
#define DOA_UNDOCK_2   4
#define DOA_UNDOCK_3   5
#define DOA_DOCK_STAY   6
#define AIDO_DOCK   1
#define AIDO_DOCK_NOW   2
#define AIDO_UNDOCK   3
#define AISS_1   41
#define AISS_2   42
#define AISS_3   43
#define AISS_1a   44
#define MAX_AI_GOALS   5
#define AIG_TYPE_DYNAMIC   5
#define AIGF_DOCKER_INDEX_VALID   (1<<0)
#define AIGF_DOCKEE_INDEX_VALID   (1<<1)
#define AIGF_GOAL_ON_HOLD   (1<<2)
#define AIGF_SUBSYS_NEEDS_FIXUP   (1<<3)
#define AIGF_GOAL_OVERRIDE   (1<<4)
#define AIGF_PURGE   (1<<5)
#define AIGF_GOALS_PURGED   (1<<6)
#define AIGF_TARGET_OWN_TEAM   (1<<8)
#define AITTV_FAST   (1<<0)
#define AITTV_VIA_SEXP   (1<<1)
#define AITTV_IGNORE_BANK   (1<<2)
#define KAMIKAZE_HULL_ON_DEATH   -1000.0f
#define AIORF_FULL   (1<<0)
#define AIORF_ROLL   (1<<1)
#define AIORF_PITCH   (1<<2)
#define AIORF_HEADING   (1<<3)
#define AIORF_FULL_LAT   (1<<4)
#define AIORF_UP   (1<<5)
#define AIORF_SIDEWAYS   (1<<6)
#define AIORF_FORWARD   (1<<7)
#define AIM_CHASE   0
#define AIM_EVADE   1
#define AIM_GET_BEHIND   2
#define AIM_STAY_NEAR   3
#define AIM_STILL   4
#define AIM_GUARD   5
#define AIM_AVOID   6
#define AIM_WAYPOINTS   7
#define AIM_DOCK   8
#define AIM_NONE   9
#define AIM_BIGSHIP   10
#define AIM_PATH   11
#define AIM_BE_REARMED   12
#define AIM_SAFETY   13
#define AIM_EVADE_WEAPON   14
#define AIM_STRAFE   15
#define AIM_PLAY_DEAD   16
#define AIM_BAY_EMERGE   17
#define AIM_BAY_DEPART   18
#define AIM_SENTRYGUN   19
#define AIM_WARP_OUT   20
#define AIM_FLY_TO_SHIP   21
#define MAX_AI_BEHAVIORS   22
#define MAX_ENEMY_DISTANCE   2500.0f
#define AI_GOAL_NONE   -1
#define SM_ATTACK   2
#define SM_EVADE_BRAKE   4
#define SM_EVADE   5
#define SM_SUPER_ATTACK   6
#define SM_AVOID   7
#define SM_GET_BEHIND   8
#define SM_GET_AWAY   9
#define SM_EVADE_WEAPON   10
#define SM_FLY_AWAY   11
#define SM_ATTACK_FOREVER   12
#define SM_STEALTH_FIND   13
#define SM_STEALTH_SWEEP   14
#define SM_BIG_APPROACH   15
#define SM_BIG_CIRCLE   16
#define SM_BIG_PARALLEL   17
#define AIS_DOCK_0   20
#define AIS_DOCK_1   21
#define AIS_DOCK_2   22
#define AIS_DOCK_3   23
#define AIS_DOCK_4   24
#define AIS_DOCK_4A   25
#define AIS_UNDOCK_0   30
#define AIS_UNDOCK_1   31
#define AIS_UNDOCK_2   32
#define AIS_UNDOCK_3   33
#define AIS_UNDOCK_4   34
#define AIS_GUARD_PATROL   101
#define AIS_GUARD_ATTACK   102
#define AIS_GUARD_2   103
#define AIS_GUARD_STATIC   104
#define AIS_STRAFE_ATTACK   201
#define AIS_STRAFE_AVOID   202
#define AIS_STRAFE_RETREAT1   203
#define AIS_STRAFE_RETREAT2   204
#define WPF_REPEAT   (1 << 0)
#define WPF_BACKTRACK   (1 << 1)
#define PD_FORWARD   1
#define PD_BACKWARD   -1
#define AIS_WARP_1   300
#define AIS_WARP_2   301
#define AIS_WARP_3   302
#define AIS_WARP_4   303
#define AIS_WARP_5   304
#define AIS_DEPART_TO_BAY   305
#define MAX_PATH_POINTS   1000
#define SUBSYS_PATH_DIST   500.0f
#define MAX_BURST_DAMAGE   20
#define BURST_DURATION   500


typedef struct ai_flag_name ai_flag_name
typedef struct ai_goal ai_goal
typedef struct ai_class ai_class
typedef struct pnode pnode
typedef struct ai_info ai_info


void update_ai_info_for_hit (int hitter_obj, int hit_obj)
void ai_frame_all (void)
int find_guard_obj (void)
const char * Skill_level_names (int skill_level, int translate=1)
int ai_get_slot (int shipnum)
 Returns index of free AI slot. More...
void ai_free_slot (int ai_index)
 Frees a currently used AI slot. More...
void ai_object_init (object *obj, int ai_index)
void ai_process (object *obj, int ai_index, float frametime)
int get_wingnum (int objnum)
void set_wingnum (int objnum, int wingnum)
char * ai_get_goal_target_name (const char *name, int *index)
void init_ai_system (void)
void ai_attack_object (object *attacker, object *attacked, ship_subsys *ssp)
void ai_evade_object (object *evader, object *evaded)
void ai_ignore_object (object *ignorer, object *ignored, int ignore_new)
void ai_ignore_wing (object *ignorer, int wingnum)
void ai_dock_with_object (object *docker, int docker_index, object *dockee, int dockee_index, int dock_type)
void ai_stay_still (object *still_objp, vec3d *view_pos)
void ai_do_default_behavior (object *obj)
void ai_start_waypoints (object *objp, waypoint_list *wp_list, int wp_flags)
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_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=NULL, int sexp_flags=0)
void init_ai_object (int objnum)
void ai_init (void)
void ai_level_init (void)
int ai_set_attack_subsystem (object *objp, int subnum)
int ai_issue_rearm_request (object *requester_objp)
int ai_abort_rearm_request (object *requester_objp)
void ai_do_repair_frame (object *objp, ai_info *aip, float frametime)
void ai_update_danger_weapon (int objnum, int weapon_objnum)
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 ai_set_guard_object (object *objp, object *other_objp)
void ai_set_evade_object (object *objp, object *other_objp)
void ai_set_guard_wing (object *objp, int wingnum)
void ai_warp_out (object *objp, vec3d *vp)
void ai_attack_wing (object *attacker, int wingnum)
void ai_deathroll_start (object *ship_obj)
void ai_fly_in_formation (int wing_num)
void ai_disband_formation (int wing_num)
int set_target_objnum (ai_info *aip, int objnum)
void ai_form_on_wing (object *objp, object *goal_objp)
void ai_do_stay_near (object *objp, object *other_obj, float dist)
ship_subsysset_targeted_subsys (ai_info *aip, ship_subsys *new_subsys, int parent_objnum)
void ai_rearm_repair (object *objp, int docker_index, object *goal_objp, int dockee_index)
void ai_add_rearm_goal (object *requester_objp, object *support_objp)
void create_model_path (object *pl_objp, object *mobjp, int path_num, int subsys_path=0)
int ai_find_goal_index (ai_goal *aigp, int mode, int submode=-1, int priority=-1)
void ai_do_safety (object *objp)
int ai_acquire_emerge_path (object *pl_objp, int parent_objnum, int path_mask, vec3d *pos, vec3d *fvec)
int ai_acquire_depart_path (object *pl_objp, int parent_objnum, int path_mask)
void ai_set_positions (object *pl_objp, object *en_objp, ai_info *aip, vec3d *player_pos, vec3d *enemy_pos)
void accelerate_ship (ai_info *aip, float accel)
void turn_away_from_point (object *objp, vec3d *point, float bank_override)
float ai_endangered_by_weapon (ai_info *aip)
void update_aspect_lock_information (ai_info *aip, vec3d *vec_to_enemy, float dist_to_enemy, float enemy_radius)
void ai_chase_ct ()
void ai_find_path (object *pl_objp, int objnum, int path_num, int exit_flag, int subsys_path=0)
float ai_path ()
void evade_weapon ()
int might_collide_with_ship (object *obj1, object *obj2, float dot_to_enemy, float dist_to_enemy, float duration)
int ai_fire_primary_weapon (object *objp)
int ai_fire_secondary_weapon (object *objp, int priority1=-1, int priority2=-1)
float ai_get_weapon_dist (ship_weapon *swp)
void turn_towards_point (object *objp, vec3d *point, vec3d *slide_vec, float bank_override)
int ai_maybe_fire_afterburner (object *objp, ai_info *aip)
void set_predicted_enemy_pos (vec3d *predicted_enemy_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, ai_info *aip)
int is_instructor (object *objp)
int find_enemy (int objnum, float range, int max_attackers)
float ai_get_weapon_speed (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 ai_set_rearm_status (int team, int new_status)
void ai_good_secondary_time (int team, int weapon_index, int num_weapons, char *shipname)
void ai_do_objects_docked_stuff (object *docker, int docker_point, object *dockee, int dockee_point, bool update_clients=true)
void ai_do_objects_undocked_stuff (object *docker, object *dockee)
void ai_do_objects_repairing_stuff (object *repaired_obj, object *repair_obj, int how)
float dock_orient_and_approach (object *docker_objp, int docker_index, object *dockee_objp, int dockee_index, int dock_mode, rotating_dockpoint_info *rdinfo=NULL)
int find_danger_weapon (object *sobjp, float dtime, float *atime, float dot_threshhold)
void ai_set_mode_warp_out (object *objp, ai_info *aip)
int get_nearest_objnum (int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers)
void ai_announce_ship_dying (object *dying_objp)
void ai_start_fly_to_ship (object *objp, int shipnum)
void ai_fly_to_ship ()
void process_subobjects (int objnum)
void init_aip_from_class_and_profile (ai_info *aip, ai_class *aicp, ai_profile_t *profile)
void ai_update_aim (ai_info *aip)
void do_random_sidethrust (ai_info *aip, ship_info *sip)


ai_flag_name Ai_flag_names []
pnode Path_points [MAX_PATH_POINTS]
int Mission_all_attack
int Total_goal_target_names
char Goal_target_names [MAX_GOAL_TARGET_NAMES][NAME_LENGTH]
ai_info Ai_info []
char ** Ai_class_names
int Num_ai_classes
int Ai_firing_enabled
int Ai_goal_signature
float AI_frametime

Macro Definition Documentation


Definition at line 196 of file ai.h.

#define AI_DEFAULT_CLASS   3

Definition at line 27 of file ai.h.

#define AI_GOAL_NONE   -1

Definition at line 194 of file ai.h.

#define AIDO_DOCK   1

Definition at line 81 of file ai.h.

#define AIDO_DOCK_NOW   2

Definition at line 82 of file ai.h.

#define AIDO_UNDOCK   3

Definition at line 83 of file ai.h.

#define AIF_ATTACK_SLOWLY   (1 << 15)

Definition at line 53 of file ai.h.


Definition at line 69 of file ai.h.

#define AIF_AVOID_SHOCKWAVE_SHIP   (1 << 12)

Definition at line 50 of file ai.h.


Definition at line 52 of file ai.h.

#define AIF_AVOID_SHOCKWAVE_WEAPON   (1 << 13)

Definition at line 51 of file ai.h.

#define AIF_AVOIDING_BIG_SHIP   (1 << 20)

Definition at line 58 of file ai.h.

#define AIF_AVOIDING_SMALL_SHIP   (1 << 19)

Definition at line 57 of file ai.h.

#define AIF_AWAITING_REPAIR   (1 << 1)

Definition at line 39 of file ai.h.

#define AIF_BEING_REPAIRED   (1 << 2)

Definition at line 40 of file ai.h.

#define AIF_BIG_SHIP_COLLIDE_RECOVER_1   (1 << 21)

Definition at line 59 of file ai.h.

#define AIF_BIG_SHIP_COLLIDE_RECOVER_2   (1 << 22)

Definition at line 60 of file ai.h.


Definition at line 70 of file ai.h.

#define AIF_FORMATION_OBJECT   (1 << 5)

Definition at line 43 of file ai.h.

#define AIF_FORMATION_WING   (1 << 0)

Definition at line 38 of file ai.h.

#define AIF_FREE_AFTERBURNER_USE   (1 << 26)

Definition at line 67 of file ai.h.

#define AIF_KAMIKAZE   (1 << 17)

Definition at line 55 of file ai.h.

#define AIF_NO_DYNAMIC   (1 << 18)

Definition at line 56 of file ai.h.

#define AIF_ON_SUBSYS_PATH   (1 << 11)

Definition at line 49 of file ai.h.

#define AIF_REPAIR_OBSTRUCTED   (1 << 16)

Definition at line 54 of file ai.h.

#define AIF_REPAIRING   (1 << 3)

Definition at line 41 of file ai.h.

#define AIF_SEEK_LOCK   (1 << 4)

Definition at line 42 of file ai.h.

#define AIF_STEALTH_PURSUIT   (1 << 23)

Definition at line 61 of file ai.h.

#define AIF_TARGET_COLLISION   (1 << 9)

Definition at line 47 of file ai.h.

#define AIF_TEMPORARY_IGNORE   (1 << 6)

Definition at line 44 of file ai.h.


Definition at line 65 of file ai.h.

#define AIF_UNLOAD_PRIMARIES   (1 << 24)

Definition at line 64 of file ai.h.

#define AIF_UNLOAD_SECONDARIES   (1 << 10)

Definition at line 48 of file ai.h.

#define AIF_USE_EXIT_PATH   (1 << 7)

Definition at line 45 of file ai.h.

#define AIF_USE_STATIC_PATH   (1 << 8)

Definition at line 46 of file ai.h.

#define AIG_TYPE_DYNAMIC   5

Definition at line 101 of file ai.h.


Definition at line 97 of file ai.h.


Definition at line 98 of file ai.h.


Definition at line 99 of file ai.h.


Definition at line 100 of file ai.h.


Definition at line 111 of file ai.h.


Definition at line 114 of file ai.h.

#define AIGF_DOCKEE_INDEX_VALID   (1<<1)

Definition at line 105 of file ai.h.

#define AIGF_DOCKER_INDEX_VALID   (1<<0)

Definition at line 104 of file ai.h.

#define AIGF_GOAL_ON_HOLD   (1<<2)

Definition at line 106 of file ai.h.

#define AIGF_GOAL_OVERRIDE   (1<<4)

Definition at line 108 of file ai.h.

#define AIGF_GOALS_PURGED   (1<<6)

Definition at line 110 of file ai.h.

#define AIGF_PURGE   (1<<5)

Definition at line 109 of file ai.h.

#define AIGF_SUBSYS_NEEDS_FIXUP   (1<<3)

Definition at line 107 of file ai.h.

#define AIGF_TARGET_OWN_TEAM   (1<<8)

Definition at line 112 of file ai.h.

#define AIM_AVOID   6

Definition at line 172 of file ai.h.

#define AIM_BAY_DEPART   18

Definition at line 184 of file ai.h.

#define AIM_BAY_EMERGE   17

Definition at line 183 of file ai.h.

#define AIM_BE_REARMED   12

Definition at line 178 of file ai.h.

#define AIM_BIGSHIP   10

Definition at line 176 of file ai.h.

#define AIM_CHASE   0

Definition at line 166 of file ai.h.

#define AIM_DOCK   8

Definition at line 174 of file ai.h.

#define AIM_EVADE   1

Definition at line 167 of file ai.h.

#define AIM_EVADE_WEAPON   14

Definition at line 180 of file ai.h.

#define AIM_FLY_TO_SHIP   21

Definition at line 187 of file ai.h.

#define AIM_GET_BEHIND   2

Definition at line 168 of file ai.h.

#define AIM_GUARD   5

Definition at line 171 of file ai.h.

#define AIM_NONE   9

Definition at line 175 of file ai.h.

#define AIM_PATH   11

Definition at line 177 of file ai.h.

#define AIM_PLAY_DEAD   16

Definition at line 182 of file ai.h.

#define AIM_SAFETY   13

Definition at line 179 of file ai.h.

#define AIM_SENTRYGUN   19

Definition at line 185 of file ai.h.

#define AIM_STAY_NEAR   3

Definition at line 169 of file ai.h.

#define AIM_STILL   4

Definition at line 170 of file ai.h.

#define AIM_STRAFE   15

Definition at line 181 of file ai.h.

#define AIM_WARP_OUT   20

Definition at line 186 of file ai.h.

#define AIM_WAYPOINTS   7

Definition at line 173 of file ai.h.

#define AIORF_FORWARD   (1<<7)

Definition at line 131 of file ai.h.

#define AIORF_FULL   (1<<0)

Definition at line 124 of file ai.h.

#define AIORF_FULL_LAT   (1<<4)

Definition at line 128 of file ai.h.

#define AIORF_HEADING   (1<<3)

Definition at line 127 of file ai.h.

#define AIORF_PITCH   (1<<2)

Definition at line 126 of file ai.h.

#define AIORF_ROLL   (1<<1)

Definition at line 125 of file ai.h.

#define AIORF_SIDEWAYS   (1<<6)

Definition at line 130 of file ai.h.

#define AIORF_UP   (1<<5)

Definition at line 129 of file ai.h.


Definition at line 266 of file ai.h.


Definition at line 265 of file ai.h.

#define AIS_DEPART_TO_BAY   305

Definition at line 309 of file ai.h.

#define AIS_DOCK_0   20

Definition at line 269 of file ai.h.

#define AIS_DOCK_1   21

Definition at line 270 of file ai.h.

#define AIS_DOCK_2   22

Definition at line 271 of file ai.h.

#define AIS_DOCK_3   23

Definition at line 272 of file ai.h.

#define AIS_DOCK_4   24

Definition at line 273 of file ai.h.

#define AIS_DOCK_4A   25

Definition at line 274 of file ai.h.

#define AIS_GUARD_2   103

Definition at line 284 of file ai.h.

#define AIS_GUARD_ATTACK   102

Definition at line 283 of file ai.h.

#define AIS_GUARD_PATROL   101

Definition at line 282 of file ai.h.

#define AIS_GUARD_STATIC   104

Definition at line 285 of file ai.h.

#define AIS_STRAFE_ATTACK   201

Definition at line 288 of file ai.h.

#define AIS_STRAFE_AVOID   202

Definition at line 289 of file ai.h.


Definition at line 293 of file ai.h.


Definition at line 292 of file ai.h.

#define AIS_STRAFE_RETREAT1   203

Definition at line 290 of file ai.h.

#define AIS_STRAFE_RETREAT2   204

Definition at line 291 of file ai.h.

#define AIS_UNDOCK_0   30

Definition at line 275 of file ai.h.

#define AIS_UNDOCK_1   31

Definition at line 276 of file ai.h.

#define AIS_UNDOCK_2   32

Definition at line 277 of file ai.h.

#define AIS_UNDOCK_3   33

Definition at line 278 of file ai.h.

#define AIS_UNDOCK_4   34

Definition at line 279 of file ai.h.

#define AIS_WARP_1   300

Definition at line 304 of file ai.h.

#define AIS_WARP_2   301

Definition at line 305 of file ai.h.

#define AIS_WARP_3   302

Definition at line 306 of file ai.h.

#define AIS_WARP_4   303

Definition at line 307 of file ai.h.

#define AIS_WARP_5   304

Definition at line 308 of file ai.h.

#define AISS_1   41

Definition at line 86 of file ai.h.

#define AISS_1a   44

Definition at line 89 of file ai.h.

#define AISS_2   42

Definition at line 87 of file ai.h.

#define AISS_3   43

Definition at line 88 of file ai.h.

#define AITTV_FAST   (1<<0)

Definition at line 117 of file ai.h.

#define AITTV_IGNORE_BANK   (1<<2)

Definition at line 119 of file ai.h.

#define AITTV_VIA_SEXP   (1<<1)

Definition at line 118 of file ai.h.

#define BURST_DURATION   500

Definition at line 573 of file ai.h.

#define DOA_APPROACH   1

Definition at line 73 of file ai.h.

#define DOA_DOCK   2

Definition at line 74 of file ai.h.

#define DOA_DOCK_STAY   6

Definition at line 78 of file ai.h.

#define DOA_UNDOCK_1   3

Definition at line 75 of file ai.h.

#define DOA_UNDOCK_2   4

Definition at line 76 of file ai.h.

#define DOA_UNDOCK_3   5

Definition at line 77 of file ai.h.

#define KAMIKAZE_HULL_ON_DEATH   -1000.0f

Definition at line 121 of file ai.h.

#define MAX_AI_BEHAVIORS   22

Definition at line 189 of file ai.h.

#define MAX_AI_FLAG_NAMES   2

Definition at line 35 of file ai.h.

#define MAX_AI_GOALS   5

Definition at line 91 of file ai.h.


Definition at line 564 of file ai.h.

#define MAX_BURST_DAMAGE   20

Definition at line 572 of file ai.h.

#define MAX_ENEMY_DISTANCE   2500.0f

Definition at line 192 of file ai.h.


Definition at line 164 of file ai.h.


Definition at line 327 of file ai.h.

#define MAX_PATH_POINTS   1000

Definition at line 322 of file ai.h.


Definition at line 191 of file ai.h.


Definition at line 301 of file ai.h.

#define PD_BACKWARD   -1

Definition at line 299 of file ai.h.

#define PD_FORWARD   1

Definition at line 298 of file ai.h.

#define SM_ATTACK   2

Definition at line 247 of file ai.h.

#define SM_ATTACK_FOREVER   12

Definition at line 257 of file ai.h.

#define SM_AVOID   7

Definition at line 252 of file ai.h.

#define SM_BIG_APPROACH   15

Definition at line 260 of file ai.h.

#define SM_BIG_CIRCLE   16

Definition at line 261 of file ai.h.

#define SM_BIG_PARALLEL   17

Definition at line 262 of file ai.h.


Definition at line 246 of file ai.h.

#define SM_EVADE   5

Definition at line 250 of file ai.h.

#define SM_EVADE_BRAKE   4

Definition at line 249 of file ai.h.


Definition at line 248 of file ai.h.

#define SM_EVADE_WEAPON   10

Definition at line 255 of file ai.h.

#define SM_FLY_AWAY   11

Definition at line 256 of file ai.h.

#define SM_GET_AWAY   9

Definition at line 254 of file ai.h.

#define SM_GET_BEHIND   8

Definition at line 253 of file ai.h.

#define SM_STEALTH_FIND   13

Definition at line 258 of file ai.h.

#define SM_STEALTH_SWEEP   14

Definition at line 259 of file ai.h.

#define SM_SUPER_ATTACK   6

Definition at line 251 of file ai.h.

#define SUBSYS_PATH_DIST   500.0f

Definition at line 569 of file ai.h.

#define WPF_BACKTRACK   (1 << 1)

Definition at line 296 of file ai.h.

#define WPF_REPEAT   (1 << 0)

Definition at line 295 of file ai.h.

Typedef Documentation

typedef struct ai_class ai_class
typedef struct ai_flag_name ai_flag_name
typedef struct ai_goal ai_goal
typedef struct ai_info ai_info
typedef struct pnode pnode

Function Documentation

void accelerate_ship ( ai_info aip,
float  accel 

Definition at line 1370 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  path_mask 

Definition at line 12883 of file aicode.cpp.

int ai_acquire_emerge_path ( object pl_objp,
int  parent_objnum,
int  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.

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_deathroll_start ( object dying_objp)

Do stuff at start of deathroll.

Definition at line 15299 of file aicode.cpp.

void ai_disband_formation ( int  wing_num)

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 = true 

Definition at line 3008 of file aicode.cpp.

void ai_do_objects_repairing_stuff ( object repaired_obj,
object repair_obj,
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_with_object ( object docker,
int  docker_index,
object dockee,
int  dockee_index,
int  dock_type 

Definition at line 3098 of file aicode.cpp.

float ai_endangered_by_weapon ( ai_info aip)

Definition at line 6584 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.

int ai_find_goal_index ( ai_goal aigp,
int  mode,
int  submode = -1,
int  priority = -1 

Definition at line 1017 of file aigoals.cpp.

void ai_find_path ( object pl_objp,
int  objnum,
int  path_num,
int  exit_flag,
int  subsys_path = 0 

Definition at line 2875 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 = -1,
int  priority2 = -1 

Definition at line 6050 of file aicode.cpp.

void ai_fly_in_formation ( int  wing_num)

Definition at line 11532 of file aicode.cpp.

void ai_fly_to_ship ( )

Definition at line 4607 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.

void ai_frame_all ( void  )
void ai_free_slot ( int  ai_index)

Frees a currently used AI slot.

Only modifies in Ai_info struct. Does not modify hook in ship.

Definition at line 50 of file ai.cpp.

char* ai_get_goal_target_name ( const char *  name,
int index 

Definition at line 85 of file ai.cpp.

int ai_get_slot ( int  shipnum)

Returns index of free AI slot.

Return -1 if no free slot.

Definition at line 30 of file ai.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.

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.

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.

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

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_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_guard_object ( object objp,
object other_objp 

Definition at line 7532 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"

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_still ( object still_objp,
vec3d view_pos 

Definition at line 2982 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 = NULL,
int  sexp_flags = 0 

Definition at line 1131 of file aicode.cpp.

void ai_update_aim ( ai_info aip)

Updates AI aim automatically based on targetted enemy.

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_warp_out ( object objp,
vec3d vp 
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.

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.

void do_random_sidethrust ( ai_info aip,
ship_info sip 

Definition at line 6609 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 = NULL 

Definition at line 9070 of file aicode.cpp.

void evade_weapon ( )

Definition at line 4904 of file aicode.cpp.

int find_danger_weapon ( object sobjp,
float  dtime,
float atime,
float  dot_threshhold 
int find_enemy ( int  objnum,
float  range,
int  max_attackers 

Return objnum if enemy found, else return -1;

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_guard_obj ( void  )
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.

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

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.

int get_wingnum ( int  objnum)

Definition at line 57 of file ai.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_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_instructor ( object objp)

Is an instructor if name begins INSTRUCTOR_SHIP_NAME else not.

true if object *objp is an instructor.

Definition at line 4895 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.

void process_subobjects ( int  objnum)

Definition at line 11120 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.

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 set_wingnum ( int  objnum,
int  wingnum 

Definition at line 68 of file ai.cpp.

const char* Skill_level_names ( int  skill_level,
int  translate = 1 

Definition at line 208 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.

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.

void update_ai_info_for_hit ( int  hitter_obj,
int  hit_obj 
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.

Variable Documentation

char** Ai_class_names

Definition at line 268 of file aicode.cpp.

ai_class* Ai_classes

Definition at line 193 of file aicode.cpp.

int Ai_firing_enabled

Definition at line 194 of file aicode.cpp.

ai_flag_name Ai_flag_names[]

Definition at line 203 of file aicode.cpp.

float AI_frametime

Definition at line 266 of file aicode.cpp.

int Ai_goal_signature

Definition at line 58 of file aigoals.cpp.

ai_info Ai_info[]

Definition at line 23 of file ai.cpp.

object* En_objp

Definition at line 170 of file aicode.cpp.

char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH]

Definition at line 22 of file ai.cpp.

int Mission_all_attack

Definition at line 200 of file aicode.cpp.

int Num_ai_classes

Definition at line 195 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.

ai_info* Player_ai

Definition at line 24 of file ai.cpp.

pnode* Ppfp

Definition at line 264 of file aicode.cpp.

int Total_goal_target_names

Definition at line 21 of file ai.cpp.