Compare commits
2 Commits
8603f2421b
...
6a30ddae07
Author | SHA1 | Date |
---|---|---|
baz | 6a30ddae07 | |
baz | cc21d38a0f |
BIN
Content/Enemy/BT_Attacking_State.uasset (Stored with Git LFS)
BIN
Content/Enemy/BT_Attacking_State.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/BT_Find_Cover.uasset (Stored with Git LFS)
BIN
Content/Enemy/BT_Find_Cover.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/EQS/AttackTarget.uasset (Stored with Git LFS)
BIN
Content/Enemy/EQS/AttackTarget.uasset (Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
Content/Enemy/Worker/AIC_Worker.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/AIC_Worker.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Worker/BB_Worker.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/BB_Worker.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Worker/BT_Worker.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/BT_Worker.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Worker/C_Worker.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/C_Worker.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Enemy/Worker/PatrolMovementSpeed.uasset (Stored with Git LFS)
BIN
Content/Enemy/Worker/PatrolMovementSpeed.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -0,0 +1,27 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "../Decorators/BTDCanSeeTarget.h"
|
||||||
|
|
||||||
|
#include "AIController.h"
|
||||||
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
|
|
||||||
|
bool UBTDCanSeeTarget::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const
|
||||||
|
{
|
||||||
|
FHitResult HitResult;
|
||||||
|
|
||||||
|
FVector Start = OwnerComp.GetAIOwner()->GetPawn()->GetActorLocation();
|
||||||
|
|
||||||
|
UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent();
|
||||||
|
AActor* TargetActor = Cast<AActor>(BlackboardComponent->GetValueAsObject(TargetActorKey.SelectedKeyName));
|
||||||
|
FVector End = TargetActor->GetActorLocation();
|
||||||
|
|
||||||
|
GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Pawn);
|
||||||
|
|
||||||
|
if (HitResult.GetActor())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BehaviorTree/BTDecorator.h"
|
||||||
|
#include "BTDCanSeeTarget.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API UBTDCanSeeTarget : public UBTDecorator
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Options",
|
||||||
|
Meta = (AllowPrivateAccess = "true", DisplayName = "Target Actor Key"))
|
||||||
|
FBlackboardKeySelector TargetActorKey;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override;
|
||||||
|
};
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "../Decorators/BTDIsHealthBelowThreshold.h"
|
||||||
|
|
||||||
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
|
|
||||||
|
bool UBTDIsHealthBelowThreshold::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const
|
||||||
|
{
|
||||||
|
UBlackboardComponent* BlackboardComponent = OwnerComp.GetBlackboardComponent();
|
||||||
|
float currentHealth = BlackboardComponent->GetValueAsFloat(CurrentHealthKey.SelectedKeyName);
|
||||||
|
|
||||||
|
return currentHealth <= HealthThreshold ? true : false;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BehaviorTree/BTDecorator.h"
|
||||||
|
#include "BTDIsHealthBelowThreshold.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API UBTDIsHealthBelowThreshold : public UBTDecorator
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Options",
|
||||||
|
Meta = (AllowPrivateAccess = "true", DisplayName = "Current Health Key"))
|
||||||
|
FBlackboardKeySelector CurrentHealthKey;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Options",
|
||||||
|
Meta = (AllowPrivateAccess = "true", DisplayName = "Health Threshold"))
|
||||||
|
float HealthThreshold = 25.0f;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const override;
|
||||||
|
};
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "../Decorators/BTDWeaponCooldown.h"
|
||||||
|
|
||||||
|
#include "AIController.h"
|
||||||
|
#include "Nakatomi/EnemyCharacter.h"
|
||||||
|
|
||||||
|
void UBTDWeaponCooldown::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
|
||||||
|
{
|
||||||
|
AEnemyCharacter* EnemyCharacter = Cast<AEnemyCharacter>(OwnerComp.GetAIOwner()->GetPawn());
|
||||||
|
|
||||||
|
if (EnemyCharacter && EnemyCharacter->GetCurrentWeapon())
|
||||||
|
{
|
||||||
|
const float Cooldown = EnemyCharacter->GetCurrentWeapon()->GetWeaponProperties()->WeaponCooldown;
|
||||||
|
if (CoolDownTime != Cooldown)
|
||||||
|
{
|
||||||
|
CoolDownTime = Cooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BehaviorTree/Decorators/BTDecorator_Cooldown.h"
|
||||||
|
#include "BTDWeaponCooldown.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API UBTDWeaponCooldown : public UBTDecorator_Cooldown
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) override;
|
||||||
|
};
|
|
@ -4,6 +4,9 @@
|
||||||
#include "EnemyAIController.h"
|
#include "EnemyAIController.h"
|
||||||
#include "EnemyHealthComponent.h"
|
#include "EnemyHealthComponent.h"
|
||||||
#include "InteractableComponent.h"
|
#include "InteractableComponent.h"
|
||||||
|
#include "BehaviorTree/BehaviorTree.h"
|
||||||
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
|
#include "BehaviorTree/BlackboardData.h"
|
||||||
|
|
||||||
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
||||||
|
|
||||||
|
@ -16,7 +19,7 @@ AEnemyCharacter::AEnemyCharacter(const FObjectInitializer& ObjectInitializer) :
|
||||||
GetHealthComponent()->OnDamaged.BindUFunction(this, "OnDamaged");
|
GetHealthComponent()->OnDamaged.BindUFunction(this, "OnDamaged");
|
||||||
GetHealthComponent()->OnDeath.BindUFunction(this, "OnDeath");
|
GetHealthComponent()->OnDeath.BindUFunction(this, "OnDeath");
|
||||||
GetHealthComponent()->SetMaxHealth(100.0f);
|
GetHealthComponent()->SetMaxHealth(100.0f);
|
||||||
|
|
||||||
this->Tags.Add(FName("Enemy"));
|
this->Tags.Add(FName("Enemy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +57,10 @@ void AEnemyCharacter::WeaponCooldownHandler()
|
||||||
void AEnemyCharacter::BeginPlay()
|
void AEnemyCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
AEnemyAIController* controller = Cast<AEnemyAIController>(GetController());
|
||||||
|
controller->GetBlackboardComponent()->SetValueAsFloat("CurrentHealth", GetHealthComponent()->GetCurrentHealth());
|
||||||
|
GetHealthComponent()->OnDamaged.BindUFunction(this, "OnDamaged");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::PlayOnFireAnimations()
|
void AEnemyCharacter::PlayOnFireAnimations()
|
||||||
|
@ -130,3 +137,12 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEnemyCharacter::OnDamaged()
|
||||||
|
{
|
||||||
|
Super::OnDamaged();
|
||||||
|
|
||||||
|
AEnemyAIController* controller = Cast<AEnemyAIController>(GetController());
|
||||||
|
controller->GetBlackboardComponent()->SetValueAsFloat("CurrentHealth", GetHealthComponent()->GetCurrentHealth());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,4 +55,7 @@ private:
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||||
|
|
||||||
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void OnDamaged() override;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue