-
-/* replace items in minstagib
- * IT_STRENGTH = invisibility
- * IT_NAILS = extra lives
- * IT_INVINCIBLE = speed
- */
-void minstagib_items (float itemid) // will be deleted soon.
-{
- float rnd;
- self.classname = "minstagib"; // ...?
-
- // replace rocket launchers and nex guns with ammo cells
- if (itemid == IT_CELLS)
- {
- self.ammo_cells = autocvar_g_minstagib_ammo_drop;
- StartItem ("models/items/a_cells.md3",
- "misc/itempickup.wav", 45, 0,
- "MinstaNex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
- return;
- }
-
- // randomize
- rnd = random() * 3;
- if (rnd <= 1)
- itemid = IT_STRENGTH;
- else if (rnd <= 2)
- itemid = IT_NAILS;
- else
- itemid = IT_INVINCIBLE;
-
- // replace with invis
- if (itemid == IT_STRENGTH)
- {
- if(!self.strength_finished)
- self.strength_finished = autocvar_g_balance_powerup_strength_time;
- StartItem ("models/items/g_strength.md3",
- "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
- "Invisibility", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID);
- }
- // replace with extra lives
- if (itemid == IT_NAILS)
- {
- self.max_health = 1;
- StartItem ("models/items/g_h100.md3",
- "misc/megahealth.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
- "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
- }
- // replace with speed
- if (itemid == IT_INVINCIBLE)
- {
- if(!self.invincible_finished)
- self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
- StartItem ("models/items/g_invincible.md3",
- "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
- "Speed", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_MID);
- }
-}
-
-float minst_no_auto_cells;
-void minst_remove_item (void) {
- if(minst_no_auto_cells)
- remove(self);
-}
-
-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;
-
- // stupid minstagib hack, don't ask
- if(g_minstagib)
- if(self.ammo_cells)
- self.ammo_cells = autocvar_g_minstagib_ammo_drop;
-
- 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)
-{
- if (g_minstagib)
- {
- minstagib_items(IT_CELLS);
- self.think = minst_remove_item;
- self.nextthink = time;
- return;
- }
- weapon_defaultspawnfunc(WEP_NEX);
-}
-
-void spawnfunc_weapon_minstanex (void)
-{
- if (g_minstagib)
- {
- minstagib_items(IT_CELLS);
- self.think = minst_remove_item;
- self.nextthink = time;
- return;
- }
- weapon_defaultspawnfunc(WEP_MINSTANEX);
-}
-
-void spawnfunc_weapon_rocketlauncher (void)
-{
- if (g_minstagib)
- {
- minstagib_items(IT_CELLS); // replace rocketlauncher with cells
- self.think = minst_remove_item;
- self.nextthink = time;
- return;
- }
- weapon_defaultspawnfunc(WEP_ROCKET_LAUNCHER);
-}
-