199 - Projectile Score Request
This commit is contained in:
parent
4ae87bee2a
commit
6acf090c07
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -37,6 +37,24 @@ void ULagCompensationComponent::ServerScoreRequest_Implementation(ABlasterCharac
|
|||
}
|
||||
}
|
||||
|
||||
void ULagCompensationComponent::ProjectileServerScoreRequest_Implementation(ABlasterCharacter* HitCharacter, const FVector_NetQuantize& TraceStart,
|
||||
const FVector_NetQuantize100& InitialVelocity, float HitTime)
|
||||
{
|
||||
const FServerSideRewindResult Confirm = ProjectilServerSideRewind(HitCharacter, TraceStart, InitialVelocity, HitTime);
|
||||
|
||||
if (Character && HitCharacter && Confirm.bHitConfirmed)
|
||||
{
|
||||
|
||||
UGameplayStatics::ApplyDamage(
|
||||
HitCharacter,
|
||||
Character->GetPrimaryWeapon()->GetDamage(),
|
||||
Character->Controller,
|
||||
Character->GetPrimaryWeapon(),
|
||||
UDamageType::StaticClass()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void ULagCompensationComponent::ShotgunServerScoreRequest_Implementation(const TArray<ABlasterCharacter*>& HitCharacters, const FVector_NetQuantize& TraceStart,
|
||||
const TArray<FVector_NetQuantize>& HitLocations, float HitTime)
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
const FVector_NetQuantize& HitLocation,
|
||||
float HitTime
|
||||
);
|
||||
|
||||
|
||||
// Projectiles
|
||||
FServerSideRewindResult ProjectilServerSideRewind(
|
||||
ABlasterCharacter* HitCharacter,
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
const TArray<FVector_NetQuantize>& HitLocations,
|
||||
float HitTime
|
||||
);
|
||||
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerScoreRequest(
|
||||
ABlasterCharacter* HitCharacter,
|
||||
|
@ -105,14 +105,22 @@ public:
|
|||
float HitTime,
|
||||
AWeapon* DamageCauser
|
||||
);
|
||||
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ProjectileServerScoreRequest(
|
||||
ABlasterCharacter* HitCharacter,
|
||||
const FVector_NetQuantize& TraceStart,
|
||||
const FVector_NetQuantize100& InitialVelocity,
|
||||
float HitTime
|
||||
);
|
||||
|
||||
FShotgunServerSideRewindResult ShotgunServerSideRewind(
|
||||
const TArray<ABlasterCharacter*>& HitCharacters,
|
||||
const FVector_NetQuantize& TraceStart,
|
||||
const TArray<FVector_NetQuantize>& HitLocations,
|
||||
float HitTime
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
void SaveFramePackage();
|
||||
|
@ -141,14 +149,14 @@ protected:
|
|||
const FVector_NetQuantize100& InitialVelocity,
|
||||
float HitTime
|
||||
);
|
||||
|
||||
|
||||
// Shotgun
|
||||
FShotgunServerSideRewindResult ShotgunConfirmHit(
|
||||
const TArray<FFramePackage>& FramePackages,
|
||||
const FVector_NetQuantize& TraceStart,
|
||||
const TArray<FVector_NetQuantize>& HitLocations
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
ABlasterCharacter* Character;
|
||||
|
|
|
@ -30,7 +30,8 @@ void AHitScanWeapon::Fire(const FVector& HitTarget)
|
|||
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(FireHit.GetActor());
|
||||
if (BlasterCharacter && InstigatorController)
|
||||
{
|
||||
if (HasAuthority() && !bUseServerSideRewind)
|
||||
bool bCauseAuthDamage = !bUseServerSideRewind || OwnerPawn->IsLocallyControlled();
|
||||
if (HasAuthority() && bCauseAuthDamage)
|
||||
{
|
||||
UGameplayStatics::ApplyDamage(
|
||||
BlasterCharacter,
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "ProjectileBullet.h"
|
||||
|
||||
#include "Blaster/Character/BlasterCharacter.h"
|
||||
#include "Blaster/Components/LagCompensationComponent.h"
|
||||
#include "Blaster/PlayerController/BlasterPlayerController.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GameFramework/ProjectileMovementComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
@ -35,13 +38,29 @@ void AProjectileBullet::PostEditChangeProperty(FPropertyChangedEvent& Event)
|
|||
|
||||
void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
|
||||
{
|
||||
ACharacter* OwnerCharacter = Cast<ACharacter>(GetOwner());
|
||||
ABlasterCharacter* OwnerCharacter = Cast<ABlasterCharacter>(GetOwner());
|
||||
if (OwnerCharacter)
|
||||
{
|
||||
AController* OwnerController = OwnerCharacter->Controller;
|
||||
ABlasterPlayerController* OwnerController = Cast<ABlasterPlayerController>(OwnerCharacter->Controller);
|
||||
if (OwnerController)
|
||||
{
|
||||
UGameplayStatics::ApplyDamage(OtherActor, Damage, OwnerController, this, UDamageType::StaticClass());
|
||||
if (OwnerCharacter->HasAuthority() && !bUseServerSideRewind)
|
||||
{
|
||||
UGameplayStatics::ApplyDamage(OtherActor, Damage, OwnerController, this, UDamageType::StaticClass());
|
||||
Super::OnHit(HitComp, OtherActor, OtherComp, NormalImpulse, Hit);
|
||||
return;
|
||||
}
|
||||
|
||||
ABlasterCharacter* HitCharacter = Cast<ABlasterCharacter>(OtherActor);
|
||||
if (bUseServerSideRewind && OwnerCharacter->GetLagCompensation() && OwnerCharacter->IsLocallyControlled() && HitCharacter)
|
||||
{
|
||||
OwnerCharacter->GetLagCompensation()->ProjectileServerScoreRequest(
|
||||
HitCharacter,
|
||||
TraceStart,
|
||||
InitialVelocity,
|
||||
OwnerController->GetServerTime() - OwnerController->SingleTripTime
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ void AProjectileWeapon::Fire(const FVector& HitTarget)
|
|||
SpawnedProjectile->bUseServerSideRewind = false;
|
||||
SpawnedProjectile->Damage = Damage;
|
||||
}
|
||||
else // Server, not locally controlled - spawn non-replicated projectile, no SSR
|
||||
else // Server, not locally controlled - spawn non-replicated projectile, SSR
|
||||
{
|
||||
SpawnedProjectile = World->SpawnActor<AProjectile>(ServerSideRewindProjectileClass, SocketTransform.GetLocation(), TargetRotation, SpawnParams);
|
||||
SpawnedProjectile->bUseServerSideRewind = false;
|
||||
SpawnedProjectile->bUseServerSideRewind = true;
|
||||
}
|
||||
}
|
||||
else // Client, using SSR
|
||||
|
|
|
@ -69,7 +69,8 @@ void AShotgun::FireShotgun(const TArray<FVector_NetQuantize>& HitTargets)
|
|||
{
|
||||
if (HitPair.Key && InstigatorController)
|
||||
{
|
||||
if (HasAuthority() && !bUseServerSideRewind)
|
||||
bool bCauseAuthDamage = !bUseServerSideRewind || OwnerPawn->IsLocallyControlled();
|
||||
if (HasAuthority() && bCauseAuthDamage)
|
||||
{
|
||||
UGameplayStatics::ApplyDamage(
|
||||
HitPair.Key, // Character that was hit
|
||||
|
|
Loading…
Reference in New Issue