Skip to content

Commit

Permalink
Separate Damage&Momentum Scaling, Trace To HitBox
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Deaod committed Sep 9, 2023
1 parent 2b2998d commit a536932
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
59 changes: 52 additions & 7 deletions Classes/ST_Mutator.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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
);
}
Expand Down
10 changes: 7 additions & 3 deletions Classes/WeaponSettings.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -148,6 +150,8 @@ defaultproperties
bEnableEnhancedSplash=True
bEnableEnhancedSplashBio=False
bEnableEnhancedSplashCombo=False
SplashMaxDiffraction=0.5
SplashMinDiffractionDistance=50.0

WarheadSelectTime=0.5
WarheadDownTime=0.233333
Expand Down

0 comments on commit a536932

Please sign in to comment.