From 9bebee983c49ed3640aa4f17b445bfe3a0690118 Mon Sep 17 00:00:00 2001 From: drjaska Date: Thu, 24 Oct 2024 08:32:00 +0300 Subject: [PATCH] Allow for reversed spread, inaccurate to accurate --- qcsrc/common/weapons/weapon/machinegun.qc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 0f32850e6..103d50b5b 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -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, -- 2.39.2