]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a new mode to weaponswitch debug which enforces the secondary weapons to only...
authorMario <mario@smbclan.net>
Sat, 28 Jan 2017 08:30:45 +0000 (18:30 +1000)
committerMario <mario@smbclan.net>
Sat, 28 Jan 2017 08:30:45 +0000 (18:30 +1000)
qcsrc/common/weapons/weapon.qh
qcsrc/server/g_hook.qc
qcsrc/server/impulse.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/weaponsystem.qc

index 67adb5aae09ebd4f997fc2a94fca10d994c8ffc8..0d0f67bef30c7011200ec45eedf5f63f1f19202d 100644 (file)
@@ -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;
index fbb4271dfbdaedfd46acdfb280615576fa76c878..2081b688dcb0f3d964bf3f1f374a80b2b993579d 100644 (file)
@@ -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;
index c84c0de9af68230359cad5c324147ae415984853..eb54a98e9ef5daa7a22ab183af99dc5d3594a1ea 100644 (file)
@@ -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;
        }
 }
index 06d5f30851711c5a952ce3935513d870da97d12a..e8b8d9a4b293c9732c7dafe777327d626c8a2d54 100644 (file)
@@ -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)
index 826bb2a5a7f8415ce2f41487d17ec2da56552a89..452ac7f533badd5084b92fd41454b4b312132e53 100644 (file)
@@ -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;