4 #include "weaponsystem.qh"
5 #include "../mutators/mutators_include.qh"
6 #include "../t_items.qh"
7 #include "../../common/weapons/weapons.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);
60 MUTATOR_CALLHOOK(SetWeaponreplace);
65 startitem_failed = true;
68 t = tokenize_console(s);
71 self.team = --internalteam;
73 for(i = 1; i < t; ++i)
76 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
78 e = get_weaponinfo(j);
82 copyentity(oldself, self);
83 self.classname = "replacedweapon";
84 weapon_defaultspawnfunc(j);
90 print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
95 if(t >= 1) // always the case!
99 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
101 e = get_weaponinfo(j);
110 print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
116 startitem_failed = true;
121 e = get_weaponinfo(wpn);
123 if(!self.respawntime)
125 if(e.weapons & WEPSET_SUPERWEAPONS)
127 self.respawntime = g_pickup_respawntime_superweapon;
128 self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
132 self.respawntime = g_pickup_respawntime_weapon;
133 self.respawntimejitter = g_pickup_respawntimejitter_weapon;
137 if(e.weapons & WEPSET_SUPERWEAPONS)
138 if(!self.superweapons_finished)
139 self.superweapons_finished = autocvar_g_balance_superweapons_time;
141 // if we don't already have ammo, give us some ammo
142 if(!self.(e.ammo_field))
146 case ammo_shells: self.ammo_shells = cvar("g_pickup_shells_weapon"); break;
147 case ammo_nails: self.ammo_nails = cvar("g_pickup_nails_weapon"); break;
148 case ammo_rockets: self.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
149 case ammo_cells: self.ammo_cells = cvar("g_pickup_cells_weapon"); break;
150 case ammo_plasma: self.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
151 case ammo_fuel: self.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
158 for(i = 0, j = 1; i < 24; ++i, j *= 2)
162 ammotype = Item_CounterField(j);
164 self.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
171 if(g_pickup_weapons_anyway)
172 self.pickup_anyway = true;
176 // no weapon-stay on superweapons
177 if(e.weapons & WEPSET_SUPERWEAPONS)
178 f |= FL_NO_WEAPON_STAY;
180 // weapon stay isn't supported for teamed weapons
182 f |= FL_NO_WEAPON_STAY;
184 StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
186 if (self.modelindex) // don't precache if self was removed
187 WEP_ACTION(e.weapon, WR_INIT);