X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fselection.qc;h=baee4ac532888599a7e3ff786bbeceb8363e6a60;hp=17ba0dc9dfafb4f1063e0f20f14b292f11856b56;hb=293777db9bd54478f88c29339f39756307a6929a;hpb=fa4d1576bf19100ffafcbff988c3309b96e4f937 diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 17ba0dc9df..baee4ac532 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -2,6 +2,7 @@ #include "weaponsystem.qh" #include +#include #include #include #include @@ -25,8 +26,10 @@ void Weapon_whereis(Weapon this, entity cl) if (!autocvar_g_showweaponspawns) return; IL_EACH(g_items, it.weapon == this.m_id && (!it.team || (it.ItemStatus & ITS_AVAILABLE)), { - if (it.classname == "droppedweapon" && autocvar_g_showweaponspawns < 2) + if (Item_IsLoot(it) && (autocvar_g_showweaponspawns < 2)) + { continue; + } entity wp = WaypointSprite_Spawn( WP_Weapon, -2, 0, @@ -44,16 +47,16 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam { float f = 0; - if (time < this.hasweapon_complain_spam) + if (time < CS(this).hasweapon_complain_spam) complain = 0; // ignore hook button when using other offhand equipment if (this.offhand != OFFHAND_HOOK) - if (wpn == WEP_HOOK && !((this.weapons | weaponsInMap) & WepSet_FromWeapon(wpn))) + if (wpn == WEP_HOOK && !((STAT(WEAPONS, this) | weaponsInMap) & WepSet_FromWeapon(wpn))) complain = 0; if (complain) - this.hasweapon_complain_spam = time + 0.2; + CS(this).hasweapon_complain_spam = time + 0.2; if (wpn == WEP_Null) { @@ -63,7 +66,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam } if (autocvar_g_weaponswitch_debug == 2 && weaponslot(weaponentity) > 0 && !(wpn.spawnflags & WEP_FLAG_DUALWIELD) && !(PS(this).dual_weapons & wpn.m_wepset)) return false; // no complaints needed - if (this.weapons & WepSet_FromWeapon(wpn)) + if (STAT(WEAPONS, this) & WepSet_FromWeapon(wpn)) { if (andammo) { @@ -158,12 +161,12 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl FOREACH(Weapons, it != WEP_Null, { if(i != weaponwant) if(it.impulse == imp || imp < 0) - if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) + if((STAT(WEAPONS, this) & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) have_other = true; }); // skip weapons we don't own that aren't normal and aren't in the map - if(!(this.weapons & wepset)) + if(!(STAT(WEAPONS, this) & wepset)) if(!(weaponsInMap & wepset)) if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other) continue; @@ -214,12 +217,12 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl FOREACH(Weapons, it != WEP_Null, { if(i != weaponwant) if(it.impulse == imp || imp < 0) - if((this.weapons & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) + if((STAT(WEAPONS, this) & (it.m_wepset)) || (weaponsInMap & (it.m_wepset))) have_other = true; }); // skip weapons we don't own that aren't normal and aren't in the map - if(!(this.weapons & wepset)) + if(!(STAT(WEAPONS, this) & wepset)) if(!(weaponsInMap & wepset)) if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other) continue; @@ -237,7 +240,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl void W_SwitchWeapon_Force(Player this, Weapon wep, .entity weaponentity) { - TC(Weapon, wep); + TC(Weapon, wep); this.(weaponentity).cnt = this.(weaponentity).m_switchweapon.m_id; this.(weaponentity).m_switchweapon = wep; this.(weaponentity).selectweapon = wep.m_id; @@ -249,11 +252,11 @@ void W_SwitchToOtherWeapon(entity this, .entity weaponentity) // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway) Weapon ww; WepSet set = WepSet_FromWeapon(this.(weaponentity).m_weapon); - if (this.weapons & set) + if (STAT(WEAPONS, this) & set) { - this.weapons &= ~set; + STAT(WEAPONS, this) &= ~set; ww = w_getbestweapon(this, weaponentity); - this.weapons |= set; + STAT(WEAPONS, this) |= set; } else { @@ -279,6 +282,25 @@ void W_SwitchWeapon(entity this, Weapon w, .entity weaponentity) } } +void W_SwitchWeapon_TryOthers(entity this, Weapon w, .entity weaponentity) +{ + if(this.(weaponentity).m_switchweapon != w) + { + if(client_hasweapon(this, w, weaponentity, true, true)) // NOTE: still complains + W_SwitchWeapon_Force(this, w, weaponentity); + else + { + this.(weaponentity).selectweapon = w.m_id; // update selectweapon anyway + W_NextWeaponOnImpulse(this, w.impulse, weaponentity); + } + } + else if(!forbidWeaponUse(this)) + { + entity actor = this; + w.wr_reload(w, actor, weaponentity); + } +} + void W_CycleWeapon(entity this, string weaponorder, float dir, .entity weaponentity) { float w; @@ -290,7 +312,7 @@ void W_CycleWeapon(entity this, string weaponorder, float dir, .entity weaponent void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity) { float w; - w = W_GetCycleWeapon(this, this.cvar_cl_weaponpriority, +1, imp, 1, (this.cvar_cl_weaponimpulsemode == 0), weaponentity); + w = W_GetCycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, imp, 1, (CS(this).cvar_cl_weaponimpulsemode == 0), weaponentity); if(w > 0) W_SwitchWeapon(this, Weapons_from(w), weaponentity); } @@ -301,9 +323,9 @@ void W_NextWeapon(entity this, int list, .entity weaponentity) if(list == 0) W_CycleWeapon(this, weaponorder_byid, -1, weaponentity); else if(list == 1) - W_CycleWeapon(this, this.weaponorder_byimpulse, -1, weaponentity); + W_CycleWeapon(this, CS(this).weaponorder_byimpulse, -1, weaponentity); else if(list == 2) - W_CycleWeapon(this, this.cvar_cl_weaponpriority, -1, weaponentity); + W_CycleWeapon(this, CS(this).cvar_cl_weaponpriority, -1, weaponentity); } // prev weapon @@ -312,9 +334,9 @@ void W_PreviousWeapon(entity this, float list, .entity weaponentity) if(list == 0) W_CycleWeapon(this, weaponorder_byid, +1, weaponentity); else if(list == 1) - W_CycleWeapon(this, this.weaponorder_byimpulse, +1, weaponentity); + W_CycleWeapon(this, CS(this).weaponorder_byimpulse, +1, weaponentity); else if(list == 2) - W_CycleWeapon(this, this.cvar_cl_weaponpriority, +1, weaponentity); + W_CycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, weaponentity); } // previously used if exists and has ammo, (second) best otherwise