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