]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement damage scaling based on accumulated spread
authordrjaska <drjaska83@gmail.com>
Thu, 5 Sep 2024 05:50:38 +0000 (08:50 +0300)
committerdrjaska <drjaska83@gmail.com>
Fri, 25 Oct 2024 09:53:55 +0000 (12:53 +0300)
bal-wep-mario.cfg
bal-wep-nexuiz25.cfg
bal-wep-samual.cfg
bal-wep-xdf.cfg
bal-wep-xonotic.cfg
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/machinegun.qh

index 306fb9a02e1719bcc4a617f137779d8cf96bafea..6a2462d33534da2164a367b58bb07c358fd72c1d 100644 (file)
@@ -84,6 +84,8 @@ set g_balance_machinegun_spread_add 0.012
 set g_balance_machinegun_spread_decay 0.048
 set g_balance_machinegun_spread_max 0.05
 set g_balance_machinegun_spread_min 0.02
+set g_balance_machinegun_spread_cold_damagemultiplier 1
+set g_balance_machinegun_spread_heat_damagemultiplier 1
 set g_balance_machinegun_sustained_ammo 1
 set g_balance_machinegun_sustained_damage 10
 set g_balance_machinegun_sustained_force 3
index aa241622e8aebf47d1d993524dcfba1e4eddd689..bfd58cf1769c09ee0e7069aa86ee3a171b8974b1 100644 (file)
@@ -84,6 +84,8 @@ set g_balance_machinegun_spread_add 0.02
 set g_balance_machinegun_spread_decay 0
 set g_balance_machinegun_spread_max 0.6
 set g_balance_machinegun_spread_min 0.02
+set g_balance_machinegun_spread_cold_damagemultiplier 1
+set g_balance_machinegun_spread_heat_damagemultiplier 1
 set g_balance_machinegun_sustained_ammo 1
 set g_balance_machinegun_sustained_damage 15
 set g_balance_machinegun_sustained_force 27
index 1320937e735cef7d8bf775208c314ad35eb02204..dd555810a2f35eb65a07cc666995696d5bb2f882 100644 (file)
@@ -84,6 +84,8 @@ set g_balance_machinegun_spread_add 0.012
 set g_balance_machinegun_spread_decay 0.048
 set g_balance_machinegun_spread_max 0.05
 set g_balance_machinegun_spread_min 0.02
+set g_balance_machinegun_spread_cold_damagemultiplier 1
+set g_balance_machinegun_spread_heat_damagemultiplier 1
 set g_balance_machinegun_sustained_ammo 1
 set g_balance_machinegun_sustained_damage 10
 set g_balance_machinegun_sustained_force 5
index 36bd4b407e6bec4f78eb47ed07f3bce64411b4f1..0c33b8e0c39f4bb59bad4e6209316064cb3cfa3c 100644 (file)
@@ -84,6 +84,8 @@ set g_balance_machinegun_spread_add 0
 set g_balance_machinegun_spread_decay 0
 set g_balance_machinegun_spread_max 0
 set g_balance_machinegun_spread_min 0
+set g_balance_machinegun_spread_cold_damagemultiplier 1
+set g_balance_machinegun_spread_heat_damagemultiplier 1
 set g_balance_machinegun_sustained_ammo 1
 set g_balance_machinegun_sustained_damage 10
 set g_balance_machinegun_sustained_force 3
index 803ae377d692a90a28400422c225a99d8dc8fae2..e24b172e8436914fec7e855fc89663871998b158 100644 (file)
@@ -84,6 +84,8 @@ set g_balance_machinegun_spread_add 0.012
 set g_balance_machinegun_spread_decay 0.048
 set g_balance_machinegun_spread_max 0.05
 set g_balance_machinegun_spread_min 0.02
+set g_balance_machinegun_spread_cold_damagemultiplier 1
+set g_balance_machinegun_spread_heat_damagemultiplier 1
 set g_balance_machinegun_sustained_ammo 1
 set g_balance_machinegun_sustained_damage 10
 set g_balance_machinegun_sustained_force 3
index 103d50b5beb9dd6b49d332ceb1c1d20b9f455b43..89d3692a1dc5c4c9f2f5f605812f624398ba3a99 100644 (file)
@@ -30,6 +30,31 @@ void MachineGun_Update_Spread(entity actor, .entity weaponentity)
        actor.(weaponentity).spreadUpdateTime = time;
 }
 
+ERASEABLE
+float MachineGun_Heat(float spread_accum)
+{
+       // function for reducing mg's damage with no spread and adding damage with
+       // heated up barrel or vice versa depending on the values of exposed cvars
+       float heatMultiplierApplicationPercent = 0.5;
+       float coldMultiplierApplicationPercent = 0.5;
+
+       float spreadSpectrumDistance = fabs(WEP_CVAR(WEP_MACHINEGUN, spread_max) - WEP_CVAR(WEP_MACHINEGUN, spread_min));
+
+       if (spreadSpectrumDistance > 0) // avoid division by 0, can never be < 0 either due to how it is set when defined
+       {
+               heatMultiplierApplicationPercent = spread_accum / spreadSpectrumDistance;
+               coldMultiplierApplicationPercent = 1 - heatMultiplierApplicationPercent;
+       }
+
+       // example where low end has halved damage and high end has tripled damage:
+       // with 50% spread accumulation: heat = (0.5 * 0.5) + (0.5 * 3) = 0.25 + 1.5 = 1.75 damage multiplier
+       // with 90% spread accumulation: heat = (0.1 * 0.5) + (0.9 * 3) = 0.05 + 2.7 = 2.75 damage multiplier
+       float heat = (coldMultiplierApplicationPercent * WEP_CVAR(WEP_MACHINEGUN, spread_cold_damagemultiplier))
+                  + (heatMultiplierApplicationPercent * WEP_CVAR(WEP_MACHINEGUN, spread_heat_damagemultiplier));
+
+       return heat;
+}
+
 void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity weaponentity)
 {
        W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((actor.(weaponentity).misc_bulletcounter == 1) ? WEP_CVAR(WEP_MACHINEGUN, first_damage) : WEP_CVAR(WEP_MACHINEGUN, sustained_damage)), deathtype);
@@ -138,6 +163,8 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
 
        float spread_accum = actor.(weaponentity).machinegun_spread_accumulation;
 
+       float heat = MachineGun_Heat(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;
@@ -147,7 +174,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
        fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir,
                           spread_accuracy,
                           WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
-                          WEP_CVAR(WEP_MACHINEGUN, sustained_damage),
+                          WEP_CVAR(WEP_MACHINEGUN, sustained_damage) * heat,
                           WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
                           WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
                           WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
@@ -187,10 +214,12 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
 
        float spread_accum = actor.(weaponentity).machinegun_spread_accumulation;
 
+       float heat = MachineGun_Heat(spread_accum);
+
        fireBullet_falloff(actor, weaponentity, w_shotorg, w_shotdir,
                           WEP_CVAR(WEP_MACHINEGUN, burst_spread),
                           WEP_CVAR(WEP_MACHINEGUN, solidpenetration),
-                          WEP_CVAR(WEP_MACHINEGUN, sustained_damage),
+                          WEP_CVAR(WEP_MACHINEGUN, sustained_damage) * heat,
                           WEP_CVAR(WEP_MACHINEGUN, damagefalloff_halflife),
                           WEP_CVAR(WEP_MACHINEGUN, damagefalloff_mindist),
                           WEP_CVAR(WEP_MACHINEGUN, damagefalloff_maxdist),
index 10bfc08f0b477b25b566efcceacc94821f582c45..824ecc3d471e4a99b8467d746138d2fd9c96a504 100644 (file)
@@ -46,6 +46,8 @@ CLASS(MachineGun, Weapon)
                P(class, prefix, spread_decay, float, NONE) \
                P(class, prefix, spread_max, float, NONE) \
                P(class, prefix, spread_min, float, NONE) \
+               P(class, prefix, spread_cold_damagemultiplier, float, NONE) \
+               P(class, prefix, spread_heat_damagemultiplier, float, NONE) \
                P(class, prefix, sustained_ammo, float, NONE) \
                P(class, prefix, sustained_damage, float, NONE) \
                P(class, prefix, sustained_force, float, NONE) \