203 - Cheating and Validation
This commit is contained in:
parent
6eb1db5505
commit
2f3404195c
|
@ -129,7 +129,7 @@ void UCombatComponent::FireProjectileWeapon()
|
|||
{
|
||||
HitTarget = PrimaryWeapon->bUseScatter ? PrimaryWeapon->TraceEndWithScatter(HitTarget) : HitTarget;
|
||||
if (!Character->HasAuthority()) LocalFire(HitTarget);
|
||||
ServerFire(HitTarget);
|
||||
ServerFire(HitTarget, PrimaryWeapon->FireDelay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void UCombatComponent::FireHitScanWeapon()
|
|||
{
|
||||
HitTarget = PrimaryWeapon->bUseScatter ? PrimaryWeapon->TraceEndWithScatter(HitTarget) : HitTarget;
|
||||
if (!Character->HasAuthority()) LocalFire(HitTarget);
|
||||
ServerFire(HitTarget);
|
||||
ServerFire(HitTarget, PrimaryWeapon->FireDelay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ void UCombatComponent::FireShotgun()
|
|||
TArray<FVector_NetQuantize> HitTargets;
|
||||
Shotgun->ShotgunTraceEndWithScatter(HitTarget, HitTargets);
|
||||
if (!Character->HasAuthority()) ShotgunLocalFire(HitTargets);
|
||||
ServerShotgunFire(HitTargets);
|
||||
ServerShotgunFire(HitTargets, PrimaryWeapon->FireDelay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,22 +177,34 @@ void UCombatComponent::FireTimerFinished()
|
|||
ReloadEmptyWeapon();
|
||||
}
|
||||
|
||||
void UCombatComponent::ServerFire_Implementation(const FVector_NetQuantize& TraceHitTarget)
|
||||
void UCombatComponent::ServerFire_Implementation(const FVector_NetQuantize& TraceHitTarget, float FireDelay)
|
||||
{
|
||||
MulticastFire(TraceHitTarget);
|
||||
}
|
||||
|
||||
bool UCombatComponent::ServerFire_Validate(const FVector_NetQuantize& TraceHitTarget, float FireDelay)
|
||||
{
|
||||
if (PrimaryWeapon == nullptr) return true;
|
||||
return FMath::IsNearlyEqual(PrimaryWeapon->FireDelay, FireDelay, 0.001f);
|
||||
}
|
||||
|
||||
void UCombatComponent::MulticastFire_Implementation(const FVector_NetQuantize& TraceHitTarget)
|
||||
{
|
||||
if (Character && Character->IsLocallyControlled() && !Character->HasAuthority()) return;
|
||||
LocalFire(TraceHitTarget);
|
||||
}
|
||||
|
||||
void UCombatComponent::ServerShotgunFire_Implementation(const TArray<FVector_NetQuantize>& TraceHitTargets)
|
||||
void UCombatComponent::ServerShotgunFire_Implementation(const TArray<FVector_NetQuantize>& TraceHitTargets, float FireDelay)
|
||||
{
|
||||
MulticastShotgunFire(TraceHitTargets);
|
||||
}
|
||||
|
||||
bool UCombatComponent::ServerShotgunFire_Validate(const TArray<FVector_NetQuantize>& TraceHitTargets, float FireDelay)
|
||||
{
|
||||
if (PrimaryWeapon == nullptr) return true;
|
||||
return FMath::IsNearlyEqual(PrimaryWeapon->FireDelay, FireDelay, 0.001f);
|
||||
}
|
||||
|
||||
void UCombatComponent::MulticastShotgunFire_Implementation(const TArray<FVector_NetQuantize>& TraceHitTargets)
|
||||
{
|
||||
if (Character && Character->IsLocallyControlled() && !Character->HasAuthority()) return;
|
||||
|
@ -823,6 +835,8 @@ bool UCombatComponent::CanFire()
|
|||
|
||||
void UCombatComponent::OnRep_CarriedAmmo()
|
||||
{
|
||||
if (Character == nullptr) return;
|
||||
|
||||
Controller = Controller == nullptr ? Cast<ABlasterPlayerController>(Character->Controller) : Controller;
|
||||
if (Controller)
|
||||
{
|
||||
|
|
|
@ -71,14 +71,14 @@ protected:
|
|||
void FireHitScanWeapon();
|
||||
void FireShotgun();
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerFire(const FVector_NetQuantize& TraceHitTarget);
|
||||
UFUNCTION(Server, Reliable, WithValidation)
|
||||
void ServerFire(const FVector_NetQuantize& TraceHitTarget, float FireDelay);
|
||||
|
||||
UFUNCTION(NetMulticast, Reliable)
|
||||
void MulticastFire(const FVector_NetQuantize& TraceHitTarget);
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerShotgunFire(const TArray<FVector_NetQuantize>& TraceHitTargets);
|
||||
UFUNCTION(Server, Reliable, WithValidation)
|
||||
void ServerShotgunFire(const TArray<FVector_NetQuantize>& TraceHitTargets, float FireDelay);
|
||||
|
||||
UFUNCTION(NetMulticast, Reliable)
|
||||
void MulticastShotgunFire(const TArray<FVector_NetQuantize>& TraceHitTargets);
|
||||
|
|
Loading…
Reference in New Issue