From 779c932b3f7f9a3a2af82e2deb5472a96f1926e2 Mon Sep 17 00:00:00 2001 From: Milxnor Date: Tue, 20 Jun 2023 08:36:24 -0400 Subject: [PATCH] fix some versions fixed s18 (I think), did something to teams, reverted harvesting thing because it was buggy --- Project Reboot 3.0/BuildingActor.cpp | 6 +++++- Project Reboot 3.0/FortGameModeAthena.cpp | 13 ++++++++++-- .../FortGameSessionDedicatedAthena.cpp | 6 ++++++ Project Reboot 3.0/FortKismetLibrary.cpp | 2 +- Project Reboot 3.0/OnlineReplStructs.h | 20 +++++++++++-------- Project Reboot 3.0/dllmain.cpp | 1 + Project Reboot 3.0/finder.cpp | 2 +- Project Reboot 3.0/finder.h | 2 +- Project Reboot 3.0/hooking.h | 9 ++++++++- 9 files changed, 46 insertions(+), 15 deletions(-) diff --git a/Project Reboot 3.0/BuildingActor.cpp b/Project Reboot 3.0/BuildingActor.cpp index 9cdfee3..157aae3 100644 --- a/Project Reboot 3.0/BuildingActor.cpp +++ b/Project Reboot 3.0/BuildingActor.cpp @@ -28,6 +28,8 @@ void ABuildingActor::OnDamageServerHook(ABuildingActor* BuildingActor, float Dam if (BuildingSMActor->IsDestroyed()) return OnDamageServerOriginal(BuildingActor, Damage, DamageTags, Momentum, HitInfo, InstigatedBy, DamageCauser, EffectContext); + /* + static auto LastDamageAmountOffset = BuildingSMActor->GetOffset("LastDamageAmount"); static auto LastDamageHitOffset = BuildingSMActor->GetOffset("LastDamageHit", false) != -1 ? BuildingSMActor->GetOffset("LastDamageHit") : BuildingSMActor->GetOffset("LastDamageHitImpulseDir"); // idc @@ -38,6 +40,8 @@ void ABuildingActor::OnDamageServerHook(ABuildingActor* BuildingActor, float Dam BuildingSMActor->Get(LastDamageAmountOffset) = Damage; BuildingSMActor->Get(LastDamageHitOffset) = CurrentBuildingHealth; + */ + if (!PlayerController || !Weapon) return OnDamageServerOriginal(BuildingActor, Damage, DamageTags, Momentum, HitInfo, InstigatedBy, DamageCauser, EffectContext); @@ -84,7 +88,7 @@ void ABuildingActor::OnDamageServerHook(ABuildingActor* BuildingActor, float Dam // LOG_INFO(LogDev, "Out: {}", Out); - const float DamageThatWillAffect = PreviousLastDamageHit > 0 && Damage > PreviousLastDamageHit ? PreviousLastDamageHit : Damage; + const float DamageThatWillAffect = /* PreviousLastDamageHit > 0 && Damage > PreviousLastDamageHit ? PreviousLastDamageHit : */ Damage; float skid = Out / (BuildingActor->GetMaxHealth() / DamageThatWillAffect); diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 0c2d5e2..259cdc0 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -699,12 +699,21 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game } else { - auto S19Patch = Memcury::Scanner::FindPattern("74 1A 48 8D 97 ? ? ? ? 49 8B CF E8 ? ? ? ? 88 87 ? ? ? ? E9").Get(); + auto S19Patch = Memcury::Scanner::FindPattern("74 1A 48 8D 97 ? ? ? ? 49 8B CF E8 ? ? ? ? 88 87 ? ? ? ? E9", false).Get(); if (S19Patch) { PatchByte(S19Patch, 0x75); } + else + { + auto S18Patch = Memcury::Scanner::FindPattern("75 02 33 F6 41 BE ? ? ? ? 48 85 F6 74 17 48 8D 93").Get(); + + if (S18Patch) + { + PatchByte(S18Patch, 0x74); + } + } } if (bEnableRebooting) @@ -776,7 +785,7 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game { auto CurrentRebootVan = (ABuildingGameplayActorSpawnMachine*)AllRebootVans.at(i); static auto FortPlayerStartClass = FindObject(L"/Script/FortniteGame.FortPlayerStart"); - CurrentRebootVan->GetResurrectLocation() = CurrentRebootVan->GetClosestActor(FortPlayerStartClass, 300); + CurrentRebootVan->GetResurrectLocation() = CurrentRebootVan->GetClosestActor(FortPlayerStartClass, 450); } AllRebootVans.Free(); diff --git a/Project Reboot 3.0/FortGameSessionDedicatedAthena.cpp b/Project Reboot 3.0/FortGameSessionDedicatedAthena.cpp index c2aed41..9a047b7 100644 --- a/Project Reboot 3.0/FortGameSessionDedicatedAthena.cpp +++ b/Project Reboot 3.0/FortGameSessionDedicatedAthena.cpp @@ -20,10 +20,16 @@ uint8 AFortGameSessionDedicatedAthena::GetSquadIdForCurrentPlayerHook(AFortGameS if (!PlayerState) continue; + // return PlayerState->GetTeamIndex() - NumToSubtractFromSquadId; + static auto UniqueIdOffset = PlayerState->GetOffset("UniqueId"); + if (IsBadReadPtr(PlayerState->GetPtr(UniqueIdOffset))) + continue; + if (PlayerState->GetPtr(UniqueIdOffset)->IsIdentical((FUniqueNetIdRepl*)&UniqueId)) { + LOG_INFO(LogDev, "Found!"); return PlayerState->GetTeamIndex() - NumToSubtractFromSquadId; } } diff --git a/Project Reboot 3.0/FortKismetLibrary.cpp b/Project Reboot 3.0/FortKismetLibrary.cpp index e569a23..7db7894 100644 --- a/Project Reboot 3.0/FortKismetLibrary.cpp +++ b/Project Reboot 3.0/FortKismetLibrary.cpp @@ -645,7 +645,7 @@ bool UFortKismetLibrary::PickLootDropsHook(UObject* Context, FFrame& Stack, bool LOG_INFO(LogDev, "Picking loot for {}.", TierGroupName.ComparisonIndex.Value ? TierGroupName.ToString() : "InvalidName"); - auto LootDrops = PickLootDrops(TierGroupName, GameState->GetWorldLevel(), -1, true); + auto LootDrops = PickLootDrops(TierGroupName, WorldLevel, ForcedLootTier); for (int i = 0; i < LootDrops.size(); i++) { diff --git a/Project Reboot 3.0/OnlineReplStructs.h b/Project Reboot 3.0/OnlineReplStructs.h index c1d9301..7f8d0f6 100644 --- a/Project Reboot 3.0/OnlineReplStructs.h +++ b/Project Reboot 3.0/OnlineReplStructs.h @@ -8,7 +8,7 @@ struct FUniqueNetIdRepl // : public FUniqueNetIdWrapper { static UStruct* GetStruct() { - static auto Struct = FindObject("/Script/Engine.UniqueNetIdRepl"); + static auto Struct = FindObject(L"/Script/Engine.UniqueNetIdRepl"); return Struct; } @@ -30,17 +30,21 @@ struct FUniqueNetIdRepl // : public FUniqueNetIdWrapper bool bTest = true; - if (this->GetReplicationBytes().Num() > this->GetReplicationBytes().Num()) // != ? - bTest = false; - - for (int i = 0; i < this->GetReplicationBytes().Num(); i++) + if (this->GetReplicationBytes().Num() >= OtherUniqueId->GetReplicationBytes().Num()) { - if (this->GetReplicationBytes().at(i) != OtherUniqueId->GetReplicationBytes().at(i)) + for (int i = 0; i < this->GetReplicationBytes().Num(); i++) { - bTest = false; - break; + if (this->GetReplicationBytes().at(i) != OtherUniqueId->GetReplicationBytes().at(i)) + { + bTest = false; + break; + } } } + else + { + bTest = false; + } // LOG_INFO(LogDev, "btest: {}", bTest); diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index 079179d..1c051bd 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -367,6 +367,7 @@ DWORD WINAPI Main(LPVOID) Addresses::SetupVersion(); + NumToSubtractFromSquadId = Engine_Version >= 424 ? 2 : 3; // TODO: check this NumElementsPerChunk = std::floor(Fortnite_Version) >= 5 && Fortnite_Version <= 6 ? 0x10400 : 0x10000; // Idk what version tbh Offsets::FindAll(); // We have to do this before because FindCantBuild uses FortAIController.CreateBuildingActor diff --git a/Project Reboot 3.0/finder.cpp b/Project Reboot 3.0/finder.cpp index 4a2184e..045a57f 100644 --- a/Project Reboot 3.0/finder.cpp +++ b/Project Reboot 3.0/finder.cpp @@ -9,7 +9,7 @@ uint64 FindGetPlayerViewpoint() uint64 FailedToSpawnPawnAddr = 0; - auto FailedToSpawnPawnStrRefAddr = Memcury::Scanner::FindStringRef(L"%s failed to spawn a pawn", true, 0, Fortnite_Version >= 18).Get(); + auto FailedToSpawnPawnStrRefAddr = Memcury::Scanner::FindStringRef(L"%s failed to spawn a pawn", true, 0, Fortnite_Version >= 19).Get(); for (int i = 0; i < 1000; i++) { diff --git a/Project Reboot 3.0/finder.h b/Project Reboot 3.0/finder.h index 81c8c4c..b38819c 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -220,7 +220,7 @@ static inline uint64 FindRebootingDelegate() if (Fortnite_Version < 8.3) return 0; - auto ServerOnAttemptInteractAddr = Memcury::Scanner::FindStringRef(L"[SCM] ABuildingGameplayActorSpawnMachine::ServerOnAttemptInteract - Start Rebooting").Get(); + auto ServerOnAttemptInteractAddr = Memcury::Scanner::FindStringRef(L"[SCM] ABuildingGameplayActorSpawnMachine::ServerOnAttemptInteract - Start Rebooting", true, 0, Fortnite_Version >= 16).Get(); for (int i = 0; i < 10000; i++) { diff --git a/Project Reboot 3.0/hooking.h b/Project Reboot 3.0/hooking.h index a274e88..01031de 100644 --- a/Project Reboot 3.0/hooking.h +++ b/Project Reboot 3.0/hooking.h @@ -367,7 +367,14 @@ namespace Hooking static inline void ChangeBytesThing(uint8_t* instrAddr, uint8_t* DetourAddr, int Offset) { int64_t delta = DetourAddr - (instrAddr + Offset + 4); - *(int32_t*)(instrAddr + Offset) = static_cast(delta); + auto addr = (int32_t*)(instrAddr + Offset); + DWORD dwProtection; + VirtualProtect((PVOID)addr, 4, PAGE_EXECUTE_READWRITE, &dwProtection); + + *addr = static_cast(delta); + + DWORD dwTemp; + VirtualProtect((PVOID)addr, 1, dwProtection, &dwTemp); } enum ERelativeOffsets