From 9c8b327cd718502567d539b689b9a8fe97f37d7c Mon Sep 17 00:00:00 2001 From: Milxnor Date: Sun, 26 Mar 2023 21:37:47 -0400 Subject: [PATCH] tassetptr impl, harvesting stuff, relevancy? --- Project Reboot 3.0/Actor.cpp | 14 ++++ Project Reboot 3.0/Actor.h | 2 + Project Reboot 3.0/AssetPtr.h | 26 +++++++ Project Reboot 3.0/BuildingActor.cpp | 2 +- Project Reboot 3.0/DataTable.h | 6 ++ Project Reboot 3.0/FortGameModeAthena.cpp | 24 ++++-- Project Reboot 3.0/FortKismetLibrary.cpp | 20 +++++ Project Reboot 3.0/FortLootPackage.cpp | 15 ++-- Project Reboot 3.0/FortPickup.cpp | 2 + Project Reboot 3.0/FortPlayerController.cpp | 2 +- .../FortPlayerControllerAthena.h | 6 ++ Project Reboot 3.0/NetDriver.cpp | 75 +++++++++++++++++-- Project Reboot 3.0/Project Reboot 3.0.vcxproj | 2 + .../Project Reboot 3.0.vcxproj.filters | 9 +++ Project Reboot 3.0/Rotator.h | 3 + Project Reboot 3.0/SoftObjectPtr.h | 15 +++- Project Reboot 3.0/StringAssetReference.h | 8 ++ Project Reboot 3.0/UnrealMath.cpp | 10 +++ Project Reboot 3.0/addresses.cpp | 7 ++ Project Reboot 3.0/addresses.h | 4 +- Project Reboot 3.0/dllmain.cpp | 22 ++++-- Project Reboot 3.0/finder.h | 25 ++++++- Project Reboot 3.0/reboot.h | 5 +- 23 files changed, 267 insertions(+), 37 deletions(-) create mode 100644 Project Reboot 3.0/AssetPtr.h create mode 100644 Project Reboot 3.0/StringAssetReference.h diff --git a/Project Reboot 3.0/Actor.cpp b/Project Reboot 3.0/Actor.cpp index f62aa9e..5c5fa8a 100644 --- a/Project Reboot 3.0/Actor.cpp +++ b/Project Reboot 3.0/Actor.cpp @@ -127,6 +127,20 @@ bool AActor::IsAlwaysRelevant() return ReadBitfieldValue(bAlwaysRelevantOffset, bAlwaysRelevantFieldMask); } +bool AActor::UsesOwnerRelevancy() +{ + static auto bNetUseOwnerRelevancyOffset = GetOffset("bNetUseOwnerRelevancy"); + static auto bNetUseOwnerRelevancyFieldMask = GetFieldMask(GetProperty("bNetUseOwnerRelevancy")); + return ReadBitfieldValue(bNetUseOwnerRelevancyOffset, bNetUseOwnerRelevancyFieldMask); +} + +bool AActor::IsOnlyRelevantToOwner() +{ + static auto bOnlyRelevantToOwnerOffset = GetOffset("bOnlyRelevantToOwner"); + static auto bOnlyRelevantToOwnerFieldMask = GetFieldMask(GetProperty("bOnlyRelevantToOwner")); + return ReadBitfieldValue(bOnlyRelevantToOwnerOffset, bOnlyRelevantToOwnerFieldMask); +} + UClass* AActor::StaticClass() { static auto Class = FindObject(L"/Script/Engine.Actor"); diff --git a/Project Reboot 3.0/Actor.h b/Project Reboot 3.0/Actor.h index 794773e..833cb2a 100644 --- a/Project Reboot 3.0/Actor.h +++ b/Project Reboot 3.0/Actor.h @@ -19,6 +19,8 @@ public: bool IsActorBeingDestroyed(); bool IsNetStartup(); bool IsAlwaysRelevant(); + bool UsesOwnerRelevancy(); + bool IsOnlyRelevantToOwner(); void SetOwner(AActor* Owner); static class UClass* StaticClass(); diff --git a/Project Reboot 3.0/AssetPtr.h b/Project Reboot 3.0/AssetPtr.h new file mode 100644 index 0000000..f95e690 --- /dev/null +++ b/Project Reboot 3.0/AssetPtr.h @@ -0,0 +1,26 @@ +#pragma once + +#include "PersistentObjectPtr.h" +#include "StringAssetReference.h" + +#include "reboot.h" + +class FAssetPtr : public TPersistentObjectPtr +{ +public: +}; + +template +class TAssetPtr +{ +public: + FAssetPtr AssetPtr; + + T* Get() + { + if (!AssetPtr.ObjectID.AssetLongPathname.IsValid()) + return nullptr; + + return FindObject(AssetPtr.ObjectID.AssetLongPathname.ToString()); + } +}; \ No newline at end of file diff --git a/Project Reboot 3.0/BuildingActor.cpp b/Project Reboot 3.0/BuildingActor.cpp index 8ed19cf..ec728ab 100644 --- a/Project Reboot 3.0/BuildingActor.cpp +++ b/Project Reboot 3.0/BuildingActor.cpp @@ -39,7 +39,7 @@ void ABuildingActor::OnDamageServerHook(ABuildingActor* BuildingActor, float Dam if (BuildingResourceAmountOverride.RowName.IsValid()) { // auto AssetManager = Cast(GEngine->AssetManager); - // auto GameState = Cast(GetWorld()->GetGGetGameStateAthena); + // auto GameState = Cast(GetWorld()->GetGameStateAthena); UCurveTable* CurveTable = nullptr; // GameState->CurrentPlaylistInfo.BasePlaylist ? GameState->CurrentPlaylistInfo.BasePlaylist->ResourceRates.Get() : nullptr; // LOG_INFO(LogDev, "Before1"); diff --git a/Project Reboot 3.0/DataTable.h b/Project Reboot 3.0/DataTable.h index 5d78fd6..02019bb 100644 --- a/Project Reboot 3.0/DataTable.h +++ b/Project Reboot 3.0/DataTable.h @@ -14,6 +14,12 @@ public: return *(TMap*)(__int64(this) + (RowStructOffset + sizeof(UObject*))); // because after rowstruct is rowmap } + + static UClass* StaticClass() + { + static auto Class = FindObject("/Script/Engine.DataTable"); + return Class; + } }; struct FDataTableRowHandle diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 9e50e19..3a7adfd 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -643,6 +643,8 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena for (auto& LootDrop : LootDrops) AFortPickup::SpawnPickup(LootDrop.ItemDefinition, Location, LootDrop.Count, SpawnFlag, EFortPickupSpawnSource::Unset, LootDrop.LoadedAmmo); } + + CurrentActor->K2_DestroyActor(); } bool bPrint = false; @@ -670,6 +672,8 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena for (auto& LootDrop : LootDrops) AFortPickup::SpawnPickup(LootDrop.ItemDefinition, Location, LootDrop.Count, SpawnFlag, EFortPickupSpawnSource::Unset, LootDrop.LoadedAmmo); } + + CurrentActor->K2_DestroyActor(); } } @@ -717,9 +721,11 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena static auto PartsOffset = FindOffsetStruct("/Script/FortniteGame.CustomCharacterParts", "Parts", false); auto Parts = (UObject**)(__int64(CharacterParts) + PartsOffset); // UCustomCharacterPart* Parts[0x6] - static auto headPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Heads/F_Med_Head1.F_Med_Head1"); - static auto bodyPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Bodies/F_Med_Soldier_01.F_Med_Soldier_01"); - static auto backpackPart = LoadObject("/Game/Characters/CharacterParts/Backpacks/NoBackpack.NoBackpack"); + 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); Parts[(int)EFortCustomPartType::Head] = headPart; Parts[(int)EFortCustomPartType::Body] = bodyPart; @@ -762,9 +768,11 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena if (Globals::bAbilitiesEnabled) { + static auto FortAbilitySetClass = FindObject("/Script/FortniteGame.FortAbilitySet"); + static auto GameplayAbilitySet = Fortnite_Version >= 8.30 ? // LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer") ? - LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer") : - LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_DefaultPlayer.GAS_DefaultPlayer"); + LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer", FortAbilitySetClass) : + LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_DefaultPlayer.GAS_DefaultPlayer", FortAbilitySetClass); LOG_INFO(LogDev, "GameplayAbilitySet {}", __int64(GameplayAbilitySet)); @@ -984,6 +992,12 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena } } + if (Engine_Version <= 420) // not sure if needed on s3-s4 + { + static auto OverriddenBackpackSizeOffset = NewPlayer->GetOffset("OverriddenBackpackSize"); + NewPlayer->Get(OverriddenBackpackSizeOffset) = 5; + } + return Athena_HandleStartingNewPlayerOriginal(GameMode, NewPlayerActor); } diff --git a/Project Reboot 3.0/FortKismetLibrary.cpp b/Project Reboot 3.0/FortKismetLibrary.cpp index 837d77b..b49083c 100644 --- a/Project Reboot 3.0/FortKismetLibrary.cpp +++ b/Project Reboot 3.0/FortKismetLibrary.cpp @@ -6,6 +6,26 @@ UFortResourceItemDefinition* UFortKismetLibrary::K2_GetResourceItemDefinition(EFortResourceType ResourceType) { + if (ResourceType == EFortResourceType::Wood) + { + static auto WoodItemData = FindObject("/Game/Items/ResourcePickups/WoodItemData.WoodItemData"); + return WoodItemData; + } + else if (ResourceType == EFortResourceType::Stone) + { + static auto StoneItemData = FindObject("/Game/Items/ResourcePickups/StoneItemData.StoneItemData"); + return StoneItemData; + } + else if (ResourceType == EFortResourceType::Metal) + { + static auto MetalItemData = FindObject("/Game/Items/ResourcePickups/MetalItemData.MetalItemData"); + return MetalItemData; + } + + return nullptr; + + // The function below doesn't exist on some very old builds. + static auto fn = FindObject(L"/Script/FortniteGame.FortKismetLibrary.K2_GetResourceItemDefinition"); struct { EFortResourceType type; UFortResourceItemDefinition* ret; } params{ResourceType}; diff --git a/Project Reboot 3.0/FortLootPackage.cpp b/Project Reboot 3.0/FortLootPackage.cpp index c647a7a..c8dd07f 100644 --- a/Project Reboot 3.0/FortLootPackage.cpp +++ b/Project Reboot 3.0/FortLootPackage.cpp @@ -156,10 +156,10 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs if (recursive > 10) return LootDrops; - static std::vector LTDTables; - static std::vector LPTables; + /* static */ std::vector LTDTables; + /* static */ std::vector LPTables; - static bool bHasFoundTables = false; + /* static */ bool bHasFoundTables = false; if (!bHasFoundTables) { @@ -168,7 +168,7 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs LTDTables.push_back(LoadObject(L"/Game/Items/Datatables/AthenaLootTierData_Client.AthenaLootTierData_Client")); LPTables.push_back(LoadObject(L"/Game/Items/Datatables/AthenaLootPackages_Client.AthenaLootPackages_Client")); - for (int i = 0; i < LTDTables.size(); i++) + /* for (int i = 0; i < LTDTables.size(); i++) { LOG_INFO(LogDev, "[{}] LTD {}", i, LTDTables.at(i)->GetFullName()); } @@ -176,7 +176,7 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs for (int i = 0; i < LPTables.size(); i++) { LOG_INFO(LogDev, "[{}] LP {}", i, LPTables.at(i)->GetFullName()); - } + } */ } std::vector TierGroupLTDs; @@ -193,14 +193,15 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs // auto TierGroupNameStr = TierGroupName.ToString(); - // LOG_INFO(LogLoot, "LTDRowMapNum: {}", LTDRowMapNum); + // if (bPrint) + // LOG_INFO(LogLoot, "LTDRowMapNum: {} LTD: {}", LTDRowMapNum, IsBadReadPtr(LTD, 8) ? "BadRead" : LTD->GetFullName()); for (int i = 0; i < LTDRowMapNum; i++) { auto& CurrentLTD = LTDRowMap.Pairs.Elements[i].ElementData.Value; auto TierData = (FFortLootTierData*)CurrentLTD.Value(); - if (IsBadReadPtr(TierData, 8)) + if (IsBadReadPtr(TierData, 8)) // this shouldn't be needed continue; if (TierGroupName == TierData->GetTierGroup() && TierData->GetWeight() != 0) diff --git a/Project Reboot 3.0/FortPickup.cpp b/Project Reboot 3.0/FortPickup.cpp index 98fbbd2..c268e8a 100644 --- a/Project Reboot 3.0/FortPickup.cpp +++ b/Project Reboot 3.0/FortPickup.cpp @@ -61,6 +61,8 @@ AFortPickup* AFortPickup::SpawnPickup(UFortItemDefinition* ItemDef, FVector Loca char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup) { + // LOG_INFO(LogDev, "Woah!"); + auto Pawn = Cast(Pickup->GetPickupLocationData()->GetPickupTarget()); if (!Pawn) diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 31a696d..09f68c0 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -768,7 +768,7 @@ void AFortPlayerController::ServerBeginEditingBuildingActorHook(AFortPlayerContr if (!BuildingActorToEdit || !BuildingActorToEdit->IsPlayerPlaced()) return; - auto Pawn = Cast(PlayerController->GetPawn(), false); + auto Pawn = PlayerController->GetMyFortPawn(); if (!Pawn) return; diff --git a/Project Reboot 3.0/FortPlayerControllerAthena.h b/Project Reboot 3.0/FortPlayerControllerAthena.h index 6332991..1bd185d 100644 --- a/Project Reboot 3.0/FortPlayerControllerAthena.h +++ b/Project Reboot 3.0/FortPlayerControllerAthena.h @@ -75,4 +75,10 @@ public: static void ServerAcknowledgePossessionHook(APlayerController* Controller, APawn* Pawn); static void ServerPlaySquadQuickChatMessage(AFortPlayerControllerAthena* PlayerController, __int64 ChatEntry, __int64 SenderID); static void GetPlayerViewPointHook(AFortPlayerControllerAthena* PlayerController, FVector& Location, FRotator& Rotation); + + static UClass* StaticClass() + { + static auto Class = FindObject("/Script/FortniteGame.FortPlayerControllerAthena"); + 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 6097312..adb165c 100644 --- a/Project Reboot 3.0/NetDriver.cpp +++ b/Project Reboot 3.0/NetDriver.cpp @@ -3,6 +3,7 @@ #include "reboot.h" #include "Actor.h" #include "NetConnection.h" +#include "FortPlayerControllerAthena.h" #include "GameplayStatics.h" void UNetDriver::TickFlushHook(UNetDriver* NetDriver) @@ -178,6 +179,62 @@ static UActorChannel* FindChannel(AActor* Actor, UNetConnection* Connection) return NULL; } +struct FNetViewer +{ + UNetConnection* Connection; // 0x0000(0x0008) (ZeroConstructor, IsPlainOldData) + AActor* InViewer; // 0x0008(0x0008) (ZeroConstructor, IsPlainOldData) + AActor* ViewTarget; // 0x0010(0x0008) (ZeroConstructor, IsPlainOldData) + FVector ViewLocation; // 0x0018(0x000C) (IsPlainOldData) + FVector ViewDir; +}; + +static bool IsActorRelevantToConnection(AActor* Actor, std::vector& ConnectionViewers) +{ + for (int32 viewerIdx = 0; viewerIdx < ConnectionViewers.size(); viewerIdx++) + { + if (!ConnectionViewers[viewerIdx].ViewTarget) + continue; + + // static bool (*IsNetRelevantFor)(AActor*, AActor*, AActor*, FVector&) = decltype(IsNetRelevantFor)(__int64(GetModuleHandleW(0)) + 0x1ECC700); + + static auto index = Offsets::IsNetRelevantFor; + + // if (Actor->IsNetRelevantFor(ConnectionViewers[viewerIdx].InViewer, ConnectionViewers[viewerIdx].ViewTarget, ConnectionViewers[viewerIdx].ViewLocation)) + // if (IsNetRelevantFor(Actor, ConnectionViewers[viewerIdx].InViewer, ConnectionViewers[viewerIdx].ViewTarget, ConnectionViewers[viewerIdx].ViewLocation)) + if (reinterpret_cast(Actor->VFTable[index])( + Actor, ConnectionViewers[viewerIdx].InViewer, ConnectionViewers[viewerIdx].ViewTarget, ConnectionViewers[viewerIdx].ViewLocation)) + { + return true; + } + } + + return false; +} + +static FNetViewer ConstructNetViewer(UNetConnection* NetConnection) +{ + FNetViewer newViewer{}; + newViewer.Connection = NetConnection; + newViewer.InViewer = NetConnection->GetPlayerController() ? NetConnection->GetPlayerController() : NetConnection->GetOwningActor(); + newViewer.ViewTarget = NetConnection->GetViewTarget(); + + if (!NetConnection->GetOwningActor() || !(!NetConnection->GetPlayerController() || (NetConnection->GetPlayerController() == NetConnection->GetOwningActor()))) + return newViewer; + + APlayerController* ViewingController = NetConnection->GetPlayerController(); + + newViewer.ViewLocation = newViewer.ViewTarget->GetActorLocation(); + + if (ViewingController) + { + FRotator ViewRotation = ViewingController->GetControlRotation(); + AFortPlayerControllerAthena::GetPlayerViewPointHook(Cast(ViewingController, false), newViewer.ViewLocation, ViewRotation); + newViewer.ViewDir = ViewRotation.Vector(); + } + + return newViewer; +} + int32 UNetDriver::ServerReplicateActors() { int32 Updated = 0; @@ -202,7 +259,7 @@ int32 UNetDriver::ServerReplicateActors() } else */ { - ServerTickTime = 1.f / ServerTickTime; + ServerTickTime = 1.f / ServerTickTime; // 0 // bCPUSaturated = DeltaSeconds > 1.2f * ServerTickTime; } @@ -241,25 +298,27 @@ int32 UNetDriver::ServerReplicateActors() auto Channel = FindChannel(Actor, Connection); - /* std::vector ConnectionViewers; + static void (*ActorChannelClose)(UActorChannel*) = decltype(ActorChannelClose)(Addresses::ActorChannelClose); + + std::vector ConnectionViewers; ConnectionViewers.push_back(ConstructNetViewer(Connection)); - if (!Actor->bAlwaysRelevant && !Actor->bNetUseOwnerRelevancy && !Actor->bOnlyRelevantToOwner) + if (!Actor->IsAlwaysRelevant() && !Actor->UsesOwnerRelevancy() && !Actor->IsOnlyRelevantToOwner()) { - if (Connection && Connection->ViewTarget) + if (Connection && Connection->GetViewTarget()) { - auto Viewer = Connection->ViewTarget; - auto Loc = Viewer->K2_GetActorLocation(); + auto Viewer = Connection->GetViewTarget(); + auto Loc = Viewer->GetActorLocation(); if (!IsActorRelevantToConnection(Actor, ConnectionViewers)) { if (Channel) - CloseChannel(Channel); + ActorChannelClose(Channel); continue; } } - } */ + } static UChannel* (*CreateChannel)(UNetConnection*, int, bool, int32_t) = decltype(CreateChannel)(Addresses::CreateChannel); static __int64 (*ReplicateActor)(UActorChannel*) = decltype(ReplicateActor)(Addresses::ReplicateActor); diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj b/Project Reboot 3.0/Project Reboot 3.0.vcxproj index d5ab8c7..d3f70ac 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj @@ -226,6 +226,7 @@ + @@ -313,6 +314,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 8f56583..f00dc49 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -461,6 +461,12 @@ Engine\Source\Runtime\Engine\Classes\GameFramework + + Engine\Source\Runtime\CoreUObject\Public\UObject + + + Engine\Source\Runtime\CoreUObject\Public\Misc + @@ -643,6 +649,9 @@ {7905895d-5ebf-4313-a9de-06f507c35113} + + {915f7622-6003-445e-a43f-04d5c7e13b49} + diff --git a/Project Reboot 3.0/Rotator.h b/Project Reboot 3.0/Rotator.h index 5a55e29..c8f38b1 100644 --- a/Project Reboot 3.0/Rotator.h +++ b/Project Reboot 3.0/Rotator.h @@ -1,6 +1,7 @@ #pragma once #include "Quat.h" +#include "Vector.h" struct FRotator { @@ -9,4 +10,6 @@ struct FRotator float Roll; FQuat Quaternion(); + + FVector Vector() const; }; \ No newline at end of file diff --git a/Project Reboot 3.0/SoftObjectPtr.h b/Project Reboot 3.0/SoftObjectPtr.h index 7a46e67..85793ee 100644 --- a/Project Reboot 3.0/SoftObjectPtr.h +++ b/Project Reboot 3.0/SoftObjectPtr.h @@ -4,6 +4,7 @@ #include "PersistentObjectPtr.h" #include "SoftObjectPath.h" +#include "AssetPtr.h" #include "reboot.h" @@ -20,9 +21,17 @@ public: T* Get() { - if (SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value <= 0) - return nullptr; + if (Engine_Version <= 416) + { + auto& AssetPtr = *(TAssetPtr*)this; + return AssetPtr.Get(); + } + else + { + if (SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value <= 0) + return nullptr; - return FindObject(SoftObjectPtr.ObjectID.AssetPathName.ToString()); + return FindObject(SoftObjectPtr.ObjectID.AssetPathName.ToString()); + } } }; \ No newline at end of file diff --git a/Project Reboot 3.0/StringAssetReference.h b/Project Reboot 3.0/StringAssetReference.h new file mode 100644 index 0000000..44d2ee6 --- /dev/null +++ b/Project Reboot 3.0/StringAssetReference.h @@ -0,0 +1,8 @@ +#pragma once + +#include "UnrealString.h" + +struct FStringAssetReference +{ + FString AssetLongPathname; +}; \ No newline at end of file diff --git a/Project Reboot 3.0/UnrealMath.cpp b/Project Reboot 3.0/UnrealMath.cpp index 9f6ceaa..2f2e4b9 100644 --- a/Project Reboot 3.0/UnrealMath.cpp +++ b/Project Reboot 3.0/UnrealMath.cpp @@ -101,4 +101,14 @@ struct FQuat FRotator::Quaternion() #endif return RotationQuat; +} + +FVector FRotator::Vector() const +{ + float CP, SP, CY, SY; + SinCos(&SP, &CP, Pitch * (PI / 180.0f)); + SinCos(&SY, &CY, Yaw * (PI / 180.0f)); + FVector V = FVector(CP * CY, CP * SY, SP); + + return V; } \ No newline at end of file diff --git a/Project Reboot 3.0/addresses.cpp b/Project Reboot 3.0/addresses.cpp index a2c9bf0..6fad3fb 100644 --- a/Project Reboot 3.0/addresses.cpp +++ b/Project Reboot 3.0/addresses.cpp @@ -246,6 +246,9 @@ void Addresses::FindAll() LOG_INFO(LogDev, "Finding RemoveFromAlivePlayers"); Addresses::RemoveFromAlivePlayers = FindRemoveFromAlivePlayers(); + LOG_INFO(LogDev, "Finding ActorChannelClose"); + Addresses::ActorChannelClose = FindActorChannelClose(); + LOG_INFO(LogDev, "Finished finding!"); } @@ -297,6 +300,7 @@ void Addresses::Print() LOG_INFO(LogDev, "OnRep_ZiplineState: 0x{:x}", OnRep_ZiplineState - Base); LOG_INFO(LogDev, "GetMaxTickRate: 0x{:x}", GetMaxTickRate - Base); LOG_INFO(LogDev, "RemoveFromAlivePlayers: 0x{:x}", RemoveFromAlivePlayers - Base); + LOG_INFO(LogDev, "ActorChannelClose: 0x{:x}", ActorChannelClose - Base); } void Offsets::FindAll() @@ -343,6 +347,8 @@ void Offsets::FindAll() Offsets::ReplicationFrame = 0xB2; else if (Fortnite_Version == 2.5) Offsets::ReplicationFrame = 0xCA; + + Offsets::IsNetRelevantFor = FindIsNetRelevantForOffset(); } void Offsets::Print() @@ -354,6 +360,7 @@ void Offsets::Print() LOG_INFO(LogDev, "Func: 0x{:x}", Func); LOG_INFO(LogDev, "ServerReplicateActors: 0x{:x}", ServerReplicateActors); LOG_INFO(LogDev, "ReplicationFrame: 0x{:x}", ReplicationFrame); + LOG_INFO(LogDev, "IsNetRelevantFor: 0x{:x}", IsNetRelevantFor); } void Addresses::Init() diff --git a/Project Reboot 3.0/addresses.h b/Project Reboot 3.0/addresses.h index b7d7b45..ce8117f 100644 --- a/Project Reboot 3.0/addresses.h +++ b/Project Reboot 3.0/addresses.h @@ -52,6 +52,7 @@ namespace Addresses extern inline uint64 FrameStep = 0; extern inline uint64 OnRep_ZiplineState = 0; extern inline uint64 RemoveFromAlivePlayers = 0; + extern inline uint64 ActorChannelClose = 0; void SetupVersion(); // Finds Engine Version void FindAll(); @@ -70,7 +71,8 @@ namespace Offsets extern inline uint64 Offset_Internal = 0; extern inline uint64 ServerReplicateActors = 0; extern inline uint64 ReplicationFrame = 0; - + extern inline uint64 IsNetRelevantFor = 0; + void FindAll(); void Print(); } diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index 343848a..29cc7d7 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -362,18 +362,23 @@ DWORD WINAPI Main(LPVOID) if (false) { - Hooking::MinHook::Hook(AthenaMarkerComponentDefault, FindObject(L"/Script/FortniteGame.AthenaMarkerComponent.ServerAddMapMarker"), - UAthenaMarkerComponent::ServerAddMapMarkerHook, nullptr, false); - Hooking::MinHook::Hook(AthenaMarkerComponentDefault, FindObject(L"/Script/FortniteGame.AthenaMarkerComponent.ServerRemoveMapMarker"), - UAthenaMarkerComponent::ServerRemoveMapMarkerHook, nullptr, false); + if (Fortnite_Version >= 8.3) // I can't remember, so ServerAddMapMarker existed on like 8.0 or 8.1 or 8.2 but it didn't have the same params. + { + Hooking::MinHook::Hook(AthenaMarkerComponentDefault, FindObject(L"/Script/FortniteGame.AthenaMarkerComponent.ServerAddMapMarker"), + UAthenaMarkerComponent::ServerAddMapMarkerHook, nullptr, false); + Hooking::MinHook::Hook(AthenaMarkerComponentDefault, FindObject(L"/Script/FortniteGame.AthenaMarkerComponent.ServerRemoveMapMarker"), + UAthenaMarkerComponent::ServerRemoveMapMarkerHook, nullptr, false); + } } Hooking::MinHook::Hook((PVOID)Addresses::GetPlayerViewpoint, (PVOID)AFortPlayerControllerAthena::GetPlayerViewPointHook, (PVOID*)&AFortPlayerControllerAthena::GetPlayerViewPointOriginal); Hooking::MinHook::Hook((PVOID)Addresses::TickFlush, (PVOID)UNetDriver::TickFlushHook, (PVOID*)&UNetDriver::TickFlushOriginal); // Hooking::MinHook::Hook((PVOID)(__int64(GetModuleHandleW(0)) + 0x1A001D0), GetServerDeltaTimeFromObjectHook); - if (Engine_Version < 427) + // if (/* Engine_Version >= 420 && */ Engine_Version < 427) + { Hooking::MinHook::Hook((PVOID)Addresses::OnDamageServer, (PVOID)ABuildingActor::OnDamageServerHook, (PVOID*)&ABuildingActor::OnDamageServerOriginal); + } Hooking::MinHook::Hook((PVOID)Addresses::GetMaxTickRate, GetMaxTickRateHook); // Hooking::MinHook::Hook((PVOID)Addresses::CollectGarbage, (PVOID)CollectGarbageHook, nullptr); @@ -390,8 +395,11 @@ DWORD WINAPI Main(LPVOID) AddVehicleHook(); - LOG_INFO(LogDev, "Test: 0x{:x}", FindFunctionCall(L"ClientOnPawnDied") - __int64(GetModuleHandleW(0))); - Hooking::MinHook::Hook((PVOID)FindFunctionCall(L"ClientOnPawnDied"), AFortPlayerController::ClientOnPawnDiedHook, (PVOID*)&AFortPlayerController::ClientOnPawnDiedOriginal); + if (Fortnite_Version > 1.8) + { + LOG_INFO(LogDev, "Test: 0x{:x}", FindFunctionCall(L"ClientOnPawnDied") - __int64(GetModuleHandleW(0))); + Hooking::MinHook::Hook((PVOID)FindFunctionCall(L"ClientOnPawnDied"), AFortPlayerController::ClientOnPawnDiedHook, (PVOID*)&AFortPlayerController::ClientOnPawnDiedOriginal); + } 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 e527851..28920af 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -308,9 +308,23 @@ static inline uint64 FindGetPlayerViewpoint() return 0; } +static inline uint64 FindIsNetRelevantForOffset() +{ + if (Engine_Version == 416) + return 648 / 8; + + return 0; +} + +static inline uint64 FindActorChannelClose() +{ + auto StringRef = Memcury::Scanner::FindStringRef(L"UActorChannel::Close: ChIndex: %d, Actor: %s"); + + return FindBytes(StringRef, { 0x48, 0x89, 0x5C }, 1000, 0, true); +} + static inline uint64 FindSpawnActor() { - if (Engine_Version >= 427) { auto stat = Memcury::Scanner::FindStringRef(L"STAT_SpawnActorTime"); @@ -366,7 +380,11 @@ static inline uint64 FindInitListen() static inline uint64 FindOnDamageServer() { - auto Addr = FindFunctionCall(L"OnDamageServer", { 0x40, 0x55 }); + auto Addr = FindFunctionCall(L"OnDamageServer", + Engine_Version == 416 ? std::vector{ 0x4C, 0x89, 0x4C} : + Engine_Version == 419 || Engine_Version >= 427 ? std::vector{ 0x48, 0x8B, 0xC4 } : std::vector{ 0x40, 0x55 } + ); + return Addr; } @@ -437,6 +455,9 @@ static inline uint64 FindSpecConstructor() static inline uint64 FindCompletePickupAnimation() { + if (Engine_Version == 416 || Engine_Version == 419) + return Memcury::Scanner::FindPattern("4C 8B DC 53 55 56 48 83 EC 60 48 8B F1 48 8B 89 ? ? ? ? 48 85 C9").Get(); + if (Engine_Version == 420) return Memcury::Scanner::FindPattern("48 89 5C 24 ? 57 48 83 EC 20 48 8B D9 48 8B 89 ? ? ? ? 48 85 C9 74 20 48 8D 44 24").Get(); diff --git a/Project Reboot 3.0/reboot.h b/Project Reboot 3.0/reboot.h index 5f89d0d..5029543 100644 --- a/Project Reboot 3.0/reboot.h +++ b/Project Reboot 3.0/reboot.h @@ -24,7 +24,7 @@ static inline T* FindObject(const TCHAR* Name, UClass* Class = nullptr, UObject* } template -static inline T* LoadObject(const TCHAR* Name, UClass* Class = nullptr, UObject* Outer = nullptr) +static inline T* LoadObject(const TCHAR* Name, UClass* Class = T::StaticClass(), UObject* Outer = nullptr) { if (!StaticLoadObjectOriginal) { @@ -46,7 +46,8 @@ static inline T* LoadObject(const std::string& NameStr, UClass* Class = nullptr, template static inline T* FindObject(const std::string& NameStr, UClass* Class = nullptr, UObject* Outer = nullptr) { - auto NameCWSTR = std::wstring(NameStr.begin(), NameStr.end()).c_str(); + std::string name = NameStr; + auto NameCWSTR = std::wstring(name.begin(), name.end()).c_str(); return StaticFindObject(Class, Outer, NameCWSTR); }