Xonotic
sv_turrets.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "all.qh"
4 
11 
12 entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim);
14 float turret_validate_target(entity e_turret, entity e_target, float validate_flags);
15 bool turret_firecheck(entity this);
17 
18 // turret fields
19 
20 #define X(class, prefix, fld, type) .type fld;
21 TR_PROPS_COMMON(X, , )
22 #undef X
23 /*
24 .float shot_volly; // smaller than 1 = shoot # times at target
25 .float shot_volly_refire; // refire after completed volly
26 */
27 
28 .float ticrate; // interal ai think rate
29 .entity tur_head; // top part of the turret
30 .entity tur_defend; // defend this entity
31 .vector tur_shotorg; // shot origin
32 .vector tur_aimpos; // aiming location
33 .float tur_impacttime; // predicted projectile impact time
34 .entity tur_impactent; // entity the projectile hit
35 .float tur_dist_enemy; // distance to enemy
36 .float tur_dist_aimpos; // distance to aim location
37 .float tur_dist_impact_to_aimpos; // distance impact<->aim
38 .float volly_counter; // decrement counter from .shot_volly to 0
39 
40 .float target_select_time; // last time turret had a valid target
41 .float target_validate_time; // throttle re-validation of current target
42 
43 
44 .float ammo; // current ammo
45 .vector idle_aim;
46 
61 
62 // tracking type
63 const float TFL_TRACKTYPE_STEPMOTOR = 1; // hard angle increments, ugly for fast turning with best accuracy
64 const float TFL_TRACKTYPE_FLUIDPRECISE = 2; // smooth absolute movement, looks OK with fair accuracy
65 const float TFL_TRACKTYPE_FLUIDINERTIA = 3; // simulated inertia ("wobbly" mode), worst accuracy, depends on below flags
66 
67 void turret_respawn(entity this);
68 
70 void turret_do_updates(entity e_turret);
72 
73 .float(entity this) turret_firecheckfunc; // TODO: deprecate!
74 
75 void turrets_setframe(entity this, float _frame, float client_only);
76 
77 bool turret_initialize(entity this, Turret tur);
78 
79 // returns true when box overlaps with a given location
80 bool turret_closetotarget(entity this, vector targ);
81 
83 .float(entity _turret, entity _target) turret_score_target;
84 
85 .bool(entity this, entity e_target,entity e_sender) turret_addtarget;
86 
87 .entity pathcurrent;
88 
89 .entity pathgoal;
90 
92 
93 // debugging
94 // Uncomment below to enable various debug output.
95 //#define TURRET_DEBUG
96 //#define TURRET_DEBUG_TARGETVALIDATE
97 //#define TURRET_DEBUG_TARGETSELECT
98 #ifdef TURRET_DEBUG
99 .float tur_debug_dmg_t_h; // total damage that hit something (can be more than tur_debug_dmg_t_f since it should count radius damage)
100 .float tur_debug_dmg_t_f; // total damage
101 .float tur_debug_start; // turret initialization time
102 .float tur_debug_tmr1; // random timer
103 .float tur_debug_tmr2; // random timer
104 .float tur_debug_tmr3; // random timer
105 .vector tur_debug_rvec; // random vector
106 #endif
107 
108 // aiming
109 vector tvt_thadv; // turret head angle diff vector, updated by a successful call to turret_validate_target
110 vector tvt_tadv; // turret angle diff vector, updated by a successful call to turret_validate_target
111 float tvt_thadf; // turret head angle diff float, updated by a successful call to turret_validate_target
112 float tvt_dist; // turret distance, updated by a successful call to turret_validate_target
113 
115 STATIC_INIT(g_turrets) { g_turrets = IL_NEW(); }
entity turret_select_target(entity this)
float turret_scale_health
Map time control health.
Definition: sv_turrets.qh:58
vector tvt_thadv
Definition: sv_turrets.qh:109
vector tur_shotorg
Definition: sv_turrets.qh:31
float turret_validate_target(entity e_turret, entity e_target, float validate_flags)
void turret_respawn(entity this)
entity pathgoal
Definition: sv_turrets.qh:89
vector idle_aim
Definition: sv_turrets.qh:45
float tvt_dist
Definition: sv_turrets.qh:112
float tur_dist_aimpos
Definition: sv_turrets.qh:36
#define IL_NEW()
entity tur_head
Definition: sv_turrets.qh:29
entity() spawn
float target_validate_time
Definition: sv_turrets.qh:41
#define TR_PROPS_COMMON(P, class, prefix)
Definition: all.qh:13
float tur_impacttime
Definition: sv_turrets.qh:33
bool turret_initialize(entity this, Turret tur)
entity tur_defend
Definition: sv_turrets.qh:30
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
void turrets_setframe(entity this, float _frame, float client_only)
void turret_do_updates(entity e_turret)
updates aim org, shot org, shot dir and enemy org for selected turret
entity tur_impactent
Definition: sv_turrets.qh:34
void turret_projectile_explode(entity this)
float autocvar_g_turrets_targetscan_maxdelay
Definition: sv_turrets.qh:9
float turret_scale_ammo
Map time control ammo held and recharged.
Definition: sv_turrets.qh:54
float tur_dist_enemy
Definition: sv_turrets.qh:35
IntrusiveList g_turrets
Definition: sv_turrets.qh:114
float volly_counter
Definition: sv_turrets.qh:38
float turret_scale_range
Map time control targetting range.
Definition: sv_turrets.qh:50
float ammo
Definition: sv_turrets.qh:44
#define X(class, prefix, fld, type)
Definition: sv_turrets.qh:20
bool autocvar_g_turrets_nofire
Definition: sv_turrets.qh:7
float turret_scale_damage
Map time control over pain inflicted.
Definition: sv_turrets.qh:48
float ticrate
Definition: sv_turrets.qh:28
float turret_scale_aim
Map time control aim speed.
Definition: sv_turrets.qh:56
float turret_scale_respawn
Map time control respawn time.
Definition: sv_turrets.qh:60
float autocvar_g_turrets_targetscan_mindelay
Definition: sv_turrets.qh:10
bool autocvar_g_turrets_reloadcvars
Definition: sv_turrets.qh:8
bool turret_firecheck(entity this)
float autocvar_g_turrets_aimidle_delay
Definition: sv_turrets.qh:6
entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
vector tur_shotdir_updated
Definition: sv_turrets.qh:71
Definition: sound.qh:119
const float TFL_TRACKTYPE_STEPMOTOR
Definition: sv_turrets.qh:63
STATIC_INIT(g_turrets)
Definition: sv_turrets.qh:115
entity pathcurrent
Definition: sv_turrets.qh:87
vector tur_aimpos
Definition: sv_turrets.qh:32
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool autocvar_g_turrets
Definition: sv_turrets.qh:5
const float TFL_TRACKTYPE_FLUIDPRECISE
Definition: sv_turrets.qh:64
bool turret_closetotarget(entity this, vector targ)
vector tvt_tadv
Definition: sv_turrets.qh:110
const float TFL_TRACKTYPE_FLUIDINERTIA
Definition: sv_turrets.qh:65
float turret_scale_refire
Map time control refire.
Definition: sv_turrets.qh:52
float target_select_time
Definition: sv_turrets.qh:40
float tur_dist_impact_to_aimpos
Definition: sv_turrets.qh:37
float tvt_thadf
Definition: sv_turrets.qh:111
float turret_count
Definition: sv_turrets.qh:91
Definition: turret.qh:5