193 - Requesting a Shotgun Hit

This commit is contained in:
Kingsmedia 2022-05-27 21:57:52 +02:00
parent 87d05490a5
commit 8feb5dcbad
5 changed files with 38 additions and 12 deletions

Binary file not shown.

View File

@ -37,7 +37,7 @@ void ULagCompensationComponent::ServerScoreRequest_Implementation(ABlasterCharac
}
void ULagCompensationComponent::ShotgunServerScoreRequest_Implementation(const TArray<ABlasterCharacter*>& HitCharacters, const FVector_NetQuantize& TraceStart,
const TArray<FVector_NetQuantize>& HitLocations, float HitTime, AWeapon* DamageCauser)
const TArray<FVector_NetQuantize>& HitLocations, float HitTime)
{
FShotgunServerSideRewindResult Confirm = ShotgunServerSideRewind(HitCharacters, TraceStart, HitLocations, HitTime);
@ -448,6 +448,8 @@ FFramePackage ULagCompensationComponent::GetFrameToCheck(ABlasterCharacter* HitC
FrameToCheck = InterpBetweenFrames(Older->GetValue(), Younger->GetValue(), HitTime);
}
FrameToCheck.Character = HitCharacter;
return FrameToCheck;
}

View File

@ -92,8 +92,7 @@ public:
const TArray<ABlasterCharacter*>& HitCharacters,
const FVector_NetQuantize& TraceStart,
const TArray<FVector_NetQuantize>& HitLocations,
float HitTime,
AWeapon* DamageCauser
float HitTime
);
FShotgunServerSideRewindResult ShotgunServerSideRewind(

View File

@ -45,7 +45,7 @@ void AHitScanWeapon::Fire(const FVector& HitTarget)
OwnerCharacter = OwnerCharacter == nullptr ? Cast<ABlasterCharacter>(OwnerPawn) : OwnerCharacter;
OwnerController = OwnerController == nullptr ? Cast<ABlasterPlayerController>(InstigatorController) : OwnerController;
if (OwnerCharacter && OwnerController && OwnerCharacter->GetLagCompensation())
if (OwnerCharacter && OwnerController && OwnerCharacter->GetLagCompensation() && OwnerCharacter->IsLocallyControlled())
{
OwnerCharacter->GetLagCompensation()->ServerScoreRequest(
BlasterCharacter,

View File

@ -4,6 +4,8 @@
#include "Shotgun.h"
#include "Blaster/Character/BlasterCharacter.h"
#include "Blaster/Components/LagCompensationComponent.h"
#include "Blaster/PlayerController/BlasterPlayerController.h"
#include "Engine/SkeletalMeshSocket.h"
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetMathLibrary.h"
@ -11,7 +13,7 @@
void AShotgun::FireShotgun(const TArray<FVector_NetQuantize>& HitTargets)
{
AWeapon::Fire(FVector());
const APawn* OwnerPawn = Cast<APawn>(GetOwner());
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if (OwnerPawn == nullptr) return;
AController* InstigatorController = OwnerPawn->GetController();
@ -61,16 +63,39 @@ void AShotgun::FireShotgun(const TArray<FVector_NetQuantize>& HitTargets)
}
}
}
TArray<ABlasterCharacter*> HitCharacters;
for (auto HitPair : HitMap)
{
if (HitPair.Key && HasAuthority() && InstigatorController)
if (HitPair.Key && InstigatorController)
{
UGameplayStatics::ApplyDamage(
HitPair.Key, // Character that was hit
Damage * HitPair.Value, // Multiply Damage by number of times hit
InstigatorController,
this,
UDamageType::StaticClass()
if (HasAuthority() && !bUseServerSideRewind)
{
UGameplayStatics::ApplyDamage(
HitPair.Key, // Character that was hit
Damage * HitPair.Value, // Multiply Damage by number of times hit
InstigatorController,
this,
UDamageType::StaticClass()
);
}
HitCharacters.Add(HitPair.Key);
}
}
if (!HasAuthority() && bUseServerSideRewind)
{
OwnerCharacter = OwnerCharacter == nullptr ? Cast<ABlasterCharacter>(OwnerPawn) : OwnerCharacter;
OwnerController = OwnerController == nullptr ? Cast<ABlasterPlayerController>(InstigatorController) : OwnerController;
if (OwnerCharacter && OwnerController && OwnerCharacter->GetLagCompensation() && OwnerCharacter->IsLocallyControlled())
{
OwnerCharacter->GetLagCompensation()->ShotgunServerScoreRequest(
HitCharacters,
Start,
HitTargets,
OwnerController->GetServerTime() - OwnerController->SingleTripTime
);
}
}