FS2_Open
Open source remastering of the Freespace 2 engine
|
#include "ai/aibig.h"
#include "ai/aiinternal.h"
#include "asteroid/asteroid.h"
#include "debugconsole/console.h"
#include "freespace2/freespace.h"
#include "gamesnd/gamesnd.h"
#include "globalincs/linklist.h"
#include "globalincs/systemvars.h"
#include "iff_defs/iff_defs.h"
#include "io/timer.h"
#include "math/staticrand.h"
#include "network/multi.h"
#include "network/multimsgs.h"
#include "object/objectdock.h"
#include "parse/scripting.h"
#include "render/3d.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#include "weapon/beam.h"
#include "weapon/flak.h"
#include "weapon/muzzleflash.h"
#include "weapon/swarm.h"
#include "weapon/weapon.h"
#include <limits.h>
Go to the source code of this file.
Classes | |
struct | eval_enemy_obj_struct |
Macros | |
#define | AICODE_TURRET_DUMBFIRE_ANGLE (0.8f) |
#define | AICODE_TURRET_HEATSEEK_ANGLE (0.7f) |
#define | AICODE_TURRET_MAX_TIME_IN_RANGE (5.0f) |
#define | BEAM_NEBULA_RANGE_REDUCE_FACTOR (0.8f) |
#define | EEOF_BIG_ONLY (1<<0) |
#define | EEOF_SMALL_ONLY (1<<1) |
#define | EEOF_TAGGED_ONLY (1<<2) |
#define | EEOF_BEAM (1<<3) |
#define | EEOF_FLAK (1<<4) |
#define | EEOF_LASER (1<<5) |
#define | EEOF_MISSILE (1<<6) |
#define | MAX_AIFFT_TURRETS 60 |
Typedefs | |
typedef struct eval_enemy_obj_struct | eval_enemy_obj_struct |
#define AICODE_TURRET_DUMBFIRE_ANGLE (0.8f) |
Definition at line 34 of file aiturret.cpp.
#define AICODE_TURRET_HEATSEEK_ANGLE (0.7f) |
Definition at line 35 of file aiturret.cpp.
#define AICODE_TURRET_MAX_TIME_IN_RANGE (5.0f) |
Definition at line 36 of file aiturret.cpp.
#define BEAM_NEBULA_RANGE_REDUCE_FACTOR (0.8f) |
Definition at line 37 of file aiturret.cpp.
#define EEOF_BEAM (1<<3) |
Definition at line 59 of file aiturret.cpp.
#define EEOF_BIG_ONLY (1<<0) |
Definition at line 56 of file aiturret.cpp.
#define EEOF_FLAK (1<<4) |
Definition at line 60 of file aiturret.cpp.
#define EEOF_LASER (1<<5) |
Definition at line 61 of file aiturret.cpp.
#define EEOF_MISSILE (1<<6) |
Definition at line 62 of file aiturret.cpp.
#define EEOF_SMALL_ONLY (1<<1) |
Definition at line 57 of file aiturret.cpp.
#define EEOF_TAGGED_ONLY (1<<2) |
Definition at line 58 of file aiturret.cpp.
#define MAX_AIFFT_TURRETS 60 |
Definition at line 1571 of file aiturret.cpp.
typedef struct eval_enemy_obj_struct eval_enemy_obj_struct |
void ai_fire_from_turret | ( | ship * | shipp, |
ship_subsys * | ss, | ||
int | parent_objnum | ||
) |
Definition at line 2219 of file aiturret.cpp.
float aifft_compute_turret_dot | ( | object * | objp, |
object * | enemy_objp, | ||
vec3d * | abs_gunposp, | ||
ship_subsys * | turret_subsysp, | ||
ship_subsys * | enemy_subsysp | ||
) |
Determine if subsystem *enemy_subsysp is hittable from objp.
@return Dot product of vector from point abs_gunposp to *enemy_subsysp, if hittable
Definition at line 1534 of file aiturret.cpp.
ship_subsys* aifft_find_turret_subsys | ( | object * | objp, |
ship_subsys * | ssp, | ||
object * | enemy_objp, | ||
float * | dot_out | ||
) |
Pick a subsystem to attack on enemy_objp. Only pick one if enemy_objp is a big ship or a capital ship.
Definition at line 1596 of file aiturret.cpp.
int aifft_rotate_turret | ( | ship * | shipp, |
int | parent_objnum, | ||
ship_subsys * | ss, | ||
object * | objp, | ||
object * | lep, | ||
vec3d * | predicted_enemy_pos, | ||
vec3d * | gvec | ||
) |
Rotate a turret towards an enemy.
Some obscure model thing only John Slagel knows about. Sets predicted enemy position. If the turret (*ss) has a subsystem targeted, the subsystem is used as the predicted point.
Definition at line 1428 of file aiturret.cpp.
bool all_turret_weapons_have_flags | ( | ship_weapon * | swp, |
int | flags | ||
) |
Returns true if all weapons in swp have the specified flag
Definition at line 262 of file aiturret.cpp.
bool all_turret_weapons_have_flags2 | ( | ship_weapon * | swp, |
int | flags | ||
) |
Returns true if all weapons in swp have the specified flag
Definition at line 284 of file aiturret.cpp.
Is bomb headed towards given ship?
bomb_objp | Bomb specified |
ship_objp | Ship specified |
Definition at line 222 of file aiturret.cpp.
void evaluate_obj_as_target | ( | object * | objp, |
eval_enemy_obj_struct * | eeo | ||
) |
Definition at line 575 of file aiturret.cpp.
int find_turret_enemy | ( | ship_subsys * | turret_subsys, |
int | objnum, | ||
vec3d * | tpos, | ||
vec3d * | tvec, | ||
int | current_enemy | ||
) |
Return objnum if enemy found, else return -1;
turret_subsys | Pointer to turret subsystem |
objnum | Parent objnum for the turret |
tpos | Position of turret (world coords) |
tvec | Forward vector of turret (world coords) |
current_enemy | Objnum of current turret target |
Definition at line 1187 of file aiturret.cpp.
float get_adjusted_turret_rof | ( | ship_subsys * | ss | ) |
Definition at line 2884 of file aiturret.cpp.
int get_nearest_turret_objnum | ( | int | turret_parent_objnum, |
ship_subsys * | turret_subsys, | ||
int | enemy_team_mask, | ||
vec3d * | tpos, | ||
vec3d * | tvec, | ||
int | current_enemy, | ||
bool | big_only_flag, | ||
bool | small_only_flag, | ||
bool | tagged_only_flag, | ||
bool | beam_flag, | ||
bool | flak_flag, | ||
bool | laser_flag, | ||
bool | missile_flag | ||
) |
Given an object and an enemy team, return the index of the nearest enemy object.
turret_parent_objnum | Parent objnum for the turret |
turret_subsys | Pointer to system_info for the turret subsystem |
enemy_team_mask | OR'ed TEAM_ flags for the enemy of the turret parent ship |
tpos | Position of turret (world coords) |
tvec | Forward vector of turret (world coords) |
current_enemy | Objnum of current turret target |
big_only_flag | |
small_only_flag | |
tagged_only_flag | |
beam_flag | |
flak_flag | |
laser_flag | |
missile_flag |
Definition at line 877 of file aiturret.cpp.
int get_turret_weapon_next_fire_stamp | ( | ship_weapon * | swp, |
int | weapon_num | ||
) |
Definition at line 450 of file aiturret.cpp.
weapon_info* get_turret_weapon_wip | ( | ship_weapon * | swp, |
int | weapon_num | ||
) |
Use for getting a Weapon_info pointer, given a turret and a turret weapon indice
Definition at line 439 of file aiturret.cpp.
if | ( | aifft_max_checks<= | 0 | ) |
Definition at line 1581 of file aiturret.cpp.
bool is_object_radius_in_turret_fov | ( | object * | objp, |
ship_subsys * | ss, | ||
vec3d * | tvec, | ||
vec3d * | tpos, | ||
vec3d * | v2e, | ||
vec3d * | predicted_pos, | ||
float | distance | ||
) |
Definition at line 119 of file aiturret.cpp.
int is_target_beam_valid | ( | ship_weapon * | swp, |
object * | objp | ||
) |
Is target beam valid?
Definition at line 842 of file aiturret.cpp.
float longest_turret_weapon_range | ( | ship_weapon * | swp | ) |
Returns the longest-ranged weapon on a turret
Definition at line 466 of file aiturret.cpp.
int object_in_turret_fov | ( | object * | objp, |
ship_subsys * | ss, | ||
vec3d * | tvec, | ||
vec3d * | tpos, | ||
float | dist | ||
) |
Is object in turret field of view?
objp | Pointer to object to test |
ss | Ship turret subsystem to test from |
tvec | Turret initial vector |
tpos | Turret initial position |
dist | Distance from turret to center point of object |
Definition at line 101 of file aiturret.cpp.
void ship_get_global_turret_gun_info | ( | object * | objp, |
ship_subsys * | ssp, | ||
vec3d * | gpos, | ||
vec3d * | gvec, | ||
int | use_angles, | ||
vec3d * | targetp | ||
) |
Given an object and a turret on that object, return the actual firing point of the gun and its normal.
objp | Pointer to object |
ssp | Pointer to turret subsystem |
gpos | Absolute position of gun firing point |
gvec | Vector from *gpos to *targetp |
use_angles | Use current angles |
targetp | Pointer to target object |
Definition at line 1327 of file aiturret.cpp.
void ship_get_global_turret_info | ( | object * | objp, |
model_subsystem * | tp, | ||
vec3d * | gpos, | ||
vec3d * | gvec | ||
) |
Given an object and a turret on that object, return the global position and forward vector of the turret.
objp | Pointer to object |
tp | Turrent model system on that object |
gpos | [Output] Global absolute position of gun firing point |
gvec | [Output] Global vector |
Definition at line 1303 of file aiturret.cpp.
bool turret_adv_fov_test | ( | ship_subsys * | ss, |
vec3d * | gvec, | ||
vec3d * | v2e, | ||
float | size_mod | ||
) |
Definition at line 2851 of file aiturret.cpp.
void turret_ai_update_aim | ( | ai_info * | aip, |
object * | En_Objp, | ||
ship_subsys * | ss | ||
) |
Update turret aiming data based on max turret aim update delay
Definition at line 1403 of file aiturret.cpp.
bool turret_fire_weapon | ( | int | weapon_num, |
ship_subsys * | turret, | ||
int | parent_objnum, | ||
vec3d * | turret_pos, | ||
vec3d * | turret_fvec, | ||
vec3d * | predicted_pos = NULL , |
||
float | flak_range_override = 100.0f |
||
) |
Fire a weapon from a turret
Definition at line 1832 of file aiturret.cpp.
bool turret_fov_test | ( | ship_subsys * | ss, |
vec3d * | gvec, | ||
vec3d * | v2e, | ||
float | size_mod | ||
) |
Definition at line 2873 of file aiturret.cpp.
int turret_select_best_weapon | ( | ship_subsys * | turret, |
object * | target | ||
) |
Returns the best weapon on turret for target
Definition at line 246 of file aiturret.cpp.
void turret_set_next_fire_timestamp | ( | int | weapon_num, |
weapon_info * | wip, | ||
ship_subsys * | turret, | ||
ai_info * | aip | ||
) |
Set the next fire timestamp for a turret, based on weapon type and ai class
Definition at line 1725 of file aiturret.cpp.
int turret_should_fire_aspect | ( | ship_subsys * | turret, |
weapon_info * | wip, | ||
bool | in_sight | ||
) |
Decide if a turret should launch an aspect seeking missile
Definition at line 1804 of file aiturret.cpp.
int turret_should_pick_new_target | ( | ship_subsys * | turret | ) |
Definition at line 1700 of file aiturret.cpp.
bool turret_std_fov_test | ( | ship_subsys * | ss, |
vec3d * | gvec, | ||
vec3d * | v2e, | ||
float | size_mod | ||
) |
Definition at line 2841 of file aiturret.cpp.
void turret_swarm_fire_from_turret | ( | turret_swarm_info * | tsi | ) |
Definition at line 2137 of file aiturret.cpp.
void turret_update_enemy_in_range | ( | ship_subsys * | turret, |
float | seconds | ||
) |
Update how long current target has been in this turrets range
Definition at line 1816 of file aiturret.cpp.
int turret_weapon_aggregate_flags | ( | ship_weapon * | swp | ) |
Just gloms all the flags from all the weapons into one variable. More efficient if all you need to do is test for the existence of a flag.
Definition at line 360 of file aiturret.cpp.
int turret_weapon_aggregate_flags2 | ( | ship_weapon * | swp | ) |
Just gloms all the flags from all the weapons into one variable. More efficient if all you need to do is test for the existence of a flag.
Definition at line 384 of file aiturret.cpp.
bool turret_weapon_has_flags | ( | ship_weapon * | swp, |
int | flags | ||
) |
Returns true if any of the weapons in swp have flags
Definition at line 306 of file aiturret.cpp.
bool turret_weapon_has_flags2 | ( | ship_weapon * | swp, |
int | flags | ||
) |
Returns true if any of the weapons in swp have flags
Definition at line 334 of file aiturret.cpp.
bool turret_weapon_has_subtype | ( | ship_weapon * | swp, |
int | subtype | ||
) |
Returns true if any of the weapons in swp have the subtype specified
Definition at line 411 of file aiturret.cpp.
Is valid turret target?
objp | Object that turret is considering as an enemy |
turret_parent | Object of ship that turret sits on |
Definition at line 507 of file aiturret.cpp.
ship_subsys* aifft_list[MAX_AIFFT_TURRETS] |
Definition at line 1573 of file aiturret.cpp.
int aifft_list_size = 0 |
Definition at line 1575 of file aiturret.cpp.
int aifft_max_checks = 5 |
Definition at line 1576 of file aiturret.cpp.
float aifft_rank[MAX_AIFFT_TURRETS] |
Definition at line 1574 of file aiturret.cpp.
float Lethality_range_const = 2.0f |
Definition at line 39 of file aiturret.cpp.
int Nebula_sec_range |
Given a turret tp and its parent parent_objnum, fire from the turret at its enemy.
Definition at line 307 of file hudlock.cpp.
int Num_ai_firing = 0 |
Definition at line 2211 of file aiturret.cpp.
int Num_find_turret_enemy = 0 |
Definition at line 2212 of file aiturret.cpp.
int Num_turrets_fired = 0 |
Definition at line 2213 of file aiturret.cpp.
int Player_attacking_enabled |
Definition at line 1638 of file aicode.cpp.
float Player_lethality_bump[NUM_SKILL_LEVELS] |
Definition at line 45 of file aiturret.cpp.
char* Turret_target_order_names[NUM_TURRET_ORDER_TYPES] |
Definition at line 50 of file aiturret.cpp.
int Use_parent_target = 0 |
Definition at line 1175 of file aiturret.cpp.