Bugfix Unable to Escape in Some Situations

This commit is contained in:
Philip W 2023-04-26 05:51:07 +01:00
parent 5634557af2
commit 37268a3dc2
3 changed files with 14 additions and 3 deletions

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

Binary file not shown.

View File

@ -2,7 +2,10 @@
#include "HoldToInitCombat.h"
#include "AIController.h"
#include "TurnBaseCombatV2.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "Blueprint/UserWidget.h"
@ -70,7 +73,12 @@ void UHoldToInitCombat::OnClickDown()
if (AActor* ClickHit = LookingAtEnemy(); ClickHit != nullptr)
{
TargetEnemy = ClickHit;
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
EnemyBlackboard = Cast<AAIController>(TargetEnemy->GetInstigatorController())->GetBlackboardComponent();
if (!EnemyBlackboard->GetValueAsBool("WasInCombat"))
{
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
return;
}
InitCombatWidget->SetVisibility(ESlateVisibility::Hidden);
return;
}

View File

@ -6,6 +6,7 @@
#include "Components/ActorComponent.h"
#include "NiagaraFunctionLibrary.h"
#include "Components/RadialSlider.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "HoldToInitCombat.generated.h"
class UNiagaraSystem;
@ -35,6 +36,8 @@ public:
protected:
// Called when the game starts
virtual void BeginPlay() override;
UPROPERTY()
UBlackboardComponent* EnemyBlackboard;
public:
// Called every frame