Skip to content

Commit

Permalink
Apply Reduced Hitbox To Sniper/Enforcer/Shock Beam
Browse files Browse the repository at this point in the history
Removed weapon setting bEnhancedHeadshotDetection.
Added weapon setting SniperUseReducedHitbox.
Added weapon setting ShockBeamUseReducedHitbox.
Added weapon setting EnforcerUseReducedHitbox.

SniperRifle behavior unaffected if SniperUseReducedHitbox matches
bEnhancedHeadshotDetection before. Ripper headshot will always use
default behavior now.
  • Loading branch information
Deaod committed Jul 29, 2024
1 parent c05ef0a commit 1d370fd
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 13 deletions.
6 changes: 0 additions & 6 deletions Classes/ST_Mutator.uc
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ function bool CheckHeadShot(Pawn P, vector HitLocation, vector Direction) {
if (P == none)
return false;

if (WeaponSettings.bEnhancedHeadshotDetection == false)
return (HitLocation.Z - P.Location.Z > 0.62 * P.CollisionHeight);

if (HitLocation.Z - P.Location.Z <= 0.3 * P.CollisionHeight)
return false;

Expand Down Expand Up @@ -475,9 +472,6 @@ function bool CheckBodyShot(Pawn P, vector HitLocation, vector Direction) {
if (P == none)
return false;

if (WeaponSettings.bEnhancedHeadshotDetection == false)
return CheckHeadShot(P, HitLocation, Direction) == false;

if (CollChecker == none || CollChecker.bDeleteMe) {
CollChecker = Spawn(class'ST_HitTestHelper',self, , P.Location);
CollChecker.bCollideWorld = false;
Expand Down
4 changes: 2 additions & 2 deletions Classes/ST_Razor2.uc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ auto state Flying
Dir = Normal(Velocity);
if (bCanHitInstigator || (Other != Instigator)) {
if (Role == ROLE_Authority) {
if (Other.bIsPawn && STM.CheckHeadShot(Pawn(Other), HitLocation, Dir) &&
if (Other.bIsPawn && (HitLocation.Z - Other.Location.Z > 0.62 * Other.CollisionHeight) &&
(!Instigator.IsA('Bot') || !Bot(Instigator).bNovice)
) {
Other.TakeDamage(
Expand All @@ -37,7 +37,7 @@ auto state Flying
STM.WeaponSettings.RipperHeadshotMomentum * MomentumTransfer * Dir,
'decapitated'
);
} else if (Other.bIsPawn == false || STM.CheckBodyShot(Pawn(Other), HitLocation, Dir)) {
} else {
Other.TakeDamage(
STM.WeaponSettings.RipperPrimaryDamage,
instigator,
Expand Down
33 changes: 33 additions & 0 deletions Classes/ST_ShockRifle.uc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ function PostBeginPlay()
break; // Find master :D
}

function TraceFire(float Accuracy) {
local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
local actor Other;
local Pawn PawnOwner;

PawnOwner = Pawn(Owner);

Owner.MakeNoise(PawnOwner.SoundDampening);
GetAxes(PawnOwner.ViewRotation,X,Y,Z);
StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.Y * Y + FireOffset.Z * Z;
EndTrace = StartTrace + (Accuracy * (FRand() - 0.5 )* Y * 1000) + (Accuracy * (FRand() - 0.5 ) * Z * 1000);

if (bBotSpecialMove && (Tracked != None) && (
((Owner.Acceleration == vect(0,0,0)) && (VSize(Owner.Velocity) < 40)) ||
(Normal(Owner.Velocity) Dot Normal(Tracked.Velocity) > 0.95)
)
) {
EndTrace += 10000 * Normal(Tracked.Location - StartTrace);
} else {
AdjustedAim = PawnOwner.AdjustAim(1000000, StartTrace, 2.75*AimError, False, False);
EndTrace += (10000 * vector(AdjustedAim));
}

Tracked = None;
bBotSpecialMove = false;

if (STM.WeaponSettings.ShockBeamUseReducedHitbox)
Other = STM.TraceShot(HitLocation, HitNormal, EndTrace, StartTrace, PawnOwner);
else
Other = PawnOwner.TraceShot(HitLocation,HitNormal,EndTrace,StartTrace);
ProcessTraceHit(Other, HitLocation, HitNormal, vector(AdjustedAim),Y,Z);
}

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local PlayerPawn PlayerOwner;
Expand Down
16 changes: 13 additions & 3 deletions Classes/ST_SniperRifle.uc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ function TraceFire(float Accuracy) {
StartTrace = Owner.Location + PawnOwner.Eyeheight * vect(0,0,1);
AdjustedAim = PawnOwner.AdjustAim(1000000, StartTrace, 2*AimError, False, False);
X = vector(AdjustedAim);
EndTrace = StartTrace + 100000 * X;
Other = STM.TraceShot(HitLocation, HitNormal, EndTrace, StartTrace, PawnOwner);
EndTrace = StartTrace + 100000 * X;
if (STM.WeaponSettings.SniperUseReducedHitbox)
Other = STM.TraceShot(HitLocation, HitNormal, EndTrace, StartTrace, PawnOwner);
else
Other = PawnOwner.TraceShot(HitLocation, HitNormal, EndTrace, StartTrace);
ProcessTraceHit(Other, HitLocation, HitNormal, X,Y,Z);
}

Expand All @@ -77,7 +80,7 @@ function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vect
if (Other == Level) {
Spawn(class'UT_HeavyWallHitEffect',,, HitLocation+HitNormal, Rotator(HitNormal));
} else if ((Other != self) && (Other != Owner) && (Other != None)) {
if (Other.bIsPawn && STM.CheckHeadShot(Pawn(Other), HitLocation, X) &&
if (Other.bIsPawn && CheckHeadShot(Pawn(Other), HitLocation, X) &&
(instigator.IsA('PlayerPawn') || (instigator.IsA('Bot') && !Bot(Instigator).bNovice))
) {
Other.PlaySound(Sound 'ChunkHit',, 4.0,,100);
Expand Down Expand Up @@ -107,6 +110,13 @@ function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vect
}
}

function bool CheckHeadShot(Pawn P, vector HitLocation, vector BulletDir) {
if (STM.WeaponSettings.SniperUseReducedHitbox == false)
return (HitLocation.Z - P.Location.Z > 0.62 * P.CollisionHeight);

return STM.CheckHeadShot(P, HitLocation, BulletDir);
}

function SetSwitchPriority(pawn Other)
{ // Make sure "old" priorities are kept.
local int i;
Expand Down
41 changes: 41 additions & 0 deletions Classes/ST_enforcer.uc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,47 @@ function PostBeginPlay()
break; // Find master :D
}

function TraceFire(float Accuracy) {
local vector RealOffset;
local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
local Actor Other;
local Pawn PawnOwner;

RealOffset = FireOffset;
FireOffset *= 0.35;
if ( (SlaveEnforcer != None) || bIsSlave )
Accuracy = FClamp(3*Accuracy,0.75,3);
else if ( Owner.IsA('Bot') && !Bot(Owner).bNovice )
Accuracy = FMax(Accuracy, 0.45);

PawnOwner = Pawn(Owner);

Owner.MakeNoise(PawnOwner.SoundDampening);
GetAxes(PawnOwner.ViewRotation,X,Y,Z);
StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;
AdjustedAim = PawnOwner.AdjustAim(1000000, StartTrace, 2*AimError, False, False);
EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000
+ Accuracy * (FRand() - 0.5 ) * Z * 1000;
X = vector(AdjustedAim);
EndTrace += (10000 * X);
if (STM.WeaponSettings.EnforcerUseReducedHitbox)
Other = STM.TraceShot(HitLocation, HitNormal, EndTrace, StartTrace, PawnOwner);
else
Other = PawnOwner.TraceShot(HitLocation, HitNormal, EndTrace, StartTrace);
ProcessTraceHit(Other, HitLocation, HitNormal, X,Y,Z);

FireOffset = RealOffset;

// Higor: move slave enforcer to TraceFire start location
// to ensure firing sounds are played from the right place
if (Owner != None && (Level.NetMode == NM_DedicatedServer || Level.NetMode == NM_ListenServer)) {
if (bIsSlave && !bCollideActors)
SetLocation(Owner.Location + CalcDrawOffset());
else if (SlaveEnforcer != None && !SlaveEnforcer.bCollideActors)
SlaveEnforcer.SetLocation(Owner.Location + SlaveEnforcer.CalcDrawOffset());
}
}

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local UT_Shellcase s;
Expand Down
8 changes: 6 additions & 2 deletions Classes/WeaponSettings.uc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var config bool bEnhancedSplashIgnoreStationaryPawns;
var config float SplashMaxDiffraction;
var config float SplashMinDiffractionDistance;

var config bool bEnhancedHeadshotDetection;
var config float HeadHalfHeight;
var config float HeadRadius;

Expand All @@ -38,6 +37,7 @@ var config float SniperHeadshotDamage;
var config float SniperMomentum;
var config float SniperHeadshotMomentum;
var config float SniperReloadTime;
var config bool SniperUseReducedHitbox;

var config float EightballSelectTime;
var config float EightballDownTime;
Expand Down Expand Up @@ -97,6 +97,7 @@ var config float ShockSelectTime;
var config float ShockDownTime;
var config float ShockBeamDamage;
var config float ShockBeamMomentum;
var config bool ShockBeamUseReducedHitbox;
var config float ShockProjectileDamage;
var config float ShockProjectileHurtRadius;
var config float ShockProjectileMomentum;
Expand Down Expand Up @@ -124,6 +125,7 @@ var config float EnforcerMomentum;
var config float EnforcerReloadTime;
var config float EnforcerReloadTimeAlt;
var config float EnforcerReloadTimeRepeat;
var config bool EnforcerUseReducedHitbox;

var config bool EnforcerAllowDouble;
var config float EnforcerDamageDouble;
Expand Down Expand Up @@ -176,7 +178,6 @@ defaultproperties
SplashMaxDiffraction=0.5
SplashMinDiffractionDistance=50.0

bEnhancedHeadshotDetection=False
HeadHalfHeight=7.5
HeadRadius=10.0

Expand All @@ -190,6 +191,7 @@ defaultproperties
SniperMomentum=1.0
SniperHeadshotMomentum=1.0
SniperReloadTime=0.6666666666
SniperUseReducedHitbox=False

EightballSelectTime=0.606061
EightballDownTime=0.366667
Expand Down Expand Up @@ -249,6 +251,7 @@ defaultproperties
ShockDownTime=0.259259
ShockBeamDamage=40
ShockBeamMomentum=1.0
ShockBeamUseReducedHitbox=False
ShockProjectileDamage=55
ShockProjectileHurtRadius=70
ShockProjectileMomentum=1.0
Expand Down Expand Up @@ -276,6 +279,7 @@ defaultproperties
EnforcerReloadTime=0.27
EnforcerReloadTimeAlt=0.26
EnforcerReloadTimeRepeat=0.266667
EnforcerUseReducedHitbox=False

EnforcerAllowDouble=True
EnforcerDamageDouble=17
Expand Down

0 comments on commit 1d370fd

Please sign in to comment.