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 = NEW(Weapon);
156 weaponorder_byid = "";
157 for (int i = WEP_MAXCOUNT - 1; i >= 0; --i)
159 weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
160 weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
162 entity get_weaponinfo(int id)
165 if(id < WEP_FIRST || id > WEP_LAST)
166 return dummy_weapon_info;
167 w = weapon_info[id - 1];
170 return dummy_weapon_info;
172 string W_FixWeaponOrder(string order, float complete)
174 return fixPriorityList(order, WEP_FIRST, WEP_LAST, 230 - WEP_FIRST, complete);
176 string W_NameWeaponOrder_MapFunc(string s)
179 if(s == "0" || stof(s))
181 wi = get_weaponinfo(stof(s));
182 if(wi != dummy_weapon_info)
188 string W_UndeprecateName(string s)
192 case "nex" : return "vortex";
193 case "rocketlauncher" : return "devastator";
194 case "laser" : return "blaster";
195 case "minstanex" : return "vaporizer";
196 case "grenadelauncher": return "mortar";
197 case "uzi" : return "machinegun";
201 string W_NameWeaponOrder(string order)
203 return mapPriorityList(order, W_NameWeaponOrder_MapFunc);
205 string W_NumberWeaponOrder_MapFunc(string s)
208 if(s == "0" || stof(s))
210 s = W_UndeprecateName(s);
211 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
212 if(s == get_weaponinfo(i).netname)
216 string W_NumberWeaponOrder(string order)
218 return mapPriorityList(order, W_NumberWeaponOrder_MapFunc);
221 float W_FixWeaponOrder_BuildImpulseList_buf[WEP_MAXCOUNT];
222 string W_FixWeaponOrder_BuildImpulseList_order;
223 void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
226 h = W_FixWeaponOrder_BuildImpulseList_buf[i];
227 W_FixWeaponOrder_BuildImpulseList_buf[i] = W_FixWeaponOrder_BuildImpulseList_buf[j];
228 W_FixWeaponOrder_BuildImpulseList_buf[j] = h;
230 float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
234 e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
235 e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
236 d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
238 return -d; // high impulse first!
240 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
242 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
243 ; // low char index first!
245 string W_FixWeaponOrder_BuildImpulseList(string o)
248 W_FixWeaponOrder_BuildImpulseList_order = o;
249 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
250 W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST] = i;
251 heapsort(WEP_LAST - WEP_FIRST + 1, W_FixWeaponOrder_BuildImpulseList_swap, W_FixWeaponOrder_BuildImpulseList_cmp, world);
253 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
254 o = strcat(o, " ", ftos(W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST]));
255 W_FixWeaponOrder_BuildImpulseList_order = string_null;
256 return substring(o, 1, -1);
259 string W_FixWeaponOrder_AllowIncomplete(string order)
261 return W_FixWeaponOrder(order, 0);
264 string W_FixWeaponOrder_ForceComplete(string order)
267 order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
268 return W_FixWeaponOrder(order, 1);
271 void W_RandomWeapons(entity e, float n)
276 remaining = e.weapons;
278 for(i = 0; i < n; ++i)
280 RandomSelection_Init();
281 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
282 if(remaining & WepSet_FromWeapon(j))
283 RandomSelection_Add(world, j, string_null, 1, 1);
284 result |= WepSet_FromWeapon(RandomSelection_chosen_float);
285 remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
290 string GetAmmoPicture(.int ammotype)
294 case ammo_shells: return ITEM_Shells.m_icon;
295 case ammo_nails: return ITEM_Bullets.m_icon;
296 case ammo_rockets: return ITEM_Rockets.m_icon;
297 case ammo_cells: return ITEM_Cells.m_icon;
298 case ammo_plasma: return ITEM_Plasma.m_icon;
299 case ammo_fuel: return ITEM_JetpackFuel.m_icon;
300 default: return ""; // wtf, no ammo type?
305 .int GetAmmoFieldFromNum(int i)
309 case 0: return ammo_shells;
310 case 1: return ammo_nails;
311 case 2: return ammo_rockets;
312 case 3: return ammo_cells;
313 case 4: return ammo_plasma;
314 case 5: return ammo_fuel;
315 default: return ammo_none;
319 int GetAmmoStat(.int ammotype)
323 case ammo_shells: return STAT_SHELLS;
324 case ammo_nails: return STAT_NAILS;
325 case ammo_rockets: return STAT_ROCKETS;
326 case ammo_cells: return STAT_CELLS;
327 case ammo_plasma: return STAT_PLASMA;
328 case ammo_fuel: return STAT_FUEL;
334 string W_Sound(string w_snd)
336 string output = strcat("weapons/", w_snd, ".wav");
338 MUTATOR_CALLHOOK(WeaponSound, w_snd, output);
343 string W_Model(string w_mdl)
345 string output = strcat("models/weapons/", w_mdl);
347 MUTATOR_CALLHOOK(WeaponModel, w_mdl, output);