1 string W_Apply_Weaponreplace(string in)
3 float n = tokenize_console(in);
4 string out = "", s, replacement;
12 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
14 e = get_weaponinfo(j);
17 replacement = e.weaponreplace;
22 out = strcat(out, " ", s);
23 else if(replacement != "0")
24 out = strcat(out, " ", replacement);
26 return substring(out, 1, -1);
29 void weapon_defaultspawnfunc(float wpn)
38 if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
40 e = get_weaponinfo(wpn);
42 if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
44 objerror("Attempted to spawn a mutator-blocked weapon rejected");
45 startitem_failed = TRUE;
49 s = W_Apply_Weaponreplace(e.netname);
52 MUTATOR_CALLHOOK(SetWeaponreplace);
57 startitem_failed = TRUE;
60 t = tokenize_console(s);
63 self.team = --internalteam;
65 for(i = 1; i < t; ++i)
68 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
70 e = get_weaponinfo(j);
74 copyentity(oldself, self);
75 self.classname = "replacedweapon";
76 weapon_defaultspawnfunc(j);
82 print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
87 if(t >= 1) // always the case!
91 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
93 e = get_weaponinfo(j);
102 print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
108 startitem_failed = TRUE;
113 e = get_weaponinfo(wpn);
115 if(!self.respawntime)
117 if(e.weapons & WEPSET_SUPERWEAPONS)
119 self.respawntime = g_pickup_respawntime_superweapon;
120 self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
124 self.respawntime = g_pickup_respawntime_weapon;
125 self.respawntimejitter = g_pickup_respawntimejitter_weapon;
129 if(e.weapons & WEPSET_SUPERWEAPONS)
130 if(!self.superweapons_finished)
131 self.superweapons_finished = autocvar_g_balance_superweapons_time;
133 // if we don't already have ammo, give us some ammo
134 if(!self.(e.ammo_field))
138 case ammo_shells: self.ammo_shells = cvar("g_pickup_shells_weapon"); break;
139 case ammo_nails: self.ammo_nails = cvar("g_pickup_nails_weapon"); break;
140 case ammo_rockets: self.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
141 case ammo_cells: self.ammo_cells = cvar("g_pickup_cells_weapon"); break;
142 case ammo_plasma: self.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
143 case ammo_fuel: self.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
150 for(i = 0, j = 1; i < 24; ++i, j *= 2)
154 ammotype = Item_CounterField(j);
156 self.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
163 if(g_pickup_weapons_anyway)
164 self.pickup_anyway = TRUE;
168 // no weapon-stay on superweapons
169 if(e.weapons & WEPSET_SUPERWEAPONS)
170 f |= FL_NO_WEAPON_STAY;
172 // weapon stay isn't supported for teamed weapons
174 f |= FL_NO_WEAPON_STAY;
176 StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
178 if (self.modelindex) // don't precache if self was removed
179 WEP_ACTION(e.weapon, WR_INIT);