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;
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();
}

View File

@ -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()
{