From a4ed589aab4c3cf79c4959ec84243ed6872d660b Mon Sep 17 00:00:00 2001 From: Milxnor Date: Thu, 4 May 2023 20:46:48 -0400 Subject: [PATCH] quite a bit llamas, fix some ltm specific stuff, add auto bus start for auto restart, work in progress lategame on 1.11, fix a crash, performance --- Project Reboot 3.0/FortAthenaMapInfo.cpp | 84 +++++++++++++ Project Reboot 3.0/FortAthenaMapInfo.h | 36 +++++- Project Reboot 3.0/FortAthenaMutator.h | 11 ++ .../FortAthenaMutator_Barrier.h | 14 +++ .../FortAthenaMutator_Disco.cpp | 6 +- Project Reboot 3.0/FortAthenaMutator_Disco.h | 2 + Project Reboot 3.0/FortAthenaMutator_GG.h | 2 + Project Reboot 3.0/FortAthenaMutator_Heist.h | 10 +- Project Reboot 3.0/FortAthenaSupplyDrop.cpp | 15 +++ Project Reboot 3.0/FortAthenaSupplyDrop.h | 2 + Project Reboot 3.0/FortGameModeAthena.cpp | 67 ++++++++--- Project Reboot 3.0/FortGameStateAthena.cpp | 28 +++++ Project Reboot 3.0/FortGameStateAthena.h | 8 ++ Project Reboot 3.0/FortInventory.cpp | 4 +- Project Reboot 3.0/FortLootPackage.cpp | 4 +- Project Reboot 3.0/FortPlayerController.cpp | 22 +++- .../FortPlayerControllerAthena.cpp | 6 +- Project Reboot 3.0/FortSafeZoneIndicator.cpp | 18 +++ Project Reboot 3.0/FortSafeZoneIndicator.h | 13 +++ Project Reboot 3.0/Project Reboot 3.0.vcxproj | 2 + .../Project Reboot 3.0.vcxproj.filters | 27 +++-- Project Reboot 3.0/Vector.h | 3 + Project Reboot 3.0/Vector2D.h | 7 ++ Project Reboot 3.0/World.h | 10 +- Project Reboot 3.0/addresses.cpp | 4 + Project Reboot 3.0/addresses.h | 1 + Project Reboot 3.0/die.h | 2 + Project Reboot 3.0/dllmain.cpp | 13 ++- Project Reboot 3.0/finder.h | 38 +++++- Project Reboot 3.0/globals.h | 1 + Project Reboot 3.0/gui.h | 110 ++++++++++++------ 31 files changed, 477 insertions(+), 93 deletions(-) create mode 100644 Project Reboot 3.0/FortAthenaMapInfo.cpp create mode 100644 Project Reboot 3.0/Vector2D.h diff --git a/Project Reboot 3.0/FortAthenaMapInfo.cpp b/Project Reboot 3.0/FortAthenaMapInfo.cpp new file mode 100644 index 0000000..2a8b509 --- /dev/null +++ b/Project Reboot 3.0/FortAthenaMapInfo.cpp @@ -0,0 +1,84 @@ +#include "FortAthenaMapInfo.h" +#include "GameplayStatics.h" +#include "FortAthenaSupplyDrop.h" +#include "FortGameModeAthena.h" +#include "Vector2D.h" + +FVector2D GenerateRandomVector2D(float Radius) +{ + float v3; + float v4; + + do + { + v3 = (float)((float)rand() * 0.000061037019) - 1.0; + v4 = (float)((float)rand() * 0.000061037019) - 1.0; + } while ((float)((float)(v4 * v4) + (float)(v3 * v3)) > 1.0); + + return FVector2D(v3 * Radius, v4 * Radius); +} + +FVector AFortAthenaMapInfo::PickSupplyDropLocation(FVector Center, float Radius) +{ + static FVector* (*PickSupplyDropLocationOriginal)(AFortAthenaMapInfo* MapInfo, FVector* outLocation, __int64 Center, float Radius) = decltype(PickSupplyDropLocationOriginal)(Addresses::PickSupplyDropLocation); + + if (!PickSupplyDropLocationOriginal) + return FVector(0, 0, 0); + + // LOG_INFO(LogDev, "GetAircraftDropVolume: {}", __int64(GetAircraftDropVolume())); + + FVector Out = FVector(0, 0, 0); + auto ahh = PickSupplyDropLocationOriginal(this, &Out, __int64(&Center), Radius); + return Out; +} + +void AFortAthenaMapInfo::SpawnLlamas() +{ + if (!GetLlamaClass()) + { + // LOG_INFO(LogDev, "No Llama Class, is this intended?"); + return; + } + + auto AmountOfLlamasToSpawn = CalcuateCurveMinAndMax(GetLlamaQuantityMin(), GetLlamaQuantityMax(), 1); + + LOG_INFO(LogDev, "Attempting to spawn {} llamas.", AmountOfLlamasToSpawn); + + for (int i = 0; i < AmountOfLlamasToSpawn; i++) + { + FVector Location = PickSupplyDropLocation(FVector(1, 1, 10000), 30000); + + // LOG_INFO(LogDev, "Initial Llama at {} {} {}", Location.X, Location.Y, Location.Z); + + if (Location == FVector(0, 0, 0)) + continue; + + FRotator RandomYawRotator = FRotator(); + RandomYawRotator.Yaw = (float)rand() * 0.010986663; + + FTransform InitialSpawnTransform; + InitialSpawnTransform.Translation = Location; + InitialSpawnTransform.Rotation = RandomYawRotator.Quaternion(); + InitialSpawnTransform.Scale3D = FVector(1, 1, 1); + + FActorSpawnParameters SpawnParameters{}; + SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + SpawnParameters.bDeferConstruction = true; + + auto LlamaStart = GetWorld()->SpawnActor(GetLlamaClass(), InitialSpawnTransform, SpawnParameters); + + LOG_INFO(LogDev, "LlamaStart: {}", __int64(LlamaStart)); + + if (!LlamaStart) + continue; + + auto GroundLocation = LlamaStart->FindGroundLocationAt(InitialSpawnTransform.Translation); + + FTransform FinalSpawnTransform = InitialSpawnTransform; + FinalSpawnTransform.Translation = GroundLocation; + + LOG_INFO(LogDev, "Spawning Llama at {} {} {}", GroundLocation.X, GroundLocation.Y, GroundLocation.Z); + + UGameplayStatics::FinishSpawningActor(LlamaStart, FinalSpawnTransform); + } +} \ No newline at end of file diff --git a/Project Reboot 3.0/FortAthenaMapInfo.h b/Project Reboot 3.0/FortAthenaMapInfo.h index f5cde36..81fc72c 100644 --- a/Project Reboot 3.0/FortAthenaMapInfo.h +++ b/Project Reboot 3.0/FortAthenaMapInfo.h @@ -6,15 +6,16 @@ #include "GameplayAbilityTypes.h" #include "DataTableFunctionLibrary.h" +#include "SoftObjectPtr.h" -static inline float CalcuateCurveMinAndMax(FScalableFloat* Min, FScalableFloat* Max) // returns 000 not 0.00 (forgot techinal name for this) +static inline float CalcuateCurveMinAndMax(FScalableFloat* Min, FScalableFloat* Max, float Multiplier = 100.f) // returns 000 not 0.00 (forgot techinal name for this) { float MinSpawnPercent = UDataTableFunctionLibrary::EvaluateCurveTableRow(Min->GetCurve().CurveTable, Min->GetCurve().RowName, 0); float MaxSpawnPercent = UDataTableFunctionLibrary::EvaluateCurveTableRow(Max->GetCurve().CurveTable, Max->GetCurve().RowName, 0); std::random_device MinMaxRd; std::mt19937 MinMaxGen(MinMaxRd()); - std::uniform_int_distribution<> MinMaxDis(MinSpawnPercent * 100, MaxSpawnPercent * 100 + 1); // + 1 ? + std::uniform_int_distribution<> MinMaxDis(MinSpawnPercent * Multiplier, MaxSpawnPercent * Multiplier + 1); // + 1 ? float SpawnPercent = MinMaxDis(MinMaxGen); @@ -129,4 +130,35 @@ public: static auto BuildingGameplayActorSpawnDetailsOffset = GetOffset("BuildingGameplayActorSpawnDetails"); return Get>(BuildingGameplayActorSpawnDetailsOffset); } + + FScalableFloat* GetLlamaQuantityMin() + { + static auto LlamaQuantityMinOffset = GetOffset("LlamaQuantityMin"); + return GetPtr(LlamaQuantityMinOffset); + } + + FScalableFloat* GetLlamaQuantityMax() + { + static auto LlamaQuantityMaxOffset = GetOffset("LlamaQuantityMax"); + return GetPtr(LlamaQuantityMaxOffset); + } + + UClass* GetLlamaClass() + { + static auto LlamaClassOffset = GetOffset("LlamaClass", false); + + if (LlamaClassOffset == -1) + return nullptr; + + return Get(LlamaClassOffset); + } + + AActor*& GetAircraftDropVolume() // actually AVolume + { + static auto AircraftDropVolumeOffset = GetOffset("AircraftDropVolume"); + return Get(AircraftDropVolumeOffset); + } + + FVector PickSupplyDropLocation(FVector Center, float Radius); + void SpawnLlamas(); }; \ No newline at end of file diff --git a/Project Reboot 3.0/FortAthenaMutator.h b/Project Reboot 3.0/FortAthenaMutator.h index f027956..4edc366 100644 --- a/Project Reboot 3.0/FortAthenaMutator.h +++ b/Project Reboot 3.0/FortAthenaMutator.h @@ -30,4 +30,15 @@ static inline void LoopMutators(std::function Callbac } AllMutators.Free(); +} + +template +static inline MutatorType* FindFirstMutator(UClass* MutatorClass = MutatorType::StaticClass()) +{ + auto AllMutators = UGameplayStatics::GetAllActorsOfClass(GetWorld(), MutatorClass); + auto FirstMutator = AllMutators.Num() >= 1 ? AllMutators.at(0) : nullptr; + + AllMutators.Free(); + + return (MutatorType*)FirstMutator; } \ No newline at end of file diff --git a/Project Reboot 3.0/FortAthenaMutator_Barrier.h b/Project Reboot 3.0/FortAthenaMutator_Barrier.h index 7756bb6..a9148eb 100644 --- a/Project Reboot 3.0/FortAthenaMutator_Barrier.h +++ b/Project Reboot 3.0/FortAthenaMutator_Barrier.h @@ -1,3 +1,5 @@ +// Food Fight + #pragma once #include "FortAthenaMutator.h" @@ -5,6 +7,18 @@ #include "AthenaBarrierObjective.h" #include "AthenaBarrierFlag.h" +/* + +EVENT IDS (got on 10.40): + +WallComingDown - 1 +WallDown - 2 +// IDK REST COMPILER WAS TOO SMART +Intro - 9 +NoMoreRespawns - 10 + +*/ + struct FBarrierTeamState // Idk if this actually changes { static UStruct* GetStruct() diff --git a/Project Reboot 3.0/FortAthenaMutator_Disco.cpp b/Project Reboot 3.0/FortAthenaMutator_Disco.cpp index 7982704..b1efd05 100644 --- a/Project Reboot 3.0/FortAthenaMutator_Disco.cpp +++ b/Project Reboot 3.0/FortAthenaMutator_Disco.cpp @@ -2,7 +2,7 @@ void AFortAthenaMutator_Disco::OnGamePhaseStepChangedHook(UObject* Context, FFrame& Stack, void* Ret) { - TScriptInterface SafeZoneInterface; + /* TScriptInterface SafeZoneInterface; EAthenaGamePhaseStep GamePhaseStep = EAthenaGamePhaseStep::BusFlying; static auto SafeZoneInterfaceOffset = FindOffsetStruct("/Script/FortniteGame.FortAthenaMutator_Disco.OnGamePhaseStepChanged", "SafeZoneInterface", false); @@ -10,9 +10,9 @@ void AFortAthenaMutator_Disco::OnGamePhaseStepChangedHook(UObject* Context, FFra if (SafeZoneInterfaceOffset != -1) Stack.StepCompiledIn(&SafeZoneInterface); - // Stack.StepCompiledIn(&GamePhaseStep, true); + Stack.StepCompiledIn(&GamePhaseStep, true); */ - LOG_INFO(LogDev, "{} GamePhaseStep: {}", __FUNCTION__, (int)GamePhaseStep); + // LOG_INFO(LogDev, "{} GamePhaseStep: {}", __FUNCTION__, (int)GamePhaseStep); return OnGamePhaseStepChangedOriginal(Context, Stack, Ret); } \ No newline at end of file diff --git a/Project Reboot 3.0/FortAthenaMutator_Disco.h b/Project Reboot 3.0/FortAthenaMutator_Disco.h index 90acf66..32202ed 100644 --- a/Project Reboot 3.0/FortAthenaMutator_Disco.h +++ b/Project Reboot 3.0/FortAthenaMutator_Disco.h @@ -1,3 +1,5 @@ +// Disco Domination + #pragma once #include "FortAthenaMutator.h" diff --git a/Project Reboot 3.0/FortAthenaMutator_GG.h b/Project Reboot 3.0/FortAthenaMutator_GG.h index 2b16c09..88df036 100644 --- a/Project Reboot 3.0/FortAthenaMutator_GG.h +++ b/Project Reboot 3.0/FortAthenaMutator_GG.h @@ -1,3 +1,5 @@ +// Gun Game + #pragma once #include "Actor.h" diff --git a/Project Reboot 3.0/FortAthenaMutator_Heist.h b/Project Reboot 3.0/FortAthenaMutator_Heist.h index 2b2ef64..808a3e3 100644 --- a/Project Reboot 3.0/FortAthenaMutator_Heist.h +++ b/Project Reboot 3.0/FortAthenaMutator_Heist.h @@ -22,12 +22,18 @@ struct FHeistExitCraftSpawnData : public FFortPieSliceSpawnData class AFortAthenaMutator_Heist : public AFortAthenaMutator { public: - TArray& GetHeistExitCraftSpawnData() + /* TArray& GetHeistExitCraftSpawnData() { static auto HeistExitCraftSpawnDataOffset = GetOffset("HeistExitCraftSpawnData"); return Get>(HeistExitCraftSpawnDataOffset); - } + } */ + float& GetSpawnExitCraftTime() + { + static auto SpawnExitCraftTimeOffset = GetOffset("SpawnExitCraftTime"); + return Get(SpawnExitCraftTimeOffset); + } + static UClass* StaticClass() { static auto Class = FindObject("/Script/FortniteGame.FortAthenaMutator_Heist"); diff --git a/Project Reboot 3.0/FortAthenaSupplyDrop.cpp b/Project Reboot 3.0/FortAthenaSupplyDrop.cpp index fdc5e4f..3b91b49 100644 --- a/Project Reboot 3.0/FortAthenaSupplyDrop.cpp +++ b/Project Reboot 3.0/FortAthenaSupplyDrop.cpp @@ -1,5 +1,20 @@ #include "FortAthenaSupplyDrop.h" +FVector AFortAthenaSupplyDrop::FindGroundLocationAt(FVector InLocation) +{ + static auto FindGroundLocationAtFn = FindObject("/Script/FortniteGame.FortAthenaSupplyDrop.FindGroundLocationAt"); + + struct + { + FVector InLocation; // (ConstParm, Parm, OutParm, ZeroConstructor, ReferenceParm, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) + FVector ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) + } AFortAthenaSupplyDrop_FindGroundLocationAt_Params{ InLocation }; + + this->ProcessEvent(FindGroundLocationAtFn, &AFortAthenaSupplyDrop_FindGroundLocationAt_Params); + + return AFortAthenaSupplyDrop_FindGroundLocationAt_Params.ReturnValue; +} + AFortPickup* AFortAthenaSupplyDrop::SpawnPickupFromItemEntryHook(UObject* Context, FFrame& Stack, AFortPickup** Ret) { LOG_INFO(LogDev, __FUNCTION__); diff --git a/Project Reboot 3.0/FortAthenaSupplyDrop.h b/Project Reboot 3.0/FortAthenaSupplyDrop.h index fbf92da..2fbc176 100644 --- a/Project Reboot 3.0/FortAthenaSupplyDrop.h +++ b/Project Reboot 3.0/FortAthenaSupplyDrop.h @@ -12,6 +12,8 @@ public: static inline AFortPickup* (*SpawnGameModePickupOriginal)(UObject* Context, FFrame& Stack, AFortPickup** Ret); static inline AFortPickup* (*SpawnPickupFromItemEntryOriginal)(UObject* Context, FFrame& Stack, AFortPickup** Ret); + FVector FindGroundLocationAt(FVector InLocation); + static AFortPickup* SpawnPickupFromItemEntryHook(UObject* Context, FFrame& Stack, AFortPickup** Ret); static AFortPickup* SpawnGameModePickupHook(UObject* Context, FFrame& Stack, AFortPickup** Ret); static AFortPickup* SpawnPickupHook(UObject* Context, FFrame& Stack, AFortPickup** Ret); diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index f61f229..00b2dcc 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -480,11 +480,6 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game { LastNum = AmountOfRestarts; - float Duration = 10000.f; - float EarlyDuration = Duration; - - float TimeSeconds = UGameplayStatics::GetTimeSeconds(GetWorld()); - LOG_INFO(LogDev, "Initializing!"); if (std::floor(Fortnite_Version) == 3) @@ -492,6 +487,11 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game LOG_INFO(LogDev, "GameMode 0x{:x}", __int64(GameMode)); + float Duration = 100000.f; + float EarlyDuration = Duration; + + float TimeSeconds = UGameplayStatics::GetTimeSeconds(GetWorld()); + static auto WarmupCountdownEndTimeOffset = GameState->GetOffset("WarmupCountdownEndTime"); static auto WarmupCountdownStartTimeOffset = GameState->GetOffset("WarmupCountdownStartTime"); static auto WarmupCountdownDurationOffset = GameMode->GetOffset("WarmupCountdownDuration"); @@ -729,6 +729,7 @@ int AFortGameModeAthena::Athena_PickTeamHook(AFortGameModeAthena* GameMode, uint static int CurrentTeamMembers = 0; // bad static int Current = DefaultFirstTeam; + static int NextTeamIndex = DefaultFirstTeam; static int LastNum = 1; @@ -737,6 +738,7 @@ int AFortGameModeAthena::Athena_PickTeamHook(AFortGameModeAthena* GameMode, uint LastNum = Globals::AmountOfListens; Current = DefaultFirstTeam; + NextTeamIndex = DefaultFirstTeam; CurrentTeamMembers = 0; } @@ -781,8 +783,6 @@ int AFortGameModeAthena::Athena_PickTeamHook(AFortGameModeAthena* GameMode, uint TeamsNum = 100; } - static int NextTeamIndex = DefaultFirstTeam; - LOG_INFO(LogTeams, "Before team assigning NextTeamIndex: {} CurrentTeamMembers: {}", NextTeamIndex, CurrentTeamMembers); if (!bShouldSpreadTeams) @@ -829,6 +829,34 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena LOG_INFO(LogPlayer, "HandleStartingNewPlayer!"); + if (Globals::bAutoRestart) + { + static int LastNum123 = 15; + + if (GetWorld()->GetNetDriver()->GetClientConnections().Num() >= NumRequiredPlayersToStart && LastNum123 != Globals::AmountOfListens) + { + LastNum123 = Globals::AmountOfListens; + + float Duration = AutoBusStartSeconds; + float EarlyDuration = Duration; + + float TimeSeconds = UGameplayStatics::GetTimeSeconds(GetWorld()); + + static auto WarmupCountdownEndTimeOffset = GameState->GetOffset("WarmupCountdownEndTime"); + static auto WarmupCountdownStartTimeOffset = GameState->GetOffset("WarmupCountdownStartTime"); + static auto WarmupCountdownDurationOffset = GameMode->GetOffset("WarmupCountdownDuration"); + static auto WarmupEarlyCountdownDurationOffset = GameMode->GetOffset("WarmupEarlyCountdownDuration"); + + GameState->Get(WarmupCountdownEndTimeOffset) = TimeSeconds + Duration; + GameMode->Get(WarmupCountdownDurationOffset) = Duration; + + GameState->Get(WarmupCountdownStartTimeOffset) = TimeSeconds; + GameMode->Get(WarmupEarlyCountdownDurationOffset) = EarlyDuration; + + LOG_INFO(LogDev, "Auto starting bus in {}.", AutoBusStartSeconds); + } + } + // if (Engine_Version < 427) { static int LastNum69 = 19451; @@ -837,11 +865,14 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena { LastNum69 = Globals::AmountOfListens; - bool bShouldDestroyVendingMachines = Fortnite_Version < 3.4 || Engine_Version >= 424; // This is not how it works, we need to add the spawn percentage. + // is there spawn percentage for vending machines? - if (!bShouldDestroyVendingMachines) // idk how to set the mat count sooooo problem for later me + bool bShouldDestroyVendingMachines = Fortnite_Version < 3.4 || Engine_Version >= 424; + + if (!bShouldDestroyVendingMachines) { - FillVendingMachines(); + if (Globals::bFillVendingMachines) + FillVendingMachines(); } else { @@ -861,15 +892,21 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena AllVendingMachines.Free(); } - SpawnBGAs(); + if (Fortnite_Version < 19) // fr idk what i did too lazy to debug + SpawnBGAs(); // Handle spawn rate - if (false) - { - auto MapInfo = GameState->GetMapInfo(); + auto MapInfo = GameState->GetMapInfo(); - if (MapInfo) + if (MapInfo) + { + if (Fortnite_Version >= 3.3) + { + MapInfo->SpawnLlamas(); + } + + if (false) { float AmmoBoxMinSpawnPercent = UDataTableFunctionLibrary::EvaluateCurveTableRow( MapInfo->GetAmmoBoxMinSpawnPercent()->GetCurve().CurveTable, MapInfo->GetAmmoBoxMinSpawnPercent()->GetCurve().RowName, 0 diff --git a/Project Reboot 3.0/FortGameStateAthena.cpp b/Project Reboot 3.0/FortGameStateAthena.cpp index 7374ba8..712e1dc 100644 --- a/Project Reboot 3.0/FortGameStateAthena.cpp +++ b/Project Reboot 3.0/FortGameStateAthena.cpp @@ -3,6 +3,7 @@ #include "reboot.h" #include "FortPlayerStateAthena.h" #include "FortGameModeAthena.h" +#include "FortAthenaMutator.h" /* void AFortGameStateAthena::AddPlayerStateToGameMemberInfo(class AFortPlayerStateAthena* PlayerState) { @@ -36,6 +37,33 @@ TScriptInterface AFortGameStateAthena::GetSafeZoneInterf return ScriptInterface; } +void AFortGameStateAthena::SetGamePhaseStep(EAthenaGamePhaseStep NewGamePhaseStep) +{ + this->GetGamePhaseStep() = NewGamePhaseStep; + + std::vector> FunctionsToCall; + + LoopMutators([&](AFortAthenaMutator* Mutator) { FunctionsToCall.push_back(std::make_pair(Mutator, Mutator->FindFunction("OnGamePhaseStepChanged"))); }); + + for (auto& FunctionToCallPair : FunctionsToCall) + { + // On newer versions there is a second param. + + LOG_INFO(LogDev, "A1: {} FunctionToCallPair.second: {}", FunctionToCallPair.first->IsValidLowLevel() ? FunctionToCallPair.first->GetFullName() : "BadRead", __int64(FunctionToCallPair.second)); + + if (FunctionToCallPair.second->IsValidLowLevel() && FunctionToCallPair.first->IsValidLowLevel()) + { + auto Params = ConstructOnGamePhaseStepChangedParams(NewGamePhaseStep); + + if (Params) + { + FunctionToCallPair.first->ProcessEvent(FunctionToCallPair.second, Params); + VirtualFree(Params, 0, MEM_RELEASE); + } + } + } +} + UFortPlaylist*& AFortGameStateAthena::GetCurrentPlaylist() { static auto CurrentPlaylistInfoOffset = GetOffset("CurrentPlaylistInfo", false); diff --git a/Project Reboot 3.0/FortGameStateAthena.h b/Project Reboot 3.0/FortGameStateAthena.h index 5e57316..efa0816 100644 --- a/Project Reboot 3.0/FortGameStateAthena.h +++ b/Project Reboot 3.0/FortGameStateAthena.h @@ -86,6 +86,14 @@ public: return Get(MapInfoOffset); } + EAthenaGamePhaseStep& GetGamePhaseStep() + { + static auto GamePhaseStepOffset = GetOffset("GamePhaseStep"); + return Get(GamePhaseStepOffset); + } + + void SetGamePhaseStep(EAthenaGamePhaseStep NewGamePhaseStep); + UFortPlaylist*& GetCurrentPlaylist(); TScriptInterface GetSafeZoneInterface(); diff --git a/Project Reboot 3.0/FortInventory.cpp b/Project Reboot 3.0/FortInventory.cpp index 475a0f9..e657bf8 100644 --- a/Project Reboot 3.0/FortInventory.cpp +++ b/Project Reboot 3.0/FortInventory.cpp @@ -172,7 +172,7 @@ std::pair, std::vector> AFortInventory::AddI if (PickaxeInstance) { - RemoveItem(PickaxeInstance->GetItemEntry()->GetItemGuid(), nullptr, PickaxeInstance->GetItemEntry()->GetCount(), true); + // RemoveItem(PickaxeInstance->GetItemEntry()->GetItemGuid(), nullptr, PickaxeInstance->GetItemEntry()->GetCount(), true); Update(); } } @@ -359,7 +359,7 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int if (Fortnite_Version < 7) { - FortPlayerController->AddPickaxeToInventory(); + // FortPlayerController->AddPickaxeToInventory(); } } } diff --git a/Project Reboot 3.0/FortLootPackage.cpp b/Project Reboot 3.0/FortLootPackage.cpp index e3fdda4..fa6a753 100644 --- a/Project Reboot 3.0/FortLootPackage.cpp +++ b/Project Reboot 3.0/FortLootPackage.cpp @@ -82,7 +82,7 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs { std::vector LootDrops; - if (recursive > 10) + if (recursive > 6) return LootDrops; auto GameState = ((AFortGameModeAthena*)GetWorld()->GetGameMode())->GetGameStateAthena(); @@ -505,7 +505,7 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs if (ChosenLootPackageName.contains(".Empty")) // I don't think? { - return PickLootDrops(TierGroupName, bPrint); + return PickLootDrops(TierGroupName, bPrint, ++recursive); // return LootDrops; } diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 52b0f11..74deb50 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -586,8 +586,6 @@ void AFortPlayerController::ServerAttemptAircraftJumpHook(AFortPlayerController* if (Fortnite_Version == 17.30 && Globals::bGoingToPlayEvent) return ServerAttemptAircraftJumpOriginal(PC, ClientRotation); // We want to be teleported back to the UFO but we dont use chooseplayerstart - LOG_INFO(LogDev, "PlayerController: {}", __int64(PlayerController)); - if (!PlayerController) return ServerAttemptAircraftJumpOriginal(PC, ClientRotation); @@ -597,13 +595,25 @@ void AFortPlayerController::ServerAttemptAircraftJumpHook(AFortPlayerController* auto GameMode = (AFortGameModeAthena*)GetWorld()->GetGameMode(); auto GameState = GameMode->GetGameStateAthena(); - static auto AircraftsOffset = GameState->GetOffset("Aircrafts"); - auto Aircrafts = GameState->GetPtr>(AircraftsOffset); + AActor* AircraftToJumpFrom = nullptr; - if (Aircrafts->Num() <= 0) + static auto AircraftsOffset = GameState->GetOffset("Aircrafts", false); + + if (AircraftsOffset == -1) + { + static auto AircraftOffset = GameState->GetOffset("Aircraft"); + AircraftToJumpFrom = GameState->Get(AircraftOffset); + } + else + { + auto Aircrafts = GameState->GetPtr>(AircraftsOffset); + AircraftToJumpFrom = Aircrafts->Num() > 0 ? Aircrafts->at(0) : nullptr; + } + + if (!AircraftToJumpFrom) return ServerAttemptAircraftJumpOriginal(PC, ClientRotation); - auto NewPawn = GameMode->SpawnDefaultPawnForHook(GameMode, (AController*)PlayerController, Aircrafts->at(0)); + auto NewPawn = GameMode->SpawnDefaultPawnForHook(GameMode, (AController*)PlayerController, AircraftToJumpFrom); PlayerController->Possess(NewPawn); auto NewPawnAsFort = Cast(NewPawn); diff --git a/Project Reboot 3.0/FortPlayerControllerAthena.cpp b/Project Reboot 3.0/FortPlayerControllerAthena.cpp index 3966055..86e0bbd 100644 --- a/Project Reboot 3.0/FortPlayerControllerAthena.cpp +++ b/Project Reboot 3.0/FortPlayerControllerAthena.cpp @@ -149,11 +149,7 @@ void AFortPlayerControllerAthena::EnterAircraftHook(UObject* PC, AActor* Aircraf WorldInventory->RemoveItem(Pair.first, nullptr, Pair.second, true); } - static auto mutatorClass = FindObject("/Script/FortniteGame.FortAthenaMutator"); - auto AllMutators = UGameplayStatics::GetAllActorsOfClass(GetWorld(), mutatorClass); - std::vector> FunctionsToCall; - LoopMutators([&](AFortAthenaMutator* Mutator) { FunctionsToCall.push_back(std::make_pair(Mutator, Mutator->FindFunction("OnGamePhaseStepChanged"))); }); auto HandleGiveItemsAtGamePhaseStepMutator = [&](AFortAthenaMutator* Mutator) { @@ -162,7 +158,7 @@ void AFortPlayerControllerAthena::EnterAircraftHook(UObject* PC, AActor* Aircraf auto PhaseToGive = GiveItemsAtGamePhaseStepMutator->GetPhaseToGiveItems(); auto& ItemsToGive = GiveItemsAtGamePhaseStepMutator->GetItemsToGive(); - // LOG_INFO(LogDev, "[{}] PhaseToGiveItems: {} ItemsToGive.Num(): {}", i, (int)PhaseToGive, ItemsToGive.Num()); + LOG_INFO(LogDev, "PhaseToGiveItems: {} ItemsToGive.Num(): {}", (int)PhaseToGive, ItemsToGive.Num()); if (PhaseToGive <= 5) // Flying or lower { diff --git a/Project Reboot 3.0/FortSafeZoneIndicator.cpp b/Project Reboot 3.0/FortSafeZoneIndicator.cpp index e91b3a3..ef03c1e 100644 --- a/Project Reboot 3.0/FortSafeZoneIndicator.cpp +++ b/Project Reboot 3.0/FortSafeZoneIndicator.cpp @@ -9,4 +9,22 @@ void AFortSafeZoneIndicator::SkipShrinkSafeZone() GetSafeZoneStartShrinkTime() = GameState->GetServerWorldTimeSeconds(); GetSafeZoneFinishShrinkTime() = GameState->GetServerWorldTimeSeconds() + 0.2; +} + +void AFortSafeZoneIndicator::OnSafeZoneStateChangeHook(AFortSafeZoneIndicator* SafeZoneIndicator, EFortSafeZoneState NewState, bool bInitial) +{ + auto GameState = Cast(GetWorld()->GetGameState()); + + LOG_INFO(LogDev, "OnSafeZoneStateChangeHook!"); + + if (NewState == EFortSafeZoneState::Shrinking) + { + GameState->SetGamePhaseStep(EAthenaGamePhaseStep::StormShrinking); + } + else if (NewState == EFortSafeZoneState::Holding) + { + GameState->SetGamePhaseStep(EAthenaGamePhaseStep::StormHolding); + } + + return OnSafeZoneStateChangeOriginal(SafeZoneIndicator, NewState, bInitial); } \ No newline at end of file diff --git a/Project Reboot 3.0/FortSafeZoneIndicator.h b/Project Reboot 3.0/FortSafeZoneIndicator.h index c5cf5ba..e7e3a9f 100644 --- a/Project Reboot 3.0/FortSafeZoneIndicator.h +++ b/Project Reboot 3.0/FortSafeZoneIndicator.h @@ -2,9 +2,20 @@ #include "Actor.h" +enum class EFortSafeZoneState : uint8_t +{ + None = 0, + Starting = 1, + Holding = 2, + Shrinking = 3, + EFortSafeZoneState_MAX = 4 +}; + class AFortSafeZoneIndicator : public AActor { public: + static inline void (*OnSafeZoneStateChangeOriginal)(AFortSafeZoneIndicator* SafeZoneIndicator, EFortSafeZoneState NewState, bool bInitial); + float& GetSafeZoneStartShrinkTime() { static auto SafeZoneStartShrinkTimeOffset = GetOffset("SafeZoneStartShrinkTime"); @@ -18,4 +29,6 @@ public: } void SkipShrinkSafeZone(); + + static void OnSafeZoneStateChangeHook(AFortSafeZoneIndicator* SafeZoneIndicator, EFortSafeZoneState NewState, bool bInitial); }; \ No newline at end of file diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj b/Project Reboot 3.0/Project Reboot 3.0.vcxproj index 5014221..7d76d7b 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj @@ -194,6 +194,7 @@ + @@ -444,6 +445,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 c82a0d6..c05dbd0 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -107,7 +107,7 @@ FortniteGame\Source\FortniteGame\Private\Pawns - FortniteGame\Source\FortniteGame\Public\Private\Gameplay + Reboot\Private\Gameplay FortniteGame\Source\FortniteGame\Private\Player @@ -140,7 +140,7 @@ Engine\Source\Runtime\Engine\Private - FortniteGame\Source\FortniteGame\Public\Private + Reboot\Private Engine\Source\Runtime\Engine\Classes\Engine @@ -265,6 +265,9 @@ FortniteGame\Source\FortniteGame\Private\Building + + FortniteGame\Source\FortniteGame\Private + @@ -826,9 +829,6 @@ Engine\Source\Runtime\CoreUObject\Public\UObject - - Engine\Source\Runtime\Core\Public\Misc - FortniteGame\Source\FortniteGame\Public\Athena\Vehicle @@ -842,6 +842,12 @@ FortniteGame\Source\FortniteGame\Public\Building + + Engine\Source\Runtime\Core\Public\Math + + + Engine\Source\Runtime\Core\Public\Math + @@ -1051,12 +1057,6 @@ {2eee3380-ea4b-4137-b058-b57a7b66005e} - - {563ca89b-be74-42a6-a995-f87ac7a532e4} - - - {52d438db-beaf-44be-bddd-9aeb07c2459f} - {af212a31-57d1-4345-a73f-cd28dc4ebd2f} @@ -1082,7 +1082,10 @@ {c04eb59f-e186-49a3-a145-1fd3dc1dcd3d} - {00ba0f86-7eef-4ffd-9a9d-47477e5193b2} + {563ca89b-be74-42a6-a995-f87ac7a532e4} + + + {52d438db-beaf-44be-bddd-9aeb07c2459f} diff --git a/Project Reboot 3.0/Vector.h b/Project Reboot 3.0/Vector.h index 6c6ec61..f00e925 100644 --- a/Project Reboot 3.0/Vector.h +++ b/Project Reboot 3.0/Vector.h @@ -7,6 +7,9 @@ public: float Y; float Z; + FVector() : X(0), Y(0), Z(0) {} + FVector(float x, float y, float z) : X(x), Y(y), Z(z) {} + FVector operator+(const FVector& A) { return FVector{ this->X + A.X, this->Y + A.Y, this->Z + A.Z }; diff --git a/Project Reboot 3.0/Vector2D.h b/Project Reboot 3.0/Vector2D.h new file mode 100644 index 0000000..65b2d40 --- /dev/null +++ b/Project Reboot 3.0/Vector2D.h @@ -0,0 +1,7 @@ +#pragma once + +struct FVector2D +{ + float X; + float Y; +}; \ No newline at end of file diff --git a/Project Reboot 3.0/World.h b/Project Reboot 3.0/World.h index 9e8f9cc..c0bcd52 100644 --- a/Project Reboot 3.0/World.h +++ b/Project Reboot 3.0/World.h @@ -41,18 +41,24 @@ public: static inline UObject* (*SpawnActorOriginal)(UWorld* World, UClass* Class, FTransform const* UserTransformPtr, const FActorSpawnParameters& SpawnParameters); template - T* GetGameMode() + T*& GetGameMode() { static auto AuthorityGameModeOffset = GetOffset("AuthorityGameMode"); return this->Get(AuthorityGameModeOffset); } - class AGameState* GetGameState() + class AGameState*& GetGameState() { static auto GameStateOffset = GetOffset("GameState"); return this->Get(GameStateOffset); } + class UNetDriver*& GetNetDriver() + { + static auto NetDriverOffset = GetOffset("NetDriver"); + return this->Get(NetDriverOffset); + } + UGameInstance* GetOwningGameInstance() { static auto OwningGameInstanceOffset = GetOffset("OwningGameInstance"); diff --git a/Project Reboot 3.0/addresses.cpp b/Project Reboot 3.0/addresses.cpp index 9f4450d..f90b131 100644 --- a/Project Reboot 3.0/addresses.cpp +++ b/Project Reboot 3.0/addresses.cpp @@ -288,6 +288,9 @@ void Addresses::FindAll() LOG_INFO(LogDev, "Finding CreateBuildingActorCallForDeco"); Addresses::CreateBuildingActorCallForDeco = FindCreateBuildingActorCallForDeco(); + LOG_INFO(LogDev, "Finding PickSupplyDropLocation"); + Addresses::PickSupplyDropLocation = FindPickSupplyDropLocation(); + LOG_INFO(LogDev, "Finished finding!"); } @@ -353,6 +356,7 @@ void Addresses::Print() LOG_INFO(LogDev, "UpdateTrackedAttributesLea: 0x{:x}", UpdateTrackedAttributesLea - Base); LOG_INFO(LogDev, "CombinePickupLea: 0x{:x}", CombinePickupLea - Base); LOG_INFO(LogDev, "CreateBuildingActorCallForDeco: 0x{:x}", CreateBuildingActorCallForDeco - Base); + LOG_INFO(LogDev, "PickSupplyDropLocation: 0x{:x}", PickSupplyDropLocation - Base); } void Offsets::FindAll() diff --git a/Project Reboot 3.0/addresses.h b/Project Reboot 3.0/addresses.h index 237fdfa..abe7fd8 100644 --- a/Project Reboot 3.0/addresses.h +++ b/Project Reboot 3.0/addresses.h @@ -68,6 +68,7 @@ namespace Addresses extern inline uint64 UpdateTrackedAttributesLea = 0; extern inline uint64 CombinePickupLea = 0; extern inline uint64 CreateBuildingActorCallForDeco = 0; + extern inline uint64 PickSupplyDropLocation = 0; void SetupVersion(); // Finds Engine Version void FindAll(); diff --git a/Project Reboot 3.0/die.h b/Project Reboot 3.0/die.h index 48d6623..44c6dbb 100644 --- a/Project Reboot 3.0/die.h +++ b/Project Reboot 3.0/die.h @@ -22,6 +22,8 @@ static void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int Override auto GameState = Cast(GameModeAthena->GetGameState()); + LOG_INFO(LogDev, "GamePhaseStep: {}", (int)GameState->GetGamePhaseStep()); + if (Globals::bLateGame) { static auto GameMode_SafeZonePhaseOffset = GameModeAthena->GetOffset("SafeZonePhase"); diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index 25866dc..ed71542 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -778,12 +778,13 @@ DWORD WINAPI Main(LPVOID) AddVehicleHook(); - // if (Fortnite_Version > 1.8 || Fortnite_Version == 1.11) - { - auto ClientOnPawnDiedCallAddr = FindFunctionCall(L"ClientOnPawnDied", Engine_Version == 416 ? std::vector{ 0x48, 0x89, 0x54 } : std::vector{ 0x48, 0x89, 0x5C }); - LOG_INFO(LogDev, "ClientOnPawnDiedCallAddr: 0x{:x}", ClientOnPawnDiedCallAddr - __int64(GetModuleHandleW(0))); - Hooking::MinHook::Hook((PVOID)ClientOnPawnDiedCallAddr, AFortPlayerController::ClientOnPawnDiedHook, (PVOID*)&AFortPlayerController::ClientOnPawnDiedOriginal); - } + auto ClientOnPawnDiedCallAddr = FindFunctionCall(L"ClientOnPawnDied", Engine_Version == 416 ? std::vector{ 0x48, 0x89, 0x54 } : std::vector{ 0x48, 0x89, 0x5C }); + LOG_INFO(LogDev, "ClientOnPawnDiedCallAddr: 0x{:x}", ClientOnPawnDiedCallAddr - __int64(GetModuleHandleW(0))); + Hooking::MinHook::Hook((PVOID)ClientOnPawnDiedCallAddr, AFortPlayerController::ClientOnPawnDiedHook, (PVOID*)&AFortPlayerController::ClientOnPawnDiedOriginal); + + auto OnSafeZoneStateChangeAddr = FindFunctionCall(L"OnSafeZoneStateChange", Engine_Version == 416 ? std::vector{ 0x48, 0x89, 0x54 } : std::vector{ 0x48, 0x89, 0x5C }); + LOG_INFO(LogDev, "OnSafeZoneStateChangeAddr: 0x{:x}", OnSafeZoneStateChangeAddr - __int64(GetModuleHandleW(0))); + Hooking::MinHook::Hook((PVOID)OnSafeZoneStateChangeAddr, AFortSafeZoneIndicator::OnSafeZoneStateChangeHook, (PVOID*)&AFortSafeZoneIndicator::OnSafeZoneStateChangeOriginal); LOG_INFO(LogDev, "PredictionKeySize: 0x{:x} {}", PredictionKeySize, PredictionKeySize); diff --git a/Project Reboot 3.0/finder.h b/Project Reboot 3.0/finder.h index 2f3235b..e365710 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -147,7 +147,14 @@ static inline uint64 FindPickupInitialize() if (Engine_Version == 420) return Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 41 56 48 83 EC 20 80 B9 ? ? ? ? ? 45 0F B6 F1 49 8B E8").Get(); // 4.1 if (Engine_Version == 421) - return Memcury::Scanner::FindPattern("48 89 5C 24 ? 55 57 41 57 48 83 EC 30 80 B9 ? ? ? ? ? 41 0F B6").Get(); // 6.21 + { + auto addr = Memcury::Scanner::FindPattern("48 89 5C 24 ? 55 57 41 57 48 83 EC 30 80 B9 ? ? ? ? ? 41 0F B6", false).Get(); // 6.21 + + if (!addr) + addr = Memcury::Scanner::FindPattern("48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 80 B9 ? ? ? ? ? 41 0F B6 E9").Get(); // 5.41 + + return addr; + } if (Engine_Version == 422) return Memcury::Scanner::FindPattern("48 89 5C 24 ? 57 41 56 41 57 48 83 EC 30 80 B9 ? ? ? ? ? 45 0F B6 F1").Get(); // 7.30 if (Engine_Version == 423) @@ -235,6 +242,26 @@ static inline uint64 FindInitHost() return FindBytes(Addr, (Engine_Version == 427 ? std::vector{ 0x48, 0x8B, 0x5C } : std::vector{ 0x48, 0x8B, 0xC4 }), 1000, 0, true); } +static inline uint64 FindPickSupplyDropLocation() +{ + auto Addrr = Memcury::Scanner::FindStringRef(L"PickSupplyDropLocation: Failed to find valid location using rejection. Using safe zone location.", true, 0).Get(); + + if (!Addrr) + return 0; + + // Newer versions it is "AFortAthenaMapInfo::PickSupplyDropLocation" (no wide str), but they also changed params so ill add later. + + for (int i = 0; i < 1000; i++) + { + if (*(uint8_t*)(uint8_t*)(Addrr - i) == 0x48 && *(uint8_t*)(uint8_t*)(Addrr - i + 1) == 0x89 && *(uint8_t*)(uint8_t*)(Addrr - i + 2) == 0x5C) + { + return Addrr - i; + } + } + + return 0; +} + static inline uint64 FindPauseBeaconRequests() { if (Engine_Version == 500) @@ -251,6 +278,9 @@ static inline uint64 FindPauseBeaconRequests() if (Engine_Version == 420) return Memcury::Scanner::FindPattern("40 53 48 83 EC 30 48 8B D9 84 D2 74 68 80 3D ? ? ? ? ? 72 2C 48 8B 05 ? ? ? ? 4C 8D 44").Get(); + if (Fortnite_Version == 6.30 || Fortnite_Version == 6.31) // bro for real! (i think its cuz theres like 3 refs to the same string) + return Memcury::Scanner::FindPattern("40 53 48 83 EC 30 48 8B D9 84 D2 74 68 80 3D").Get(); + if (Engine_Version == 419) { auto aa = Memcury::Scanner::FindPattern("40 53 48 83 EC 30 48 8B D9 84 D2 74 6F 80 3D", false).Get(); @@ -725,6 +755,8 @@ static inline uint64 FindNoMCP() static inline uint64 FindSetZoneToIndex() // actually StartNewSafeZonePhase { + if (Engine_Version == 419) + return Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 70 48 8B B9 ? ? ? ? 33 DB 0F 29 74 24 ? 48 8B F1 48 85 FF 74 2C E8").Get(); // 1.11 if (Engine_Version == 420) return Memcury::Scanner::FindPattern("E8 ? ? ? ? EB 31 80 B9 ? ? ? ? ?").RelativeOffset(1).Get(); // 3.5 if (Engine_Version == 422) @@ -1474,7 +1506,7 @@ static inline uint64 FindPickTeam() auto testAddr = Memcury::Scanner::FindPattern("88 54 24 10 53 56 41 54 41 55 41 56 48 83 EC 60 4C 8B A1", false).Get(); // 14.60 what is happening lol ???? if (!testAddr) - testAddr = Memcury::Scanner::FindPattern("88 54 24 10 53 55 56 41 55 41 56 48 83 EC 70 48 8B", false).Get(); // 15.10 + testAddr = Memcury::Scanner::FindPattern("88 54 24 10 53 55 56 41 55 41 ? 48 83 EC 70 48", false).Get(); // 15.10 & 15.50 if (testAddr) return testAddr; @@ -1640,7 +1672,7 @@ static inline uint64 FindCantBuild() static inline uint64 FindReplaceBuildingActor() { - auto StringRef = Memcury::Scanner::FindStringRef(L"STAT_Fort_BuildingSMActorReplaceBuildingActor"); + auto StringRef = Memcury::Scanner::FindStringRef(L"STAT_Fort_BuildingSMActorReplaceBuildingActor", false); if (!StringRef.Get()) // we are on a version where stats dont exist { diff --git a/Project Reboot 3.0/globals.h b/Project Reboot 3.0/globals.h index 171c79c..2d37eba 100644 --- a/Project Reboot 3.0/globals.h +++ b/Project Reboot 3.0/globals.h @@ -21,6 +21,7 @@ namespace Globals extern inline bool bInitializedPlaylist = false; extern inline bool bStartedListening = false; extern inline bool bAutoRestart = true; + extern inline bool bFillVendingMachines = true; extern inline int AmountOfListens = 0; // TODO: Switch to this for LastNum } diff --git a/Project Reboot 3.0/gui.h b/Project Reboot 3.0/gui.h index abd7031..d192b86 100644 --- a/Project Reboot 3.0/gui.h +++ b/Project Reboot 3.0/gui.h @@ -56,9 +56,11 @@ #define LOADOUT_PLAYERTAB 4 #define FUN_PLAYERTAB 5 -static inline int SecondsUntilTravel = 5; -static inline bool bSwitchedInitialLevel = false; +extern inline int SecondsUntilTravel = 5; +extern inline bool bSwitchedInitialLevel = false; extern inline bool bIsInAutoRestart = false; +extern inline float AutoBusStartSeconds = 60; +extern inline int NumRequiredPlayersToStart = 2; // THE BASE CODE IS FROM IMGUI GITHUB @@ -264,6 +266,12 @@ static inline void StaticUI() if (IsRestartingSupported()) { ImGui::Checkbox("Auto Restart", &Globals::bAutoRestart); + + if (Globals::bAutoRestart) + { + ImGui::InputFloat(std::format("How long after {} players join the bus will start", NumRequiredPlayersToStart).c_str(), &AutoBusStartSeconds); + ImGui::InputInt("How many players required to join for bus auto timer to start", &NumRequiredPlayersToStart); + } } #ifndef PROD @@ -548,22 +556,32 @@ static inline void MainUI() auto GameMode = (AFortGameMode*)GetWorld()->GetGameMode(); auto GameState = GameMode->GetGameState(); - static auto AircraftsOffset = GameState->GetOffset("Aircrafts"); - UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startaircraft", nullptr); - while (GameState->GetPtr>(AircraftsOffset)->Num() <= 0) // hmm + auto GetAircrafts = [&]() -> TArray + { + static auto AircraftsOffset = GameState->GetOffset("Aircrafts", false); + + if (AircraftsOffset == -1) + { + // GameState->Aircraft + + static auto FortAthenaAircraftClass = FindObject("/Script/FortniteGame.FortAthenaAircraft"); + auto AllAircrafts = UGameplayStatics::GetAllActorsOfClass(GetWorld(), FortAthenaAircraftClass); + + return AllAircrafts; + } + + return GameState->Get>(AircraftsOffset); + }; + + while (GetAircrafts().Num() <= 0) // hmm { Sleep(500); } UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startsafezone", nullptr); - static auto SafeZoneLocationsOffset = GameMode->GetOffset("SafeZoneLocations"); - auto& SafeZoneLocations = GameMode->Get>(SafeZoneLocationsOffset); - - LOG_INFO(LogDev, "SafeZoneLocations.Num(): {}", SafeZoneLocations.Num()); - static auto SafeZoneIndicatorOffset = GameState->GetOffset("SafeZoneIndicator"); static auto SafeZonesStartTimeOffset = GameState->GetOffset("SafeZonesStartTime"); @@ -574,26 +592,44 @@ static inline void MainUI() Sleep(500); } - while (GameState->GetPtr>(AircraftsOffset)->Num() <= 0) // hmm + while (GetAircrafts().Num() <= 0) // hmm { Sleep(500); } - static auto NextNextCenterOffset = GameState->Get(SafeZoneIndicatorOffset)->GetOffset("NextNextCenter"); + static auto NextNextCenterOffset = GameState->Get(SafeZoneIndicatorOffset)->GetOffset("NextNextCenter", false); static auto NextCenterOffset = GameState->Get(SafeZoneIndicatorOffset)->GetOffset("NextCenter"); - FVector LocationToStartAircraft = GameState->Get(SafeZoneIndicatorOffset)->Get(NextNextCenterOffset); // SafeZoneLocations.at(4); + FVector LocationToStartAircraft = GameState->Get(SafeZoneIndicatorOffset)->Get(NextNextCenterOffset == -1 ? NextCenterOffset : NextNextCenterOffset); // SafeZoneLocations.at(4); LocationToStartAircraft.Z += 10000; - for (int i = 0; i < GameState->GetPtr>(AircraftsOffset)->Num(); i++) + for (int i = 0; i < GetAircrafts().Num(); i++) { - GameState->GetPtr>(AircraftsOffset)->at(i)->TeleportTo(LocationToStartAircraft, FRotator()); + auto CurrentAircraft = GetAircrafts().at(i); - static auto FlightInfoOffset = GameState->GetPtr>(AircraftsOffset)->at(i)->GetOffset("FlightInfo"); - auto FlightInfo = GameState->GetPtr>(AircraftsOffset)->at(i)->GetPtr(FlightInfoOffset); + CurrentAircraft->TeleportTo(LocationToStartAircraft, FRotator()); - FlightInfo->GetFlightSpeed() = 0; - FlightInfo->GetFlightStartLocation() = LocationToStartAircraft; - FlightInfo->GetTimeTillDropStart() = 0.0f; + static auto FlightInfoOffset = CurrentAircraft->GetOffset("FlightInfo", false); + + float FlightSpeed = 0.0f; + + if (FlightInfoOffset == -1) + { + static auto FlightStartLocationOffset = CurrentAircraft->GetOffset("FlightStartLocation"); + static auto FlightSpeedOffset = CurrentAircraft->GetOffset("FlightSpeed"); + static auto DropStartTimeOffset = CurrentAircraft->GetOffset("DropStartTime"); + + CurrentAircraft->Get(FlightStartLocationOffset) = LocationToStartAircraft; + CurrentAircraft->Get(FlightSpeedOffset) = FlightSpeed; + CurrentAircraft->Get(DropStartTimeOffset) = GameState->GetServerWorldTimeSeconds(); + } + else + { + auto FlightInfo = CurrentAircraft->GetPtr(FlightInfoOffset); + + FlightInfo->GetFlightSpeed() = FlightSpeed; + FlightInfo->GetFlightStartLocation() = LocationToStartAircraft; + FlightInfo->GetTimeTillDropStart() = 0.0f; + } } static auto MapInfoOffset = GameState->GetOffset("MapInfo"); @@ -601,18 +637,22 @@ static inline void MainUI() if (MapInfo) { - static auto FlightInfosOffset = MapInfo->GetOffset("FlightInfos"); - auto& FlightInfos = MapInfo->Get>(FlightInfosOffset); + static auto FlightInfosOffset = MapInfo->GetOffset("FlightInfos", false); - LOG_INFO(LogDev, "FlightInfos.Num(): {}", FlightInfos.Num()); - - for (int i = 0; i < FlightInfos.Num(); i++) + if (FlightInfosOffset != -1) { - auto FlightInfo = FlightInfos.AtPtr(i, FAircraftFlightInfo::GetStructSize()); + auto& FlightInfos = MapInfo->Get>(FlightInfosOffset); - FlightInfo->GetFlightSpeed() = 0; - FlightInfo->GetFlightStartLocation() = LocationToStartAircraft; - FlightInfo->GetTimeTillDropStart() = 0.0f; + LOG_INFO(LogDev, "FlightInfos.Num(): {}", FlightInfos.Num()); + + for (int i = 0; i < FlightInfos.Num(); i++) + { + auto FlightInfo = FlightInfos.AtPtr(i, FAircraftFlightInfo::GetStructSize()); + + FlightInfo->GetFlightSpeed() = 0; + FlightInfo->GetFlightStartLocation() = LocationToStartAircraft; + FlightInfo->GetTimeTillDropStart() = 0.0f; + } } } @@ -845,6 +885,7 @@ static inline void MainUI() static std::string ClassNameToDump; static std::string FunctionNameToDump; + ImGui::Checkbox("Fill Vending Machines", &Globals::bFillVendingMachines); ImGui::InputText("Class Name to mess with", &ClassNameToDump); ImGui::InputText("Function Name to mess with", &FunctionNameToDump); @@ -864,7 +905,7 @@ static inline void MainUI() } } - if (ImGui::Button("Print Function Exec Addy")) + if (ImGui::Button("Print Function Exec Addr")) { auto Function = FindObject(FunctionNameToDump); @@ -929,9 +970,12 @@ static inline void PregameUI() ImGui::Checkbox("Creative", &Globals::bCreative); } - bool bWillBeLategame = Globals::bLateGame.load(); - ImGui::Checkbox("Lategame", &bWillBeLategame); - Globals::bLateGame.store(bWillBeLategame); + if (Addresses::SetZoneToIndex) + { + bool bWillBeLategame = Globals::bLateGame.load(); + ImGui::Checkbox("Lategame", &bWillBeLategame); + Globals::bLateGame.store(bWillBeLategame); + } if (HasEvent()) {