From a536932c93a824e357f5115f3e346861fd6acfa3 Mon Sep 17 00:00:00 2001 From: Lukas Bagaric Date: Sun, 10 Sep 2023 00:10:26 +0200 Subject: [PATCH] Separate Damage&Momentum Scaling, Trace To HitBox Added two new weapon settings: SplashMaxDiffraction - The maximum reduction possible through diffraction; Range: [0..1] SplashMinDiffractionDistance - No diffraction before this distance, biases calculated distance inside geometry --- Classes/ST_Mutator.uc | 59 ++++++++++++++++++++++++++++++++++----- Classes/WeaponSettings.uc | 10 +++++-- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/Classes/ST_Mutator.uc b/Classes/ST_Mutator.uc index dea254ca..828f3f87 100644 --- a/Classes/ST_Mutator.uc +++ b/Classes/ST_Mutator.uc @@ -922,9 +922,16 @@ final function EnhancedHurtRadius( ) { local actor Victim; local float damageScale, dist; - local vector Delta; + local float DamageDiffraction; + local float MomentumScale; + local vector MomentumDelta, MomentumDir; + local vector Delta, DeltaXY; + local vector Closest; local vector dir; + local vector SourceGeoLocation, SourceGeoNormal; + local vector VictimGeoLocation, VictimGeoNormal; + if (Source.bHurtEntry) return; @@ -943,6 +950,34 @@ final function EnhancedHurtRadius( if (Victim == self) continue; + Delta = Victim.Location - HitLocation; + DeltaXY = Delta * vect(1.0, 1.0, 0.0); + dist = VSize(Delta); + dir = Normal(Delta); + + if (Abs(Delta.Z) <= Victim.CollisionHeight) { + Closest = HitLocation + Normal(DeltaXY) * (VSize(DeltaXY) - Victim.CollisionRadius); + } else if (VSize(DeltaXY) <= Victim.CollisionRadius) { + if (Delta.Z > 0.0) + Closest = HitLocation + FMax(Delta.Z - Victim.CollisionHeight, 0.0) * vect(0.0, 0.0, 1.0); + else + Closest = HitLocation + FMin(Delta.Z + Victim.CollisionHeight, 0.0) * vect(0.0, 0.0, 1.0); + } else { + // Closest point must be on the cylinder rims, find out where + Closest = Victim.Location + dir * (Source.CollisionRadius / VSize(dir * vect(1.0, 1.0, 0.0))); + if (Delta.Z > 0.0) + Closest.Z = Victim.Location.Z - Victim.CollisionHeight; + else + Closest.Z = Victim.Location.Z + Victim.CollisionHeight; + } + + Delta = Closest - HitLocation; + if (VSize(Delta) > CollChecker.CollisionRadius) + continue; + + dist = VSize(Delta); + dir = Normal(Delta); + if (FastTrace(Victim.Location, Source.Location) == false) { if (Victim.IsA('Pawn') == false) continue; @@ -956,23 +991,33 @@ final function EnhancedHurtRadius( HitTestHelper.FlyTowards(Victim.Location, DamageRadius); if (FastTrace(Victim.Location, HitTestHelper.Location) == false) continue; + + Trace(SourceGeoLocation, SourceGeoNormal, Closest, HitLocation, false); + Trace(VictimGeoLocation, VictimGeoNormal, HitLocation, Closest, false); + + DamageDiffraction = + FClamp(WeaponSettings.SplashMaxDiffraction, 0.0, 1.0) * + FClamp((VSize(VictimGeoLocation - SourceGeoLocation) - WeaponSettings.SplashMinDiffractionDistance) / dist, 0.0, 1.0); } - Delta = Victim.Location - HitLocation; - dist = VSize(Delta); - dir = Normal(Delta); + MomentumDelta = Victim.Location - HitLocation; + MomentumDir = Normal(MomentumDelta); if (bIsRazor2Alt) - dir.Z = FMin(0.45, dir.Z); + MomentumDir.Z = FMin(0.45, MomentumDir.Z); + + damageScale = FMin(1.0 - dist/DamageRadius, 1.0); // apply upper bound to damage + damageScale *= (1.0 - DamageDiffraction); + MomentumScale = FClamp(1.0 - (VSize(MomentumDelta) - Victim.CollisionRadius)/DamageRadius, 0.0, 1.0); - damageScale = FMin(1.0 - (dist - Victim.CollisionRadius)/DamageRadius, 1.0); // apply upper bound to damage if (damageScale <= 0.0) continue; + Victim.TakeDamage( damageScale * DamageAmount, Source.Instigator, Victim.Location - 0.5 * (Victim.CollisionRadius + Victim.CollisionHeight) * dir, - (damageScale * Momentum * dir), + (MomentumScale * Momentum * MomentumDir), DamageName ); } diff --git a/Classes/WeaponSettings.uc b/Classes/WeaponSettings.uc index d21a81c0..b651af6e 100644 --- a/Classes/WeaponSettings.uc +++ b/Classes/WeaponSettings.uc @@ -14,9 +14,11 @@ var config bool bReplaceRocketLauncher; var config bool bReplaceSniperRifle; var config bool bReplaceWarheadLauncher; -var config bool bEnableEnhancedSplash; -var config bool bEnableEnhancedSplashBio; -var config bool bEnableEnhancedSplashCombo; +var config bool bEnableEnhancedSplash; +var config bool bEnableEnhancedSplashBio; +var config bool bEnableEnhancedSplashCombo; +var config float SplashMaxDiffraction; +var config float SplashMinDiffractionDistance; var config float WarheadSelectTime; var config float WarheadDownTime; @@ -148,6 +150,8 @@ defaultproperties bEnableEnhancedSplash=True bEnableEnhancedSplashBio=False bEnableEnhancedSplashCombo=False + SplashMaxDiffraction=0.5 + SplashMinDiffractionDistance=50.0 WarheadSelectTime=0.5 WarheadDownTime=0.233333