FS2_Open
Open source remastering of the Freespace 2 engine
|
#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 |
Typedefs | |
typedef struct eval_nearest_objnum | eval_nearest_objnum |
typedef struct ai_render_stuff | ai_render_stuff |
Variables | |
char * | Mode_text [MAX_AI_BEHAVIORS] |
char * | Submode_text [] |
char * | Strafe_submode_text [5] |
control_info | AI_ci |
object * | Pl_objp |
object * | En_objp |
ai_class * | Ai_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] |
pnode * | Ppfp |
float | AI_frametime |
char ** | Ai_class_names = NULL |
SCP_vector< huge_fire_info > | Ai_huge_fire_info |
int | Ai_last_arrive_path |
object * | Autopilot_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 |
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.
#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_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)) |
Definition at line 11292 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 struct ai_render_stuff ai_render_stuff |
typedef struct eval_nearest_objnum eval_nearest_objnum |
Definition at line 13568 of file aicode.cpp.
Definition at line 1370 of file aicode.cpp.
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.
pos | Position in vector space |
path_num | Path numbers |
path_index | Index into path |
modify_index | Index in Path_points at which to store path point. |
Definition at line 2512 of file aicode.cpp.
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.
Definition at line 15338 of file aicode.cpp.
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.
Definition at line 15421 of file aicode.cpp.
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.
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.
Definition at line 13711 of file aicode.cpp.
Definition at line 13765 of file aicode.cpp.
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.
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.
Definition at line 7285 of file aicode.cpp.
Definition at line 7643 of file aicode.cpp.
Trying to get away from opponent.
Definition at line 7319 of file aicode.cpp.
Definition at line 7700 of file aicode.cpp.
Definition at line 10481 of file aicode.cpp.
Definition at line 10417 of file aicode.cpp.
Definition at line 10491 of file aicode.cpp.
Definition at line 14181 of file aicode.cpp.
void ai_cruiser_chase | ( | ) |
Definition at line 7987 of file aicode.cpp.
Definition at line 7940 of file aicode.cpp.
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.
Definition at line 11556 of file aicode.cpp.
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.
Definition at line 10186 of file aicode.cpp.
Definition at line 3054 of file aicode.cpp.
If object *objp is being repaired, deal with it!
Definition at line 11996 of file aicode.cpp.
Definition at line 3273 of file aicode.cpp.
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.
Clean up path data used for emerging from a fighter bay
Definition at line 12737 of file aicode.cpp.
Definition at line 6584 of file aicode.cpp.
Definition at line 6565 of file aicode.cpp.
void ai_evade | ( | ) |
Definition at line 5205 of file aicode.cpp.
Set *evaded as object for *evader to evade.
Definition at line 2362 of file aicode.cpp.
Execute behavior given by aip->mode.
Definition at line 13029 of file aicode.cpp.
Definition at line 12824 of file aicode.cpp.
Definition at line 2875 of file aicode.cpp.
Definition at line 13532 of file aicode.cpp.
Definition at line 13466 of file aicode.cpp.
Definition at line 5626 of file aicode.cpp.
Definition at line 6050 of file aicode.cpp.
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.
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.
Given an object and an object on whose wing to form, return slot to use.
Definition at line 3332 of file aicode.cpp.
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.
Entry point from sexpression code to set internal data for use by AI code.
Definition at line 326 of file aicode.cpp.
"safe" is currently defined by the mission designer using the good/bad time to rearm sexpressions. This status is currently team based.
Definition at line 313 of file aicode.cpp.
void ai_guard | ( | ) |
Definition at line 9983 of file aicode.cpp.
Definition at line 9704 of file aicode.cpp.
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.
Scan enemy ships and see if one is near enough to guard object to be pursued.
Definition at line 9663 of file aicode.cpp.
Ignore some object without changing mode.
Definition at line 2440 of file aicode.cpp.
Ignore some object without changing mode.
Definition at line 2485 of file aicode.cpp.
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.
Definition at line 966 of file aicode.cpp.
Definition at line 15446 of file aicode.cpp.
This inits the AI. You should be able to call this between levels to reset everything.
Definition at line 853 of file aicode.cpp.
Definition at line 12581 of file aicode.cpp.
Definition at line 12312 of file aicode.cpp.
Definition at line 3562 of file aicode.cpp.
Definition at line 5939 of file aicode.cpp.
Definition at line 13313 of file aicode.cpp.
Definition at line 12350 of file aicode.cpp.
Maybe fire afterburner based on AI class
Definition at line 4825 of file aicode.cpp.
Definition at line 12086 of file aicode.cpp.
Definition at line 9449 of file aicode.cpp.
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.
Definition at line 6604 of file aicode.cpp.
Determine if pl_objp needs a new target, called from ai_frame()
Definition at line 13850 of file aicode.cpp.
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.
Definition at line 12159 of file aicode.cpp.
Definition at line 14232 of file aicode.cpp.
Make objp rearm and repair goal_objp
Definition at line 15493 of file aicode.cpp.
Definition at line 15516 of file aicode.cpp.
void ai_safety | ( | ) |
Definition at line 4210 of file aicode.cpp.
Definition at line 4195 of file aicode.cpp.
Definition at line 4172 of file aicode.cpp.
Definition at line 4147 of file aicode.cpp.
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.
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.
Definition at line 7359 of file aicode.cpp.
Definition at line 7505 of file aicode.cpp.
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.
Definition at line 7532 of file aicode.cpp.
Definition at line 7411 of file aicode.cpp.
Definition at line 7450 of file aicode.cpp.
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.
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"
team | Team (friendly, hostile, neutral) |
time | Time to rearm |
Definition at line 300 of file aicode.cpp.
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.
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.
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.
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.
Updates AI aim automatically based on targetted enemy.
aip | Pointer to AI info |
Definition at line 3490 of file aicode.cpp.
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.
Definition at line 14881 of file aicode.cpp.
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.
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.
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.
Definition at line 12072 of file aicode.cpp.
Definition at line 1377 of file aicode.cpp.
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.
Definition at line 14463 of file aicode.cpp.
Returns total number of ignored objects.
aip | AI info |
force | Means 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.
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.
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.
Return total payload of all incoming missiles.
Definition at line 5966 of file aicode.cpp.
Definition at line 5919 of file aicode.cpp.
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.
objp | Object pointer |
mp | Model path |
dir | Directory type |
count | Count of items |
path_num | Path number |
pnp | Node on a path |
randomize_pnt | Optional parameter (default value -1), add random vector in sphere to this path point |
Definition at line 2621 of file aicode.cpp.
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.
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_objp | Player object |
mobjp | Model object |
path_num | Number of path |
subsys_path | Optional param (default 0), indicating this is a path to a subsystem |
Definition at line 2706 of file aicode.cpp.
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.
curpos | Current position in vector space |
goalpos | Goal position in vector space |
curobjp | Current object pointer |
goalobjp | Goal object pointer |
subsys_path | Optional 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.
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.
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.
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.
Return objnum if enemy found, else return -1;
objnum | Object number |
range | Range within which to look |
max_attackers | Don't attack a ship that already has at least max_attackers attacking it. |
Definition at line 2186 of file aicode.cpp.
Definition at line 1877 of file aicode.cpp.
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.
Definition at line 8994 of file aicode.cpp.
Definition at line 14813 of file aicode.cpp.
Definition at line 2244 of file aicode.cpp.
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
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.
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.
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
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.
objnum | Object number |
enemy_team_mask | Mask to apply to enemy team |
enemy_wing | Enemy wing chosen |
range | Ship must be within range "range". |
max_attackers | Don'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.
Stuff tan1 with tangent point on sphere.
tan1 | is point nearer to *p1 |
*p0 | is point through which tangents pass. |
*centerp | is center of sphere. |
*p1 | is another point in space to define the plane in which tan1, tan2 reside. |
radius | is 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.
Returns a point radius units away from *point that *objp should turn towards to orbit *point
Definition at line 1609 of file aicode.cpp.
Definition at line 11299 of file aicode.cpp.
Definition at line 11230 of file aicode.cpp.
For the wing that *objp is part of, return the largest ship radius in that wing.
Definition at line 11374 of file aicode.cpp.
Definition at line 11251 of file aicode.cpp.
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.
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.
Object being guarded by object *guard_objp was hit by object *hitter_objp
Definition at line 9471 of file aicode.cpp.
Compute the largest radius of a ship in a *objp's wing.
Definition at line 11329 of file aicode.cpp.
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.
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.
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.
Initialize ai_info struct of object objnum.
Definition at line 14300 of file aicode.cpp.
Init necessary AI info for new stealth target
Definition at line 894 of file aicode.cpp.
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.
Definition at line 1891 of file aicode.cpp.
Determine if object objnum is supposed to be ignored by object with ai_info *aip.
Definition at line 1843 of file aicode.cpp.
Is an instructor if name begins INSTRUCTOR_SHIP_NAME else not.
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.
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.
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.
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.
Definition at line 2911 of file aicode.cpp.
If *objp is recovering from a collision with a big ship, handle it.
Definition at line 13887 of file aicode.cpp.
Definition at line 15575 of file aicode.cpp.
Definition at line 10584 of file aicode.cpp.
Definition at line 12456 of file aicode.cpp.
int maybe_hack_cruiser_chase_abort | ( | ) |
Definition at line 7965 of file aicode.cpp.
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.
Definition at line 13182 of file aicode.cpp.
Definition at line 4757 of file aicode.cpp.
Maybe make ship with ai_info *aip attack hitter_objnum as a dynamic goal
Definition at line 14782 of file aicode.cpp.
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.
Return true if ship *objp firing a laser believes it will hit a teammate.
Definition at line 6120 of file aicode.cpp.
Definition at line 3533 of file aicode.cpp.
Definition at line 13139 of file aicode.cpp.
Return number of ships on *objp's team that are currently rearming.
Definition at line 13155 of file aicode.cpp.
Return number of enemies attacking object objnum
Definition at line 1676 of file aicode.cpp.
Definition at line 5765 of file aicode.cpp.
Given an object number, return the number of ships attacking it.
Definition at line 9346 of file aicode.cpp.
Number of live turrets with target_objnum
Definition at line 2137 of file aicode.cpp.
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.
Definition at line 14608 of file aicode.cpp.
Definition at line 11120 of file aicode.cpp.
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.
Definition at line 9384 of file aicode.cpp.
Definition at line 6145 of file aicode.cpp.
Debug function to show all path points associated with an object
Definition at line 6190 of file aicode.cpp.
Definition at line 6230 of file aicode.cpp.
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.
Definition at line 1400 of file aicode.cpp.
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.
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.
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.
Definition at line 208 of file aicode.cpp.
void slide_face_ship | ( | ) |
Definition at line 5019 of file aicode.cpp.
Definition at line 4808 of file aicode.cpp.
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.
Definition at line 1558 of file aicode.cpp.
Given an object and a point, turn towards the point, resulting in approach behavior.
Definition at line 1491 of file aicode.cpp.
Definition at line 1533 of file aicode.cpp.
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.
Definition at line 4104 of file aicode.cpp.
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.
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.
ai_render_stuff AI_debug_render_stuff[MAX_AI_DEBUG_RENDER_STUFF] |
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[] |
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.
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] |
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] |
Definition at line 154 of file aicode.cpp.
char* Submode_text[] |
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.