From e8e4e8687385dc368683c7d03dc8f80933e2d593 Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Thu, 11 May 2023 05:59:49 +0100 Subject: [PATCH] Updated Status System to Add Buff Jelly Functionality --- .../Combat_UI/CombatCharacter.uasset | 4 ++-- Content/Blueprints/Combat_UI/Combat_UI.uasset | 4 ++-- .../StatusEffects/BP_StrengthBuff.uasset | 3 +++ .../Blueprints/Status_UI/StatusIcon.uasset | 4 ++-- .../Status_UI/StatusIndicator.uasset | 4 ++-- Content/Levels/Build.umap | 2 +- .../BaseItems/Items/EatableItems.cpp | 9 ++++--- .../BaseItems/Items/EatableItems.h | 2 +- .../StatusEffects/StrengthBuff.cpp | 17 +++++++++++++ .../StatusEffects/StrengthBuff.h | 24 +++++++++++++++++++ .../TurnBasedCombatV2/TurnBaseCombatV2.cpp | 15 ++++++++---- .../TurnBasedCombatV2/TurnBaseCombatV2.h | 2 +- 12 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 Content/Blueprints/StatusEffects/BP_StrengthBuff.uasset create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.cpp create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.h diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index 8b1d515..7bce521 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97ca9282909363f58376f8539f5122d7d0888477a07babdcbbd99e99e0d97219 -size 192939 +oid sha256:afa219a774a7b87b1d8d7bf0ae37a4c149d1953526d7472ee547409e709abc44 +size 193210 diff --git a/Content/Blueprints/Combat_UI/Combat_UI.uasset b/Content/Blueprints/Combat_UI/Combat_UI.uasset index 9996d3c..ff5d157 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:4437094a6e73b899dd4ec398c22ccf5914a0cc512faf2b9ef2cf1ed9452536e5 -size 95430 +oid sha256:105d6df7f4c76bb98360aa3eff4f469b822b9181a792c69f9bfc4573701cb31a +size 94121 diff --git a/Content/Blueprints/StatusEffects/BP_StrengthBuff.uasset b/Content/Blueprints/StatusEffects/BP_StrengthBuff.uasset new file mode 100644 index 0000000..1bc6db2 --- /dev/null +++ b/Content/Blueprints/StatusEffects/BP_StrengthBuff.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c28c12bd3b4efe1571477a85d9e82b78e42d66564e86160c5d43da73c81c8d93 +size 6600 diff --git a/Content/Blueprints/Status_UI/StatusIcon.uasset b/Content/Blueprints/Status_UI/StatusIcon.uasset index 74e0964..7ae7696 100644 --- a/Content/Blueprints/Status_UI/StatusIcon.uasset +++ b/Content/Blueprints/Status_UI/StatusIcon.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a911529b7d90b0795d916aa06b7e43b3a488abce5af21ccd7bb79f2a3d4f1354 -size 26496 +oid sha256:eb1a0103b723a7f67842fda35a4f722b9bcd6e1032fb4e7bf14df7dcdb7904e5 +size 26624 diff --git a/Content/Blueprints/Status_UI/StatusIndicator.uasset b/Content/Blueprints/Status_UI/StatusIndicator.uasset index 2271e59..fe06d41 100644 --- a/Content/Blueprints/Status_UI/StatusIndicator.uasset +++ b/Content/Blueprints/Status_UI/StatusIndicator.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f4c57c2d0f42d4361bef541ca607987254abf8f4dee42b89368e99e52a27361e -size 24448 +oid sha256:5f0835e79b48d1c2d2f95256074af14fe64f698239a1962bbb5d9385c52045a5 +size 24612 diff --git a/Content/Levels/Build.umap b/Content/Levels/Build.umap index ad21206..bdd410a 100644 --- a/Content/Levels/Build.umap +++ b/Content/Levels/Build.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d5da9beed8469b1be9db042b6b0b700727afa0ef160c26bba597a8b90fe8d22f +oid sha256:acf906ad8c2c692ccff309d0bee7f418527eb40bcebfa989d7f62a2f44aee6f2 size 3464522 diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index cab1c7a..c260817 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -10,8 +10,8 @@ UEatableItems::UEatableItems() { - static ConstructorHelpers::FClassFinder StatusEffectClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_HealOverTime")); - HealOverTimeStatusEffect = StatusEffectClassFinder.Class; + static ConstructorHelpers::FClassFinder StrengthBuffClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_StrengthBuff")); + StrengthBuffStatusEffect = StrengthBuffClassFinder.Class; } void UEatableItems::Use(ATempCharacter* Character) @@ -22,8 +22,6 @@ void UEatableItems::Use(ATempCharacter* Character) { if (Character->Health < 100) { - // UStatusSystem* StatusSystem = Character->FindComponentByClass(); - // StatusSystem->AddStatusEffect(NewObject(Character, HealOverTimeStatusEffect)); Character->Health += 20; Character->Inventory->RemoveItem(this); } @@ -36,7 +34,8 @@ void UEatableItems::Use(ATempCharacter* Character) if (isDamageBuffItem) { - // need to add the damage buff functionality here + UStatusSystem* StatusSystem = Character->FindComponentByClass(); + StatusSystem->AddStatusEffect(NewObject(Character, StrengthBuffStatusEffect)); UE_LOG(LogTemp, Display, TEXT("Damage Buffed")); Character->Inventory->RemoveItem(this); } diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h index 419f8e3..54bcaa8 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h @@ -22,7 +22,7 @@ protected: virtual void Use(class ATempCharacter* Character) override; UPROPERTY() - TSubclassOf HealOverTimeStatusEffect; + TSubclassOf StrengthBuffStatusEffect; private: UPROPERTY() diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.cpp new file mode 100644 index 0000000..194851b --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.cpp @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "StrengthBuff.h" + +void UStrengthBuff::Invoke(AActor* Character, float TimeOfExpiry) +{ + Super::Invoke(Character, TimeOfExpiry); + CombatSystem = Cast(GetWorld()->GetGameState()); + CombatSystem->BaseDamageMultiplier += 1; +} + +void UStrengthBuff::OnExpiry(AActor* Character) +{ + Super::OnExpiry(Character); + CombatSystem->BaseDamageMultiplier -= 1; +} diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.h b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.h new file mode 100644 index 0000000..33ba410 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/StrengthBuff.h @@ -0,0 +1,24 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "../StatusEffect.h" +#include "the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h" +#include "StrengthBuff.generated.h" + +/** + * + */ +UCLASS() +class THE_TWILIGHT_ABYSS_API UStrengthBuff : public UStatusEffect +{ + GENERATED_BODY() + +public: + virtual void Invoke(AActor* Character, float TimeOfExpiry) override; + virtual void OnExpiry(AActor* Character) override; + +protected: + ATurnBaseCombatV2* CombatSystem; +}; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index 2a7a8bf..65d1833 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -115,8 +115,7 @@ void ATurnBaseCombatV2::CombatCheck(const bool bWasShot) { const UBlackboardComponent* EnemyBlackboard = Cast(EnemyActor->GetInstigatorController())->GetBlackboardComponent(); - ChainDamageMultiplier = 1.0f; - BaseDamageMultiplier = 1.0f; + ChainDamageMultiplier = 0; DamageMultiplierTextBlock->SetText(FText::FromString("")); const FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed")); @@ -157,6 +156,8 @@ void ATurnBaseCombatV2::EndCombat() bEnemyHasExtraTurn = false; bPlayerHasExtraTurn = false; bIsInCombat = false; + BaseDamageMultiplier -= ChainDamageMultiplier; + PreviousComboString = ""; for (UStatusEffect* StatusEffect : StatusEffects) { StatusEffect->OnExpiry(PlayerActor); @@ -328,12 +329,11 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) (PreviousComboString == "II" || PreviousComboString == "PP" || PreviousComboString == "EE" || PreviousComboString == "AA")) { ChainDamageMultiplier += ChainDamageMultiplierIncrease; - DamageMultiplierTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString("x"), FText::FromString(FString::SanitizeFloat(ChainDamageMultiplier)))); + DamageMultiplierTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString("x"), FText::FromString(FString::SanitizeFloat(ChainDamageMultiplier + BaseDamageMultiplier)))); } else if (CurrentComboString == "EI") { - BaseDamageMultiplier = ChainDamageMultiplier; - ChainDamageMultiplier = 1; + BaseDamageMultiplier += ChainDamageMultiplier; DamageMultiplierTextBlock->SetText(FText::FromString("")); } @@ -435,6 +435,11 @@ void ATurnBaseCombatV2::DamageEnemy(int Damage, const FString& DamageType) const FString Command = FString::Printf(TEXT("PlayDamageEnemyTextAnimation")); HUD->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage * BaseDamageMultiplier) + " HP by " + DamageType + "."); + if (DamageMultiplierTextBlock->GetText().ToString() == "") + { + BaseDamageMultiplier -= ChainDamageMultiplier; + ChainDamageMultiplier = 0; + } FProperty* IsBossProperty = FindFieldChecked(EnemyActor->GetClass(), "IsBoss"); const FBoolProperty* IsBossBoolProperty = CastFieldChecked(IsBossProperty); diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index 35de317..19be486 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -32,7 +32,7 @@ public: UPROPERTY(EditDefaultsOnly) float BaseDefenseMultiplier = 1.0f; UPROPERTY() - float ChainDamageMultiplier = 1.0f; + float ChainDamageMultiplier = 0; UPROPERTY(EditAnywhere) float ChainDamageMultiplierIncrease = 0.2f;