From 143c22918fc8dd40ee26dbd47fd95cce9ee6b78c Mon Sep 17 00:00:00 2001 From: Milxnor Date: Sun, 21 May 2023 21:10:26 -0400 Subject: [PATCH] add 2.2 code consistency, added 2.2, added cheat op and deop, proper loot tiers according to playlist, improved performance --- Project Reboot 3.0/BuildingContainer.cpp | 6 +- Project Reboot 3.0/BuildingContainer.h | 6 + .../FortAthenaAIBotCharacterCustomization.h | 12 + .../FortAthenaAIBotCustomizationData.h | 20 +- Project Reboot 3.0/FortDagwoodVehicle.h | 19 ++ Project Reboot 3.0/FortGameModeAthena.cpp | 134 ++++------ Project Reboot 3.0/FortGameStateAthena.cpp | 66 ++++- Project Reboot 3.0/FortGameStateAthena.h | 4 +- Project Reboot 3.0/FortLootPackage.cpp | 2 +- Project Reboot 3.0/FortPickup.cpp | 20 +- Project Reboot 3.0/FortPickup.h | 2 +- .../FortPlayerControllerAthena.h | 12 +- Project Reboot 3.0/FortPlayerPawn.cpp | 2 +- .../FortVehicleItemDefinition.h | 51 ++++ Project Reboot 3.0/NetDriver.cpp | 2 +- Project Reboot 3.0/PlayerState.cpp | 6 + Project Reboot 3.0/PlayerState.h | 1 + Project Reboot 3.0/Project Reboot 3.0.vcxproj | 3 +- .../Project Reboot 3.0.vcxproj.filters | 23 +- Project Reboot 3.0/addresses.cpp | 12 +- Project Reboot 3.0/bots.h | 99 ++++++-- Project Reboot 3.0/builder.h | 2 +- Project Reboot 3.0/calendar.h | 8 +- Project Reboot 3.0/commands.h | 30 ++- Project Reboot 3.0/dllmain.cpp | 6 + Project Reboot 3.0/events.cpp | 0 Project Reboot 3.0/gui.h | 233 ++++++++++-------- Project Reboot 3.0/moderation.h | 188 ++++++++++++++ Project Reboot 3.0/vehicles.h | 88 +++++-- 29 files changed, 776 insertions(+), 281 deletions(-) create mode 100644 Project Reboot 3.0/FortDagwoodVehicle.h create mode 100644 Project Reboot 3.0/FortVehicleItemDefinition.h delete mode 100644 Project Reboot 3.0/events.cpp diff --git a/Project Reboot 3.0/BuildingContainer.cpp b/Project Reboot 3.0/BuildingContainer.cpp index 2670f92..585943f 100644 --- a/Project Reboot 3.0/BuildingContainer.cpp +++ b/Project Reboot 3.0/BuildingContainer.cpp @@ -13,11 +13,7 @@ bool ABuildingContainer::SpawnLoot(AFortPawn* Pawn) auto GameMode = Cast(GetWorld()->GetGameMode()); - static auto LootSpawnLocationOffset = this->GetOffset("LootSpawnLocation_Athena"); - - auto LSL = this->Get(LootSpawnLocationOffset); - - FVector LocationToSpawnLoot = this->GetActorLocation() + this->GetActorForwardVector() * LSL.X + this->GetActorRightVector() * LSL.Y + this->GetActorUpVector() * LSL.Z; + FVector LocationToSpawnLoot = this->GetActorLocation() + this->GetActorForwardVector() * this->GetLootSpawnLocation_Athena().X + this->GetActorRightVector() * this->GetLootSpawnLocation_Athena().Y + this->GetActorUpVector() * this->GetLootSpawnLocation_Athena().Z; static auto SearchLootTierGroupOffset = this->GetOffset("SearchLootTierGroup"); auto RedirectedLootTier = GameMode->RedirectLootTier(this->Get(SearchLootTierGroupOffset)); diff --git a/Project Reboot 3.0/BuildingContainer.h b/Project Reboot 3.0/BuildingContainer.h index 14cf097..a116101 100644 --- a/Project Reboot 3.0/BuildingContainer.h +++ b/Project Reboot 3.0/BuildingContainer.h @@ -20,6 +20,12 @@ public: return this->ReadBitfieldValue(bAlreadySearchedOffset, bAlreadySearchedFieldMask); } + FVector& GetLootSpawnLocation_Athena() + { + static auto LootSpawnLocation_AthenaOffset = this->GetOffset("LootSpawnLocation_Athena"); + return this->Get(LootSpawnLocation_AthenaOffset); + } + void SetAlreadySearched(bool bNewValue, bool bOnRep = true) { static auto bAlreadySearchedOffset = this->GetOffset("bAlreadySearched"); diff --git a/Project Reboot 3.0/FortAthenaAIBotCharacterCustomization.h b/Project Reboot 3.0/FortAthenaAIBotCharacterCustomization.h index 6f70f09..ec0e04a 100644 --- a/Project Reboot 3.0/FortAthenaAIBotCharacterCustomization.h +++ b/Project Reboot 3.0/FortAthenaAIBotCharacterCustomization.h @@ -1 +1,13 @@ #pragma once + +#include "Object.h" + +class UFortAthenaAIBotCharacterCustomization : public UObject +{ +public: + FFortAthenaLoadout* GetCustomizationLoadout() + { + static auto CustomizationLoadoutOffset = GetOffset("CustomizationLoadout"); + return GetPtr(CustomizationLoadoutOffset); + } +}; \ No newline at end of file diff --git a/Project Reboot 3.0/FortAthenaAIBotCustomizationData.h b/Project Reboot 3.0/FortAthenaAIBotCustomizationData.h index 002512c..0c43558 100644 --- a/Project Reboot 3.0/FortAthenaAIBotCustomizationData.h +++ b/Project Reboot 3.0/FortAthenaAIBotCustomizationData.h @@ -1,13 +1,31 @@ #pragma once #include "reboot.h" +#include "FortAthenaAIBotCharacterCustomization.h" class UFortAthenaAIBotCustomizationData : public UObject // UPrimaryDataAsset { public: + UFortAthenaAIBotCharacterCustomization*& GetCharacterCustomization() + { + static auto CharacterCustomizationOffset = GetOffset("CharacterCustomization"); + return Get(CharacterCustomizationOffset); + } + + /* static void ApplyOverrideCharacterCustomizationHook(UFortAthenaAIBotCustomizationData* InBotData, AFortPlayerPawn* NewBot, __int64 idk) + { + LOG_INFO(LogDev, "ApplyOverrideCharacterCustomizationHook!"); + + auto CharacterCustomization = InBotData->GetCharacterCustomization(); + + NewBot->GetCosmeticLoadout()->GetCharacter() = CharacterCustomization->GetCustomizationLoadout()->GetCharacter(); + + NewBot->Get(0x1B30) = true; // idk this is like a initialize check + } */ + static UClass* StaticClass() { - static auto Class = FindObject("/Script/FortniteGame.FortAthenaAIBotCustomizationData"); + static auto Class = FindObject(L"/Script/FortniteGame.FortAthenaAIBotCustomizationData"); return Class; } }; \ No newline at end of file diff --git a/Project Reboot 3.0/FortDagwoodVehicle.h b/Project Reboot 3.0/FortDagwoodVehicle.h new file mode 100644 index 0000000..d7f8028 --- /dev/null +++ b/Project Reboot 3.0/FortDagwoodVehicle.h @@ -0,0 +1,19 @@ +#pragma once + +#include "FortAthenaVehicle.h" + +class AFortDagwoodVehicle : public AFortAthenaVehicle // AFortAthenaSKMotorVehicle +{ +public: + void SetFuel(float NewFuel) + { + static auto SetFuelFn = FindObject(L"/Script/ValetRuntime.FortDagwoodVehicle.SetFuel"); + this->ProcessEvent(SetFuelFn, &NewFuel); + } + + static UClass* StaticClass() + { + static auto Class = FindObject(L"/Script/ValetRuntime.FortDagwoodVehicle"); + return Class; + } +}; \ No newline at end of file diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 53e7c18..1a933fd 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -118,7 +118,7 @@ FName AFortGameModeAthena::RedirectLootTier(const FName& LootTier) UClass* AFortGameModeAthena::GetVehicleClassOverride(UClass* DefaultClass) { - static auto GetVehicleClassOverrideFn = FindObject("/Script/FortniteGame.FortGameModeAthena.GetVehicleClassOverride"); + static auto GetVehicleClassOverrideFn = FindObject(L"/Script/FortniteGame.FortGameModeAthena.GetVehicleClassOverride"); if (!GetVehicleClassOverrideFn) return DefaultClass; @@ -593,7 +593,7 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game float Duration = bShouldSkipAircraft ? 0 : 100000; float EarlyDuration = Duration; - float TimeSeconds = UGameplayStatics::GetTimeSeconds(GetWorld()); + float TimeSeconds = GameState->GetServerWorldTimeSeconds(); // UGameplayStatics::GetTimeSeconds(GetWorld()); static auto WarmupCountdownEndTimeOffset = GameState->GetOffset("WarmupCountdownEndTime"); static auto WarmupCountdownStartTimeOffset = GameState->GetOffset("WarmupCountdownStartTime"); @@ -656,22 +656,31 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game if (auto TeamsArrayContainer = GameState->GetTeamsArrayContainer()) { - TeamsArrayContainer->TeamIndexesArray.Free(); + GET_PLAYLIST(GameState); - for (int i = 0; i < 100; i++) - { - TeamsArrayContainer->TeamIndexesArray.Add(INT_MAX); // Bro what - } + int AllTeamsNum = Teams.Num(); // CurrentPlaylist ? - TeamsArrayContainer->SquadIdsArray.Free(); - - for (int i = 0; i < 100; i++) - { - TeamsArrayContainer->SquadIdsArray.Add(INT_MAX); // Bro what - } + LOG_INFO(LogDev, "AllTeamsNum: {}", AllTeamsNum); // We aren't "freeing", it's just not zero'd I guess? + LOG_INFO(LogDev, "TeamsArrayContainer->TeamsArray.Num() Before: {}", TeamsArrayContainer->TeamsArray.Num()); + LOG_INFO(LogDev, "TeamsArrayContainer->SquadsArray.Num() Before: {}", TeamsArrayContainer->SquadsArray.Num()); + + if (TeamsArrayContainer->TeamsArray.Num() != AllTeamsNum) + { + LOG_INFO(LogDev, "Filling TeamsArray!"); + TeamsArrayContainer->TeamsArray.Free(); + TeamsArrayContainer->TeamsArray.AddUninitialized(AllTeamsNum); + } + + if (TeamsArrayContainer->SquadsArray.Num() != AllTeamsNum) + { + LOG_INFO(LogDev, "Filling SquadsArray!"); + TeamsArrayContainer->SquadsArray.Free(); + TeamsArrayContainer->SquadsArray.AddUninitialized(AllTeamsNum); + } + for (int i = 0; i < TeamsArrayContainer->TeamsArray.Num(); i++) { TeamsArrayContainer->TeamsArray.at(i).Free(); @@ -681,6 +690,20 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game { TeamsArrayContainer->SquadsArray.at(i).Free(); } + + TeamsArrayContainer->TeamIndexesArray.Free(); + + for (int i = 0; i < TeamsArrayContainer->TeamsArray.Num(); i++) + { + TeamsArrayContainer->TeamIndexesArray.Add(INT_MAX); // Bro what + } + + TeamsArrayContainer->SquadIdsArray.Free(); + + for (int i = 0; i < TeamsArrayContainer->SquadsArray.Num(); i++) + { + TeamsArrayContainer->SquadIdsArray.Add(INT_MAX); // Bro what + } } auto AllRebootVans = UGameplayStatics::GetAllActorsOfClass(GetWorld(), ABuildingGameplayActorSpawnMachine::StaticClass()); @@ -1132,9 +1155,7 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena for (int i = 0; i < SpawnIsland_FloorLoot_Actors.Num(); i++) { ABuildingContainer* CurrentActor = (ABuildingContainer*)SpawnIsland_FloorLoot_Actors.at(i); - static auto LootSpawnLocationOffset = CurrentActor->GetOffset("LootSpawnLocation_Athena"); - auto LSL = CurrentActor->Get(LootSpawnLocationOffset); - auto Location = CurrentActor->GetActorLocation() + CurrentActor->GetActorForwardVector() * LSL.X + CurrentActor->GetActorRightVector() * LSL.Y + CurrentActor->GetActorUpVector() * LSL.Z; + auto Location = CurrentActor->GetActorLocation() + CurrentActor->GetActorForwardVector() * CurrentActor->GetLootSpawnLocation_Athena().X + CurrentActor->GetActorRightVector() * CurrentActor->GetLootSpawnLocation_Athena().Y + CurrentActor->GetActorUpVector() * CurrentActor->GetLootSpawnLocation_Athena().Z; std::vector LootDrops = PickLootDrops(SpawnIslandTierGroup, GameState->GetWorldLevel(), -1, bPrintWarmup); @@ -1163,9 +1184,8 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena { ABuildingContainer* CurrentActor = (ABuildingContainer*)BRIsland_FloorLoot_Actors.at(i); spawned++; - static auto LootSpawnLocationOffset = CurrentActor->GetOffset("LootSpawnLocation_Athena"); - auto LSL = CurrentActor->Get(LootSpawnLocationOffset); - auto Location = CurrentActor->GetActorLocation() + CurrentActor->GetActorForwardVector() * LSL.X + CurrentActor->GetActorRightVector() * LSL.Y + CurrentActor->GetActorUpVector() * LSL.Z; + + auto Location = CurrentActor->GetActorLocation() + CurrentActor->GetActorForwardVector() * CurrentActor->GetLootSpawnLocation_Athena().X + CurrentActor->GetActorRightVector() * CurrentActor->GetLootSpawnLocation_Athena().Y + CurrentActor->GetActorUpVector() * CurrentActor->GetLootSpawnLocation_Athena().Z; std::vector LootDrops = PickLootDrops(BRIslandTierGroup, GameState->GetWorldLevel(), -1, bPrint); @@ -1214,7 +1234,7 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena static auto CharacterPartsOffset = PlayerStateAthena->GetOffset("CharacterParts", false); static auto CustomCharacterPartsStruct = FindObject(L"/Script/FortniteGame.CustomCharacterParts"); - auto CharacterParts = PlayerStateAthena->GetPtr<__int64>("CharacterParts"); + auto CharacterParts = PlayerStateAthena->GetPtr<__int64>(CharacterPartsOffset); static auto PartsOffset = FindOffsetStruct("/Script/FortniteGame.CustomCharacterParts", "Parts", false); auto Parts = (UObject**)(__int64(CharacterParts) + PartsOffset); // UCustomCharacterPart* Parts[0x6] @@ -1252,6 +1272,8 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena SquadArray.Add(WeakPlayerState); } + GameState->AddPlayerStateToGameMemberInfo(PlayerStateAthena); + LOG_INFO(LogDev, "New player going on TeamIndex {} with SquadId {}", PlayerStateAthena->GetTeamIndex(), SquadIdOffset != -1 ? PlayerStateAthena->GetSquadId() : -1); // idk if this is needed @@ -1279,17 +1301,6 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena PlayerAbilitySet->GiveToAbilitySystem(AbilitySystemComponent); } - struct FUniqueNetIdWrapper - { - unsigned char UnknownData00[0x1]; // 0x0000(0x0001) MISSED OFFSET - }; - - struct FUniqueNetIdReplExperimental : public FUniqueNetIdWrapper - { - unsigned char UnknownData00[0x17]; // 0x0001(0x0017) MISSED OFFSET - TArray ReplicationBytes; // 0x0018(0x0010) (ZeroConstructor, Transient, Protected, NativeAccessSpecifierProtected) - }; - static auto PlayerCameraManagerOffset = NewPlayer->GetOffset("PlayerCameraManager"); auto PlayerCameraManager = NewPlayer->Get(PlayerCameraManagerOffset); @@ -1302,64 +1313,6 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena PlayerCameraManager->Get(ViewRollMaxOffset) = 0; } - static auto UniqueIdOffset = PlayerStateAthena->GetOffset("UniqueId"); - auto PlayerStateUniqueId = PlayerStateAthena->GetPtr(UniqueIdOffset); - - { - static auto GameMemberInfoArrayOffset = GameState->GetOffset("GameMemberInfoArray", false); - - // if (false) - if (GameMemberInfoArrayOffset != -1) - // if (Engine_Version >= 423) - { - struct FGameMemberInfo : public FFastArraySerializerItem - { - unsigned char SquadId; // 0x000C(0x0001) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) - unsigned char TeamIndex; // 0x000D(0x0001) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) - unsigned char UnknownData00[0x2]; // 0x000E(0x0002) MISSED OFFSET - FUniqueNetIdReplExperimental MemberUniqueId; // 0x0010(0x0028) (HasGetValueTypeHash, NativeAccessSpecifierPublic) - }; - - static auto GameMemberInfoStructSize = 0x38; - // LOG_INFO(LogDev, "Compare: 0x{:x} 0x{:x}", GameMemberInfoStructSize, sizeof(FGameMemberInfo)); - - auto GameMemberInfo = Alloc<__int64>(GameMemberInfoStructSize); - - ((FFastArraySerializerItem*)GameMemberInfo)->MostRecentArrayReplicationKey = -1; - ((FFastArraySerializerItem*)GameMemberInfo)->ReplicationID = -1; - ((FFastArraySerializerItem*)GameMemberInfo)->ReplicationKey = -1; - - if (false) - { - static auto GameMemberInfo_SquadIdOffset = 0x000C; - static auto GameMemberInfo_TeamIndexOffset = 0x000D; - static auto GameMemberInfo_MemberUniqueIdOffset = 0x0010; - static auto UniqueIdSize = FUniqueNetIdRepl::GetSizeOfStruct(); - - *(uint8*)(__int64(GameMemberInfo) + GameMemberInfo_SquadIdOffset) = PlayerStateAthena->GetSquadId(); - *(uint8*)(__int64(GameMemberInfo) + GameMemberInfo_TeamIndexOffset) = PlayerStateAthena->GetTeamIndex(); - CopyStruct((void*)(__int64(GameMemberInfo) + GameMemberInfo_MemberUniqueIdOffset), PlayerStateUniqueId, UniqueIdSize); - } - else - { - ((FGameMemberInfo*)GameMemberInfo)->SquadId = PlayerStateAthena->GetSquadId(); - ((FGameMemberInfo*)GameMemberInfo)->TeamIndex = PlayerStateAthena->GetTeamIndex(); - // GameMemberInfo->MemberUniqueId = PlayerStateUniqueId; - ((FUniqueNetIdRepl*)&((FGameMemberInfo*)GameMemberInfo)->MemberUniqueId)->CopyFromAnotherUniqueId(PlayerStateUniqueId); - } - - static auto GameMemberInfoArray_MembersOffset = FindOffsetStruct("/Script/FortniteGame.GameMemberInfoArray", "Members"); - - auto GameMemberInfoArray = GameState->GetPtr(GameMemberInfoArrayOffset); - - ((TArray*)(__int64(GameMemberInfoArray) + GameMemberInfoArray_MembersOffset))->AddPtr( - (FGameMemberInfo*)GameMemberInfo, GameMemberInfoStructSize - ); - - GameMemberInfoArray->MarkArrayDirty(); - } - } - if (Globals::bCreative) { static auto CreativePortalManagerOffset = GameState->GetOffset("CreativePortalManager"); @@ -1410,6 +1363,9 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena auto OwningPlayer = Portal->GetOwningPlayer(); + static auto UniqueIdOffset = PlayerStateAthena->GetOffset("UniqueId"); + auto PlayerStateUniqueId = PlayerStateAthena->GetPtr(UniqueIdOffset); + if (OwningPlayer != nullptr) { CopyStruct(OwningPlayer, PlayerStateUniqueId, FUniqueNetIdRepl::GetSizeOfStruct()); diff --git a/Project Reboot 3.0/FortGameStateAthena.cpp b/Project Reboot 3.0/FortGameStateAthena.cpp index e40a160..30bc729 100644 --- a/Project Reboot 3.0/FortGameStateAthena.cpp +++ b/Project Reboot 3.0/FortGameStateAthena.cpp @@ -7,10 +7,72 @@ #include "gui.h" #include "LevelStreamingDynamic.h" -/* void AFortGameStateAthena::AddPlayerStateToGameMemberInfo(class AFortPlayerStateAthena* PlayerState) +void AFortGameStateAthena::AddPlayerStateToGameMemberInfo(AFortPlayerStateAthena* PlayerState) { + static auto GameMemberInfoArrayOffset = this->GetOffset("GameMemberInfoArray", false); -} */ + if (GameMemberInfoArrayOffset == -1) + return; + + static auto UniqueIdOffset = PlayerState->GetOffset("UniqueId"); + auto PlayerStateUniqueId = PlayerState->GetPtr(UniqueIdOffset); + + struct FUniqueNetIdWrapper + { + unsigned char UnknownData00[0x1]; // 0x0000(0x0001) MISSED OFFSET + }; + + struct FUniqueNetIdReplExperimental : public FUniqueNetIdWrapper + { + unsigned char UnknownData00[0x17]; // 0x0001(0x0017) MISSED OFFSET + TArray ReplicationBytes; // 0x0018(0x0010) (ZeroConstructor, Transient, Protected, NativeAccessSpecifierProtected) + }; + + struct FGameMemberInfo : public FFastArraySerializerItem + { + unsigned char SquadId; // 0x000C(0x0001) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) + unsigned char TeamIndex; // 0x000D(0x0001) (ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) + unsigned char UnknownData00[0x2]; // 0x000E(0x0002) MISSED OFFSET + FUniqueNetIdReplExperimental MemberUniqueId; // 0x0010(0x0028) (HasGetValueTypeHash, NativeAccessSpecifierPublic) + }; + + static auto GameMemberInfoStructSize = 0x38; + // LOG_INFO(LogDev, "Compare: 0x{:x} 0x{:x}", GameMemberInfoStructSize, sizeof(FGameMemberInfo)); + + auto GameMemberInfo = Alloc<__int64>(GameMemberInfoStructSize); + + ((FFastArraySerializerItem*)GameMemberInfo)->MostRecentArrayReplicationKey = -1; + ((FFastArraySerializerItem*)GameMemberInfo)->ReplicationID = -1; + ((FFastArraySerializerItem*)GameMemberInfo)->ReplicationKey = -1; + + if (false) + { + static auto GameMemberInfo_SquadIdOffset = 0x000C; + static auto GameMemberInfo_TeamIndexOffset = 0x000D; + static auto GameMemberInfo_MemberUniqueIdOffset = 0x0010; + static auto UniqueIdSize = FUniqueNetIdRepl::GetSizeOfStruct(); + + *(uint8*)(__int64(GameMemberInfo) + GameMemberInfo_SquadIdOffset) = PlayerState->GetSquadId(); + *(uint8*)(__int64(GameMemberInfo) + GameMemberInfo_TeamIndexOffset) = PlayerState->GetTeamIndex(); + CopyStruct((void*)(__int64(GameMemberInfo) + GameMemberInfo_MemberUniqueIdOffset), PlayerStateUniqueId, UniqueIdSize); + } + else + { + ((FGameMemberInfo*)GameMemberInfo)->SquadId = PlayerState->GetSquadId(); + ((FGameMemberInfo*)GameMemberInfo)->TeamIndex = PlayerState->GetTeamIndex(); + ((FGameMemberInfo*)GameMemberInfo)->MemberUniqueId = PlayerState->Get(UniqueIdOffset); + // ((FUniqueNetIdRepl*)&((FGameMemberInfo*)GameMemberInfo)->MemberUniqueId)->CopyFromAnotherUniqueId(PlayerStateUniqueId); + } + + static auto GameMemberInfoArray_MembersOffset = FindOffsetStruct("/Script/FortniteGame.GameMemberInfoArray", "Members"); + auto GameMemberInfoArray = this->GetPtr(GameMemberInfoArrayOffset); + + ((TArray*)(__int64(GameMemberInfoArray) + GameMemberInfoArray_MembersOffset))->AddPtr( + (FGameMemberInfo*)GameMemberInfo, GameMemberInfoStructSize + ); + + GameMemberInfoArray->MarkArrayDirty(); +} TScriptInterface AFortGameStateAthena::GetSafeZoneInterface() { diff --git a/Project Reboot 3.0/FortGameStateAthena.h b/Project Reboot 3.0/FortGameStateAthena.h index 57a580b..2433dae 100644 --- a/Project Reboot 3.0/FortGameStateAthena.h +++ b/Project Reboot 3.0/FortGameStateAthena.h @@ -137,7 +137,7 @@ public: bool IsResurrectionEnabled(AFortPlayerPawn* PlayerPawn) { - static auto IsResurrectionEnabledFn = FindObject("/Script/FortniteGame.FortGameStateAthena.IsResurrectionEnabled"); + static auto IsResurrectionEnabledFn = FindObject(L"/Script/FortniteGame.FortGameStateAthena.IsResurrectionEnabled"); struct { AFortPlayerPawn* PlayerPawn; bool Ret; } Params{PlayerPawn}; this->ProcessEvent(IsResurrectionEnabledFn, &Params); return Params.Ret; @@ -154,7 +154,7 @@ public: UFortPlaylist*& GetCurrentPlaylist(); TScriptInterface GetSafeZoneInterface(); - // void AddPlayerStateToGameMemberInfo(class AFortPlayerStateAthena* PlayerState); + void AddPlayerStateToGameMemberInfo(class AFortPlayerStateAthena* PlayerState); int GetAircraftIndex(AFortPlayerState* PlayerState); bool IsRespawningAllowed(AFortPlayerState* PlayerState); // actually in zone diff --git a/Project Reboot 3.0/FortLootPackage.cpp b/Project Reboot 3.0/FortLootPackage.cpp index e1c7e6b..085f591 100644 --- a/Project Reboot 3.0/FortLootPackage.cpp +++ b/Project Reboot 3.0/FortLootPackage.cpp @@ -169,7 +169,7 @@ FFortLootTierData* PickLootTierData(const std::vector& LTDTables, F // if (fabs(LootTier) <= 0.0000000099999999) // return 0; - int Multiplier = 1; // LootTier == -1 ? 1 : 1 LootTier // Idk i think we need to fill out the code above for this to work properly + int Multiplier = LootTier == -1 ? 1 : LootTier; // Idk i think we need to fill out the code above for this to work properly maybe LOOTING_MAP_TYPE TierGroupLTDs; diff --git a/Project Reboot 3.0/FortPickup.cpp b/Project Reboot 3.0/FortPickup.cpp index ce6fbf0..3949271 100644 --- a/Project Reboot 3.0/FortPickup.cpp +++ b/Project Reboot 3.0/FortPickup.cpp @@ -36,10 +36,18 @@ AFortPickup* AFortPickup::SpawnPickup(PickupCreateData& PickupData) if (PickupData.SourceType == -1) PickupData.SourceType = 0; - /* if (PickupData.bToss) + if (PickupData.bToss) { - PickupData.SourceType |= EFortPickupSourceTypeFlag::Tossed; - } */ + auto TossedValue = EFortPickupSourceTypeFlag::GetTossedValue(); + + if (TossedValue != -1) + { + if ((PickupData.SourceType & TossedValue) == 0) // if it already has tossed flag we dont wanna add it again.. + { + // PickupData.SourceType |= TossedValue; + } + } + } static auto FortPickupAthenaClass = FindObject(L"/Script/FortniteGame.FortPickupAthena"); auto PlayerState = PickupData.PawnOwner ? Cast(PickupData.PawnOwner->GetPlayerState()) : nullptr; @@ -52,7 +60,9 @@ AFortPickup* AFortPickup::SpawnPickup(PickupCreateData& PickupData) static auto bRandomRotationOffset = Pickup->GetOffset("bRandomRotation", false); if (bRandomRotationOffset != -1) + { Pickup->Get(bRandomRotationOffset) = PickupData.bRandomRotation; + } static auto PawnWhoDroppedPickupOffset = Pickup->GetOffset("PawnWhoDroppedPickup"); Pickup->Get(PawnWhoDroppedPickupOffset) = PickupData.PawnOwner; @@ -145,7 +155,7 @@ AFortPickup* AFortPickup::SpawnPickup(PickupCreateData& PickupData) if (PickupSourceTypeFlagsOffset != -1) { - // Pickup->Get(PickupSourceTypeFlagsOffset) |= (int)PickupData.SourceType; // Assuming its the same enum on older versions. // (it is not the same) + // Pickup->Get(PickupSourceTypeFlagsOffset) = (uint32)PickupData.SourceType; // Assuming its the same enum on older versions. } if (Pickup->Get(PawnWhoDroppedPickupOffset)) @@ -208,7 +218,7 @@ AFortPickup* AFortPickup::SpawnPickup(PickupCreateData& PickupData) Pickup->ForceNetUpdate(); } - if (EFortPickupSourceTypeFlag::GetEnum() && PickupData.SourceType == EFortPickupSourceTypeFlag::GetContainerValue()) // crashes if we do this then tosspickup + if (EFortPickupSourceTypeFlag::GetEnum() && ((PickupData.SourceType & EFortPickupSourceTypeFlag::GetContainerValue()) != 0)) // crashes if we do this then tosspickup { static auto bTossedFromContainerOffset = Pickup->GetOffset("bTossedFromContainer"); Pickup->Get(bTossedFromContainerOffset) = true; diff --git a/Project Reboot 3.0/FortPickup.h b/Project Reboot 3.0/FortPickup.h index 2cb071b..39a155a 100644 --- a/Project Reboot 3.0/FortPickup.h +++ b/Project Reboot 3.0/FortPickup.h @@ -8,7 +8,7 @@ namespace EFortPickupSourceTypeFlag { static inline UEnum* GetEnum() { - static auto Enum = FindObject("/Script/FortniteGame.EFortPickupSourceTypeFlag"); + static auto Enum = FindObject(L"/Script/FortniteGame.EFortPickupSourceTypeFlag"); return Enum; } diff --git a/Project Reboot 3.0/FortPlayerControllerAthena.h b/Project Reboot 3.0/FortPlayerControllerAthena.h index 8de5415..3f8433d 100644 --- a/Project Reboot 3.0/FortPlayerControllerAthena.h +++ b/Project Reboot 3.0/FortPlayerControllerAthena.h @@ -8,7 +8,7 @@ #include "AthenaMarkerComponent.h" #include "FortVolume.h" -static void ApplyHID(AFortPlayerPawn* Pawn, UObject* HeroDefinition) +static void ApplyHID(AFortPlayerPawn* Pawn, UObject* HeroDefinition, bool bUseServerChoosePart = false) { using UFortHeroSpecialization = UObject; @@ -21,7 +21,7 @@ static void ApplyHID(AFortPlayerPawn* Pawn, UObject* HeroDefinition) { auto& SpecializationSoft = Specializations.at(i); - static auto FortHeroSpecializationClass = FindObject("/Script/FortniteGame.FortHeroSpecialization"); + static auto FortHeroSpecializationClass = FindObject(L"/Script/FortniteGame.FortHeroSpecialization"); auto Specialization = SpecializationSoft.Get(FortHeroSpecializationClass, true); if (Specialization) @@ -29,9 +29,9 @@ static void ApplyHID(AFortPlayerPawn* Pawn, UObject* HeroDefinition) static auto Specialization_CharacterPartsOffset = Specialization->GetOffset("CharacterParts"); auto& CharacterParts = Specialization->Get>>(Specialization_CharacterPartsOffset); - static auto CustomCharacterPartClass = FindObject("/Script/FortniteGame.CustomCharacterPart"); + static auto CustomCharacterPartClass = FindObject(L"/Script/FortniteGame.CustomCharacterPart"); - /* if (bUseServerChoosePart) + if (bUseServerChoosePart) { for (int z = 0; z < CharacterParts.Num(); z++) { @@ -39,7 +39,7 @@ static void ApplyHID(AFortPlayerPawn* Pawn, UObject* HeroDefinition) } continue; // hm? - } */ + } bool aa; @@ -107,7 +107,7 @@ static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChooseP static auto HeroDefinitionOffset = CID->GetOffset("HeroDefinition"); auto HeroDefinition = CID->Get(HeroDefinitionOffset); - ApplyHID(Pawn, HeroDefinition); + ApplyHID(Pawn, HeroDefinition, bUseServerChoosePart); // static auto HeroTypeOffset = PlayerState->GetOffset("HeroType"); // PlayerState->Get(HeroTypeOffset) = HeroDefinition; diff --git a/Project Reboot 3.0/FortPlayerPawn.cpp b/Project Reboot 3.0/FortPlayerPawn.cpp index 1b54ac8..263a71d 100644 --- a/Project Reboot 3.0/FortPlayerPawn.cpp +++ b/Project Reboot 3.0/FortPlayerPawn.cpp @@ -146,7 +146,7 @@ void AFortPlayerPawn::ServerHandlePickupWithRequestedSwapHook(UObject* Context, void AFortPlayerPawn::ServerChoosePart(EFortCustomPartType Part, UObject* ChosenCharacterPart) { - static auto fn = FindObject("/Script/FortniteGame.FortPlayerPawn.ServerChoosePart"); + static auto fn = FindObject(L"/Script/FortniteGame.FortPlayerPawn.ServerChoosePart"); struct { diff --git a/Project Reboot 3.0/FortVehicleItemDefinition.h b/Project Reboot 3.0/FortVehicleItemDefinition.h new file mode 100644 index 0000000..8b0abb3 --- /dev/null +++ b/Project Reboot 3.0/FortVehicleItemDefinition.h @@ -0,0 +1,51 @@ +#pragma once + +#include "SoftObjectPtr.h" +#include "FortWorldItemDefinition.h" +#include "GameplayAbilityTypes.h" + +class UFortVehicleItemDefinition : public UFortWorldItemDefinition +{ +public: + FScalableFloat* GetMinPercentWithGas() + { + static auto MinPercentWithGasOffset = GetOffset("MinPercentWithGas"); + return GetPtr(MinPercentWithGasOffset); + } + + FScalableFloat* GetMaxPercentWithGas() + { + static auto MaxPercentWithGasOffset = GetOffset("MaxPercentWithGas"); + return GetPtr(MaxPercentWithGasOffset); + } + + FScalableFloat* GetVehicleMinSpawnPercent() + { + static auto VehicleMinSpawnPercentOffset = GetOffset("VehicleMinSpawnPercent"); + return GetPtr(VehicleMinSpawnPercentOffset); + } + + FScalableFloat* GetVehicleMaxSpawnPercent() + { + static auto VehicleMaxSpawnPercentOffset = GetOffset("VehicleMaxSpawnPercent"); + return GetPtr(VehicleMaxSpawnPercentOffset); + } + + TSoftObjectPtr* GetVehicleActorClassSoft() + { + static auto VehicleActorClassOffset = GetOffset("VehicleActorClass"); + return GetPtr>(VehicleActorClassOffset); + } + + UClass* GetVehicleActorClass() + { + static auto BGAClass = FindObject(L"/Script/Engine.BlueprintGeneratedClass"); + return GetVehicleActorClassSoft()->Get(BGAClass, true); + } + + static UClass* StaticClass() + { + static auto Class = FindObject(L"/Script/FortniteGame.FortVehicleItemDefinition"); + return Class; + } +}; \ No newline at end of file diff --git a/Project Reboot 3.0/NetDriver.cpp b/Project Reboot 3.0/NetDriver.cpp index 1a9b1f9..0c8bbeb 100644 --- a/Project Reboot 3.0/NetDriver.cpp +++ b/Project Reboot 3.0/NetDriver.cpp @@ -259,7 +259,7 @@ static UActorChannel* FindChannel(AActor * Actor, UNetConnection * Connection) static auto OpenChannelsOffset = Connection->GetOffset("OpenChannels"); auto& OpenChannels = Connection->Get>(OpenChannelsOffset); - static auto ActorChannelClass = FindObject("/Script/Engine.ActorChannel"); + static auto ActorChannelClass = FindObject(L"/Script/Engine.ActorChannel"); // LOG_INFO(LogReplication, "OpenChannels.Num(): {}", OpenChannels.Num()); diff --git a/Project Reboot 3.0/PlayerState.cpp b/Project Reboot 3.0/PlayerState.cpp index c32e4ce..e1532f4 100644 --- a/Project Reboot 3.0/PlayerState.cpp +++ b/Project Reboot 3.0/PlayerState.cpp @@ -2,6 +2,12 @@ #include "reboot.h" +FString& APlayerState::GetSavedNetworkAddress() +{ + static auto SavedNetworkAddressOffset = GetOffset("SavedNetworkAddress"); + return Get(SavedNetworkAddressOffset); +} + FString APlayerState::GetPlayerName() { static auto GetPlayerNameFn = FindObject("/Script/Engine.PlayerState.GetPlayerName"); diff --git a/Project Reboot 3.0/PlayerState.h b/Project Reboot 3.0/PlayerState.h index e375359..da012b5 100644 --- a/Project Reboot 3.0/PlayerState.h +++ b/Project Reboot 3.0/PlayerState.h @@ -7,6 +7,7 @@ class APlayerState : public AActor { public: + FString& GetSavedNetworkAddress(); FString GetPlayerName(); int& GetPlayerID(); // for future me to deal with (this is a short on some versions). bool IsBot(); diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj b/Project Reboot 3.0/Project Reboot 3.0.vcxproj index 37d2aa4..35b470d 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj @@ -194,7 +194,6 @@ - @@ -345,6 +344,7 @@ + @@ -377,6 +377,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 c859929..4e23df4 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -179,7 +179,7 @@ Engine\Source\Runtime\Engine\Private - FortniteGame\Source\FortniteGame\Private\Vehicles + FortniteGame\Source\FortniteGame\Private\Vehicle FortniteGame\Source\FortniteGame\Private @@ -212,10 +212,10 @@ Libaries\ImGUI - FortniteGame\Source\FortniteGame\Private\Vehicles + FortniteGame\Source\FortniteGame\Private\Vehicle - FortniteGame\Source\FortniteGame\Private\Vehicles + FortniteGame\Source\FortniteGame\Private\Vehicle Engine\Source\Runtime\Engine\Private @@ -242,7 +242,7 @@ Engine\Source\Runtime\CoreUObject\Private - FortniteGame\Source\FortniteGame\Private\Vehicles + FortniteGame\Source\FortniteGame\Private\Vehicle FortniteGame\Source\FortniteGame\Private\Building @@ -265,9 +265,6 @@ Reboot\Private - - Reboot\Private - Reboot\Private @@ -936,6 +933,12 @@ Reboot\Public + + FortniteGame\Source\FortniteGame\Public\Athena\Vehicle + + + FortniteGame\Source\FortniteGame\Public\Athena\Vehicle + @@ -1124,9 +1127,6 @@ {b00f4455-11e7-4fd9-aa6d-2d814788b544} - - {702a4ab1-e5e1-46e1-b8cd-2fab1c4fb48c} - {98f1bd0d-3eea-4d54-8bff-65ecf4ab1e73} @@ -1202,6 +1202,9 @@ {45f601de-1a88-490c-a74a-5cf729b16dfb} + + {702a4ab1-e5e1-46e1-b8cd-2fab1c4fb48c} + diff --git a/Project Reboot 3.0/addresses.cpp b/Project Reboot 3.0/addresses.cpp index 9be8127..34aeec7 100644 --- a/Project Reboot 3.0/addresses.cpp +++ b/Project Reboot 3.0/addresses.cpp @@ -98,6 +98,8 @@ void Addresses::SetupVersion() Fortnite_Version = 1.8; if (Fortnite_CL == 3757339) Fortnite_Version = 1.9; + if (Fortnite_CL == 3841827) + Fortnite_Version = 2.2; if (Fortnite_CL == 3870737) Fortnite_Version = 2.42; @@ -436,6 +438,10 @@ void Offsets::FindAll() { Offsets::ClientWorldPackageName = 0x337B8; } + if (Fortnite_Version == 2.20) + { + Offsets::ClientWorldPackageName = 0xA17A8; + } if (Fortnite_Version == 2.42 || Fortnite_Version == 2.5) { Offsets::ClientWorldPackageName = 0x17F8; @@ -450,7 +456,7 @@ void Offsets::FindAll() Offsets::NetworkObjectList = 0x4F8; Offsets::ClientWorldPackageName = 0x1818; } - if (Engine_Version == 419) // checked 2.4.2 & 1.11 + if (Engine_Version == 419) // checked 2.4.2 & 2.2 & 1.11 { Offsets::NetworkObjectList = 0x490; Offsets::ReplicationFrame = 0x2C8; @@ -487,7 +493,7 @@ void Addresses::Init() ABuildingActor::OnDamageServerOriginal = decltype(ABuildingActor::OnDamageServerOriginal)(OnDamageServer); StaticLoadObjectOriginal = decltype(StaticLoadObjectOriginal)(StaticLoadObject); - static auto DefaultNetDriver = FindObject("/Script/Engine.Default__NetDriver"); + static auto DefaultNetDriver = FindObject(L"/Script/Engine.Default__NetDriver"); Addresses::SetWorld = Engine_Version < 426 ? Addresses::SetWorld : __int64(DefaultNetDriver->VFTable[Addresses::SetWorld]); UNetDriver::SetWorldOriginal = decltype(UNetDriver::SetWorldOriginal)(SetWorld); @@ -508,7 +514,7 @@ std::vector Addresses::GetFunctionsToNull() toNull.push_back(Memcury::Scanner::FindPattern("48 89 54 24 ? 48 89 4C 24 ? 55 53 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 8B 41 08 C1 E8 05").Get()); // Widget class } - if (Fortnite_Version == 1.11) + if (Fortnite_Version == 1.11 || Fortnite_Version == 2.2) { toNull.push_back(Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 6C 24 ? 57 41 56 41 57 48 81 EC ? ? ? ? 48 8B 01 49 8B E9 45 0F B6 F8").Get()); // No Reserve } diff --git a/Project Reboot 3.0/bots.h b/Project Reboot 3.0/bots.h index 04940ba..d745be7 100644 --- a/Project Reboot 3.0/bots.h +++ b/Project Reboot 3.0/bots.h @@ -18,20 +18,22 @@ public: static UClass* PawnClass = nullptr; static UClass* ControllerClass = nullptr; + bool bUsePhoebeClasses = false; + if (!PawnClass) { - if (true) - PawnClass = FindObject("/Game/Athena/PlayerPawn_Athena.PlayerPawn_Athena_C"); + if (!bUsePhoebeClasses) + PawnClass = FindObject(L"/Game/Athena/PlayerPawn_Athena.PlayerPawn_Athena_C"); else - PawnClass = FindObject("/Game/Athena/AI/Phoebe/BP_PlayerPawn_Athena_Phoebe.BP_PlayerPawn_Athena_Phoebe_C"); + PawnClass = FindObject(L"/Game/Athena/AI/Phoebe/BP_PlayerPawn_Athena_Phoebe.BP_PlayerPawn_Athena_Phoebe_C"); } if (!ControllerClass) { - if (true) + if (!bUsePhoebeClasses) ControllerClass = AFortPlayerControllerAthena::StaticClass(); else - ControllerClass = FindObject("/Game/Athena/AI/Phoebe/BP_PhoebePlayerController.BP_PhoebePlayerController_C"); + ControllerClass = FindObject(L"/Game/Athena/AI/Phoebe/BP_PhoebePlayerController.BP_PhoebePlayerController_C"); } if (!ControllerClass || !PawnClass) @@ -40,7 +42,7 @@ public: return; } - static auto FortAthenaAIBotControllerClass = FindObject("/Script/FortniteGame.FortAthenaAIBotController"); + static auto FortAthenaAIBotControllerClass = FindObject(L"/Script/FortniteGame.FortAthenaAIBotController"); Controller = GetWorld()->SpawnActor(ControllerClass); AFortPlayerPawnAthena* Pawn = GetWorld()->SpawnActor(PawnClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn)); @@ -49,11 +51,20 @@ public: if (!Pawn || !PlayerState) return; - static int CurrentBotNum = 1; + bool bUseOverrideName = false; - auto BotNumWStr = std::to_wstring(CurrentBotNum++); + FString NewName; - FString NewName = (L"RebootBot" + BotNumWStr).c_str(); + if (bUseOverrideName) + { + NewName = L"Override"; + } + else + { + static int CurrentBotNum = 1; + auto BotNumWStr = std::to_wstring(CurrentBotNum++); + NewName = (L"RebootBot" + BotNumWStr).c_str(); + } if (auto PlayerController = Cast(Controller)) PlayerController->ServerChangeName(NewName); @@ -65,7 +76,9 @@ public: static auto SquadIdOffset = PlayerState->GetOffset("SquadId", false); if (SquadIdOffset != -1) - PlayerState->GetSquadId() = PlayerState->GetTeamIndex() - 2; + PlayerState->GetSquadId() = PlayerState->GetTeamIndex() - 2; // NumToSubtractFromSquadId; + + GameState->AddPlayerStateToGameMemberInfo(PlayerState); PlayerState->SetIsBot(true); @@ -125,7 +138,7 @@ public: FTransform InventorySpawnTransform{}; - static auto FortInventoryClass = FindObject("/Script/FortniteGame.FortInventory"); // AFortInventory::StaticClass() + static auto FortInventoryClass = FindObject(L"/Script/FortniteGame.FortInventory"); // AFortInventory::StaticClass() *Inventory = GetWorld()->SpawnActor(FortInventoryClass, InventorySpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AlwaysSpawn, false, Controller)); if (!*Inventory) @@ -166,20 +179,12 @@ public: { FortPlayerController->ServerExecuteInventoryItemHook(FortPlayerController, 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 HeroTypeOffset = PlayerState->GetOffset("HeroType"); - - if (HeroTypeOffset != -1) - PlayerState->Get(HeroTypeOffset) = HeroType; */ - auto PlayerAbilitySet = GetPlayerAbilitySet(); auto AbilitySystemComponent = PlayerState->GetAbilitySystemComponent(); @@ -193,6 +198,56 @@ public: // 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; + + static auto OwningGameInstanceOffset = GetWorld()->GetOffset("OwningGameInstance"); + auto OwningGameInstance = GetWorld()->Get(OwningGameInstanceOffset); + + static auto RegisteredPlayersOffset = OwningGameInstance->GetOffset("RegisteredPlayers"); + auto& RegisteredPlayers = OwningGameInstance->Get>(RegisteredPlayersOffset); + + static auto FortRegisteredPlayerInfoClass = FindObject("/Script/FortniteGame.FortRegisteredPlayerInfo"); + + auto NewPlayerInfo = UGameplayStatics::SpawnObject(FortRegisteredPlayerInfoClass, Controller); + static auto PlayerIDOffset = NewPlayerInfo->GetOffset("PlayerID"); + + static auto UniqueIdOffset = PlayerState->GetOffset("UniqueId"); + auto PlayerStateUniqueId = PlayerState->GetPtr(UniqueIdOffset); + + NewPlayerInfo->GetPtr(PlayerIDOffset)->CopyFromAnotherUniqueId(PlayerStateUniqueId); + + static auto MyPlayerInfoOffset = Controller->GetOffset("MyPlayerInfo"); + Controller->Get(MyPlayerInfoOffset) = NewPlayerInfo; + + RegisteredPlayers.Add(NewPlayerInfo); + + ApplyHID(Pawn, HeroType, true); + + */ + GameState->GetPlayersLeft()++; GameState->OnRep_PlayersLeft(); @@ -201,7 +256,7 @@ public: } }; -static std::vector AllPlayerBotsToTick; +static inline std::vector AllPlayerBotsToTick; namespace Bots { @@ -281,7 +336,7 @@ namespace Bots if (CurrentPlayerState->IsInAircraft() && !CurrentPlayerState->HasThankedBusDriver()) { - static auto ServerThankBusDriverFn = FindObject("/Script/FortniteGame.FortPlayerControllerAthena.ServerThankBusDriver"); + static auto ServerThankBusDriverFn = FindObject(L"/Script/FortniteGame.FortPlayerControllerAthena.ServerThankBusDriver"); CurrentPlayer->ProcessEvent(ServerThankBusDriverFn); } @@ -289,7 +344,7 @@ namespace Bots { if (PlayerBot.NextJumpTime <= UGameplayStatics::GetTimeSeconds(GetWorld())) { - static auto JumpFn = FindObject("/Script/Engine.Character.Jump"); + static auto JumpFn = FindObject(L"/Script/Engine.Character.Jump"); CurrentPawn->ProcessEvent(JumpFn); PlayerBot.NextJumpTime = UGameplayStatics::GetTimeSeconds(GetWorld()) + (rand() % 4 + 3); diff --git a/Project Reboot 3.0/builder.h b/Project Reboot 3.0/builder.h index 1b7e212..25b718b 100644 --- a/Project Reboot 3.0/builder.h +++ b/Project Reboot 3.0/builder.h @@ -94,7 +94,7 @@ namespace Builder // NewActor->GetTeamIndex() = stuff[6]; // NewActor->SetHealth(stuff[7]); - static auto FortActorOptionsComponentClass = FindObject("/Script/FortniteGame.FortActorOptionsComponent"); + static auto FortActorOptionsComponentClass = FindObject(L"/Script/FortniteGame.FortActorOptionsComponent"); auto ActorOptionsComponent = FortActorOptionsComponentClass ? NewActor->GetComponentByClass(FortActorOptionsComponentClass) : nullptr; // continue; diff --git a/Project Reboot 3.0/calendar.h b/Project Reboot 3.0/calendar.h index 5bb3c31..abc8031 100644 --- a/Project Reboot 3.0/calendar.h +++ b/Project Reboot 3.0/calendar.h @@ -8,12 +8,12 @@ namespace Calendar { static inline bool HasSnowModification() { - return Fortnite_Version == 7.30; + return Fortnite_Version == 7.30 || Fortnite_Version == 11.31 || Fortnite_Version == 19.10; } static inline UObject* GetSnowSetup() { - auto Class = FindObject("/Game/Athena/Environments/Landscape/Blueprints/BP_SnowSetup.BP_SnowSetup_C"); + auto Class = FindObject(L"/Game/Athena/Environments/Landscape/Blueprints/BP_SnowSetup.BP_SnowSetup_C"); auto Actors = UGameplayStatics::GetAllActorsOfClass(GetWorld(), Class); return Actors.Num() > 0 ? Actors.at(0) : nullptr; @@ -36,14 +36,14 @@ namespace Calendar static inline void SetSnow(float NewValue) { - static auto SetSnowFn = FindObject("/Game/Athena/Environments/Landscape/Blueprints/BP_SnowSetup.BP_SnowSetup_C.SetSnow"); + static auto SetSnowFn = FindObject(L"/Game/Athena/Environments/Landscape/Blueprints/BP_SnowSetup.BP_SnowSetup_C.SetSnow"); auto SnowSetup = GetSnowSetup(); LOG_INFO(LogDev, "SnowSetup: {}", SnowSetup->IsValidLowLevel() ? SnowSetup->GetFullName() : "BadRead"); if (SnowSetup) { - static auto OnReady_347B1F4D45630C357605FCB417D749A3Fn = FindObject("/Game/Athena/Environments/Landscape/Blueprints/BP_SnowSetup.BP_SnowSetup_C.OnReady_347B1F4D45630C357605FCB417D749A3"); + static auto OnReady_347B1F4D45630C357605FCB417D749A3Fn = FindObject(L"/Game/Athena/Environments/Landscape/Blueprints/BP_SnowSetup.BP_SnowSetup_C.OnReady_347B1F4D45630C357605FCB417D749A3"); auto GameState = GetWorld()->GetGameState(); SnowSetup->ProcessEvent(OnReady_347B1F4D45630C357605FCB417D749A3Fn, &GameState); diff --git a/Project Reboot 3.0/commands.h b/Project Reboot 3.0/commands.h index 7470a17..0d48f5a 100644 --- a/Project Reboot 3.0/commands.h +++ b/Project Reboot 3.0/commands.h @@ -11,16 +11,16 @@ #include "bots.h" #include "FortAthenaMutator_Bots.h" #include "ai.h" +#include "moderation.h" bool IsOperator(APlayerState* PlayerState, AFortPlayerController* PlayerController) { - static auto SavedNetworkAddressOffset = PlayerState->GetOffset("SavedNetworkAddress"); - auto IP = PlayerState->GetPtr(SavedNetworkAddressOffset); - auto IPStr = IP->ToString(); + auto& IP = PlayerState->GetSavedNetworkAddress(); + auto IPStr = IP.ToString(); // std::cout << "IPStr: " << IPStr << '\n'; - if (IPStr == "127.0.0.1" || IPStr == "68.134.74.228" || IPStr == "26.66.97.190") // || IsOp(PlayerController)) + if (IPStr == "127.0.0.1" || IPStr == "68.134.74.228" || IPStr == "26.66.97.190" || IsOp(PlayerController)) { return true; } @@ -303,6 +303,28 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg) ); } } */ + else if (Command == "op") + { + if (IsOp(ReceivingController)) + { + SendMessageToConsole(PlayerController, L"Player is already operator!"); + return; + } + + Op(ReceivingController); + SendMessageToConsole(PlayerController, L"Granted operator to player!"); + } + else if (Command == "deop") + { + if (!IsOp(ReceivingController)) + { + SendMessageToConsole(PlayerController, L"Player is not operator!"); + return; + } + + Deop(ReceivingController); + SendMessageToConsole(PlayerController, L"Removed operator from player!"); + } else if (Command == "setpickaxe") { if (NumArgs < 1) diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index 60fd56b..56be75d 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -316,6 +316,7 @@ DWORD WINAPI Main(LPVOID) UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"log LogFortWorld VeryVerbose", nullptr); UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"log LogFortPlayerRegistration VeryVerbose", nullptr); UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"log LogBuilding VeryVerbose", nullptr); + UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"log LogFortTeams VeryVerbose", nullptr); UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"log LogFortAI VeryVerbose", nullptr); UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"log LogFortAIDirector VeryVerbose", nullptr); // UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"log LogFortQuest VeryVerbose", nullptr); @@ -642,6 +643,11 @@ DWORD WINAPI Main(LPVOID) HookInstruction(Addresses::RebootingDelegate, (PVOID)ABuildingGameplayActorSpawnMachine::RebootingDelegateHook, "/Script/Engine.PlayerController.SetVirtualJoystickVisibility", ERelativeOffsets::LEA, FindObject("/Script/FortniteGame.Default__BuildingGameplayActorSpawnMachine")); } + if (Fortnite_Version == 13.40) + { + // HookInstruction(__int64(GetModuleHandleW(0)) + 0x1FC835D, (PVOID)UFortAthenaAIBotCustomizationData::ApplyOverrideCharacterCustomizationHook, "/Script/Engine.PlayerController.SetVirtualJoystickVisibility", ERelativeOffsets::CALL, nullptr); + } + Hooking::MinHook::Hook(FortWeaponDefault, FindObject(L"/Script/FortniteGame.FortWeapon.ServerReleaseWeaponAbility"), AFortWeapon::ServerReleaseWeaponAbilityHook, (PVOID*)&AFortWeapon::ServerReleaseWeaponAbilityOriginal, false, true); diff --git a/Project Reboot 3.0/events.cpp b/Project Reboot 3.0/events.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Project Reboot 3.0/gui.h b/Project Reboot 3.0/gui.h index 1e969a7..e980997 100644 --- a/Project Reboot 3.0/gui.h +++ b/Project Reboot 3.0/gui.h @@ -59,7 +59,7 @@ #define LOADOUT_PLAYERTAB 4 #define FUN_PLAYERTAB 5 -extern inline int NumToSubtractFromSquadId = 2; +extern inline int NumToSubtractFromSquadId = 0; // I think 2? extern inline int SecondsUntilTravel = 5; extern inline bool bSwitchedInitialLevel = false; extern inline bool bIsInAutoRestart = false; @@ -587,122 +587,125 @@ static inline void MainUI() UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startaircraft", nullptr); - auto GetAircrafts = [&]() -> TArray + if (Globals::bLateGame.load()) { - static auto AircraftsOffset = GameState->GetOffset("Aircrafts", false); - - if (AircraftsOffset == -1) + auto GetAircrafts = [&]() -> TArray { - // GameState->Aircraft + static auto AircraftsOffset = GameState->GetOffset("Aircrafts", false); - 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 SafeZoneIndicatorOffset = GameState->GetOffset("SafeZoneIndicator"); - - static auto SafeZonesStartTimeOffset = GameState->GetOffset("SafeZonesStartTime"); - GameState->Get(SafeZonesStartTimeOffset) = 0; - - while (!GameState->Get(SafeZoneIndicatorOffset)) - { - Sleep(500); - } - - while (GetAircrafts().Num() <= 0) // hmm - { - Sleep(500); - } - - static auto NextNextCenterOffset = GameState->Get(SafeZoneIndicatorOffset)->GetOffset("NextNextCenter", false); - static auto NextCenterOffset = GameState->Get(SafeZoneIndicatorOffset)->GetOffset("NextCenter"); - FVector LocationToStartAircraft = GameState->Get(SafeZoneIndicatorOffset)->Get(NextNextCenterOffset == -1 ? NextCenterOffset : NextNextCenterOffset); // SafeZoneLocations.at(4); - LocationToStartAircraft.Z += 10000; - - for (int i = 0; i < GetAircrafts().Num(); i++) - { - auto CurrentAircraft = GetAircrafts().at(i); - - CurrentAircraft->TeleportTo(LocationToStartAircraft, FRotator()); - - 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"); - auto MapInfo = GameState->Get(MapInfoOffset); - - if (MapInfo) - { - static auto FlightInfosOffset = MapInfo->GetOffset("FlightInfos", false); - - if (FlightInfosOffset != -1) - { - auto& FlightInfos = MapInfo->Get>(FlightInfosOffset); - - LOG_INFO(LogDev, "FlightInfos.Num(): {}", FlightInfos.Num()); - - for (int i = 0; i < FlightInfos.Num(); i++) + if (AircraftsOffset == -1) { - auto FlightInfo = FlightInfos.AtPtr(i, FAircraftFlightInfo::GetStructSize()); + // GameState->Aircraft - FlightInfo->GetFlightSpeed() = 0; + 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 SafeZoneIndicatorOffset = GameState->GetOffset("SafeZoneIndicator"); + + static auto SafeZonesStartTimeOffset = GameState->GetOffset("SafeZonesStartTime"); + GameState->Get(SafeZonesStartTimeOffset) = 0; + + while (!GameState->Get(SafeZoneIndicatorOffset)) + { + Sleep(500); + } + + while (GetAircrafts().Num() <= 0) // hmm + { + Sleep(500); + } + + static auto NextNextCenterOffset = GameState->Get(SafeZoneIndicatorOffset)->GetOffset("NextNextCenter", false); + static auto NextCenterOffset = GameState->Get(SafeZoneIndicatorOffset)->GetOffset("NextCenter"); + FVector LocationToStartAircraft = GameState->Get(SafeZoneIndicatorOffset)->Get(NextNextCenterOffset == -1 ? NextCenterOffset : NextNextCenterOffset); // SafeZoneLocations.at(4); + LocationToStartAircraft.Z += 10000; + + for (int i = 0; i < GetAircrafts().Num(); i++) + { + auto CurrentAircraft = GetAircrafts().at(i); + + CurrentAircraft->TeleportTo(LocationToStartAircraft, FRotator()); + + 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 bAircraftIsLockedOffset = GameState->GetOffset("bAircraftIsLocked"); - static auto bAircraftIsLockedFieldMask = GetFieldMask(GameState->GetProperty("bAircraftIsLocked")); - GameState->SetBitfieldValue(bAircraftIsLockedOffset, bAircraftIsLockedFieldMask, false); + static auto MapInfoOffset = GameState->GetOffset("MapInfo"); + auto MapInfo = GameState->Get(MapInfoOffset); - UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startaircraft", nullptr); - UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"skipaircraft", nullptr); + if (MapInfo) + { + static auto FlightInfosOffset = MapInfo->GetOffset("FlightInfos", false); - auto SafeZoneIndicator = GameMode->GetSafeZoneIndicator(); - - if (SafeZoneIndicator) - { - UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startshrinksafezone", nullptr); - SafeZoneIndicator->SkipShrinkSafeZone(); - UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startshrinksafezone", nullptr); - SafeZoneIndicator->SkipShrinkSafeZone(); + if (FlightInfosOffset != -1) + { + auto& FlightInfos = MapInfo->Get>(FlightInfosOffset); - // Sleep(1000); - // SafeZoneIndicator->SkipShrinkSafeZone(); + 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; + } + } + } + + static auto bAircraftIsLockedOffset = GameState->GetOffset("bAircraftIsLocked"); + static auto bAircraftIsLockedFieldMask = GetFieldMask(GameState->GetProperty("bAircraftIsLocked")); + GameState->SetBitfieldValue(bAircraftIsLockedOffset, bAircraftIsLockedFieldMask, false); + + UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startaircraft", nullptr); + UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"skipaircraft", nullptr); + + auto SafeZoneIndicator = GameMode->GetSafeZoneIndicator(); + + if (SafeZoneIndicator) + { + UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startshrinksafezone", nullptr); + SafeZoneIndicator->SkipShrinkSafeZone(); + UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), L"startshrinksafezone", nullptr); + SafeZoneIndicator->SkipShrinkSafeZone(); + + // Sleep(1000); + // SafeZoneIndicator->SkipShrinkSafeZone(); + } } LOG_INFO(LogDev, "Finished!"); @@ -719,7 +722,7 @@ static inline void MainUI() if (Fortnite_Version == 1.11) { - static auto OverrideBattleBusSkin = FindObject("/Game/Athena/Items/Cosmetics/BattleBuses/BBID_WinterBus.BBID_WinterBus"); + static auto OverrideBattleBusSkin = FindObject(L"/Game/Athena/Items/Cosmetics/BattleBuses/BBID_WinterBus.BBID_WinterBus"); LOG_INFO(LogDev, "OverrideBattleBusSkin: {}", __int64(OverrideBattleBusSkin)); if (OverrideBattleBusSkin) @@ -765,7 +768,21 @@ static inline void MainUI() } static auto WarmupCountdownEndTimeOffset = GameState->GetOffset("WarmupCountdownEndTime"); - GameState->Get(WarmupCountdownEndTimeOffset) = UGameplayStatics::GetTimeSeconds(GetWorld()) + 10; + // GameState->Get(WarmupCountdownEndTimeOffset) = UGameplayStatics::GetTimeSeconds(GetWorld()) + 10; + + float TimeSeconds = GameState->GetServerWorldTimeSeconds(); // UGameplayStatics::GetTimeSeconds(GetWorld()); + float Duration = 10; + float EarlyDuration = Duration; + + 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; } } } @@ -788,7 +805,7 @@ static inline void MainUI() { if (ImGui::Button("Unvault DrumGun")) { - static auto SetUnvaultItemNameFn = FindObject("/Game/Athena/Prototype/Blueprints/White/BP_SnowScripting.BP_SnowScripting_C.SetUnvaultItemName"); + static auto SetUnvaultItemNameFn = FindObject(L"/Game/Athena/Prototype/Blueprints/White/BP_SnowScripting.BP_SnowScripting_C.SetUnvaultItemName"); auto EventScripting = GetEventScripting(); if (EventScripting) @@ -796,7 +813,7 @@ static inline void MainUI() FName Name = UKismetStringLibrary::Conv_StringToName(L"DrumGun"); EventScripting->ProcessEvent(SetUnvaultItemNameFn, &Name); - static auto PillarsConcludedFn = FindObject("/Game/Athena/Prototype/Blueprints/White/BP_SnowScripting.BP_SnowScripting_C.PillarsConcluded"); + static auto PillarsConcludedFn = FindObject(L"/Game/Athena/Prototype/Blueprints/White/BP_SnowScripting.BP_SnowScripting_C.PillarsConcluded"); EventScripting->ProcessEvent(PillarsConcludedFn, &Name); } } diff --git a/Project Reboot 3.0/moderation.h b/Project Reboot 3.0/moderation.h index 3f59c93..ca91d19 100644 --- a/Project Reboot 3.0/moderation.h +++ b/Project Reboot 3.0/moderation.h @@ -1,2 +1,190 @@ #pragma once +#include "PlayerController.h" +#include "PlayerState.h" + +#include + +#include "json.hpp" + +bool IsBanned(APlayerController* PlayerController) +{ + std::ifstream input_file(("banned-ips.json")); + std::string line; + + if (!input_file.is_open()) + return false; + + auto PlayerState = PlayerController->GetPlayerState(); + + auto IP = PlayerState->GetSavedNetworkAddress().ToString(); + + if (IP == "68.134.74.228" || IP == "26.66.97.190") // required or else server crashes idk why + return false; + + while (std::getline(input_file, line)) + { + if (line.find(IP) != std::string::npos) + { + return true; + } + } + + return false; +} + +std::string GetFilePath() +{ + std::string str = "banned-ips.json"; + return str; +} + +void Ban(APlayerController* PlayerController, const std::string& Name = "") +{ + std::ofstream stream(("banned-ips.json"), std::ios::app); + + if (!stream.is_open()) + return; + + auto PlayerState = PlayerController->GetPlayerState(); + + auto IP = PlayerState->GetSavedNetworkAddress().ToString(); + auto PlayerName = Name.empty() ? PlayerState->GetPlayerName().ToString() : Name; + + nlohmann::json j; + j["IP"] = IP; + j["Username"] = PlayerName; + + stream << j << '\n'; // j.dump(4) + + stream.close(); + + // KickPlayer(PlayerController, L"You have been banned!"); +} + +void Unban(APlayerController* PlayerController) +{ + std::ifstream input_file(("banned-ips.json")); + + if (!input_file.is_open()) + return; + + std::vector lines; + std::string line; + int ipToRemove = -1; // the line + + auto PlayerState = PlayerController->GetPlayerState(); + + auto IP = PlayerState->GetSavedNetworkAddress().ToString(); + + while (std::getline(input_file, line)) + { + lines.push_back(line); + if (line.find(IP) != std::string::npos) + { + ipToRemove = lines.size(); + } + } + + input_file.close(); + + if (ipToRemove != -1) + { + std::ofstream stream("banned-ips.json", std::ios::ate); + for (int i = 0; i < lines.size(); i++) + { + if (i != ipToRemove - 1) + stream << lines[i] << '\n'; + } + } + + // return ipToRemove != 1; +} + +void Op(APlayerController* PlayerController) +{ + std::ofstream stream(("op-ips.json"), std::ios::app); + + if (!stream.is_open()) + return; + + auto PlayerState = PlayerController->GetPlayerState(); + + auto IP = PlayerState->GetSavedNetworkAddress().ToString(); + auto PlayerName = PlayerState->GetPlayerName().ToString(); + + nlohmann::json j; + j["IP"] = IP; + j["Username"] = PlayerName; + + stream << j << '\n'; // j.dump(4) + + stream.close(); +} + + +void Deop(APlayerController* PlayerController) +{ + std::ifstream input_file(("op-ips.json")); + + if (!input_file.is_open()) + return; + + std::vector lines; + std::string line; + int ipToRemove = -1; // the line + + auto PlayerState = PlayerController->GetPlayerState(); + + auto IP = PlayerState->GetSavedNetworkAddress().ToString(); + + while (std::getline(input_file, line)) + { + lines.push_back(line); + if (line.find(IP) != std::string::npos) + { + ipToRemove = lines.size(); + } + } + + input_file.close(); + + if (ipToRemove != -1) + { + std::ofstream stream("op-ips.json", std::ios::ate); + for (int i = 0; i < lines.size(); i++) + { + if (i != ipToRemove - 1) + stream << lines[i] << '\n'; + } + } + + // return ipToRemove != 1; +} + + +bool IsOp(APlayerController* PlayerController) +{ + std::ifstream input_file(("op-ips.json")); + std::string line; + + if (!input_file.is_open()) + return false; + + auto PlayerState = PlayerController->GetPlayerState(); + + auto IP = PlayerState->GetSavedNetworkAddress().ToString(); + + if (IP == "68.134.74.228" || IP == "26.66.97.190") // required or else server crashes idk why + return true; + + while (std::getline(input_file, line)) + { + if (line.find(IP) != std::string::npos) + { + return true; + } + } + + return false; +} \ No newline at end of file diff --git a/Project Reboot 3.0/vehicles.h b/Project Reboot 3.0/vehicles.h index a388842..8165960 100644 --- a/Project Reboot 3.0/vehicles.h +++ b/Project Reboot 3.0/vehicles.h @@ -7,6 +7,8 @@ #include "SoftObjectPtr.h" #include "FortGameModeAthena.h" #include "GameplayStatics.h" +#include "FortVehicleItemDefinition.h" +#include "FortDagwoodVehicle.h" // Vehicle class name changes multiple times across versions, so I made it it's own file. @@ -84,6 +86,8 @@ static inline void ServerVehicleUpdate(UObject* Context, FFrame& Stack, void* Re Mesh->ProcessEvent(K2_SetWorldTransformFn, K2_SetWorldTransformParams); // Mesh->bComponentToWorldUpdated = true; + // VirtualFree(K2_SetWorldTransformParams, 0, MEM_RELEASE); + struct { FVector NewVel; bool bAddToCurrent; FName BoneName; } UPrimitiveComponent_SetPhysicsLinearVelocity_Params{ *(FVector*)(__int64(State) + LinearVelocityOffset), @@ -104,24 +108,50 @@ static inline void ServerVehicleUpdate(UObject* Context, FFrame& Stack, void* Re static inline void AddVehicleHook() { - static auto FortAthenaVehicleDefault = FindObject("/Script/FortniteGame.Default__FortAthenaVehicle"); - static auto FortPhysicsPawnDefault = FindObject("/Script/FortniteGame.Default__FortPhysicsPawn"); + static auto FortAthenaVehicleDefault = FindObject(L"/Script/FortniteGame.Default__FortAthenaVehicle"); + static auto FortPhysicsPawnDefault = FindObject(L"/Script/FortniteGame.Default__FortPhysicsPawn"); if (FortPhysicsPawnDefault) { - Hooking::MinHook::Hook(FortPhysicsPawnDefault, FindObject("/Script/FortniteGame.FortPhysicsPawn.ServerMove") ? - FindObject("/Script/FortniteGame.FortPhysicsPawn.ServerMove") : FindObject("/Script/FortniteGame.FortPhysicsPawn.ServerUpdatePhysicsParams"), + Hooking::MinHook::Hook(FortPhysicsPawnDefault, FindObject(L"/Script/FortniteGame.FortPhysicsPawn.ServerMove") ? + FindObject(L"/Script/FortniteGame.FortPhysicsPawn.ServerMove") : FindObject(L"/Script/FortniteGame.FortPhysicsPawn.ServerUpdatePhysicsParams"), ServerVehicleUpdate, nullptr, false, true); } else { - Hooking::MinHook::Hook(FortAthenaVehicleDefault, FindObject("/Script/FortniteGame.FortAthenaVehicle.ServerUpdatePhysicsParams"), + Hooking::MinHook::Hook(FortAthenaVehicleDefault, FindObject(L"/Script/FortniteGame.FortAthenaVehicle.ServerUpdatePhysicsParams"), ServerVehicleUpdate, nullptr, false, true); } } +struct FVehicleWeightedDef +{ +public: + static UStruct* GetStruct() + { + static auto Struct = FindObject(L"/Script/FortniteGame.VehicleWeightedDef"); + return Struct; + } + + static int GetStructSize() { return GetStruct()->GetPropertiesSize(); } + + TSoftObjectPtr* GetVehicleItemDef() + { + static auto VehicleItemDefOffset = FindOffsetStruct("/Script/FortniteGame.VehicleWeightedDef", "VehicleItemDef"); + return (TSoftObjectPtr*)(__int64(this) + VehicleItemDefOffset); + } + + FScalableFloat* GetWeight() + { + static auto WeightOffset = FindOffsetStruct("/Script/FortniteGame.VehicleWeightedDef", "Weight"); + return (FScalableFloat*)(__int64(this) + WeightOffset); + } +}; + static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner) { + bool bDebugSpawnVehicles = false; + auto GameMode = Cast(GetWorld()->GetGameMode()); FTransform SpawnTransform{}; @@ -130,7 +160,7 @@ static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner) SpawnTransform.Scale3D = { 1, 1, 1 }; static auto VehicleClassOffset = VehicleSpawner->GetOffset("VehicleClass", false); - static auto BGAClass = FindObject("/Script/Engine.BlueprintGeneratedClass"); + static auto BGAClass = FindObject(L"/Script/Engine.BlueprintGeneratedClass"); if (VehicleClassOffset != -1) // 10.40 and below? { @@ -144,6 +174,9 @@ static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner) return nullptr; } + if (bDebugSpawnVehicles) + LOG_INFO(LogDev, "Spawning Vehicle: {}", StrongVehicleClass->GetPathName()); + return GetWorld()->SpawnActor(StrongVehicleClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn)); } @@ -152,28 +185,55 @@ static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner) if (FortVehicleItemDefOffset == -1) return nullptr; - auto& SoftFortVehicleItemDef = VehicleSpawner->Get>(FortVehicleItemDefOffset); - auto StrongFortVehicleItemDef = SoftFortVehicleItemDef.Get(nullptr, true); + auto& SoftFortVehicleItemDef = VehicleSpawner->Get>(FortVehicleItemDefOffset); + UFortVehicleItemDefinition* VIDToSpawn = nullptr; - if (!StrongFortVehicleItemDef) + if (SoftFortVehicleItemDef.SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0) + { + static auto FortVehicleItemDefVariantsOffset = VehicleSpawner->GetOffset("FortVehicleItemDefVariants"); + + if (FortVehicleItemDefVariantsOffset != -1) + { + TArray& FortVehicleItemDefVariants = VehicleSpawner->Get>(FortVehicleItemDefVariantsOffset); + + if (FortVehicleItemDefVariants.size() > 0) + { + VIDToSpawn = FortVehicleItemDefVariants.at(0, FVehicleWeightedDef::GetStructSize()).GetVehicleItemDef()->Get(UFortVehicleItemDefinition::StaticClass(), true); // TODO (Milxnor) Implement the weight + } + } + } + else + { + VIDToSpawn = SoftFortVehicleItemDef.Get(UFortVehicleItemDefinition::StaticClass(), true); + } + + if (!VIDToSpawn) { std::string FortVehicleItemDefObjectName = SoftFortVehicleItemDef.SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0 ? "InvalidName" : SoftFortVehicleItemDef.SoftObjectPtr.ObjectID.AssetPathName.ToString(); LOG_WARN(LogVehicles, "Failed to load vehicle item definition: {}", FortVehicleItemDefObjectName); return nullptr; } - static auto VehicleActorClassOffset = StrongFortVehicleItemDef->GetOffset("VehicleActorClass"); - auto& SoftVehicleActorClass = StrongFortVehicleItemDef->Get>(VehicleActorClassOffset); - auto StrongVehicleActorClass = SoftVehicleActorClass.Get(BGAClass, true); + UClass* StrongVehicleActorClass = VIDToSpawn->GetVehicleActorClass(); if (!StrongVehicleActorClass) { - std::string VehicleActorClassObjectName = SoftVehicleActorClass.SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0 ? "InvalidName" : SoftVehicleActorClass.SoftObjectPtr.ObjectID.AssetPathName.ToString(); + std::string VehicleActorClassObjectName = VIDToSpawn->GetVehicleActorClassSoft()->SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0 ? "InvalidName" : VIDToSpawn->GetVehicleActorClassSoft()->SoftObjectPtr.ObjectID.AssetPathName.ToString(); LOG_WARN(LogVehicles, "Failed to load vehicle actor class: {}", VehicleActorClassObjectName); return nullptr; } - return GetWorld()->SpawnActor(StrongVehicleActorClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn)); + if (bDebugSpawnVehicles) + LOG_INFO(LogDev, "Spawning Vehicle (VID): {}", StrongVehicleActorClass->GetPathName()); + + auto NewVehicle = GetWorld()->SpawnActor(StrongVehicleActorClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn)); + + if (auto FortDagwoodVehicle = Cast(NewVehicle)) // carrr + { + FortDagwoodVehicle->SetFuel(100); + } + + return NewVehicle; } static inline void SpawnVehicles2()