diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 2840bcbf..13d7f08f 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -134,4 +134,6 @@ ManualIPAddress= +PropertyRedirects=(OldName="/Script/D1.CombatCharacter.ToogleLockOnAction",NewName="/Script/D1.CombatCharacter.ToggleLockOnAction") +ClassRedirects=(OldName="/Script/D1.UI_LockOnComponent",NewName="/Script/D1.LockOnWidgetComponent") +PropertyRedirects=(OldName="/Script/D1.MasterAI.TargetingWidget",NewName="/Script/D1.MasterAI.TargetingWidgetComponent") -+PropertyRedirects=(OldName="/Script/D1.HumanoidEnemy.HealthBar",NewName="/Script/D1.HumanoidEnemy.HealthBarComponent") \ No newline at end of file ++PropertyRedirects=(OldName="/Script/D1.HumanoidEnemy.HealthBar",NewName="/Script/D1.HumanoidEnemy.HealthBarComponent") ++PropertyRedirects=(OldName="/Script/D1.T_FindNextPatrolPoint.TargetLocation",NewName="/Script/D1.T_FindNextPatrolPoint.BlackboardKey_TargetLocation") ++PropertyRedirects=(OldName="/Script/D1.T_FindNextPatrolPoint.PatrolIndex",NewName="/Script/D1.T_FindNextPatrolPoint.BlackboardKey_PatrolIndex") \ No newline at end of file diff --git a/Content/Characters/Mannequins/Animations/Manny/BS_MM_IdleRun.uasset b/Content/Characters/Mannequins/Animations/Manny/BS_MM_IdleRun.uasset new file mode 100644 index 00000000..a3519ffc Binary files /dev/null and b/Content/Characters/Mannequins/Animations/Manny/BS_MM_IdleRun.uasset differ diff --git a/Content/CombatSystem/Blueprints/AI/BB_Base.uasset b/Content/CombatSystem/Blueprints/AI/BB_Base.uasset index d8ab959a..ae8141ea 100644 Binary files a/Content/CombatSystem/Blueprints/AI/BB_Base.uasset and b/Content/CombatSystem/Blueprints/AI/BB_Base.uasset differ diff --git a/Content/CombatSystem/Blueprints/AI/BP_ExampleEnemy.uasset b/Content/CombatSystem/Blueprints/AI/BP_ExampleEnemy.uasset index 7076610d..908e286e 100644 Binary files a/Content/CombatSystem/Blueprints/AI/BP_ExampleEnemy.uasset and b/Content/CombatSystem/Blueprints/AI/BP_ExampleEnemy.uasset differ diff --git a/Content/CombatSystem/Blueprints/AI/BP_HumanoidEnemy.uasset b/Content/CombatSystem/Blueprints/AI/BP_HumanoidEnemy.uasset index fd20098a..9019e1a6 100644 Binary files a/Content/CombatSystem/Blueprints/AI/BP_HumanoidEnemy.uasset and b/Content/CombatSystem/Blueprints/AI/BP_HumanoidEnemy.uasset differ diff --git a/Content/CombatSystem/Blueprints/AI/EnemyManny/ABP_EnemyManny.uasset b/Content/CombatSystem/Blueprints/AI/EnemyManny/ABP_EnemyManny.uasset new file mode 100644 index 00000000..fb1a9650 Binary files /dev/null and b/Content/CombatSystem/Blueprints/AI/EnemyManny/ABP_EnemyManny.uasset differ diff --git a/Content/__ExternalActors__/Maps/ThirdPersonMap/0/9Z/OBHQTF8IORVT433VKL992W.uasset b/Content/__ExternalActors__/Maps/ThirdPersonMap/0/9Z/OBHQTF8IORVT433VKL992W.uasset index de1361fb..55efffe6 100644 Binary files a/Content/__ExternalActors__/Maps/ThirdPersonMap/0/9Z/OBHQTF8IORVT433VKL992W.uasset and b/Content/__ExternalActors__/Maps/ThirdPersonMap/0/9Z/OBHQTF8IORVT433VKL992W.uasset differ diff --git a/Content/__ExternalActors__/Maps/ThirdPersonMap/5/OY/YL0YUUS0185V2XTXOV7HZM.uasset b/Content/__ExternalActors__/Maps/ThirdPersonMap/5/OY/YL0YUUS0185V2XTXOV7HZM.uasset new file mode 100644 index 00000000..e404cfb2 Binary files /dev/null and b/Content/__ExternalActors__/Maps/ThirdPersonMap/5/OY/YL0YUUS0185V2XTXOV7HZM.uasset differ diff --git a/Content/__ExternalActors__/Maps/ThirdPersonMap/6/AC/G7GS1SXVWEW7XPA23H8VCS.uasset b/Content/__ExternalActors__/Maps/ThirdPersonMap/6/AC/G7GS1SXVWEW7XPA23H8VCS.uasset new file mode 100644 index 00000000..02149ad5 Binary files /dev/null and b/Content/__ExternalActors__/Maps/ThirdPersonMap/6/AC/G7GS1SXVWEW7XPA23H8VCS.uasset differ diff --git a/Content/__ExternalActors__/Maps/ThirdPersonMap/7/2I/J4LGKN2OBPVN6O1HTZIT8S.uasset b/Content/__ExternalActors__/Maps/ThirdPersonMap/7/2I/J4LGKN2OBPVN6O1HTZIT8S.uasset new file mode 100644 index 00000000..217434be Binary files /dev/null and b/Content/__ExternalActors__/Maps/ThirdPersonMap/7/2I/J4LGKN2OBPVN6O1HTZIT8S.uasset differ diff --git a/Content/__ExternalActors__/Maps/ThirdPersonMap/D/2D/BLDK57NVWLW7KMI3WWCP0L.uasset b/Content/__ExternalActors__/Maps/ThirdPersonMap/D/2D/BLDK57NVWLW7KMI3WWCP0L.uasset new file mode 100644 index 00000000..c3b902e1 Binary files /dev/null and b/Content/__ExternalActors__/Maps/ThirdPersonMap/D/2D/BLDK57NVWLW7KMI3WWCP0L.uasset differ diff --git a/Content/__ExternalActors__/Maps/ThirdPersonMap/E/FN/VGDXV9D7OGOFPO0UHRYU1H.uasset b/Content/__ExternalActors__/Maps/ThirdPersonMap/E/FN/VGDXV9D7OGOFPO0UHRYU1H.uasset new file mode 100644 index 00000000..77d4ac67 Binary files /dev/null and b/Content/__ExternalActors__/Maps/ThirdPersonMap/E/FN/VGDXV9D7OGOFPO0UHRYU1H.uasset differ diff --git a/Content/__ExternalActors__/Maps/ThirdPersonMap/E/SI/2GNUG7N8YL1CV9XGXC4B5N.uasset b/Content/__ExternalActors__/Maps/ThirdPersonMap/E/SI/2GNUG7N8YL1CV9XGXC4B5N.uasset index 21265e92..3e3bd614 100644 Binary files a/Content/__ExternalActors__/Maps/ThirdPersonMap/E/SI/2GNUG7N8YL1CV9XGXC4B5N.uasset and b/Content/__ExternalActors__/Maps/ThirdPersonMap/E/SI/2GNUG7N8YL1CV9XGXC4B5N.uasset differ diff --git a/Source/D1/AI/MasterAI.h b/Source/D1/AI/MasterAI.h index 49fe241d..d4048805 100644 --- a/Source/D1/AI/MasterAI.h +++ b/Source/D1/AI/MasterAI.h @@ -9,6 +9,7 @@ #include "Components/StatsComponent.h" #include "Components/TargetingComponent.h" #include "Definitions/GameEnums.h" +#include "Engine/TargetPoint.h" #include "Interface/TargetingInterface.h" #include "MasterAI.generated.h" @@ -99,6 +100,7 @@ protected: //Check Func public: //Getter FORCEINLINE class UBehaviorTree* GetBeHaviorTree() {return BehaviorTree;} + FORCEINLINE const TArray& GetPatrolPoints() { return PatrolPoints; } private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization", meta=(AllowPrivateAccess="true")) @@ -137,6 +139,9 @@ private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage|Actions", meta = (AllowPrivateAccess = "true")) TObjectPtr ExitCombat; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Patrol", meta = (AllowPrivateAccess = "true")) + TArray> PatrolPoints; + private: FTimerHandle StaminaTimerHandle; diff --git a/Source/D1/AI/T_FindNextPatrolPoint.cpp b/Source/D1/AI/T_FindNextPatrolPoint.cpp new file mode 100644 index 00000000..9d44531e --- /dev/null +++ b/Source/D1/AI/T_FindNextPatrolPoint.cpp @@ -0,0 +1,96 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "AI/T_FindNextPatrolPoint.h" +#include "AIController.h" +#include "MasterAI.h" +#include "NavigationSystem.h" +#include "BehaviorTree/BlackboardComponent.h" + + +UT_FindNextPatrolPoint::UT_FindNextPatrolPoint() +{ + bShouldReverse = false; + bShouldLoop = true; +} + +EBTNodeResult::Type UT_FindNextPatrolPoint::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; + AMasterAI* masterAI = Cast(ControllingPawn); + if(masterAI == nullptr) + return EBTNodeResult::Failed; + ControlledMasterAI = masterAI; + BlackboardComponent = OwnerComp.GetBlackboardComponent(); + + if(SetPathLocation()) + { + if(bShouldReverse) + DecrementPathIndex(); + else + IncrementPathIndex(); + } + else + return EBTNodeResult::Failed; + + return EBTNodeResult::Succeeded; +} + +bool UT_FindNextPatrolPoint::SetPathLocation() +{ + if(!IsValid(ControlledMasterAI)) + return false; + + int PatrolIndex = BlackboardComponent->GetValueAsInt(BlackboardKey_PatrolIndex.SelectedKeyName); + if(!ControlledMasterAI->GetPatrolPoints().IsValidIndex(PatrolIndex)) + return false; + + UNavigationSystemV1* navSystem = UNavigationSystemV1::GetNavigationSystem(GetWorld()); + if(navSystem == nullptr) + return false; + FVector targetLocation = ControlledMasterAI->GetPatrolPoints()[PatrolIndex]->GetActorLocation(); + FNavLocation outLocation; + navSystem->ProjectPointToNavigation(targetLocation, outLocation); + BlackboardComponent->SetValueAsVector(BlackboardKey_TargetLocation.SelectedKeyName, outLocation.Location); + + return true; +} + +void UT_FindNextPatrolPoint::IncrementPathIndex() +{ + if(!IsValid(ControlledMasterAI)) + return; + + int PatrolIndex = BlackboardComponent->GetValueAsInt(BlackboardKey_PatrolIndex.SelectedKeyName) + 1; + if(ControlledMasterAI->GetPatrolPoints().Num() > PatrolIndex) + BlackboardComponent->SetValueAsInt(BlackboardKey_PatrolIndex.SelectedKeyName, PatrolIndex); + else + { + if(bShouldLoop) + { + bShouldReverse = true; + DecrementPathIndex(); + } + } +} + +void UT_FindNextPatrolPoint::DecrementPathIndex() +{ + if(!IsValid(ControlledMasterAI)) + return; + + int PatrolIndex = BlackboardComponent->GetValueAsInt(BlackboardKey_PatrolIndex.SelectedKeyName) - 1; + if(PatrolIndex >= 0) + BlackboardComponent->SetValueAsInt(BlackboardKey_PatrolIndex.SelectedKeyName, PatrolIndex); + else + { + bShouldReverse = false; + IncrementPathIndex(); + } +} diff --git a/Source/D1/AI/T_FindNextPatrolPoint.h b/Source/D1/AI/T_FindNextPatrolPoint.h new file mode 100644 index 00000000..da3e50cf --- /dev/null +++ b/Source/D1/AI/T_FindNextPatrolPoint.h @@ -0,0 +1,37 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BehaviorTree/BTTaskNode.h" +#include "T_FindNextPatrolPoint.generated.h" + +/** + * + */ +UCLASS() +class D1_API UT_FindNextPatrolPoint : public UBTTaskNode +{ + GENERATED_BODY() + +public: + UT_FindNextPatrolPoint(); + virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; + +public: + bool SetPathLocation(); + void IncrementPathIndex(); + void DecrementPathIndex(); + +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="BlackBoard", meta=(AllowPrivateAccess="true")) + FBlackboardKeySelector BlackboardKey_TargetLocation; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="BlackBoard", meta=(AllowPrivateAccess="true")) + FBlackboardKeySelector BlackboardKey_PatrolIndex; +private: + TObjectPtr ControlledMasterAI; + TObjectPtr BlackboardComponent; + bool bShouldReverse; + bool bShouldLoop; +}; diff --git a/Source/D1/AI/T_SetMovementSpeed.cpp b/Source/D1/AI/T_SetMovementSpeed.cpp new file mode 100644 index 00000000..557ab1a4 --- /dev/null +++ b/Source/D1/AI/T_SetMovementSpeed.cpp @@ -0,0 +1,32 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "AI/T_SetMovementSpeed.h" +#include "GameFramework/CharacterMovementComponent.h" +#include "AIController.h" + + +UT_SetMovementSpeed::UT_SetMovementSpeed() +{ + MovementSpeed = 400.f; + +} + +EBTNodeResult::Type UT_SetMovementSpeed::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; + UCharacterMovementComponent* MovementComponent = ControllingPawn->GetComponentByClass(); + if(MovementComponent == nullptr) + return EBTNodeResult::Failed; + + MovementComponent->MaxWalkSpeed = MovementSpeed; + return EBTNodeResult::Succeeded; +} + diff --git a/Source/D1/AI/T_SetMovementSpeed.h b/Source/D1/AI/T_SetMovementSpeed.h new file mode 100644 index 00000000..cef43074 --- /dev/null +++ b/Source/D1/AI/T_SetMovementSpeed.h @@ -0,0 +1,23 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BehaviorTree/BTTaskNode.h" +#include "T_SetMovementSpeed.generated.h" + +/** + * + */ +UCLASS() +class D1_API UT_SetMovementSpeed : public UBTTaskNode +{ + GENERATED_BODY() + +public: + UT_SetMovementSpeed(); + virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override; +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess="true")) + float MovementSpeed; +}; diff --git a/Source/D1/D1.Build.cs b/Source/D1/D1.Build.cs index a05893db..86b686ba 100644 --- a/Source/D1/D1.Build.cs +++ b/Source/D1/D1.Build.cs @@ -11,6 +11,7 @@ public class D1 : ModuleRules PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput", "AnimGraphRuntime", "GameplayTags", "Niagara", + "AIModule", "GameplayTasks", "NavigationSystem" }); PublicIncludePaths.AddRange(new string[] { "D1" });