Updated Status Effects to Add Damage Down for Enemy & Player

This commit is contained in:
Philip W 2023-05-12 20:44:46 +01:00
parent 0064e9a003
commit 2f582cb507
8 changed files with 150 additions and 5 deletions

BIN
Content/Blueprints/StatusEffects/BP_DamageDown.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Blueprints/StatusEffects/BP_DamageDownPlayer.uasset (Stored with Git LFS) Normal file

Binary file not shown.

View File

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

View File

@ -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;
};

View File

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

View File

@ -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;
};

View File

@ -23,10 +23,15 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
{ {
static ConstructorHelpers::FClassFinder<UUserWidget> HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI")); static ConstructorHelpers::FClassFinder<UUserWidget> HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI"));
HUDWidget = HUDWidgetClass.Class; HUDWidget = HUDWidgetClass.Class;
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns")); static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns"));
ThornsStatusEffect = StatusEffectThornsClassFinder.Class; ThornsStatusEffect = StatusEffectThornsClassFinder.Class;
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime")); static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime"));
DOTStatusEffect = StatusEffectDotClassFinder.Class; DOTStatusEffect = StatusEffectDotClassFinder.Class;
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDamageDownClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageDown"));
DamageDownStatusEffect = StatusEffectDamageDownClassFinder.Class;
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDamageDownPlayerClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageDownPlayer"));
DamageDownPlayerStatusEffect = StatusEffectDamageDownPlayerClassFinder.Class;
static ConstructorHelpers::FClassFinder<UUserWidget> DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI")); static ConstructorHelpers::FClassFinder<UUserWidget> DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI"));
DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class; DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class;
@ -101,6 +106,7 @@ void ATurnBaseCombatV2::CombatCheck(const bool bWasShot)
ChainDamageMultiplier = 0; ChainDamageMultiplier = 0;
BaseDamageMultiplier = DefaultBaseDamageMultiplier; BaseDamageMultiplier = DefaultBaseDamageMultiplier;
EnemyBaseDamageMultiplier = DefaultEnemyBaseDamageMultiplier;
if (bIsBuffed) BaseDamageMultiplier += 1.0f; if (bIsBuffed) BaseDamageMultiplier += 1.0f;
DamageMultiplierTextBlock->SetText(FText::FromString("")); DamageMultiplierTextBlock->SetText(FText::FromString(""));
@ -302,6 +308,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
} }
if (IsSpecialCombo(Combo)) if (IsSpecialCombo(Combo))
{ {
FOutputDeviceNull AR;
UStatusSystem* StatusSystem = Cast<UStatusSystem>(PlayerActor->GetComponentByClass(UStatusSystem::StaticClass())); UStatusSystem* StatusSystem = Cast<UStatusSystem>(PlayerActor->GetComponentByClass(UStatusSystem::StaticClass()));
if (Combo == "PA") if (Combo == "PA")
{ {
@ -309,6 +316,9 @@ 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->SetText(FText::FromString("Casted Thorns"));
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
} }
else if (Combo == "PI") else if (Combo == "PI")
{ {
@ -316,6 +326,19 @@ 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->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<UStatusEffect>(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) void ATurnBaseCombatV2::DamagePlayer(int Damage, const FString& DamageType)
{ {
FOutputDeviceNull AR; FOutputDeviceNull AR;
*PlayerHealth -= FMath::Clamp(Damage * BaseDefenseMultiplier, 0, 100); *PlayerHealth -= FMath::Clamp(Damage * EnemyBaseDamageMultiplier, 0, 100);
DamageAmountPlayerTextBlock->SetText(FText::FromString("-" + FString::FromInt(Damage * BaseDefenseMultiplier))); DamageAmountPlayerTextBlock->SetText(FText::FromString("-" + FString::FromInt(Damage * EnemyBaseDamageMultiplier)));
const FString Command3 = FString::Printf(TEXT("PlayDamagePlayerTextAnimation")); const FString Command3 = FString::Printf(TEXT("PlayDamagePlayerTextAnimation"));
BookHUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true); BookHUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
UpdateProgressBars(); 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) if (*EnemyHealth <= 0)
{ {
EndCombat(); EndCombat();

View File

@ -28,7 +28,7 @@ public:
UPROPERTY(BlueprintReadOnly) UPROPERTY(BlueprintReadOnly)
bool bIsInCombat = false; bool bIsInCombat = false;
UPROPERTY(EditDefaultsOnly) UPROPERTY()
float BaseDamageMultiplier = 1.0f; float BaseDamageMultiplier = 1.0f;
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
float BaseDefenseMultiplier = 1.0f; float BaseDefenseMultiplier = 1.0f;
@ -40,6 +40,11 @@ public:
float ChainDamageMultiplier = 0; float ChainDamageMultiplier = 0;
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
float ChainDamageMultiplierIncrease = 0.2f; float ChainDamageMultiplierIncrease = 0.2f;
UPROPERTY(EditDefaultsOnly)
float EnemyBaseDamageMultiplier = 1.0f;
UPROPERTY(EditDefaultsOnly)
float DefaultEnemyBaseDamageMultiplier = 1.0f;
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
int DefaultActionPoints = 2; int DefaultActionPoints = 2;
@ -99,7 +104,8 @@ public:
TMap<FString, FString> SpecialCombos = TMap<FString, FString> SpecialCombos =
{ {
{"PA", "Thorns"}, {"PA", "Thorns"},
{"PI", "DamageOverTime"} {"PI", "DamageOverTime"},
{"AI", "DamageDown"}
}; };
FString BattleLog; FString BattleLog;
@ -145,6 +151,10 @@ private:
TSubclassOf<UStatusEffect> ThornsStatusEffect; TSubclassOf<UStatusEffect> ThornsStatusEffect;
UPROPERTY() UPROPERTY()
TSubclassOf<UStatusEffect> DOTStatusEffect; TSubclassOf<UStatusEffect> DOTStatusEffect;
UPROPERTY()
TSubclassOf<UStatusEffect> DamageDownStatusEffect;
UPROPERTY()
TSubclassOf<UStatusEffect> DamageDownPlayerStatusEffect;
UPROPERTY() UPROPERTY()
TArray<UStatusEffect*> StatusEffects; TArray<UStatusEffect*> StatusEffects;