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/common.qh"
13 #include "../../warpzonelib/client.qh"
15 #include "../buffs.qh"
16 #include "../../client/autocvars.qh"
17 #include "../deathtypes.qh"
18 #include "../../csqcmodellib/interpolate.qh"
19 #include "../movetypes/movetypes.qh"
20 #include "../../client/main.qh"
21 #include "../../csqcmodellib/cl_model.qh"
24 #include "../../dpdefs/progsdefs.qh"
25 #include "../../dpdefs/dpextensions.qh"
26 #include "../../warpzonelib/anglestransform.qh"
27 #include "../../warpzonelib/common.qh"
28 #include "../../warpzonelib/util_server.qh"
29 #include "../../warpzonelib/server.qh"
30 #include "../constants.qh"
31 #include "../stats.qh"
32 #include "../teams.qh"
34 #include "../buffs.qh"
35 #include "../monsters/all.qh"
37 #include "../../server/weapons/csqcprojectile.qh"
38 #include "../../server/weapons/tracing.qh"
39 #include "../../server/t_items.qh"
40 #include "../../server/autocvars.qh"
41 #include "../../server/constants.qh"
42 #include "../../server/defs.qh"
43 #include "../notifications.qh"
44 #include "../deathtypes.qh"
45 #include "../../server/mutators/mutators_include.qh"
46 #include "../mapinfo.qh"
47 #include "../../server/command/common.qh"
48 #include "../../csqcmodellib/sv_model.qh"
49 #include "../../server/portals.qh"
50 #include "../../server/g_hook.qh"
53 #include "calculations.qc"
55 #define IMPLEMENTATION
59 // WEAPON PLUGIN SYSTEM
62 # error Kein Weltraum links auf dem Gerät
65 WepSet WepSet_FromWeapon(int a) {
73 return '0 0 1' * power2of(a);
76 return '0 1 0' * power2of(a);
79 return '1 0 0' * power2of(a);
84 addstat(STAT_WEAPONS, AS_INT, weapons_x);
86 addstat(STAT_WEAPONS2, AS_INT, weapons_y);
88 addstat(STAT_WEAPONS3, AS_INT, weapons_z);
92 void WepSet_AddStat_InMap()
94 addstat(STAT_WEAPONSINMAP, AS_INT, weaponsinmap_x);
96 addstat(STAT_WEAPONSINMAP2, AS_INT, weaponsinmap_y);
98 addstat(STAT_WEAPONSINMAP3, AS_INT, weaponsinmap_z);
102 void WriteWepSet(float dst, WepSet w)
104 #if WEP_MAXCOUNT > 48
105 WriteInt72_t(dst, w);
106 #elif WEP_MAXCOUNT > 24
107 WriteInt48_t(dst, w);
109 WriteInt24_t(dst, w.x);
114 WepSet WepSet_GetFromStat()
117 w.x = getstati(STAT_WEAPONS);
118 #if WEP_MAXCOUNT > 24
119 w.y = getstati(STAT_WEAPONS2);
120 #if WEP_MAXCOUNT > 48
121 w.z = getstati(STAT_WEAPONS3);
126 WepSet WepSet_GetFromStat_InMap()
129 w_x = getstati(STAT_WEAPONSINMAP);
130 #if WEP_MAXCOUNT > 24
131 w_y = getstati(STAT_WEAPONSINMAP2);
132 #if WEP_MAXCOUNT > 48
133 w_z = getstati(STAT_WEAPONSINMAP3);
140 #if WEP_MAXCOUNT > 48
141 return ReadInt72_t();
142 #elif WEP_MAXCOUNT > 24
143 return ReadInt48_t();
145 return ReadInt24_t() * '1 0 0';
150 string W_FixWeaponOrder(string order, float complete)
152 return fixPriorityList(order, WEP_FIRST, WEP_LAST, WEP_IMPULSE_BEGIN - WEP_FIRST, complete);
154 string W_NameWeaponOrder_MapFunc(string s)
157 if(s == "0" || stof(s))
159 wi = get_weaponinfo(stof(s));
166 string W_UndeprecateName(string s)
170 case "nex" : return "vortex";
171 case "rocketlauncher" : return "devastator";
172 case "laser" : return "blaster";
173 case "minstanex" : return "vaporizer";
174 case "grenadelauncher": return "mortar";
175 case "uzi" : return "machinegun";
179 string W_NameWeaponOrder(string order)
181 return mapPriorityList(order, W_NameWeaponOrder_MapFunc);
183 string W_NumberWeaponOrder_MapFunc(string s)
186 if(s == "0" || stof(s))
188 s = W_UndeprecateName(s);
189 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
190 if(s == get_weaponinfo(i).netname)
194 string W_NumberWeaponOrder(string order)
196 return mapPriorityList(order, W_NumberWeaponOrder_MapFunc);
199 float W_FixWeaponOrder_BuildImpulseList_buf[WEP_MAXCOUNT];
200 string W_FixWeaponOrder_BuildImpulseList_order;
201 void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
204 h = W_FixWeaponOrder_BuildImpulseList_buf[i];
205 W_FixWeaponOrder_BuildImpulseList_buf[i] = W_FixWeaponOrder_BuildImpulseList_buf[j];
206 W_FixWeaponOrder_BuildImpulseList_buf[j] = h;
208 float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
212 e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
213 e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
214 d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
216 return -d; // high impulse first!
218 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
220 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
221 ; // low char index first!
223 string W_FixWeaponOrder_BuildImpulseList(string o)
226 W_FixWeaponOrder_BuildImpulseList_order = o;
227 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
228 W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST] = i;
229 heapsort(WEP_LAST - WEP_FIRST + 1, W_FixWeaponOrder_BuildImpulseList_swap, W_FixWeaponOrder_BuildImpulseList_cmp, world);
231 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
232 o = strcat(o, " ", ftos(W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST]));
233 W_FixWeaponOrder_BuildImpulseList_order = string_null;
234 return substring(o, 1, -1);
237 string W_FixWeaponOrder_AllowIncomplete(string order)
239 return W_FixWeaponOrder(order, 0);
242 string W_FixWeaponOrder_ForceComplete(string order)
245 order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
246 return W_FixWeaponOrder(order, 1);
249 void W_RandomWeapons(entity e, float n)
254 remaining = e.weapons;
256 for(i = 0; i < n; ++i)
258 RandomSelection_Init();
259 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
260 if(remaining & WepSet_FromWeapon(j))
261 RandomSelection_Add(world, j, string_null, 1, 1);
262 result |= WepSet_FromWeapon(RandomSelection_chosen_float);
263 remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
268 string GetAmmoPicture(.int ammotype)
272 case ammo_shells: return ITEM_Shells.m_icon;
273 case ammo_nails: return ITEM_Bullets.m_icon;
274 case ammo_rockets: return ITEM_Rockets.m_icon;
275 case ammo_cells: return ITEM_Cells.m_icon;
276 case ammo_plasma: return ITEM_Plasma.m_icon;
277 case ammo_fuel: return ITEM_JetpackFuel.m_icon;
278 default: return ""; // wtf, no ammo type?
283 .int GetAmmoFieldFromNum(int i)
287 case 0: return ammo_shells;
288 case 1: return ammo_nails;
289 case 2: return ammo_rockets;
290 case 3: return ammo_cells;
291 case 4: return ammo_plasma;
292 case 5: return ammo_fuel;
293 default: return ammo_none;
297 int GetAmmoStat(.int ammotype)
301 case ammo_shells: return STAT_SHELLS;
302 case ammo_nails: return STAT_NAILS;
303 case ammo_rockets: return STAT_ROCKETS;
304 case ammo_cells: return STAT_CELLS;
305 case ammo_plasma: return STAT_PLASMA;
306 case ammo_fuel: return STAT_FUEL;
312 string W_Sound(string w_snd)
314 #define extensions(X) X(wav) X(ogg)
315 #define tryext(ext) { if (fexists(strcat("sound/", output = strcat("weapons/", w_snd, "."#ext)))) break; }
321 output = strcat("weapons/", w_snd);
325 MUTATOR_CALLHOOK(WeaponSound, w_snd, output);
326 return weapon_sound_output;
332 string W_Model(string w_mdl)
334 string output = strcat("models/weapons/", w_mdl);
336 MUTATOR_CALLHOOK(WeaponModel, w_mdl, output);
337 return weapon_model_output;