213 - Head Shots for Server-Side Rewind
This commit is contained in:
parent
9b45b23dfd
commit
2a5c6cb50a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -32,7 +32,7 @@ void UBlasterAnimInstance::NativeUpdateAnimation(float DeltaTime)
|
||||||
bIsInAir = BlasterCharacter->GetCharacterMovement()->IsFalling();
|
bIsInAir = BlasterCharacter->GetCharacterMovement()->IsFalling();
|
||||||
bIsAccelerating = BlasterCharacter->GetCharacterMovement()->GetCurrentAcceleration().Size() > 0.f ? true : false;
|
bIsAccelerating = BlasterCharacter->GetCharacterMovement()->GetCurrentAcceleration().Size() > 0.f ? true : false;
|
||||||
bWeaponEquipped = BlasterCharacter->IsWeaponEquipped();
|
bWeaponEquipped = BlasterCharacter->IsWeaponEquipped();
|
||||||
EquippedWeapon = BlasterCharacter->GetPrimaryWeapon();
|
EquippedWeapon = BlasterCharacter->GetEquippedWeapon();
|
||||||
bIsCrouched = BlasterCharacter->bIsCrouched;
|
bIsCrouched = BlasterCharacter->bIsCrouched;
|
||||||
bAiming = BlasterCharacter->IsAiming();
|
bAiming = BlasterCharacter->IsAiming();
|
||||||
TurningInPlace = BlasterCharacter->GetTurningInPlace();
|
TurningInPlace = BlasterCharacter->GetTurningInPlace();
|
||||||
|
|
|
@ -230,7 +230,7 @@ void ABlasterCharacter::MulticastEliminated_Implementation(bool bPlayerLeftGame)
|
||||||
GetActorLocation()
|
GetActorLocation()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (IsLocallyControlled() && GetPrimaryWeapon() && GetPrimaryWeapon()->IsSniper() && IsAiming())
|
if (IsLocallyControlled() && GetEquippedWeapon() && GetEquippedWeapon()->IsSniper() && IsAiming())
|
||||||
{
|
{
|
||||||
ShowSniperScopeWidget(false);
|
ShowSniperScopeWidget(false);
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ void ABlasterCharacter::ReceiveDamage(AActor* DamagedActor, float Damage, const
|
||||||
if (bEliminated) return;
|
if (bEliminated) return;
|
||||||
|
|
||||||
float DamageToHealth = Damage;
|
float DamageToHealth = Damage;
|
||||||
if (Shield > 0)
|
if (Shield > 0.f)
|
||||||
{
|
{
|
||||||
if (Shield >= Damage)
|
if (Shield >= Damage)
|
||||||
{
|
{
|
||||||
|
@ -526,8 +526,8 @@ void ABlasterCharacter::ReceiveDamage(AActor* DamagedActor, float Damage, const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DamageToHealth = FMath::Clamp(DamageToHealth - Shield, 0.f, Damage);
|
||||||
Shield = 0.f;
|
Shield = 0.f;
|
||||||
DamageToHealth = FMath::Clamp(DamageToHealth - (Damage - Shield), 0.f, Damage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,7 +963,7 @@ bool ABlasterCharacter::IsAiming()
|
||||||
return Combat && Combat->bAiming;
|
return Combat && Combat->bAiming;
|
||||||
}
|
}
|
||||||
|
|
||||||
AWeapon* ABlasterCharacter::GetPrimaryWeapon()
|
AWeapon* ABlasterCharacter::GetEquippedWeapon()
|
||||||
{
|
{
|
||||||
if (Combat == nullptr) return nullptr;
|
if (Combat == nullptr) return nullptr;
|
||||||
return Combat->EquippedWeapon;
|
return Combat->EquippedWeapon;
|
||||||
|
|
|
@ -310,7 +310,7 @@ public:
|
||||||
bool IsAiming();
|
bool IsAiming();
|
||||||
FORCEINLINE float GetAO_Yaw() const { return AO_Yaw; }
|
FORCEINLINE float GetAO_Yaw() const { return AO_Yaw; }
|
||||||
FORCEINLINE float GetAO_Pitch() const { return AO_Pitch; }
|
FORCEINLINE float GetAO_Pitch() const { return AO_Pitch; }
|
||||||
AWeapon* GetPrimaryWeapon();
|
AWeapon* GetEquippedWeapon();
|
||||||
FORCEINLINE ETurningInPlace GetTurningInPlace() const { return TurningInPlace; }
|
FORCEINLINE ETurningInPlace GetTurningInPlace() const { return TurningInPlace; }
|
||||||
FVector GetHitTarget() const;
|
FVector GetHitTarget() const;
|
||||||
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
||||||
|
|
|
@ -411,17 +411,19 @@ FFramePackage ULagCompensationComponent::GetFrameToCheck(ABlasterCharacter* HitC
|
||||||
return FrameToCheck;
|
return FrameToCheck;
|
||||||
}
|
}
|
||||||
void ULagCompensationComponent::ServerScoreRequest_Implementation(ABlasterCharacter* HitCharacter, const FVector_NetQuantize& TraceStart,
|
void ULagCompensationComponent::ServerScoreRequest_Implementation(ABlasterCharacter* HitCharacter, const FVector_NetQuantize& TraceStart,
|
||||||
const FVector_NetQuantize& HitLocation, float HitTime, AWeapon* DamageCauser)
|
const FVector_NetQuantize& HitLocation, float HitTime)
|
||||||
{
|
{
|
||||||
const FServerSideRewindResult Confirm = ServerSideRewind(HitCharacter, TraceStart, HitLocation, HitTime);
|
const FServerSideRewindResult Confirm = ServerSideRewind(HitCharacter, TraceStart, HitLocation, HitTime);
|
||||||
|
|
||||||
if (Character && HitCharacter && DamageCauser && Confirm.bHitConfirmed)
|
if (Character && HitCharacter && Character->GetEquippedWeapon() && Confirm.bHitConfirmed)
|
||||||
{
|
{
|
||||||
|
const float Damage = Confirm.bHeadShot ? Character->GetEquippedWeapon()->GetHeadShotDamage() : Character->GetEquippedWeapon()->GetDamage();
|
||||||
|
|
||||||
UGameplayStatics::ApplyDamage(
|
UGameplayStatics::ApplyDamage(
|
||||||
HitCharacter,
|
HitCharacter,
|
||||||
DamageCauser->GetDamage(),
|
Damage,
|
||||||
Character->Controller,
|
Character->Controller,
|
||||||
DamageCauser,
|
Character->GetEquippedWeapon(),
|
||||||
UDamageType::StaticClass()
|
UDamageType::StaticClass()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -432,13 +434,15 @@ void ULagCompensationComponent::ProjectileServerScoreRequest_Implementation(ABla
|
||||||
{
|
{
|
||||||
const FServerSideRewindResult Confirm = ProjectileServerSideRewind(HitCharacter, TraceStart, InitialVelocity, HitTime);
|
const FServerSideRewindResult Confirm = ProjectileServerSideRewind(HitCharacter, TraceStart, InitialVelocity, HitTime);
|
||||||
|
|
||||||
if (Character && HitCharacter && Confirm.bHitConfirmed)
|
if (Character && HitCharacter && Character->GetEquippedWeapon() && Confirm.bHitConfirmed)
|
||||||
{
|
{
|
||||||
|
const float Damage = Confirm.bHeadShot ? Character->GetEquippedWeapon()->GetHeadShotDamage() : Character->GetEquippedWeapon()->GetDamage();
|
||||||
|
|
||||||
UGameplayStatics::ApplyDamage(
|
UGameplayStatics::ApplyDamage(
|
||||||
HitCharacter,
|
HitCharacter,
|
||||||
Character->GetPrimaryWeapon()->GetDamage(),
|
Damage,
|
||||||
Character->Controller,
|
Character->Controller,
|
||||||
Character->GetPrimaryWeapon(),
|
Character->GetEquippedWeapon(),
|
||||||
UDamageType::StaticClass()
|
UDamageType::StaticClass()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -451,22 +455,22 @@ void ULagCompensationComponent::ShotgunServerScoreRequest_Implementation(const T
|
||||||
|
|
||||||
for (auto& HitCharacter : HitCharacters)
|
for (auto& HitCharacter : HitCharacters)
|
||||||
{
|
{
|
||||||
if (HitCharacter == nullptr || Character == nullptr || HitCharacter->GetPrimaryWeapon() == nullptr) continue;
|
if (HitCharacter == nullptr || Character == nullptr || HitCharacter->GetEquippedWeapon() == nullptr) continue;
|
||||||
float TotalDamage = 0.f;
|
float TotalDamage = 0.f;
|
||||||
if (Confirm.Headshots.Contains(HitCharacter))
|
if (Confirm.Headshots.Contains(HitCharacter))
|
||||||
{
|
{
|
||||||
TotalDamage += Confirm.Headshots[HitCharacter] * Character->GetPrimaryWeapon()->GetDamage();
|
TotalDamage += Confirm.Headshots[HitCharacter] * Character->GetEquippedWeapon()->GetHeadShotDamage();
|
||||||
}
|
}
|
||||||
if (Confirm.BodyShots.Contains(HitCharacter))
|
if (Confirm.BodyShots.Contains(HitCharacter))
|
||||||
{
|
{
|
||||||
TotalDamage += Confirm.BodyShots[HitCharacter] * Character->GetPrimaryWeapon()->GetDamage();
|
TotalDamage += Confirm.BodyShots[HitCharacter] * Character->GetEquippedWeapon()->GetDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
UGameplayStatics::ApplyDamage(
|
UGameplayStatics::ApplyDamage(
|
||||||
HitCharacter,
|
HitCharacter,
|
||||||
TotalDamage,
|
TotalDamage,
|
||||||
Character->Controller,
|
Character->Controller,
|
||||||
Character->GetPrimaryWeapon(),
|
Character->GetEquippedWeapon(),
|
||||||
UDamageType::StaticClass()
|
UDamageType::StaticClass()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,7 @@ public:
|
||||||
ABlasterCharacter* HitCharacter,
|
ABlasterCharacter* HitCharacter,
|
||||||
const FVector_NetQuantize& TraceStart,
|
const FVector_NetQuantize& TraceStart,
|
||||||
const FVector_NetQuantize& HitLocation,
|
const FVector_NetQuantize& HitLocation,
|
||||||
float HitTime,
|
float HitTime
|
||||||
AWeapon* DamageCauser
|
|
||||||
);
|
);
|
||||||
|
|
||||||
UFUNCTION(Server, Reliable)
|
UFUNCTION(Server, Reliable)
|
||||||
|
|
|
@ -54,8 +54,7 @@ void AHitScanWeapon::Fire(const FVector& HitTarget)
|
||||||
BlasterCharacter,
|
BlasterCharacter,
|
||||||
Start,
|
Start,
|
||||||
HitTarget,
|
HitTarget,
|
||||||
OwnerController->GetServerTime() - OwnerController->SingleTripTime,
|
OwnerController->GetServerTime() - OwnerController->SingleTripTime
|
||||||
this
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ void AWeapon::OnRep_Owner()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OwnerCharacter = OwnerCharacter == nullptr ? Cast<ABlasterCharacter>(Owner) : OwnerCharacter;
|
OwnerCharacter = OwnerCharacter == nullptr ? Cast<ABlasterCharacter>(Owner) : OwnerCharacter;
|
||||||
if (OwnerCharacter && OwnerCharacter->GetPrimaryWeapon() && OwnerCharacter->GetPrimaryWeapon() == this)
|
if (OwnerCharacter && OwnerCharacter->GetEquippedWeapon() && OwnerCharacter->GetEquippedWeapon() == this)
|
||||||
{
|
{
|
||||||
SetHUDAmmo();
|
SetHUDAmmo();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue