]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Mario/overkill' into 'master'
authorMario <zacjardine@y7mail.com>
Sat, 28 Jan 2017 11:36:05 +0000 (11:36 +0000)
committerMario <zacjardine@y7mail.com>
Sat, 28 Jan 2017 11:36:05 +0000 (11:36 +0000)
Merge branch Mario/overkill (S merge request)

See merge request !407

qcsrc/common/weapons/weapon.qh
qcsrc/server/autocvars.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 c4f77dfad38446d8e11fe91466db06e6d1319ae7..975a95b29906e42c2b87032a3ad558048a4c900b 100644 (file)
@@ -522,3 +522,4 @@ float autocvar_sv_airaccelerate;
 float autocvar_sv_airstopaccelerate;
 float autocvar_sv_track_canjump;
 bool autocvar_sv_showspectators;
+bool autocvar_g_weaponswitch_debug;
index ef4cbc5a65409f2858f5a90561fa4c0a4910d240..2081b688dcb0f3d964bf3f1f374a80b2b993579d 100644 (file)
@@ -79,11 +79,11 @@ 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;
-       }
+       pl.(weaponentity).hook = NULL;
     }
 
        //pl.disableclientprediction = false;
@@ -91,15 +91,14 @@ void RemoveGrapplingHooks(entity pl)
 
 void RemoveHook(entity this)
 {
-       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    {
-       .entity weaponentity = weaponentities[slot];
-       if(this.realowner.(weaponentity).hook == this)
-               this.realowner.(weaponentity).hook = NULL;
-    }
+       entity player = this.realowner;
+    .entity weaponentity = this.weaponentity_fld;
+
+    if(player.(weaponentity).hook == this)
+       player.(weaponentity).hook = NULL;
 
-    if(this.realowner.move_movetype == MOVETYPE_FLY)
-       set_movetype(this.realowner, MOVETYPE_WALK);
+    if(player.move_movetype == MOVETYPE_FLY)
+       set_movetype(player, MOVETYPE_WALK);
     delete(this);
 }
 
index c84c0de9af68230359cad5c324147ae415984853..57aaf4a2b51ae1208470cc4bdf3a3deeca573624 100644 (file)
@@ -52,8 +52,6 @@
 
 // weapon switching impulses
 
-bool autocvar_g_weaponswitch_debug;
-
 #define X(slot) \
        IMPULSE(weapon_group_##slot) \
        { \
@@ -66,7 +64,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 +98,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 +151,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 +194,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 +212,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 +230,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 +248,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 +266,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 +284,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 +298,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 +312,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 +326,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 +343,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..3347f2bb1e2a78d30ac52746e744140275cbb534 100644 (file)
@@ -452,6 +452,22 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                }
        }
 
+       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;
+               }
+       }
+
        if (this.m_switchweapon == WEP_Null)
        {
                this.m_weapon = WEP_Null;