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