From 30cba785cd27f19eeff00581212eba997c43f21d Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 Apr 2017 14:52:29 +1000 Subject: [PATCH] Add a field to handle dual wielding status of a player's weapons --- qcsrc/server/client.qc | 2 ++ qcsrc/server/defs.qh | 2 ++ qcsrc/server/weapons/selection.qc | 2 +- qcsrc/server/weapons/weaponsystem.qc | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 168ca8496..72ee5a7cd 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -338,6 +338,7 @@ void PutObserverInServer(entity this) this.items = 0; this.weapons = '0 0 0'; + this.dual_weapons = '0 0 0'; this.drawonlytoclient = this; this.weaponmodel = ""; @@ -1694,6 +1695,7 @@ void SpectateCopy(entity this, entity spectatee) this.superweapons_finished = spectatee.superweapons_finished; STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee); this.weapons = spectatee.weapons; + this.dual_weapons = spectatee.dual_weapons; this.vortex_charge = spectatee.vortex_charge; this.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo; this.hagar_load = spectatee.hagar_load; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index ccb361ea6..e210151dc 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -418,6 +418,8 @@ const int MIF_GUIDED_CONFUSABLE = MIF_GUIDED_HEAT | MIF_GUIDED_AI; .void(entity this, entity player) init_for_player; +.WepSet dual_weapons; + IntrusiveList g_monsters; STATIC_INIT(g_monsters) { g_monsters = IL_NEW(); } diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index e8b8d9a4b..895c65ae2 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -61,7 +61,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam sprint(this, "Invalid weapon\n"); return false; } - if (autocvar_g_weaponswitch_debug == 2 && weaponslot(weaponentity) > 0 && !(wpn.spawnflags & WEP_FLAG_DUALWIELD)) + if (autocvar_g_weaponswitch_debug == 2 && weaponslot(weaponentity) > 0 && !(wpn.spawnflags & WEP_FLAG_DUALWIELD) && !(this.dual_weapons & wpn.m_wepset)) return false; // no complaints needed if (this.weapons & WepSet_FromWeapon(wpn)) { diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 1605db39d..2e4e160b3 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -457,7 +457,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity) .entity wepe1 = weaponentities[0]; entity wep1 = actor.(wepe1); this.m_switchweapon = wep1.m_switchweapon; - if(!(this.m_switchweapon.spawnflags & WEP_FLAG_DUALWIELD)) + if(!(this.m_switchweapon.spawnflags & WEP_FLAG_DUALWIELD) && !(actor.dual_weapons & wep1.m_switchweapon.m_wepset)) { this.m_weapon = WEP_Null; this.m_switchingweapon = WEP_Null; -- 2.39.2