4 #include "weaponsystem.qh"
5 #include "../mutators/mutators_include.qh"
6 #include "../t_items.qh"
7 #include "../../common/weapons/all.qh"
9 string W_Apply_Weaponreplace(string in)
11 float n = tokenize_console(in);
12 string out = "", s, replacement;
15 for(i = 0; i < n; ++i)
20 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
22 e = get_weaponinfo(j);
25 replacement = e.weaponreplace;
30 out = strcat(out, " ", s);
31 else if(replacement != "0")
32 out = strcat(out, " ", replacement);
34 return substring(out, 1, -1);
37 void weapon_defaultspawnfunc(float wpn)
46 if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
48 e = get_weaponinfo(wpn);
50 if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
52 objerror("Attempted to spawn a mutator-blocked weapon rejected");
53 startitem_failed = true;
57 s = W_Apply_Weaponreplace(e.netname);
58 MUTATOR_CALLHOOK(SetWeaponreplace, self, e, s);
63 startitem_failed = true;
66 t = tokenize_console(s);
69 self.team = --internalteam;
71 for(i = 1; i < t; ++i)
74 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
76 e = get_weaponinfo(j);
80 copyentity(oldself, self);
81 self.classname = "replacedweapon";
82 weapon_defaultspawnfunc(j);
88 print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
93 if(t >= 1) // always the case!
97 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
99 e = get_weaponinfo(j);
108 print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
114 startitem_failed = true;
119 e = get_weaponinfo(wpn);
121 if(!self.respawntime)
123 if(e.weapons & WEPSET_SUPERWEAPONS)
125 self.respawntime = g_pickup_respawntime_superweapon;
126 self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
130 self.respawntime = g_pickup_respawntime_weapon;
131 self.respawntimejitter = g_pickup_respawntimejitter_weapon;
135 if(e.weapons & WEPSET_SUPERWEAPONS)
136 if(!self.superweapons_finished)
137 self.superweapons_finished = autocvar_g_balance_superweapons_time;
139 // if we don't already have ammo, give us some ammo
140 if(!self.(e.ammo_field))
144 case ammo_shells: self.ammo_shells = cvar("g_pickup_shells_weapon"); break;
145 case ammo_nails: self.ammo_nails = cvar("g_pickup_nails_weapon"); break;
146 case ammo_rockets: self.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
147 case ammo_cells: self.ammo_cells = cvar("g_pickup_cells_weapon"); break;
148 case ammo_plasma: self.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
149 case ammo_fuel: self.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
156 for(i = 0, j = 1; i < 24; ++i, j *= 2)
160 ammotype = Item_CounterField(j);
162 self.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
169 if(g_pickup_weapons_anyway)
170 self.pickup_anyway = true;
174 // no weapon-stay on superweapons
175 if(e.weapons & WEPSET_SUPERWEAPONS)
176 f |= FL_NO_WEAPON_STAY;
178 // weapon stay isn't supported for teamed weapons
180 f |= FL_NO_WEAPON_STAY;
182 StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
184 if (self.modelindex) // don't precache if self was removed
185 WEP_ACTION(e.weapon, WR_INIT);