3 #include "weaponsystem.qh"
4 #include "../mutators/mutators_include.qh"
5 #include "../t_items.qh"
6 #include "../../common/weapons/all.qh"
8 string W_Apply_Weaponreplace(string in)
10 float n = tokenize_console(in);
11 string out = "", s, replacement;
14 for(i = 0; i < n; ++i)
19 for(j = WEP_FIRST; j <= WEP_LAST; ++j)
21 e = get_weaponinfo(j);
24 replacement = e.weaponreplace;
29 out = strcat(out, " ", s);
30 else if(replacement != "0")
31 out = strcat(out, " ", replacement);
33 return substring(out, 1, -1);
36 void weapon_defaultspawnfunc(entity this, Weapon e)
39 if (this.classname != "droppedweapon" && this.classname != "replacedweapon")
41 if (e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
43 objerror("Attempted to spawn a mutator-blocked weapon rejected");
44 startitem_failed = true;
48 string s = W_Apply_Weaponreplace(e.netname);
49 MUTATOR_CALLHOOK(SetWeaponreplace, this, e, s);
54 startitem_failed = true;
57 int t = tokenize_console(s);
60 this.team = --internalteam;
61 for (int i = 1; i < t; ++i)
65 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
67 e = get_weaponinfo(j);
70 entity replacement = spawn();
71 copyentity(this, replacement);
72 replacement.classname = "replacedweapon";
73 weapon_defaultspawnfunc(replacement, e);
79 LOG_INFO("The weapon replace list for ", this.classname, " contains an unknown weapon ", s, ". Skipped.\n");
83 if (t >= 1) // always the case!
88 for (j = WEP_FIRST; j <= WEP_LAST; ++j)
90 e = get_weaponinfo(j);
99 LOG_INFO("The weapon replace list for ", this.classname, " contains an unknown weapon ", s, ". Skipped.\n");
105 startitem_failed = true;
110 e = get_weaponinfo(wpn);
112 if (!this.respawntime)
114 if (e.weapons & WEPSET_SUPERWEAPONS)
116 this.respawntime = g_pickup_respawntime_superweapon;
117 this.respawntimejitter = g_pickup_respawntimejitter_superweapon;
121 this.respawntime = g_pickup_respawntime_weapon;
122 this.respawntimejitter = g_pickup_respawntimejitter_weapon;
126 if (e.weapons & WEPSET_SUPERWEAPONS)
127 if (!this.superweapons_finished)
128 this.superweapons_finished = autocvar_g_balance_superweapons_time;
130 // if we don't already have ammo, give us some ammo
131 if (!this.(e.ammo_field))
133 switch (e.ammo_field)
135 case ammo_shells: this.ammo_shells = cvar("g_pickup_shells_weapon"); break;
136 case ammo_nails: this.ammo_nails = cvar("g_pickup_nails_weapon"); break;
137 case ammo_rockets: this.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
138 case ammo_cells: this.ammo_cells = cvar("g_pickup_cells_weapon"); break;
139 case ammo_plasma: this.ammo_plasma = cvar("g_pickup_plasma_weapon"); break;
140 case ammo_fuel: this.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
147 for (int i = 0, j = 1; i < 24; ++i, j <<= 1)
151 ammotype = Item_CounterField(j);
153 this.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
160 if (g_pickup_weapons_anyway)
161 this.pickup_anyway = true;
165 // no weapon-stay on superweapons
166 if (e.weapons & WEPSET_SUPERWEAPONS)
167 f |= FL_NO_WEAPON_STAY;
169 // weapon stay isn't supported for teamed weapons
171 f |= FL_NO_WEAPON_STAY;
175 strzone(e.m_model.model_str()), // itemmodel
176 string_null, // pickupsound
177 this.respawntime, // defaultrespawntime
178 this.respawntimejitter, // defaultrespawntimejitter
179 e.message, // itemname
181 e.weapon, // weaponid
183 weapon_pickupevalfunc, // pickupevalfunc
184 e.bot_pickupbasevalue // pickupbasevalue
186 this.item_pickupsound_ent = SND_WEAPONPICKUP;
188 if (this.modelindex) { // don't precache if this was removed