X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fspawning.qc;h=f555a6ea7bdb69278479171a6e71146e2a54f389;hp=204b5a7633669ffeac43adcf5c6da6013939d703;hb=67610c5b92e218cc245c040209c1a79ab6b02758;hpb=e51ce3d45d2852ca793118fc73da9c25f789101f diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 204b5a763..f555a6ea7 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -3,8 +3,9 @@ #include "weaponsystem.qh" #include "../resources.qh" #include -#include -#include +#include +#include +#include #include .bool m_isreplaced; ///< Holds whether the weapon has been replaced. @@ -14,7 +15,7 @@ string W_Apply_Weaponreplace(string in) string out = ""; FOREACH_WORD(in, true, { string replacement = ""; - Weapon w = Weapons_fromstr(it); + Weapon w = Weapon_from_name(it); if (w) { replacement = w.weaponreplace; @@ -26,22 +27,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; - e = wpn = wpn.m_spawnfunc_hookreplace(wpn, this); + 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); + //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 == "") { @@ -56,29 +56,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.m_isreplaced = true; - weapon_defaultspawnfunc(replacement, it); - break; - } - }); + Weapon wep = Weapon_from_name(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 = Weapon_from_name(s); } if (wpn == WEP_Null) { @@ -88,6 +79,9 @@ void weapon_defaultspawnfunc(entity this, Weapon e) } } + if(!Item_IsLoot(this)) + weaponsInMapAll |= WepSet_FromWeapon(wpn); + if (!Item_IsDefinitionAllowed(wpn.m_pickup)) { delete(this); @@ -114,16 +108,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 ((wpn.ammo_type != RESOURCE_NONE) && !GetResourceAmount(this, wpn.ammo_type)) + if ((wpn.ammo_type != RES_NONE) && !GetResource(this, wpn.ammo_type)) { switch (wpn.ammo_type) { - case RESOURCE_SHELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_shells_weapon")); break; - case RESOURCE_BULLETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_nails_weapon")); break; - case RESOURCE_ROCKETS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break; - case RESOURCE_CELLS: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_cells_weapon")); break; - case RESOURCE_PLASMA: SetResourceAmount(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon")); break; - case RESOURCE_FUEL: SetResourceAmount(this, wpn.ammo_type, 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; } }