7 #include "../../client/defs.qh"
8 #include "../constants.qh"
10 #include "../../lib/warpzone/anglestransform.qh"
11 #include "../../lib/warpzone/common.qh"
12 #include "../../lib/warpzone/client.qh"
14 #include "../../client/autocvars.qh"
15 #include "../deathtypes/all.qh"
16 #include "../../lib/csqcmodel/interpolate.qh"
17 #include "../movetypes/movetypes.qh"
18 #include "../../client/main.qh"
19 #include "../../lib/csqcmodel/cl_model.qh"
22 #include "../../lib/warpzone/anglestransform.qh"
23 #include "../../lib/warpzone/common.qh"
24 #include "../../lib/warpzone/util_server.qh"
25 #include "../../lib/warpzone/server.qh"
26 #include "../constants.qh"
27 #include "../stats.qh"
28 #include "../teams.qh"
30 #include "../monsters/all.qh"
32 #include "../../server/weapons/csqcprojectile.qh"
33 #include "../../server/weapons/tracing.qh"
34 #include "../../server/t_items.qh"
35 #include "../../server/autocvars.qh"
36 #include "../../server/constants.qh"
37 #include "../../server/defs.qh"
38 #include "../notifications.qh"
39 #include "../deathtypes/all.qh"
40 #include "../../server/mutators/all.qh"
41 #include "../mapinfo.qh"
42 #include "../../server/command/common.qh"
43 #include "../../lib/csqcmodel/sv_model.qh"
44 #include "../../server/portals.qh"
45 #include "../../server/g_hook.qh"
48 #include "calculations.qc"
50 #define IMPLEMENTATION
54 // WEAPON PLUGIN SYSTEM
56 WepSet _WepSet_FromWeapon(int a) {
64 return '0 0 1' * power2of(a);
66 return '0 1 0' * power2of(a);
68 return '1 0 0' * power2of(a);
73 addstat(STAT_WEAPONS, AS_INT, weapons_x);
75 addstat(STAT_WEAPONS2, AS_INT, weapons_y);
77 addstat(STAT_WEAPONS3, AS_INT, weapons_z);
79 void WepSet_AddStat_InMap()
81 addstat(STAT_WEAPONSINMAP, AS_INT, weaponsinmap_x);
83 addstat(STAT_WEAPONSINMAP2, AS_INT, weaponsinmap_y);
85 addstat(STAT_WEAPONSINMAP3, AS_INT, weaponsinmap_z);
87 void WriteWepSet(float dst, WepSet w)
91 else if (Weapons_MAX > 24)
94 WriteInt24_t(dst, w.x);
98 WepSet WepSet_GetFromStat()
101 w.x = getstati(STAT_WEAPONS);
102 if (Weapons_MAX > 24)
103 w.y = getstati(STAT_WEAPONS2);
104 if (Weapons_MAX > 48)
105 w.z = getstati(STAT_WEAPONS3);
108 WepSet WepSet_GetFromStat_InMap()
111 w_x = getstati(STAT_WEAPONSINMAP);
112 if (Weapons_MAX > 24)
113 w_y = getstati(STAT_WEAPONSINMAP2);
114 if (Weapons_MAX > 48)
115 w_z = getstati(STAT_WEAPONSINMAP3);
120 if (Weapons_MAX > 48)
121 return ReadInt72_t();
122 if (Weapons_MAX > 24)
123 return ReadInt48_t();
124 return ReadInt24_t() * '1 0 0';
128 string W_FixWeaponOrder(string order, float complete)
130 return fixPriorityList(order, WEP_FIRST, WEP_LAST, WEP_IMPULSE_BEGIN - WEP_FIRST, complete);
132 string W_NameWeaponOrder_MapFunc(string s)
135 if(s == "0" || stof(s))
137 wi = get_weaponinfo(stof(s));
144 string W_UndeprecateName(string s)
148 case "nex" : return "vortex";
149 case "rocketlauncher" : return "devastator";
150 case "laser" : return "blaster";
151 case "minstanex" : return "vaporizer";
152 case "grenadelauncher": return "mortar";
153 case "uzi" : return "machinegun";
157 string W_NameWeaponOrder(string order)
159 return mapPriorityList(order, W_NameWeaponOrder_MapFunc);
161 string W_NumberWeaponOrder_MapFunc(string s)
164 if(s == "0" || stof(s))
166 s = W_UndeprecateName(s);
167 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
168 if(s == get_weaponinfo(i).netname)
172 string W_NumberWeaponOrder(string order)
174 return mapPriorityList(order, W_NumberWeaponOrder_MapFunc);
177 float W_FixWeaponOrder_BuildImpulseList_buf[Weapons_MAX];
178 string W_FixWeaponOrder_BuildImpulseList_order;
179 void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
182 h = W_FixWeaponOrder_BuildImpulseList_buf[i];
183 W_FixWeaponOrder_BuildImpulseList_buf[i] = W_FixWeaponOrder_BuildImpulseList_buf[j];
184 W_FixWeaponOrder_BuildImpulseList_buf[j] = h;
186 float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
190 e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
191 e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
192 d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
194 return -d; // high impulse first!
196 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
198 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
199 ; // low char index first!
201 string W_FixWeaponOrder_BuildImpulseList(string o)
204 W_FixWeaponOrder_BuildImpulseList_order = o;
205 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
206 W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST] = i;
207 heapsort(WEP_LAST - WEP_FIRST + 1, W_FixWeaponOrder_BuildImpulseList_swap, W_FixWeaponOrder_BuildImpulseList_cmp, world);
209 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
210 o = strcat(o, " ", ftos(W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST]));
211 W_FixWeaponOrder_BuildImpulseList_order = string_null;
212 return substring(o, 1, -1);
215 string W_FixWeaponOrder_AllowIncomplete(string order)
217 return W_FixWeaponOrder(order, 0);
220 string W_FixWeaponOrder_ForceComplete(string order)
223 order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
224 return W_FixWeaponOrder(order, 1);
227 void W_RandomWeapons(entity e, float n)
232 remaining = e.weapons;
234 for(i = 0; i < n; ++i)
236 RandomSelection_Init();
237 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
238 if(remaining & WepSet_FromWeapon(j))
239 RandomSelection_Add(world, j, string_null, 1, 1);
240 result |= WepSet_FromWeapon(RandomSelection_chosen_float);
241 remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
246 string GetAmmoPicture(.int ammotype)
250 case ammo_shells: return ITEM_Shells.m_icon;
251 case ammo_nails: return ITEM_Bullets.m_icon;
252 case ammo_rockets: return ITEM_Rockets.m_icon;
253 case ammo_cells: return ITEM_Cells.m_icon;
254 case ammo_plasma: return ITEM_Plasma.m_icon;
255 case ammo_fuel: return ITEM_JetpackFuel.m_icon;
256 default: return ""; // wtf, no ammo type?
261 .int GetAmmoFieldFromNum(int i)
265 case 0: return ammo_shells;
266 case 1: return ammo_nails;
267 case 2: return ammo_rockets;
268 case 3: return ammo_cells;
269 case 4: return ammo_plasma;
270 case 5: return ammo_fuel;
271 default: return ammo_none;
275 int GetAmmoStat(.int ammotype)
279 case ammo_shells: return STAT_SHELLS;
280 case ammo_nails: return STAT_NAILS;
281 case ammo_rockets: return STAT_ROCKETS;
282 case ammo_cells: return STAT_CELLS;
283 case ammo_plasma: return STAT_PLASMA;
284 case ammo_fuel: return STAT_FUEL;
290 string W_Sound(string w_snd)
292 string output = strcat("weapons/", w_snd);
294 MUTATOR_CALLHOOK(WeaponSound, w_snd, output);
295 return weapon_sound_output;
301 string W_Model(string w_mdl)
303 string output = strcat("models/weapons/", w_mdl);
305 MUTATOR_CALLHOOK(WeaponModel, w_mdl, output);
306 return weapon_model_output;