Update AI, Character to Detect If Being Investigated
This commit is contained in:
parent
6e056a94f2
commit
0b9791086e
@ -117,13 +117,20 @@ void AAI_EnemyController::OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus c
|
|||||||
GetBlackboardComponent()->ClearValue("TargetLocation");
|
GetBlackboardComponent()->ClearValue("TargetLocation");
|
||||||
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", false);
|
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", false);
|
||||||
GetBlackboardComponent()->SetValueAsBool("SeenWithHostilities", false);
|
GetBlackboardComponent()->SetValueAsBool("SeenWithHostilities", false);
|
||||||
PlayerCharacter->DecrementSeenHostileCount();
|
if (!GetBlackboardComponent()->GetValueAsBool("SeenWithHostilities"))
|
||||||
|
{
|
||||||
|
PlayerCharacter->DecrementSeenHostileCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Stimulus.WasSuccessfullySensed() && Stimulus.Type == HearingConfig->GetSenseID())
|
if (Stimulus.WasSuccessfullySensed() && Stimulus.Type == HearingConfig->GetSenseID())
|
||||||
{
|
{
|
||||||
GetBlackboardComponent()->SetValueAsObject("TargetPlayer", Actor);
|
GetBlackboardComponent()->SetValueAsObject("TargetPlayer", Actor);
|
||||||
GetBlackboardComponent()->SetValueAsVector("InvestigationLocation", Stimulus.StimulusLocation);
|
GetBlackboardComponent()->SetValueAsVector("InvestigationLocation", Stimulus.StimulusLocation);
|
||||||
|
if (!GetBlackboardComponent()->GetValueAsBool("IsInvestigating"))
|
||||||
|
{
|
||||||
|
PlayerCharacter->IncrementBeingInvestigatedCount();
|
||||||
|
}
|
||||||
GetBlackboardComponent()->SetValueAsBool("IsInvestigating", true);
|
GetBlackboardComponent()->SetValueAsBool("IsInvestigating", true);
|
||||||
}
|
}
|
||||||
else if (!Stimulus.WasSuccessfullySensed() && Stimulus.Type == HearingConfig->GetSenseID())
|
else if (!Stimulus.WasSuccessfullySensed() && Stimulus.Type == HearingConfig->GetSenseID())
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "BTTask_StopInvestigating.h"
|
#include "BTTask_StopInvestigating.h"
|
||||||
|
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
|
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||||
#include "EndlessVendetta/AI/AI_EnemyController.h"
|
#include "EndlessVendetta/AI/AI_EnemyController.h"
|
||||||
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
||||||
|
|
||||||
@ -18,9 +19,13 @@ EBTNodeResult::Type UBTTask_StopInvestigating::ExecuteTask(UBehaviorTreeComponen
|
|||||||
{
|
{
|
||||||
if (UBlackboardComponent* const BlackboardComponent = OwnerComp.GetBlackboardComponent())
|
if (UBlackboardComponent* const BlackboardComponent = OwnerComp.GetBlackboardComponent())
|
||||||
{
|
{
|
||||||
BlackboardComponent->ClearValue(GetSelectedBlackboardKey());
|
if (AEndlessVendettaCharacter* Player = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
|
||||||
FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
|
{
|
||||||
return EBTNodeResult::Succeeded;
|
BlackboardComponent->ClearValue(GetSelectedBlackboardKey());
|
||||||
|
Player->DecrementBeingInvestigatedCount();
|
||||||
|
FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
|
||||||
|
return EBTNodeResult::Succeeded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EBTNodeResult::Failed;
|
return EBTNodeResult::Failed;
|
||||||
|
@ -60,7 +60,10 @@ void AEndlessVendettaCharacter::IncrementSeenHostileCount()
|
|||||||
{
|
{
|
||||||
GetWorld()->GetTimerManager().ClearTimer(NotInCombatTimerHandle);
|
GetWorld()->GetTimerManager().ClearTimer(NotInCombatTimerHandle);
|
||||||
}
|
}
|
||||||
bIsInCombat = true;
|
if (!bIsInCombat)
|
||||||
|
{
|
||||||
|
bIsInCombat = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::DecrementSeenHostileCount()
|
void AEndlessVendettaCharacter::DecrementSeenHostileCount()
|
||||||
@ -77,6 +80,24 @@ void AEndlessVendettaCharacter::DecrementSeenHostileCount()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::IncrementBeingInvestigatedCount()
|
||||||
|
{
|
||||||
|
BeingInvestigatedCount++;
|
||||||
|
if (!bIsBeingInvestigated)
|
||||||
|
{
|
||||||
|
bIsBeingInvestigated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::DecrementBeingInvestigatedCount()
|
||||||
|
{
|
||||||
|
BeingInvestigatedCount--;
|
||||||
|
if (BeingInvestigatedCount <= 0)
|
||||||
|
{
|
||||||
|
bIsBeingInvestigated = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::ReloadAnimationComplete()
|
void AEndlessVendettaCharacter::ReloadAnimationComplete()
|
||||||
{
|
{
|
||||||
if (IsValid(PrimaryWeapon))
|
if (IsValid(PrimaryWeapon))
|
||||||
@ -216,7 +237,6 @@ void AEndlessVendettaCharacter::Heal(const float Amount)
|
|||||||
void AEndlessVendettaCharacter::NotInCombat()
|
void AEndlessVendettaCharacter::NotInCombat()
|
||||||
{
|
{
|
||||||
bIsInCombat = false;
|
bIsInCombat = false;
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("Not In Combat"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::WeaponPickUpSystem()
|
void AEndlessVendettaCharacter::WeaponPickUpSystem()
|
||||||
|
@ -165,6 +165,9 @@ public:
|
|||||||
bool bIsInRestrictedArea = false;
|
bool bIsInRestrictedArea = false;
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
||||||
bool bIsInCombat = false;
|
bool bIsInCombat = false;
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
||||||
|
bool bIsBeingInvestigated = false;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void IncrementRestrictedBoundsCount();
|
void IncrementRestrictedBoundsCount();
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
@ -173,6 +176,10 @@ public:
|
|||||||
void IncrementSeenHostileCount();
|
void IncrementSeenHostileCount();
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void DecrementSeenHostileCount();
|
void DecrementSeenHostileCount();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void IncrementBeingInvestigatedCount();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void DecrementBeingInvestigatedCount();
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStartReload);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStartReload);
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "Weapon")
|
UPROPERTY(BlueprintAssignable, Category = "Weapon")
|
||||||
@ -223,6 +230,8 @@ protected:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
int SeenHostileCount = 0;
|
int SeenHostileCount = 0;
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
|
int BeingInvestigatedCount = 0;
|
||||||
|
UPROPERTY()
|
||||||
FTimerHandle NotInCombatTimerHandle;
|
FTimerHandle NotInCombatTimerHandle;
|
||||||
void NotInCombat();
|
void NotInCombat();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user