From 4c19144b0f3fd7d9dea5b75265ba6d63b451665c Mon Sep 17 00:00:00 2001 From: Milxnor Date: Wed, 26 Apr 2023 23:22:22 -0400 Subject: [PATCH] Add random defaults 1.7.2, some other internal stuff --- Project Reboot 3.0/FortGameModeAthena.cpp | 21 ++-- Project Reboot 3.0/FortGameModeAthena.h | 13 ++- Project Reboot 3.0/FortInventory.h | 18 --- Project Reboot 3.0/FortItemDefinition.h | 18 +++ Project Reboot 3.0/FortPlayerController.cpp | 7 +- Project Reboot 3.0/FortPlayerController.h | 12 +- .../FortPlayerControllerAthena.h | 105 +++++++++--------- Project Reboot 3.0/GameModeBase.cpp | 4 +- Project Reboot 3.0/SoftObjectPtr.h | 7 +- Project Reboot 3.0/dllmain.cpp | 23 +++- 10 files changed, 139 insertions(+), 89 deletions(-) diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 220b153..7182e0d 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -929,20 +929,19 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena if (!PlayerStateAthena) return Athena_HandleStartingNewPlayerOriginal(GameMode, NewPlayerActor); - if (Globals::bNoMCP || Engine_Version == 416) - { - static auto CharacterPartsOffset = PlayerStateAthena->GetOffset("CharacterParts", false); - static auto CustomCharacterPartsStruct = FindObject("/Script/FortniteGame.CustomCharacterParts"); + static auto CharacterPartsOffset = PlayerStateAthena->GetOffset("CharacterParts", false); + static auto CustomCharacterPartsStruct = FindObject("/Script/FortniteGame.CustomCharacterParts"); + auto CharacterParts = PlayerStateAthena->GetPtr<__int64>("CharacterParts"); + static auto PartsOffset = FindOffsetStruct("/Script/FortniteGame.CustomCharacterParts", "Parts", false); + auto Parts = (UObject**)(__int64(CharacterParts) + PartsOffset); // UCustomCharacterPart* Parts[0x6] + + static auto CustomCharacterPartClass = FindObject("/Script/FortniteGame.CustomCharacterPart"); + + if (Globals::bNoMCP) + { if (CharacterPartsOffset != -1) // && CustomCharacterPartsStruct) { - auto CharacterParts = PlayerStateAthena->GetPtr<__int64>("CharacterParts"); - - static auto PartsOffset = FindOffsetStruct("/Script/FortniteGame.CustomCharacterParts", "Parts", false); - auto Parts = (UObject**)(__int64(CharacterParts) + PartsOffset); // UCustomCharacterPart* Parts[0x6] - - static auto CustomCharacterPartClass = FindObject("/Script/FortniteGame.CustomCharacterPart"); - static auto headPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Heads/F_Med_Head1.F_Med_Head1", CustomCharacterPartClass); static auto bodyPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Bodies/F_Med_Soldier_01.F_Med_Soldier_01", CustomCharacterPartClass); static auto backpackPart = LoadObject("/Game/Characters/CharacterParts/Backpacks/NoBackpack.NoBackpack", CustomCharacterPartClass); diff --git a/Project Reboot 3.0/FortGameModeAthena.h b/Project Reboot 3.0/FortGameModeAthena.h index 20fb8fc..3ffbbbc 100644 --- a/Project Reboot 3.0/FortGameModeAthena.h +++ b/Project Reboot 3.0/FortGameModeAthena.h @@ -1,13 +1,13 @@ #pragma once #include "FortGameModePvPBase.h" -// #include "FortPlayerControllerAthena.h" #include "FortGameStateAthena.h" #include "KismetStringLibrary.h" #include "reboot.h" #include "BuildingSMActor.h" #include "FortSafeZoneIndicator.h" #include "GameplayStatics.h" +#include "FortItemDefinition.h" struct FAircraftFlightInfo { @@ -158,6 +158,11 @@ static void ShowFoundation(AActor* BuildingFoundation, bool bShow = true) { UGameplayStatics::UnloadStreamLevel(GetWorld(), LevelToStream, FLatentActionInfo(), false); } */ + + // real + + BuildingFoundation->FlushNetDormancy(); + BuildingFoundation->ForceNetUpdate(); } static void StreamLevel(const std::string& LevelName, FVector Location = {}) @@ -210,6 +215,12 @@ public: return (AFortGameStateAthena*)GetGameState(); } + TArray& GetStartingItems() // really in zone + { + static auto StartingItemsOffset = GetOffset("StartingItems"); + return Get>(StartingItemsOffset); + } + FName RedirectLootTier(const FName& LootTier); UClass* GetVehicleClassOverride(UClass* DefaultClass); diff --git a/Project Reboot 3.0/FortInventory.h b/Project Reboot 3.0/FortInventory.h index 05149ec..55491de 100644 --- a/Project Reboot 3.0/FortInventory.h +++ b/Project Reboot 3.0/FortInventory.h @@ -44,24 +44,6 @@ enum class EFortInventoryType : unsigned char MAX = 3, }; -struct FItemAndCount -{ -private: - int Count; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) - unsigned char UnknownData00[0x4]; // 0x0004(0x0004) MISSED OFFSET - UFortItemDefinition* Item; // 0x0008(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) -public: - int& GetCount() - { - return Count; - } - - UFortItemDefinition*& GetItem() - { - return Item; - } -}; - struct FItemGuidAndCount { public: diff --git a/Project Reboot 3.0/FortItemDefinition.h b/Project Reboot 3.0/FortItemDefinition.h index 790cbff..25c043b 100644 --- a/Project Reboot 3.0/FortItemDefinition.h +++ b/Project Reboot 3.0/FortItemDefinition.h @@ -24,4 +24,22 @@ public: static auto Class = FindObject("/Script/FortniteGame.FortItemDefinition"); return Class; } +}; + +struct FItemAndCount +{ +private: + int Count; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) + unsigned char UnknownData00[0x4]; // 0x0004(0x0004) MISSED OFFSET + UFortItemDefinition* Item; // 0x0008(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) +public: + int& GetCount() + { + return Count; + } + + UFortItemDefinition*& GetItem() + { + return Item; + } }; \ No newline at end of file diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 4e2e1b9..d941cc7 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -123,7 +123,7 @@ void AFortPlayerController::ApplyCosmeticLoadout() return; } - auto CosmeticLoadout = this->GetCosmeticLoadout(); + auto CosmeticLoadout = GetCosmeticLoadoutOffset() != -1 ? this->GetCosmeticLoadout() : nullptr; if (CosmeticLoadout) { @@ -168,6 +168,11 @@ void AFortPlayerController::ApplyCosmeticLoadout() } } } + else + { + static auto HeroTypeOffset = PlayerStateAsFort->GetOffset("HeroType"); + ApplyHID(PawnAsFort, PlayerStateAsFort->Get(HeroTypeOffset)); + } PlayerStateAsFort->ForceNetUpdate(); PawnAsFort->ForceNetUpdate(); diff --git a/Project Reboot 3.0/FortPlayerController.h b/Project Reboot 3.0/FortPlayerController.h index 1a995a4..97739f1 100644 --- a/Project Reboot 3.0/FortPlayerController.h +++ b/Project Reboot 3.0/FortPlayerController.h @@ -66,16 +66,22 @@ public: return Get(MyFortPawnOffset); } - FFortAthenaLoadout* GetCosmeticLoadout() + int GetCosmeticLoadoutOffset() { static auto CosmeticLoadoutPCOffset = this->GetOffset("CosmeticLoadoutPC", false); if (CosmeticLoadoutPCOffset == -1) - CosmeticLoadoutPCOffset = this->GetOffset("CustomizationLoadout"); + CosmeticLoadoutPCOffset = this->GetOffset("CustomizationLoadout", false); if (CosmeticLoadoutPCOffset == -1) - return nullptr; + return -1; + return CosmeticLoadoutPCOffset; + } + + FFortAthenaLoadout* GetCosmeticLoadout() + { + static auto CosmeticLoadoutPCOffset = GetCosmeticLoadoutOffset(); auto CosmeticLoadout = this->GetPtr(CosmeticLoadoutPCOffset); return CosmeticLoadout; diff --git a/Project Reboot 3.0/FortPlayerControllerAthena.h b/Project Reboot 3.0/FortPlayerControllerAthena.h index 7c6bc81..94ad278 100644 --- a/Project Reboot 3.0/FortPlayerControllerAthena.h +++ b/Project Reboot 3.0/FortPlayerControllerAthena.h @@ -8,6 +8,59 @@ #include "AthenaMarkerComponent.h" #include "FortVolume.h" +static void ApplyHID(AFortPlayerPawn* Pawn, UObject* HeroDefinition) +{ + using UFortHeroSpecialization = UObject; + + static auto SpecializationsOffset = HeroDefinition->GetOffset("Specializations"); + auto& Specializations = HeroDefinition->Get>>(SpecializationsOffset); + + auto PlayerState = Pawn->GetPlayerState(); + + for (int i = 0; i < Specializations.Num(); i++) + { + auto& SpecializationSoft = Specializations.at(i); + + static auto FortHeroSpecializationClass = FindObject("/Script/FortniteGame.FortHeroSpecialization"); + auto Specialization = SpecializationSoft.Get(FortHeroSpecializationClass, true); + + if (Specialization) + { + static auto Specialization_CharacterPartsOffset = Specialization->GetOffset("CharacterParts"); + auto& CharacterParts = Specialization->Get>>(Specialization_CharacterPartsOffset); + + static auto CustomCharacterPartClass = FindObject("/Script/FortniteGame.CustomCharacterPart"); + + /* if (bUseServerChoosePart) + { + for (int z = 0; z < CharacterParts.Num(); z++) + { + Pawn->ServerChoosePart((EFortCustomPartType)z, CharacterParts.at(z).Get(CustomCharacterPartClass, true)); + } + + continue; // hm? + } */ + + bool aa; + + TArray CharacterPartsaa; + + for (int z = 0; z < CharacterParts.Num(); z++) + { + auto& CharacterPartSoft = CharacterParts.at(z, GetSoftObjectSize()); + auto CharacterPart = CharacterPartSoft.Get(CustomCharacterPartClass, true); + + CharacterPartsaa.Add(CharacterPart); + + continue; + } + + UFortKismetLibrary::ApplyCharacterCosmetics(GetWorld(), CharacterPartsaa, PlayerState, &aa); + CharacterPartsaa.Free(); + } + } +} + static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChoosePart = false) { if (!CID) @@ -46,57 +99,9 @@ static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChooseP static auto HeroDefinitionOffset = CID->GetOffset("HeroDefinition"); auto HeroDefinition = CID->Get(HeroDefinitionOffset); - using UFortHeroSpecialization = UObject; + ApplyHID(Pawn, HeroDefinition); - static auto SpecializationsOffset = HeroDefinition->GetOffset("Specializations"); - auto& Specializations = HeroDefinition->Get>>(SpecializationsOffset); - - auto PlayerState = Pawn->GetPlayerState(); - - for (int i = 0; i < Specializations.Num(); i++) - { - auto& SpecializationSoft = Specializations.at(i); - - static auto FortHeroSpecializationClass = FindObject("/Script/FortniteGame.FortHeroSpecialization"); - auto Specialization = SpecializationSoft.Get(FortHeroSpecializationClass, true); - - if (Specialization) - { - static auto Specialization_CharacterPartsOffset = Specialization->GetOffset("CharacterParts"); - auto& CharacterParts = Specialization->Get>>(Specialization_CharacterPartsOffset); - - static auto CustomCharacterPartClass = FindObject("/Script/FortniteGame.CustomCharacterPart"); - - /* if (bUseServerChoosePart) - { - for (int z = 0; z < CharacterParts.Num(); z++) - { - Pawn->ServerChoosePart((EFortCustomPartType)z, CharacterParts.at(z).Get(CustomCharacterPartClass, true)); - } - - continue; // hm? - } */ - - bool aa; - - TArray CharacterPartsaa; - - for (int z = 0; z < CharacterParts.Num(); z++) - { - auto& CharacterPartSoft = CharacterParts.at(z); - auto CharacterPart = CharacterPartSoft.Get(CustomCharacterPartClass, true); - - CharacterPartsaa.Add(CharacterPart); - - continue; - } - - UFortKismetLibrary::ApplyCharacterCosmetics(GetWorld(), CharacterPartsaa, PlayerState, &aa); - CharacterPartsaa.Free(); - } - } - - static auto HeroTypeOffset = PlayerState->GetOffset("HeroType"); + // static auto HeroTypeOffset = PlayerState->GetOffset("HeroType"); // PlayerState->Get(HeroTypeOffset) = HeroDefinition; return true; diff --git a/Project Reboot 3.0/GameModeBase.cpp b/Project Reboot 3.0/GameModeBase.cpp index 8975267..c8e5fe8 100644 --- a/Project Reboot 3.0/GameModeBase.cpp +++ b/Project Reboot 3.0/GameModeBase.cpp @@ -90,12 +90,12 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll { // TODO Check Playlist->bRequirePickaxeInStartingInventory - auto CosmeticLoadout = NewPlayerAsAthena->GetCosmeticLoadout(); + auto CosmeticLoadout = NewPlayerAsAthena->GetCosmeticLoadoutOffset() != -1 ? NewPlayerAsAthena->GetCosmeticLoadout() : nullptr; // LOG_INFO(LogDev, "CosmeticLoadout: {}", __int64(CosmeticLoadout)); auto CosmeticLoadoutPickaxe = CosmeticLoadout ? CosmeticLoadout->GetPickaxe() : nullptr; // LOG_INFO(LogDev, "CosmeticLoadoutPickaxe: {}", __int64(CosmeticLoadoutPickaxe)); // LOG_INFO(LogDev, "CosmeticLoadoutPickaxe Name: {}", CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->GetFullName() : "InvalidObject"); - static auto WeaponDefinitionOffset = FindOffsetStruct("/Script/FortniteGame.AthenaPickaxeItemDefinition", "WeaponDefinition"); + static auto WeaponDefinitionOffset = FindOffsetStruct("/Script/FortniteGame.AthenaPickaxeItemDefinition", "WeaponDefinition", false); auto PickaxeDefinition = CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->Get(WeaponDefinitionOffset) : FindObject(L"/Game/Athena/Items/Weapons/WID_Harvest_Pickaxe_Athena_C_T01.WID_Harvest_Pickaxe_Athena_C_T01"); diff --git a/Project Reboot 3.0/SoftObjectPtr.h b/Project Reboot 3.0/SoftObjectPtr.h index 7f13da6..43ad475 100644 --- a/Project Reboot 3.0/SoftObjectPtr.h +++ b/Project Reboot 3.0/SoftObjectPtr.h @@ -52,4 +52,9 @@ public: return FindObject(SoftObjectPtr.ObjectID.AssetPathName.ToString()); } } -}; \ No newline at end of file +}; + +static inline int GetSoftObjectSize() +{ + return Engine_Version == 416 ? sizeof(TAssetPtr) : sizeof(TSoftObjectPtr); +} \ No newline at end of file diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index cd018a0..c6872ae 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -100,7 +100,26 @@ void __fastcall ApplyHomebaseEffectsOnPlayerSetupHook( { LOG_INFO(LogDev, "Old hero: {}", Hero ? Hero->GetFullName() : "InvalidObject"); - auto HeroType = FindObject("/Game/Athena/Heroes/HID_030_Athena_Commando_M_Halloween.HID_030_Athena_Commando_M_Halloween"); + UFortItemDefinition* HeroType = FindObject("/Game/Athena/Heroes/HID_030_Athena_Commando_M_Halloween.HID_030_Athena_Commando_M_Halloween"); + + if (Fortnite_Version == 1.72) + { + auto AllHeroTypes = GetAllObjectsOfClass(FindObject("/Script/FortniteGame.FortHeroType")); + std::vector AthenaHeroTypes; + + 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 ItemDefinitionOffset = Hero->GetOffset("ItemDefinition"); Hero->Get(ItemDefinitionOffset) = HeroType; @@ -359,7 +378,7 @@ DWORD WINAPI Main(LPVOID) if (Engine_Version < 420) { - auto ApplyHomebaseEffectsOnPlayerSetupAddr = Memcury::Scanner::FindPattern("40 55 53 57 41 54 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 00 4C 8B BD ? ? ? ? 49").Get(); + auto ApplyHomebaseEffectsOnPlayerSetupAddr = Memcury::Scanner::FindPattern("40 55 53 57 41 54 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 00 4C 8B").Get(); Hooking::MinHook::Hook((PVOID)ApplyHomebaseEffectsOnPlayerSetupAddr, ApplyHomebaseEffectsOnPlayerSetupHook, (PVOID*)&ApplyHomebaseEffectsOnPlayerSetupOriginal); }