From c742abfce4ab9c4c91b09bd4153e84b845f08b6a Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Thu, 2 Mar 2023 15:06:31 +0000 Subject: [PATCH] Added DamageOverTime Status Effect for Combat --- .vsconfig | 5 ++++ .../StatusEffects/BP_DamageOverTime.uasset | 3 +++ .../StatusEffects/DamageOverTime.cpp | 17 ++++++++++++++ .../StatusEffects/DamageOverTime.h | 23 +++++++++++++++++++ .../TurnBasedCombatV2/TurnBaseCombatV2.cpp | 9 ++++++++ .../TurnBasedCombatV2/TurnBaseCombatV2.h | 2 ++ 6 files changed, 59 insertions(+) create mode 100644 Content/Blueprints/StatusEffects/BP_DamageOverTime.uasset create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.cpp create mode 100644 Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.h diff --git a/.vsconfig b/.vsconfig index cf3175a..b9be525 100644 --- a/.vsconfig +++ b/.vsconfig @@ -1,10 +1,15 @@ { "version": "1.0", "components": [ + "Microsoft.Net.Component.4.6.2.TargetingPack", + "Microsoft.VisualStudio.Component.VC.14.33.17.3.ARM64", + "Microsoft.VisualStudio.Component.VC.14.33.17.3.x86.x64", "Microsoft.VisualStudio.Component.VC.Tools.ARM64", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "Microsoft.VisualStudio.Component.Windows10SDK", "Microsoft.VisualStudio.Workload.CoreEditor", + "Microsoft.VisualStudio.Workload.ManagedDesktop", + "Microsoft.VisualStudio.Workload.NativeCrossPlat", "Microsoft.VisualStudio.Workload.NativeDesktop", "Microsoft.VisualStudio.Workload.NativeGame", "Microsoft.VisualStudio.Workload.Universal" diff --git a/Content/Blueprints/StatusEffects/BP_DamageOverTime.uasset b/Content/Blueprints/StatusEffects/BP_DamageOverTime.uasset new file mode 100644 index 0000000..c69a24b --- /dev/null +++ b/Content/Blueprints/StatusEffects/BP_DamageOverTime.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08f2fffcd5fe0379220954960108a4ee1346bc64bd456fee30919e5f60725878 +size 6592 diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.cpp new file mode 100644 index 0000000..c6692b1 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.cpp @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "DamageOverTime.h" +#include + +void UDamageOverTime::OnEnemyTurn(AActor* Enemy, AActor* Character) +{ + Super::OnEnemyTurn(Enemy, Character); + ATurnBaseCombatV2* CombatSystem = Cast(GetWorld()->GetGameState()); + CombatSystem->DamageEnemy(DamagePerTurn, "DOT"); + BaseDuration -= 1.0f; + if (BaseDuration <= 0.0f) + { + OnExpiry(Character); + } +} diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.h b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.h new file mode 100644 index 0000000..c50db18 --- /dev/null +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/DamageOverTime.h @@ -0,0 +1,23 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "../StatusEffect.h" +#include "DamageOverTime.generated.h" + +/** + * + */ +UCLASS() +class THE_TWILIGHT_ABYSS_API UDamageOverTime : public UStatusEffect +{ + GENERATED_BODY() +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float DamagePerTurn = 6.0f; + + //virtual void Invoke(AActor* Character, float TimeOfExpiry) override; + //virtual void OnExpiry(AActor* Character) override; + virtual void OnEnemyTurn(AActor* Enemy, AActor* Character) override; +}; diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index eb2eb90..3bbffa9 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -22,6 +22,8 @@ ATurnBaseCombatV2::ATurnBaseCombatV2() 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; } } @@ -178,6 +180,13 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo) StatusEffects.Add(TempThornsStatusEffect); AddBattleLogMessage("Player Casted Thorns"); } + else if (Combo == "PPI") + { + UStatusEffect* TempDOTStatusEffect = NewObject(PlayerActor, DOTStatusEffect); + StatusSystem->AddStatusEffect(TempDOTStatusEffect, 1, false); + StatusEffects.Add(TempDOTStatusEffect); + AddBattleLogMessage("Player Casted DOT"); + } } if (GunEffect) diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index db67b13..db70d83 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -121,6 +121,8 @@ private: UPROPERTY() TSubclassOf ThornsStatusEffect; + UPROPERTY() + TSubclassOf DOTStatusEffect; UPROPERTY() TArray StatusEffects;