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 "../buffs/all.qh"
15 #include "../../client/autocvars.qh"
16 #include "../deathtypes/all.qh"
17 #include "../../lib/csqcmodel/interpolate.qh"
18 #include "../movetypes/movetypes.qh"
19 #include "../../client/main.qh"
20 #include "../../lib/csqcmodel/cl_model.qh"
23 #include "../../lib/warpzone/anglestransform.qh"
24 #include "../../lib/warpzone/common.qh"
25 #include "../../lib/warpzone/util_server.qh"
26 #include "../../lib/warpzone/server.qh"
27 #include "../constants.qh"
28 #include "../stats.qh"
29 #include "../teams.qh"
31 #include "../buffs/all.qh"
32 #include "../monsters/all.qh"
34 #include "../../server/weapons/csqcprojectile.qh"
35 #include "../../server/weapons/tracing.qh"
36 #include "../../server/t_items.qh"
37 #include "../../server/autocvars.qh"
38 #include "../../server/constants.qh"
39 #include "../../server/defs.qh"
40 #include "../notifications.qh"
41 #include "../deathtypes/all.qh"
42 #include "../../server/mutators/all.qh"
43 #include "../mapinfo.qh"
44 #include "../../server/command/common.qh"
45 #include "../../lib/csqcmodel/sv_model.qh"
46 #include "../../server/portals.qh"
47 #include "../../server/g_hook.qh"
50 #include "calculations.qc"
52 #define IMPLEMENTATION
56 // WEAPON PLUGIN SYSTEM
58 WepSet WepSet_FromWeapon(int a) {
66 return '0 0 1' * power2of(a);
68 return '0 1 0' * power2of(a);
70 return '1 0 0' * power2of(a);
73 void WriteWepSet(float dst, WepSet w)
77 else if (Weapons_MAX > 24)
80 WriteInt24_t(dst, w.x);
84 WepSet WepSet_GetFromStat()
88 WepSet WepSet_GetFromStat_InMap()
90 return STAT(WEAPONSINMAP);
98 return ReadInt24_t() * '1 0 0';
102 string W_FixWeaponOrder(string order, float complete)
104 return fixPriorityList(order, WEP_FIRST, WEP_LAST, WEP_IMPULSE_BEGIN - WEP_FIRST, complete);
106 string W_NameWeaponOrder_MapFunc(string s)
109 if(s == "0" || stof(s))
111 wi = get_weaponinfo(stof(s));
118 string W_UndeprecateName(string s)
122 case "nex" : return "vortex";
123 case "rocketlauncher" : return "devastator";
124 case "laser" : return "blaster";
125 case "minstanex" : return "vaporizer";
126 case "grenadelauncher": return "mortar";
127 case "uzi" : return "machinegun";
131 string W_NameWeaponOrder(string order)
133 return mapPriorityList(order, W_NameWeaponOrder_MapFunc);
135 string W_NumberWeaponOrder_MapFunc(string s)
138 if(s == "0" || stof(s))
140 s = W_UndeprecateName(s);
141 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
142 if(s == get_weaponinfo(i).netname)
146 string W_NumberWeaponOrder(string order)
148 return mapPriorityList(order, W_NumberWeaponOrder_MapFunc);
151 float W_FixWeaponOrder_BuildImpulseList_buf[Weapons_MAX];
152 string W_FixWeaponOrder_BuildImpulseList_order;
153 void W_FixWeaponOrder_BuildImpulseList_swap(int i, int j, entity pass)
156 h = W_FixWeaponOrder_BuildImpulseList_buf[i];
157 W_FixWeaponOrder_BuildImpulseList_buf[i] = W_FixWeaponOrder_BuildImpulseList_buf[j];
158 W_FixWeaponOrder_BuildImpulseList_buf[j] = h;
160 float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
164 e1 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[i]);
165 e2 = get_weaponinfo(W_FixWeaponOrder_BuildImpulseList_buf[j]);
166 d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
168 return -d; // high impulse first!
170 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[i]), 0)
172 strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), sprintf(" %d ", W_FixWeaponOrder_BuildImpulseList_buf[j]), 0)
173 ; // low char index first!
175 string W_FixWeaponOrder_BuildImpulseList(string o)
178 W_FixWeaponOrder_BuildImpulseList_order = o;
179 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
180 W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST] = i;
181 heapsort(WEP_LAST - WEP_FIRST + 1, W_FixWeaponOrder_BuildImpulseList_swap, W_FixWeaponOrder_BuildImpulseList_cmp, world);
183 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
184 o = strcat(o, " ", ftos(W_FixWeaponOrder_BuildImpulseList_buf[i - WEP_FIRST]));
185 W_FixWeaponOrder_BuildImpulseList_order = string_null;
186 return substring(o, 1, -1);
189 string W_FixWeaponOrder_AllowIncomplete(string order)
191 return W_FixWeaponOrder(order, 0);
194 string W_FixWeaponOrder_ForceComplete(string order)
197 order = W_NumberWeaponOrder(cvar_defstring("cl_weaponpriority"));
198 return W_FixWeaponOrder(order, 1);
201 void W_RandomWeapons(entity e, float n)
206 remaining = e.weapons;
208 for(i = 0; i < n; ++i)
210 RandomSelection_Init();
211 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
212 if(remaining & WepSet_FromWeapon(j))
213 RandomSelection_Add(world, j, string_null, 1, 1);
214 result |= WepSet_FromWeapon(RandomSelection_chosen_float);
215 remaining &= ~WepSet_FromWeapon(RandomSelection_chosen_float);
220 string GetAmmoPicture(.int ammotype)
224 case ammo_shells: return ITEM_Shells.m_icon;
225 case ammo_nails: return ITEM_Bullets.m_icon;
226 case ammo_rockets: return ITEM_Rockets.m_icon;
227 case ammo_cells: return ITEM_Cells.m_icon;
228 case ammo_plasma: return ITEM_Plasma.m_icon;
229 case ammo_fuel: return ITEM_JetpackFuel.m_icon;
230 default: return ""; // wtf, no ammo type?
235 .int GetAmmoFieldFromNum(int i)
239 case 0: return ammo_shells;
240 case 1: return ammo_nails;
241 case 2: return ammo_rockets;
242 case 3: return ammo_cells;
243 case 4: return ammo_plasma;
244 case 5: return ammo_fuel;
245 default: return ammo_none;
249 int GetAmmoStat(.int ammotype)
253 case ammo_shells: return STAT_SHELLS;
254 case ammo_nails: return STAT_NAILS;
255 case ammo_rockets: return STAT_ROCKETS;
256 case ammo_cells: return STAT_CELLS;
257 case ammo_plasma: return STAT_PLASMA.m_id;
258 case ammo_fuel: return STAT_FUEL.m_id;
264 string W_Sound(string w_snd)
266 string output = strcat("weapons/", w_snd);
268 MUTATOR_CALLHOOK(WeaponSound, w_snd, output);
269 return weapon_sound_output;
275 string W_Model(string w_mdl)
277 string output = strcat("models/weapons/", w_mdl);
279 MUTATOR_CALLHOOK(WeaponModel, w_mdl, output);
280 return weapon_model_output;