diff --git a/Project Reboot 3.0/PlayerController.cpp b/Project Reboot 3.0/PlayerController.cpp index db2dfae..f05e9c2 100644 --- a/Project Reboot 3.0/PlayerController.cpp +++ b/Project Reboot 3.0/PlayerController.cpp @@ -3,10 +3,10 @@ #include "reboot.h" -void APlayerController::ServerChangeName(FString& S) +void APlayerController::ServerChangeName(const FString& S) { static auto ServerChangeNameFn = FindObject(L"/Script/Engine.PlayerController.ServerChangeName"); - this->ProcessEvent(ServerChangeNameFn, &S); + this->ProcessEvent(ServerChangeNameFn, (FString*)&S); } void APlayerController::SetPlayerIsWaiting(bool NewValue) diff --git a/Project Reboot 3.0/PlayerController.h b/Project Reboot 3.0/PlayerController.h index ae61bae..76c14d7 100644 --- a/Project Reboot 3.0/PlayerController.h +++ b/Project Reboot 3.0/PlayerController.h @@ -24,7 +24,7 @@ public: void SetPlayerIsWaiting(bool NewValue); bool IsPlayerWaiting(); - void ServerChangeName(FString& S); + void ServerChangeName(const FString& S); UCheatManager*& SpawnCheatManager(UClass* CheatManagerClass); FRotator GetControlRotation(); void ServerRestartPlayer(); diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj b/Project Reboot 3.0/Project Reboot 3.0.vcxproj index cf4b9fd..d13ab8f 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj @@ -293,6 +293,7 @@ + diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters index 4eddaf0..f97598b 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -984,6 +984,9 @@ Engine\Source\Runtime\AIModule\Classes + + Reboot\Public + diff --git a/Project Reboot 3.0/botnames.h b/Project Reboot 3.0/botnames.h new file mode 100644 index 0000000..71c83b3 --- /dev/null +++ b/Project Reboot 3.0/botnames.h @@ -0,0 +1,73 @@ +#pragma once + +#include +#include +#include +#include "discord.h" +#include "log.h" + +static inline size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* buffer) { + size_t total_size = size * nmemb; + buffer->append((char*)contents, total_size); + return total_size; +} + +inline std::vector PlayerBotNames; + +static inline void InitBotNames() +{ + PlayerBotNames.clear(); + + PlayerBotNames.push_back(L"qwertyouriop"); + PlayerBotNames.push_back(L"willdey"); + PlayerBotNames.push_back(L"Soggs"); + PlayerBotNames.push_back(L"vxzty"); + PlayerBotNames.push_back(L"Milxnor"); + PlayerBotNames.push_back(L"max"); + PlayerBotNames.push_back(L"Callum"); + PlayerBotNames.push_back(L"Samicc"); + PlayerBotNames.push_back(L"AidasP"); + PlayerBotNames.push_back(L"danii"); + PlayerBotNames.push_back(L"sizzy"); + PlayerBotNames.push_back(L"penguin"); + PlayerBotNames.push_back(L"Jagger"); + PlayerBotNames.push_back(L"Jacobb"); + PlayerBotNames.push_back(L"Zulu"); + PlayerBotNames.push_back(L"kemo"); + PlayerBotNames.push_back(L"Ender"); + PlayerBotNames.push_back(L"Samuel"); + PlayerBotNames.push_back(L"Kyiro"); + PlayerBotNames.push_back(L"Ahava"); + PlayerBotNames.push_back(L"Spooky"); + PlayerBotNames.push_back(L"Akos"); + PlayerBotNames.push_back(L"ridecly"); + PlayerBotNames.push_back(L"cardurr"); + PlayerBotNames.push_back(L"android"); + PlayerBotNames.push_back(L"Sync"); + PlayerBotNames.push_back(L"GD"); + PlayerBotNames.push_back(L"Jeremy"); + PlayerBotNames.push_back(L"TeoVR"); + PlayerBotNames.push_back(L"CuteLess"); + PlayerBotNames.push_back(L"Trash Bot"); + PlayerBotNames.push_back(L"Lawin"); + PlayerBotNames.push_back(L"Adam"); + PlayerBotNames.push_back(L"Ruby"); + PlayerBotNames.push_back(L"Rythm"); + PlayerBotNames.push_back(L"Fexor"); + PlayerBotNames.push_back(L"Windermed"); + PlayerBotNames.push_back(L"BIGGINS"); + PlayerBotNames.push_back(L"Charles"); + PlayerBotNames.push_back(L"Custox"); + PlayerBotNames.push_back(L"Kaede"); + PlayerBotNames.push_back(L"lintu"); + PlayerBotNames.push_back(L"Baby"); + PlayerBotNames.push_back(L"Mineluke"); + PlayerBotNames.push_back(L"wiktorwiktor12"); + PlayerBotNames.push_back(L"solo"); + PlayerBotNames.push_back(L"HxD"); + PlayerBotNames.push_back(L"Noggo"); + PlayerBotNames.push_back(L"weyn"); + PlayerBotNames.push_back(L"ralz"); + PlayerBotNames.push_back(L"farex"); + PlayerBotNames.push_back(L"AllyJax"); +} \ No newline at end of file diff --git a/Project Reboot 3.0/bots.h b/Project Reboot 3.0/bots.h index a056835..506a4df 100644 --- a/Project Reboot 3.0/bots.h +++ b/Project Reboot 3.0/bots.h @@ -4,6 +4,7 @@ #include "OnlineReplStructs.h" #include "FortAthenaAIBotController.h" #include "BuildingContainer.h" +#include "botnames.h" class BotPOI { @@ -62,7 +63,6 @@ public: else { PawnClass = LoadObject(L"/Game/Athena/AI/Phoebe/BP_PlayerPawn_Athena_Phoebe.BP_PlayerPawn_Athena_Phoebe_C", BlueprintGeneratedClassClass); - // ControllerClass = PawnClass->CreateDefaultObject()->GetAIControllerClass(); } @@ -160,6 +160,98 @@ public: } } + void PickRandomLoadout() + { + auto AllHeroTypes = GetAllObjectsOfClass(FindObject(L"/Script/FortniteGame.FortHeroType")); + std::vector AthenaHeroTypes; + + UFortItemDefinition* HeroType = FindObject(L"/Game/Athena/Heroes/HID_030_Athena_Commando_M_Halloween.HID_030_Athena_Commando_M_Halloween"); + + for (int i = 0; i < AllHeroTypes.size(); ++i) + { + auto CurrentHeroType = (UFortItemDefinition*)AllHeroTypes.at(i); + + if (CurrentHeroType->GetPathName().starts_with("/Game/Athena/Heroes/")) + AthenaHeroTypes.push_back(CurrentHeroType); + } + + if (AthenaHeroTypes.size()) + { + HeroType = AthenaHeroTypes.at(std::rand() % AthenaHeroTypes.size()); + } + + static auto HeroTypeOffset = PlayerState->GetOffset("HeroType"); + PlayerState->Get(HeroTypeOffset) = HeroType; + } + + void ApplyCosmeticLoadout() + { + static auto HeroTypeOffset = PlayerState->GetOffset("HeroType"); + const auto CurrentHeroType = PlayerState->Get(HeroTypeOffset); + + if (!CurrentHeroType) + { + LOG_WARN(LogBots, "CurrentHeroType called with an invalid HeroType!"); + return; + } + + ApplyHID(Pawn, CurrentHeroType, true); + } + + void SetName(const FString& NewName) + { + if (// true || + Fortnite_Version < 9 + ) + { + if (auto PlayerController = Cast(Controller)) + { + PlayerController->ServerChangeName(NewName); + } + } + else + { + auto GameMode = Cast(GetWorld()->GetGameMode()); + GameMode->ChangeName(Controller, NewName, true); + } + + PlayerState->OnRep_PlayerName(); // ? + } + + FString GetRandomName() // Todo SetName(GetRandomName()) + { + static int CurrentBotNum = 1; + std::wstring BotNumWStr; + FString NewName; + + if (Fortnite_Version < 9) + { + BotNumWStr = std::to_wstring(CurrentBotNum++); + NewName = (L"RebootBot" + BotNumWStr).c_str(); + } + else + { + if (Fortnite_Version < 11) + { + BotNumWStr = std::to_wstring(CurrentBotNum++ + 200); + NewName = (std::format(L"Anonymous[{}]", BotNumWStr)).c_str(); + } + else + { + if (!PlayerBotNames.empty()) + { + // std::shuffle(PlayerBotNames.begin(), PlayerBotNames.end(), std::default_random_engine((unsigned int)time(0))); + + int RandomIndex = std::rand() % (PlayerBotNames.size() - 1); + NewName = PlayerBotNames[RandomIndex]; + PlayerBotNames.erase(PlayerBotNames.begin() + RandomIndex); + } + } + } + + return NewName; + } + void Initialize(const FTransform& SpawnTransform, AActor* InSpawnLocator) { auto GameState = Cast(GetWorld()->GetGameState()); @@ -202,25 +294,9 @@ public: Controller->Possess(Pawn); } - static int CurrentBotNum = 1; - auto BotNumWStr = std::to_wstring(CurrentBotNum++); - FString NewName = (L"Jimmy" + BotNumWStr).c_str(); - - if (true || - Fortnite_Version < 9 - ) - { - if (auto PlayerController = Cast(Controller)) - { - PlayerController->ServerChangeName(NewName); - } - } - else - { - GameMode->ChangeName(Controller, NewName, true); - } - - PlayerState->OnRep_PlayerName(); + auto BotNewName = GetRandomName(); + LOG_INFO(LogBots, "BotNewName: {}", BotNewName.ToString()); + SetName(BotNewName); PlayerState->GetTeamIndex() = GameMode->Athena_PickTeamHook(GameMode, 0, Controller); @@ -231,8 +307,6 @@ public: GameState->AddPlayerStateToGameMemberInfo(PlayerState); - Controller->Possess(Pawn); - Pawn->SetHealth(100); Pawn->SetMaxHealth(100); @@ -245,38 +319,8 @@ public: } SetupInventory(); - - // 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(); - - // PlayerController->ApplyCosmeticLoadout(); - - auto AllHeroTypes = GetAllObjectsOfClass(FindObject(L"/Script/FortniteGame.FortHeroType")); - std::vector AthenaHeroTypes; - - UFortItemDefinition* HeroType = FindObject(L"/Game/Athena/Heroes/HID_030_Athena_Commando_M_Halloween.HID_030_Athena_Commando_M_Halloween"); - - for (int i = 0; i < AllHeroTypes.size(); ++i) - { - auto CurrentHeroType = (UFortItemDefinition*)AllHeroTypes.at(i); - - if (CurrentHeroType->GetPathName().starts_with("/Game/Athena/Heroes/")) - AthenaHeroTypes.push_back(CurrentHeroType); - } - - if (AthenaHeroTypes.size()) - { - HeroType = AthenaHeroTypes.at(std::rand() % AthenaHeroTypes.size()); - } - - static auto HeroTypeOffset = PlayerState->GetOffset("HeroType"); - - if (HeroTypeOffset != -1) - { - PlayerState->Get(HeroTypeOffset) = HeroType; - } - - ApplyHID(Pawn, HeroType, true); + PickRandomLoadout(); + ApplyCosmeticLoadout(); GameState->GetPlayersLeft()++; GameState->OnRep_PlayersLeft(); diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index b57546a..588c8cc 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -47,6 +47,7 @@ #include "FortGameSessionDedicatedAthena.h" #include "FortAIEncounterInfo.h" #include "FortServerBotManagerAthena.h" +#include "botnames.h" enum class EMeshNetworkNodeType : uint8_t { @@ -846,7 +847,7 @@ DWORD WINAPI Main(LPVOID) #else if (Fortnite_Version > 20) { - MessageBoxA(0, "Please define ABOVE_S20", "Project Reboot 3.0", MB_ICONERROR); + MessageBoxA(0, "Please define ABOVE_S20 (compile it yourself and change inc.h)", "Project Reboot 3.0", MB_ICONERROR); return 0; } #endif @@ -1120,6 +1121,8 @@ DWORD WINAPI Main(LPVOID) // Globals::bAbilitiesEnabled = Engine_Version < 500; + InitBotNames(); + if (Engine_Version < 420) { auto ApplyHomebaseEffectsOnPlayerSetupAddr = Memcury::Scanner::FindPattern("40 55 53 57 41 54 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 00 4C 8B").Get(); diff --git a/Project Reboot 3.0/gui.h b/Project Reboot 3.0/gui.h index b1a99b9..9c89068 100644 --- a/Project Reboot 3.0/gui.h +++ b/Project Reboot 3.0/gui.h @@ -28,6 +28,7 @@ #include "Fonts/ruda-bold.h" #include "Vector.h" #include "reboot.h" +#include "botnames.h" #include "FortGameModeAthena.h" #include "UnrealString.h" #include "KismetTextLibrary.h" @@ -119,6 +120,8 @@ static inline bool HasAnyCalendarModification() static inline void Restart() // todo move? { + InitBotNames(); + FString LevelA = Engine_Version < 424 ? L"open Athena_Terrain" : Engine_Version >= 500 ? Engine_Version >= 501 ? L"open Asteria_Terrain"