From 8ad1393ffb79d78fa79ec4add71d35f98106081a Mon Sep 17 00:00:00 2001 From: Rafal Swierczek <34179rs@gmail.com> Date: Sun, 15 Oct 2023 13:16:59 +0100 Subject: [PATCH] Fixed Buying a Bounty Alteration Multiple Times Player can now only buy each bounty alteration once per bounty --- .../BountySystem/BountyDirector.cpp | 18 ++++++++++++------ .../BountySystem/MainBountyClass.h | 10 ++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp index e11b7841..56ed2056 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp @@ -126,9 +126,10 @@ void ABountyDirector::BuyCustomBountyAlteration_1() { if (!IsValid(ActiveBounty)) return; int Cost = ActiveBounty->GetCustomBountyAlteration_1_Cost(); - if (Cost == 0 || Favours < Cost) return; + if (Cost == 0 || Favours < Cost || ActiveBounty->ActivatedCBA_1) return; Favours -= Cost; PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivatedCBA_1 = true; ActiveBounty->ActivateCustomBountyAlteration_1(); } @@ -137,9 +138,10 @@ void ABountyDirector::BuyCustomBountyAlteration_2() { if (!IsValid(ActiveBounty)) return; int Cost = ActiveBounty->GetCustomBountyAlteration_2_Cost(); - if (Cost == 0 || Favours < Cost) return; + if (Cost == 0 || Favours < Cost || ActiveBounty->ActivatedCBA_2) return; Favours -= Cost; PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivatedCBA_2 = true; ActiveBounty->ActivateCustomBountyAlteration_2(); } @@ -147,36 +149,40 @@ void ABountyDirector::BuyCustomBountyAlteration_3() { if (!IsValid(ActiveBounty)) return; int Cost = ActiveBounty->GetCustomBountyAlteration_3_Cost(); - if (Cost == 0 || Favours < Cost) return; + if (Cost == 0 || Favours < Cost || ActiveBounty->ActivatedCBA_3) return; Favours -= Cost; PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivatedCBA_3 = true; ActiveBounty->ActivateCustomBountyAlteration_3(); } void ABountyDirector::BuyAmmoDrop() { if (!IsValid(ActiveBounty)) return; - if (Favours < 1) return; + if (Favours < 1 || ActiveBounty->ActivateAmmoDrops) return; Favours--; PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivateAmmoDrops = true; ActiveBounty->SpawnAmmoDrops(); } void ABountyDirector::BuyHealthDrop() { if (!IsValid(ActiveBounty)) return; - if (Favours < 1) return; + if (Favours < 1 || ActiveBounty->ActivatedHealthDrops) return; Favours--; PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivatedHealthDrops = true; ActiveBounty->SpawnHealthDrops(); } void ABountyDirector::BuyEnemyRadio() { if (!IsValid(ActiveBounty)) return; - if (Favours < 1) return; + if (Favours < 1 || ActiveBounty->ActivatedRadio) return; Favours--; PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivatedRadio = true; ActiveBounty->ActivateEnemyRadio(); } diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h index 47109d1e..96dc99cc 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h @@ -56,6 +56,10 @@ public: UFUNCTION(BlueprintImplementableEvent, Category = "Bounty") void ActivateCustomBountyAlteration_3(); + bool ActivatedCBA_1 = false; + bool ActivatedCBA_2 = false; + bool ActivatedCBA_3 = false; + UFUNCTION(BlueprintCallable, Category = "Bounty") FString GetCustomBountyAlteration_1_Description() { @@ -95,14 +99,20 @@ public: void SpawnAmmoDrops(); + bool ActivateAmmoDrops = false; + void SpawnHealthDrops(); + bool ActivatedHealthDrops = false; + void ActivateEnemyRadio() { UE_LOG(LogTemp, Display, TEXT("Bought Radio, but it's not implemented yet")); HasEnemyRadio = true; } + bool ActivatedRadio = false; + // Concerned Enemies will call this function, if true, play funny poop voice line and stop enemies from being concerned bool CheckIfHasEnemyRadio() {