FS2_Open
Open source remastering of the Freespace 2 engine
ai.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _AI_H
13 #define _AI_H
14 
15 #include "ai/ai_profiles.h"
16 #include "globalincs/globals.h"
17 #include "globalincs/pstypes.h"
18 #include "globalincs/systemvars.h"
19 #include "object/waypoint.h"
20 #include "physics/physics.h"
21 
22 struct ship_weapon;
23 class ship_subsys;
24 class object;
25 class ship_info;
26 
27 #define AI_DEFAULT_CLASS 3 // default AI class for new ships (Fred)
28 
29 typedef struct ai_flag_name {
30  int flag;
32  int flag_list;
33 } ai_flag_name;
34 
35 #define MAX_AI_FLAG_NAMES 2
37 
38 #define AIF_FORMATION_WING (1 << 0) // Fly in formation as part of wing.
39 #define AIF_AWAITING_REPAIR (1 << 1) // Awaiting a repair ship.
40 #define AIF_BEING_REPAIRED (1 << 2) // Currently docked with repair ship.
41 #define AIF_REPAIRING (1 << 3) // Repairing a ship (or going to repair a ship)
42 #define AIF_SEEK_LOCK (1 << 4) // set if should focus on gaining aspect lock, not hitting with lasers
43 #define AIF_FORMATION_OBJECT (1 << 5) // Fly in formation off a specific object.
44 #define AIF_TEMPORARY_IGNORE (1 << 6) // Means current ignore_objnum is only temporary, not an order from the player.
45 #define AIF_USE_EXIT_PATH (1 << 7) // Used by path code, to flag path as an exit path
46 #define AIF_USE_STATIC_PATH (1 << 8) // Used by path code, use fixed path, don't try to recreate
47 #define AIF_TARGET_COLLISION (1 << 9) // Collided with aip->target_objnum last frame. Avoid that ship for half a second or so.
48 #define AIF_UNLOAD_SECONDARIES (1 << 10) // Fire secondaries as fast as possible!
49 #define AIF_ON_SUBSYS_PATH (1 << 11) // Current path leads to a subsystem
50 #define AIF_AVOID_SHOCKWAVE_SHIP (1 << 12) // Avoid an existing shockwave from a ship.
51 #define AIF_AVOID_SHOCKWAVE_WEAPON (1 << 13) // Avoid an expected shockwave from a weapon. shockwave_object field contains object index.
52 #define AIF_AVOID_SHOCKWAVE_STARTED (1 << 14) // Already started avoiding shockwave, don't keep deciding whether to avoid.
53 #define AIF_ATTACK_SLOWLY (1 << 15) // Move slowly while attacking.
54 #define AIF_REPAIR_OBSTRUCTED (1 << 16) // Ship wants to be repaired, but path is obstructed.
55 #define AIF_KAMIKAZE (1 << 17) // Crash into target
56 #define AIF_NO_DYNAMIC (1 << 18) // Not allowed to get dynamic goals
57 #define AIF_AVOIDING_SMALL_SHIP (1 << 19) // Avoiding a player ship.
58 #define AIF_AVOIDING_BIG_SHIP (1 << 20) // Avoiding a large ship.
59 #define AIF_BIG_SHIP_COLLIDE_RECOVER_1 (1 << 21) // Collided into a big ship. Recovering by flying away.
60 #define AIF_BIG_SHIP_COLLIDE_RECOVER_2 (1 << 22) // Collided into a big ship. Fly towards big ship sphere perimeter.
61 #define AIF_STEALTH_PURSUIT (1 << 23) // AI is trying to fight stealth ship
62 
63 // Goober5000
64 #define AIF_UNLOAD_PRIMARIES (1 << 24) // Fire primaries as fast as possible!
65 #define AIF_TRYING_UNSUCCESSFULLY_TO_WARP (1 << 25) // Trying to warp, but can't warp at the moment
66 
67 #define AIF_FREE_AFTERBURNER_USE (1 << 26) // Use afterburners while following waypoints or flying towards objects
68 
69 #define AIF_AVOID_SHOCKWAVE (AIF_AVOID_SHOCKWAVE_SHIP | AIF_AVOID_SHOCKWAVE_WEAPON)
70 #define AIF_FORMATION (AIF_FORMATION_WING | AIF_FORMATION_OBJECT)
71 
72 // dock_orient_and_approach() modes.
73 #define DOA_APPROACH 1 // Approach the current point on the path (aip->path_cur)
74 #define DOA_DOCK 2 // Dock with goal object.
75 #define DOA_UNDOCK_1 3 // Begin undocking with goal object. Just move away.
76 #define DOA_UNDOCK_2 4 // Secondary undocking. Move away.
77 #define DOA_UNDOCK_3 5 // Tertiary undocking. Move away and orient away.
78 #define DOA_DOCK_STAY 6 // Rigidly maintain position in dock bay.
79 
80 // Type values for ai_dock_with_object() dock_type parameter.
81 #define AIDO_DOCK 1 // Set goal of docking with object.
82 #define AIDO_DOCK_NOW 2 // Immediately move into dock position. For ships that start mission docked.
83 #define AIDO_UNDOCK 3 // Set goal of undocking with object.
84 
85 // Submodes for seeking safety.
86 #define AISS_1 41 // Pick a spot to fly to.
87 #define AISS_2 42 // Flying to spot.
88 #define AISS_3 43 // Gotten near spot, fly about there.
89 #define AISS_1a 44 // Pick a new nearby spot because we are endangered, then go to AISS_2
90 
91 #define MAX_AI_GOALS 5
92 
93 // types of ai goals -- tyese types will help us to determination on which goals should
94 // have priority over others (i.e. when a player issues a goal to a wing, then a seperate
95 // goal to a ship in that wing). We would probably use this type in conjunction with
96 // goal priority to establish which goal to follow
97 #define AIG_TYPE_EVENT_SHIP 1 // from mission event direct to ship
98 #define AIG_TYPE_EVENT_WING 2 // from mission event direct to wing
99 #define AIG_TYPE_PLAYER_SHIP 3 // from player direct to ship
100 #define AIG_TYPE_PLAYER_WING 4 // from player direct to wing
101 #define AIG_TYPE_DYNAMIC 5 // created on the fly
102 
103 // flags for AI_GOALS
104 #define AIGF_DOCKER_INDEX_VALID (1<<0) // when set, index field for docker is valid
105 #define AIGF_DOCKEE_INDEX_VALID (1<<1) // when set, index field for dockee is valid
106 #define AIGF_GOAL_ON_HOLD (1<<2) // when set, this goal cannot currently be satisfied, although it could be in the future
107 #define AIGF_SUBSYS_NEEDS_FIXUP (1<<3) // when set, the subsystem index (for a destroy subsystem goal) is invalid and must be gotten from the subsys name stored in docker.name field!!
108 #define AIGF_GOAL_OVERRIDE (1<<4) // paired with AIG_TYPE_DYNAMIC to mean this goal overrides any other goal
109 #define AIGF_PURGE (1<<5) // purge this goal next time we process
110 #define AIGF_GOALS_PURGED (1<<6) // this goal has already caused other goals to get purged
111 #define AIGF_DEPART_SOUND_PLAYED (1<<7) // Goober5000 - replacement for AL's hack ;)
112 #define AIGF_TARGET_OWN_TEAM (1<<8) // Goober5000 - removes standard precautions against AI ships taking traitorous actions
113 
114 #define AIGF_DOCK_INDEXES_VALID (AIGF_DOCKER_INDEX_VALID|AIGF_DOCKEE_INDEX_VALID)
115 
116 // Flags to ai_turn_towards_vector().
117 #define AITTV_FAST (1<<0) // Turn fast, not slowed down based on skill level.
118 #define AITTV_VIA_SEXP (1<<1) // Goober5000 - via sexp
119 #define AITTV_IGNORE_BANK (1<<2) // Goober5000 - ignore bank when turning
120 
121 #define KAMIKAZE_HULL_ON_DEATH -1000.0f // Hull strength ship gets set to if it crash-dies.
122 
123 // flags for possible ai overrides
124 #define AIORF_FULL (1<<0) // Full sexp control
125 #define AIORF_ROLL (1<<1) // Sexp forced roll maneuver
126 #define AIORF_PITCH (1<<2) // Sexp forced pitch change
127 #define AIORF_HEADING (1<<3) // Sexp forced heading change
128 #define AIORF_FULL_LAT (1<<4) // full control over up/side/forward movement
129 #define AIORF_UP (1<<5) // vertical movement
130 #define AIORF_SIDEWAYS (1<<6) // horizontal movement
131 #define AIORF_FORWARD (1<<7) // forward movement
132 
133 // structure for AI goals
134 typedef struct ai_goal {
135  int signature; // Unique identifier. All goals ever created (per mission) have a unique signature.
136  int ai_mode; // one of the AIM_* modes for this goal
137  int ai_submode; // maybe need a submode
138  int type; // one of the AIG_TYPE_* values above
139  int flags; // one of the AIGF_* values above
140  fix time; // time at which this goal was issued.
141  int priority; // how important is this goal -- number 0 - 100
142 
143  char *target_name; // name of the thing that this goal acts upon
144  int target_name_index; // index of goal_target_name in Goal_target_names[][]
145  waypoint_list *wp_list; // waypoints that this ship might fly.
146  int target_instance; // instance of thing this ship might be chasing (currently only used for weapons; note, not the same as objnum!)
147  int target_signature; // signature of object this ship might be chasing (currently only used for weapons; paired with above value to confirm target)
148 
149  // unions for docking stuff.
150  // (AIGF_DOCKER_INDEX_VALID and AIGF_DOCKEE_INDEX_VALID tell us to use indexes; otherwise we use names)
151  // these are the dockpoints used on the docker and dockee ships, not the ships themselves
152  union {
153  char *name;
154  int index;
155  } docker;
156 
157  union {
158  char *name;
159  int index;
160  } dockee;
161 
162 } ai_goal;
163 
164 #define MAX_GOAL_TARGET_NAMES 100
165 
166 #define AIM_CHASE 0
167 #define AIM_EVADE 1
168 #define AIM_GET_BEHIND 2
169 #define AIM_STAY_NEAR 3 // Stay near another ship.
170 #define AIM_STILL 4 // Sit still. Don't move. Hold your breath. Don't blink.
171 #define AIM_GUARD 5 // Guard an object
172 #define AIM_AVOID 6 // Avoid an object
173 #define AIM_WAYPOINTS 7 // Fly waypoints
174 #define AIM_DOCK 8 // Dock with ship.
175 #define AIM_NONE 9 // Uh, do nothing.
176 #define AIM_BIGSHIP 10 // Like a capital ship, doesn't focus on one ship.
177 #define AIM_PATH 11 // Follow path on ship
178 #define AIM_BE_REARMED 12 // Allow self to be rearmed
179 #define AIM_SAFETY 13 // Seek safety at periphery of battle
180 #define AIM_EVADE_WEAPON 14 // Evade a weapon.
181 #define AIM_STRAFE 15 // Attack a big ship by strafing it
182 #define AIM_PLAY_DEAD 16 // Play dead. Get it? Don't move, fire, etc.
183 #define AIM_BAY_EMERGE 17 // Emerging from a fighter bay, following path to do so
184 #define AIM_BAY_DEPART 18 // Departing to a fighter bay, following path to do so
185 #define AIM_SENTRYGUN 19 // AI mode for sentry guns only (floating turrets)
186 #define AIM_WARP_OUT 20 // Commence warp out sequence. Point in legal direction. Then call John's code.
187 #define AIM_FLY_TO_SHIP 21 // [Kazan] Fly to a ship, doesn't matter if it's hostile or friendly -- for Autopilot usage
188 
189 #define MAX_AI_BEHAVIORS 22 // Number of AIM_xxxx types
190 
191 #define MAX_WAYPOINTS_PER_LIST 20
192 #define MAX_ENEMY_DISTANCE 2500.0f // Maximum distance from which a ship will pursue an enemy.
193 
194 #define AI_GOAL_NONE -1
195 
196 #define AI_ACTIVE_GOAL_DYNAMIC 999
197 
198 typedef struct ai_class {
204 
205  //SUSHI: These were originally in AI_Profiles, adding the option to override in AI.tbl
206  //INT_MIN and FLT_MIN represent the "not set" state for which defaults are used instead.
230  int ai_profile_flags; //Holds the state of flags that are set
231  int ai_profile_flags_set; //Holds which flags are set and which are just left alone
234 
235  //SUSHI: These are optional overrides to an AI class to prevent the automatic scaling based on AI class index
240  bool ai_class_autoscale; //Defaults to true, but can be turned off in order to disable extra scaling of some AI behaviors
241  //based on AI class index
242 } ai_class;
243 
244 // Submode definitions.
245 // Note: These need to be renamed to be of the form: AIS_mode_xxxx
246 #define SM_CONTINUOUS_TURN 1 // takes parm: vector_id {0..3 = right, -right, up, -up}
247 #define SM_ATTACK 2
248 #define SM_EVADE_SQUIGGLE 3
249 #define SM_EVADE_BRAKE 4
250 #define SM_EVADE 5
251 #define SM_SUPER_ATTACK 6
252 #define SM_AVOID 7
253 #define SM_GET_BEHIND 8
254 #define SM_GET_AWAY 9
255 #define SM_EVADE_WEAPON 10 // Evade incoming weapon
256 #define SM_FLY_AWAY 11 // Fly away from target_objnum
257 #define SM_ATTACK_FOREVER 12 // Engine subsystem destroyed, so attack, never evading, avoiding, etc.
258 #define SM_STEALTH_FIND 13 // Stealth ship is "targeted", but not visible, so try to find based on predicted pos
259 #define SM_STEALTH_SWEEP 14 // General sweep, looking for stealth after not visible for some time.
260 #define SM_BIG_APPROACH 15 // Big ship approaches another
261 #define SM_BIG_CIRCLE 16 // Big ship flies circle around other big ship to get good angle to go parallel
262 #define SM_BIG_PARALLEL 17 // Big ship flies parallel to another
263 
264 //SUSHI: Attack submodes (besides those implicitly listed above)
265 #define AIS_CHASE_GLIDEATTACK 18 // Ship uses glide to move in a constant direction while pointing and shooting at target
266 #define AIS_CHASE_CIRCLESTRAFE 19 // Attempt a circle-strafe on the target
267 
268 // Submodes for docking behavior
269 #define AIS_DOCK_0 20
270 #define AIS_DOCK_1 21
271 #define AIS_DOCK_2 22
272 #define AIS_DOCK_3 23
273 #define AIS_DOCK_4 24 // Only for rearm/repair.
274 #define AIS_DOCK_4A 25 // Only for not rearm/repair. MK, 7/15/97
275 #define AIS_UNDOCK_0 30
276 #define AIS_UNDOCK_1 31
277 #define AIS_UNDOCK_2 32
278 #define AIS_UNDOCK_3 33
279 #define AIS_UNDOCK_4 34
280 
281 // Submodes for Guard behavior
282 #define AIS_GUARD_PATROL 101
283 #define AIS_GUARD_ATTACK 102
284 #define AIS_GUARD_2 103
285 #define AIS_GUARD_STATIC 104 // maintain current relative position to guard object, if possible
286 
287 // Submodes for strafing big ships behavior (AIM_STRAFE)
288 #define AIS_STRAFE_ATTACK 201 // fly towards target and attack
289 #define AIS_STRAFE_AVOID 202 // fly evasive vector to avoid incoming fire
290 #define AIS_STRAFE_RETREAT1 203 // fly away from attack point
291 #define AIS_STRAFE_RETREAT2 204
292 #define AIS_STRAFE_POSITION 205 // re-position to resume strafing attack
293 #define AIS_STRAFE_GLIDE_ATTACK 206 // SUSHI: Glide strafe atack
294 
295 #define WPF_REPEAT (1 << 0)
296 #define WPF_BACKTRACK (1 << 1)
297 
298 #define PD_FORWARD 1
299 #define PD_BACKWARD -1
300 
301 #define MIN_TRACKABLE_ASPECT_DOT 0.992f // dot of fvec and vec_to_enemy to progress towards aspect lock
302 
303 // Submodes for warping out.
304 #define AIS_WARP_1 300 // Make sure there is no obstruction to warping out.
305 #define AIS_WARP_2 301
306 #define AIS_WARP_3 302
307 #define AIS_WARP_4 303
308 #define AIS_WARP_5 304
309 #define AIS_DEPART_TO_BAY 305
310 
311 // A node on a path.
312 // Contains global location of point.
313 // Contains hooks back to original path information.
314 // This hook is used to extract information on the point such as whether it is
315 // protected by turrets.
316 typedef struct pnode {
318  int path_num; // path number from polymodel, ie in polymodel, paths[path_num]
319  int path_index; // index in original model path of point, ie in model_path, use verts[path_index]
320 } pnode;
321 
322 #define MAX_PATH_POINTS 1000
324 extern pnode *Ppfp; // Free pointer in path points.
325 
326 // Goober5000 (based on the "you can only remember 7 things in short-term memory" assumption)
327 #define MAX_IGNORE_NEW_OBJECTS 7
328 
329 typedef struct ai_info {
330  int ai_flags; // Special flags for AI behavior.
331  int shipnum; // Ship using this slot, -1 means none.
332  int type; //
333  int wing; // Member of what wing? -1 means none.
334 
335  int behavior; // AI behavior; vestigial field from early development of FS1
336  int mode;
338  int mode_time; // timestamp at which current mode elapses.
339  int target_objnum; // object index of current target.
340  int target_signature; // Signature of current target.
341  int previous_target_objnum; // On 5/19/97, only used for player.
342 
343  int stealth_last_cheat_visible_stamp; // when within 100m, always update pos and velocity, with error increasing for increasing time from last legal visible
348 
349  float previous_dot_to_enemy; // dot(fvec, vec_to_enemy) last frame
350  float target_time; // Amount of time continuously targeting this ship.
351 
352  int enemy_wing; // When picking an enemy wing, only allow to be in enemy_wing, unless == -1, in which case don't care.
354 
355  int goal_objnum; // mode specific goal. In DOCK, ship to dock with.
357 
358  int guard_objnum; // Ship to guard.
359  int guard_signature; // Signature of ship to guard.
360  int guard_wingnum; // Wing to guard. guard_objnum set to leader.
361 
362  int ignore_objnum; // ship to be ignored, based on player order. UNUSED_OBJNUM if none. -(wing_num+1) if ignoring wing.
363  int ignore_signature; // signature of ship to be ignored
364 
365  // Goober5000
368 
369  int ai_class; // Class. Might be override of default.
370 
371  // Probably become obsolete, to be replaced by path_start, path_cur, etc.
372  waypoint_list *wp_list; // waypoint list being followed
373  size_t wp_index; // waypoint index in list
374  int wp_flags; // waypoint flags, see WPF_xxxx
375  int waypoint_speed_cap; // -1 no cap, otherwise cap - changed to int by Goober5000
376 
377  // Path following information
378  int path_start; // Index into global array, start of path.
379  int path_cur; // Index into global array, current location in path.
380  int path_length; // Number of links in this path.
381  int path_dir; // PD_FORWARD, PD_BACKWARD
382  int path_flags; // loop, backtrack, whatever else.
383  int path_objnum; // Object of interest. It's model contains the path.
384  int path_goal_obj_hash; // Hash value of goal object when global path created.
385  fix path_next_create_time; // Next time at which we'll create a global path.
386  vec3d path_create_pos; // Object's position at time of global path creation.
387  matrix path_create_orient; // Object's orientation at time of global path creation.
388  int mp_index; // Model path index. Index in polymodel:model_paths
389  fix path_next_check_time; // Last time checked to see if would collide with model.
390  int path_goal_dist; // minimum distance to first path point to consider path reached
391  int path_subsystem_next_check; // timestamp to next check if subsystem is still visible
392  vec3d path_depart_orient; //Rotational orientation associated with the path
393 
394  int submode;
395  int previous_submode; // previous submode, get it?
396  float best_dot_to_enemy; // best dot product to enemy in last BEST_DOT_TIME seconds
397  float best_dot_from_enemy; // best dot product for enemy to player in last BEST_DOT_TIME seconds
398  fix best_dot_to_time; // time at which best dot occurred
399  fix best_dot_from_time; // time at which best dot occurred
400  fix submode_start_time; // time at which we entered the current submode
401  int submode_parm0; // parameter specific to current submode
402  int submode_parm1; // SUSHI: Another optional parameter
403  fix next_predict_pos_time; // Next time to predict position.
404 
405  //SUSHI: like last_predicted_enemy_pos, but for aiming (which currently ignores predicted position)
406  //Unlike the predicted position stuff, also takes into account velocity
407  //Only used against small ships
411 
413  int active_goal; // index of active goal, -1 if none, AI_ACTIVE_GOAL_DYNAMIC if dynamic (runtime-created) goal
414  int goal_check_time; // timer used for processing goals for this ai object
415 
416  vec3d last_predicted_enemy_pos; // Where he thought enemy was last time.
417  float time_enemy_in_range; // Amount of time enemy continuously in "sight", near crosshair.
418  float time_enemy_near; // SUSHI: amount of time enemy continuously "near" the player
419  fix last_attack_time; // Missiontime of last time this ship attacked its enemy.
420  fix last_hit_time; // Missiontime of last time this ship was hit by anyone.
421  int last_hit_quadrant; // Shield section of last hit.
422  fix last_hit_target_time; // Missiontime of last time this ship successfully hit target.
423  int hitter_objnum; // Object index of ship that hit this ship last time.
424  int hitter_signature; // Signature of hitter. Prevents stupidity if hitter gets killed.
425  fix resume_goal_time; // Time at which to resume interrupted goal, if nothing else intervenes.
426  float prev_accel; // Acceleration last frame.
427  float prev_dot_to_goal; // dot of fvec to goal last frame, used to see if making progress towards goal.
428  vec3d goal_point; // Used in AIM_SAFETY, AIM_STILL and in circling.
429  vec3d prev_goal_point; // Previous location of goal point, used at least for evading.
430 
431  //Values copied from the AI class
438 
439  //SUSHI: These were originally in AI_Profiles, adding the option to override in AI.tbl
463  int ai_profile_flags; //Holds AI_Profiles flags (possibly overriden by AI class) that actually apply to AI
465 
466 
467  union {
468  float lead_scale; // Amount to lead current opponent by.
469  float stay_near_distance; // Distance to stay within for AIM_STAY_NEAR mode.
470  };
471 
472  ship_subsys* targeted_subsys; // Targeted subobject on current target. NULL if none;
473  ship_subsys* last_subsys_target; // last known subsystem target
474  int targeted_subsys_parent; // Parent objnum of subobject, not necessarily targeted
475 
476  float aspect_locked_time; // Time towards acquiring lock for current_target
477 
478  // Goober5000
479  int support_ship_objnum; // objnum of support ship docking with us, or (if we're a support ship) object we're docking to
480  int support_ship_signature; // signature of the same
481 
482  int danger_weapon_objnum; // Closest objnum of weapon fired at this ship.
483  int danger_weapon_signature; // Signature of object danger_weapon_objnum.
484 
485  vec3d guard_vec; // vector to object being guarded, only used in AIS_GUARD_STATIC submode
486  int nearest_locked_object; // Nearest locked object.
487  float nearest_locked_distance; // Distance to nearest locked object.
488 
489  float current_target_distance; // Distance of current target from player
490  int current_target_is_locked; // Flag to indicate whether the current target is locked for missile fire
491  int current_target_dist_trend; // Tracks whether distance to target is increasing or decreasing
492  int current_target_speed_trend; // Tracks whether speed of target is increasing or decreasing
493 
494  float last_dist; // last frame's distance between player and target
495  float last_speed; // last frame's target speed
496  int last_secondary_index; // needed for secondary weapon change check
498 
499  int rearm_first_missile; // flag to show that reloading of missilies hasn't begun yet
500  int rearm_first_ballistic_primary; // flag to show that reloading of ballistic primaries hasn't begun yet
501  int rearm_release_delay; // timestamp used to delay separation of ships after rearm complete
502 
503  fix afterburner_stop_time; // Missiontime to turn off afterburner
504  int last_objsig_hit; // The object number signature of the ship last hit by this ship
505  int ignore_expire_timestamp; // Timestamp at which temporary ignore (AIF_TEMPORARY_IGNORE) expires.
506  int warp_out_timestamp; // Timestamp at which this ship is to warp out.
507  int next_rearm_request_timestamp; // Timestamp at which ship might next request rearm.
508  int primary_select_timestamp; // When to next select a primary weapon.
509  int secondary_select_timestamp; // When to next select a secondary weapon.
510 
511  int scan_for_enemy_timestamp; // When to next look for enemy fighters if sitting still while pounding
512  // on a bigship. SCAN_FIGHTERS_INTERVAL is defined in AiBig.h
513  int choose_enemy_timestamp; // Time at which it is next legal to choose a new enemy (does not apply
514  // to special situations, like getting hit by a weapon)
515  int force_warp_time; // time at which to give up avoiding a ship and just warp out
516 
517  int shockwave_object; // Object index of missile that will generate a shockwave. We will try to avoid.
518 
519  int shield_manage_timestamp; // Time at which to next manage shield.
520  int self_destruct_timestamp; // Time at which to self-destruct, probably due to being disabled.
521  int ok_to_target_timestamp; // Time at which this ship can dynamically target.
522 
523  int kamikaze_damage; // some damage value used to produce a shockwave from a kamikaze ship
524  vec3d big_attack_point; // Global point this ship is attacking on a big ship.
525  vec3d big_attack_surface_normal; // Surface normal at ship at big_attack_point;
526  int pick_big_attack_point_timestamp; // timestamp at which to pick a new point to attack on a big ship.
527 
528  // Note: These three avoid_XX terms are shared between the code that avoids small (only player now) and large ships
529  // The bits in ai_flags determine which is occurring. AIF_AVOID_SMALL_SHIP, AIF_AVOID_BIG_SHIP
530  int avoid_ship_num; // object index of small ship to avoid
531  vec3d avoid_goal_point; // point to aim at when avoiding a ship
532  fix avoid_check_timestamp; // timestamp at which to next check for having to avoid ship
533 
534  vec3d big_collision_normal; // Global normal of collision with big ship. Helps find direction to fly away from big ship. Set for each collision.
535  vec3d big_recover_pos_1; // Global point to fly towards when recovering from collision with a big ship, stage 1.
536  vec3d big_recover_pos_2; // Global point to fly towards when recovering from collision with a big ship, stage 2.
537  int big_recover_timestamp; // timestamp at which it's OK to re-enter stage 1.
538 
539  int abort_rearm_timestamp; // time at which this rearm should be aborted in a multiplayer game.
540 
541  // artillery targeting info
542  int artillery_objnum; // object currently being targeted for artillery lock/attack
543  int artillery_sig; // artillery object signature
544  float artillery_lock_time; // how long we've been locked onto this guy
545  vec3d artillery_lock_pos; // base position of the lock point on (in model's frame of reference)
546  float lethality; // measure of how dangerous ship is to enemy BIG|HUGE ships (likelyhood of targeting)
547 
548  int ai_override_flags; // flags for marking ai overrides from sexp or lua systems
549  control_info ai_override_ci; // ai override control info
550  int ai_override_timestamp; // mark for when to end the current override
551 } ai_info;
552 
553 // Goober5000
554 typedef struct {
558  int submodel;
560  float submodel_r;
561  float submodel_w;
563 
564 #define MAX_AI_INFO MAX_SHIPS
565 
566 // SUBSYS_PATH_DIST is used as the distance that a subsystem path should terminate from the actual
567 // subsystem. We don't want to rely on the model path points for this, since we may need to be
568 // changed.
569 #define SUBSYS_PATH_DIST 500.0f
570 
571 // Friendly damage defines
572 #define MAX_BURST_DAMAGE 20 // max damage that can be done in BURST_DURATION
573 #define BURST_DURATION 500 // decay time over which Player->damage_this_burst falls from MAX_BURST_DAMAGE to 0
574 
575 extern int Mission_all_attack; // !0 means all teams attack all teams.
576 extern int Total_goal_target_names;
578 
579 extern void update_ai_info_for_hit(int hitter_obj, int hit_obj);
580 extern void ai_frame_all(void);
581 
582 extern int find_guard_obj(void);
583 
584 extern ai_info Ai_info[];
585 extern ai_info *Player_ai;
586 
587 extern ai_class *Ai_classes;
588 extern char** Ai_class_names;
589 
590 extern int Num_ai_classes;
591 extern int Ai_firing_enabled;
592 
593 extern const char *Skill_level_names(int skill_level, int translate = 1);
594 extern int Ai_goal_signature;
595 
596 // need access to following data in AiBig.cpp
597 extern object *Pl_objp;
598 extern object *En_objp;
599 extern float AI_frametime;
600 
601 
602 // Return index of free AI slot.
603 // Return 0 if no free slot.
604 int ai_get_slot(int shipnum);
605 
606 // Releases an AI slot to be used by someone else.
607 void ai_free_slot(int ai_index);
608 
609 // call to init one ai object.. you can pass all sorts of
610 // stuff by adding new paramters.
611 void ai_object_init(object * obj, int ai_index);
612 
613 // Called once a frame
614 void ai_process( object * obj, int ai_index, float frametime );
615 
616 int get_wingnum(int objnum);
617 
618 void set_wingnum(int objnum, int wingnum);
619 char *ai_get_goal_target_name(const char *name, int *index);
620 
621 extern void init_ai_system(void);
622 extern void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp);
623 extern void ai_evade_object(object *evader, object *evaded);
624 extern void ai_ignore_object(object *ignorer, object *ignored, int ignore_new);
625 extern void ai_ignore_wing(object *ignorer, int wingnum);
626 extern void ai_dock_with_object(object *docker, int docker_index, object *dockee, int dockee_index, int dock_type);
627 extern void ai_stay_still(object *still_objp, vec3d *view_pos);
628 extern void ai_do_default_behavior(object *obj);
629 extern void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags);
630 extern void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal);
631 extern void ai_ship_destroy(int shipnum, int method);
632 extern 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);
633 extern void init_ai_object(int objnum);
634 extern void ai_init(void); // Call this one to parse ai.tbl.
635 extern void ai_level_init(void); // Call before each level to reset AI
636 
637 extern int ai_set_attack_subsystem(object *objp, int subnum);
638 extern int ai_issue_rearm_request(object *requester_objp); // Object requests rearm/repair.
639 extern int ai_abort_rearm_request(object *requester_objp); // Object aborts rearm/repair.
640 extern void ai_do_repair_frame(object *objp, ai_info *aip, float frametime); // Repair a ship object, player or AI.
641 extern void ai_update_danger_weapon(int objnum, int weapon_objnum);
642 
643 // called externally from MissionParse.cpp to position ships in wings upon arrival into the
644 // mission.
645 extern void get_absolute_wing_pos( vec3d *result_pos, object *leader_objp, int wing_index, int formation_object_flag);
646 extern void get_absolute_wing_pos_autopilot( vec3d *result_pos, object *leader_objp, int wing_index, int formation_object_flag);
647 
648 // Interface from goals code to AI. Set ship to guard. *objp guards *other_objp
649 extern void ai_set_guard_object(object *objp, object *other_objp);
650 extern void ai_set_evade_object(object *objp, object *other_objp);
651 extern void ai_set_guard_wing(object *objp, int wingnum);
652 extern void ai_warp_out(object *objp, vec3d *vp);
653 extern void ai_attack_wing(object *attacker, int wingnum);
654 extern void ai_deathroll_start(object *ship_obj);
655 extern void ai_fly_in_formation(int wing_num); // Force wing to fly in formation.
656 extern void ai_disband_formation(int wing_num); // Force wing to disband formation flying.
657 extern int set_target_objnum(ai_info *aip, int objnum);
658 extern void ai_form_on_wing(object *objp, object *goal_objp);
659 extern void ai_do_stay_near(object *objp, object *other_obj, float dist);
660 extern ship_subsys *set_targeted_subsys(ai_info *aip, ship_subsys *new_subsys, int parent_objnum);
661 extern void ai_rearm_repair( object *objp, int docker_index, object *goal_objp, int dockee_index );
662 extern void ai_add_rearm_goal( object *requester_objp, object *support_objp );
663 extern void create_model_path(object *pl_objp, object *mobjp, int path_num, int subsys_path=0);
664 extern int ai_find_goal_index( ai_goal* aigp, int mode, int submode = -1, int priority = -1 );
665 
666 // Goober5000
667 extern void ai_do_safety(object *objp);
668 
669 // used to get path info for fighter bay emerging and departing
670 int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int path_mask, vec3d *pos, vec3d *fvec);
671 int ai_acquire_depart_path(object *pl_objp, int parent_objnum, int path_mask);
672 
673 // used by AiBig.cpp
674 extern void ai_set_positions(object *pl_objp, object *en_objp, ai_info *aip, vec3d *player_pos, vec3d *enemy_pos);
675 extern void accelerate_ship(ai_info *aip, float accel);
676 extern void turn_away_from_point(object *objp, vec3d *point, float bank_override);
677 extern float ai_endangered_by_weapon(ai_info *aip);
678 extern void update_aspect_lock_information(ai_info *aip, vec3d *vec_to_enemy, float dist_to_enemy, float enemy_radius);
679 extern void ai_chase_ct();
680 extern void ai_find_path(object *pl_objp, int objnum, int path_num, int exit_flag, int subsys_path=0);
681 extern float ai_path();
682 extern void evade_weapon();
683 extern int might_collide_with_ship(object *obj1, object *obj2, float dot_to_enemy, float dist_to_enemy, float duration);
684 extern int ai_fire_primary_weapon(object *objp); //changed to return weather it fired-Bobboau
685 extern int ai_fire_secondary_weapon(object *objp, int priority1 = -1, int priority2 = -1);
686 extern float ai_get_weapon_dist(ship_weapon *swp);
687 extern void turn_towards_point(object *objp, vec3d *point, vec3d *slide_vec, float bank_override);
688 extern int ai_maybe_fire_afterburner(object *objp, ai_info *aip);
689 extern void set_predicted_enemy_pos(vec3d *predicted_enemy_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, ai_info *aip);
690 
691 extern int is_instructor(object *objp);
692 extern int find_enemy(int objnum, float range, int max_attackers);
693 
694 float ai_get_weapon_speed(ship_weapon *swp);
695 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);
696 
697 // function to change rearm status for ai ships (called from sexpression code)
698 extern void ai_set_rearm_status( int team, int new_status );
699 extern void ai_good_secondary_time( int team, int weapon_index, int num_weapons, char *shipname );
700 
701 extern void ai_do_objects_docked_stuff(object *docker, int docker_point, object *dockee, int dockee_point, bool update_clients = true);
702 extern void ai_do_objects_undocked_stuff( object *docker, object *dockee );
703 extern void ai_do_objects_repairing_stuff( object *repaired_obj, object *repair_obj, int how );
704 
705 // Goober5000
706 // Move to a position relative to a dock bay using thrusters.
707 extern 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);
708 
709 extern int find_danger_weapon(object *sobjp, float dtime, float *atime, float dot_threshhold);
710 
711 void ai_set_mode_warp_out(object *objp, ai_info *aip);
712 
713 // prototyped by Goober5000
714 int get_nearest_objnum(int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers);
715 
716 // moved to header file by Goober5000
717 void ai_announce_ship_dying(object *dying_objp);
718 
719 // added by kazan
720 void ai_start_fly_to_ship(object *objp, int shipnum);
721 void ai_fly_to_ship();
722 
723 //Moved declaration here for player ship -WMC
724 void process_subobjects(int objnum);
725 
726 //SUSHI: Setting ai_info stuff from both ai class and ai profile
728 
729 void ai_update_aim(ai_info *aip);
730 
731 //SUSHI: Random evasive sidethrust
732 void do_random_sidethrust(ai_info *aip, ship_info *sip);
733 
734 #endif
void ai_fly_in_formation(int wing_num)
Definition: aicode.cpp:11532
float ai_stalemate_time_thresh[NUM_SKILL_LEVELS]
Definition: ai.h:225
int ai_profile_flags2_set
Definition: ai.h:233
vec3d dockee_point
Definition: ai.h:556
float ai_glide_strafe_percent
Definition: ai.h:456
float lethality
Definition: ai.h:546
fix last_attack_time
Definition: ai.h:419
size_t wp_index
Definition: ai.h:373
vec3d big_recover_pos_2
Definition: ai.h:536
fix submode_start_time
Definition: ai.h:400
void ai_update_danger_weapon(int objnum, int weapon_objnum)
Definition: aicode.cpp:1056
ai_info * Player_ai
Definition: ai.cpp:24
float prev_accel
Definition: ai.h:426
int ai_profile_flags_set
Definition: ai.h:231
void ai_set_evade_object(object *objp, object *other_objp)
Definition: aicode.cpp:7505
float last_speed
Definition: ai.h:495
float ai_accuracy[NUM_SKILL_LEVELS]
Definition: ai.h:200
fix avoid_check_timestamp
Definition: ai.h:532
float ai_ship_fire_secondary_delay_scale_friendly
Definition: ai.h:451
union ai_goal::@1 dockee
#define vp(p)
Definition: modelsinc.h:70
int ai_abort_rearm_request(object *requester_objp)
Definition: aicode.cpp:15338
int is_instructor(object *objp)
Definition: aicode.cpp:4895
#define MAX_IGNORE_NEW_OBJECTS
Definition: ai.h:327
int type
Definition: ai.h:332
control_info ai_override_ci
Definition: ai.h:549
int ai_maybe_fire_afterburner(object *objp, ai_info *aip)
Definition: aicode.cpp:4825
float previous_dot_to_enemy
Definition: ai.h:349
void ai_do_stay_near(object *objp, object *other_obj, float dist)
Definition: aicode.cpp:3254
void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp)
Definition: aicode.cpp:2257
int secondary_select_timestamp
Definition: ai.h:509
float ai_glide_strafe_percent[NUM_SKILL_LEVELS]
Definition: ai.h:223
float nearest_locked_distance
Definition: ai.h:487
int shockwave_object
Definition: ai.h:517
int ai_find_goal_index(ai_goal *aigp, int mode, int submode=-1, int priority=-1)
Definition: aigoals.cpp:1017
bool ai_class_autoscale
Definition: ai.h:240
float time_enemy_near
Definition: ai.h:418
char * name
Definition: ai.h:153
int ai_fire_primary_weapon(object *objp)
Definition: aicode.cpp:5626
char ** Ai_class_names
Definition: aicode.cpp:268
GLuint index
Definition: Glext.h:5608
void ai_form_on_wing(object *objp, object *goal_objp)
Definition: aicode.cpp:3290
fix last_hit_target_time
Definition: ai.h:422
int active_goal
Definition: ai.h:413
vec3d avoid_goal_point
Definition: ai.h:531
int target_signature
Definition: ai.h:147
int path_subsystem_next_check
Definition: ai.h:391
int ai_get_slot(int shipnum)
Returns index of free AI slot.
Definition: ai.cpp:30
float ai_get_away_chance[NUM_SKILL_LEVELS]
Definition: ai.h:238
int previous_submode
Definition: ai.h:395
int get_wingnum(int objnum)
Definition: ai.cpp:57
float best_dot_to_enemy
Definition: ai.h:396
int ai_profile_flags2
Definition: ai.h:232
int ai_chance_to_use_missiles_on_plr[NUM_SKILL_LEVELS]
Definition: ai.h:227
int path_start
Definition: ai.h:378
void ai_ignore_object(object *ignorer, object *ignored, int ignore_new)
Definition: aicode.cpp:2440
float ai_glide_attack_percent[NUM_SKILL_LEVELS]
Definition: ai.h:221
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: aicode.cpp:6344
int path_flags
Definition: ai.h:382
waypoint_list * wp_list
Definition: ai.h:372
int target_objnum
Definition: ai.h:339
vec3d artillery_lock_pos
Definition: ai.h:545
int submode
Definition: ai.h:394
vec3d prev_goal_point
Definition: ai.h:429
object * Pl_objp
Definition: aicode.cpp:169
int ai_submode
Definition: ai.h:137
int path_goal_dist
Definition: ai.h:390
Definition: pstypes.h:88
int force_warp_time
Definition: ai.h:515
fix afterburner_stop_time
Definition: ai.h:503
#define NUM_SKILL_LEVELS
Definition: systemvars.h:150
int ai_class
Definition: ai.h:369
pnode * Ppfp
Definition: aicode.cpp:264
float artillery_lock_time
Definition: ai.h:544
float target_time
Definition: ai.h:350
void ai_announce_ship_dying(object *dying_objp)
Definition: aicode.cpp:13506
int path_cur
Definition: ai.h:379
int ai_profile_flags2
Definition: ai.h:464
int next_rearm_request_timestamp
Definition: ai.h:507
CButton * team
#define MAX_PATH_POINTS
Definition: ai.h:322
int target_name_index
Definition: ai.h:144
int might_collide_with_ship(object *obj1, object *obj2, float dot_to_enemy, float dist_to_enemy, float duration)
Definition: aicode.cpp:6108
fix best_dot_to_time
Definition: ai.h:398
void ai_do_repair_frame(object *objp, ai_info *aip, float frametime)
Definition: aicode.cpp:11996
float lead_scale
Definition: ai.h:468
float ai_link_energy_levels_always
Definition: ai.h:446
int big_recover_timestamp
Definition: ai.h:537
fix path_next_check_time
Definition: ai.h:389
void init_ai_object(int objnum)
Definition: aicode.cpp:14300
int find_guard_obj(void)
void ai_stay_still(object *still_objp, vec3d *view_pos)
Definition: aicode.cpp:2982
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: aicode.cpp:9070
vec3d guard_vec
Definition: ai.h:485
int target_signature
Definition: ai.h:340
void accelerate_ship(ai_info *aip, float accel)
Definition: aicode.cpp:1370
ship_subsys * targeted_subsys
Definition: ai.h:472
GLenum mode
Definition: Glext.h:5794
float ai_turret_max_aim_update_delay
Definition: ai.h:462
Definition: ai.h:329
float ai_stalemate_time_thresh
Definition: ai.h:458
void ai_good_secondary_time(int team, int weapon_index, int num_weapons, char *shipname)
Definition: aicode.cpp:326
char dockee_point[NAME_LENGTH]
int mp_index
Definition: ai.h:388
object * objp
Definition: lua.cpp:3105
float ai_endangered_by_weapon(ai_info *aip)
Definition: aicode.cpp:6584
void ai_object_init(object *obj, int ai_index)
Definition: aicode.cpp:1330
float current_target_distance
Definition: ai.h:489
int support_ship_objnum
Definition: ai.h:479
float ai_max_aim_update_delay
Definition: ai.h:461
float ai_path()
Definition: aicode.cpp:4087
fix resume_goal_time
Definition: ai.h:425
vec3d view_pos
Definition: fredrender.cpp:103
void ai_rearm_repair(object *objp, int docker_index, object *goal_objp, int dockee_index)
Definition: aicode.cpp:15493
int ai_flags
Definition: ai.h:330
float ai_glide_attack_percent
Definition: ai.h:454
vec3d last_predicted_enemy_pos
Definition: ai.h:416
vec3d submodel_pos
Definition: ai.h:559
pnode Path_points[MAX_PATH_POINTS]
Definition: aicode.cpp:263
float ai_turn_time_scale
Definition: ai.h:453
float ai_random_sidethrust_percent
Definition: ai.h:457
float ai_cmeasure_fire_chance[NUM_SKILL_LEVELS]
Definition: ai.h:207
void update_ai_info_for_hit(int hitter_obj, int hit_obj)
void ai_init(void)
Definition: aicode.cpp:828
void ai_do_objects_docked_stuff(object *docker, int docker_point, object *dockee, int dockee_point, bool update_clients=true)
Definition: aicode.cpp:3008
fix ai_predict_position_delay
Definition: ai.h:447
int goal_check_time
Definition: ai.h:414
void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags)
Definition: aicode.cpp:3215
int path_length
Definition: ai.h:380
int rearm_first_missile
Definition: ai.h:499
int ai_profile_flags
Definition: ai.h:463
float ai_random_sidethrust_percent[NUM_SKILL_LEVELS]
Definition: ai.h:224
int abort_rearm_timestamp
Definition: ai.h:539
void evade_weapon()
Definition: aicode.cpp:4904
vec3d pos
Definition: ai.h:317
vec3d path_create_pos
Definition: ai.h:386
fix next_predict_pos_time
Definition: ai.h:403
int current_target_speed_trend
Definition: ai.h:492
vec3d big_attack_point
Definition: ai.h:524
int stealth_last_cheat_visible_stamp
Definition: ai.h:343
int waypoint_speed_cap
Definition: ai.h:375
float ai_turret_max_aim_update_delay[NUM_SKILL_LEVELS]
Definition: ai.h:229
int ok_to_target_timestamp
Definition: ai.h:521
GLenum GLint * range
Definition: Glext.h:7096
int path_objnum
Definition: ai.h:383
struct ai_info ai_info
float ai_circle_strafe_percent
Definition: ai.h:455
float stealth_sweep_box_size
Definition: ai.h:345
void turn_towards_point(object *objp, vec3d *point, vec3d *slide_vec, float bank_override)
Definition: aicode.cpp:1491
int danger_weapon_objnum
Definition: ai.h:482
ai_class * Ai_classes
Definition: aicode.cpp:193
int type
Definition: ai.h:138
int attacker_objnum
Definition: ai.h:353
float ai_get_weapon_speed(ship_weapon *swp)
Definition: aicode.cpp:6304
char dockee[NAME_LENGTH]
float ai_get_away_chance
Definition: ai.h:435
int submode_parm1
Definition: ai.h:402
void ai_attack_wing(object *attacker, int wingnum)
Definition: aicode.cpp:2326
void ai_fly_to_ship()
Definition: aicode.cpp:4607
int find_enemy(int objnum, float range, int max_attackers)
Definition: aicode.cpp:2186
int self_destruct_timestamp
Definition: ai.h:520
void ai_dock_with_object(object *docker, int docker_index, object *dockee, int dockee_index, int dock_type)
Definition: aicode.cpp:3098
float ai_accuracy
Definition: ai.h:432
int mode_time
Definition: ai.h:338
void update_aspect_lock_information(ai_info *aip, vec3d *vec_to_enemy, float dist_to_enemy, float enemy_radius)
Definition: aicode.cpp:7576
ai_goal goals[MAX_AI_GOALS]
Definition: ai.h:412
int mode
Definition: ai.h:336
float time_enemy_in_range
Definition: ai.h:417
int shipnum
Definition: ai.h:331
fix time
Definition: ai.h:140
int stealth_last_visible_stamp
Definition: ai.h:344
float ai_get_weapon_dist(ship_weapon *swp)
Definition: aicode.cpp:6288
ship_subsys * last_subsys_target
Definition: ai.h:473
void ai_free_slot(int ai_index)
Frees a currently used AI slot.
Definition: ai.cpp:50
float ai_in_range_time
Definition: ai.h:441
fix best_dot_from_time
Definition: ai.h:399
void ai_find_path(object *pl_objp, int objnum, int path_num, int exit_flag, int subsys_path=0)
Definition: aicode.cpp:2875
float ai_link_ammo_levels_maybe
Definition: ai.h:442
vec3d big_collision_normal
Definition: ai.h:534
int last_target
Definition: ai.h:497
float ai_ship_fire_secondary_delay_scale_hostile
Definition: ai.h:452
float ai_ship_fire_delay_scale_friendly
Definition: ai.h:449
int ai_mode
Definition: ai.h:136
ai_flag_name Ai_flag_names[]
Definition: aicode.cpp:203
fix next_aim_pos_time
Definition: ai.h:408
float prev_dot_to_goal
Definition: ai.h:427
#define MAX_AI_GOALS
Definition: ai.h:91
fix path_next_create_time
Definition: ai.h:385
int flag
Definition: ai.h:30
int danger_weapon_signature
Definition: ai.h:483
float ai_ship_fire_delay_scale_friendly[NUM_SKILL_LEVELS]
Definition: ai.h:216
void ai_do_default_behavior(object *obj)
Definition: aicode.cpp:14564
int target_instance
Definition: ai.h:146
int priority
Definition: ai.h:141
void ai_do_objects_repairing_stuff(object *repaired_obj, object *repair_obj, int how)
Definition: aicode.cpp:10186
void create_model_path(object *pl_objp, object *mobjp, int path_num, int subsys_path=0)
Definition: aicode.cpp:2706
float ai_link_energy_levels_always[NUM_SKILL_LEVELS]
Definition: ai.h:213
void ai_ship_destroy(int shipnum, int method)
Definition: aicode.cpp:15234
fix last_hit_time
Definition: ai.h:420
int Num_ai_classes
Definition: aicode.cpp:195
char * target_name
Definition: ai.h:143
float ai_stalemate_dist_thresh
Definition: ai.h:459
int shield_manage_timestamp
Definition: ai.h:519
float ai_ship_fire_delay_scale_hostile[NUM_SKILL_LEVELS]
Definition: ai.h:217
float ai_link_ammo_levels_always
Definition: ai.h:443
void ai_set_rearm_status(int team, int new_status)
Definition: aicode.cpp:300
float ai_evasion[NUM_SKILL_LEVELS]
Definition: ai.h:201
float ai_turn_time_scale[NUM_SKILL_LEVELS]
Definition: ai.h:220
vec3d big_attack_surface_normal
Definition: ai.h:525
int ai_acquire_depart_path(object *pl_objp, int parent_objnum, int path_mask)
Definition: aicode.cpp:12883
float ai_max_aim_update_delay[NUM_SKILL_LEVELS]
Definition: ai.h:228
float ai_circle_strafe_percent[NUM_SKILL_LEVELS]
Definition: ai.h:222
int targeted_subsys_parent
Definition: ai.h:474
void do_random_sidethrust(ai_info *aip, ship_info *sip)
Definition: aicode.cpp:6609
int ai_chance_to_use_missiles_on_plr
Definition: ai.h:460
int submode_parm0
Definition: ai.h:401
float ai_primary_ammo_burst_mult[NUM_SKILL_LEVELS]
Definition: ai.h:211
int ignore_new_objnums[MAX_IGNORE_NEW_OBJECTS]
Definition: ai.h:366
int last_secondary_index
Definition: ai.h:496
float ai_link_ammo_levels_maybe[NUM_SKILL_LEVELS]
Definition: ai.h:209
void ai_chase_ct()
Definition: aicode.cpp:6505
int wp_flags
Definition: ai.h:374
long fix
Definition: pstypes.h:54
Definition: object.h:141
void ai_level_init(void)
Definition: aicode.cpp:853
struct pnode pnode
int previous_mode
Definition: ai.h:337
void ai_set_mode_warp_out(object *objp, ai_info *aip)
Definition: aicode.cpp:13301
void ai_update_aim(ai_info *aip)
Definition: aicode.cpp:3490
int ai_override_flags
Definition: ai.h:548
int primary_select_timestamp
Definition: ai.h:508
int path_dir
Definition: ai.h:381
float last_dist
Definition: ai.h:494
int artillery_sig
Definition: ai.h:543
float ai_evasion
Definition: ai.h:432
void ai_start_fly_to_ship(object *objp, int shipnum)
Definition: aicode.cpp:3186
int Ai_goal_signature
Definition: aigoals.cpp:58
int ai_override_timestamp
Definition: ai.h:550
int rearm_first_ballistic_primary
Definition: ai.h:500
int ai_aburn_use_factor
Definition: ai.h:433
GLbitfield flags
Definition: Glext.h:6722
float ai_patience[NUM_SKILL_LEVELS]
Definition: ai.h:203
int guard_wingnum
Definition: ai.h:360
GLuint const GLchar * name
Definition: Glext.h:5608
float ai_cmeasure_fire_chance
Definition: ai.h:440
float ai_link_ammo_levels_always[NUM_SKILL_LEVELS]
Definition: ai.h:210
bool ai_class_autoscale
Definition: ai.h:437
void process_subobjects(int objnum)
Definition: aicode.cpp:11120
int ignore_expire_timestamp
Definition: ai.h:505
vec3d stealth_velocity
Definition: ai.h:347
#define TOKEN_LENGTH
Definition: globals.h:41
float ai_in_range_time[NUM_SKILL_LEVELS]
Definition: ai.h:208
vec3d last_aim_enemy_vel
Definition: ai.h:410
int last_objsig_hit
Definition: ai.h:504
int pick_big_attack_point_timestamp
Definition: ai.h:526
int scan_for_enemy_timestamp
Definition: ai.h:511
int path_index
Definition: ai.h:319
int hitter_signature
Definition: ai.h:424
int path_num
Definition: ai.h:318
float best_dot_from_enemy
Definition: ai.h:397
int avoid_ship_num
Definition: ai.h:530
int ai_issue_rearm_request(object *requester_objp)
Definition: aicode.cpp:15446
float ai_shockwave_evade_chance[NUM_SKILL_LEVELS]
Definition: ai.h:237
int Mission_all_attack
Definition: aicode.cpp:200
int warp_out_timestamp
Definition: ai.h:506
int goal_signature
Definition: ai.h:356
vec3d stealth_last_pos
Definition: ai.h:346
#define NAME_LENGTH
Definition: globals.h:15
int artillery_objnum
Definition: ai.h:542
int find_danger_weapon(object *sobjp, float dtime, float *atime, float dot_threshhold)
int set_target_objnum(ai_info *aip, int objnum)
Definition: aicode.cpp:1250
float ai_ship_fire_delay_scale_hostile
Definition: ai.h:450
float ai_secondary_range_mult[NUM_SKILL_LEVELS]
Definition: ai.h:239
int flag_list
Definition: ai.h:32
struct ai_flag_name ai_flag_name
char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH]
Definition: ai.cpp:22
float ai_courage[NUM_SKILL_LEVELS]
Definition: ai.h:202
int behavior
Definition: ai.h:335
int enemy_wing
Definition: ai.h:352
float AI_frametime
Definition: aicode.cpp:266
void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal)
Definition: aicode.cpp:14934
void set_wingnum(int objnum, int wingnum)
Definition: ai.cpp:68
void ai_add_rearm_goal(object *requester_objp, object *support_objp)
Definition: aicode.cpp:15421
int Total_goal_target_names
Definition: ai.cpp:21
void ai_deathroll_start(object *ship_obj)
Definition: aicode.cpp:15299
int guard_signature
Definition: ai.h:359
int choose_enemy_timestamp
Definition: ai.h:513
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: aicode.cpp:1131
Definition: ai.h:198
int ai_profile_flags
Definition: ai.h:230
void init_ai_system(void)
Definition: aicode.cpp:14458
void ai_do_objects_undocked_stuff(object *docker, object *dockee)
Definition: aicode.cpp:3054
const char * Skill_level_names(int skill_level, int translate=1)
Definition: aicode.cpp:208
int nearest_locked_object
Definition: ai.h:486
float ai_ship_fire_secondary_delay_scale_hostile[NUM_SKILL_LEVELS]
Definition: ai.h:219
int path_goal_obj_hash
Definition: ai.h:384
union ai_goal::@0 docker
char docker[NAME_LENGTH]
hull_check pos
Definition: lua.cpp:5050
GLsizei GLsizei GLuint * obj
Definition: Glext.h:5619
float ai_shield_manage_delay
Definition: ai.h:448
void ai_process(object *obj, int ai_index, float frametime)
Definition: aicode.cpp:14232
int wing
Definition: ai.h:333
float stay_near_distance
Definition: ai.h:469
int ignore_new_signatures[MAX_IGNORE_NEW_OBJECTS]
Definition: ai.h:367
float ai_shield_manage_delay[NUM_SKILL_LEVELS]
Definition: ai.h:215
int guard_objnum
Definition: ai.h:358
waypoint_list * wp_list
Definition: ai.h:145
char flag_name[TOKEN_LENGTH]
Definition: ai.h:31
int support_ship_signature
Definition: ai.h:480
void ai_set_guard_wing(object *objp, int wingnum)
Definition: aicode.cpp:7450
float ai_ship_fire_secondary_delay_scale_friendly[NUM_SKILL_LEVELS]
Definition: ai.h:218
Definition: ai.h:134
float ai_stalemate_dist_thresh[NUM_SKILL_LEVELS]
Definition: ai.h:226
int kamikaze_damage
Definition: ai.h:523
int goal_objnum
Definition: ai.h:355
int Ai_firing_enabled
Definition: aicode.cpp:194
vec3d big_recover_pos_1
Definition: ai.h:535
int current_target_dist_trend
Definition: ai.h:491
float ai_shockwave_evade_chance
Definition: ai.h:434
int ai_aburn_use_factor[NUM_SKILL_LEVELS]
Definition: ai.h:236
int ignore_objnum
Definition: ai.h:362
float ai_secondary_range_mult
Definition: ai.h:436
int get_nearest_objnum(int objnum, int enemy_team_mask, int enemy_wing, float range, int max_attackers)
Definition: aicode.cpp:2029
void set_predicted_enemy_pos(vec3d *predicted_enemy_pos, object *pobjp, vec3d *enemy_pos, vec3d *enemy_vel, ai_info *aip)
Definition: aicode.cpp:6397
struct ai_class ai_class
vec3d last_aim_enemy_pos
Definition: ai.h:409
void turn_away_from_point(object *objp, vec3d *point, float bank_override)
Definition: aicode.cpp:1513
void ai_evade_object(object *evader, object *evaded)
Definition: aicode.cpp:2362
int ai_set_attack_subsystem(object *objp, int subnum)
Definition: aicode.cpp:7359
void ai_warp_out(object *objp, vec3d *vp)
fix ai_predict_position_delay[NUM_SKILL_LEVELS]
Definition: ai.h:214
int ignore_signature
Definition: ai.h:363
int rearm_release_delay
Definition: ai.h:501
int hitter_objnum
Definition: ai.h:423
char * ai_get_goal_target_name(const char *name, int *index)
Definition: ai.cpp:85
float ai_patience
Definition: ai.h:432
void ai_do_safety(object *objp)
Definition: aicode.cpp:3273
void init_aip_from_class_and_profile(ai_info *aip, ai_class *aicp, ai_profile_t *profile)
Definition: aicode.cpp:14490
int index
Definition: ai.h:154
void ai_set_positions(object *pl_objp, object *en_objp, ai_info *aip, vec3d *player_pos, vec3d *enemy_pos)
Definition: aicode.cpp:3469
float ai_link_energy_levels_maybe[NUM_SKILL_LEVELS]
Definition: ai.h:212
void get_absolute_wing_pos(vec3d *result_pos, object *leader_objp, int wing_index, int formation_object_flag)
Definition: aicode.cpp:11409
vec3d path_depart_orient
Definition: ai.h:392
void ai_set_guard_object(object *objp, object *other_objp)
Definition: aicode.cpp:7532
int flags
Definition: ai.h:139
struct ai_goal ai_goal
float ai_primary_ammo_burst_mult
Definition: ai.h:444
ship_subsys * set_targeted_subsys(ai_info *aip, ship_subsys *new_subsys, int parent_objnum)
Definition: aicode.cpp:1289
vec3d goal_point
Definition: ai.h:428
object * En_objp
Definition: aicode.cpp:170
vec3d docker_point
Definition: ai.h:555
float ai_courage
Definition: ai.h:432
char docker_point[NAME_LENGTH]
int signature
Definition: ai.h:135
int ai_fire_secondary_weapon(object *objp, int priority1=-1, int priority2=-1)
Definition: aicode.cpp:6050
float ai_link_energy_levels_maybe
Definition: ai.h:445
int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int path_mask, vec3d *pos, vec3d *fvec)
Definition: aicode.cpp:12632
matrix path_create_orient
Definition: ai.h:387
int current_target_is_locked
Definition: ai.h:490
float aspect_locked_time
Definition: ai.h:476
void get_absolute_wing_pos_autopilot(vec3d *result_pos, object *leader_objp, int wing_index, int formation_object_flag)
Definition: aicode.cpp:11432
void ai_disband_formation(int wing_num)
Definition: aicode.cpp:11556
int previous_target_objnum
Definition: ai.h:341
void ai_frame_all(void)
ai_info Ai_info[]
Definition: ai.cpp:23
Definition: ai.h:316
#define MAX_GOAL_TARGET_NAMES
Definition: ai.h:164
int last_hit_quadrant
Definition: ai.h:421
void ai_ignore_wing(object *ignorer, int wingnum)
Definition: aicode.cpp:2485