3 #include "weaponsystem.qh"
4 #include "../mutators/_mod.qh"
5 #include <common/t_items.qh>
6 #include <common/weapons/_all.qh>
8 string W_Apply_Weaponreplace(string in)
11 FOREACH_WORD(in, true, {
12 string replacement = "";
13 Weapon w = Weapons_fromstr(it);
16 replacement = w.weaponreplace;
17 if (replacement == "") replacement = it;
19 if (replacement == "0") continue;
20 out = cons(out, replacement);
25 void weapon_defaultspawnfunc(entity this, Weapon e)
28 if (this.classname != "droppedweapon" && this.classname != "replacedweapon")
30 if (e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
32 LOG_WARNF("Attempted to spawn a mutator-blocked weapon rejected: prvm_edict server %i", this);
33 startitem_failed = true;
37 string s = W_Apply_Weaponreplace(e.netname);
38 MUTATOR_CALLHOOK(SetWeaponreplace, this, e, s);
39 s = M_ARGV(2, string);
43 startitem_failed = true;
46 int t = tokenize_console(s);
49 this.team = --internalteam;
50 for (int i = 1; i < t; ++i)
53 FOREACH(Weapons, it != WEP_Null, LAMBDA(
56 entity replacement = spawn();
57 copyentity(this, replacement);
58 replacement.classname = "replacedweapon";
59 weapon_defaultspawnfunc(replacement, it);
65 if (t >= 1) // always the case!
69 FOREACH(Weapons, it != WEP_Null, LAMBDA(
80 startitem_failed = true;
85 if (!this.respawntime)
87 if (wpn.spawnflags & WEP_FLAG_SUPERWEAPON)
89 this.respawntime = g_pickup_respawntime_superweapon;
90 this.respawntimejitter = g_pickup_respawntimejitter_superweapon;
94 this.respawntime = g_pickup_respawntime_weapon;
95 this.respawntimejitter = g_pickup_respawntimejitter_weapon;
99 if (wpn.spawnflags & WEP_FLAG_SUPERWEAPON)
100 if (!this.superweapons_finished)
101 this.superweapons_finished = autocvar_g_balance_superweapons_time;
103 // if we don't already have ammo, give us some ammo
104 if (!this.(wpn.ammo_field))
106 switch (wpn.ammo_field)
108 case ammo_shells: this.ammo_shells = cvar("g_pickup_shells_weapon"); break;
109 case ammo_nails: this.ammo_nails = cvar("g_pickup_nails_weapon"); break;
110 case ammo_rockets: this.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
111 case ammo_cells: this.ammo_cells = cvar("g_pickup_cells_weapon"); break;
112 case ammo_plasma: this.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
113 case ammo_fuel: this.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
120 for (int i = 0, j = 1; i < 24; ++i, j <<= 1)
124 ammotype = Item_CounterField(j);
126 this.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
133 if (g_pickup_weapons_anyway)
134 this.pickup_anyway = true;
137 this.glowmod = wpn.wpcolor;
139 GameItem def = wpn.m_pickup;
143 this.respawntime, // defaultrespawntime
144 this.respawntimejitter // defaultrespawntimejitter
147 if (this.modelindex) { // don't precache if this was removed