Compare commits

..

10 Commits

17 changed files with 122 additions and 43 deletions

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

Binary file not shown.

Binary file not shown.

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.

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

Binary file not shown.

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

Binary file not shown.

BIN
Content/Music/Blue/SFX/Coins.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -49,6 +49,7 @@ void UInteractNPC::Interact()
{
//DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f);
if (Cast<ATempCharacter>(GetOwner())->bShopKeeperText) return;
if (Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->bIsInCombat) return;
UDialogueNPC* DialogueNPC = HitResult.GetActor()->FindComponentByClass<UDialogueNPC>();
if (DialogueNPC->bIsInDialogue)
{
@ -61,3 +62,22 @@ void UInteractNPC::Interact()
}
}
void UInteractNPC::EndInteract()
{
FVector Start = Cast<UCameraComponent>(GetOwner()->FindComponentByClass<UCameraComponent>())->GetComponentLocation();
FVector End = GetOwner()->GetActorForwardVector() * 300.0f + Start;
FCollisionQueryParams CollisionParams;
CollisionParams.AddIgnoredActor(GetOwner());
if (FHitResult HitResult; GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Pawn, CollisionParams))
{
//UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *HitResult.GetActor()->GetName());
if (HitResult.GetActor()->Tags.Contains("NPC"))
{
//DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f);
UDialogueNPC* DialogueNPC = HitResult.GetActor()->FindComponentByClass<UDialogueNPC>();
DialogueNPC->EndDialogue();
}
//DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f);
}
}

View File

@ -26,4 +26,7 @@ public:
UFUNCTION(BlueprintCallable)
void Interact();
UFUNCTION(BlueprintCallable)
void EndInteract();
};

View File

@ -114,6 +114,8 @@ void ATempCharacter::Tick(float DeltaTime)
FVector WidgetLocation;
FirstPlayerController->DeprojectMousePositionToWorld(WidgetLocation, VectorRotation);
WidgetPointer->SetWorldLocationAndRotation(WidgetLocation, VectorRotation.Rotation().Quaternion());
CrossHair->SetBrush(FSlateBrush());
CrossHair->SetDesiredSizeOverride(FVector2D(5, 5));
}
else
{
@ -242,6 +244,28 @@ void ATempCharacter::LineTraceLogic()
}
}
void ATempCharacter::ExitMerchant()
{
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
const float GlobalTrace = TraceDistance;
const FVector Start = ThisCamera->GetComponentLocation();
const FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector();
FCollisionQueryParams TraceParams;
TraceParams.AddIgnoredActor(this);
bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams);
if (bHit)
{
if (OutHit.GetActor() == nullptr) return;
if (AInteraction* MyInteractable = Cast<AInteraction>(OutHit.GetActor()))
{
if (MyInteractable->ShopDialogWidget->IsVisible())
{
MyInteractable->ExitScreen();
}
}
}
}
void ATempCharacter::AddToInventory()
{
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
@ -262,7 +286,7 @@ void ATempCharacter::AddToInventory()
}
}
void ATempCharacter::InputDisabler()
void ATempCharacter::InputDisabler(const bool SetCamera)
{
CrossHairWidget->SetVisibility(ESlateVisibility::Hidden);
@ -274,7 +298,7 @@ void ATempCharacter::InputDisabler()
PlayerController->SetIgnoreLookInput(true);
disableTab = true;
if (ThisCamera != nullptr)
if (ThisCamera != nullptr && SetCamera)
{
OriginalCameraLocation = ThisCamera->GetComponentLocation();
OriginalCameraRotation = ThisCamera->GetComponentRotation();
@ -283,7 +307,7 @@ void ATempCharacter::InputDisabler()
}
}
void ATempCharacter::InputEnabler()
void ATempCharacter::InputEnabler(const bool SetCamera)
{
//Reset UI Mode
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
@ -302,7 +326,7 @@ void ATempCharacter::InputEnabler()
UE_LOG(LogTemp, Display, TEXT("Enabling Inputs"));
disableTab = true;
TraceDistance = 300;
if (ThisCamera != nullptr)
if (ThisCamera != nullptr && SetCamera)
{
ThisCamera->SetWorldLocation(OriginalCameraLocation);
ThisCamera->SetWorldRotation(OriginalCameraRotation);

View File

@ -56,7 +56,6 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true"))
class UInventoryComponent* Inventory; //Using the InventoryComponent class
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
@ -66,10 +65,13 @@ public:
float TraceDistance = 200;
UFUNCTION(BlueprintCallable)
void InputDisabler();
void InputDisabler(bool SetCamera = true);
void LineTraceLogic();
UFUNCTION(BlueprintCallable)
void ExitMerchant();
UPROPERTY()
class UPawnNoiseEmitterComponent* NoiseEmitter;
@ -87,7 +89,7 @@ public:
void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class
UFUNCTION(BlueprintCallable)
void InputEnabler();
void InputEnabler(bool SetCamera = true);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
UCameraComponent* ThisCamera;

View File

@ -52,7 +52,8 @@ void UStatusEffect::TickDown(AActor* Character)
void UStatusEffect::CheckForExpiry(const float TimeOfExpiry, AActor* Character)
{
if (IsValid(Character)) return;
if (!IsValid(this)) return;
if (!IsValid(Character)) return;
if (TimeOfExpiry <= UGameplayStatics::GetRealTimeSeconds(GetWorld())) OnExpiry(Character);
UStatusSystem* StatusSystem = Cast<UStatusSystem>(Character->GetComponentByClass(UStatusSystem::StaticClass()));
if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return;

View File

@ -40,17 +40,19 @@ void UStatusSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCo
void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float DurationMultiplier, const bool Invoke)
{
for (FActiveStatusEffect ActiveStatusEffect : ActiveStatusEffects)
TArray<UStatusEffect*> ToExpire;
for (const FActiveStatusEffect& ActiveStatusEffect : ActiveStatusEffects)
{
if (ActiveStatusEffect.StatusEffect->Name == StatusEffect->Name)
{
ActiveStatusEffect.TimeTillExpiry = StatusEffect->BaseDuration * DurationMultiplier;
UTextBlock* StatusText = Cast<UTextBlock>(ActiveStatusEffect.StatusIcon->GetWidgetFromName(TEXT("DurationText")));
StatusText->SetText(FText::FromString(FString::FromInt(ActiveStatusEffect.TimeTillExpiry)));
if (Invoke) ActiveStatusEffect.StatusEffect->Invoke(GetOwner(), ActiveStatusEffect.TimeTillExpiry);
return;
ToExpire.Add(ActiveStatusEffect.StatusEffect);
}
}
for (UStatusEffect* StatusEffectToExpire : ToExpire)
{
StatusEffectToExpire->OnExpiry(GetOwner());
}
ToExpire.Empty();
FActiveStatusEffect NewStatusEffect;
NewStatusEffect.StatusEffect = StatusEffect;
NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());

View File

@ -12,6 +12,7 @@
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetMathLibrary.h"
#include "Misc/OutputDeviceNull.h"
#include "the_twilight_abyss/Dialogue/InteractNPC.h"
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
#include "the_twilight_abyss/Quest/QuestSystem.h"
@ -53,16 +54,25 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
EscapePercentage = CalculateEscapePercentage();
EscapePercentageTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString(FString::FromInt(EscapePercentage * 100)), FText::FromString("%")));
bIsInCombat = true;
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
Cast<UQuestSystem>(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden);
HealingJellyAmountTextBlock->SetText(FText::FromString(FString::FromInt(FMath::Clamp(Cast<ATempCharacter>(PlayerActor)->Inventory->GetItemAmount(0), 0, 99))));
if (Cast<ATempCharacter>(PlayerActor)->bIsInDialogue)
{
Cast<UInteractNPC>(PlayerActor->GetComponentByClass(UInteractNPC::StaticClass()))->EndInteract();
}
if (Cast<ATempCharacter>(PlayerActor)->bShopKeeperText)
{
Cast<ATempCharacter>(PlayerActor)->ExitMerchant();
}
FOutputDeviceNull AR;
const FString Command = FString::Printf(TEXT("CloseInventory"));
PlayerActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
const FString Command69 = FString::Printf(TEXT("CloseEscapeMenu"));
PlayerActor->CallFunctionByNameWithArguments(*Command69, AR, nullptr, true);
//Disable Character Movement
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetIgnoreMoveInput(true);
@ -70,7 +80,6 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
PlayerController->SetInputMode(FInputModeGameAndUI());
PlayerController->bShowMouseCursor = true;
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
const FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
@ -112,7 +121,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot)
void ATurnBaseCombatV2::CombatCheck(const bool bWasShot)
{
const UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
ChainDamageMultiplier = 0;
BaseDamageMultiplier = DefaultBaseDamageMultiplier;
EnemyBaseDamageMultiplier = DefaultEnemyBaseDamageMultiplier;
@ -148,6 +157,7 @@ void ATurnBaseCombatV2::CombatCheck(const bool bWasShot)
void ATurnBaseCombatV2::EndCombat()
{
GetWorldTimerManager().ClearTimer(EnemyTurnTimerHandle);
BookHUD->SetVisibility(ESlateVisibility::Hidden);
HUD->RemoveFromParent();
BookStaticMeshComponent->SetVisibility(false);
@ -333,7 +343,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
{
FOutputDeviceNull AR;
UStatusSystem* StatusSystem = Cast<UStatusSystem>(PlayerActor->GetComponentByClass(UStatusSystem::StaticClass()));
if (Combo == "PA")
if (Combo == "PA" || Combo == "AP")
{
UStatusEffect* TempThornsStatusEffect = NewObject<UStatusEffect>(PlayerActor, ThornsStatusEffect);
StatusSystem->AddStatusEffect(TempThornsStatusEffect, 1, false);
@ -344,7 +354,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
}
else if (Combo == "PI")
else if (Combo == "PI" || Combo == "IP")
{
UStatusEffect* TempDOTStatusEffect = NewObject<UStatusEffect>(PlayerActor, DOTStatusEffect);
StatusSystem->AddStatusEffect(TempDOTStatusEffect, 1, false);
@ -355,7 +365,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
const FString Command3 = FString::Printf(TEXT("PlayStatusAnimation"));
HUD->CallFunctionByNameWithArguments(*Command3, AR, nullptr, true);
}
else if (Combo == "AI")
else if (Combo == "AI" || Combo == "IA")
{
UStatusEffect* TempDamageDownStatusEffect = NewObject<UStatusEffect>(PlayerActor, DamageDownStatusEffect);
StatusSystem->AddStatusEffect(TempDamageDownStatusEffect, 1, true);
@ -403,7 +413,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
{
case true:
// Player Turn
DamageEnemy(*ValidCombos.Find(Combo));
DamageEnemy(ValidCombos.Contains(Combo) ? *ValidCombos.Find(Combo) : *ValidCombos.Find(Combo.Reverse()));
OnPlayerTurn.Broadcast(PlayerActor, EnemyActor);
break;
case false:
@ -415,6 +425,9 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
if (!bPlayerHasExtraTurn)
{
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);
if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor) && EnemyHealth <= nullptr) return;
SwitchTurn();
}
else
@ -459,6 +472,11 @@ void ATurnBaseCombatV2::DamagePlayer(int Damage, const FString& DamageType)
{
const FString Command = FString::Printf(TEXT("TriggerDeathAnimation"));
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
for (UStatusEffect* StatusEffect : StatusEffects)
{
StatusEffect->OnExpiry(PlayerActor);
}
StatusEffects.Empty();
return;
}
EndCombat();
@ -512,6 +530,11 @@ void ATurnBaseCombatV2::DamageEnemy(int Damage, const FString& DamageType)
{
const FString Command2 = FString::Printf(TEXT("TriggerDeathAnimation"));
EnemyActor->CallFunctionByNameWithArguments(*Command2, AR, nullptr, true);
for (UStatusEffect* StatusEffect : StatusEffects)
{
StatusEffect->OnExpiry(PlayerActor);
}
StatusEffects.Empty();
return;
}
EndCombat();
@ -542,12 +565,14 @@ float ATurnBaseCombatV2::CalculateEscapePercentage() const
bool ATurnBaseCombatV2::IsValidCombo(const FString& Combo) const
{
return ValidCombos.Contains(Combo);
if (ValidCombos.Contains(Combo) || ValidCombos.Contains(Combo.Reverse())) return true;
return false;
}
bool ATurnBaseCombatV2::IsSpecialCombo(const FString& Combo) const
{
return SpecialCombos.Contains(Combo);
if (SpecialCombos.Contains(Combo) || SpecialCombos.Contains(Combo.Reverse())) return true;
return false;
}
void ATurnBaseCombatV2::SwitchTurn()
@ -557,8 +582,7 @@ void ATurnBaseCombatV2::SwitchTurn()
TurnIndicatorTextBlock->SetText(FText::FromString("Enemy Turn"));
DisableButtons();
FTimerHandle UnusedHandle;
GetWorldTimerManager().SetTimer(UnusedHandle, this, &ATurnBaseCombatV2::EnemyTurn, 2.0f, false);
GetWorldTimerManager().SetTimer(EnemyTurnTimerHandle, this, &ATurnBaseCombatV2::EnemyTurn, 2.0f, false);
//activeActor = bIsPlayerTurn ? enemyActor : playerActor;
}
@ -799,6 +823,7 @@ void ATurnBaseCombatV2::EnableButtons() const
void ATurnBaseCombatV2::EnemyTurn()
{
if (!IsValid(EnemyActor)) return;
if (EnemyHealth <= nullptr) return;
int ChanceToMiss;
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);

View File

@ -146,6 +146,8 @@ protected:
private:
bool IsValidCombo(const FString& Combo) const;
bool IsSpecialCombo(const FString& Combo) const;
UPROPERTY()
FTimerHandle EnemyTurnTimerHandle;
UPROPERTY()
APostProcessVolume* PostProcessVolume;