From 9b0ef82e7c0d5e0e4fa9a427743fabc6dc75fbc3 Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Mon, 27 Feb 2023 04:07:19 +0000 Subject: [PATCH] Updated TurnBasedCombat to Include New Combos --- Content/BlueprintAI/AI/AIBruh.uasset | 4 +- Content/Blueprints/Combat_UI/Combat_UI.uasset | 4 +- .../BaseItems/Items/EatableItems.cpp | 8 +- .../PlayerTemp/TempCharacter.h | 2 + .../TurnBasedCombatV2/TurnBaseCombatV2.cpp | 136 +++++++++++++----- .../TurnBasedCombatV2/TurnBaseCombatV2.h | 67 ++++++--- the_twilight_abyss.uproject.DotSettings | 4 + 7 files changed, 160 insertions(+), 65 deletions(-) create mode 100644 the_twilight_abyss.uproject.DotSettings diff --git a/Content/BlueprintAI/AI/AIBruh.uasset b/Content/BlueprintAI/AI/AIBruh.uasset index 25592c5..bd28064 100644 --- a/Content/BlueprintAI/AI/AIBruh.uasset +++ b/Content/BlueprintAI/AI/AIBruh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:800bdc6bd6084e775a08f93e15e6c3131bc1e42051c43aeed6cce77a4a694319 -size 82006 +oid sha256:7cf3192a69ceecc6e6552c89a0093b9b2add8e0561001f82362d6485877d64d3 +size 82913 diff --git a/Content/Blueprints/Combat_UI/Combat_UI.uasset b/Content/Blueprints/Combat_UI/Combat_UI.uasset index 416a260..c053719 100644 --- a/Content/Blueprints/Combat_UI/Combat_UI.uasset +++ b/Content/Blueprints/Combat_UI/Combat_UI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:52a0bccd38454b1877744bb682416d170c6d74c8de74517c8856432b45915b79 -size 78977 +oid sha256:ec2d60b9e1497660f1b9a7efa8bc67a4c333d0de1016fde2f78c39f3fe9e6537 +size 72875 diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index 9a0b867..0d0098d 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -42,13 +42,13 @@ void UEatableItems::Use(ATempCharacter* Character) if (isAmmoItemType) { TurnBaseCombat = GetWorld()->GetGameState(); - if (TurnBaseCombat->IronResource > 10) + if (TurnBaseCombat->ProbertiumResource > 10) { - TurnBaseCombat->IronResource += 5; + TurnBaseCombat->ProbertiumResource += 5; } - if (TurnBaseCombat->SulfurResource > 10) + if (TurnBaseCombat->EisResource > 10) { - TurnBaseCombat->SulfurResource += 5; + TurnBaseCombat->EisResource += 5; } Character->Inventory->RemoveItem(this); } diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 57675b2..f9d57fb 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -95,4 +95,6 @@ public: FName Ammo; + UPROPERTY(BlueprintReadWrite) + float ReactionSpeed = 100.0f; }; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index b2c29ff..e4e4e0f 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -27,7 +27,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy) { if (Enemy == nullptr) return; UBlackboardComponent* EnemyBlackboard = Cast(Enemy->GetInstigatorController())->GetBlackboardComponent(); - + if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return; EnemyBlackboard->SetValueAsBool("IsInCombat", true); FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health")); @@ -39,8 +39,10 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy) HUD->AddToViewport(); EnemyActor = Enemy; - IronResource = 10; - SulfurResource = 10; + ProbertiumResource = 10; + EisResource = 10; + AzosResource = 10; + IroquoidResource = 10; //Disable Character Movement if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) @@ -51,7 +53,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy) APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerController->SetInputMode(FInputModeUIOnly()); PlayerController->bShowMouseCursor = true; - + CurrentComboString = ""; UpdateComboString(CurrentComboString); RevertActionPoints(); @@ -80,12 +82,12 @@ void ATurnBaseCombatV2::EndCombat() void ATurnBaseCombatV2::FKeyPressed() { - FButtonOnClick(); + PButtonOnClick(); } void ATurnBaseCombatV2::WKeyPressed() { - WButtonOnClick(); + EButtonOnClick(); } void ATurnBaseCombatV2::BeginPlay() @@ -109,16 +111,22 @@ void ATurnBaseCombatV2::BeginPlay() BattleLogTextBlock = Cast(HUD->GetWidgetFromName("BattleLog")); PlayerHealthBar = Cast(HUD->GetWidgetFromName("PlayerHealthBar")); EnemyHealthBar = Cast(HUD->GetWidgetFromName("EnemyHealthBar")); - IronResourceBar = Cast(HUD->GetWidgetFromName("IronResourceBar")); - SulfurResourceBar = Cast(HUD->GetWidgetFromName("SulfurResourceBar")); + ProbertiumResourceBar = Cast(HUD->GetWidgetFromName("ProbertiumResourceBar")); + EisResourceBar = Cast(HUD->GetWidgetFromName("EisResourceBar")); + AzosResourceBar = Cast(HUD->GetWidgetFromName("AzosResourceBar")); + IroquoidResourceBar = Cast(HUD->GetWidgetFromName("IroquoidResourceBar")); CastButton = Cast(HUD->GetWidgetFromName("CastButton")); - FButton = Cast(HUD->GetWidgetFromName("FButton")); - WButton = Cast(HUD->GetWidgetFromName("WButton")); + PButton = Cast(HUD->GetWidgetFromName("PButton")); + EButton = Cast(HUD->GetWidgetFromName("EButton")); + AButton = Cast(HUD->GetWidgetFromName("AButton")); + IButton = Cast(HUD->GetWidgetFromName("IButton")); BackspaceButton = Cast(HUD->GetWidgetFromName("BackspaceButton")); RunButton = Cast(HUD->GetWidgetFromName("RunButton")); CastButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::CastButtonOnClick); - FButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::FButtonOnClick); - WButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::WButtonOnClick); + PButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::PButtonOnClick); + EButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::EButtonOnClick); + AButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::AButtonOnClick); + IButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::IButtonOnClick); BackspaceButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::BackspaceButtonOnClick); RunButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::RunButtonOnClick); } @@ -131,13 +139,21 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) //For each character in the current combo add back the resource for (int i = 0; i < Combo.Len(); i++) { - if (Combo[i] == 'F') + if (Combo[i] == 'P') { - IronResource += 1; + ProbertiumResource += 1; } - else if (Combo[i] == 'W') + else if (Combo[i] == 'E') { - SulfurResource += 1; + EisResource += 1; + } + else if (Combo[i] == 'A') + { + AzosResource += 1; + } + else if (Combo[i] == 'I') + { + IroquoidResource += 1; } } CurrentComboString = ""; @@ -251,41 +267,79 @@ void ATurnBaseCombatV2::CastButtonOnClick() ExecuteCast(CurrentComboString); } -void ATurnBaseCombatV2::FButtonOnClick() +void ATurnBaseCombatV2::PButtonOnClick() { if (ActiveActionPoints >= DefaultActionPoints) { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); return; } - if (IronResource <= 0) + if (ProbertiumResource <= 0) { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Iron")); + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Probertium")); return; } UseActionPoint(); - CurrentComboString.AppendChar('F'); + CurrentComboString.AppendChar('P'); UpdateComboString(CurrentComboString); - IronResource -= 1; + ProbertiumResource -= 1; UpdateResourceBars(); } -void ATurnBaseCombatV2::WButtonOnClick() +void ATurnBaseCombatV2::EButtonOnClick() { if (ActiveActionPoints >= DefaultActionPoints) { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); return; } - if (SulfurResource <= 0) + if (EisResource <= 0) { - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Sulfur")); + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Eis")); return; } UseActionPoint(); - CurrentComboString.AppendChar('W'); + CurrentComboString.AppendChar('E'); UpdateComboString(CurrentComboString); - SulfurResource -= 1; + EisResource -= 1; + UpdateResourceBars(); +} + +void ATurnBaseCombatV2::AButtonOnClick() +{ + if (ActiveActionPoints >= DefaultActionPoints) + { + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); + return; + } + if (AzosResource <= 0) + { + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Azos")); + return; + } + UseActionPoint(); + CurrentComboString.AppendChar('A'); + UpdateComboString(CurrentComboString); + AzosResource -= 1; + UpdateResourceBars(); +} + +void ATurnBaseCombatV2::IButtonOnClick() +{ + if (ActiveActionPoints >= DefaultActionPoints) + { + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Action Points")); + return; + } + if (IroquoidResource <= 0) + { + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("No More Iroquoid")); + return; + } + UseActionPoint(); + CurrentComboString.AppendChar('I'); + UpdateComboString(CurrentComboString); + IroquoidResource -= 1; UpdateResourceBars(); } @@ -297,13 +351,21 @@ void ATurnBaseCombatV2::BackspaceButtonOnClick() return; } ReuseActionPoint(); - if (CurrentComboString.Right(1) == "F") + if (CurrentComboString.Right(1) == "P") { - IronResource += 1; + ProbertiumResource += 1; } - else if (CurrentComboString.Right(1) == "W") + else if (CurrentComboString.Right(1) == "E") { - SulfurResource += 1; + EisResource += 1; + } + else if (CurrentComboString.Right(1) == "A") + { + AzosResource += 1; + } + else if (CurrentComboString.Right(1) == "I") + { + IroquoidResource += 1; } CurrentComboString.RemoveAt(CurrentComboString.Len() - 1); UpdateComboString(CurrentComboString); @@ -313,7 +375,7 @@ void ATurnBaseCombatV2::BackspaceButtonOnClick() void ATurnBaseCombatV2::RunButtonOnClick() { UBlackboardComponent* EnemyBlackboard = Cast(EnemyActor->GetInstigatorController())->GetBlackboardComponent(); - + EnemyBlackboard->SetValueAsBool("IsInCombat", false); EndCombat(); } @@ -351,14 +413,18 @@ void ATurnBaseCombatV2::UpdateBattleLog() void ATurnBaseCombatV2::UpdateResourceBars() const { - IronResourceBar->SetPercent(IronResource / 10.0f); - SulfurResourceBar->SetPercent(SulfurResource / 10.0f); + ProbertiumResourceBar->SetPercent(ProbertiumResource / 10.0f); + EisResourceBar->SetPercent(EisResource / 10.0f); + AzosResourceBar->SetPercent(AzosResource / 10.0f); + IroquoidResourceBar->SetPercent(IroquoidResource / 10.0f); } void ATurnBaseCombatV2::ToggleButtons() const { - FButton->SetIsEnabled(!FButton->GetIsEnabled()); - WButton->SetIsEnabled(!WButton->GetIsEnabled()); + PButton->SetIsEnabled(!PButton->GetIsEnabled()); + EButton->SetIsEnabled(!EButton->GetIsEnabled()); + AButton->SetIsEnabled(!AButton->GetIsEnabled()); + IButton->SetIsEnabled(!IButton->GetIsEnabled()); BackspaceButton->SetIsEnabled(!BackspaceButton->GetIsEnabled()); CastButton->SetIsEnabled(!CastButton->GetIsEnabled()); RunButton->SetIsEnabled(!RunButton->GetIsEnabled()); diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index 283ef1e..732612a 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -27,10 +27,15 @@ public: int DefaultActionPoints = 3; UPROPERTY(EditDefaultsOnly) int ActiveActionPoints = 0; + UPROPERTY(EditDefaultsOnly) - int IronResource = 10; // F + int ProbertiumResource = 10; UPROPERTY(EditDefaultsOnly) - int SulfurResource = 10; // W + int EisResource = 10; + UPROPERTY(EditDefaultsOnly) + int AzosResource = 10; + UPROPERTY(EditDefaultsOnly) + int IroquoidResource = 10; UPROPERTY(EditDefaultsOnly) UNiagaraSystem* GunEffect; @@ -51,11 +56,26 @@ public: UPROPERTY(EditAnywhere) TMap ValidCombos = { - {"F", 10}, - {"W", 10}, - {"WW", 15}, - {"FW", 20}, - {"FFW", 30} + {"P", 5}, + {"PP", 15}, + {"PPP", 20}, + {"E", 5}, + {"EE", 15}, + {"EEE", 20}, + {"A", 5}, + {"AA", 15}, + {"AAA", 20}, + {"I", 5}, + {"II", 15}, + {"III", 20}, + {"IA", 15}, + {"IIA", 20}, + {"EP", 15}, + {"EEP", 20}, + {"AE", 15}, + {"AAE", 20}, + {"PI", 15}, + {"PPI", 20} }; FString BattleLog; @@ -92,40 +112,41 @@ private: UPROPERTY(VisibleAnywhere) UTextBlock* TurnIndicatorTextBlock; - UPROPERTY(VisibleAnywhere) UTextBlock* CurrentComboTextBlock; - UPROPERTY(VisibleAnywhere) UTextBlock* BattleLogTextBlock; - UPROPERTY(VisibleAnywhere) UTextBlock* ActionPointsTextBlock; UPROPERTY(VisibleAnywhere) UProgressBar* PlayerHealthBar; - UPROPERTY(VisibleAnywhere) UProgressBar* EnemyHealthBar; UPROPERTY(VisibleAnywhere) - UProgressBar* IronResourceBar; - + UProgressBar* ProbertiumResourceBar; UPROPERTY(VisibleAnywhere) - UProgressBar* SulfurResourceBar; + UProgressBar* EisResourceBar; + UPROPERTY(VisibleAnywhere) + UProgressBar* AzosResourceBar; + UPROPERTY(VisibleAnywhere) + UProgressBar* IroquoidResourceBar; UPROPERTY(VisibleAnywhere) UButton* CastButton; UPROPERTY(VisibleAnywhere) - UButton* FButton; - + UButton* PButton; UPROPERTY(VisibleAnywhere) - UButton* WButton; + UButton* EButton; + UPROPERTY(VisibleAnywhere) + UButton* AButton; + UPROPERTY(VisibleAnywhere) + UButton* IButton; UPROPERTY(VisibleAnywhere) UButton* BackspaceButton; - UPROPERTY(VisibleAnywhere) UButton* RunButton; @@ -133,14 +154,16 @@ private: void CastButtonOnClick(); UFUNCTION() - void FButtonOnClick(); - + void PButtonOnClick(); UFUNCTION() - void WButtonOnClick(); + void EButtonOnClick(); + UFUNCTION() + void AButtonOnClick(); + UFUNCTION() + void IButtonOnClick(); UFUNCTION() void BackspaceButtonOnClick(); - UFUNCTION() void RunButtonOnClick(); diff --git a/the_twilight_abyss.uproject.DotSettings b/the_twilight_abyss.uproject.DotSettings new file mode 100644 index 0000000..2323d1b --- /dev/null +++ b/the_twilight_abyss.uproject.DotSettings @@ -0,0 +1,4 @@ + + True + True + True \ No newline at end of file