From 2f582cb507de2b16256d9ccc1f0eee596debc3dc Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Fri, 12 May 2023 20:44:46 +0100 Subject: [PATCH] Updated Status Effects to Add Damage Down for Enemy & Player --- .../StatusEffects/BP_DamageDown.uasset | 3 ++ .../StatusEffects/BP_DamageDownPlayer.uasset | 3 ++ .../StatusEffects/DamageDown.cpp | 26 +++++++++++++++++ .../StatusEffects/DamageDown.h | 27 +++++++++++++++++ .../StatusEffects/DamageDownPlayer.cpp | 26 +++++++++++++++++ .../StatusEffects/DamageDownPlayer.h | 27 +++++++++++++++++ .../TurnBasedCombatV2/TurnBaseCombatV2.cpp | 29 +++++++++++++++++-- .../TurnBasedCombatV2/TurnBaseCombatV2.h | 14 +++++++-- 8 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 Content/Blueprints/StatusEffects/BP_DamageDown.uasset create mode 100644 Content/Blueprints/StatusEffects/BP_DamageDownPlayer.uasset create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.cpp create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.h create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.cpp create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.h diff --git a/Content/Blueprints/StatusEffects/BP_DamageDown.uasset b/Content/Blueprints/StatusEffects/BP_DamageDown.uasset new file mode 100644 index 0000000..b05d92b --- /dev/null +++ b/Content/Blueprints/StatusEffects/BP_DamageDown.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:725465e42f03b432e3ac51705eac6998e369b933262565349694748dfd8cbfd5 +size 6090 diff --git a/Content/Blueprints/StatusEffects/BP_DamageDownPlayer.uasset b/Content/Blueprints/StatusEffects/BP_DamageDownPlayer.uasset new file mode 100644 index 0000000..6682e95 --- /dev/null +++ b/Content/Blueprints/StatusEffects/BP_DamageDownPlayer.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a4c63e8e94e70e90a3ebb6c5118ce7c14e473790d1f47b58b74a62767212916 +size 6667 diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.cpp new file mode 100644 index 0000000..80b0442 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.cpp @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "DamageDown.h" + +void UDamageDown::Invoke(AActor* Character, float TimeOfExpiry) +{ + CombatSystem = Cast(GetWorld()->GetGameState()); + CombatSystem->EnemyBaseDamageMultiplier -= EnemyDamageMultiplierDecreaseAmount; +} + +void UDamageDown::OnExpiry(AActor* Character) +{ + CombatSystem->EnemyBaseDamageMultiplier += EnemyDamageMultiplierDecreaseAmount; + Super::OnExpiry(Character); +} + +void UDamageDown::OnEnemyTurn(AActor* Enemy, AActor* Character) +{ + BaseDuration -= 1.0f; + Super::OnEnemyTurn(Enemy, Character); + if (BaseDuration <= 0.0f) + { + OnExpiry(Character); + } +} diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.h b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.h new file mode 100644 index 0000000..23a43d0 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDown.h @@ -0,0 +1,27 @@ +// 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 "DamageDown.generated.h" + +/** + * + */ +UCLASS() +class THE_TWILIGHT_ABYSS_API UDamageDown : public UStatusEffect +{ + GENERATED_BODY() + +public: + UPROPERTY(EditDefaultsOnly) + float EnemyDamageMultiplierDecreaseAmount = 0.2f; + virtual void Invoke(AActor* Character, float TimeOfExpiry) override; + virtual void OnExpiry(AActor* Character) override; + virtual void OnEnemyTurn(AActor* Enemy, AActor* Character) override; + +protected: + ATurnBaseCombatV2* CombatSystem; +}; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.cpp new file mode 100644 index 0000000..a0ba615 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.cpp @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "DamageDownPlayer.h" + +void UDamageDownPlayer::Invoke(AActor* Character, float TimeOfExpiry) +{ + CombatSystem = Cast(GetWorld()->GetGameState()); + CombatSystem->BaseDamageMultiplier -= PlayerDamageMultiplierDecreaseAmount; +} + +void UDamageDownPlayer::OnExpiry(AActor* Character) +{ + Super::OnExpiry(Character); + CombatSystem->BaseDamageMultiplier += PlayerDamageMultiplierDecreaseAmount; +} + +void UDamageDownPlayer::OnEnemyTurn(AActor* Enemy, AActor* Character) +{ + BaseDuration -= 1.0f; + Super::OnEnemyTurn(Enemy, Character); + if (BaseDuration <= 0.0f) + { + OnExpiry(Character); + } +} diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.h b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.h new file mode 100644 index 0000000..8170034 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageDownPlayer.h @@ -0,0 +1,27 @@ +// 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 "DamageDownPlayer.generated.h" + +/** + * + */ +UCLASS() +class THE_TWILIGHT_ABYSS_API UDamageDownPlayer : public UStatusEffect +{ + GENERATED_BODY() + +public: + UPROPERTY(EditDefaultsOnly) + float PlayerDamageMultiplierDecreaseAmount = 0.2f; + virtual void Invoke(AActor* Character, float TimeOfExpiry) override; + virtual void OnExpiry(AActor* Character) override; + virtual void OnEnemyTurn(AActor* Enemy, 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 9c80469..af2285b 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -23,10 +23,15 @@ ATurnBaseCombatV2::ATurnBaseCombatV2() { static ConstructorHelpers::FClassFinder HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI")); HUDWidget = HUDWidgetClass.Class; + static ConstructorHelpers::FClassFinder StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns")); ThornsStatusEffect = StatusEffectThornsClassFinder.Class; static ConstructorHelpers::FClassFinder StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime")); DOTStatusEffect = StatusEffectDotClassFinder.Class; + static ConstructorHelpers::FClassFinder StatusEffectDamageDownClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageDown")); + DamageDownStatusEffect = StatusEffectDamageDownClassFinder.Class; + static ConstructorHelpers::FClassFinder StatusEffectDamageDownPlayerClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageDownPlayer")); + DamageDownPlayerStatusEffect = StatusEffectDamageDownPlayerClassFinder.Class; static ConstructorHelpers::FClassFinder DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI")); DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class; @@ -101,6 +106,7 @@ void ATurnBaseCombatV2::CombatCheck(const bool bWasShot) ChainDamageMultiplier = 0; BaseDamageMultiplier = DefaultBaseDamageMultiplier; + EnemyBaseDamageMultiplier = DefaultEnemyBaseDamageMultiplier; if (bIsBuffed) BaseDamageMultiplier += 1.0f; DamageMultiplierTextBlock->SetText(FText::FromString("")); @@ -302,6 +308,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) } if (IsSpecialCombo(Combo)) { + FOutputDeviceNull AR; UStatusSystem* StatusSystem = Cast(PlayerActor->GetComponentByClass(UStatusSystem::StaticClass())); if (Combo == "PA") { @@ -309,6 +316,9 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) StatusSystem->AddStatusEffect(TempThornsStatusEffect, 1, false); StatusEffects.Add(TempThornsStatusEffect); AddBattleLogMessage("Player Casted Thorns"); + StatusTextBlock->SetText(FText::FromString("Casted Thorns")); + const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); + HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); } else if (Combo == "PI") { @@ -316,6 +326,19 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) StatusSystem->AddStatusEffect(TempDOTStatusEffect, 1, false); StatusEffects.Add(TempDOTStatusEffect); AddBattleLogMessage("Player Casted DOT"); + StatusTextBlock->SetText(FText::FromString("Casted DOT")); + const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); + HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); + } + else if (Combo == "AI") + { + UStatusEffect* TempDamageDownStatusEffect = NewObject(PlayerActor, DamageDownStatusEffect); + StatusSystem->AddStatusEffect(TempDamageDownStatusEffect, 1); + StatusEffects.Add(TempDamageDownStatusEffect); + AddBattleLogMessage("Player Casted DamageDown"); + StatusTextBlock->SetText(FText::FromString("Enemy Damage Down")); + const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation")); + HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); } } @@ -396,12 +419,12 @@ void ATurnBaseCombatV2::RevertActionPoints() void ATurnBaseCombatV2::DamagePlayer(int Damage, const FString& DamageType) { FOutputDeviceNull AR; - *PlayerHealth -= FMath::Clamp(Damage * BaseDefenseMultiplier, 0, 100); - DamageAmountPlayerTextBlock->SetText(FText::FromString("-" + FString::FromInt(Damage * BaseDefenseMultiplier))); + *PlayerHealth -= FMath::Clamp(Damage * EnemyBaseDamageMultiplier, 0, 100); + DamageAmountPlayerTextBlock->SetText(FText::FromString("-" + FString::FromInt(Damage * EnemyBaseDamageMultiplier))); const FString Command3 = FString::Printf(TEXT("PlayDamagePlayerTextAnimation")); BookHUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); UpdateProgressBars(); - AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage * BaseDefenseMultiplier) + " HP by " + DamageType + "."); + AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage * EnemyBaseDamageMultiplier) + " HP by " + DamageType + "."); if (*EnemyHealth <= 0) { EndCombat(); diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index 17b588a..cd71c0e 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -28,7 +28,7 @@ public: UPROPERTY(BlueprintReadOnly) bool bIsInCombat = false; - UPROPERTY(EditDefaultsOnly) + UPROPERTY() float BaseDamageMultiplier = 1.0f; UPROPERTY(EditDefaultsOnly) float BaseDefenseMultiplier = 1.0f; @@ -40,6 +40,11 @@ public: float ChainDamageMultiplier = 0; UPROPERTY(EditAnywhere) float ChainDamageMultiplierIncrease = 0.2f; + + UPROPERTY(EditDefaultsOnly) + float EnemyBaseDamageMultiplier = 1.0f; + UPROPERTY(EditDefaultsOnly) + float DefaultEnemyBaseDamageMultiplier = 1.0f; UPROPERTY(EditDefaultsOnly) int DefaultActionPoints = 2; @@ -99,7 +104,8 @@ public: TMap SpecialCombos = { {"PA", "Thorns"}, - {"PI", "DamageOverTime"} + {"PI", "DamageOverTime"}, + {"AI", "DamageDown"} }; FString BattleLog; @@ -145,6 +151,10 @@ private: TSubclassOf ThornsStatusEffect; UPROPERTY() TSubclassOf DOTStatusEffect; + UPROPERTY() + TSubclassOf DamageDownStatusEffect; + UPROPERTY() + TSubclassOf DamageDownPlayerStatusEffect; UPROPERTY() TArray StatusEffects;