Update AI, Character to Detect If Player is In Combat
This commit is contained in:
parent
c0df68596b
commit
6e056a94f2
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BB_BasicEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/AI/Enemy/Basic/BT_BasicEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Combat_start__808s_.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Combat_start__808s_.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Drums.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Drums.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Guitar.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Guitar.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Hats_and_clap.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Hats_and_clap.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Sound_effect.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/Sound_effect.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/combat_Continuous.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Audio/Music/Combat_track_1/combat_Continuous.uasset
(Stored with Git LFS)
Binary file not shown.
@ -10,6 +10,9 @@
|
|||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
#include <EndlessVendetta/EndlessVendettaGameMode.h>
|
#include <EndlessVendetta/EndlessVendettaGameMode.h>
|
||||||
|
|
||||||
|
#include "AI_EnemyController.h"
|
||||||
|
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||||
|
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
AAICharacter::AAICharacter()
|
AAICharacter::AAICharacter()
|
||||||
@ -73,8 +76,13 @@ void AAICharacter::SetupStimuliSourceComponent()
|
|||||||
|
|
||||||
void AAICharacter::OnDeath()
|
void AAICharacter::OnDeath()
|
||||||
{
|
{
|
||||||
/*const AAI_EnemyController* AIController = Cast<AAI_EnemyController>(GetController());
|
AAI_EnemyController* AIController = Cast<AAI_EnemyController>(GetController());
|
||||||
AIController->GetBrainComponent()->StopLogic(" is dead");*/
|
if (UBlackboardComponent* Blackboard = AIController->GetBlackboardComponent(); Blackboard->GetValueAsBool("SeenWithHostilities"))
|
||||||
|
{
|
||||||
|
AEndlessVendettaCharacter* PlayerCharacter = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
|
||||||
|
PlayerCharacter->DecrementSeenHostileCount();
|
||||||
|
}
|
||||||
|
|
||||||
this->Tags.Add(FName("Dead"));
|
this->Tags.Add(FName("Dead"));
|
||||||
//Ragdoll
|
//Ragdoll
|
||||||
DetachFromControllerPendingDestroy();
|
DetachFromControllerPendingDestroy();
|
||||||
|
@ -105,17 +105,19 @@ void AAI_EnemyController::OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus c
|
|||||||
{
|
{
|
||||||
GetBlackboardComponent()->SetValueAsObject("TargetPlayer", Actor);
|
GetBlackboardComponent()->SetValueAsObject("TargetPlayer", Actor);
|
||||||
GetBlackboardComponent()->SetValueAsVector("TargetLocation", Stimulus.StimulusLocation);
|
GetBlackboardComponent()->SetValueAsVector("TargetLocation", Stimulus.StimulusLocation);
|
||||||
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", true);
|
|
||||||
if (PlayerCharacter->CurrentOverlayState != EOverlayState::Default)
|
if (PlayerCharacter->CurrentOverlayState != EOverlayState::Default)
|
||||||
{
|
{
|
||||||
GetBlackboardComponent()->SetValueAsBool("IsHostile", true);
|
GetBlackboardComponent()->SetValueAsBool("IsHostile", true);
|
||||||
}
|
}
|
||||||
|
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", true);
|
||||||
}
|
}
|
||||||
else if (!Stimulus.WasSuccessfullySensed() && Stimulus.Type == SightConfig->GetSenseID())
|
else if (!Stimulus.WasSuccessfullySensed() && Stimulus.Type == SightConfig->GetSenseID())
|
||||||
{
|
{
|
||||||
GetBlackboardComponent()->ClearValue("TargetActor");
|
GetBlackboardComponent()->ClearValue("TargetActor");
|
||||||
GetBlackboardComponent()->ClearValue("TargetLocation");
|
GetBlackboardComponent()->ClearValue("TargetLocation");
|
||||||
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", false);
|
GetBlackboardComponent()->SetValueAsBool("CanSeePlayer", false);
|
||||||
|
GetBlackboardComponent()->SetValueAsBool("SeenWithHostilities", false);
|
||||||
|
PlayerCharacter->DecrementSeenHostileCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Stimulus.WasSuccessfullySensed() && Stimulus.Type == HearingConfig->GetSenseID())
|
if (Stimulus.WasSuccessfullySensed() && Stimulus.Type == HearingConfig->GetSenseID())
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "BTTask_SetSeenWithHostilities.h"
|
||||||
|
|
||||||
|
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||||
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
|
|
||||||
|
UBTTask_SetSeenWithHostilities::UBTTask_SetSeenWithHostilities()
|
||||||
|
{
|
||||||
|
NodeName = "Set Seen With Hostilities";
|
||||||
|
}
|
||||||
|
|
||||||
|
EBTNodeResult::Type UBTTask_SetSeenWithHostilities::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
|
||||||
|
{
|
||||||
|
if (AEndlessVendettaCharacter* Player = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
|
||||||
|
{
|
||||||
|
if (UBlackboardComponent* const Blackboard = OwnerComp.GetBlackboardComponent())
|
||||||
|
{
|
||||||
|
if (!Blackboard->GetValueAsBool("SeenWithHostilities") && Blackboard->GetValueAsBool("IsHostile"))
|
||||||
|
{
|
||||||
|
Blackboard->SetValueAsBool("SeenWithHostilities", true);
|
||||||
|
Player->IncrementSeenHostileCount();
|
||||||
|
}
|
||||||
|
FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
|
||||||
|
return EBTNodeResult::Succeeded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EBTNodeResult::Failed;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BehaviorTree/Tasks/BTTask_BlackboardBase.h"
|
||||||
|
#include "BTTask_SetSeenWithHostilities.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class ENDLESSVENDETTA_API UBTTask_SetSeenWithHostilities : public UBTTask_BlackboardBase
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UBTTask_SetSeenWithHostilities();
|
||||||
|
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
|
||||||
|
};
|
@ -53,6 +53,30 @@ void AEndlessVendettaCharacter::DecrementRestrictedBoundsCount()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::IncrementSeenHostileCount()
|
||||||
|
{
|
||||||
|
SeenHostileCount++;
|
||||||
|
if (GetWorld()->GetTimerManager().IsTimerActive(NotInCombatTimerHandle))
|
||||||
|
{
|
||||||
|
GetWorld()->GetTimerManager().ClearTimer(NotInCombatTimerHandle);
|
||||||
|
}
|
||||||
|
bIsInCombat = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::DecrementSeenHostileCount()
|
||||||
|
{
|
||||||
|
SeenHostileCount--;
|
||||||
|
if (SeenHostileCount <= 0)
|
||||||
|
{
|
||||||
|
if (GetWorld()->GetTimerManager().IsTimerActive(NotInCombatTimerHandle))
|
||||||
|
{
|
||||||
|
GetWorld()->GetTimerManager().ClearTimer(NotInCombatTimerHandle);
|
||||||
|
}
|
||||||
|
GetWorld()->GetTimerManager().SetTimer(NotInCombatTimerHandle, this, &AEndlessVendettaCharacter::NotInCombat,
|
||||||
|
5.0f, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::ReloadAnimationComplete()
|
void AEndlessVendettaCharacter::ReloadAnimationComplete()
|
||||||
{
|
{
|
||||||
if (IsValid(PrimaryWeapon))
|
if (IsValid(PrimaryWeapon))
|
||||||
@ -189,6 +213,12 @@ void AEndlessVendettaCharacter::Heal(const float Amount)
|
|||||||
CurrentHealth = FMath::Clamp(Amount + CurrentHealth, 0, MaxHealth);
|
CurrentHealth = FMath::Clamp(Amount + CurrentHealth, 0, MaxHealth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::NotInCombat()
|
||||||
|
{
|
||||||
|
bIsInCombat = false;
|
||||||
|
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("Not In Combat"));
|
||||||
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::WeaponPickUpSystem()
|
void AEndlessVendettaCharacter::WeaponPickUpSystem()
|
||||||
{
|
{
|
||||||
FHitResult OutHit;
|
FHitResult OutHit;
|
||||||
|
@ -163,10 +163,16 @@ public:
|
|||||||
bool bIsInDialogue = false;
|
bool bIsInDialogue = false;
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
||||||
bool bIsInRestrictedArea = false;
|
bool bIsInRestrictedArea = false;
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Stats")
|
||||||
|
bool bIsInCombat = false;
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void IncrementRestrictedBoundsCount();
|
void IncrementRestrictedBoundsCount();
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void DecrementRestrictedBoundsCount();
|
void DecrementRestrictedBoundsCount();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void IncrementSeenHostileCount();
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void DecrementSeenHostileCount();
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStartReload);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStartReload);
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "Weapon")
|
UPROPERTY(BlueprintAssignable, Category = "Weapon")
|
||||||
@ -214,6 +220,11 @@ protected:
|
|||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
int RestrictedBoundsCount = 0;
|
int RestrictedBoundsCount = 0;
|
||||||
|
UPROPERTY()
|
||||||
|
int SeenHostileCount = 0;
|
||||||
|
UPROPERTY()
|
||||||
|
FTimerHandle NotInCombatTimerHandle;
|
||||||
|
void NotInCombat();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AGadgetManager* GadgetManager;
|
AGadgetManager* GadgetManager;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user