X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fspawning.qc;h=d5b78aa1cd064424b267ca3cfc2ce7c782714d09;hb=565754a35f9e84a3b8e6eac08635ec27145b369a;hp=62b11ea45d62e47e3bc9c3d7244b05837e39c737;hpb=ecd018b0f2a99be972759503e3efea35b6717ee9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 62b11ea45..23a3ee67d 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -1,10 +1,14 @@ #include "spawning.qh" #include "weaponsystem.qh" -#include "../mutators/_mod.qh" +#include "../resources.qh" +#include #include +#include #include +.bool m_isreplaced; ///< Holds whether the weapon has been replaced. + string W_Apply_Weaponreplace(string in) { string out = ""; @@ -22,20 +26,21 @@ string W_Apply_Weaponreplace(string in) return out; } -void weapon_defaultspawnfunc(entity this, Weapon e) +void weapon_defaultspawnfunc(entity this, Weapon wpn) { - Weapon wpn = e; - if (this.classname != "droppedweapon" && this.classname != "replacedweapon") + wpn = wpn.m_spawnfunc_hookreplace(wpn, this); + this.classname = wpn.m_canonical_spawnfunc; + if (!Item_IsLoot(this) && !this.m_isreplaced) { - if (e.spawnflags & WEP_FLAG_MUTATORBLOCKED) + if (wpn.spawnflags & WEP_FLAG_MUTATORBLOCKED) { LOG_WARNF("Attempted to spawn a mutator-blocked weapon rejected: prvm_edict server %i", this); startitem_failed = true; return; } - string s = W_Apply_Weaponreplace(e.netname); - MUTATOR_CALLHOOK(SetWeaponreplace, this, e, s); + string s = W_Apply_Weaponreplace(wpn.netname); + MUTATOR_CALLHOOK(SetWeaponreplace, this, wpn, s); s = M_ARGV(2, string); if (s == "") { @@ -50,29 +55,20 @@ void weapon_defaultspawnfunc(entity this, Weapon e) for (int i = 1; i < t; ++i) { s = argv(i); - FOREACH(Weapons, it != WEP_Null, { - if(it.netname == s) - { - entity replacement = spawn(); - copyentity(this, replacement); - replacement.classname = "replacedweapon"; - weapon_defaultspawnfunc(replacement, it); - break; - } - }); + Weapon wep = Weapons_fromstr(s); + if(wep != WEP_Null) + { + entity replacement = spawn(); + copyentity(this, replacement); + replacement.m_isreplaced = true; + weapon_defaultspawnfunc(replacement, wep); + } } } if (t >= 1) // always the case! { s = argv(0); - wpn = WEP_Null; - FOREACH(Weapons, it != WEP_Null, { - if(it.netname == s) - { - wpn = it; - break; - } - }); + wpn = Weapons_fromstr(s); } if (wpn == WEP_Null) { @@ -82,6 +78,16 @@ void weapon_defaultspawnfunc(entity this, Weapon e) } } + if(!Item_IsLoot(this)) + weaponsInMapAll |= WepSet_FromWeapon(wpn); + + if (!Item_IsDefinitionAllowed(wpn.m_pickup)) + { + delete(this); + startitem_failed = true; + return; + } + if (!this.respawntime) { if (wpn.spawnflags & WEP_FLAG_SUPERWEAPON) @@ -101,16 +107,16 @@ void weapon_defaultspawnfunc(entity this, Weapon e) this.superweapons_finished = autocvar_g_balance_superweapons_time; // if we don't already have ammo, give us some ammo - if (!this.(wpn.ammo_field)) + if ((wpn.ammo_type != RES_NONE) && !GetResource(this, wpn.ammo_type)) { - switch (wpn.ammo_field) + switch (wpn.ammo_type) { - case ammo_shells: this.ammo_shells = cvar("g_pickup_shells_weapon"); break; - case ammo_nails: this.ammo_nails = cvar("g_pickup_nails_weapon"); break; - case ammo_rockets: this.ammo_rockets = cvar("g_pickup_rockets_weapon"); break; - case ammo_cells: this.ammo_cells = cvar("g_pickup_cells_weapon"); break; - case ammo_plasma: this.ammo_plasma = cvar("g_pickup_plasma_weapon"); break; - case ammo_fuel: this.ammo_fuel = cvar("g_pickup_fuel_weapon"); break; + case RES_SHELLS: SetResource(this, wpn.ammo_type, cvar("g_pickup_shells_weapon")); break; + case RES_BULLETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_nails_weapon")); break; + case RES_ROCKETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break; + case RES_CELLS: SetResource(this, wpn.ammo_type, cvar("g_pickup_cells_weapon")); break; + case RES_PLASMA: SetResource(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon")); break; + case RES_FUEL: SetResource(this, wpn.ammo_type, cvar("g_pickup_fuel_weapon")); break; } }