From a69d1bda6e46c2ef760b24ea30f67f92b6b8c42d Mon Sep 17 00:00:00 2001 From: Gray <84999745+Milxnor@users.noreply.github.com> Date: Wed, 20 Mar 2024 19:11:16 -0400 Subject: [PATCH] big oops --- Project Reboot 3.0/ai.h | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Project Reboot 3.0/ai.h b/Project Reboot 3.0/ai.h index 5931cdf..10b3f5b 100644 --- a/Project Reboot 3.0/ai.h +++ b/Project Reboot 3.0/ai.h @@ -107,23 +107,34 @@ static bool SetNavigationSystem(AAthenaNavSystemConfigOverride* NavSystemOverrid static inline AFortAthenaMutator_Bots* SpawnBotMutator() //sets up all the classes for phoebe { - auto GameState = Cast(GetWorld()->GetGameState()); - auto GameMode = Cast(GetWorld()->GetGameMode()); + auto GameState = Cast(GetWorld()->GetGameState()); + auto GameMode = Cast(GetWorld()->GetGameMode()); - static auto BGAClass = FindObject(L"/Script/Engine.BlueprintGeneratedClass"); - static auto PhoebeMutatorClass = LoadObject(L"/Game/Athena/AI/Phoebe/BP_Phoebe_Mutator.BP_Phoebe_Mutator_C", BGAClass); + static auto BGAClass = FindObject(L"/Script/Engine.BlueprintGeneratedClass"); + static auto PhoebeMutatorClass = LoadObject(L"/Game/Athena/AI/Phoebe/BP_Phoebe_Mutator.BP_Phoebe_Mutator_C", BGAClass); - auto BotMutator = GetWorld()->SpawnActor(PhoebeMutatorClass); + if (!PhoebeMutatorClass) + { + return nullptr; + } - static auto CachedGameModeOffset = BotMutator->GetOffset("CachedGameMode"); - BotMutator->Get(CachedGameModeOffset) = GameMode; + auto BotMutator = GetWorld()->SpawnActor(PhoebeMutatorClass); - static auto CachedGameStateOffset = BotMutator->GetOffset("CachedGameState", false); + if (!BotMutator) + { + LOG_WARN(LogAI, "Failed to spawn Bot Mutator!"); + return nullptr; + } - if (CachedGameStateOffset != -1) - BotMutator->Get(CachedGameStateOffset) = GameState; + static auto CachedGameModeOffset = BotMutator->GetOffset("CachedGameMode"); + BotMutator->Get(CachedGameModeOffset) = GameMode; - return BotMutator; + static auto CachedGameStateOffset = BotMutator->GetOffset("CachedGameState", false); + + if (CachedGameStateOffset != -1) + BotMutator->Get(CachedGameStateOffset) = GameState; + + return BotMutator; } static void SetupServerBotManager() @@ -435,4 +446,4 @@ static AFortPlayerPawn* SpawnAIFromCustomizationData(const FVector& Location, UF } return Pawn; -} \ No newline at end of file +}