Update AI for Hostility Levels

This commit is contained in:
Philip W 2024-02-27 17:32:29 +00:00
parent 8e727e4a06
commit 52229f8975
86 changed files with 272 additions and 22 deletions

BIN
EndlessVendetta/Content/AI/EQS/EQSB_Enemy.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/AI/EQS/EQSB_Player.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/AI/EQS/EQS_Test.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
EndlessVendetta/Content/AI/EQS_Test.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
EndlessVendetta/Content/Levels/AITest.umap (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -6,6 +6,7 @@
#include "AIControlHub.h"
#include "AIController.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
class UAISense_Sight;
@ -26,11 +27,8 @@ void AEnemyCharacter::BeginPlay()
void AEnemyCharacter::OnDeath()
{
Super::OnDeath();
DelegatedControlHub->AlertLevelEvent.Remove(AlertLevelDelegateHandle);
DelegatedControlHub->HuntPlayerEvent.Remove(HuntPlayerDelegateHandle);
AlertLevelDelegateHandle.Reset();
HuntPlayerDelegateHandle.Reset();
DelegatedControlHub->RemoveEnemyActor(this);
}
// Called every frame
@ -61,6 +59,26 @@ void AEnemyCharacter::SetLocalAlertLevel(int NewAlertLevel) const
DelegatedControlHub->SetAlertLevel(NewAlertLevel);
}
void AEnemyCharacter::SetHostilityLevel(const EHostilityLevel NewHostilityLevel)
{
if (NewHostilityLevel == EHostilityLevel::Hostile)
{
if (!IsValid(GetController())) return;
Cast<AAIController>(GetController())->GetBlackboardComponent()->SetValueAsBool("IsHostile", true);
}
HostilityLevel = NewHostilityLevel;
}
float AEnemyCharacter::TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{
if (Cast<AEndlessVendettaCharacter>(EventInstigator->GetPawn()))
{
SetHostilityLevel(EHostilityLevel::Hostile);
HuntPlayer(Cast<AEndlessVendettaCharacter>(EventInstigator->GetPawn())->GetActorLocation());
}
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}
void AEnemyCharacter::EquipWeapon_Implementation()
{
}

View File

@ -8,6 +8,15 @@
#include "GameFramework/Character.h"
#include "EnemyCharacter.generated.h"
UENUM(BlueprintType)
enum class EHostilityLevel : uint8
{
None UMETA(DisplayName = "None"),
Neutral UMETA(DisplayName = "Neutral"),
Warning UMETA(DisplayName = "Warning"),
Hostile UMETA(DisplayName = "Hostile")
};
UCLASS()
class ENDLESSVENDETTA_API AEnemyCharacter : public AAICharacter
{
@ -18,6 +27,8 @@ public:
AEnemyCharacter();
UPROPERTY(BlueprintReadWrite)
bool WeaponRaised = false;
UPROPERTY(BlueprintReadOnly)
EHostilityLevel HostilityLevel = EHostilityLevel::None;
protected:
// Called when the game starts or when spawned
@ -31,7 +42,10 @@ public:
UFUNCTION(BlueprintCallable)
void SubscribeToGroupAIEvents(class AAIControlHub* ControlHub);
void SetLocalAlertLevel(int NewAlertLevel) const;
UFUNCTION(BlueprintCallable)
void SetHostilityLevel(EHostilityLevel NewHostilityLevel);
virtual float TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
//Animation Blueprint Triggers
UFUNCTION(BlueprintNativeEvent)
void EquipWeapon();

View File

@ -9,7 +9,6 @@
#include "Components/ArrowComponent.h"
#include "GadgetSystem/GadgetManager.h"
#include "Inventory/InventoryComponent.h"
#include "Pawn/VICharacter.h"
#include "SpaceShip/SpaceShip.h"
#include "EndlessVendettaCharacter.generated.h"