Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
turret.qh
Go to the documentation of this file.
1#pragma once
2
3#ifndef SVQC
4#include <common/util.qh> // for icon_path_from_HUDskin
5#endif
7
9 ATTRIB(Turret, m_id, int, 0);
10
12 ATTRIB(Turret, m_icon, string);
16 ATTRIB(Turret, m_name, string, _("Turret"));
19#ifdef GAMEQC
21 ATTRIB(Turret, mdl, string);
23 ATTRIB(Turret, model, string);
25 ATTRIB(Turret, head_model, string);
26
29 ATTRIB(Turret, m_mins, vector, '-0 -0 -0');
32#endif
33
34#ifdef GAMEQC
36 METHOD(Turret, tr_setup, void(Turret this, entity it)) { }
37#endif
38#ifdef SVQC
40 METHOD(Turret, tr_think, void(Turret this, entity it)) { }
42 METHOD(Turret, tr_death, void(Turret this, entity it)) { }
43#endif
44#ifdef GAMEQC
46 METHOD(Turret, tr_precache, void(Turret this)) { }
47#endif
48#ifdef SVQC
52 {
53 Weapon w = this.m_weapon;
54 .entity weaponentity = weaponentities[0];
55 w.wr_think(w, it, weaponentity, 1);
56 }
57
58 METHOD(Turret, tr_config, void(Turret this)) { }
59#endif
60
61#ifdef MENUQC
62 METHOD(Turret, describe, string(Turret this))
63 {
64 TC(Turret, this);
65 return SUPER(Turret).describe(this);
66 }
67 METHOD(Turret, display, void(Turret this, void(string name, string icon) returns))
68 {
69 TC(Turret, this);
70 returns(this.m_name, icon_path_from_HUDskin(this.m_icon));
71 }
72#endif
74
75// fields:
76.entity tur_head;
77
78// target selection flags
81const int TFL_TARGETSELECT_NO = BIT(1);
82const int TFL_TARGETSELECT_LOS = BIT(2);
92const int TFL_TARGETSELECT_FOV = BIT(12);
95
96// aim flags
98const int TFL_AIM_NO = BIT(0);
99const int TFL_AIM_SPLASH = BIT(1);
100const int TFL_AIM_LEAD = BIT(2);
102const int TFL_AIM_ZPREDICT = BIT(4);
103const int TFL_AIM_SIMPLE = BIT(5);
104
105// tracking flags
107const int TFL_TRACK_NO = BIT(1);
108const int TFL_TRACK_PITCH = BIT(2);
109const int TFL_TRACK_ROTATE = BIT(3);
110
111// prefire checks
113const int TFL_FIRECHECK_DEAD = BIT(2);
115const int TFL_FIRECHECK_LOS = BIT(4);
120const int TFL_FIRECHECK_AFF = BIT(9);
123const int TFL_FIRECHECK_REFIRE = BIT(12);
124const int TFL_FIRECHECK_NO = BIT(14);
125
126// attack flags
128const int TFL_SHOOT_NO = BIT(6);
129const int TFL_SHOOT_VOLLY = BIT(1);
133const int TFL_SHOOT_CUSTOM = BIT(5);
134
135// turret capabilities
137const int TUR_FLAG_NONE = 0;
138const int TUR_FLAG_SNIPER = BIT(1);
139const int TUR_FLAG_SPLASH = BIT(2);
140const int TUR_FLAG_HITSCAN = BIT(3);
141const int TUR_FLAG_MULTIGUN = BIT(4);
142const int TUR_FLAG_GUIDED = BIT(5);
143const int TUR_FLAG_SLOWPROJ = BIT(6);
144const int TUR_FLAG_MEDPROJ = BIT(7);
145const int TUR_FLAG_FASTPROJ = BIT(8);
146const int TUR_FLAG_PLAYER = BIT(9);
147const int TUR_FLAG_MISSILE = BIT(10);
148const int TUR_FLAG_SUPPORT = BIT(11);
149const int TUR_FLAG_AMMOSOURCE = BIT(12);
151const int TUR_FLAG_MOVE = BIT(14);
152const int TUR_FLAG_ROAM = BIT(15);
153const int TUR_FLAG_ISTURRET = BIT(16);
154
155// ammo types
156#define ammo_flags currentammo
157const int TFL_AMMO_NONE = BIT(6);
158const int TFL_AMMO_ENERGY = BIT(1);
159const int TFL_AMMO_BULLETS = BIT(2);
160const int TFL_AMMO_ROCKETS = BIT(3);
161const int TFL_AMMO_RECHARGE = BIT(4);
162const int TFL_AMMO_RECIEVE = BIT(5);
163
164// damage flags
166const int TFL_DMG_NO = BIT(8);
167const int TFL_DMG_YES = BIT(1);
168const int TFL_DMG_TEAM = BIT(2);
169const int TFL_DMG_RETALIATE = BIT(3);
171const int TFL_DMG_TARGETLOSS = BIT(5);
172const int TFL_DMG_AIMSHAKE = BIT(6);
173const int TFL_DMG_HEADSHAKE = BIT(7);
175
176// spawn flags
177const int TSF_SUSPENDED = BIT(0);
178const int TSF_TERRAINBASE = BIT(1);
179const int TSF_NO_AMMO_REGEN = BIT(2);
180const int TSF_NO_PATHBREAK = BIT(3);
181const int TSL_NO_RESPAWN = BIT(4);
182const int TSL_ROAM = BIT(5);
183
184// send flags
185const int TNSF_UPDATE = BIT(1);
186const int TNSF_STATUS = BIT(2);
187const int TNSF_SETUP = BIT(3);
188const int TNSF_ANG = BIT(4);
189const int TNSF_AVEL = BIT(5);
190const int TNSF_MOVE = BIT(6);
192const int TNSF_ANIM = BIT(7);
193
194const int TNSF_FULL_UPDATE = 0xFFFFFF;
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
virtual void display()
Definition turret.qh:67
vector m_color
color
Definition turret.qh:18
virtual void tr_attack()
(SERVER) called when turret attacks
Definition turret.qh:51
string m_name
human readable name
Definition turret.qh:16
int m_id
Definition turret.qh:9
ATTRIB(Turret, mdl, string)
currently a copy of the model
vector m_maxs
turret hitbox size
Definition turret.qh:31
ATTRIB(Turret, model, string)
full name of model
virtual void describe()
Definition turret.qh:62
virtual void tr_death()
(SERVER) called when turret dies
Definition turret.qh:42
ATTRIB(Turret, m_icon, string)
icon
virtual void tr_setup()
(BOTH) setup turret data
Definition turret.qh:36
virtual void tr_precache()
(BOTH) precaches models/sounds used by this turret
Definition turret.qh:46
virtual void tr_config()
(SERVER) dump turret cvars to config in data directory (see: sv_cmd dumpturrets)
Definition turret.qh:58
vector m_mins
turret hitbox size
Definition turret.qh:29
virtual void tr_think()
(SERVER) logic to run every frame
Definition turret.qh:40
int spawnflags
Definition turret.qh:27
ATTRIB(Turret, head_model, string)
full name of tur_head model
ATTRIB(Turret, m_weapon, Weapon)
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:42
virtual void wr_think()
(SERVER) logic to run every frame
Definition weapon.qh:98
string netname
Definition powerups.qc:20
float anim_start_time
Definition items.qc:15
string mdl
Definition item.qh:89
model
Definition ent_cs.qc:139
#define TC(T, sym)
Definition _all.inc:82
string name
Definition menu.qh:30
#define SUPER(cname)
Definition oo.qh:231
#define CLASS(...)
Definition oo.qh:145
#define ENDCLASS(cname)
Definition oo.qh:281
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define ATTRIB(...)
Definition oo.qh:148
vector
Definition self.qh:92
entity tur_head
Definition sv_turrets.qh:28
const int TUR_FLAG_ROAM
roams around if not attacking
Definition turret.qh:152
const int TFL_TRACK_NO
don't move head
Definition turret.qh:107
const int TFL_TARGETSELECT_ANGLELIMITS
apply extra angular limits to target selection
Definition turret.qh:86
const int TUR_FLAG_SUPPORT
supports other units
Definition turret.qh:148
const int TFL_FIRECHECK_DISTANCES
another range check
Definition turret.qh:114
const int TFL_DMG_HEADSHAKE
damage shakes head
Definition turret.qh:173
const int TSF_SUSPENDED
Definition turret.qh:177
const int TUR_FLAG_RECIEVETARGETS
can recieve targets from external sources
Definition turret.qh:150
const int TNSF_FULL_UPDATE
Definition turret.qh:194
const int TFL_TARGETSELECT_TEAMCHECK
don't attack teammates
Definition turret.qh:88
const int TUR_FLAG_HITSCAN
hit scan
Definition turret.qh:140
const int TFL_FIRECHECK_AMMO_OWN
own ammo needs to be larger than damage dealt
Definition turret.qh:121
const int TUR_FLAG_MISSILE
can damage missiles
Definition turret.qh:147
int target_validate_flags
Definition turret.qh:80
const int TFL_DMG_YES
can be damaged
Definition turret.qh:167
const int TUR_FLAG_NONE
no abilities
Definition turret.qh:137
const int TUR_FLAG_ISTURRET
identifies this unit as a turret
Definition turret.qh:153
const int TFL_SHOOT_VOLLYALWAYS
always do a full volly, even if target is lost
Definition turret.qh:130
const int TFL_FIRECHECK_DEAD
don't attack dead targets (zombies?)
Definition turret.qh:113
const int TFL_AIM_LEAD
try to predict target movement
Definition turret.qh:100
const int TFL_TARGETSELECT_TRIGGERTARGET
respond to turret_trigger_target events
Definition turret.qh:85
const int TFL_DMG_TARGETLOSS
loses target when damaged
Definition turret.qh:171
const int TFL_TARGETSELECT_PLAYERS
target players
Definition turret.qh:83
const int TFL_AIM_SPLASH
aim for ground around the target's feet
Definition turret.qh:99
int track_flags
Definition turret.qh:106
const int TNSF_ANG
Definition turret.qh:188
const int TSF_NO_AMMO_REGEN
disable builtin ammo regeneration
Definition turret.qh:179
const int TUR_FLAG_PLAYER
can damage players
Definition turret.qh:146
int turret_flags
Definition turret.qh:136
const int TFL_FIRECHECK_AIMDIST
consider distance impactpoint<->aimspot
Definition turret.qh:116
const int TFL_DMG_TEAM
can be damaged by teammates
Definition turret.qh:168
const int TFL_TARGETSELECT_RANGELIMITS
limit target selection range
Definition turret.qh:87
const int TUR_FLAG_FASTPROJ
turret fires fast projectiles
Definition turret.qh:145
const int TNSF_AVEL
Definition turret.qh:189
const int TFL_DMG_RETALIATE_TEAM
target attackers, even if on same team
Definition turret.qh:170
const int TFL_SHOOT_CLEARTARGET
lose target after attack (after volly is done if in volly mode)
Definition turret.qh:132
const int TFL_AMMO_ROCKETS
uses explosives
Definition turret.qh:160
const int TFL_AIM_ZPREDICT
predict target's z position at impact
Definition turret.qh:102
const int TSF_NO_PATHBREAK
don't break path to chase enemies, will still fire at them if possible
Definition turret.qh:180
const int TFL_FIRECHECK_AMMO_OTHER
target's ammo needs to be less than max
Definition turret.qh:122
const int TFL_TRACK_ROTATE
rotate head
Definition turret.qh:109
const int TUR_FLAG_SNIPER
sniping turret
Definition turret.qh:138
int shoot_flags
Definition turret.qh:127
int target_select_flags
Definition turret.qh:79
const int TFL_DMG_AIMSHAKE
damage throws off aim
Definition turret.qh:172
const int TFL_TARGETSELECT_NO
don't automatically find targets
Definition turret.qh:81
const int TFL_AMMO_BULLETS
uses bullets
Definition turret.qh:159
const int TFL_FIRECHECK_REFIRE
check single attack finished delays
Definition turret.qh:123
const int TFL_TARGETSELECT_NOBUILTIN
only attack targets when triggered
Definition turret.qh:89
const int TSL_NO_RESPAWN
don't re-spawn
Definition turret.qh:181
const int TNSF_UPDATE
Definition turret.qh:185
const int TFL_TARGETSELECT_VEHICLES
target manned vehicles
Definition turret.qh:94
const int TNSF_SETUP
Definition turret.qh:187
const int TFL_AIM_SHOTTIMECOMPENSATE
compensate for shot traveltime when leading
Definition turret.qh:101
const int TFL_AMMO_ENERGY
uses power
Definition turret.qh:158
const int TNSF_MOVE
Definition turret.qh:190
const int TFL_FIRECHECK_LOS
line of sight
Definition turret.qh:115
const int TFL_AIM_NO
no aiming
Definition turret.qh:98
const int TFL_DMG_RETALIATE
target attackers
Definition turret.qh:169
const int TSF_TERRAINBASE
currently unused
Definition turret.qh:178
const int TFL_TARGETSELECT_LOS
require line of sight to find targets
Definition turret.qh:82
const int TFL_FIRECHECK_NO
no prefire checks
Definition turret.qh:124
const int TNSF_ANIM
Definition turret.qh:192
const int TFL_SHOOT_VOLLY
fire in vollies
Definition turret.qh:129
const int TFL_AMMO_RECHARGE
regenerates ammo
Definition turret.qh:161
const int TFL_AMMO_NONE
doesn't use ammo
Definition turret.qh:157
int damage_flags
Definition turret.qh:165
const int TFL_DMG_DEATH_NORESPAWN
no re-spawning
Definition turret.qh:174
const int TNSF_STATUS
Definition turret.qh:186
const int TFL_FIRECHECK_TEAMCHECK
don't attack teammates
Definition turret.qh:119
const int TUR_FLAG_GUIDED
laser guided projectiles
Definition turret.qh:142
const int TFL_TARGETSELECT_FOV
extra limits to attack range
Definition turret.qh:92
const int TFL_TRACK_PITCH
pitch head
Definition turret.qh:108
const int TFL_SHOOT_NO
no attacking
Definition turret.qh:128
const int TFL_AMMO_RECIEVE
can recieve ammo from support units
Definition turret.qh:162
const int TUR_FLAG_SPLASH
can deal splash damage
Definition turret.qh:139
const int TUR_FLAG_MOVE
can move
Definition turret.qh:151
int firecheck_flags
Definition turret.qh:112
int aim_flags
Definition turret.qh:97
const int TFL_TARGETSELECT_MISSILES
target projectiles
Definition turret.qh:84
const int TUR_FLAG_SLOWPROJ
turret fires slow projectiles
Definition turret.qh:143
const int TSL_ROAM
roam while idle
Definition turret.qh:182
const int TFL_AIM_SIMPLE
aim at player's current location
Definition turret.qh:103
const int TFL_TARGETSELECT_NOTURRETS
don't attack other turrets
Definition turret.qh:91
const int TFL_FIRECHECK_REALDIST
consider enemy origin<->impactpoint
Definition turret.qh:117
const int TFL_TARGETSELECT_OWNTEAM
only attack teammates
Definition turret.qh:90
const int TUR_FLAG_MEDPROJ
turret fires medium projectiles
Definition turret.qh:144
const int TFL_SHOOT_CUSTOM
custom attacking
Definition turret.qh:133
const int TFL_TARGETSELECT_MISSILESONLY
only attack missiles
Definition turret.qh:93
const int TUR_FLAG_MULTIGUN
multiple guns
Definition turret.qh:141
const int TFL_FIRECHECK_AFF
try to avoid any friendly fire
Definition turret.qh:120
const int TFL_DMG_NO
doesn't take damage
Definition turret.qh:166
const int TFL_FIRECHECK_ANGLEDIST
consider angular diff head<->aimspot
Definition turret.qh:118
const int TUR_FLAG_AMMOSOURCE
can provide ammunition
Definition turret.qh:149
const int TFL_SHOOT_HITALLVALID
loop through all valid targets
Definition turret.qh:131
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
Weapon m_weapon
Definition wepent.qh:26