diff --git a/Content/Maps/BlasterMap.umap b/Content/Maps/BlasterMap.umap index 0a0b90c..4608d86 100644 Binary files a/Content/Maps/BlasterMap.umap and b/Content/Maps/BlasterMap.umap differ diff --git a/Source/Blaster/Components/LagCompensationComponent.cpp b/Source/Blaster/Components/LagCompensationComponent.cpp index 5824e50..331b2ed 100644 --- a/Source/Blaster/Components/LagCompensationComponent.cpp +++ b/Source/Blaster/Components/LagCompensationComponent.cpp @@ -37,7 +37,7 @@ void ULagCompensationComponent::ServerScoreRequest_Implementation(ABlasterCharac } void ULagCompensationComponent::ShotgunServerScoreRequest_Implementation(const TArray& HitCharacters, const FVector_NetQuantize& TraceStart, - const TArray& HitLocations, float HitTime, AWeapon* DamageCauser) + const TArray& 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; } diff --git a/Source/Blaster/Components/LagCompensationComponent.h b/Source/Blaster/Components/LagCompensationComponent.h index 1a29cff..07f73b6 100644 --- a/Source/Blaster/Components/LagCompensationComponent.h +++ b/Source/Blaster/Components/LagCompensationComponent.h @@ -92,8 +92,7 @@ public: const TArray& HitCharacters, const FVector_NetQuantize& TraceStart, const TArray& HitLocations, - float HitTime, - AWeapon* DamageCauser + float HitTime ); FShotgunServerSideRewindResult ShotgunServerSideRewind( diff --git a/Source/Blaster/Weapon/HitScanWeapon.cpp b/Source/Blaster/Weapon/HitScanWeapon.cpp index cca2925..305e34b 100644 --- a/Source/Blaster/Weapon/HitScanWeapon.cpp +++ b/Source/Blaster/Weapon/HitScanWeapon.cpp @@ -45,7 +45,7 @@ void AHitScanWeapon::Fire(const FVector& HitTarget) OwnerCharacter = OwnerCharacter == nullptr ? Cast(OwnerPawn) : OwnerCharacter; OwnerController = OwnerController == nullptr ? Cast(InstigatorController) : OwnerController; - if (OwnerCharacter && OwnerController && OwnerCharacter->GetLagCompensation()) + if (OwnerCharacter && OwnerController && OwnerCharacter->GetLagCompensation() && OwnerCharacter->IsLocallyControlled()) { OwnerCharacter->GetLagCompensation()->ServerScoreRequest( BlasterCharacter, diff --git a/Source/Blaster/Weapon/Shotgun.cpp b/Source/Blaster/Weapon/Shotgun.cpp index bb788da..7ad8bbd 100644 --- a/Source/Blaster/Weapon/Shotgun.cpp +++ b/Source/Blaster/Weapon/Shotgun.cpp @@ -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& HitTargets) { AWeapon::Fire(FVector()); - const APawn* OwnerPawn = Cast(GetOwner()); + APawn* OwnerPawn = Cast(GetOwner()); if (OwnerPawn == nullptr) return; AController* InstigatorController = OwnerPawn->GetController(); @@ -61,16 +63,39 @@ void AShotgun::FireShotgun(const TArray& HitTargets) } } } + + TArray 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(OwnerPawn) : OwnerCharacter; + OwnerController = OwnerController == nullptr ? Cast(InstigatorController) : OwnerController; + + if (OwnerCharacter && OwnerController && OwnerCharacter->GetLagCompensation() && OwnerCharacter->IsLocallyControlled()) + { + OwnerCharacter->GetLagCompensation()->ShotgunServerScoreRequest( + HitCharacters, + Start, + HitTargets, + OwnerController->GetServerTime() - OwnerController->SingleTripTime ); } }