208 - Spawning the Crown
This commit is contained in:
parent
45b9f170e7
commit
4fa586e648
Binary file not shown.
|
@ -3,11 +3,14 @@
|
||||||
|
|
||||||
#include "BlasterCharacter.h"
|
#include "BlasterCharacter.h"
|
||||||
|
|
||||||
|
#include "NiagaraComponent.h"
|
||||||
|
#include "NiagaraFunctionLibrary.h"
|
||||||
#include "Blaster/Blaster.h"
|
#include "Blaster/Blaster.h"
|
||||||
#include "Blaster/Components/BuffComponent.h"
|
#include "Blaster/Components/BuffComponent.h"
|
||||||
#include "Blaster/Components/CombatComponent.h"
|
#include "Blaster/Components/CombatComponent.h"
|
||||||
#include "Blaster/Components/LagCompensationComponent.h"
|
#include "Blaster/Components/LagCompensationComponent.h"
|
||||||
#include "Blaster/GameMode/BlasterGameMode.h"
|
#include "Blaster/GameMode/BlasterGameMode.h"
|
||||||
|
#include "Blaster/GameState/BlasterGameState.h"
|
||||||
#include "Blaster/PlayerController/BlasterPlayerController.h"
|
#include "Blaster/PlayerController/BlasterPlayerController.h"
|
||||||
#include "Blaster/PlayerState/BlasterPlayerState.h"
|
#include "Blaster/PlayerState/BlasterPlayerState.h"
|
||||||
#include "Blaster/Weapon/Weapon.h"
|
#include "Blaster/Weapon/Weapon.h"
|
||||||
|
@ -231,7 +234,10 @@ void ABlasterCharacter::MulticastEliminated_Implementation(bool bPlayerLeftGame)
|
||||||
{
|
{
|
||||||
ShowSniperScopeWidget(false);
|
ShowSniperScopeWidget(false);
|
||||||
}
|
}
|
||||||
|
if (CrownComponent)
|
||||||
|
{
|
||||||
|
CrownComponent->DestroyComponent();
|
||||||
|
}
|
||||||
GetWorldTimerManager().SetTimer(
|
GetWorldTimerManager().SetTimer(
|
||||||
EliminationTimer,
|
EliminationTimer,
|
||||||
this,
|
this,
|
||||||
|
@ -281,6 +287,36 @@ void ABlasterCharacter::Destroyed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ABlasterCharacter::MulticastGainedTheLead_Implementation()
|
||||||
|
{
|
||||||
|
if (CrownSystem == nullptr) return;
|
||||||
|
if (CrownComponent == nullptr)
|
||||||
|
{
|
||||||
|
CrownComponent = UNiagaraFunctionLibrary::SpawnSystemAttached(
|
||||||
|
CrownSystem,
|
||||||
|
GetCapsuleComponent(),
|
||||||
|
FName(),
|
||||||
|
GetActorLocation() + FVector(0.f, 0.f, 110.f),
|
||||||
|
GetActorRotation(),
|
||||||
|
EAttachLocation::KeepWorldPosition,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CrownComponent)
|
||||||
|
{
|
||||||
|
CrownComponent->Activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABlasterCharacter::MulticastLostTheLead_Implementation()
|
||||||
|
{
|
||||||
|
if (CrownComponent)
|
||||||
|
{
|
||||||
|
CrownComponent->DestroyComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ABlasterCharacter::BeginPlay()
|
void ABlasterCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
@ -864,8 +900,15 @@ void ABlasterCharacter::PollInit()
|
||||||
// Initialize Score now we have the PlayerState
|
// Initialize Score now we have the PlayerState
|
||||||
BlasterPlayerState->IncreaseScore(0.f);
|
BlasterPlayerState->IncreaseScore(0.f);
|
||||||
BlasterPlayerState->IncreaseDefeats(0);
|
BlasterPlayerState->IncreaseDefeats(0);
|
||||||
|
|
||||||
|
const ABlasterGameState* BlasterGameState = Cast<ABlasterGameState>(UGameplayStatics::GetGameState(this));
|
||||||
|
if (BlasterGameState && BlasterGameState->TopScoringPlayers.Contains(BlasterPlayerState))
|
||||||
|
{
|
||||||
|
MulticastGainedTheLead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABlasterCharacter::UpdateDissolveMaterial(float DissolveValue)
|
void ABlasterCharacter::UpdateDissolveMaterial(float DissolveValue)
|
||||||
|
|
|
@ -60,6 +60,13 @@ public:
|
||||||
void ServerLeaveGame();
|
void ServerLeaveGame();
|
||||||
|
|
||||||
FOnLeftGame OnLeftGame;
|
FOnLeftGame OnLeftGame;
|
||||||
|
|
||||||
|
UFUNCTION(NetMulticast, Reliable)
|
||||||
|
void MulticastGainedTheLead();
|
||||||
|
|
||||||
|
UFUNCTION(NetMulticast, Reliable)
|
||||||
|
void MulticastLostTheLead();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
@ -273,7 +280,7 @@ private:
|
||||||
UPROPERTY(EditAnywhere, Category = Elimination)
|
UPROPERTY(EditAnywhere, Category = Elimination)
|
||||||
UMaterialInstance* DissolveMaterialInstance;
|
UMaterialInstance* DissolveMaterialInstance;
|
||||||
|
|
||||||
// Elimination bot
|
// Elimination effects
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
UParticleSystem* EliminationBotEffect;
|
UParticleSystem* EliminationBotEffect;
|
||||||
|
|
||||||
|
@ -283,12 +290,17 @@ private:
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
USoundCue* EliminationBotSound;
|
USoundCue* EliminationBotSound;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
class UNiagaraSystem* CrownSystem;
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
class UNiagaraComponent* CrownComponent;
|
||||||
|
|
||||||
// Default weapon
|
// Default weapon
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
TSubclassOf<AWeapon> DefaultWeaponClass;
|
TSubclassOf<AWeapon> DefaultWeaponClass;
|
||||||
|
|
||||||
// Grenade
|
// Grenade
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY(VisibleAnywhere)
|
||||||
UStaticMeshComponent* AttachedGrenade;
|
UStaticMeshComponent* AttachedGrenade;
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,6 @@ ULagCompensationComponent::ULagCompensationComponent()
|
||||||
PrimaryComponentTick.bCanEverTick = true;
|
PrimaryComponentTick.bCanEverTick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULagCompensationComponent::BeginPlay()
|
|
||||||
{
|
|
||||||
Super::BeginPlay();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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, AWeapon* DamageCauser)
|
||||||
{
|
{
|
||||||
|
@ -26,7 +20,6 @@ void ULagCompensationComponent::ServerScoreRequest_Implementation(ABlasterCharac
|
||||||
|
|
||||||
if (Character && HitCharacter && DamageCauser && Confirm.bHitConfirmed)
|
if (Character && HitCharacter && DamageCauser && Confirm.bHitConfirmed)
|
||||||
{
|
{
|
||||||
|
|
||||||
UGameplayStatics::ApplyDamage(
|
UGameplayStatics::ApplyDamage(
|
||||||
HitCharacter,
|
HitCharacter,
|
||||||
DamageCauser->GetDamage(),
|
DamageCauser->GetDamage(),
|
||||||
|
@ -44,7 +37,6 @@ void ULagCompensationComponent::ProjectileServerScoreRequest_Implementation(ABla
|
||||||
|
|
||||||
if (Character && HitCharacter && Confirm.bHitConfirmed)
|
if (Character && HitCharacter && Confirm.bHitConfirmed)
|
||||||
{
|
{
|
||||||
|
|
||||||
UGameplayStatics::ApplyDamage(
|
UGameplayStatics::ApplyDamage(
|
||||||
HitCharacter,
|
HitCharacter,
|
||||||
Character->GetPrimaryWeapon()->GetDamage(),
|
Character->GetPrimaryWeapon()->GetDamage(),
|
||||||
|
@ -103,7 +95,6 @@ void ULagCompensationComponent::SaveFramePackage()
|
||||||
FFramePackage ThisFrame;
|
FFramePackage ThisFrame;
|
||||||
SaveFramePackage(ThisFrame);
|
SaveFramePackage(ThisFrame);
|
||||||
FrameHistory.AddHead(ThisFrame);
|
FrameHistory.AddHead(ThisFrame);
|
||||||
// ShowFramePackage(ThisFrame, FColor::Red);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,8 +158,7 @@ FServerSideRewindResult ULagCompensationComponent::ConfirmHit(const FFramePackag
|
||||||
HeadBox->SetCollisionResponseToChannel(ECC_HitBox, ECR_Block);
|
HeadBox->SetCollisionResponseToChannel(ECC_HitBox, ECR_Block);
|
||||||
|
|
||||||
const FVector TraceEnd = TraceStart + (HitLocation - TraceStart) * 1.25f;
|
const FVector TraceEnd = TraceStart + (HitLocation - TraceStart) * 1.25f;
|
||||||
UWorld* World = GetWorld();
|
if (UWorld* World = GetWorld())
|
||||||
if (World)
|
|
||||||
{
|
{
|
||||||
FHitResult ConfirmHitResult;
|
FHitResult ConfirmHitResult;
|
||||||
World->LineTraceSingleByChannel(
|
World->LineTraceSingleByChannel(
|
||||||
|
@ -180,14 +170,6 @@ FServerSideRewindResult ULagCompensationComponent::ConfirmHit(const FFramePackag
|
||||||
|
|
||||||
if (ConfirmHitResult.bBlockingHit) // we hit the head, return early
|
if (ConfirmHitResult.bBlockingHit) // we hit the head, return early
|
||||||
{
|
{
|
||||||
if (ConfirmHitResult.Component.IsValid())
|
|
||||||
{
|
|
||||||
UBoxComponent* Box = Cast<UBoxComponent>(ConfirmHitResult.Component);
|
|
||||||
if (Box)
|
|
||||||
{
|
|
||||||
DrawDebugBox(GetWorld(), Box->GetComponentLocation(), Box->GetScaledBoxExtent(), FQuat(Box->GetComponentRotation()), FColor::Red, false, 8.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResetHitBoxes(HitCharacter, CurrentFrame);
|
ResetHitBoxes(HitCharacter, CurrentFrame);
|
||||||
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
||||||
return FServerSideRewindResult{ true, true };
|
return FServerSideRewindResult{ true, true };
|
||||||
|
@ -212,14 +194,6 @@ FServerSideRewindResult ULagCompensationComponent::ConfirmHit(const FFramePackag
|
||||||
|
|
||||||
if (ConfirmHitResult.bBlockingHit)
|
if (ConfirmHitResult.bBlockingHit)
|
||||||
{
|
{
|
||||||
if (ConfirmHitResult.Component.IsValid())
|
|
||||||
{
|
|
||||||
UBoxComponent* Box = Cast<UBoxComponent>(ConfirmHitResult.Component);
|
|
||||||
if (Box)
|
|
||||||
{
|
|
||||||
DrawDebugBox(GetWorld(), Box->GetComponentLocation(), Box->GetScaledBoxExtent(), FQuat(Box->GetComponentRotation()), FColor::Blue, false, 8.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResetHitBoxes(HitCharacter, CurrentFrame);
|
ResetHitBoxes(HitCharacter, CurrentFrame);
|
||||||
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
||||||
return FServerSideRewindResult{ true, false };
|
return FServerSideRewindResult{ true, false };
|
||||||
|
@ -253,22 +227,12 @@ FServerSideRewindResult ULagCompensationComponent::ProjectileConfirmHit(const FF
|
||||||
PathParams.ProjectileRadius = 5.f;
|
PathParams.ProjectileRadius = 5.f;
|
||||||
PathParams.TraceChannel = ECC_HitBox;
|
PathParams.TraceChannel = ECC_HitBox;
|
||||||
PathParams.ActorsToIgnore.Add(GetOwner());
|
PathParams.ActorsToIgnore.Add(GetOwner());
|
||||||
PathParams.DrawDebugTime = 5.f;
|
|
||||||
PathParams.DrawDebugType = EDrawDebugTrace::ForDuration;
|
|
||||||
|
|
||||||
FPredictProjectilePathResult PathResult;
|
FPredictProjectilePathResult PathResult;
|
||||||
UGameplayStatics::PredictProjectilePath(this, PathParams, PathResult);
|
UGameplayStatics::PredictProjectilePath(this, PathParams, PathResult);
|
||||||
|
|
||||||
if (PathResult.HitResult.bBlockingHit) // we hit the head, return early
|
if (PathResult.HitResult.bBlockingHit) // we hit the head, return early
|
||||||
{
|
{
|
||||||
if (PathResult.HitResult.Component.IsValid())
|
|
||||||
{
|
|
||||||
UBoxComponent* Box = Cast<UBoxComponent>(PathResult.HitResult.Component);
|
|
||||||
if (Box)
|
|
||||||
{
|
|
||||||
DrawDebugBox(GetWorld(), Box->GetComponentLocation(), Box->GetScaledBoxExtent(), FQuat(Box->GetComponentRotation()), FColor::Red, false, 8.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResetHitBoxes(HitCharacter, CurrentFrame);
|
ResetHitBoxes(HitCharacter, CurrentFrame);
|
||||||
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
||||||
return FServerSideRewindResult{ true, true };
|
return FServerSideRewindResult{ true, true };
|
||||||
|
@ -287,14 +251,6 @@ FServerSideRewindResult ULagCompensationComponent::ProjectileConfirmHit(const FF
|
||||||
UGameplayStatics::PredictProjectilePath(this, PathParams, PathResult);
|
UGameplayStatics::PredictProjectilePath(this, PathParams, PathResult);
|
||||||
if (PathResult.HitResult.bBlockingHit)
|
if (PathResult.HitResult.bBlockingHit)
|
||||||
{
|
{
|
||||||
if (PathResult.HitResult.Component.IsValid())
|
|
||||||
{
|
|
||||||
UBoxComponent* Box = Cast<UBoxComponent>(PathResult.HitResult.Component);
|
|
||||||
if (Box)
|
|
||||||
{
|
|
||||||
DrawDebugBox(GetWorld(), Box->GetComponentLocation(), Box->GetScaledBoxExtent(), FQuat(Box->GetComponentRotation()), FColor::Blue, false, 8.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ResetHitBoxes(HitCharacter, CurrentFrame);
|
ResetHitBoxes(HitCharacter, CurrentFrame);
|
||||||
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
EnableCharacterMeshCollision(HitCharacter, ECollisionEnabled::QueryAndPhysics);
|
||||||
return FServerSideRewindResult{ true, false };
|
return FServerSideRewindResult{ true, false };
|
||||||
|
@ -353,14 +309,6 @@ FShotgunServerSideRewindResult ULagCompensationComponent::ShotgunConfirmHit(cons
|
||||||
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(ConfirmHitResult.GetActor());
|
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(ConfirmHitResult.GetActor());
|
||||||
if (BlasterCharacter)
|
if (BlasterCharacter)
|
||||||
{
|
{
|
||||||
if (ConfirmHitResult.Component.IsValid())
|
|
||||||
{
|
|
||||||
UBoxComponent* Box = Cast<UBoxComponent>(ConfirmHitResult.Component);
|
|
||||||
if (Box)
|
|
||||||
{
|
|
||||||
DrawDebugBox(GetWorld(), Box->GetComponentLocation(), Box->GetScaledBoxExtent(), FQuat(Box->GetComponentRotation()), FColor::Red, false, 8.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ShotgunResult.Headshots.Contains(BlasterCharacter))
|
if (ShotgunResult.Headshots.Contains(BlasterCharacter))
|
||||||
{
|
{
|
||||||
ShotgunResult.Headshots[BlasterCharacter]++;
|
ShotgunResult.Headshots[BlasterCharacter]++;
|
||||||
|
@ -405,14 +353,6 @@ FShotgunServerSideRewindResult ULagCompensationComponent::ShotgunConfirmHit(cons
|
||||||
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(ConfirmHitResult.GetActor());
|
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(ConfirmHitResult.GetActor());
|
||||||
if (BlasterCharacter)
|
if (BlasterCharacter)
|
||||||
{
|
{
|
||||||
if (ConfirmHitResult.Component.IsValid())
|
|
||||||
{
|
|
||||||
UBoxComponent* Box = Cast<UBoxComponent>(ConfirmHitResult.Component);
|
|
||||||
if (Box)
|
|
||||||
{
|
|
||||||
DrawDebugBox(GetWorld(), Box->GetComponentLocation(), Box->GetScaledBoxExtent(), FQuat(Box->GetComponentRotation()), FColor::Blue, false, 8.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ShotgunResult.BodyShots.Contains(BlasterCharacter))
|
if (ShotgunResult.BodyShots.Contains(BlasterCharacter))
|
||||||
{
|
{
|
||||||
ShotgunResult.BodyShots[BlasterCharacter]++;
|
ShotgunResult.BodyShots[BlasterCharacter]++;
|
||||||
|
|
|
@ -122,7 +122,6 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
|
||||||
void SaveFramePackage();
|
void SaveFramePackage();
|
||||||
void SaveFramePackage(FFramePackage& Package);
|
void SaveFramePackage(FFramePackage& Package);
|
||||||
FFramePackage InterpBetweenFrames(const FFramePackage& OlderFrame, const FFramePackage& YoungerFrame, float HitTime);
|
FFramePackage InterpBetweenFrames(const FFramePackage& OlderFrame, const FFramePackage& YoungerFrame, float HitTime);
|
||||||
|
|
|
@ -83,8 +83,33 @@ void ABlasterGameMode::PlayerEliminated(class ABlasterCharacter* EliminatedChara
|
||||||
|
|
||||||
if (AttackerPlayerState && AttackerPlayerState != VictimPlayerState && BlasterGameState)
|
if (AttackerPlayerState && AttackerPlayerState != VictimPlayerState && BlasterGameState)
|
||||||
{
|
{
|
||||||
|
TArray<ABlasterPlayerState*> PlayersCurrentlyInTheLead;
|
||||||
|
for (auto LeadPlayer : BlasterGameState->TopScoringPlayers)
|
||||||
|
{
|
||||||
|
PlayersCurrentlyInTheLead.Add(LeadPlayer);
|
||||||
|
}
|
||||||
AttackerPlayerState->IncreaseScore(1.f);
|
AttackerPlayerState->IncreaseScore(1.f);
|
||||||
BlasterGameState->UpdateTopScore(AttackerPlayerState);
|
BlasterGameState->UpdateTopScore(AttackerPlayerState);
|
||||||
|
|
||||||
|
if (BlasterGameState->TopScoringPlayers.Contains(AttackerPlayerState))
|
||||||
|
{
|
||||||
|
ABlasterCharacter* Leader = Cast<ABlasterCharacter>(AttackerPlayerState->GetPawn());
|
||||||
|
if (Leader)
|
||||||
|
{
|
||||||
|
Leader->MulticastGainedTheLead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int32 i = 0; i < PlayersCurrentlyInTheLead.Num(); i++)
|
||||||
|
{
|
||||||
|
if (!BlasterGameState->TopScoringPlayers.Contains(PlayersCurrentlyInTheLead[i]))
|
||||||
|
{
|
||||||
|
ABlasterCharacter* Loser = Cast<ABlasterCharacter>(PlayersCurrentlyInTheLead[i]->GetPawn());
|
||||||
|
if (Loser)
|
||||||
|
{
|
||||||
|
Loser->MulticastLostTheLead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (VictimPlayerState)
|
if (VictimPlayerState)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,5 +30,4 @@ void ABlasterGameState::UpdateTopScore(ABlasterPlayerState* ScoringPlayer)
|
||||||
TopScoringPlayers.AddUnique(ScoringPlayer);
|
TopScoringPlayers.AddUnique(ScoringPlayer);
|
||||||
TopScore = ScoringPlayer->GetScore();
|
TopScore = ScoringPlayer->GetScore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,6 @@ void AHitScanWeapon::WeaponTraceHit(const FVector& TraceStart, const FVector& Hi
|
||||||
BeamEnd = OutHit.ImpactPoint;
|
BeamEnd = OutHit.ImpactPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DrawDebugSphere(GetWorld(), BeamEnd, 16.f, 12, FColor::Orange, true);
|
|
||||||
|
|
||||||
if (BeamParticles)
|
if (BeamParticles)
|
||||||
{
|
{
|
||||||
UParticleSystemComponent* Beam = UGameplayStatics::SpawnEmitterAtLocation(
|
UParticleSystemComponent* Beam = UGameplayStatics::SpawnEmitterAtLocation(
|
||||||
|
|
Loading…
Reference in New Issue