From: Mario Date: Sat, 28 Jan 2017 08:30:45 +0000 (+1000) Subject: Add a new mode to weaponswitch debug which enforces the secondary weapons to only... X-Git-Tag: xonotic-v0.8.2~269 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=608df3eea77373f3457a825a5e9047b8ac11fe20;p=xonotic%2Fxonotic-data.pk3dir.git Add a new mode to weaponswitch debug which enforces the secondary weapons to only weapons with a dual wielding flag --- diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 67adb5aae..0d0f67bef 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -194,6 +194,7 @@ const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag) const int WEP_TYPE_MELEE_PRI = 0x400; // primary attack is melee swing (for animation) const int WEP_TYPE_MELEE_SEC = 0x800; // secondary attack is melee swing (for animation) +const int WEP_FLAG_DUALWIELD = 0x1000; // weapon can be dual wielded // variables: string weaponorder_byid; diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index fbb4271df..2081b688d 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -79,6 +79,8 @@ void RemoveGrapplingHooks(entity pl) for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; + if(!pl.(weaponentity)) + continue; // continue incase other slots exist? if(pl.(weaponentity).hook) delete(pl.(weaponentity).hook); pl.(weaponentity).hook = NULL; diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index c84c0de9a..eb54a98e9 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -66,7 +66,7 @@ bool autocvar_g_weaponswitch_debug; { \ .entity weaponentity = weaponentities[wepslot]; \ W_NextWeaponOnImpulse(this, slot, weaponentity); \ - if(wepslot == 0 && !autocvar_g_weaponswitch_debug) \ + if(wepslot == 0 && autocvar_g_weaponswitch_debug != 1) \ break; \ } \ } @@ -100,7 +100,7 @@ X(0) { \ .entity weaponentity = weaponentities[wepslot]; \ W_CycleWeapon(this, this.cvar_cl_weaponpriorities[slot], dir, weaponentity); \ - if(wepslot == 0 && !autocvar_g_weaponswitch_debug) \ + if(wepslot == 0 && autocvar_g_weaponswitch_debug != 1) \ break; \ } \ } @@ -153,7 +153,7 @@ X(9, next) { \ .entity weaponentity = weaponentities[slot]; \ W_SwitchWeapon(this, Weapons_from(WEP_FIRST + i), weaponentity); \ - if(slot == 0 && !autocvar_g_weaponswitch_debug) \ + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) \ break; \ } \ } @@ -196,7 +196,7 @@ IMPULSE(weapon_next_byid) .entity weaponentity = weaponentities[slot]; W_NextWeapon(this, 0, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -214,7 +214,7 @@ IMPULSE(weapon_prev_byid) .entity weaponentity = weaponentities[slot]; W_PreviousWeapon(this, 0, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -232,7 +232,7 @@ IMPULSE(weapon_next_bygroup) .entity weaponentity = weaponentities[slot]; W_NextWeapon(this, 1, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -250,7 +250,7 @@ IMPULSE(weapon_prev_bygroup) .entity weaponentity = weaponentities[slot]; W_PreviousWeapon(this, 1, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -268,7 +268,7 @@ IMPULSE(weapon_next_bypriority) .entity weaponentity = weaponentities[slot]; W_NextWeapon(this, 2, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -286,7 +286,7 @@ IMPULSE(weapon_prev_bypriority) .entity weaponentity = weaponentities[slot]; W_PreviousWeapon(this, 2, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -300,7 +300,7 @@ IMPULSE(weapon_last) .entity weaponentity = weaponentities[slot]; W_LastWeapon(this, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -314,7 +314,7 @@ IMPULSE(weapon_best) .entity weaponentity = weaponentities[slot]; W_SwitchWeapon(this, w_getbestweapon(this, weaponentity), weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -328,7 +328,7 @@ IMPULSE(weapon_drop) .entity weaponentity = weaponentities[slot]; W_ThrowWeapon(this, weaponentity, W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } @@ -345,7 +345,7 @@ IMPULSE(weapon_reload) Weapon w = this.(weaponentity).m_weapon; w.wr_reload(w, actor, weaponentity); - if(slot == 0 && !autocvar_g_weaponswitch_debug) + if(slot == 0 && autocvar_g_weaponswitch_debug != 1) break; } } diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 06d5f3085..e8b8d9a4b 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -61,6 +61,8 @@ 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)) + return false; // no complaints needed if (this.weapons & WepSet_FromWeapon(wpn)) { if (andammo) diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 826bb2a5a..452ac7f53 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -461,6 +461,22 @@ void W_WeaponFrame(Player actor, .entity weaponentity) return; } + if(autocvar_g_weaponswitch_debug == 2 && weaponslot(weaponentity) > 0) + { + .entity wepe1 = weaponentities[0]; + entity wep1 = actor.(wepe1); + this.m_switchweapon = wep1.m_switchweapon; + if(!(this.m_switchweapon.spawnflags & WEP_FLAG_DUALWIELD)) + { + this.m_weapon = WEP_Null; + this.m_switchingweapon = WEP_Null; + this.m_switchweapon = WEP_Null; + this.state = WS_CLEAR; + this.weaponname = ""; + return; + } + } + makevectors(actor.v_angle); vector fo = v_forward; // save them in case the weapon think functions change it vector ri = v_right;