Skip to content

Commit

Permalink
Give bot skins
Browse files Browse the repository at this point in the history
  • Loading branch information
Milxnor committed Mar 19, 2024
1 parent 54b2383 commit 5bfe3a6
Show file tree
Hide file tree
Showing 19 changed files with 366 additions and 205 deletions.
8 changes: 8 additions & 0 deletions Project Reboot 3.0/AIController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "Controller.h"

class AAIController : public AController
{
public:
};
2 changes: 1 addition & 1 deletion Project Reboot 3.0/CurveTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class UCurveTable : public UObject
public:
static int GetCurveTableSize()
{
static auto CurveTableClass = FindObject<UClass>("/Script/Engine.CurveTable");
static auto CurveTableClass = FindObject<UClass>(L"/Script/Engine.CurveTable");
return CurveTableClass->GetPropertiesSize();
}

Expand Down
14 changes: 14 additions & 0 deletions Project Reboot 3.0/FortAthenaAIBotController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "reboot.h"
#include "AIController.h"

class AFortAthenaAIBotController : public AAIController
{
public:
static UClass* StaticClass()
{
static auto Class = FindObject<UClass>(L"/Script/FortniteGame.FortAthenaAIBotController");
return Class;
}
};
2 changes: 1 addition & 1 deletion Project Reboot 3.0/FortAthenaMutator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AFortAthenaMutator : public AActor // AFortGameplayMutator
public:
static UClass* StaticClass()
{
static auto Class = FindObject<UClass>("/Script/FortniteGame.FortAthenaMutator");
static auto Class = FindObject<UClass>(L"/Script/FortniteGame.FortAthenaMutator");
return Class;
}
};
Expand Down
61 changes: 46 additions & 15 deletions Project Reboot 3.0/FortGameModeAthena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,22 @@ void AFortGameModeAthena::OverrideSupplyDrop(AFortGameStateAthena* GameState, UC
return;
}

static auto SupplyDropInfoListOffset = MapInfo->GetOffset("SupplyDropInfoList");
static auto SupplyDropInfoListOffset = MapInfo->GetOffset("SupplyDropInfoList", false);

if (SupplyDropInfoListOffset == -1)
return;

auto& SupplyDropInfoList = MapInfo->Get<TArray<UFortSupplyDropInfo*>>(SupplyDropInfoListOffset);
auto FirstSupplyDropInfo = SupplyDropInfoList.at(0);

static auto SupplyDropClassOffset = SupplyDropInfoList.at(0)->GetOffset("SupplyDropClass");
SupplyDropInfoList.at(0)->Get<TSubclassOf<AFortAthenaSupplyDrop*>>(SupplyDropClassOffset) = OverrideSupplyDropBusClass;
if (!FirstSupplyDropInfo)
{
LOG_WARN(LogGame, "No FirstSupplyDropInfo!");
return;
}

static auto SupplyDropClassOffset = FirstSupplyDropInfo->GetOffset("SupplyDropClass");
FirstSupplyDropInfo->Get<TSubclassOf<AFortAthenaSupplyDrop*>>(SupplyDropClassOffset) = OverrideSupplyDropBusClass;

LOG_INFO(LogGame, "Overridden SupplyDropClass: {}", OverrideSupplyDropBusClass->GetFullName());
}
Expand Down Expand Up @@ -283,6 +294,15 @@ void AFortGameModeAthena::OnAircraftEnteredDropZoneHook(AFortGameModeAthena* Gam
}
}

void SetupEverythingAI() // find better name lol
{
PlayerBot::InitializeBotClasses();
// SetupAIGoalManager();
// SetupAIDirector();
SetupServerBotManager();
// SetupNavConfig(UKismetStringLibrary::Conv_StringToName(L"MANG"));
}

bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* GameMode)
{
Globals::bHitReadyToStartMatch = true;
Expand Down Expand Up @@ -348,14 +368,6 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game

LOG_INFO(LogDev, "Presetup!");

if (false)
{
SetupAIGoalManager();
SetupAIDirector();
SetupServerBotManager();
}
// SetupNavConfig(UKismetStringLibrary::Conv_StringToName(L"MANG"));

/*
static auto WorldManagerOffset = GameState->GetOffset("WorldManager", false);
Expand Down Expand Up @@ -402,12 +414,14 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game
}
else
{
if (Fortnite_Version >= 4.1) // ????
if (Fortnite_Version > 4.0) // bruh
{
SetPlaylist(PlaylistToUse, true);

auto CurrentPlaylist = GameState->GetCurrentPlaylist();
LOG_INFO(LogDev, "Set playlist to {}!", CurrentPlaylist->IsValidLowLevel() ? CurrentPlaylist->GetFullName() : "Invalid");

SetupEverythingAI();
}
}
}
Expand Down Expand Up @@ -674,7 +688,7 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game

static int LastNum5 = 1;

if (AmountOfRestarts != LastNum5 && LastNum6 == AmountOfRestarts) // Make sure we loaded the event.
if (AmountOfRestarts != LastNum5 && LastNum6 == AmountOfRestarts) // Make sure we loaded the event successfully.
{
LastNum5 = AmountOfRestarts;

Expand Down Expand Up @@ -706,7 +720,9 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game

auto MapInfo = GameState->GetMapInfo();

if (Engine_Version >= 421 && !MapInfo)
if (Engine_Version >= 421 && // todo recheck this version
!MapInfo
)
return false;

static int LastNum = 1;
Expand All @@ -717,8 +733,11 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game

LOG_INFO(LogDev, "Initializing!");

if (Fortnite_Version == 3)
if (Fortnite_Version >= 3.5 && Fortnite_Version <= 4) // todo check 3.4
{
SetPlaylist(GetPlaylistToUse(), true);
SetupEverythingAI();
}

LOG_INFO(LogDev, "GameMode 0x{:x}", __int64(GameMode));

Expand Down Expand Up @@ -1531,6 +1550,18 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena
if (PlayerAbilitySet && Fortnite_Version != 12.00)
{
PlayerAbilitySet->GiveToAbilitySystem(AbilitySystemComponent);

if (Fortnite_Version >= 21)
{
#if 0
static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass");
auto TacticalSprintClass = LoadObject<UClass>("/TacticalSprint/Gameplay/GA_Athena_GrantTacticalSprint.GA_Athena_GrantTacticalSprint_C", BGAClass);
AbilitySystemComponent->GiveAbilityEasy(TacticalSprintClass);
#else
auto TacticalSprintAbilitySet = LoadObject<UFortAbilitySet>("/TacticalSprint/Gameplay/AS_TacticalSprint.AS_TacticalSprint");
// TacticalSprintAbilitySet->GiveToAbilitySystem(AbilitySystemComponent);
#endif
}
}

static auto PlayerCameraManagerOffset = NewPlayer->GetOffset("PlayerCameraManager");
Expand Down
12 changes: 9 additions & 3 deletions Project Reboot 3.0/FortGameModeAthena.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "FortAbilitySet.h"
#include "FortPlayerControllerAthena.h"
#include "FortItemDefinition.h"
#include "FortServerBotManagerAthena.h"

struct FAircraftFlightInfo
{
Expand Down Expand Up @@ -82,9 +83,8 @@ static inline UFortAbilitySet* GetPlayerAbilitySet()
{
// There are some variables that contain this but it changes through versions soo..

static auto GameplayAbilitySet = (UFortAbilitySet*)(Fortnite_Version >= 8.30
? LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer", UFortAbilitySet::StaticClass())
: LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_DefaultPlayer.GAS_DefaultPlayer", UFortAbilitySet::StaticClass()));
static auto GameplayAbilitySet = (Fortnite_Version >= 8.30 ? LoadObject<UFortAbilitySet>(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer")
: LoadObject<UFortAbilitySet>(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_DefaultPlayer.GAS_DefaultPlayer"));

return GameplayAbilitySet;
}
Expand Down Expand Up @@ -251,6 +251,12 @@ class AFortGameModeAthena : public AFortGameModePvPBase
return Get<AFortSafeZoneIndicator*>(SafeZoneIndicatorOffset);
}

UFortServerBotManagerAthena*& GetServerBotManager()
{
static auto ServerBotManagerOffset = GetOffset("ServerBotManager");
return Get<UFortServerBotManagerAthena*>(ServerBotManagerOffset);
}

AFortGameStateAthena* GetGameStateAthena()
{
return (AFortGameStateAthena*)GetGameState();
Expand Down
3 changes: 2 additions & 1 deletion Project Reboot 3.0/FortPlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,8 @@ void AFortPlayerController::ServerEndEditingBuildingActorHook(AFortPlayerControl
if (auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon()))
{
EditTool->SetEditActor(nullptr);
// PlayerController->ClientForceCancelBuildingTool();
}

PlayerController->ClientForceCancelBuildingTool();
// PlayerController->ClientForceCancelBuildingTool();
}
7 changes: 7 additions & 0 deletions Project Reboot 3.0/FortServerBotManagerAthena.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Object.h"
#include "FortPlayerPawnAthena.h"
#include "FortAthenaAIBotCustomizationData.h"
#include "FortAthenaMutator_Bots.h"

struct FFortAthenaAIBotRunTimeCustomizationData
{
Expand All @@ -16,5 +17,11 @@ class UFortServerBotManagerAthena : public UObject
public:
static inline AFortPlayerPawnAthena* (*SpawnBotOriginal)(UFortServerBotManagerAthena* BotManager, FVector InSpawnLocation, FRotator InSpawnRotation, UFortAthenaAIBotCustomizationData* InBotData, FFortAthenaAIBotRunTimeCustomizationData InRuntimeBotData);

AFortAthenaMutator_Bots*& GetCachedBotMutator()
{
static auto CachedBotMutatorOffset = GetOffset("CachedBotMutator");
return Get<AFortAthenaMutator_Bots*>(CachedBotMutatorOffset);
}

static AFortPlayerPawnAthena* SpawnBotHook(UFortServerBotManagerAthena* BotManager, FVector& InSpawnLocation, FRotator& InSpawnRotation, UFortAthenaAIBotCustomizationData* InBotData, FFortAthenaAIBotRunTimeCustomizationData* InRuntimeBotData);
};
7 changes: 7 additions & 0 deletions Project Reboot 3.0/Pawn.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Actor.h"
#include "TSubClassOf.h"

class APawn : public AActor
{
Expand All @@ -16,4 +17,10 @@ class APawn : public AActor
static auto ControllerOffset = GetOffset("Controller");
return Get<class APlayerController*>(ControllerOffset);
}

TSubclassOf<class AController> GetAIControllerClass()
{
static auto AIControllerClassOffset = GetOffset("AIControllerClass");
return Get<TSubclassOf<class AController>>(AIControllerClassOffset);
}
};
5 changes: 5 additions & 0 deletions Project Reboot 3.0/Project Reboot 3.0.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
Expand Down Expand Up @@ -274,6 +277,7 @@
<ClInclude Include="ActorComponent.h" />
<ClInclude Include="addresses.h" />
<ClInclude Include="ai.h" />
<ClInclude Include="AIController.h" />
<ClInclude Include="AndOrNot.h" />
<ClInclude Include="anticheat.h" />
<ClInclude Include="Array.h" />
Expand Down Expand Up @@ -328,6 +332,7 @@
<ClInclude Include="FortAbilitySet.h" />
<ClInclude Include="FortAIEncounterInfo.h" />
<ClInclude Include="FortAthenaAIBotCharacterCustomization.h" />
<ClInclude Include="FortAthenaAIBotController.h" />
<ClInclude Include="FortAthenaAIBotCustomizationData.h" />
<ClInclude Include="FortAthenaAIBotSpawnerData.h" />
<ClInclude Include="FortAthenaAISpawnerDataComponent_CosmeticLoadout.h" />
Expand Down
6 changes: 6 additions & 0 deletions Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,12 @@
<ClInclude Include="FortServerBotManagerAthena.h">
<Filter>FortniteGame\Source\FortniteGame\Public\AI</Filter>
</ClInclude>
<ClInclude Include="FortAthenaAIBotController.h">
<Filter>FortniteGame\Source\FortniteGame\Public\AI</Filter>
</ClInclude>
<ClInclude Include="AIController.h">
<Filter>Engine\Source\Runtime\AIModule\Classes</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Engine">
Expand Down
41 changes: 37 additions & 4 deletions Project Reboot 3.0/ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ static bool SetNavigationSystem(AAthenaNavSystemConfigOverride* NavSystemOverrid
return true;
}

static inline AFortAthenaMutator_Bots* SpawnBotMutator() //sets up all the classes for phoebe
{
auto GameState = Cast<AFortGameStateAthena>(GetWorld()->GetGameState());
auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode());

static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass");
static auto PhoebeMutatorClass = LoadObject<UClass>(L"/Game/Athena/AI/Phoebe/BP_Phoebe_Mutator.BP_Phoebe_Mutator_C", BGAClass);

auto BotMutator = GetWorld()->SpawnActor<AFortAthenaMutator_Bots>(PhoebeMutatorClass);

static auto CachedGameModeOffset = BotMutator->GetOffset("CachedGameMode");
BotMutator->Get(CachedGameModeOffset) = GameMode;

static auto CachedGameStateOffset = BotMutator->GetOffset("CachedGameState", false);

if (CachedGameStateOffset != -1)
BotMutator->Get(CachedGameStateOffset) = GameState;

return BotMutator;
}

static void SetupServerBotManager()
{
auto GameState = Cast<AFortGameStateAthena>(GetWorld()->GetGameState());
Expand All @@ -115,11 +136,10 @@ static void SetupServerBotManager()
if (!FortServerBotManagerClass)
return;

static auto ServerBotManagerOffset = GameMode->GetOffset("ServerBotManager");
UObject*& ServerBotManager = GameMode->Get(ServerBotManagerOffset);
UFortServerBotManagerAthena*& ServerBotManager = GameMode->GetServerBotManager();

if (!ServerBotManager)
ServerBotManager = UGameplayStatics::SpawnObject(FortServerBotManagerClass, GetTransientPackage());
ServerBotManager = (UFortServerBotManagerAthena*)UGameplayStatics::SpawnObject(FortServerBotManagerClass, GetTransientPackage());

if (ServerBotManager)
{
Expand All @@ -132,7 +152,20 @@ static void SetupServerBotManager()
ServerBotManager->Get(CachedGameStateOffset) = GameState;

static auto CachedBotMutatorOffset = ServerBotManager->GetOffset("CachedBotMutator");
ServerBotManager->Get(CachedBotMutatorOffset) = FindFirstMutator(FindObject<UClass>(L"/Script/FortniteGame.FortAthenaMutator_Bots"));
auto BotMutator = FindFirstMutator(FindObject<UClass>(L"/Script/FortniteGame.FortAthenaMutator_Bots"));

if (!BotMutator)
{
LOG_WARN(LogAI, "Failed to find Bot Mutator! Spawning it..");
BotMutator = SpawnBotMutator();
}

if (!BotMutator)
{
LOG_ERROR(LogAI, "Failed to spawn or find Bot Mutator!");
}

ServerBotManager->Get(CachedBotMutatorOffset) = BotMutator;
}
}

Expand Down
Loading

0 comments on commit 5bfe3a6

Please sign in to comment.