7 #include "../../dpdefs/csprogsdefs.qh"
8 #include "../../client/defs.qh"
9 #include "../constants.qh"
10 #include "../stats.qh"
11 #include "../../warpzonelib/anglestransform.qh"
12 #include "../../warpzonelib/mathlib.qh"
13 #include "../../warpzonelib/common.qh"
14 #include "../../warpzonelib/client.qh"
16 #include "../buffs.qh"
17 #include "../../client/autocvars.qh"
18 #include "../deathtypes.qh"
19 #include "../../csqcmodellib/interpolate.qh"
20 #include "../movetypes/movetypes.qh"
21 #include "../../client/main.qh"
22 #include "../../csqcmodellib/cl_model.qh"
25 #include "../../dpdefs/progsdefs.qh"
26 #include "../../dpdefs/dpextensions.qh"
27 #include "../../warpzonelib/anglestransform.qh"
28 #include "../../warpzonelib/mathlib.qh"
29 #include "../../warpzonelib/common.qh"
30 #include "../../warpzonelib/util_server.qh"
31 #include "../../warpzonelib/server.qh"
32 #include "../constants.qh"
33 #include "../stats.qh"
34 #include "../teams.qh"
36 #include "../buffs.qh"
37 #include "../monsters/all.qh"
39 #include "../../server/weapons/csqcprojectile.qh"
40 #include "../../server/weapons/tracing.qh"
41 #include "../../server/t_items.qh"
42 #include "../../server/autocvars.qh"
43 #include "../../server/constants.qh"
44 #include "../../server/defs.qh"
45 #include "../notifications.qh"
46 #include "../deathtypes.qh"
47 #include "../../server/mutators/mutators_include.qh"
48 #include "../mapinfo.qh"
49 #include "../../server/command/common.qh"
50 #include "../../csqcmodellib/sv_model.qh"
51 #include "../../server/portals.qh"
52 #include "../../server/g_hook.qh"
55 #include "calculations.qc"
57 #define IMPLEMENTATION
61 // WEAPON PLUGIN SYSTEM
64 # error Kein Weltraum links auf dem Gerät
67 WepSet WepSet_FromWeapon(int a) {
75 return '0 0 1' * power2of(a);
78 return '0 1 0' * power2of(a);
81 return '1 0 0' * power2of(a);
86 addstat(STAT_WEAPONS, AS_INT, weapons_x);
88 addstat(STAT_WEAPONS2, AS_INT, weapons_y);
90 addstat(STAT_WEAPONS3, AS_INT, weapons_z);
94 void WepSet_AddStat_InMap()
96 addstat(STAT_WEAPONSINMAP, AS_INT, weaponsinmap_x);
98 addstat(STAT_WEAPONSINMAP2, AS_INT, weaponsinmap_y);
100 addstat(STAT_WEAPONSINMAP3, AS_INT, weaponsinmap_z);
104 void WriteWepSet(float dst, WepSet w)
106 #if WEP_MAXCOUNT > 48
107 WriteInt72_t(dst, w);
108 #elif WEP_MAXCOUNT > 24
109 WriteInt48_t(dst, w);
111 WriteInt24_t(dst, w.x);
116 WepSet WepSet_GetFromStat()
119 w.x = getstati(STAT_WEAPONS);
120 #if WEP_MAXCOUNT > 24
121 w.y = getstati(STAT_WEAPONS2);
122 #if WEP_MAXCOUNT > 48
123 w.z = getstati(STAT_WEAPONS3);
128 WepSet WepSet_GetFromStat_InMap()
131 w_x = getstati(STAT_WEAPONSINMAP);
132 #if WEP_MAXCOUNT > 24
133 w_y = getstati(STAT_WEAPONSINMAP2);
134 #if WEP_MAXCOUNT > 48
135 w_z = getstati(STAT_WEAPONSINMAP3);
142 #if WEP_MAXCOUNT > 48
143 return ReadInt72_t();
144 #elif WEP_MAXCOUNT > 24
145 return ReadInt48_t();
147 return ReadInt24_t() * '1 0 0';
152 void register_weapons_done()
154 dummy_weapon_info = spawn();
155 dummy_weapon_info.classname = "weapon_info";
156 dummy_weapon_info.weapon = 0; // you can recognize dummies by this
157 dummy_weapon_info.weapons = '0 0 0';
158 dummy_weapon_info.netname = "";
159 dummy_weapon_info.message = "AOL CD Thrower";
160 dummy_weapon_info.weapon_func = w_null;
161 dummy_weapon_info.wpmodel = "";
162 dummy_weapon_info.mdl = "";
163 dummy_weapon_info.model = "";
164 dummy_weapon_info.spawnflags = 0;
165 dummy_weapon_info.impulse = -1;
166 dummy_weapon_info.bot_pickupbasevalue = 0;
167 dummy_weapon_info.ammo_field = ammo_none;
169 dummy_weapon_info.w_crosshair = "gfx/crosshair1";
170 dummy_weapon_info.w_crosshair_size = 1;
171 dummy_weapon_info.model2 = "";
173 weaponorder_byid = "";
174 for (int i = WEP_MAXCOUNT - 1; i >= 0; --i)
176 weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
177 weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
179 entity get_weaponinfo(int id)
182 if(id < WEP_FIRST || id > WEP_LAST)
183 return dummy_weapon_info;
184 w = weapon_info[id - 1];
187 return dummy_weapon_info;
189 string W_FixWeaponOrder(string order, float complete)
191 return fixPriorityList(order, WEP_FIRST, WEP_LAST, 230 - WEP_FIRST, complete);
193 string W_NameWeaponOrder_MapFunc(string s)
196 if(s == "0" || stof(s))
198 wi = get_weaponinfo(stof(s));
199 if(wi != dummy_weapon_info)
205 string W_UndeprecateName(string s)
209 case "nex" : return "vortex";
210 case "rocketlauncher" : return "devastator";
211 case "laser" : return "blaster";
212 case "minstanex" : return "vaporizer";
213 case "grenadelauncher": return "mortar";
214 case "uzi" : return "machinegun";
218 string W_NameWeaponOrder(string order)
220 return mapPriorityList(order, W_NameWeaponOrder_MapFunc);
222 string W_NumberWeaponOrder_MapFunc(string s)
225 if(s == "0" || stof(s))
227 s = W_UndeprecateName(s);
228 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
229 if(s == get_weaponinfo(i).netname)
233 string W_NumberWeaponOrder(string order)
235 return mapPriorityList(order, W_NumberWeaponOrder_MapFunc);
238 float W_FixWeaponOrder_BuildImpulseList_buf[WEP_MAXCOUNT];
239 string W_FixWeaponOrder_BuildImpulseList_order;
240 void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
243 h = W_FixWeaponOrder_BuildImpulseList_buf[i];
244 W_FixWeaponOrder_BuildImpulseList_buf[i] = W_FixWeaponOrder_BuildImpulseList_buf[j];
245 W_FixWeaponOrder_BuildImpulseList_buf[j] = h;
247 float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
251 e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
252 e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
253 d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
255 return -d; // high impulse first!
257 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
259 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
260 ; // low char index first!
262 string W_FixWeaponOrder_BuildImpulseList(string o)
265 W_FixWeaponOrder_BuildImpulseList_order = o;
266 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
267 W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST] = i;
268 heapsort(WEP_LAST - WEP_FIRST + 1, W_FixWeaponOrder_BuildImpulseList_swap, W_FixWeaponOrder_BuildImpulseList_cmp, world);
270 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
271 o = strcat(o, " ", ftos(W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST]));
272 W_FixWeaponOrder_BuildImpulseList_order = string_null;
273 return substring(o, 1, -1);
276 string W_FixWeaponOrder_AllowIncomplete(string order)
278 return W_FixWeaponOrder(order, 0);
281 string W_FixWeaponOrder_ForceComplete(string order)
284 order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
285 return W_FixWeaponOrder(order, 1);
288 void W_RandomWeapons(entity e, float n)
293 remaining = e.weapons;
295 for(i = 0; i < n; ++i)
297 RandomSelection_Init();
298 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
299 if(remaining & WepSet_FromWeapon(j))
300 RandomSelection_Add(world, j, string_null, 1, 1);
301 result |= WepSet_FromWeapon(RandomSelection_chosen_float);
302 remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
307 string GetAmmoPicture(.int ammotype)
311 case ammo_shells: return "ammo_shells";
312 case ammo_nails: return "ammo_bullets";
313 case ammo_rockets: return "ammo_rockets";
314 case ammo_cells: return "ammo_cells";
315 case ammo_plasma: return "ammo_cells";
316 case ammo_fuel: return "ammo_fuel";
317 default: return ""; // wtf, no ammo type?
322 .int GetAmmoFieldFromNum(int i)
326 case 0: return ammo_shells;
327 case 1: return ammo_nails;
328 case 2: return ammo_rockets;
329 case 3: return ammo_cells;
330 case 4: return ammo_plasma;
331 case 5: return ammo_fuel;
332 default: return ammo_none;
336 int GetAmmoStat(.int ammotype)
340 case ammo_shells: return STAT_SHELLS;
341 case ammo_nails: return STAT_NAILS;
342 case ammo_rockets: return STAT_ROCKETS;
343 case ammo_cells: return STAT_CELLS;
344 case ammo_plasma: return STAT_PLASMA;
345 case ammo_fuel: return STAT_FUEL;