3 #include "weaponsystem.qh"
4 #include "../mutators/all.qh"
5 #include "../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 objerror("Attempted to spawn a mutator-blocked weapon rejected");
33 startitem_failed = true;
37 string s = W_Apply_Weaponreplace(e.netname);
38 MUTATOR_CALLHOOK(SetWeaponreplace, this, e, s);
43 startitem_failed = true;
46 int t = tokenize_console(s);
49 this.team = --internalteam;
50 for (int i = 1; i < t; ++i)
54 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
59 entity replacement = spawn();
60 copyentity(this, replacement);
61 replacement.classname = "replacedweapon";
62 weapon_defaultspawnfunc(replacement, e);
68 LOG_INFO("The weapon replace list for ", this.classname, " contains an unknown weapon ", s, ". Skipped.\n");
72 if (t >= 1) // always the case!
77 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
88 LOG_INFO("The weapon replace list for ", this.classname, " contains an unknown weapon ", s, ". Skipped.\n");
94 startitem_failed = true;
99 e = Weapons_from(wpn);
101 if (!this.respawntime)
103 if (e.spawnflags & WEP_FLAG_SUPERWEAPON)
105 this.respawntime = g_pickup_respawntime_superweapon;
106 this.respawntimejitter = g_pickup_respawntimejitter_superweapon;
110 this.respawntime = g_pickup_respawntime_weapon;
111 this.respawntimejitter = g_pickup_respawntimejitter_weapon;
115 if (e.spawnflags & WEP_FLAG_SUPERWEAPON)
116 if (!this.superweapons_finished)
117 this.superweapons_finished = autocvar_g_balance_superweapons_time;
119 // if we don't already have ammo, give us some ammo
120 if (!this.(e.ammo_field))
122 switch (e.ammo_field)
124 case ammo_shells: this.ammo_shells = cvar("g_pickup_shells_weapon"); break;
125 case ammo_nails: this.ammo_nails = cvar("g_pickup_nails_weapon"); break;
126 case ammo_rockets: this.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
127 case ammo_cells: this.ammo_cells = cvar("g_pickup_cells_weapon"); break;
128 case ammo_plasma: this.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
129 case ammo_fuel: this.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
136 for (int i = 0, j = 1; i < 24; ++i, j <<= 1)
140 ammotype = Item_CounterField(j);
142 this.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
149 if (g_pickup_weapons_anyway)
150 this.pickup_anyway = true;
152 GameItem def = e.m_pickup;
156 this.respawntime, // defaultrespawntime
157 this.respawntimejitter // defaultrespawntimejitter
160 if (this.modelindex) { // don't precache if this was removed