Fixed Buying a Bounty Alteration Multiple Times

Player can now only buy each bounty alteration once per bounty
This commit is contained in:
Rafal Swierczek 2023-10-15 13:16:59 +01:00
parent d32b2fc6f5
commit 8ad1393ffb
2 changed files with 22 additions and 6 deletions

View File

@ -126,9 +126,10 @@ void ABountyDirector::BuyCustomBountyAlteration_1()
{ {
if (!IsValid(ActiveBounty)) return; if (!IsValid(ActiveBounty)) return;
int Cost = ActiveBounty->GetCustomBountyAlteration_1_Cost(); int Cost = ActiveBounty->GetCustomBountyAlteration_1_Cost();
if (Cost == 0 || Favours < Cost) return; if (Cost == 0 || Favours < Cost || ActiveBounty->ActivatedCBA_1) return;
Favours -= Cost; Favours -= Cost;
PC_Display->UpdateFavourCount(Favours); PC_Display->UpdateFavourCount(Favours);
ActiveBounty->ActivatedCBA_1 = true;
ActiveBounty->ActivateCustomBountyAlteration_1(); ActiveBounty->ActivateCustomBountyAlteration_1();
} }
@ -137,9 +138,10 @@ void ABountyDirector::BuyCustomBountyAlteration_2()
{ {
if (!IsValid(ActiveBounty)) return; if (!IsValid(ActiveBounty)) return;
int Cost = ActiveBounty->GetCustomBountyAlteration_2_Cost(); int Cost = ActiveBounty->GetCustomBountyAlteration_2_Cost();
if (Cost == 0 || Favours < Cost) return; if (Cost == 0 || Favours < Cost || ActiveBounty->ActivatedCBA_2) return;
Favours -= Cost; Favours -= Cost;
PC_Display->UpdateFavourCount(Favours); PC_Display->UpdateFavourCount(Favours);
ActiveBounty->ActivatedCBA_2 = true;
ActiveBounty->ActivateCustomBountyAlteration_2(); ActiveBounty->ActivateCustomBountyAlteration_2();
} }
@ -147,36 +149,40 @@ void ABountyDirector::BuyCustomBountyAlteration_3()
{ {
if (!IsValid(ActiveBounty)) return; if (!IsValid(ActiveBounty)) return;
int Cost = ActiveBounty->GetCustomBountyAlteration_3_Cost(); int Cost = ActiveBounty->GetCustomBountyAlteration_3_Cost();
if (Cost == 0 || Favours < Cost) return; if (Cost == 0 || Favours < Cost || ActiveBounty->ActivatedCBA_3) return;
Favours -= Cost; Favours -= Cost;
PC_Display->UpdateFavourCount(Favours); PC_Display->UpdateFavourCount(Favours);
ActiveBounty->ActivatedCBA_3 = true;
ActiveBounty->ActivateCustomBountyAlteration_3(); ActiveBounty->ActivateCustomBountyAlteration_3();
} }
void ABountyDirector::BuyAmmoDrop() void ABountyDirector::BuyAmmoDrop()
{ {
if (!IsValid(ActiveBounty)) return; if (!IsValid(ActiveBounty)) return;
if (Favours < 1) return; if (Favours < 1 || ActiveBounty->ActivateAmmoDrops) return;
Favours--; Favours--;
PC_Display->UpdateFavourCount(Favours); PC_Display->UpdateFavourCount(Favours);
ActiveBounty->ActivateAmmoDrops = true;
ActiveBounty->SpawnAmmoDrops(); ActiveBounty->SpawnAmmoDrops();
} }
void ABountyDirector::BuyHealthDrop() void ABountyDirector::BuyHealthDrop()
{ {
if (!IsValid(ActiveBounty)) return; if (!IsValid(ActiveBounty)) return;
if (Favours < 1) return; if (Favours < 1 || ActiveBounty->ActivatedHealthDrops) return;
Favours--; Favours--;
PC_Display->UpdateFavourCount(Favours); PC_Display->UpdateFavourCount(Favours);
ActiveBounty->ActivatedHealthDrops = true;
ActiveBounty->SpawnHealthDrops(); ActiveBounty->SpawnHealthDrops();
} }
void ABountyDirector::BuyEnemyRadio() void ABountyDirector::BuyEnemyRadio()
{ {
if (!IsValid(ActiveBounty)) return; if (!IsValid(ActiveBounty)) return;
if (Favours < 1) return; if (Favours < 1 || ActiveBounty->ActivatedRadio) return;
Favours--; Favours--;
PC_Display->UpdateFavourCount(Favours); PC_Display->UpdateFavourCount(Favours);
ActiveBounty->ActivatedRadio = true;
ActiveBounty->ActivateEnemyRadio(); ActiveBounty->ActivateEnemyRadio();
} }

View File

@ -56,6 +56,10 @@ public:
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty") UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")
void ActivateCustomBountyAlteration_3(); void ActivateCustomBountyAlteration_3();
bool ActivatedCBA_1 = false;
bool ActivatedCBA_2 = false;
bool ActivatedCBA_3 = false;
UFUNCTION(BlueprintCallable, Category = "Bounty") UFUNCTION(BlueprintCallable, Category = "Bounty")
FString GetCustomBountyAlteration_1_Description() FString GetCustomBountyAlteration_1_Description()
{ {
@ -95,14 +99,20 @@ public:
void SpawnAmmoDrops(); void SpawnAmmoDrops();
bool ActivateAmmoDrops = false;
void SpawnHealthDrops(); void SpawnHealthDrops();
bool ActivatedHealthDrops = false;
void ActivateEnemyRadio() void ActivateEnemyRadio()
{ {
UE_LOG(LogTemp, Display, TEXT("Bought Radio, but it's not implemented yet")); UE_LOG(LogTemp, Display, TEXT("Bought Radio, but it's not implemented yet"));
HasEnemyRadio = true; HasEnemyRadio = true;
} }
bool ActivatedRadio = false;
// Concerned Enemies will call this function, if true, play funny poop voice line and stop enemies from being concerned // Concerned Enemies will call this function, if true, play funny poop voice line and stop enemies from being concerned
bool CheckIfHasEnemyRadio() bool CheckIfHasEnemyRadio()
{ {