-float weaponswapping;
-float internalteam;
-
-void weapon_defaultspawnfunc(float wpn)
-{
- entity e;
- float t;
- var .float ammofield;
- string s;
- entity oldself;
- float i, j;
- float f;
-
- if(self.classname != "droppedweapon" && self.classname != "replacedweapon")
- {
- e = get_weaponinfo(wpn);
-
- if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
- {
- print("Attempted to spawn a mutator-blocked weapon; these guns will in the future require a mutator\n");
- /*
- objerror("Attempted to spawn a mutator-blocked weapon rejected");
- startitem_failed = TRUE;
- return;
- */
- }
-
- s = W_Apply_Weaponreplace(e.netname);
- ret_string = s;
- other = e;
- MUTATOR_CALLHOOK(SetWeaponreplace);
- s = ret_string;
- if(s == "")
- {
- remove(self);
- startitem_failed = TRUE;
- return;
- }
- t = tokenize_console(s);
- if(t >= 2)
- {
- self.team = --internalteam;
- oldself = self;
- for(i = 1; i < t; ++i)
- {
- s = argv(i);
- for(j = WEP_FIRST; j <= WEP_LAST; ++j)
- {
- e = get_weaponinfo(j);
- if(e.netname == s)
- {
- self = spawn();
- copyentity(oldself, self);
- self.classname = "replacedweapon";
- weapon_defaultspawnfunc(j);
- break;
- }
- }
- if(j > WEP_LAST)
- {
- print("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
- }
- }
- self = oldself;
- }
- if(t >= 1) // always the case!
- {
- s = argv(0);
- wpn = 0;
- for(j = WEP_FIRST; j <= WEP_LAST; ++j)
- {
- e = get_weaponinfo(j);
- if(e.netname == s)
- {
- wpn = j;
- break;
- }
- }
- if(j > WEP_LAST)
- {
- print("The weapon replace list for ", self.classname, " contains an unknown weapon ", s, ". Skipped.\n");
- }
- }
- if(wpn == 0)
- {
- remove(self);
- startitem_failed = TRUE;
- return;
- }
- }
-
- e = get_weaponinfo(wpn);
-
- if(!self.respawntime)
- {
- if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
- {
- self.respawntime = g_pickup_respawntime_superweapon;
- self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
- }
- else
- {
- self.respawntime = g_pickup_respawntime_weapon;
- self.respawntimejitter = g_pickup_respawntimejitter_weapon;
- }
- }
-
- if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
- if(!self.superweapons_finished)
- self.superweapons_finished = autocvar_g_balance_superweapons_time;
-
- if(e.items)
- {
- for(i = 0, j = 1; i < 24; ++i, j *= 2)
- {
- if(e.items & j)
- {
- ammofield = Item_CounterField(j);
- if(!self.ammofield)
- self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
- }
- }
- }
-
- // pickup anyway
- if(g_pickup_weapons_anyway)
- self.pickup_anyway = TRUE;
-
- f = FL_WEAPON;
-
- // no weapon-stay on superweapons
- if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
- f |= FL_NO_WEAPON_STAY;
-
- // weapon stay isn't supported for teamed weapons
- if(self.team)
- f |= FL_NO_WEAPON_STAY;
-
- StartItem(e.model, "weapons/weaponpickup.wav", self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue);
- if (self.modelindex) // don't precache if self was removed
- weapon_action(e.weapon, WR_PRECACHE);
-}
-
-void spawnfunc_weapon_shotgun (void);
-void spawnfunc_weapon_uzi (void) {
- if(autocvar_sv_q3acompat_machineshotgunswap)
- if(self.classname != "droppedweapon")
- {
- weapon_defaultspawnfunc(WEP_SHOTGUN);
- return;
- }
- weapon_defaultspawnfunc(WEP_UZI);
-}
-
-void spawnfunc_weapon_shotgun (void) {
- if(autocvar_sv_q3acompat_machineshotgunswap)
- if(self.classname != "droppedweapon")
- {
- weapon_defaultspawnfunc(WEP_UZI);
- return;
- }
- weapon_defaultspawnfunc(WEP_SHOTGUN);
-}
-
-void spawnfunc_weapon_nex (void)
-{
- weapon_defaultspawnfunc(WEP_NEX);
-}
-
-void spawnfunc_weapon_minstanex (void)
-{
- weapon_defaultspawnfunc(WEP_MINSTANEX);
-}
-