4 #include "../../dpdefs/progsdefs.qh"
5 #include "../../dpdefs/dpextensions.qh"
6 #include "../../common/weapons/weapons.qh"
8 #include "weaponsystem.qh"
9 #include "../t_items.qh"
10 #include "../autocvars.qh"
11 #include "../constants.qh"
13 #include "../mutators/mutators_include.qh"
16 string W_Apply_Weaponreplace(string in)
18 float n = tokenize_console(in);
19 string out = "", s, replacement;
22 for(i = 0; i < n; ++i)
27 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
29 e = get_weaponinfo(j);
32 replacement = e.weaponreplace;
37 out = strcat(out, " ", s);
38 else if(replacement != "0")
39 out = strcat(out, " ", replacement);
41 return substring(out, 1, -1);
44 void weapon_defaultspawnfunc(float wpn)
53 if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
55 e = get_weaponinfo(wpn);
57 if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
59 objerror("Attempted to spawn a mutator-blocked weapon rejected");
60 startitem_failed = true;
64 s = W_Apply_Weaponreplace(e.netname);
67 MUTATOR_CALLHOOK(SetWeaponreplace);
72 startitem_failed = true;
75 t = tokenize_console(s);
78 self.team = --internalteam;
80 for(i = 1; i < t; ++i)
83 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
85 e = get_weaponinfo(j);
89 copyentity(oldself, self);
90 self.classname = "replacedweapon";
91 weapon_defaultspawnfunc(j);
97 print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
102 if(t >= 1) // always the case!
106 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
108 e = get_weaponinfo(j);
117 print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
123 startitem_failed = true;
128 e = get_weaponinfo(wpn);
130 if(!self.respawntime)
132 if(e.weapons & WEPSET_SUPERWEAPONS)
134 self.respawntime = g_pickup_respawntime_superweapon;
135 self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
139 self.respawntime = g_pickup_respawntime_weapon;
140 self.respawntimejitter = g_pickup_respawntimejitter_weapon;
144 if(e.weapons & WEPSET_SUPERWEAPONS)
145 if(!self.superweapons_finished)
146 self.superweapons_finished = autocvar_g_balance_superweapons_time;
148 // if we don't already have ammo, give us some ammo
149 if(!self.(e.ammo_field))
153 case ammo_shells: self.ammo_shells = cvar("g_pickup_shells_weapon"); break;
154 case ammo_nails: self.ammo_nails = cvar("g_pickup_nails_weapon"); break;
155 case ammo_rockets: self.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
156 case ammo_cells: self.ammo_cells = cvar("g_pickup_cells_weapon"); break;
157 case ammo_plasma: self.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
158 case ammo_fuel: self.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
165 for(i = 0, j = 1; i < 24; ++i, j *= 2)
169 ammotype = Item_CounterField(j);
171 self.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
178 if(g_pickup_weapons_anyway)
179 self.pickup_anyway = true;
183 // no weapon-stay on superweapons
184 if(e.weapons & WEPSET_SUPERWEAPONS)
185 f |= FL_NO_WEAPON_STAY;
187 // weapon stay isn't supported for teamed weapons
189 f |= FL_NO_WEAPON_STAY;
191 StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
193 if (self.modelindex) // don't precache if self was removed
194 WEP_ACTION(e.weapon, WR_INIT);