mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-14 03:02:22 +01:00
artificial intelligence
proper *****, work on ai, organize some things
This commit is contained in:
@@ -38,37 +38,67 @@ enum class ENavSystemOverridePolicy : uint8_t
|
||||
|
||||
extern inline void (*NavSystemCleanUpOriginal)(UNavigationSystemV1*, uint8) = nullptr;
|
||||
|
||||
extern inline void (*AddNavigationSystemToWorldOriginal)(UWorld& WorldOwner, EFNavigationSystemRunMode RunMode, UNavigationSystemConfig* NavigationSystemConfig, char bInitializeForWorld,
|
||||
char bOverridePreviousNavSys) = nullptr;
|
||||
|
||||
static void SetNavigationSystem(AAthenaNavSystemConfigOverride* NavSystemOverride)
|
||||
static bool SetNavigationSystem(AAthenaNavSystemConfigOverride* NavSystemOverride)
|
||||
{
|
||||
auto WorldSettings = GetWorld()->K2_GetWorldSettings();
|
||||
UAthenaNavSystem*& NavSystem = (UAthenaNavSystem*&)GetWorld()->Get("NavigationSystem");
|
||||
|
||||
NavSystemOverride->Get<ENavSystemOverridePolicy>("OverridePolicy") = ENavSystemOverridePolicy::Append;
|
||||
LOG_INFO(LogDev, "NavSystem: {}", NavSystem->IsValidLowLevel() ? NavSystem->GetFullName() : "BadRead");
|
||||
|
||||
WorldSettings->Get("NavigationSystemConfigOverride") = NavSystemOverride->Get("NavigationSystemConfig");
|
||||
WorldSettings->Get("NavigationSystemConfig")->Get<bool>("bIsOverriden") = true;
|
||||
if (NavSystem)
|
||||
{
|
||||
return false;
|
||||
NavSystemCleanUpOriginal(NavSystem, 0);
|
||||
GetWorld()->Get("NavigationSystem") = nullptr;
|
||||
}
|
||||
|
||||
auto NavSystem = (UAthenaNavSystem*)GetWorld()->Get("NavigationSystem");
|
||||
auto WorldSettings = GetWorld()->GetWorldSettings();
|
||||
|
||||
NavSystemCleanUpOriginal(NavSystem, 0);
|
||||
LOG_INFO(LogDev, "WorldSettings: {}", WorldSettings->IsValidLowLevel() ? WorldSettings->GetFullName() : "BadRead");
|
||||
|
||||
GetWorld()->Get("NavigationSystem") = nullptr;
|
||||
if (!WorldSettings)
|
||||
return false;
|
||||
|
||||
static auto OverridePolicyOffset = NavSystemOverride->GetOffset("OverridePolicy", false);
|
||||
|
||||
if (OverridePolicyOffset != -1)
|
||||
NavSystemOverride->Get<ENavSystemOverridePolicy>(OverridePolicyOffset) = ENavSystemOverridePolicy::Append;
|
||||
|
||||
static auto NavSystemOverride_NavigationSystemConfigOffset = NavSystemOverride->GetOffset("NavigationSystemConfig");
|
||||
|
||||
WorldSettings->Get("NavigationSystemConfigOverride") = NavSystemOverride->Get(NavSystemOverride_NavigationSystemConfigOffset);
|
||||
|
||||
LOG_INFO(LogDev, "WorldSettings_NavigationSystemConfig: {}", __int64(WorldSettings->Get("NavigationSystemConfig")));
|
||||
|
||||
if (WorldSettings->Get("NavigationSystemConfig"))
|
||||
WorldSettings->Get("NavigationSystemConfig")->Get<bool>("bIsOverriden") = true;
|
||||
|
||||
if (!NavSystemOverride->Get("NavigationSystemConfig"))
|
||||
return;
|
||||
{
|
||||
LOG_ERROR(LogAI, "No NavigationSystemConfig!");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& ClassPath = NavSystemOverride->Get("NavigationSystemConfig")->Get<FSoftObjectPath>("NavigationSystemClass");
|
||||
|
||||
auto NewNavSystemClass = FindObject<UClass>(ClassPath.AssetPathName.ToString());
|
||||
|
||||
if (!NewNavSystemClass)
|
||||
return;
|
||||
{
|
||||
LOG_ERROR(LogAI, "No NavigationSystemClass!");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO(LogAI, "Setup navigation system.");
|
||||
|
||||
AddNavigationSystemToWorldOriginal(*GetWorld(), EFNavigationSystemRunMode::GameMode, NavSystemOverride->Get("NavigationSystemConfig"), true, false);
|
||||
// if (Fortnite_Version >= 10.40) // idk when they added the fifth arg or does it even matter????
|
||||
{
|
||||
static void (*AddNavigationSystemToWorldOriginal)(UWorld * WorldOwner, EFNavigationSystemRunMode RunMode, UNavigationSystemConfig * NavigationSystemConfig, char bInitializeForWorld, char bOverridePreviousNavSys) =
|
||||
decltype(AddNavigationSystemToWorldOriginal)(Addresses::AddNavigationSystemToWorld);
|
||||
|
||||
AddNavigationSystemToWorldOriginal(GetWorld(), EFNavigationSystemRunMode::GameMode, NavSystemOverride->Get("NavigationSystemConfig"), true, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SetupServerBotManager()
|
||||
@@ -76,7 +106,7 @@ static void SetupServerBotManager()
|
||||
auto GameState = Cast<AFortGameStateAthena>(GetWorld()->GetGameState());
|
||||
auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode());
|
||||
|
||||
static auto FortServerBotManagerClass = FindObject<UClass>("/Script/FortniteGame.FortServerBotManagerAthena"); // Is there a BP for this? // GameMode->ServerBotManagerClass
|
||||
static auto FortServerBotManagerClass = FindObject<UClass>(L"/Script/FortniteGame.FortServerBotManagerAthena"); // Is there a BP for this? // GameMode->ServerBotManagerClass
|
||||
|
||||
if (!FortServerBotManagerClass)
|
||||
return;
|
||||
@@ -95,10 +125,10 @@ static void SetupServerBotManager()
|
||||
static auto CachedGameStateOffset = ServerBotManager->GetOffset("CachedGameState", false);
|
||||
|
||||
if (CachedGameStateOffset != -1)
|
||||
ServerBotManager->Get(CachedGameStateOffset) = GameState;
|
||||
ServerBotManager->Get(CachedGameStateOffset) = GameState;
|
||||
|
||||
static auto CachedBotMutatorOffset = ServerBotManager->GetOffset("CachedBotMutator");
|
||||
ServerBotManager->Get(CachedBotMutatorOffset) = FindFirstMutator(FindObject<UClass>("/Script/FortniteGame.FortAthenaMutator_Bots"));
|
||||
ServerBotManager->Get(CachedBotMutatorOffset) = FindFirstMutator(FindObject<UClass>(L"/Script/FortniteGame.FortAthenaMutator_Bots"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +137,7 @@ static void SetupAIDirector()
|
||||
auto GameState = Cast<AFortGameStateAthena>(GetWorld()->GetGameState());
|
||||
auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode());
|
||||
|
||||
static auto AIDirectorClass = FindObject<UClass>("/Script/FortniteGame.AthenaAIDirector"); // Probably wrong class
|
||||
static auto AIDirectorClass = FindObject<UClass>(L"/Script/FortniteGame.AthenaAIDirector"); // Probably wrong class
|
||||
|
||||
if (!AIDirectorClass)
|
||||
return;
|
||||
@@ -119,28 +149,46 @@ static void SetupAIDirector()
|
||||
|
||||
if (GameMode->Get(AIDirectorOffset))
|
||||
{
|
||||
LOG_INFO(LogAI, "Successfully spawned AIDirector!");
|
||||
|
||||
static auto ActivateFn = FindObject<UFunction>("/Script/FortniteGame.FortAIDirector.Activate");
|
||||
|
||||
if (ActivateFn) // ?
|
||||
GameMode->Get(AIDirectorOffset)->ProcessEvent(ActivateFn); // ?
|
||||
}
|
||||
}
|
||||
|
||||
static void SetupNavConfig(const FName& AgentName)
|
||||
{
|
||||
static auto AthenaNavSystemConfigOverrideClass = FindObject<UClass>("/Script/FortniteGame.AthenaNavSystemConfigOverride");
|
||||
static auto AthenaNavSystemConfigOverrideClass = FindObject<UClass>(L"/Script/FortniteGame.AthenaNavSystemConfigOverride");
|
||||
auto NavSystemOverride = GetWorld()->SpawnActor<AActor>(AthenaNavSystemConfigOverrideClass);
|
||||
|
||||
if (!NavSystemOverride)
|
||||
return;
|
||||
|
||||
static auto AthenaNavSystemConfigClass = FindObject<UClass>("/Script/FortniteGame.AthenaNavSystemConfig");
|
||||
static auto AthenaNavSystemConfigClass = FindObject<UClass>(L"/Script/FortniteGame.AthenaNavSystemConfig");
|
||||
auto AthenaNavConfig = (UAthenaNavSystemConfig*)UGameplayStatics::SpawnObject(AthenaNavSystemConfigClass, NavSystemOverride);
|
||||
AthenaNavConfig->Get<bool>("bUseBuildingGridAsNavigableSpace") = false;
|
||||
AthenaNavConfig->Get<bool>("bUsesStreamedInNavLevel") = true;
|
||||
|
||||
static auto bUsesStreamedInNavLevelOffset = AthenaNavConfig->GetOffset("bUsesStreamedInNavLevel", false);
|
||||
|
||||
if (bUsesStreamedInNavLevelOffset != -1)
|
||||
AthenaNavConfig->Get<bool>(bUsesStreamedInNavLevelOffset) = true;
|
||||
|
||||
AthenaNavConfig->Get<bool>("bAllowAutoRebuild") = true;
|
||||
AthenaNavConfig->Get<bool>("bCreateOnClient") = true; // BITFIELD
|
||||
AthenaNavConfig->Get<bool>("bAutoSpawnMissingNavData") = true; // BITFIELD
|
||||
AthenaNavConfig->Get<bool>("bSpawnNavDataInNavBoundsLevel") = true; // BITFIELD
|
||||
AthenaNavConfig->Get<bool>("bUseNavigationInvokers") = false;
|
||||
AthenaNavConfig->Get<FName>("DefaultAgentName") = AgentName;
|
||||
|
||||
static auto bUseNavigationInvokersOffset = AthenaNavConfig->GetOffset("bUseNavigationInvokers", false);
|
||||
|
||||
if (bUseNavigationInvokersOffset != -1)
|
||||
AthenaNavConfig->Get<bool>(bUseNavigationInvokersOffset) = false;
|
||||
|
||||
static auto DefaultAgentNameOffset = AthenaNavConfig->GetOffset("DefaultAgentName", false);
|
||||
|
||||
if (DefaultAgentNameOffset != -1)
|
||||
AthenaNavConfig->Get<FName>(DefaultAgentNameOffset) = AgentName;
|
||||
|
||||
// NavSystemOverride->Get<ENavSystemOverridePolicy>("OverridePolicy") = ENavSystemOverridePolicy::Append;
|
||||
NavSystemOverride->Get("NavigationSystemConfig") = AthenaNavConfig;
|
||||
|
||||
Reference in New Issue
Block a user