Updated Combat System for Minor Cosmetic Changes

This commit is contained in:
Philip W 2023-05-12 21:45:51 +01:00
parent 2f582cb507
commit b9985228d2
3 changed files with 12 additions and 3 deletions

View File

@ -33,6 +33,11 @@ bool UQuest::WorldStateMatch(UWorldState* A, UWorldState* B)
if (A->Items.IsEmpty() && !B->Items.IsEmpty()) return false; if (A->Items.IsEmpty() && !B->Items.IsEmpty()) return false;
for (UBaseItem* Item : B->Items) for (UBaseItem* Item : B->Items)
{ {
if (A->Items.IndexOfByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; }) == -1)
{
UE_LOG(LogTemp, Warning, TEXT("WorldState Predicate Failed"));
return false;
}
if (!A->Items.Contains(Item) && Item->StackCount > A->Items[A->Items.IndexOfByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; })]->StackCount) if (!A->Items.Contains(Item) && Item->StackCount > A->Items[A->Items.IndexOfByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; })]->StackCount)
{ {
return false; return false;

View File

@ -48,7 +48,7 @@ public:
UPROPERTY() UPROPERTY()
UWrapBox* StatusIconsBox; UWrapBox* StatusIconsBox;
UPROPERTY() UPROPERTY(VisibleAnywhere)
TArray<FActiveStatusEffect> ActiveStatusEffects; TArray<FActiveStatusEffect> ActiveStatusEffects;
protected: protected:

View File

@ -316,6 +316,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
StatusSystem->AddStatusEffect(TempThornsStatusEffect, 1, false); StatusSystem->AddStatusEffect(TempThornsStatusEffect, 1, false);
StatusEffects.Add(TempThornsStatusEffect); StatusEffects.Add(TempThornsStatusEffect);
AddBattleLogMessage("Player Casted Thorns"); AddBattleLogMessage("Player Casted Thorns");
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Casted Thorns")); StatusTextBlock->SetText(FText::FromString("Casted Thorns"));
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
@ -326,6 +327,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
StatusSystem->AddStatusEffect(TempDOTStatusEffect, 1, false); StatusSystem->AddStatusEffect(TempDOTStatusEffect, 1, false);
StatusEffects.Add(TempDOTStatusEffect); StatusEffects.Add(TempDOTStatusEffect);
AddBattleLogMessage("Player Casted DOT"); AddBattleLogMessage("Player Casted DOT");
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Casted DOT")); StatusTextBlock->SetText(FText::FromString("Casted DOT"));
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
@ -336,6 +338,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
StatusSystem->AddStatusEffect(TempDamageDownStatusEffect, 1); StatusSystem->AddStatusEffect(TempDamageDownStatusEffect, 1);
StatusEffects.Add(TempDamageDownStatusEffect); StatusEffects.Add(TempDamageDownStatusEffect);
AddBattleLogMessage("Player Casted DamageDown"); AddBattleLogMessage("Player Casted DamageDown");
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Enemy Damage Down")); StatusTextBlock->SetText(FText::FromString("Enemy Damage Down"));
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
@ -653,7 +656,7 @@ void ATurnBaseCombatV2::RunButtonOnClick()
{ {
if (FMath::RandRange(0.0f, 1.0f) >= EscapePercentage) if (FMath::RandRange(0.0f, 1.0f) >= EscapePercentage)
{ {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Escape Failed")); StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 0.0f, 0.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Escape Failed")); StatusTextBlock->SetText(FText::FromString("Escape Failed"));
FOutputDeviceNull AR; FOutputDeviceNull AR;
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
@ -781,6 +784,7 @@ void ATurnBaseCombatV2::EnemyTurn()
} }
else else
{ {
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Missed")); StatusTextBlock->SetText(FText::FromString("Missed"));
FOutputDeviceNull AR; FOutputDeviceNull AR;
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
@ -804,6 +808,6 @@ void ATurnBaseCombatV2::ToggleButtonIfResourceAvailable() const
else AButton->SetIsEnabled(false); else AButton->SetIsEnabled(false);
if (IroquoidResource >= 1) IButton->SetIsEnabled(true); if (IroquoidResource >= 1) IButton->SetIsEnabled(true);
else IButton->SetIsEnabled(false); else IButton->SetIsEnabled(false);
if (Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0) >= 1) HealButton->SetIsEnabled(true); if (Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0) >= 1 && *PlayerHealth < 100.0f) HealButton->SetIsEnabled(true);
else HealButton->SetIsEnabled(false); else HealButton->SetIsEnabled(false);
} }