]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow for reversed spread, inaccurate to accurate
authordrjaska <drjaska83@gmail.com>
Thu, 24 Oct 2024 05:32:00 +0000 (08:32 +0300)
committerdrjaska <drjaska83@gmail.com>
Thu, 24 Oct 2024 05:32:00 +0000 (08:32 +0300)
qcsrc/common/weapons/weapon/machinegun.qc

index 0f32850e60fad4482aa1027d80f2f3b94aaab775..103d50b5beb9dd6b49d332ceb1c1d20b9f455b43 100644 (file)
@@ -13,7 +13,7 @@ void MachineGun_Update_Spread(entity actor, .entity weaponentity)
        // time based spread decay
        if (WEP_CVAR(WEP_MACHINEGUN, spread_decay))
        {
-               float spreadSpectrumDistance = WEP_CVAR(WEP_MACHINEGUN, spread_max) - WEP_CVAR(WEP_MACHINEGUN, spread_min);
+               float spreadSpectrumDistance = fabs(WEP_CVAR(WEP_MACHINEGUN, spread_max) - WEP_CVAR(WEP_MACHINEGUN, spread_min));
                float timediff = time - actor.(weaponentity).spreadUpdateTime;
                spread_accum = bound(0,
                        spread_accum - (timediff * WEP_CVAR(WEP_MACHINEGUN, spread_decay)),
@@ -138,7 +138,11 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
 
        float spread_accum = actor.(weaponentity).machinegun_spread_accumulation;
 
-       float spread_accuracy = WEP_CVAR(WEP_MACHINEGUN, spread_min) + spread_accum;
+       float spread_accuracy;
+       if (WEP_CVAR(WEP_MACHINEGUN, spread_min) < WEP_CVAR(WEP_MACHINEGUN, spread_max))
+               spread_accuracy = WEP_CVAR(WEP_MACHINEGUN, spread_min) + spread_accum;
+       else // inverted
+               spread_accuracy = WEP_CVAR(WEP_MACHINEGUN, spread_min) - spread_accum;
 
        fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir,
                           spread_accuracy,