Skip to content

Commit

Permalink
Fix SniperRifle Shots Ending On Hitboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Deaod committed Jul 26, 2024
1 parent 6cbc950 commit 869975d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
33 changes: 33 additions & 0 deletions Classes/ST_Mutator.uc
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,39 @@ function bool CheckBodyShot(Pawn P, vector HitLocation, vector Direction) {
return Result;
}

function Actor TraceShot(out vector HitLocation, out vector HitNormal, vector EndTrace, vector StartTrace, Pawn PawnOwner) {
local Actor A, Other;
local Pawn P;
local bool bSProjBlocks;
local bool bWeaponShock;
local vector Dir;

bSProjBlocks = WeaponSettings.ShockProjectileBlockBullets;
bWeaponShock = (PawnOwner.Weapon != none && PawnOwner.Weapon.IsA('ShockRifle'));
Dir = Normal(EndTrace - StartTrace);

foreach TraceActors(class'Actor', A, HitLocation, HitNormal, EndTrace, StartTrace) {
P = Pawn(A);
if (P != none) {
if (P == PawnOwner)
continue;
if (P.AdjustHitLocation(HitLocation, EndTrace - StartTrace) == false)
continue;
if (CheckBodyShot(P, HitLocation, Dir) == false && CheckHeadShot(P, HitLocation, Dir) == false)
continue;

Other = A;
} else if ((A == Level) || (Mover(A) != None) || A.bProjTarget || (A.bBlockPlayers && A.bBlockActors)) {
if (bSProjBlocks || A.IsA('ShockProj') == false || bWeaponShock)
Other = A;
}

if (Other != none)
break;
}
return Other;
}

defaultproperties {
DefaultWeapon=Class'ST_ImpactHammer'

Expand Down
2 changes: 1 addition & 1 deletion 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 && STM.CheckHeadShot(Pawn(Other), HitLocation, Dir) &&
(!Instigator.IsA('Bot') || !Bot(Instigator).bNovice)
) {
Other.TakeDamage(
Expand Down
25 changes: 21 additions & 4 deletions Classes/ST_SniperRifle.uc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ 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 + PawnOwner.Eyeheight * vect(0,0,1);
AdjustedAim = PawnOwner.AdjustAim(1000000, StartTrace, 2*AimError, False, False);
X = vector(AdjustedAim);
EndTrace = StartTrace + 10000 * X;
Other = STM.TraceShot(HitLocation, HitNormal, EndTrace, StartTrace, PawnOwner);
ProcessTraceHit(Other, HitLocation, HitNormal, X,Y,Z);
}

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local UT_Shellcase s;
Expand All @@ -60,7 +77,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 && STM.CheckHeadShot(Pawn(Other), HitLocation, X) &&
(instigator.IsA('PlayerPawn') || (instigator.IsA('Bot') && !Bot(Instigator).bNovice))
) {
Other.PlaySound(Sound 'ChunkHit',, 4.0,,100);
Expand All @@ -70,12 +87,14 @@ function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vect
HitLocation,
STM.WeaponSettings.SniperHeadshotMomentum * 35000 * X,
AltDamageType);
} else if (Other.bIsPawn == false || STM.CheckBodyShot(Pawn(Other), HitLocation, X)) {
} else {
if (Other.bIsPawn) {
Other.PlaySound(Sound 'ChunkHit',, 4.0,,100);
Momentum = STM.WeaponSettings.SniperMomentum * 30000.0*X;
} else {
Momentum = 30000.0*X;
if (Other.IsA('Carcass') == false)
Spawn(class'UT_SpriteSmokePuff',,,HitLocation+HitNormal*9);
}

Other.TakeDamage(
Expand All @@ -85,8 +104,6 @@ function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vect
Momentum,
MyDamageType);
}
if (!Other.bIsPawn && !Other.IsA('Carcass'))
Spawn(class'UT_SpriteSmokePuff',,,HitLocation+HitNormal*9);
}
}

Expand Down

0 comments on commit 869975d

Please sign in to comment.