Compare commits

...

2 Commits

19 changed files with 102 additions and 4 deletions

View File

@ -0,0 +1,44 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "AI/BehaviorTreeNodes/T_TryGetRandomPatrolPoint.h"
#include "AIController.h"
#include "NavigationData.h"
#include "NavigationSystem.h"
#include "BehaviorTree/BlackboardComponent.h"
UT_TryGetRandomPatrolPoint::UT_TryGetRandomPatrolPoint()
{
Radius = 500.f;
QueryExtent = {300.f, 300.f, 300.f};
}
EBTNodeResult::Type UT_TryGetRandomPatrolPoint::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
EBTNodeResult::Type result = Super::ExecuteTask(OwnerComp, NodeMemory);
if(result == EBTNodeResult::Failed)
return EBTNodeResult::Failed;
APawn* ControllingPawn = OwnerComp.GetAIOwner()->GetPawn();
if(ControllingPawn == nullptr)
return EBTNodeResult::Failed;
UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetNavigationSystem(ControllingPawn->GetWorld());
if(NavSystem == nullptr)
return EBTNodeResult::Failed;
FVector CurLocation = ControllingPawn->GetActorLocation();
FNavLocation RandomLocation, ProjectLocation;
if(NavSystem->GetRandomReachablePointInRadius(CurLocation, Radius, RandomLocation))
{
if(NavSystem->ProjectPointToNavigation(RandomLocation.Location, ProjectLocation, QueryExtent))
OwnerComp.GetBlackboardComponent()->SetValueAsVector(BlackboardKey_TargetLocation.SelectedKeyName, ProjectLocation.Location);
else
return EBTNodeResult::Failed;
}
else
return EBTNodeResult::Failed;
return EBTNodeResult::Succeeded;
}

View File

@ -0,0 +1,30 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTTaskNode.h"
#include "T_TryGetRandomPatrolPoint.generated.h"
/**
*
*/
UCLASS()
class D1_API UT_TryGetRandomPatrolPoint : public UBTTaskNode
{
GENERATED_BODY()
public:
UT_TryGetRandomPatrolPoint();
public:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="BlackBoard", meta=(AllowPrivateAccess="true"))
FBlackboardKeySelector BlackboardKey_TargetLocation;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="BlackBoard", meta=(AllowPrivateAccess="true"))
float Radius;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="BlackBoard", meta=(AllowPrivateAccess="true"))
FVector QueryExtent;
};

View File

@ -61,8 +61,8 @@ void AGruntlingEnemy::BeginPlay()
HealthBarComponent->SetWidget(HealthBarRef); HealthBarComponent->SetWidget(HealthBarRef);
} }
if(IsValid(IntroAnimMontage)) //if(IsValid(IntroAnimMontage)) //Intro가 필요하지 않음. 필요할 경우 주석해제
PlayAnimMontage(IntroAnimMontage); // PlayAnimMontage(IntroAnimMontage);
} }
void AGruntlingEnemy::OnTargeted(bool bIsTargeted) void AGruntlingEnemy::OnTargeted(bool bIsTargeted)

View File

@ -42,6 +42,8 @@ ABaseWeapon::ABaseWeapon()
ActionDamageMultiplier.Add(FCombatGameplayTags::Get().Character_Action_Attack_ChargedAttack, 1.5f); ActionDamageMultiplier.Add(FCombatGameplayTags::Get().Character_Action_Attack_ChargedAttack, 1.5f);
ActionDamageMultiplier.Add(FCombatGameplayTags::Get().Character_Action_Attack_FallingAttack, 1.2f); ActionDamageMultiplier.Add(FCombatGameplayTags::Get().Character_Action_Attack_FallingAttack, 1.2f);
ActionDamageMultiplier.Add(FCombatGameplayTags::Get().Character_Action_Attack_SprintAttack, 1.2f); ActionDamageMultiplier.Add(FCombatGameplayTags::Get().Character_Action_Attack_SprintAttack, 1.2f);
bCanBlock = true;
} }
void ABaseWeapon::OnEquipped() void ABaseWeapon::OnEquipped()

View File

@ -46,6 +46,8 @@ public:
public: public:
virtual TArray<UAnimMontage*> GetActionMontage(FGameplayTag characterAction); virtual TArray<UAnimMontage*> GetActionMontage(FGameplayTag characterAction);
public:
FORCEINLINE bool GetCanBlock() { return bCanBlock; }
protected: protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
FName HandSocketName; FName HandSocketName;
@ -53,6 +55,8 @@ protected:
ECombatType CombatType; ECombatType CombatType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
TSubclassOf<UDamageType> DamageTypeClass; TSubclassOf<UDamageType> DamageTypeClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
bool bCanBlock;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components") UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components")
TObjectPtr<class UCombatComponent> CombatComponent; TObjectPtr<class UCombatComponent> CombatComponent;

View File

@ -23,6 +23,7 @@ void UCombatAnimInstance::NativeInitializeAnimation()
{ {
CombatComponent->OnCombatToggled.AddUObject(this, &UCombatAnimInstance::UpdateCombatEnabled); CombatComponent->OnCombatToggled.AddUObject(this, &UCombatAnimInstance::UpdateCombatEnabled);
CombatComponent->OnBlockingSet.AddUObject(this, &UCombatAnimInstance::OnBlockingSet_Event); CombatComponent->OnBlockingSet.AddUObject(this, &UCombatAnimInstance::OnBlockingSet_Event);
CombatComponent->OnShieldEquippedSet.AddUObject(this, &UCombatAnimInstance::OnShieldSet_Event);
} }
} }
} }
@ -59,3 +60,8 @@ void UCombatAnimInstance::OnBlockingSet_Event(bool bIsBlock)
{ {
IsBlocking = bIsBlock; IsBlocking = bIsBlock;
} }
void UCombatAnimInstance::OnShieldSet_Event(bool bIsShieldEquipped)
{
IsShieldEquipped = bIsShieldEquipped;
}

View File

@ -26,6 +26,7 @@ public:
public: //Delegate public: //Delegate
void UpdateCombatEnabled(bool combatEnabled); void UpdateCombatEnabled(bool combatEnabled);
void OnBlockingSet_Event(bool bIsBlock); void OnBlockingSet_Event(bool bIsBlock);
void OnShieldSet_Event(bool bIsShieldEquipped);
private: private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="References", meta=(AllowPrivateAccess="true")) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="References", meta=(AllowPrivateAccess="true"))
@ -51,4 +52,6 @@ private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true")) UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
bool IsBlocking; bool IsBlocking;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
bool IsShieldEquipped;
}; };

View File

@ -1021,7 +1021,10 @@ bool ACombatPlayerCharacter::CanPerformBlock()
ReturnValue &= !StateManagerComponent->IsCurrentStateEqualToAny(inputContainer); ReturnValue &= !StateManagerComponent->IsCurrentStateEqualToAny(inputContainer);
ReturnValue &= CombatComponent->GetCombatEnabled(); ReturnValue &= CombatComponent->GetCombatEnabled();
ReturnValue &= CombatComponent->GetShieldEquipped(); if(!IsValid(CombatComponent->GetMainWeapon()))
ReturnValue &= false;
else
ReturnValue &= CombatComponent->GetMainWeapon()->GetCanBlock();
ReturnValue &= bIsBlockPressed; //Block Key를 눌렀는가? ReturnValue &= bIsBlockPressed; //Block Key를 눌렀는가?
return ReturnValue; return ReturnValue;

View File

@ -8,6 +8,7 @@
DECLARE_MULTICAST_DELEGATE_OneParam(FOnCombatToggled, bool); DECLARE_MULTICAST_DELEGATE_OneParam(FOnCombatToggled, bool);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnBlockingSet, bool); DECLARE_MULTICAST_DELEGATE_OneParam(FOnBlockingSet, bool);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnShieldEquippedSet, bool);
class ABaseWeapon; class ABaseWeapon;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
@ -40,7 +41,11 @@ public:
void SetBlockingState(bool enableBlocking); void SetBlockingState(bool enableBlocking);
FORCEINLINE bool GetIsBlocking() { return bIsBlocking; } FORCEINLINE bool GetIsBlocking() { return bIsBlocking; }
FORCEINLINE void SetShieldEquipped(bool isEquipped) { bIsShieldEquipped = isEquipped; } FORCEINLINE void SetShieldEquipped(bool isEquipped)
{
bIsShieldEquipped = isEquipped;
OnShieldEquippedSet.Broadcast(isEquipped);
}
FORCEINLINE bool GetShieldEquipped() { return bIsShieldEquipped; } FORCEINLINE bool GetShieldEquipped() { return bIsShieldEquipped; }
private: private:
@ -63,4 +68,5 @@ private:
public: //Delegate public: //Delegate
FOnCombatToggled OnCombatToggled; FOnCombatToggled OnCombatToggled;
FOnBlockingSet OnBlockingSet; FOnBlockingSet OnBlockingSet;
FOnShieldEquippedSet OnShieldEquippedSet;
}; };