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