some ai stuff

might have completely broke ai but idk
This commit is contained in:
Milxnor
2023-05-07 23:42:23 -04:00
parent bfe2610a11
commit d5c95ac978
9 changed files with 217 additions and 119 deletions

View File

@@ -8,4 +8,10 @@ AActor* AController::GetViewTarget()
AActor* ViewTarget = nullptr; AActor* ViewTarget = nullptr;
this->ProcessEvent(GetViewTargetFn, &ViewTarget); this->ProcessEvent(GetViewTargetFn, &ViewTarget);
return ViewTarget; return ViewTarget;
}
void AController::Possess(class APawn* Pawn)
{
auto PossessFn = FindFunction("Possess");
this->ProcessEvent(PossessFn, &Pawn);
} }

View File

@@ -6,4 +6,17 @@ class AController : public AActor
{ {
public: public:
AActor* GetViewTarget(); AActor* GetViewTarget();
void Possess(class APawn* Pawn);
class APawn*& GetPawn()
{
static auto PawnOffset = this->GetOffset("Pawn");
return this->Get<class APawn*>(PawnOffset);
}
class APlayerState*& GetPlayerState()
{
static auto PlayerStateOffset = this->GetOffset("PlayerState");
return this->Get<class APlayerState*>(PlayerStateOffset);
}
}; };

View File

@@ -554,6 +554,9 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game
GetWorld()->Listen(); GetWorld()->Listen();
SetupAIDirector();
SetupServerBotManager();
if (AmountOfBotsToSpawn != 0) if (AmountOfBotsToSpawn != 0)
{ {
Bots::SpawnBotsAtPlayerStarts(AmountOfBotsToSpawn); Bots::SpawnBotsAtPlayerStarts(AmountOfBotsToSpawn);

View File

@@ -23,12 +23,6 @@ FRotator APlayerController::GetControlRotation()
return rot; return rot;
} }
void APlayerController::Possess(class APawn* Pawn)
{
static auto fn = FindObject<UFunction>(L"/Script/Engine.Controller.Possess");
this->ProcessEvent(fn, &Pawn);
}
void APlayerController::ServerRestartPlayer() void APlayerController::ServerRestartPlayer()
{ {
static auto fn = FindObject<UFunction>(L"/Script/Engine.PlayerController.ServerRestartPlayer"); static auto fn = FindObject<UFunction>(L"/Script/Engine.PlayerController.ServerRestartPlayer");

View File

@@ -10,30 +10,6 @@
class APlayerController : public AController class APlayerController : public AController
{ {
public: public:
/* void Possess(APawn* Pawn)
{
static auto Possess = FindObject<UFunction>("/Script/Engine.Controller.Possess");
this->ProcessEvent(Possess, &Pawn);
}
static inline void ServerAcknowledgePossessionHook(APlayerController* PlayerController, APawn* P)
{
static auto AcknowledgedPawnOffset = PlayerController->GetOffset("AcknowledgedPawn");
PlayerController->Get<APawn*>(AcknowledgedPawnOffset) = P;
} */
class APlayerState*& GetPlayerState()
{
static auto PlayerStateOffset = this->GetOffset("PlayerState");
return this->Get<class APlayerState*>(PlayerStateOffset);
}
class APawn*& GetPawn()
{
static auto PawnOffset = this->GetOffset("Pawn");
return this->Get<class APawn*>(PawnOffset);
}
UCheatManager*& GetCheatManager() UCheatManager*& GetCheatManager()
{ {
static auto CheatManagerOffset = this->GetOffset("CheatManager"); static auto CheatManagerOffset = this->GetOffset("CheatManager");
@@ -43,7 +19,6 @@ public:
void ServerChangeName(FString& S); void ServerChangeName(FString& S);
UCheatManager*& SpawnCheatManager(UClass* CheatManagerClass); UCheatManager*& SpawnCheatManager(UClass* CheatManagerClass);
FRotator GetControlRotation(); FRotator GetControlRotation();
void Possess(class APawn* Pawn);
void ServerRestartPlayer(); void ServerRestartPlayer();
static UClass* StaticClass(); static UClass* StaticClass();

View File

@@ -232,15 +232,6 @@
<ClCompile Include="FortSafeZoneIndicator.cpp"> <ClCompile Include="FortSafeZoneIndicator.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private</Filter> <Filter>FortniteGame\Source\FortniteGame\Private</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="FortAthenaMutator_GiveItemsAtGamePhaseStep.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private\Mutators</Filter>
</ClCompile>
<ClCompile Include="FortAthenaMutator_Disco.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private\Mutators</Filter>
</ClCompile>
<ClCompile Include="FortAthenaMutator_Barrier.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private\Mutators</Filter>
</ClCompile>
<ClCompile Include="GenericPlatformMath.cpp"> <ClCompile Include="GenericPlatformMath.cpp">
<Filter>Engine\Source\Runtime\Core\Private\GenericPlatform</Filter> <Filter>Engine\Source\Runtime\Core\Private\GenericPlatform</Filter>
</ClCompile> </ClCompile>
@@ -268,6 +259,15 @@
<ClCompile Include="FortWeaponItemDefinition.cpp"> <ClCompile Include="FortWeaponItemDefinition.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private\Items</Filter> <Filter>FortniteGame\Source\FortniteGame\Private\Items</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="FortAthenaMutator_Barrier.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private\Athena\Modifiers</Filter>
</ClCompile>
<ClCompile Include="FortAthenaMutator_GiveItemsAtGamePhaseStep.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private\Athena\Modifiers</Filter>
</ClCompile>
<ClCompile Include="FortAthenaMutator_Disco.cpp">
<Filter>FortniteGame\Source\FortniteGame\Private\Athena\Modifiers</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="log.h" /> <ClInclude Include="log.h" />
@@ -745,39 +745,12 @@
<ClInclude Include="FortSafeZoneIndicator.h"> <ClInclude Include="FortSafeZoneIndicator.h">
<Filter>FortniteGame\Source\FortniteGame\Public</Filter> <Filter>FortniteGame\Source\FortniteGame\Public</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FortAthenaMutator_GiveItemsAtGamePhaseStep.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_GG.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_InventoryOverride_Bucket.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_InventoryOverride.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_ItemDropOnDeath.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_Disco.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_Heist.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="AthenaBarrierFlag.h"> <ClInclude Include="AthenaBarrierFlag.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier</Filter> <Filter>FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="AthenaBarrierObjective.h"> <ClInclude Include="AthenaBarrierObjective.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier</Filter> <Filter>FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FortAthenaMutator_Barrier.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="AthenaBigBaseWall.h"> <ClInclude Include="AthenaBigBaseWall.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier</Filter> <Filter>FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier</Filter>
</ClInclude> </ClInclude>
@@ -826,12 +799,6 @@
<ClInclude Include="FortAthenaVehicleSpawner.h"> <ClInclude Include="FortAthenaVehicleSpawner.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Vehicle</Filter> <Filter>FortniteGame\Source\FortniteGame\Public\Athena\Vehicle</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FortAthenaMutator_TDM.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_LoadoutSwap.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Mutators</Filter>
</ClInclude>
<ClInclude Include="discord.h" /> <ClInclude Include="discord.h" />
<ClInclude Include="FortAthenaSupplyDrop.h"> <ClInclude Include="FortAthenaSupplyDrop.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Building</Filter> <Filter>FortniteGame\Source\FortniteGame\Public\Building</Filter>
@@ -854,6 +821,39 @@
<ClInclude Include="gui.h"> <ClInclude Include="gui.h">
<Filter>Reboot\Public</Filter> <Filter>Reboot\Public</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FortAthenaMutator.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_Disco.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_Barrier.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_GG.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_GiveItemsAtGamePhaseStep.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_Heist.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_InventoryOverride.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_ItemDropOnDeath.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_InventoryOverride_Bucket.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_TDM.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
<ClInclude Include="FortAthenaMutator_LoadoutSwap.h">
<Filter>FortniteGame\Source\FortniteGame\Public\Athena\Modifiers</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="Engine"> <Filter Include="Engine">
@@ -1066,12 +1066,6 @@
<Filter Include="FortniteGame\Source\FortniteGame\Public\Athena\Vehicle"> <Filter Include="FortniteGame\Source\FortniteGame\Public\Athena\Vehicle">
<UniqueIdentifier>{b1cc2ad4-6196-455c-bda7-d0a2e7be2e70}</UniqueIdentifier> <UniqueIdentifier>{b1cc2ad4-6196-455c-bda7-d0a2e7be2e70}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="FortniteGame\Source\FortniteGame\Private\Mutators">
<UniqueIdentifier>{bfeeff9b-a86e-47a9-973c-47f6d0dfe5d5}</UniqueIdentifier>
</Filter>
<Filter Include="FortniteGame\Source\FortniteGame\Public\Mutators">
<UniqueIdentifier>{6efc7bff-2d7b-4fdb-bae8-3d2e736cc82e}</UniqueIdentifier>
</Filter>
<Filter Include="FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier"> <Filter Include="FortniteGame\Source\FortniteGame\Public\Building\GameplayActors\Barrier">
<UniqueIdentifier>{a633ca3f-f699-4c92-8522-e49a14157b95}</UniqueIdentifier> <UniqueIdentifier>{a633ca3f-f699-4c92-8522-e49a14157b95}</UniqueIdentifier>
</Filter> </Filter>
@@ -1090,6 +1084,15 @@
<Filter Include="Reboot\Private\Gameplay"> <Filter Include="Reboot\Private\Gameplay">
<UniqueIdentifier>{52d438db-beaf-44be-bddd-9aeb07c2459f}</UniqueIdentifier> <UniqueIdentifier>{52d438db-beaf-44be-bddd-9aeb07c2459f}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="FortniteGame\Source\FortniteGame\Public\Athena\Modifiers">
<UniqueIdentifier>{39656a6c-bfe1-4521-8652-aea0146564d6}</UniqueIdentifier>
</Filter>
<Filter Include="FortniteGame\Source\FortniteGame\Private\Athena">
<UniqueIdentifier>{411d5144-2703-4a96-a7b0-9f2a81abdead}</UniqueIdentifier>
</Filter>
<Filter Include="FortniteGame\Source\FortniteGame\Private\Athena\Modifiers">
<UniqueIdentifier>{ade44d65-f7a4-4fc9-ac38-637c84493b58}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="UnrealEngine.cpp"> <None Include="UnrealEngine.cpp">

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Object.h" #include "Object.h"
#include "Package.h"
#define ANY_PACKAGE (UObject*)-1 #define ANY_PACKAGE (UObject*)-1
@@ -11,4 +12,10 @@ static inline T* StaticFindObject(UClass* Class, UObject* InOuter, const TCHAR*
{ {
// LOG_INFO(LogDev, "StaticFindObjectOriginal: {}", __int64(StaticFindObjectOriginal)); // LOG_INFO(LogDev, "StaticFindObjectOriginal: {}", __int64(StaticFindObjectOriginal));
return (T*)StaticFindObjectOriginal(Class, InOuter, Name, ExactClass); return (T*)StaticFindObjectOriginal(Class, InOuter, Name, ExactClass);
}
static inline UPackage* GetTransientPackage()
{
static auto TransientPackage = StaticFindObject<UPackage>(nullptr, nullptr, L"/Engine/Transient");
return TransientPackage;
} }

View File

@@ -6,7 +6,10 @@
#include "KismetStringLibrary.h" #include "KismetStringLibrary.h"
#include "GameplayStatics.h" #include "GameplayStatics.h"
#include "FortPlayerPawn.h" #include "FortPlayerPawn.h"
#include "FortAthenaMutator.h"
#include "FortPlayerController.h" #include "FortPlayerController.h"
#include "FortGameModeAthena.h"
#include "FortGameStateAthena.h"
#include "FortPlayerControllerAthena.h" #include "FortPlayerControllerAthena.h"
using UNavigationSystemV1 = UObject; using UNavigationSystemV1 = UObject;
@@ -68,7 +71,57 @@ static void SetNavigationSystem(AAthenaNavSystemConfigOverride* NavSystemOverrid
AddNavigationSystemToWorldOriginal(*GetWorld(), EFNavigationSystemRunMode::GameMode, NavSystemOverride->Get("NavigationSystemConfig"), true, false); AddNavigationSystemToWorldOriginal(*GetWorld(), EFNavigationSystemRunMode::GameMode, NavSystemOverride->Get("NavigationSystemConfig"), true, false);
} }
static void SetupNavConfig() 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
if (!FortServerBotManagerClass)
return;
static auto ServerBotManagerOffset = GameMode->GetOffset("ServerBotManager");
UObject*& ServerBotManager = GameMode->Get(ServerBotManagerOffset);
if (!ServerBotManager)
ServerBotManager = UGameplayStatics::SpawnObject(FortServerBotManagerClass, GetTransientPackage());
if (ServerBotManager)
{
static auto CachedGameModeOffset = ServerBotManager->GetOffset("CachedGameMode");
ServerBotManager->Get(CachedGameModeOffset) = GameMode;
static auto CachedGameStateOffset = ServerBotManager->GetOffset("CachedGameState");
ServerBotManager->Get(CachedGameStateOffset) = GameState;
static auto CachedBotMutatorOffset = ServerBotManager->GetOffset("CachedBotMutator");
ServerBotManager->Get(CachedBotMutatorOffset) = FindFirstMutator(FindObject<UClass>("/Script/FortniteGame.FortAthenaMutator_Bots"));
}
}
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
if (!AIDirectorClass)
return;
static auto AIDirectorOffset = GameMode->GetOffset("AIDirector");
if (!GameMode->Get(AIDirectorOffset))
GameMode->Get(AIDirectorOffset) = GetWorld()->SpawnActor<AActor>(AIDirectorClass);
if (GameMode->Get(AIDirectorOffset))
{
}
}
static void SetupNavConfig(const FName& AgentName)
{ {
static auto AthenaNavSystemConfigOverrideClass = FindObject<UClass>("/Script/FortniteGame.AthenaNavSystemConfigOverride"); static auto AthenaNavSystemConfigOverrideClass = FindObject<UClass>("/Script/FortniteGame.AthenaNavSystemConfigOverride");
auto NavSystemOverride = GetWorld()->SpawnActor<AActor>(AthenaNavSystemConfigOverrideClass); auto NavSystemOverride = GetWorld()->SpawnActor<AActor>(AthenaNavSystemConfigOverrideClass);
@@ -85,7 +138,7 @@ static void SetupNavConfig()
AthenaNavConfig->Get<bool>("bAutoSpawnMissingNavData") = true; // BITFIELD AthenaNavConfig->Get<bool>("bAutoSpawnMissingNavData") = true; // BITFIELD
AthenaNavConfig->Get<bool>("bSpawnNavDataInNavBoundsLevel") = true; // BITFIELD AthenaNavConfig->Get<bool>("bSpawnNavDataInNavBoundsLevel") = true; // BITFIELD
AthenaNavConfig->Get<bool>("bUseNavigationInvokers") = false; AthenaNavConfig->Get<bool>("bUseNavigationInvokers") = false;
AthenaNavConfig->Get<FName>("DefaultAgentName") = UKismetStringLibrary::Conv_StringToName(L"Galileo"); AthenaNavConfig->Get<FName>("DefaultAgentName") = AgentName;
// NavSystemOverride->Get<ENavSystemOverridePolicy>("OverridePolicy") = ENavSystemOverridePolicy::Append; // NavSystemOverride->Get<ENavSystemOverridePolicy>("OverridePolicy") = ENavSystemOverridePolicy::Append;
NavSystemOverride->Get("NavigationSystemConfig") = AthenaNavConfig; NavSystemOverride->Get("NavigationSystemConfig") = AthenaNavConfig;

View File

@@ -7,22 +7,30 @@
class PlayerBot class PlayerBot
{ {
public: public:
AFortPlayerControllerAthena* PlayerController = nullptr; AController* Controller = nullptr;
float NextJumpTime = 1.0f; float NextJumpTime = 1.0f;
void Initialize(FTransform SpawnTransform) void Initialize(const FTransform& SpawnTransform)
{ {
auto GameState = Cast<AFortGameStateAthena>(GetWorld()->GetGameState()); auto GameState = Cast<AFortGameStateAthena>(GetWorld()->GetGameState());
auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode()); auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode());
#if 0
static auto PawnClass = FindObject<UClass>("/Game/Athena/PlayerPawn_Athena.PlayerPawn_Athena_C"); static auto PawnClass = FindObject<UClass>("/Game/Athena/PlayerPawn_Athena.PlayerPawn_Athena_C");
static auto ControllerClass = AFortPlayerControllerAthena::StaticClass();
#else
static auto PawnClass = FindObject<UClass>("/Game/Athena/AI/Phoebe/BP_PlayerPawn_Athena_Phoebe.BP_PlayerPawn_Athena_Phoebe_C");
static auto ControllerClass = FindObject<UClass>("/Game/Athena/AI/Phoebe/BP_PhoebePlayerController.BP_PhoebePlayerController_C");
#endif
static auto FortAthenaAIBotControllerClass = FindObject<UClass>("/Script/FortniteGame.FortAthenaAIBotController");
FActorSpawnParameters PawnSpawnParameters{}; FActorSpawnParameters PawnSpawnParameters{};
PawnSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn; PawnSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
PlayerController = GetWorld()->SpawnActor<AFortPlayerControllerAthena>(AFortPlayerControllerAthena::StaticClass()); Controller = GetWorld()->SpawnActor<AController>(ControllerClass);
AFortPlayerPawnAthena* Pawn = GetWorld()->SpawnActor<AFortPlayerPawnAthena>(PawnClass, SpawnTransform, PawnSpawnParameters); AFortPlayerPawnAthena* Pawn = GetWorld()->SpawnActor<AFortPlayerPawnAthena>(PawnClass, SpawnTransform, PawnSpawnParameters);
AFortPlayerStateAthena* PlayerState = Cast<AFortPlayerStateAthena>(PlayerController->GetPlayerState()); AFortPlayerStateAthena* PlayerState = Cast<AFortPlayerStateAthena>(Controller->GetPlayerState());
if (!Pawn || !PlayerState) if (!Pawn || !PlayerState)
return; return;
@@ -33,10 +41,12 @@ public:
FString NewName = (L"RebootBot" + BotNumWStr).c_str(); FString NewName = (L"RebootBot" + BotNumWStr).c_str();
PlayerController->ServerChangeName(NewName); if (auto PlayerController = Cast<APlayerController>(Controller))
PlayerController->ServerChangeName(NewName);
PlayerState->OnRep_PlayerName(); PlayerState->OnRep_PlayerName();
PlayerState->GetTeamIndex() = GameMode->Athena_PickTeamHook(GameMode, 0, PlayerController); PlayerState->GetTeamIndex() = GameMode->Athena_PickTeamHook(GameMode, 0, Controller);
static auto SquadIdOffset = PlayerState->GetOffset("SquadId", false); static auto SquadIdOffset = PlayerState->GetOffset("SquadId", false);
@@ -70,51 +80,84 @@ public:
*/ */
PlayerController->Possess(Pawn); Controller->Possess(Pawn);
Pawn->SetHealth(100); Pawn->SetHealth(100);
Pawn->SetMaxHealth(100); Pawn->SetMaxHealth(100);
FActorSpawnParameters WorldInventorySpawnParameters{}; AFortInventory** Inventory = nullptr;
WorldInventorySpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
WorldInventorySpawnParameters.Owner = PlayerController;
FTransform WorldInventorySpawnTransform{}; if (auto FortPlayerController = Cast<AFortPlayerController>(Controller))
static auto FortInventoryClass = FindObject<UClass>("/Script/FortniteGame.FortInventory"); // AFortInventory::StaticClass()
PlayerController->GetWorldInventory() = GetWorld()->SpawnActor<AFortInventory>(FortInventoryClass, WorldInventorySpawnTransform, WorldInventorySpawnParameters);
if (!PlayerController->GetWorldInventory())
{ {
LOG_ERROR(LogBots, "Failed to spawn WorldInventory!"); Inventory = &FortPlayerController->GetWorldInventory();
}
else
{
if (Controller->IsA(FortAthenaAIBotControllerClass))
{
static auto InventoryOffset = Controller->GetOffset("Inventory");
Inventory = Controller->GetPtr<AFortInventory*>(InventoryOffset);
}
}
if (!Inventory)
{
LOG_ERROR(LogBots, "No inventory pointer!");
Pawn->K2_DestroyActor(); Pawn->K2_DestroyActor();
PlayerController->K2_DestroyActor(); Controller->K2_DestroyActor();
return; return;
} }
PlayerController->GetWorldInventory()->GetInventoryType() = EFortInventoryType::World; FActorSpawnParameters InventorySpawnParameters{};
InventorySpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
InventorySpawnParameters.Owner = Controller;
static auto bHasInitializedWorldInventoryOffset = PlayerController->GetOffset("bHasInitializedWorldInventory"); FTransform InventorySpawnTransform{};
PlayerController->Get<bool>(bHasInitializedWorldInventoryOffset) = true;
auto& StartingItems = GameMode->GetStartingItems(); static auto FortInventoryClass = FindObject<UClass>("/Script/FortniteGame.FortInventory"); // AFortInventory::StaticClass()
*Inventory = GetWorld()->SpawnActor<AFortInventory>(FortInventoryClass, InventorySpawnTransform, InventorySpawnParameters);
auto PickaxeInstance = PlayerController->AddPickaxeToInventory(); if (!*Inventory)
for (int i = 0; i < StartingItems.Num(); i++)
{ {
auto& StartingItem = StartingItems.at(i); LOG_ERROR(LogBots, "Failed to spawn Inventory!");
PlayerController->GetWorldInventory()->AddItem(StartingItem.GetItem(), nullptr, StartingItem.GetCount()); Pawn->K2_DestroyActor();
Controller->K2_DestroyActor();
return;
} }
if (PickaxeInstance) (*Inventory)->GetInventoryType() = EFortInventoryType::World;
if (auto FortPlayerController = Cast<AFortPlayerController>(Controller))
{ {
PlayerController->ServerExecuteInventoryItemHook(PlayerController, PickaxeInstance->GetItemEntry()->GetItemGuid()); static auto bHasInitializedWorldInventoryOffset = FortPlayerController->GetOffset("bHasInitializedWorldInventory");
FortPlayerController->Get<bool>(bHasInitializedWorldInventoryOffset) = true;
} }
PlayerController->GetWorldInventory()->Update(); if (false)
{
if (Inventory)
{
auto& StartingItems = GameMode->GetStartingItems();
UFortItem* PickaxeInstance = nullptr; // PlayerController->AddPickaxeToInventory();
for (int i = 0; i < StartingItems.Num(); i++)
{
auto& StartingItem = StartingItems.at(i);
(*Inventory)->AddItem(StartingItem.GetItem(), nullptr, StartingItem.GetCount());
}
if (PickaxeInstance)
{
// PlayerController->ServerExecuteInventoryItemHook(PlayerController, PickaxeInstance->GetItemEntry()->GetItemGuid());
}
(*Inventory)->Update();
}
}
/* static auto HeroType = FindObject(L"/Game/Athena/Heroes/HID_115_Athena_Commando_M_CarbideBlue.HID_115_Athena_Commando_M_CarbideBlue"); /* static auto HeroType = FindObject(L"/Game/Athena/Heroes/HID_115_Athena_Commando_M_CarbideBlue.HID_115_Athena_Commando_M_CarbideBlue");
@@ -131,15 +174,16 @@ public:
PlayerAbilitySet->GiveToAbilitySystem(AbilitySystemComponent); PlayerAbilitySet->GiveToAbilitySystem(AbilitySystemComponent);
} }
PlayerController->GetCosmeticLoadout()->GetCharacter() = FindObject("/Game/Athena/Items/Cosmetics/Characters/CID_263_Athena_Commando_F_MadCommander.CID_263_Athena_Commando_F_MadCommander"); // PlayerController->GetCosmeticLoadout()->GetCharacter() = FindObject("/Game/Athena/Items/Cosmetics/Characters/CID_263_Athena_Commando_F_MadCommander.CID_263_Athena_Commando_F_MadCommander");
Pawn->GetCosmeticLoadout()->GetCharacter() = PlayerController->GetCosmeticLoadout()->GetCharacter(); // Pawn->GetCosmeticLoadout()->GetCharacter() = PlayerController->GetCosmeticLoadout()->GetCharacter();
PlayerController->ApplyCosmeticLoadout(); // PlayerController->ApplyCosmeticLoadout();
GameState->GetPlayersLeft()++; GameState->GetPlayersLeft()++;
GameState->OnRep_PlayersLeft(); GameState->OnRep_PlayersLeft();
GameMode->GetAlivePlayers().Add(PlayerController); if (auto FortPlayerControllerAthena = Cast<AFortPlayerControllerAthena>(Controller))
GameMode->GetAlivePlayers().Add(FortPlayerControllerAthena);
} }
}; };
@@ -147,12 +191,12 @@ static std::vector<PlayerBot> AllPlayerBotsToTick;
namespace Bots namespace Bots
{ {
static AFortPlayerControllerAthena* SpawnBot(FTransform SpawnTransform) static AController* SpawnBot(FTransform SpawnTransform)
{ {
auto playerBot = PlayerBot(); auto playerBot = PlayerBot();
playerBot.Initialize(SpawnTransform); playerBot.Initialize(SpawnTransform);
AllPlayerBotsToTick.push_back(playerBot); AllPlayerBotsToTick.push_back(playerBot);
return playerBot.PlayerController; return playerBot.Controller;
} }
static void SpawnBotsAtPlayerStarts(int AmountOfBots) static void SpawnBotsAtPlayerStarts(int AmountOfBots)
@@ -195,12 +239,12 @@ namespace Bots
// for (int i = 0; i < GameMode->GetAlivePlayers().Num(); i++) // for (int i = 0; i < GameMode->GetAlivePlayers().Num(); i++)
for (auto& PlayerBot : AllPlayerBotsToTick) for (auto& PlayerBot : AllPlayerBotsToTick)
{ {
auto CurrentPlayer = PlayerBot.PlayerController; auto CurrentPlayer = PlayerBot.Controller;
if (CurrentPlayer->IsActorBeingDestroyed()) if (CurrentPlayer->IsActorBeingDestroyed())
continue; continue;
auto CurrentPawn = CurrentPlayer->GetMyFortPawn(); auto CurrentPawn = CurrentPlayer->GetPawn();
auto CurrentPlayerState = Cast<AFortPlayerStateAthena>(CurrentPlayer->GetPlayerState()); auto CurrentPlayerState = Cast<AFortPlayerStateAthena>(CurrentPlayer->GetPlayerState());