Merge branch 'dev' into Inventory-Notifications

This commit is contained in:
Philip W 2023-05-12 21:47:07 +01:00
commit 7a04920197
13 changed files with 189 additions and 41 deletions

BIN
Content/Animations/Boss/AB_Boss.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/BlueprintAI/AI/AIBruh_Boss.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

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

@ -33,6 +33,11 @@ bool UQuest::WorldStateMatch(UWorldState* A, UWorldState* B)
if (A->Items.IsEmpty() && !B->Items.IsEmpty()) return false;
for (UBaseItem* Item : B->Items)
{
if (A->Items.IndexOfByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; }) == -1)
{
UE_LOG(LogTemp, Warning, TEXT("WorldState Predicate Failed"));
return false;
}
if (!A->Items.Contains(Item) && Item->StackCount > A->Items[A->Items.IndexOfByPredicate([Item](const UBaseItem* AItem) { return AItem->ItemID == Item->ItemID; })]->StackCount)
{
return false;

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

@ -48,7 +48,7 @@ public:
UPROPERTY()
UWrapBox* StatusIconsBox;
UPROPERTY()
UPROPERTY(VisibleAnywhere)
TArray<FActiveStatusEffect> ActiveStatusEffects;
protected:

View File

@ -23,10 +23,15 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
{
static ConstructorHelpers::FClassFinder<UUserWidget> HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI"));
HUDWidget = HUDWidgetClass.Class;
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns"));
ThornsStatusEffect = StatusEffectThornsClassFinder.Class;
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime"));
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"));
DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class;
@ -58,19 +63,27 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
PlayerController->SetInputMode(FInputModeGameAndUI());
PlayerController->bShowMouseCursor = true;
// FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
// Direction.Normalize();
// FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
// const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
// LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
// PlayerController->SetControlRotation(LookAtRotation);
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
const FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
EnemyHealth = EnemyHealthPtr;
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
if (const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
{
FOutputDeviceNull AR;
const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true"));
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation();
Direction.Normalize();
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
LookAtRotation.Pitch += 10; //Offset
PlayerController->SetControlRotation(LookAtRotation);
}
if (IsValid(CombatTutorialWidgetInstance) && CombatTutorialWidgetInstance->IsInViewport()) return;
if (!HasSeenTutorial)
{
@ -93,6 +106,7 @@ void ATurnBaseCombatV2::CombatCheck(const bool bWasShot)
ChainDamageMultiplier = 0;
BaseDamageMultiplier = DefaultBaseDamageMultiplier;
EnemyBaseDamageMultiplier = DefaultEnemyBaseDamageMultiplier;
if (bIsBuffed) BaseDamageMultiplier += 1.0f;
DamageMultiplierTextBlock->SetText(FText::FromString(""));
@ -249,28 +263,14 @@ void ATurnBaseCombatV2::Tick(const float DeltaTime)
{
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);
if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
{
FOutputDeviceNull AR;
const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true"));
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation();
Direction.Normalize();
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
PlayerController->SetControlRotation(LookAtRotation);
}
else
if (const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty); !IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
{
FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation();
Direction.Normalize();
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), Cast<USkeletalMeshComponent>(EnemyActor->FindComponentByClass<USkeletalMeshComponent>())->GetComponentLocation());
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->SetWorldRotation(LookAtRotation);
PlayerController->SetControlRotation(LookAtRotation);
}
}
}
@ -308,6 +308,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
}
if (IsSpecialCombo(Combo))
{
FOutputDeviceNull AR;
UStatusSystem* StatusSystem = Cast<UStatusSystem>(PlayerActor->GetComponentByClass(UStatusSystem::StaticClass()));
if (Combo == "PA")
{
@ -315,6 +316,10 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
StatusSystem->AddStatusEffect(TempThornsStatusEffect, 1, false);
StatusEffects.Add(TempThornsStatusEffect);
AddBattleLogMessage("Player Casted Thorns");
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Casted Thorns"));
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
}
else if (Combo == "PI")
{
@ -322,6 +327,21 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
StatusSystem->AddStatusEffect(TempDOTStatusEffect, 1, false);
StatusEffects.Add(TempDOTStatusEffect);
AddBattleLogMessage("Player Casted DOT");
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
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->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Enemy Damage Down"));
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
}
}
@ -402,12 +422,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();
@ -636,7 +656,7 @@ void ATurnBaseCombatV2::RunButtonOnClick()
{
if (FMath::RandRange(0.0f, 1.0f) >= EscapePercentage)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Escape Failed"));
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 0.0f, 0.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Escape Failed"));
FOutputDeviceNull AR;
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
@ -722,10 +742,10 @@ void ATurnBaseCombatV2::UpdateBattleLog()
void ATurnBaseCombatV2::UpdateResourceBars() const
{
ProbertiumResourceBar->SetPercent(ProbertiumResource / 10.0f);
EisResourceBar->SetPercent(EisResource / 10.0f);
AzosResourceBar->SetPercent(AzosResource / 10.0f);
IroquoidResourceBar->SetPercent(IroquoidResource / 10.0f);
ProbertiumResourceBar->SetPercent(ProbertiumResource / 20.0f);
EisResourceBar->SetPercent(EisResource / 20.0f);
AzosResourceBar->SetPercent(AzosResource / 20.0f);
IroquoidResourceBar->SetPercent(IroquoidResource / 20.0f);
ToggleButtonIfResourceAvailable();
}
@ -764,6 +784,7 @@ void ATurnBaseCombatV2::EnemyTurn()
}
else
{
StatusTextBlock->SetColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f)));
StatusTextBlock->SetText(FText::FromString("Missed"));
FOutputDeviceNull AR;
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
@ -787,6 +808,6 @@ void ATurnBaseCombatV2::ToggleButtonIfResourceAvailable() const
else AButton->SetIsEnabled(false);
if (IroquoidResource >= 1) IButton->SetIsEnabled(true);
else IButton->SetIsEnabled(false);
if (Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0) >= 1) HealButton->SetIsEnabled(true);
if (Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0) >= 1 && *PlayerHealth < 100.0f) HealButton->SetIsEnabled(true);
else HealButton->SetIsEnabled(false);
}

View File

@ -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<FString, FString> SpecialCombos =
{
{"PA", "Thorns"},
{"PI", "DamageOverTime"}
{"PI", "DamageOverTime"},
{"AI", "DamageDown"}
};
FString BattleLog;
@ -145,6 +151,10 @@ private:
TSubclassOf<UStatusEffect> ThornsStatusEffect;
UPROPERTY()
TSubclassOf<UStatusEffect> DOTStatusEffect;
UPROPERTY()
TSubclassOf<UStatusEffect> DamageDownStatusEffect;
UPROPERTY()
TSubclassOf<UStatusEffect> DamageDownPlayerStatusEffect;
UPROPERTY()
TArray<UStatusEffect*> StatusEffects;