Implemented Side Bounties Spawning

This commit is contained in:
Rafal Swierczek 2024-02-11 14:21:45 +00:00
parent 4621c3d9a6
commit b7f376e9df
36 changed files with 205 additions and 143 deletions

View File

@ -9,9 +9,31 @@
<component name="ChangeListManager">
<list default="true" id="dfa3053d-1d51-4dad-9270-4c17e086f627" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/BP_Elevator.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/BP_Elevator.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/CP_ElimTImothyHuntsmer.uasset" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/CinematicFrmaes/TimothyEliminatedSequence1.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/CinematicFrmaes/TimothyEliminatedSequence1.uasset" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/CinematicFrmaes/TimothyEliminatedSequence2.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/CinematicFrmaes/TimothyEliminatedSequence2.uasset" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/CinematicFrmaes/TimothyEliminatedSequence3.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/CinematicFrmaes/TimothyEliminatedSequence3.uasset" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/MB_Apartment.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/MB_Apartment.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/OWCP_Apartment.uasset" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/TargetEliminatedSequence.uasset" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/WBP_TimothyEliminated.uasset" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/TempOpenWorld.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/TempOpenWorld.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/CheckpointClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/CheckpointClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -38,7 +60,7 @@
&quot;C++ Project.EndlessVendetta.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;PuaseMenuTabs&quot;,
&quot;git-widget-placeholder&quot;: &quot;PauseMenuTabs&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
@ -132,7 +154,8 @@
<workItem from="1707103463352" duration="6662000" />
<workItem from="1707304148719" duration="10277000" />
<workItem from="1707409116575" duration="8922000" />
<workItem from="1707574922675" duration="660000" />
<workItem from="1707574922675" duration="10730000" />
<workItem from="1707658695399" duration="837000" />
</task>
<servers />
</component>

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:149144b6fd8ca68c9504252e87e3dea76145a975072f5f950a31628b7265bc5d
size 93434

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4011687f5e23d06e47c3eb26866081d1272cf73a2692252cd57fd4b3483a884d
size 95250

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0b75c5541122da7d86dde09ffc1dca38739137c6fed09f31f953578392aa8e4c
size 24261

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5e4033216548f6200b2265883ed20f8c859b0ad6b628540b7cc58c8bdb2da091
size 81558

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:239ef48ba56a9ad2be8dbba09ec5c54affebabdc535173bc421788faf05f7afa
oid sha256:6764172277cd1d5812197441d69c3897c757be02854b03b5e4a0ddf6cfa563fb
size 66790690

View File

@ -17,10 +17,18 @@ void ABountyClass::ActivateFirstCheckpoint()
BountyCheckpoints[0]->Active = true;
BountyCheckpoints[0]->SpawnWaypoint(BountyTitle);
BountyCheckpoints[0]->CheckpointActivated();
// BountyCheckpoints[0]->CheckpointActivated();
BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint);
}
void ABountyClass::DeActivateFirstCheckpoint()
{
if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
BountyCheckpoints[0]->Active = false;
BountyCheckpoints[0]->DestroyWaypoint();
}
void ABountyClass::SpawnCheckpoints()
{
// Spawn all checkpoints associated with this bounty and store them in order
@ -41,38 +49,10 @@ void ABountyClass::SpawnCheckpoints()
ACheckpointClass* SpawnedCheckpoint = Cast<ACheckpointClass>(GetWorld()->SpawnActor<AActor>(CheckpointClass, Loc, Rot, SpawnParameters));
BountyCheckpoints.Add(SpawnedCheckpoint);
}
ActivateFirstCheckpoint();
}
void ABountyClass::IncrementBountyCheckpoint()
{
// ---------------------------------------------------------------------------------------------------------------------
// Broadcast that the first Checkpoint has been completed so that side bounties can be destroyed
// if (!BountyStarted)
// {
// BountyStarted = true;
// CompletedFirstCheckpoint.Broadcast();
// }
//
// // Bounty Completion Condition
// if (BountyCheckpoints.Num() <= 1)
// {
// Completed = true;
// BountyCheckpoints[0]->Active = false;
// BountyCheckpoints[0]->Destroy();
// BountyCheckpoints.RemoveAt(0);
// UE_LOG(LogTemp, Warning, TEXT(" You've Completed the Bounty!! Well done"));
// return;
// }
//
// if (BountyCheckpoints[0] == nullptr)
// {
// UE_LOG(LogTemp, Fatal, TEXT("Missing checkpoint in bounty checkpoints, could've failed to spawn or cast"));
// return;
// }
//---------------------------------------------------------------------------------------------------------------------
if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
// Destroy Actor and Shrink Array

View File

@ -31,8 +31,7 @@ public:
// ------------------- METHODS ---------------------------------
private:
// Activate the First Checkpoint in Bounty Checkpoints and Listen for its Completion
void ActivateFirstCheckpoint();
protected:
// Called when a checkpoint is completed, handles moving onto next checkpoint and discarding the old one
@ -44,9 +43,13 @@ public:
ABountyClass();
// Spawns and stores this Bounties Checkpoints in order
void SpawnCheckpoints();
virtual void SpawnCheckpoints();
// Activate the First Checkpoint in Bounty Checkpoints and Listen for its Completion
void ActivateFirstCheckpoint();
// De-Activate the First Checkpoint in Bounty Checkpoints
void DeActivateFirstCheckpoint();
@ -71,10 +74,6 @@ protected:
FString BountyDesc;
// -----------------------------------------------
public:
// Broadcast when first checkpoint from this bounty is completed
FCompletedFirstCheckpoint CompletedFirstCheckpoint;

View File

@ -9,24 +9,6 @@ ACheckpointClass::ACheckpointClass()
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
BountyTitle = "";
}
// Called when the game starts or when spawned
void ACheckpointClass::BeginPlay()
{
Super::BeginPlay();
}
void ACheckpointClass::SpawnWaypoint(const FString& CurrentBountyTitle)
{
if (!IsValid(WaypointActorClass) || HideWaypoint) return;
BountyTitle = CurrentBountyTitle;
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
WaypointActor = Cast<AWaypointActor>(GetWorld()->SpawnActor<AActor>(WaypointActorClass, WaypointLoc, GetActorRotation(), SpawnParams));
WaypointActor->SetupWaypoint(WaypointIcon, BountyTitle);
}
void ACheckpointClass::UpdateCheckpointWaypoint(FVector WaypointNewLoc)
@ -40,17 +22,19 @@ void ACheckpointClass::UpdateCheckpointWaypoint(FVector WaypointNewLoc)
WaypointActor->SetupWaypoint(WaypointIcon, BountyTitle);
}
// Called every frame
void ACheckpointClass::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ACheckpointClass::Destroyed()
{
if (WaypointActor) WaypointActor->Destroy();
DestroyWaypoint();
Super::Destroyed();
}
void ACheckpointClass::SpawnWaypoint(const FString& CurrentBountyTitle)
{
if (!IsValid(WaypointActorClass) || HideWaypoint) return;
BountyTitle = CurrentBountyTitle;
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
WaypointActor = Cast<AWaypointActor>(GetWorld()->SpawnActor<AActor>(WaypointActorClass, WaypointLoc, GetActorRotation(), SpawnParams));
WaypointActor->SetupWaypoint(WaypointIcon, BountyTitle);
}

View File

@ -16,8 +16,7 @@ class ENDLESSVENDETTA_API ACheckpointClass : public AActor
{
GENERATED_BODY()
FString BountyTitle;
// ------------------- ATTRIBUTES ------------------------------
// ------ Properties set from Editor ------
UPROPERTY(EditDefaultsOnly, Category = "Checkpoint")
FString CheckpointTip;
@ -32,9 +31,25 @@ class ENDLESSVENDETTA_API ACheckpointClass : public AActor
UPROPERTY(EditDefaultsOnly, Category = "Checkpoint")
bool HideWaypoint = false;
// Stored Title of Bounty, used by Update Checkpoint Waypoint Func
FString BountyTitle;
// Ref to Waypoint Actor
AWaypointActor* WaypointActor;
// ----------------------------------------
protected:
public:
// Delegate called when Checkpoint is Completed
FCompletedCheckpoint CompletedCheckpoint;
// Used by Checkpoint BPs to Determine weather to Run Checkpoint Logic
UPROPERTY(BlueprintReadOnly, Category = "Checkpoint")
bool Active = false;
// ------------------- METHODS ---------------------------------
private:
protected:
// Used by Checkpoints BPs to broadcast that they're Completed
UFUNCTION(BlueprintCallable, Category = "Checkpoint")
void BroadcastCompletion()
{
@ -42,21 +57,34 @@ protected:
Cast<AEndlessVendettaGameMode>(GetWorld()->GetAuthGameMode())->SendEvent("Check", CheckpointTip);
}
// Used by Checkpoint BPs to update Checkpoint Loc without Finishing Checkpoint itself
UFUNCTION(BlueprintCallable)
void UpdateCheckpointWaypoint(FVector WaypointNewLoc);
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Used to Destroy any Waypoint Actor Associated with this Checkpoint when it's Destroyed
virtual void Destroyed() override;
public:
FCompletedCheckpoint CompletedCheckpoint;
UPROPERTY(BlueprintReadOnly, Category = "Checkpoint")
bool Active = false;
// Sets default values for this actor's properties
ACheckpointClass();
// Used by Bounties to Spawn Waypoint for this Checkpoint when it's Activated
void SpawnWaypoint(const FString& BountyTitle);
// Destroys Waypoint Associated with this Checkpoint if one Exists
void DestroyWaypoint()
{
if (WaypointActor) WaypointActor->Destroy();
}
// ------------------- LEGACY ---------------------------------
public:
UFUNCTION(BlueprintImplementableEvent)
void CheckpointActivated();
@ -82,11 +110,4 @@ public:
return CheckpointSpawnTransform;
}
// ---------------------------------------
// Sets default values for this actor's properties
ACheckpointClass();
// Called every frame
virtual void Tick(float DeltaTime) override;
};

View File

@ -25,9 +25,26 @@ void AMainBountyClass::SpawnOpenWorldCheckpoint()
OpenWorldcheckpoint->SpawnWaypoint(BountyTitle);
}
void AMainBountyClass::SpawnCheckpoints()
{
Super::SpawnCheckpoints();
ActivateFirstCheckpoint();
}
TArray<ASideBountyClass*> AMainBountyClass::SpawnAndReturnSideBounties()
{
TArray<ASideBountyClass*> SpawnedSideBounties;
for (auto SideBountyClass : SideBountiesToSpawn)
{
if (!IsValid(SideBountyClass)) continue;
ASideBountyClass* SpawnedSideBounty = GetWorld()->SpawnActor<ASideBountyClass>(SideBountyClass);
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
SpawnedSideBounty->AttachToComponent(GetRootComponent(), AttachmentTransformRules);
SpawnedSideBounty->SpawnCheckpoints();
SpawnedSideBounties.Add(SpawnedSideBounty);
}
return SpawnedSideBounties;
}
void AMainBountyClass::SpawnAmmoDrops()

View File

@ -54,6 +54,9 @@ class ENDLESSVENDETTA_API AMainBountyClass : public ABountyClass
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FTransform PlayerSpawnTransform;
// Used to Spawn Side Bounties Associated with this Main Bounty
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn;
protected:
@ -74,6 +77,11 @@ public:
// Spawns the Single Checkpoint in the Open World for this Main Bounty
void SpawnOpenWorldCheckpoint();
void SpawnCheckpoints() override;
// Used by Bounty Character to Spawn and Store Side Bounty Refs when Main Bounty is Updated
TArray<ASideBountyClass*> SpawnAndReturnSideBounties();
// Used by Players Character to Determine where to Spawn in the Open World after Completing Main Bounty
FTransform GetPlayerSpawnTransform()
{
@ -86,8 +94,7 @@ public:
// ------------------- LEGACY CODE TO BE REWORKED ---------------------------------
protected:
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn;
// ---------------- Bounty Alterations ----------------
UPROPERTY(EditDefaultsOnly, Category = "Bounty")

View File

@ -3,22 +3,15 @@
#include "SideBountyClass.h"
void ASideBountyClass::BeginPlay()
{
Super::BeginPlay();
}
void ASideBountyClass::IncrementBountyCheckpoint()
{
Super::IncrementBountyCheckpoint();
// Rework!!!!
// if (Completed)
// {
// CompletedSideBounty.Broadcast(FavoursEarnedForCompletion);
// }
if (BountyCheckpoints.IsEmpty())
{
CompletedSideBounty.Broadcast(FavoursEarnedForCompletion);
}
}
void ASideBountyClass::DestroyCheckpoints()

View File

@ -28,16 +28,35 @@ class ENDLESSVENDETTA_API ASideBountyClass : public ABountyClass
{
GENERATED_BODY()
protected:
// ------------------- ATTRIBUTES ------------------------------
// Amount of Favours the Player will earn for Completing this Side Bounty
UPROPERTY(EditDefaultsOnly, Category = "Side Bounty")
int FavoursEarnedForCompletion = 1;
virtual void BeginPlay() override;
protected:
public:
// Delegate Broadcast when Side Bounty is Completed, Listened to by Bounty Character
FCompletedSideBounty CompletedSideBounty;
// Struct Containing all Data to be Displayed about the Side Bounty
UPROPERTY(EditDefaultsOnly, Category = "Side Bounty")
FSideBountyStruct SideBountyStruct;
// ------------------- METHODS ---------------------------------
private:
protected:
// Overrides to check if Side Bounty has been Completed
virtual void IncrementBountyCheckpoint() override;
public:
// ------------------- LEGACY ---------------------------------
public:
void DestroyCheckpoints();
int GetRewardInFavours()
{

View File

@ -14,10 +14,6 @@ void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
if (MainBountyClasses.IsEmpty() || MainBountyClasses.Num() <= CurrentMainBountyIndex|| !IsValid(MainBountyClasses[CurrentMainBountyIndex]))
{
AllBountiesCompleted();
if (CurrentMainBountyIndex >= 2 && !(UGameplayStatics::GetCurrentLevelName(GetWorld()) == "EnemyAITest"))
{
UGameplayStatics::OpenLevel(GetWorld(), FName("EnemyAITest"));
}
return;
}
@ -25,8 +21,20 @@ void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
CurrentMainBounty->AttachToComponent(GetRootComponent(), AttachmentTransformRules);
UGameplayStatics::GetCurrentLevelName(GetWorld()) == OpenWorldLevelName ? CurrentMainBounty->SpawnOpenWorldCheckpoint() : CurrentMainBounty->SpawnCheckpoints();
MainBountyStruct = CurrentMainBounty->MainBountyStruct;
if (UGameplayStatics::GetCurrentLevelName(GetWorld()) != OpenWorldLevelName)
{
CurrentMainBounty->SpawnCheckpoints();
return;
}
CurrentMainBounty->SpawnOpenWorldCheckpoint();
CurrentSideBounties = CurrentMainBounty->SpawnAndReturnSideBounties();
SideBountyStructs.Empty();
for (auto SideBounty : CurrentSideBounties)
{
SideBountyStructs.Add(SideBounty->SideBountyStruct);
}
}
void ABountyHunterCharacter::CompleteCurrentMainBounty(UEVGameInstance* GI)

View File

@ -30,6 +30,8 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
// Reference to the Currently Active Main Bounty
AMainBountyClass* CurrentMainBounty;
TArray<ASideBountyClass*> CurrentSideBounties;
// Index of Currently Active Main Bounty, Used for MainBountyClasses
int CurrentMainBountyIndex = 0;
@ -175,13 +177,13 @@ private:
FMainBountyStruct MainBountyStruct;
TArray<FSideBountyStruct> SideBountyStruct;
TArray<FSideBountyStruct> SideBountyStructs;
void UpdateBountyTabInfo()
{
if (!IsValid(BountiesTab)) return;
BountyTabInfo.MainBountyStruct = MainBountyStruct;
BountyTabInfo.SideBountyStructs = SideBountyStruct;
BountyTabInfo.SideBountyStructs = SideBountyStructs;
BountiesTab->UpdateBountyTab(BountyTabInfo);
}