Bugfix Enemy Runs Away when User Init Combat

This commit is contained in:
Philip W 2023-01-31 00:29:53 +00:00
parent 6092c22a2b
commit e91d059c56
3 changed files with 7 additions and 3 deletions

View File

@ -3,8 +3,9 @@
#include "TurnBaseCombatV2.h"
#include "CoreMinimal.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "AIController.h"
#include "Blueprint/UserWidget.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "Components/TextBlock.h"
#include "Components/ProgressBar.h"
#include "GameFramework/Character.h"
@ -24,8 +25,10 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
{
if (Enemy == nullptr) return;
UBlackboardComponent* EnemyBlackboard = Cast<UBlackboardComponent>(Enemy->GetComponentByClass(UBlackboardComponent::StaticClass()));
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);

View File

@ -8,7 +8,7 @@ public class the_twilight_abyss : ModuleRules
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara" });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Niagara", "AIModule" });
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

View File

@ -9,6 +9,7 @@ public class the_twilight_abyssEditorTarget : TargetRules
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;
ExtraModuleNames.AddRange( new string[] { "the_twilight_abyss" } );
}
}