Updated Status System to Add Buff Jelly Functionality

This commit is contained in:
Philip W 2023-05-11 05:59:49 +01:00
parent d197dc4d7e
commit e8e4e86873
12 changed files with 69 additions and 21 deletions

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Levels/Build.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -10,8 +10,8 @@
UEatableItems::UEatableItems() UEatableItems::UEatableItems()
{ {
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_HealOverTime")); static ConstructorHelpers::FClassFinder<UStatusEffect> StrengthBuffClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_StrengthBuff"));
HealOverTimeStatusEffect = StatusEffectClassFinder.Class; StrengthBuffStatusEffect = StrengthBuffClassFinder.Class;
} }
void UEatableItems::Use(ATempCharacter* Character) void UEatableItems::Use(ATempCharacter* Character)
@ -22,8 +22,6 @@ void UEatableItems::Use(ATempCharacter* Character)
{ {
if (Character->Health < 100) if (Character->Health < 100)
{ {
// UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>();
// StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(Character, HealOverTimeStatusEffect));
Character->Health += 20; Character->Health += 20;
Character->Inventory->RemoveItem(this); Character->Inventory->RemoveItem(this);
} }
@ -36,7 +34,8 @@ void UEatableItems::Use(ATempCharacter* Character)
if (isDamageBuffItem) if (isDamageBuffItem)
{ {
// need to add the damage buff functionality here UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>();
StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(Character, StrengthBuffStatusEffect));
UE_LOG(LogTemp, Display, TEXT("Damage Buffed")); UE_LOG(LogTemp, Display, TEXT("Damage Buffed"));
Character->Inventory->RemoveItem(this); Character->Inventory->RemoveItem(this);
} }

View File

@ -22,7 +22,7 @@ protected:
virtual void Use(class ATempCharacter* Character) override; virtual void Use(class ATempCharacter* Character) override;
UPROPERTY() UPROPERTY()
TSubclassOf<UStatusEffect> HealOverTimeStatusEffect; TSubclassOf<UStatusEffect> StrengthBuffStatusEffect;
private: private:
UPROPERTY() UPROPERTY()

View File

@ -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<ATurnBaseCombatV2>(GetWorld()->GetGameState());
CombatSystem->BaseDamageMultiplier += 1;
}
void UStrengthBuff::OnExpiry(AActor* Character)
{
Super::OnExpiry(Character);
CombatSystem->BaseDamageMultiplier -= 1;
}

View File

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

View File

@ -115,8 +115,7 @@ void ATurnBaseCombatV2::CombatCheck(const bool bWasShot)
{ {
const UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent(); const UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
ChainDamageMultiplier = 1.0f; ChainDamageMultiplier = 0;
BaseDamageMultiplier = 1.0f;
DamageMultiplierTextBlock->SetText(FText::FromString("")); DamageMultiplierTextBlock->SetText(FText::FromString(""));
const FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed")); const FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed"));
@ -157,6 +156,8 @@ void ATurnBaseCombatV2::EndCombat()
bEnemyHasExtraTurn = false; bEnemyHasExtraTurn = false;
bPlayerHasExtraTurn = false; bPlayerHasExtraTurn = false;
bIsInCombat = false; bIsInCombat = false;
BaseDamageMultiplier -= ChainDamageMultiplier;
PreviousComboString = "";
for (UStatusEffect* StatusEffect : StatusEffects) for (UStatusEffect* StatusEffect : StatusEffects)
{ {
StatusEffect->OnExpiry(PlayerActor); StatusEffect->OnExpiry(PlayerActor);
@ -328,12 +329,11 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
(PreviousComboString == "II" || PreviousComboString == "PP" || PreviousComboString == "EE" || PreviousComboString == "AA")) (PreviousComboString == "II" || PreviousComboString == "PP" || PreviousComboString == "EE" || PreviousComboString == "AA"))
{ {
ChainDamageMultiplier += ChainDamageMultiplierIncrease; 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") else if (CurrentComboString == "EI")
{ {
BaseDamageMultiplier = ChainDamageMultiplier; BaseDamageMultiplier += ChainDamageMultiplier;
ChainDamageMultiplier = 1;
DamageMultiplierTextBlock->SetText(FText::FromString("")); DamageMultiplierTextBlock->SetText(FText::FromString(""));
} }
@ -435,6 +435,11 @@ void ATurnBaseCombatV2::DamageEnemy(int Damage, const FString& DamageType)
const FString Command = FString::Printf(TEXT("PlayDamageEnemyTextAnimation")); const FString Command = FString::Printf(TEXT("PlayDamageEnemyTextAnimation"));
HUD->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); HUD->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage * BaseDamageMultiplier) + " HP by " + DamageType + "."); AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage * BaseDamageMultiplier) + " HP by " + DamageType + ".");
if (DamageMultiplierTextBlock->GetText().ToString() == "")
{
BaseDamageMultiplier -= ChainDamageMultiplier;
ChainDamageMultiplier = 0;
}
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss"); FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);

View File

@ -32,7 +32,7 @@ public:
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
float BaseDefenseMultiplier = 1.0f; float BaseDefenseMultiplier = 1.0f;
UPROPERTY() UPROPERTY()
float ChainDamageMultiplier = 1.0f; float ChainDamageMultiplier = 0;
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
float ChainDamageMultiplierIncrease = 0.2f; float ChainDamageMultiplierIncrease = 0.2f;