4 #include "../../dpdefs/progsdefs.qc"
5 #include "../../dpdefs/dpextensions.qc"
6 #include "../sys-post.qh"
7 #include "../../common/weapons/weapons.qh"
9 #include "weaponsystem.qh"
10 #include "../t_items.qh"
11 #include "../autocvars.qh"
12 #include "../constants.qh"
14 #include "../mutators/mutators_include.qh"
17 string W_Apply_Weaponreplace(string in)
19 float n = tokenize_console(in);
20 string out = "", s, replacement;
23 for(i = 0; i < n; ++i)
28 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
30 e = get_weaponinfo(j);
33 replacement = e.weaponreplace;
38 out = strcat(out, " ", s);
39 else if(replacement != "0")
40 out = strcat(out, " ", replacement);
42 return substring(out, 1, -1);
45 void weapon_defaultspawnfunc(float wpn)
54 if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
56 e = get_weaponinfo(wpn);
58 if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
60 objerror("Attempted to spawn a mutator-blocked weapon rejected");
61 startitem_failed = true;
65 s = W_Apply_Weaponreplace(e.netname);
68 MUTATOR_CALLHOOK(SetWeaponreplace);
73 startitem_failed = true;
76 t = tokenize_console(s);
79 self.team = --internalteam;
81 for(i = 1; i < t; ++i)
84 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
86 e = get_weaponinfo(j);
90 copyentity(oldself, self);
91 self.classname = "replacedweapon";
92 weapon_defaultspawnfunc(j);
98 print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
103 if(t >= 1) // always the case!
107 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
109 e = get_weaponinfo(j);
118 print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
124 startitem_failed = true;
129 e = get_weaponinfo(wpn);
131 if(!self.respawntime)
133 if(e.weapons & WEPSET_SUPERWEAPONS)
135 self.respawntime = g_pickup_respawntime_superweapon;
136 self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
140 self.respawntime = g_pickup_respawntime_weapon;
141 self.respawntimejitter = g_pickup_respawntimejitter_weapon;
145 if(e.weapons & WEPSET_SUPERWEAPONS)
146 if(!self.superweapons_finished)
147 self.superweapons_finished = autocvar_g_balance_superweapons_time;
149 // if we don't already have ammo, give us some ammo
150 if(!self.(e.ammo_field))
154 case ammo_shells: self.ammo_shells = cvar("g_pickup_shells_weapon"); break;
155 case ammo_nails: self.ammo_nails = cvar("g_pickup_nails_weapon"); break;
156 case ammo_rockets: self.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
157 case ammo_cells: self.ammo_cells = cvar("g_pickup_cells_weapon"); break;
158 case ammo_plasma: self.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
159 case ammo_fuel: self.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
166 for(i = 0, j = 1; i < 24; ++i, j *= 2)
170 ammotype = Item_CounterField(j);
172 self.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
179 if(g_pickup_weapons_anyway)
180 self.pickup_anyway = true;
184 // no weapon-stay on superweapons
185 if(e.weapons & WEPSET_SUPERWEAPONS)
186 f |= FL_NO_WEAPON_STAY;
188 // weapon stay isn't supported for teamed weapons
190 f |= FL_NO_WEAPON_STAY;
192 StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
194 if (self.modelindex) // don't precache if self was removed
195 WEP_ACTION(e.weapon, WR_INIT);