Updated Party NPCs to Run Away When Enemies Become Hostile

This commit is contained in:
Rafal Swierczek 2024-04-11 20:44:11 +01:00
parent c65c963cc5
commit 5086aa3877
6 changed files with 12 additions and 8 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4b7711721e4ac69734e98b538d8a4120895d5c9786407711f0065dc8a9bf7530
size 98194
oid sha256:e6909a8e2d971ff0b975143ab77859dbb51346172a5134d9dd22005a44ab5e06
size 111927

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0268f573172a85cbed0ebff602394fe7429e5c00743043ae0c95a49bdc0ba94e
size 1017973
oid sha256:cd5075433024da9604f0800478f522c559be465de8fdbbc963f046200f0e600c
size 1017945

View File

@ -71,6 +71,7 @@ void AEnemyCharacter::SetHostilityLevel(const EHostilityLevel NewHostilityLevel)
if (NewHostilityLevel == EHostilityLevel::Hostile)
{
if (!IsValid(GetController())) return;
BecameHostile.Broadcast();
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsBool("IsHostile", true);
}
HostilityLevel = NewHostilityLevel;

View File

@ -17,6 +17,7 @@ enum class EHostilityLevel : uint8
Hostile UMETA(DisplayName = "Hostile")
};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FEnemyDied);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBecameHostile);
UCLASS()
class ENDLESSVENDETTA_API AEnemyCharacter : public AAICharacter
@ -32,6 +33,8 @@ public:
EHostilityLevel HostilityLevel = EHostilityLevel::None;
UPROPERTY(BlueprintAssignable)
FEnemyDied EnemyDied;
UPROPERTY(BlueprintAssignable)
FBecameHostile BecameHostile;
protected:
// Called when the game starts or when spawned