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#define TURRET_SAME_TEAM(a, b) (a.team == b.team)
76#define TURRET_DIFF_TEAM(a, b) (a.team != b.team)
77
78// fields:
79.entity tur_head;
80
81// target selection flags
84const int TFL_TARGETSELECT_NO = BIT(1);
85const int TFL_TARGETSELECT_LOS = BIT(2);
95const int TFL_TARGETSELECT_FOV = BIT(12);
98
99// aim flags
101const int TFL_AIM_NO = BIT(0);
102const int TFL_AIM_SPLASH = BIT(1);
103const int TFL_AIM_LEAD = BIT(2);
105const int TFL_AIM_ZPREDICT = BIT(4);
106const int TFL_AIM_SIMPLE = BIT(5);
107
108// tracking flags
110const int TFL_TRACK_NO = BIT(1);
111const int TFL_TRACK_PITCH = BIT(2);
112const int TFL_TRACK_ROTATE = BIT(3);
113
114// prefire checks
116const int TFL_FIRECHECK_DEAD = BIT(2);
118const int TFL_FIRECHECK_LOS = BIT(4);
123const int TFL_FIRECHECK_AFF = BIT(9);
126const int TFL_FIRECHECK_REFIRE = BIT(12);
127const int TFL_FIRECHECK_NO = BIT(14);
128
129// attack flags
131const int TFL_SHOOT_NO = BIT(6);
132const int TFL_SHOOT_VOLLY = BIT(1);
136const int TFL_SHOOT_CUSTOM = BIT(5);
137
138// turret capabilities
140const int TUR_FLAG_NONE = 0;
141const int TUR_FLAG_SNIPER = BIT(1);
142const int TUR_FLAG_SPLASH = BIT(2);
143const int TUR_FLAG_HITSCAN = BIT(3);
144const int TUR_FLAG_MULTIGUN = BIT(4);
145const int TUR_FLAG_GUIDED = BIT(5);
146const int TUR_FLAG_SLOWPROJ = BIT(6);
147const int TUR_FLAG_MEDPROJ = BIT(7);
148const int TUR_FLAG_FASTPROJ = BIT(8);
149const int TUR_FLAG_PLAYER = BIT(9);
150const int TUR_FLAG_MISSILE = BIT(10);
151const int TUR_FLAG_SUPPORT = BIT(11);
152const int TUR_FLAG_AMMOSOURCE = BIT(12);
154const int TUR_FLAG_MOVE = BIT(14);
155const int TUR_FLAG_ROAM = BIT(15);
156const int TUR_FLAG_ISTURRET = BIT(16);
157
158// ammo types
159#define ammo_flags currentammo
160const int TFL_AMMO_NONE = BIT(6);
161const int TFL_AMMO_ENERGY = BIT(1);
162const int TFL_AMMO_BULLETS = BIT(2);
163const int TFL_AMMO_ROCKETS = BIT(3);
164const int TFL_AMMO_RECHARGE = BIT(4);
165const int TFL_AMMO_RECIEVE = BIT(5);
166
167// damage flags
169const int TFL_DMG_NO = BIT(8);
170const int TFL_DMG_YES = BIT(1);
171const int TFL_DMG_TEAM = BIT(2);
172const int TFL_DMG_RETALIATE = BIT(3);
174const int TFL_DMG_TARGETLOSS = BIT(5);
175const int TFL_DMG_AIMSHAKE = BIT(6);
176const int TFL_DMG_HEADSHAKE = BIT(7);
178
179// spawn flags
180const int TSF_SUSPENDED = BIT(0);
181const int TSF_TERRAINBASE = BIT(1);
182const int TSF_NO_AMMO_REGEN = BIT(2);
183const int TSF_NO_PATHBREAK = BIT(3);
184const int TSL_NO_RESPAWN = BIT(4);
185const int TSL_ROAM = BIT(5);
186
187// send flags
188const int TNSF_UPDATE = BIT(1);
189const int TNSF_STATUS = BIT(2);
190const int TNSF_SETUP = BIT(3);
191const int TNSF_ANG = BIT(4);
192const int TNSF_AVEL = BIT(5);
193const int TNSF_MOVE = BIT(6);
195const int TNSF_ANIM = BIT(7);
196
197const 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:164
#define TC(T, sym)
Definition _all.inc:82
string name
Definition menu.qh:30
#define SUPER(cname)
Definition oo.qh:236
#define CLASS(...)
Definition oo.qh:149
#define ENDCLASS(cname)
Definition oo.qh:286
#define METHOD(cname, name, prototype)
Definition oo.qh:274
#define ATTRIB(...)
Definition oo.qh:152
vector
Definition self.qh:96
entity tur_head
Definition sv_turrets.qh:28
const int TUR_FLAG_ROAM
roams around if not attacking
Definition turret.qh:155
const int TFL_TRACK_NO
don't move head
Definition turret.qh:110
const int TFL_TARGETSELECT_ANGLELIMITS
apply extra angular limits to target selection
Definition turret.qh:89
const int TUR_FLAG_SUPPORT
supports other units
Definition turret.qh:151
const int TFL_FIRECHECK_DISTANCES
another range check
Definition turret.qh:117
const int TFL_DMG_HEADSHAKE
damage shakes head
Definition turret.qh:176
const int TSF_SUSPENDED
Definition turret.qh:180
const int TUR_FLAG_RECIEVETARGETS
can recieve targets from external sources
Definition turret.qh:153
const int TNSF_FULL_UPDATE
Definition turret.qh:197
const int TFL_TARGETSELECT_TEAMCHECK
don't attack teammates
Definition turret.qh:91
const int TUR_FLAG_HITSCAN
hit scan
Definition turret.qh:143
const int TFL_FIRECHECK_AMMO_OWN
own ammo needs to be larger than damage dealt
Definition turret.qh:124
const int TUR_FLAG_MISSILE
can damage missiles
Definition turret.qh:150
int target_validate_flags
Definition turret.qh:83
const int TFL_DMG_YES
can be damaged
Definition turret.qh:170
const int TUR_FLAG_NONE
no abilities
Definition turret.qh:140
const int TUR_FLAG_ISTURRET
identifies this unit as a turret
Definition turret.qh:156
const int TFL_SHOOT_VOLLYALWAYS
always do a full volly, even if target is lost
Definition turret.qh:133
const int TFL_FIRECHECK_DEAD
don't attack dead targets (zombies?)
Definition turret.qh:116
const int TFL_AIM_LEAD
try to predict target movement
Definition turret.qh:103
const int TFL_TARGETSELECT_TRIGGERTARGET
respond to turret_trigger_target events
Definition turret.qh:88
const int TFL_DMG_TARGETLOSS
loses target when damaged
Definition turret.qh:174
const int TFL_TARGETSELECT_PLAYERS
target players
Definition turret.qh:86
const int TFL_AIM_SPLASH
aim for ground around the target's feet
Definition turret.qh:102
int track_flags
Definition turret.qh:109
const int TNSF_ANG
Definition turret.qh:191
const int TSF_NO_AMMO_REGEN
disable builtin ammo regeneration
Definition turret.qh:182
const int TUR_FLAG_PLAYER
can damage players
Definition turret.qh:149
int turret_flags
Definition turret.qh:139
const int TFL_FIRECHECK_AIMDIST
consider distance impactpoint<->aimspot
Definition turret.qh:119
const int TFL_DMG_TEAM
can be damaged by teammates
Definition turret.qh:171
const int TFL_TARGETSELECT_RANGELIMITS
limit target selection range
Definition turret.qh:90
const int TUR_FLAG_FASTPROJ
turret fires fast projectiles
Definition turret.qh:148
const int TNSF_AVEL
Definition turret.qh:192
const int TFL_DMG_RETALIATE_TEAM
target attackers, even if on same team
Definition turret.qh:173
const int TFL_SHOOT_CLEARTARGET
lose target after attack (after volly is done if in volly mode)
Definition turret.qh:135
const int TFL_AMMO_ROCKETS
uses explosives
Definition turret.qh:163
const int TFL_AIM_ZPREDICT
predict target's z position at impact
Definition turret.qh:105
const int TSF_NO_PATHBREAK
don't break path to chase enemies, will still fire at them if possible
Definition turret.qh:183
const int TFL_FIRECHECK_AMMO_OTHER
target's ammo needs to be less than max
Definition turret.qh:125
const int TFL_TRACK_ROTATE
rotate head
Definition turret.qh:112
const int TUR_FLAG_SNIPER
sniping turret
Definition turret.qh:141
int shoot_flags
Definition turret.qh:130
int target_select_flags
Definition turret.qh:82
const int TFL_DMG_AIMSHAKE
damage throws off aim
Definition turret.qh:175
const int TFL_TARGETSELECT_NO
don't automatically find targets
Definition turret.qh:84
const int TFL_AMMO_BULLETS
uses bullets
Definition turret.qh:162
const int TFL_FIRECHECK_REFIRE
check single attack finished delays
Definition turret.qh:126
const int TFL_TARGETSELECT_NOBUILTIN
only attack targets when triggered
Definition turret.qh:92
const int TSL_NO_RESPAWN
don't re-spawn
Definition turret.qh:184
const int TNSF_UPDATE
Definition turret.qh:188
const int TFL_TARGETSELECT_VEHICLES
target manned vehicles
Definition turret.qh:97
const int TNSF_SETUP
Definition turret.qh:190
const int TFL_AIM_SHOTTIMECOMPENSATE
compensate for shot traveltime when leading
Definition turret.qh:104
const int TFL_AMMO_ENERGY
uses power
Definition turret.qh:161
const int TNSF_MOVE
Definition turret.qh:193
const int TFL_FIRECHECK_LOS
line of sight
Definition turret.qh:118
const int TFL_AIM_NO
no aiming
Definition turret.qh:101
const int TFL_DMG_RETALIATE
target attackers
Definition turret.qh:172
const int TSF_TERRAINBASE
currently unused
Definition turret.qh:181
const int TFL_TARGETSELECT_LOS
require line of sight to find targets
Definition turret.qh:85
const int TFL_FIRECHECK_NO
no prefire checks
Definition turret.qh:127
const int TNSF_ANIM
Definition turret.qh:195
const int TFL_SHOOT_VOLLY
fire in vollies
Definition turret.qh:132
const int TFL_AMMO_RECHARGE
regenerates ammo
Definition turret.qh:164
const int TFL_AMMO_NONE
doesn't use ammo
Definition turret.qh:160
int damage_flags
Definition turret.qh:168
const int TFL_DMG_DEATH_NORESPAWN
no re-spawning
Definition turret.qh:177
const int TNSF_STATUS
Definition turret.qh:189
const int TFL_FIRECHECK_TEAMCHECK
don't attack teammates
Definition turret.qh:122
const int TUR_FLAG_GUIDED
laser guided projectiles
Definition turret.qh:145
const int TFL_TARGETSELECT_FOV
extra limits to attack range
Definition turret.qh:95
const int TFL_TRACK_PITCH
pitch head
Definition turret.qh:111
const int TFL_SHOOT_NO
no attacking
Definition turret.qh:131
const int TFL_AMMO_RECIEVE
can recieve ammo from support units
Definition turret.qh:165
const int TUR_FLAG_SPLASH
can deal splash damage
Definition turret.qh:142
const int TUR_FLAG_MOVE
can move
Definition turret.qh:154
int firecheck_flags
Definition turret.qh:115
int aim_flags
Definition turret.qh:100
const int TFL_TARGETSELECT_MISSILES
target projectiles
Definition turret.qh:87
const int TUR_FLAG_SLOWPROJ
turret fires slow projectiles
Definition turret.qh:146
const int TSL_ROAM
roam while idle
Definition turret.qh:185
const int TFL_AIM_SIMPLE
aim at player's current location
Definition turret.qh:106
const int TFL_TARGETSELECT_NOTURRETS
don't attack other turrets
Definition turret.qh:94
const int TFL_FIRECHECK_REALDIST
consider enemy origin<->impactpoint
Definition turret.qh:120
const int TFL_TARGETSELECT_OWNTEAM
only attack teammates
Definition turret.qh:93
const int TUR_FLAG_MEDPROJ
turret fires medium projectiles
Definition turret.qh:147
const int TFL_SHOOT_CUSTOM
custom attacking
Definition turret.qh:136
const int TFL_TARGETSELECT_MISSILESONLY
only attack missiles
Definition turret.qh:96
const int TUR_FLAG_MULTIGUN
multiple guns
Definition turret.qh:144
const int TFL_FIRECHECK_AFF
try to avoid any friendly fire
Definition turret.qh:123
const int TFL_DMG_NO
doesn't take damage
Definition turret.qh:169
const int TFL_FIRECHECK_ANGLEDIST
consider angular diff head<->aimspot
Definition turret.qh:121
const int TUR_FLAG_AMMOSOURCE
can provide ammunition
Definition turret.qh:152
const int TFL_SHOOT_HITALLVALID
loop through all valid targets
Definition turret.qh:134
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
Weapon m_weapon
Definition wepent.qh:26