]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an option to alternate between weapons when dual wielding
authorMario <mario@smbclan.net>
Sat, 13 Oct 2018 05:47:15 +0000 (15:47 +1000)
committerMario <mario@smbclan.net>
Sat, 13 Oct 2018 05:47:15 +0000 (15:47 +1000)
qcsrc/server/autocvars.qh
qcsrc/server/weapons/weaponsystem.qc

index b3d23256f080f30bf0fdf881634803596dabbe90..b23f6f148175478fbdc9acb885cc71cb3179b045 100644 (file)
@@ -518,5 +518,6 @@ float autocvar_sv_airstopaccelerate;
 float autocvar_sv_track_canjump;
 bool autocvar_sv_showspectators;
 bool autocvar_g_weaponswitch_debug;
+bool autocvar_g_weaponswitch_debug_alternate;
 bool autocvar_g_allow_checkpoints;
 bool autocvar_sv_vq3compat_changehitbox = false;
index 1f8c58be14a9ee886c52b03febe4d6dd1c717db8..50a30fed8938e7c6530227389dc07a9ca6a833d5 100644 (file)
@@ -321,6 +321,22 @@ void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary,
                        // dprint("resetting attack finished to ", ftos(time), "\n");
                }
                ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * W_WeaponRateFactor(actor);
+
+               if(autocvar_g_weaponswitch_debug_alternate && W_DualWielding(actor))
+               {
+                       for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot)
+                       {
+                               if(slot == wepslot)
+                                       continue;
+                               .entity wepent = weaponentities[wepslot];
+                               if(actor.(wepent) && actor.(wepent).m_weapon != WEP_Null)
+                               {
+                                       if (ATTACK_FINISHED(actor, wepslot) < time - actor.(wepent).weapon_frametime * 1.5)
+                                               ATTACK_FINISHED(actor, wepslot) = time;
+                                       ATTACK_FINISHED(actor, wepslot) = ATTACK_FINISHED(actor, wepslot) + (attacktime * W_WeaponRateFactor(actor)) * 0.5;
+                               }
+                       }
+               }
        }
        this.bulletcounter += 1;
        // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");