diff --git a/Content/BlueprintAI/AI/AIBruh.uasset b/Content/BlueprintAI/AI/AIBruh.uasset index c510da3..712c9e6 100644 --- a/Content/BlueprintAI/AI/AIBruh.uasset +++ b/Content/BlueprintAI/AI/AIBruh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a288fa4ebd324988aab14b0d87b949c358a2c2c3cc9bc3bd6332f555732806d5 -size 100609 +oid sha256:fd2ed6c4f53386c79e1daff8522dd56b341cf93fa2957fd06bd48d324af0ee04 +size 100469 diff --git a/Content/Blueprints/Combat_UI/BookCombat_UI.uasset b/Content/Blueprints/Combat_UI/BookCombat_UI.uasset index 1e2f7ec..23d4be0 100644 --- a/Content/Blueprints/Combat_UI/BookCombat_UI.uasset +++ b/Content/Blueprints/Combat_UI/BookCombat_UI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6c5fcc9889b89941b5a0a8d8ab6dec169e3409c426d30d3e4c20cdaee22b5453 -size 164265 +oid sha256:345fed2f81c369ee2d8d7110421899b9b89e13c3ce19b56c3b9a1fcb2503fb11 +size 164508 diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index b0a68de..c6816ca 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -18,6 +18,7 @@ // Sets default values ATurnBaseCombatV2::ATurnBaseCombatV2() { + PrimaryActorTick.bCanEverTick = true; if (HUDWidget == nullptr) { static ConstructorHelpers::FClassFinder HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI")); @@ -57,37 +58,12 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot) PlayerController->SetInputMode(FInputModeGameAndUI()); PlayerController->bShowMouseCursor = true; - FProperty* IsBossProperty = FindFieldChecked(EnemyActor->GetClass(), "IsBoss"); - const FBoolProperty* IsBossBoolProperty = CastFieldChecked(IsBossProperty); - if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor)) - { - FOutputDeviceNull AR; - const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true")); - EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); - - FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); - Direction.Normalize(); - FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); - const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), EnemyActor->GetActorLocation()); - LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; - PlayerController->SetControlRotation(LookAtRotation); - } - else - { - FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); - Direction.Normalize(); - FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); - const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), Cast(EnemyActor->FindComponentByClass())->GetComponentLocation()); - LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; - PlayerController->SetControlRotation(LookAtRotation); - } - - FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); - Direction.Normalize(); - FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); - const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), EnemyActor->GetActorLocation()); - LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; - PlayerController->SetControlRotation(LookAtRotation); + // FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); + // Direction.Normalize(); + // FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); + // const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), EnemyActor->GetActorLocation()); + // LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; + // PlayerController->SetControlRotation(LookAtRotation); if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return; EnemyBlackboard->SetValueAsBool("IsInCombat", true); @@ -266,6 +242,39 @@ void ATurnBaseCombatV2::BeginPlay() HealButton->OnClicked.AddDynamic(this, &ATurnBaseCombatV2::HealButtonOnClick); } +void ATurnBaseCombatV2::Tick(const float DeltaTime) +{ + Super::Tick(DeltaTime); + if (bIsInCombat) + { + APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); + FProperty* IsBossProperty = FindFieldChecked(EnemyActor->GetClass(), "IsBoss"); + const FBoolProperty* IsBossBoolProperty = CastFieldChecked(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(PlayerActor->FindComponentByClass())->GetComponentLocation(), EnemyActor->GetActorLocation()); + LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; + PlayerController->SetControlRotation(LookAtRotation); + } + else + { + FVector Direction = EnemyActor->GetActorLocation() - PlayerActor->GetActorLocation(); + Direction.Normalize(); + FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); + const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), Cast(EnemyActor->FindComponentByClass())->GetComponentLocation()); + LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; + Cast(PlayerActor->FindComponentByClass())->SetWorldRotation(LookAtRotation); + } + } +} + void ATurnBaseCombatV2::ExecuteCast(FString Combo) { if (!IsValidCombo(Combo)) diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index b473788..17b588a 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -121,6 +121,7 @@ public: protected: virtual void BeginPlay() override; + virtual void Tick(float DeltaTime) override; void ExecuteCast(FString Combo); void UseActionPoint(); void ReuseActionPoint();