193 - Requesting a Shotgun Hit
This commit is contained in:
parent
87d05490a5
commit
8feb5dcbad
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue