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