]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/turrets/sv_turrets.qh
Purge autocvars.qh from the codebase, cvars are defined in the headers of the feature...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / sv_turrets.qh
1 #pragma once
2
3 #include "all.qh"
4
5 bool autocvar_g_turrets;
6 float autocvar_g_turrets_aimidle_delay;
7 bool autocvar_g_turrets_nofire;
8 bool autocvar_g_turrets_reloadcvars;
9 float autocvar_g_turrets_targetscan_maxdelay;
10 float autocvar_g_turrets_targetscan_mindelay;
11
12 entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim);
13 void turret_projectile_explode(entity this);
14 float turret_validate_target(entity e_turret, entity e_target, float validate_flags);
15 bool turret_firecheck(entity this);
16 entity turret_select_target(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
47 /// Map time control over pain inflicted
48 .float turret_scale_damage;
49 /// Map time control targetting range
50 .float turret_scale_range;
51 /// Map time control refire
52 .float turret_scale_refire;
53 /// Map time control ammo held and recharged
54 .float turret_scale_ammo;
55 /// Map time control aim speed
56 .float turret_scale_aim;
57 /// Map time control health
58 .float turret_scale_health;
59 /// Map time control respawn time
60 .float turret_scale_respawn;
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
69 /// updates aim org, shot org, shot dir and enemy org for selected turret
70 void turret_do_updates(entity e_turret);
71 .vector tur_shotdir_updated;
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
82 /// Function to use for target evaluation. usualy turret_targetscore_generic
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
91 float turret_count;
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
114 IntrusiveList g_turrets;
115 STATIC_INIT(g_turrets) { g_turrets = IL_NEW(); }