From 32bcc705afe2b10eef1325428212e01a8bf94060 Mon Sep 17 00:00:00 2001 From: Milxnor Date: Sun, 12 Mar 2023 16:00:26 -0400 Subject: [PATCH] clip size vehicles cheat command --- .../AbilitySystemComponent_Abilities.cpp | 44 ++++ Project Reboot 3.0/Actor.cpp | 21 ++ Project Reboot 3.0/Actor.h | 4 + Project Reboot 3.0/BuildingActor.cpp | 2 +- Project Reboot 3.0/BuildingActor.h | 7 +- Project Reboot 3.0/BuildingSMActor.h | 8 +- Project Reboot 3.0/BuildingTrap.cpp | 4 + Project Reboot 3.0/BuildingTrap.h | 9 + Project Reboot 3.0/DataTable.h | 8 +- Project Reboot 3.0/FortGameModeAthena.cpp | 36 +++- Project Reboot 3.0/FortInventory.cpp | 12 +- Project Reboot 3.0/FortInventoryInterface.cpp | 14 ++ Project Reboot 3.0/FortInventoryInterface.h | 9 + Project Reboot 3.0/FortKismetLibrary.cpp | 23 +- Project Reboot 3.0/FortLootPackage.cpp | 14 +- Project Reboot 3.0/FortLootPackage.h | 11 +- Project Reboot 3.0/FortPickup.cpp | 4 +- Project Reboot 3.0/FortPlayerController.cpp | 18 +- Project Reboot 3.0/FortPlayerController.h | 2 - Project Reboot 3.0/FortPlayerState.h | 6 + Project Reboot 3.0/FortPlayerStateAthena.h | 14 ++ .../FortWeaponItemDefinition.cpp | 41 ++++ Project Reboot 3.0/FortWeaponItemDefinition.h | 3 + Project Reboot 3.0/GameModeBase.cpp | 2 + Project Reboot 3.0/GameplayAbilitySpec.h | 16 +- Project Reboot 3.0/Project Reboot 3.0.vcxproj | 7 + .../Project Reboot 3.0.vcxproj.filters | 21 ++ Project Reboot 3.0/Stack.h | 11 + Project Reboot 3.0/UObjectArray.h | 4 +- Project Reboot 3.0/addresses.cpp | 11 +- Project Reboot 3.0/addresses.h | 2 + Project Reboot 3.0/commands.h | 186 ++++++++++++++++ Project Reboot 3.0/dllmain.cpp | 34 ++- Project Reboot 3.0/finder.h | 50 +++++ Project Reboot 3.0/globals.h | 2 +- Project Reboot 3.0/reboot.h | 2 +- Project Reboot 3.0/vehicles.h | 198 ++++++++++++++++++ 37 files changed, 803 insertions(+), 57 deletions(-) create mode 100644 Project Reboot 3.0/BuildingTrap.cpp create mode 100644 Project Reboot 3.0/BuildingTrap.h create mode 100644 Project Reboot 3.0/FortInventoryInterface.cpp create mode 100644 Project Reboot 3.0/FortInventoryInterface.h create mode 100644 Project Reboot 3.0/FortWeaponItemDefinition.cpp create mode 100644 Project Reboot 3.0/commands.h create mode 100644 Project Reboot 3.0/vehicles.h diff --git a/Project Reboot 3.0/AbilitySystemComponent_Abilities.cpp b/Project Reboot 3.0/AbilitySystemComponent_Abilities.cpp index 0a01505..a91e392 100644 --- a/Project Reboot 3.0/AbilitySystemComponent_Abilities.cpp +++ b/Project Reboot 3.0/AbilitySystemComponent_Abilities.cpp @@ -1,5 +1,9 @@ #include "AbilitySystemComponent.h" #include "NetSerialization.h" +#include "Actor.h" +#include "FortPawn.h" +#include "FortPlayerController.h" +#include "FortPlayerStateAthena.h" void LoopSpecs(UAbilitySystemComponent* AbilitySystemComponent, std::function func) { @@ -76,6 +80,46 @@ void InternalServerTryActivateAbility(UAbilitySystemComponent* AbilitySystemComp static auto ActivatableAbilitiesOffset = AbilitySystemComponent->GetOffset("ActivatableAbilities"); AbilitySystemComponent->Get(ActivatableAbilitiesOffset).MarkItemDirty(Spec); // we only need to do this if the ability fails but eh + + // bro ignore this next part idk where to put it ok + + /* static auto OwnerActorOffset = AbilitySystemComponent->GetOffset("OwnerActor"); + auto PlayerState = Cast(AbilitySystemComponent->Get(OwnerActorOffset)); + + if (!PlayerState) + return; + + auto Controller = Cast(PlayerState->GetOwner()); + LOG_INFO(LogAbilities, "Owner {}", PlayerState->GetOwner()->GetFullName()); + + if (!Controller) + return; + + auto Pawn = Controller->GetMyFortPawn(); + + if (!Pawn) + return; + + auto CurrentWeapon = Pawn->GetCurrentWeapon(); + auto WorldInventory = Controller ? Controller->GetWorldInventory() : nullptr; + + if (!WorldInventory || !CurrentWeapon) + return; + + auto CurrentWeaponInstance = WorldInventory->FindItemInstance(CurrentWeapon->GetItemEntryGuid()); + auto CurrentWeaponReplicatedEntry = WorldInventory->FindReplicatedEntry(CurrentWeapon->GetItemEntryGuid()); + + static auto AmmoCountOffset = CurrentWeapon->GetOffset("AmmoCount"); + auto AmmoCount = CurrentWeapon->Get(AmmoCountOffset); + + if (CurrentWeaponReplicatedEntry->GetLoadedAmmo() != AmmoCount) + { + CurrentWeaponInstance->GetItemEntry()->GetLoadedAmmo() = AmmoCount; + CurrentWeaponReplicatedEntry->GetLoadedAmmo() = AmmoCount; + + WorldInventory->GetItemList().MarkItemDirty(CurrentWeaponInstance->GetItemEntry()); + WorldInventory->GetItemList().MarkItemDirty(CurrentWeaponReplicatedEntry); + } */ } FGameplayAbilitySpecHandle UAbilitySystemComponent::GiveAbilityEasy(UClass* AbilityClass) diff --git a/Project Reboot 3.0/Actor.cpp b/Project Reboot 3.0/Actor.cpp index fc55efe..73088e1 100644 --- a/Project Reboot 3.0/Actor.cpp +++ b/Project Reboot 3.0/Actor.cpp @@ -70,4 +70,25 @@ FVector AActor::GetActorRightVector() this->ProcessEvent(GetActorRightVectorFn, &ret); return ret; +} + +FRotator AActor::GetActorRotation() +{ + static auto K2_GetActorRotationFn = FindObject(L"/Script/Engine.Actor.K2_GetActorRotation"); + FRotator ret; + this->ProcessEvent(K2_GetActorRotationFn, &ret); + + return ret; +} + +void AActor::FlushNetDormancy() +{ + static auto fn = FindObject("/Script/Engine.Actor.FlushNetDormancy"); + this->ProcessEvent(fn); +} + +UClass* AActor::StaticClass() +{ + static auto Class = FindObject(L"/Script/Engine.Actor"); + return Class; } \ No newline at end of file diff --git a/Project Reboot 3.0/Actor.h b/Project Reboot 3.0/Actor.h index f167f13..71ea66e 100644 --- a/Project Reboot 3.0/Actor.h +++ b/Project Reboot 3.0/Actor.h @@ -13,4 +13,8 @@ public: void K2_DestroyActor(); class UActorComponent* GetComponentByClass(class UClass* ComponentClass); float GetDistanceTo(AActor* OtherActor); + struct FRotator GetActorRotation(); + void FlushNetDormancy(); + + static class UClass* StaticClass(); }; \ No newline at end of file diff --git a/Project Reboot 3.0/BuildingActor.cpp b/Project Reboot 3.0/BuildingActor.cpp index d10d139..8ed19cf 100644 --- a/Project Reboot 3.0/BuildingActor.cpp +++ b/Project Reboot 3.0/BuildingActor.cpp @@ -92,4 +92,4 @@ UClass* ABuildingActor::StaticClass() { static auto Class = FindObject(L"/Script/FortniteGame.BuildingActor"); return Class; -} \ No newline at end of file +} diff --git a/Project Reboot 3.0/BuildingActor.h b/Project Reboot 3.0/BuildingActor.h index ba089c7..c5268bc 100644 --- a/Project Reboot 3.0/BuildingActor.h +++ b/Project Reboot 3.0/BuildingActor.h @@ -32,12 +32,17 @@ public: void SetTeam(unsigned char InTeam) { - static auto fn = FindObject("/Script/FortniteGame.BuildingActor.SetTeam"); + static auto fn = nullptr; // FindObject("/Script/FortniteGame.BuildingActor.SetTeam"); if (!fn) { static auto TeamOffset = GetOffset("Team"); Get(TeamOffset) = InTeam; + + static auto TeamIndexOffset = GetOffset("TeamIndex", false); + + if (TeamIndexOffset != 0) + Get(TeamIndexOffset) = InTeam; } else { diff --git a/Project Reboot 3.0/BuildingSMActor.h b/Project Reboot 3.0/BuildingSMActor.h index e19cfef..6666c1b 100644 --- a/Project Reboot 3.0/BuildingSMActor.h +++ b/Project Reboot 3.0/BuildingSMActor.h @@ -18,12 +18,16 @@ class ABuildingSMActor : public ABuildingActor public: bool IsPlayerPlaced() { - return true; // FOR NOW + static auto bPlayerPlacedOffset = GetOffset("bPlayerPlaced"); + static auto bPlayerPlacedFieldMask = GetFieldMask(this->GetProperty("bPlayerPlaced")); + return ReadBitfieldValue(bPlayerPlacedOffset, bPlayerPlacedFieldMask); } void SetPlayerPlaced(bool NewValue) { - + static auto bPlayerPlacedOffset = GetOffset("bPlayerPlaced"); + static auto bPlayerPlacedFieldMask = GetFieldMask(this->GetProperty("bPlayerPlaced")); + this->SetBitfieldValue(bPlayerPlacedOffset, bPlayerPlacedFieldMask, NewValue); } bool IsDestroyed() diff --git a/Project Reboot 3.0/BuildingTrap.cpp b/Project Reboot 3.0/BuildingTrap.cpp new file mode 100644 index 0000000..8a8fbf0 --- /dev/null +++ b/Project Reboot 3.0/BuildingTrap.cpp @@ -0,0 +1,4 @@ +#include "BuildingTrap.h" + +#include "GameplayStatics.h" +#include "FortPlayerStateAthena.h" diff --git a/Project Reboot 3.0/BuildingTrap.h b/Project Reboot 3.0/BuildingTrap.h new file mode 100644 index 0000000..f630f94 --- /dev/null +++ b/Project Reboot 3.0/BuildingTrap.h @@ -0,0 +1,9 @@ +#pragma once + +#include "BuildingSMActor.h" + +class ABuildingTrap : public ABuildingSMActor +{ +public: + +}; \ No newline at end of file diff --git a/Project Reboot 3.0/DataTable.h b/Project Reboot 3.0/DataTable.h index c402695..5d78fd6 100644 --- a/Project Reboot 3.0/DataTable.h +++ b/Project Reboot 3.0/DataTable.h @@ -14,4 +14,10 @@ public: return *(TMap*)(__int64(this) + (RowStructOffset + sizeof(UObject*))); // because after rowstruct is rowmap } -}; \ No newline at end of file +}; + +struct FDataTableRowHandle +{ + UDataTable* DataTable; // 0x0000(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) + FName RowName; // 0x0008(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic) +}; diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 3b5d7e8..ff18cfd 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -14,6 +14,7 @@ #include "KismetStringLibrary.h" #include "SoftObjectPtr.h" +#include "vehicles.h" #include "globals.h" #include "events.h" #include "reboot.h" @@ -124,7 +125,19 @@ UObject* GetPlaylistToUse() if (Globals::bGoingToPlayEvent) { if (Fortnite_Version != 12.61) - Playlist = GetEventPlaylist(); + { + auto EventPlaylist = GetEventPlaylist(); + + if (!EventPlaylist) + { + LOG_ERROR(LogPlaylist, "No event playlist! Turning off going to play event"); + Globals::bGoingToPlayEvent = false; + } + else + { + Playlist = EventPlaylist; + } + } } // Playlist = FindObject("/MoleGame/Playlists/Playlist_MoleGame.Playlist_MoleGame"); @@ -616,7 +629,7 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena auto Location = CurrentActor->GetActorLocation(); Location.Z += UpZ; - std::vector> LootDrops = PickLootDrops(SpawnIslandTierGroup, bPrintWarmup); + std::vector LootDrops = PickLootDrops(SpawnIslandTierGroup, bPrintWarmup); if (bPrintWarmup) { @@ -626,7 +639,7 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena if (LootDrops.size()) { for (auto& LootDrop : LootDrops) - AFortPickup::SpawnPickup(LootDrop.first, Location, LootDrop.second, SpawnFlag); + AFortPickup::SpawnPickup(LootDrop.ItemDefinition, Location, LootDrop.Count, SpawnFlag, EFortPickupSpawnSource::Unset, LootDrop.LoadedAmmo); } } @@ -645,7 +658,7 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena auto Location = CurrentActor->GetActorLocation(); Location.Z += UpZ; - std::vector> LootDrops = PickLootDrops(BRIslandTierGroup, bPrint); + std::vector LootDrops = PickLootDrops(BRIslandTierGroup, bPrint); if (bPrint) std::cout << "\n"; @@ -653,11 +666,20 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena if (LootDrops.size()) { for (auto& LootDrop : LootDrops) - AFortPickup::SpawnPickup(LootDrop.first, Location, LootDrop.second, SpawnFlag); + AFortPickup::SpawnPickup(LootDrop.ItemDefinition, Location, LootDrop.Count, SpawnFlag, EFortPickupSpawnSource::Unset, LootDrop.LoadedAmmo); } } } + static bool bSpawnedVehicles = Engine_Version < 423; + + if (!bSpawnedVehicles) + { + bSpawnedVehicles = true; + + SpawnVehicles(); + } + auto NewPlayer = (AFortPlayerControllerAthena*)NewPlayerActor; auto PlayerStateAthena = NewPlayer->GetPlayerStateAthena(); @@ -704,6 +726,10 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena PlayerStateAthena->ProcessEvent(OnRep_bHasStartedPlayingFn); } + // static int CurrentPlayerId = 1; + static auto PlayerIdOffset = PlayerStateAthena->GetOffset("PlayerId"); + PlayerStateAthena->GetWorldPlayerId() = PlayerStateAthena->Get(PlayerIdOffset); // ++CurrentPlayerId; + if (Globals::bAbilitiesEnabled) { static auto GameplayAbilitySet = Fortnite_Version >= 8.30 ? // LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer") ? diff --git a/Project Reboot 3.0/FortInventory.cpp b/Project Reboot 3.0/FortInventory.cpp index 36ac3eb..a628aaa 100644 --- a/Project Reboot 3.0/FortInventory.cpp +++ b/Project Reboot 3.0/FortInventory.cpp @@ -16,6 +16,14 @@ std::pair, std::vector> AFortInventory::AddI if (bShouldUpdate) *bShouldUpdate = false; + if (LoadedAmmo == -1) + { + if (auto WeaponDef = Cast(ItemDefinition)) + LoadedAmmo = WeaponDef->GetClipSize(); + else + LoadedAmmo = 0; + } + std::vector NewItemInstances; std::vector ModifiedItemInstances; @@ -25,8 +33,8 @@ std::pair, std::vector> AFortInventory::AddI if (NewItemInstance) { - if (LoadedAmmo != -1) - NewItemInstance->GetItemEntry()->GetLoadedAmmo() = LoadedAmmo; + // if (LoadedAmmo != -1) + NewItemInstance->GetItemEntry()->GetLoadedAmmo() = LoadedAmmo; NewItemInstances.push_back(NewItemInstance); diff --git a/Project Reboot 3.0/FortInventoryInterface.cpp b/Project Reboot 3.0/FortInventoryInterface.cpp new file mode 100644 index 0000000..2dbb8ca --- /dev/null +++ b/Project Reboot 3.0/FortInventoryInterface.cpp @@ -0,0 +1,14 @@ +#include "FortInventoryInterface.h" + +#include "reboot.h" + +char UFortInventoryInterface::RemoveInventoryItemHook(__int64 a1, FGuid a2, int Count, char bForceRemoveFromQuickBars, char bForceRemoval) +{ + static auto FortPlayerControllerSuperSize = (*(UClass**)(__int64(FindObject("/Script/FortniteGame.FortPlayerController")) + Offsets::SuperStruct))->GetPropertiesSize(); + auto Controller = *(UObject**)(__int64(a1) - (FortPlayerControllerSuperSize + 8)); + + LOG_INFO(LogDev, "FortPlayerControllerSuperSize: {}", FortPlayerControllerSuperSize); + LOG_INFO(LogDev, "Controller: {}", Controller->GetFullName()); + + +} \ No newline at end of file diff --git a/Project Reboot 3.0/FortInventoryInterface.h b/Project Reboot 3.0/FortInventoryInterface.h new file mode 100644 index 0000000..1d97a71 --- /dev/null +++ b/Project Reboot 3.0/FortInventoryInterface.h @@ -0,0 +1,9 @@ +#pragma once + +#include "Object.h" + +class UFortInventoryInterface +{ +public: + static char RemoveInventoryItemHook(__int64 a1, FGuid a2, int Count, char bForceRemoveFromQuickBars, char bForceRemoval); +}; \ No newline at end of file diff --git a/Project Reboot 3.0/FortKismetLibrary.cpp b/Project Reboot 3.0/FortKismetLibrary.cpp index 8d93d1c..7b10734 100644 --- a/Project Reboot 3.0/FortKismetLibrary.cpp +++ b/Project Reboot 3.0/FortKismetLibrary.cpp @@ -74,12 +74,23 @@ void UFortKismetLibrary::GiveItemToInventoryOwnerHook(UObject* Context, FFrame& static auto ItemLevelOffset = FindOffsetStruct("/Script/FortniteGame.FortKismetLibrary.GiveItemToInventoryOwner", "ItemLevel"); static auto PickupInstigatorHandleOffset = FindOffsetStruct("/Script/FortniteGame.FortKismetLibrary.GiveItemToInventoryOwner", "PickupInstigatorHandle"); - auto InventoryOwner = *(TScriptInterface*)(__int64(Params) + InventoryOwnerOffset); - auto ItemDefinition = *(UFortWorldItemDefinition**)(__int64(Params) + ItemDefinitionOffset); - auto NumberToGive = *(int*)(__int64(Params) + NumberToGiveOffset); - auto bNotifyPlayer = *(bool*)(__int64(Params) + bNotifyPlayerOffset); - auto ItemLevel = *(int*)(__int64(Params) + ItemLevelOffset); - auto PickupInstigatorHandle = *(int*)(__int64(Params) + PickupInstigatorHandleOffset); + LOG_INFO(LogDev, "wtf: {}", __int64(Stack.Code)); + + return; + + TScriptInterface InventoryOwner; // = *(TScriptInterface*)(__int64(Params) + InventoryOwnerOffset); + UFortWorldItemDefinition* ItemDefinition; // *(UFortWorldItemDefinition**)(__int64(Params) + ItemDefinitionOffset); + int NumberToGive; // = *(int*)(__int64(Params) + NumberToGiveOffset); + bool bNotifyPlayer; // = *(bool*)(__int64(Params) + bNotifyPlayerOffset); + int ItemLevel; // = *(int*)(__int64(Params) + ItemLevelOffset); + int PickupInstigatorHandle; // = *(int*)(__int64(Params) + PickupInstigatorHandleOffset); + + Stack.Step(Context, &InventoryOwner); + Stack.Step(Context, &ItemDefinition); + Stack.Step(Context, &NumberToGive); + Stack.Step(Context, &bNotifyPlayer); + Stack.Step(Context, &ItemLevel); + Stack.Step(Context, &PickupInstigatorHandle); auto InterfacePointer = InventoryOwner.InterfacePointer; diff --git a/Project Reboot 3.0/FortLootPackage.cpp b/Project Reboot 3.0/FortLootPackage.cpp index eaa23bd..af6735a 100644 --- a/Project Reboot 3.0/FortLootPackage.cpp +++ b/Project Reboot 3.0/FortLootPackage.cpp @@ -2,6 +2,7 @@ #include "DataTable.h" #include "KismetMathLibrary.h" +#include "FortWeaponItemDefinition.h" static FFortLootTierData* GetLootTierData(std::vector& LootTierData, bool bPrint) { @@ -73,9 +74,9 @@ static FFortLootPackageData* GetLootPackage(std::vector& return SelectedItem; } -std::vector> PickLootDrops(FName TierGroupName, bool bPrint, int recursive) +std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recursive) { - std::vector> LootDrops; + std::vector LootDrops; static std::vector LTDTables; static std::vector LPTables; @@ -334,7 +335,14 @@ std::vector> PickLootDrops(FName TierGroupN std::cout << std::format("[{}] {} {} {}\n", i, lootPackageCalls.size(), TierGroupLPStr, ItemDef->GetName()); } - LootDrops.push_back({ ItemDef, LootPackageCall->GetCount() }); + auto WeaponDef = Cast(ItemDef); + + LootDrop lootDrop{}; + lootDrop.ItemDefinition = ItemDef; + lootDrop.LoadedAmmo = WeaponDef ? WeaponDef->GetClipSize() : 0; + lootDrop.Count = LootPackageCall->GetCount(); + + LootDrops.push_back(lootDrop); } return LootDrops; diff --git a/Project Reboot 3.0/FortLootPackage.h b/Project Reboot 3.0/FortLootPackage.h index abbc8a7..2057236 100644 --- a/Project Reboot 3.0/FortLootPackage.h +++ b/Project Reboot 3.0/FortLootPackage.h @@ -3,9 +3,16 @@ #include #include "Array.h" -#include "FortItemDefinition.h" +#include "FortWorldItemDefinition.h" #include "SoftObjectPtr.h" +struct LootDrop +{ + UFortItemDefinition* ItemDefinition; + int Count; + int LoadedAmmo; +}; + struct FFortLootPackageData { public: @@ -86,4 +93,4 @@ public: } }; -std::vector> PickLootDrops(FName TierGroupName, bool bPrint = false, int recursive = 0); \ No newline at end of file +std::vector PickLootDrops(FName TierGroupName, bool bPrint = false, int recursive = 0); \ No newline at end of file diff --git a/Project Reboot 3.0/FortPickup.cpp b/Project Reboot 3.0/FortPickup.cpp index f1d0d3c..340ec0a 100644 --- a/Project Reboot 3.0/FortPickup.cpp +++ b/Project Reboot 3.0/FortPickup.cpp @@ -20,7 +20,7 @@ void AFortPickup::TossPickup(FVector FinalLocation, AFortPawn* ItemOwner, int Ov AFortPickup* AFortPickup::SpawnPickup(UFortItemDefinition* ItemDef, FVector Location, int Count, EFortPickupSourceTypeFlag PickupSource, EFortPickupSpawnSource SpawnSource, int LoadedAmmo, AFortPawn* Pawn) { static auto FortPickupClass = FindObject(L"/Script/FortniteGame.FortPickup"); - // auto PlayerState = Pawn ? Cast(Pawn->GetPlayerState) : nullptr; + auto PlayerState = Pawn ? Cast(Pawn->GetPlayerState()) : nullptr; if (auto Pickup = GetWorld()->SpawnActor(FortPickupClass, Location)) { @@ -32,6 +32,8 @@ AFortPickup* AFortPickup::SpawnPickup(UFortItemDefinition* ItemDef, FVector Loca PrimaryPickupItemEntry->GetItemDefinition() = ItemDef; PrimaryPickupItemEntry->GetLoadedAmmo() = LoadedAmmo; + static auto OptionalOwnerIDOffset = Pickup->GetOffset("OptionalOwnerID"); + Pickup->Get(OptionalOwnerIDOffset) = PlayerState ? PlayerState->GetWorldPlayerId() : -1; // Pickup->OptionalOwnerID = Pawn ? PlayerState->WorldPlayerId : -1; Pickup->Get(PawnWhoDroppedPickupOffset) = Pawn; diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 1132b0a..4acd83d 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -119,7 +119,8 @@ void AFortPlayerController::ServerAttemptInteractHook(UObject* Context, FFrame* for (int i = 0; i < LootDrops.size(); i++) { - AFortPickup::SpawnPickup(LootDrops.at(i).first, LocationToSpawnLoot, LootDrops.at(i).second, EFortPickupSourceTypeFlag::Container, EFortPickupSpawnSource::Unset, -1 + auto& lootDrop = LootDrops.at(i); + AFortPickup::SpawnPickup(lootDrop.ItemDefinition, LocationToSpawnLoot, lootDrop.Count, EFortPickupSourceTypeFlag::Container, EFortPickupSpawnSource::Unset, lootDrop.LoadedAmmo // , (AFortPawn*)PlayerController->GetPawn() // should we put this here? ); } @@ -180,6 +181,7 @@ void AFortPlayerController::ServerCreateBuildingActorHook(UObject* Context, FFra if (Fortnite_Version >= 8.30) { + struct FCreateBuildingActorData { uint32_t BuildingClassHandle; FVector BuildLoc; FRotator BuildRot; bool bMirrored; }; auto CreateBuildingData = (FCreateBuildingActorData*)Stack->Locals; BuildLocation = CreateBuildingData->BuildLoc; @@ -240,9 +242,12 @@ void AFortPlayerController::ServerCreateBuildingActorHook(UObject* Context, FFra if (!BuildingActor) return ServerCreateBuildingActorOriginal(Context, Stack, Ret); + // static auto OwnerPersistentIDOffset = BuildingActor->GetOffset("OwnerPersistentID"); + // BuildingActor->Get(OwnerPersistentIDOffset) = PlayerStateAthena->GetWorldPlayerId(); + BuildingActor->SetPlayerPlaced(true); - BuildingActor->SetTeam(PlayerStateAthena->GetTeamIndex()); BuildingActor->InitializeBuildingActor(PlayerController, BuildingActor, true); + BuildingActor->SetTeam(PlayerStateAthena->GetTeamIndex()); return ServerCreateBuildingActorOriginal(Context, Stack, Ret); } @@ -311,9 +316,6 @@ void AFortPlayerController::ServerPlayEmoteItemHook(AFortPlayerController* Playe int outHandle = 0; - FGameplayAbilitySpecHandle Handle{}; - Handle.GenerateNewHandle(); - FGameplayAbilitySpec* Spec = MakeNewSpec((UClass*)AbilityToUse, EmoteAsset, true); static unsigned int* (*GiveAbilityAndActivateOnce)(UAbilitySystemComponent * ASC, int* outHandle, __int64 Spec) @@ -492,10 +494,8 @@ void AFortPlayerController::ServerEditBuildingActorHook(AFortPlayerController* P { BuildingActor->SetPlayerPlaced(true); - if (auto PlayerState = Cast(PlayerController->GetPlayerState())) - BuildingActor->SetTeam(PlayerState->GetTeamIndex()); - - // BuildingActor->OnRep_Team(); + // if (auto PlayerState = Cast(PlayerController->GetPlayerState())) + // BuildingActor->SetTeam(PlayerState->GetTeamIndex()); } } diff --git a/Project Reboot 3.0/FortPlayerController.h b/Project Reboot 3.0/FortPlayerController.h index 355b33c..df0aca0 100644 --- a/Project Reboot 3.0/FortPlayerController.h +++ b/Project Reboot 3.0/FortPlayerController.h @@ -8,8 +8,6 @@ #include "BuildingSMActor.h" #include "Stack.h" -struct FCreateBuildingActorData { uint32_t BuildingClassHandle; FVector BuildLoc; FRotator BuildRot; bool bMirrored; }; - struct FFortAthenaLoadout { UObject*& GetCharacter() diff --git a/Project Reboot 3.0/FortPlayerState.h b/Project Reboot 3.0/FortPlayerState.h index 96766e3..f5adf18 100644 --- a/Project Reboot 3.0/FortPlayerState.h +++ b/Project Reboot 3.0/FortPlayerState.h @@ -12,6 +12,12 @@ public: return this->Get(AbilitySystemComponentOffset); } + int& GetWorldPlayerId() + { + static auto WorldPlayerIdOffset = GetOffset("WorldPlayerId"); + return this->Get(WorldPlayerIdOffset); + } + static UClass* StaticClass() { static auto Class = FindObject("/Script/FortniteGame.FortPlayerState"); diff --git a/Project Reboot 3.0/FortPlayerStateAthena.h b/Project Reboot 3.0/FortPlayerStateAthena.h index 7d60c22..d83ba23 100644 --- a/Project Reboot 3.0/FortPlayerStateAthena.h +++ b/Project Reboot 3.0/FortPlayerStateAthena.h @@ -16,4 +16,18 @@ public: static auto TeamIndexOffset = GetOffset("TeamIndex"); return Get(TeamIndexOffset); } + + FString GetPlayerName() + { + static auto GetPlayerNameFn = FindObject("/Script/Engine.PlayerState.GetPlayerName"); + FString PlayerName; + this->ProcessEvent(GetPlayerNameFn, &PlayerName); + return PlayerName; + } + + static UClass* StaticClass() + { + static auto Class = FindObject("/Script/FortniteGame.FortPlayerStateAthena"); + return Class; + } }; \ No newline at end of file diff --git a/Project Reboot 3.0/FortWeaponItemDefinition.cpp b/Project Reboot 3.0/FortWeaponItemDefinition.cpp new file mode 100644 index 0000000..9932bc3 --- /dev/null +++ b/Project Reboot 3.0/FortWeaponItemDefinition.cpp @@ -0,0 +1,41 @@ +#include "FortWeaponItemDefinition.h" + +#include "DataTable.h" + +int UFortWeaponItemDefinition::GetClipSize() +{ + static auto WeaponStatHandleOffset = GetOffset("WeaponStatHandle"); + auto& WeaponStatHandle = Get(WeaponStatHandleOffset); + + auto Table = WeaponStatHandle.DataTable; + + if (!Table) + return 0; + + auto& RowMap = Table->GetRowMap(); + + void* Row = nullptr; + + for (int i = 0; i < RowMap.Pairs.Elements.Data.Num(); i++) + { + auto& Pair = RowMap.Pairs.Elements.Data.at(i).ElementData.Value; + + if (Pair.Key() == WeaponStatHandle.RowName) + { + Row = Pair.Value(); + break; + } + } + + if (!Row) + return 0; + + static auto ClipSizeOffset = FindOffsetStruct("/Script/FortniteGame.FortBaseWeaponStats", "ClipSize"); + return *(int*)(__int64(Row) + ClipSizeOffset); +} + +UClass* UFortWeaponItemDefinition::StaticClass() +{ + static auto Class = FindObject(L"/Script/FortniteGame.FortWeaponItemDefinition"); + return Class; +} \ No newline at end of file diff --git a/Project Reboot 3.0/FortWeaponItemDefinition.h b/Project Reboot 3.0/FortWeaponItemDefinition.h index cecfc4a..4b3fcb9 100644 --- a/Project Reboot 3.0/FortWeaponItemDefinition.h +++ b/Project Reboot 3.0/FortWeaponItemDefinition.h @@ -4,5 +4,8 @@ class UFortWeaponItemDefinition : public UFortWorldItemDefinition { +public: + int GetClipSize(); + static UClass* StaticClass(); }; \ No newline at end of file diff --git a/Project Reboot 3.0/GameModeBase.cpp b/Project Reboot 3.0/GameModeBase.cpp index f23f300..4c33821 100644 --- a/Project Reboot 3.0/GameModeBase.cpp +++ b/Project Reboot 3.0/GameModeBase.cpp @@ -40,6 +40,7 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll static UFortItemDefinition* BuildingItemData_Stair_W = FindObject(L"/Game/Items/Weapons/BuildingTools/BuildingItemData_Stair_W.BuildingItemData_Stair_W"); static UFortItemDefinition* BuildingItemData_RoofS = FindObject(L"/Game/Items/Weapons/BuildingTools/BuildingItemData_RoofS.BuildingItemData_RoofS"); static UFortItemDefinition* WoodItemData = FindObject(L"/Game/Items/ResourcePickups/WoodItemData.WoodItemData"); + static UFortItemDefinition* DamageTrap = FindObject(L"/Game/Athena/Items/Traps/TID_ContextTrap_Athena.TID_ContextTrap_Athena"); WorldInventory->AddItem(EditToolItemDefinition, nullptr); WorldInventory->AddItem(BuildingItemData_Wall, nullptr); @@ -48,6 +49,7 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll WorldInventory->AddItem(BuildingItemData_RoofS, nullptr); WorldInventory->AddItem(PickaxeDefinition, nullptr); WorldInventory->AddItem(WoodItemData, nullptr, 100); + WorldInventory->AddItem(DamageTrap, nullptr); // WorldInventory->AddItem(FindObject(L"/ParallelGameplay/Items/WestSausage/WID_WestSausage_Parallel.WID_WestSausage_Parallel"), nullptr, 1, 1000); WorldInventory->Update(true); diff --git a/Project Reboot 3.0/GameplayAbilitySpec.h b/Project Reboot 3.0/GameplayAbilitySpec.h index c035ab1..81b31f4 100644 --- a/Project Reboot 3.0/GameplayAbilitySpec.h +++ b/Project Reboot 3.0/GameplayAbilitySpec.h @@ -9,7 +9,7 @@ struct FGameplayAbilitySpecHandle { int Handle; - void GenerateNewHandle() + /* void GenerateNewHandle() { if (true) { @@ -20,7 +20,7 @@ struct FGameplayAbilitySpecHandle static int GHandle = 1; Handle = ++GHandle; } - } + } */ }; struct FGameplayAbilitySpec : FFastArraySerializerItem @@ -54,7 +54,13 @@ static FGameplayAbilitySpec* MakeNewSpec(UClass* GameplayAbilityClass, UObject* if (!NewSpec) return nullptr; - static auto LevelOffset = FindOffsetStruct("/Script/GameplayAbilities.GameplayAbilitySpec", "Level"); + auto DefaultAbility = bAlreadyIsDefault ? GameplayAbilityClass : GameplayAbilityClass->CreateDefaultObject(); + + static __int64 (*SpecConstructor)(__int64 spec, UObject* Ability, int Level, int InputID, UObject* SourceObject) = decltype(SpecConstructor)(Addresses::SpecConstructor); + + SpecConstructor(__int64(NewSpec), DefaultAbility, 0, -1, SourceObject); + + /* static auto LevelOffset = FindOffsetStruct("/Script/GameplayAbilities.GameplayAbilitySpec", "Level"); static auto SourceObjectOffset = FindOffsetStruct("/Script/GameplayAbilities.GameplayAbilitySpec", "SourceObject"); static auto InputIDOffset = FindOffsetStruct("/Script/GameplayAbilities.GameplayAbilitySpec", "InputID"); @@ -63,10 +69,10 @@ static FGameplayAbilitySpec* MakeNewSpec(UClass* GameplayAbilityClass, UObject* ((FFastArraySerializerItem*)NewSpec)->ReplicationKey = -1; NewSpec->GetHandle().GenerateNewHandle(); - NewSpec->GetAbility() = bAlreadyIsDefault ? GameplayAbilityClass : GameplayAbilityClass->CreateDefaultObject(); + NewSpec->GetAbility() = DefaultAbility; *(int*)(__int64(NewSpec) + LevelOffset) = 0; *(int*)(__int64(NewSpec) + InputIDOffset) = -1; - *(UObject**)(__int64(NewSpec) + SourceObjectOffset) = SourceObject; + *(UObject**)(__int64(NewSpec) + SourceObjectOffset) = SourceObject; */ return NewSpec; } \ No newline at end of file diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj b/Project Reboot 3.0/Project Reboot 3.0.vcxproj index f563441..5b6b769 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj @@ -170,6 +170,7 @@ + @@ -181,6 +182,7 @@ + @@ -192,6 +194,7 @@ + @@ -218,8 +221,10 @@ + + @@ -236,6 +241,7 @@ + @@ -296,6 +302,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 f52385c..cfc75e6 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -122,6 +122,15 @@ FortniteGame\Source\FortniteGame\Private\Items + + FortniteGame\Source\FortniteGame\Private\Items + + + FortniteGame\Source\FortniteGame\Private\Items + + + FortniteGame\Source\FortniteGame\Private\Building + @@ -389,6 +398,18 @@ FortniteGame\Source\FortniteGame\Public + + Reboot\Public + + + FortniteGame\Source\FortniteGame\Public\Items + + + FortniteGame\Source\FortniteGame\Public\Building + + + Reboot + diff --git a/Project Reboot 3.0/Stack.h b/Project Reboot 3.0/Stack.h index 3f9a30f..d3a13c9 100644 --- a/Project Reboot 3.0/Stack.h +++ b/Project Reboot 3.0/Stack.h @@ -3,6 +3,8 @@ #include "OutputDevice.h" #include "Class.h" +#define RESULT_DECL void*const RESULT_PARAM + struct FFrame : public FOutputDevice // https://github.com/EpicGames/UnrealEngine/blob/7acbae1c8d1736bb5a0da4f6ed21ccb237bc8851/Engine/Source/Runtime/CoreUObject/Public/UObject/Stack.h#L83 { public: @@ -15,4 +17,13 @@ public: uint8* Locals; // 40 // MORE STUFF HERE + + void Step(UObject* Context, RESULT_DECL) + { + static void (*StepOriginal)(UObject* Context, RESULT_DECL) = decltype(StepOriginal)(Addresses::FrameStep); + StepOriginal(Context, RESULT_PARAM); + + // int32 B = *Code++; + // (GNatives[B])(Context, *this, RESULT_PARAM); + } }; \ No newline at end of file diff --git a/Project Reboot 3.0/UObjectArray.h b/Project Reboot 3.0/UObjectArray.h index 12c1750..0c3cae9 100644 --- a/Project Reboot 3.0/UObjectArray.h +++ b/Project Reboot 3.0/UObjectArray.h @@ -78,8 +78,8 @@ public: } }; -static inline FChunkedFixedUObjectArray* ChunkedObjects; -static inline FFixedUObjectArray* UnchunkedObjects; +extern inline FChunkedFixedUObjectArray* ChunkedObjects = 0; +extern inline FFixedUObjectArray* UnchunkedObjects = 0; FORCEINLINE UObject* GetObjectByIndex(int32 Index) { diff --git a/Project Reboot 3.0/addresses.cpp b/Project Reboot 3.0/addresses.cpp index 90bb875..0f73731 100644 --- a/Project Reboot 3.0/addresses.cpp +++ b/Project Reboot 3.0/addresses.cpp @@ -17,6 +17,7 @@ #include "BuildingActor.h" #include "FortPlaysetItemDefinition.h" #include "FortGameModeAthena.h" +#include "UObjectArray.h" void Addresses::SetupVersion() { @@ -196,6 +197,9 @@ void Addresses::FindAll() Addresses::SetZoneToIndex = FindSetZoneToIndex(); Addresses::CompletePickupAnimation = FindCompletePickupAnimation(); Addresses::CanActivateAbility = FindCanActivateAbility(); + Addresses::SpecConstructor = FindSpecConstructor(); + Addresses::FrameStep = FindFrameStep(); + Addresses::ObjectArray = FindObjectArray(); } void Addresses::Print() @@ -235,6 +239,9 @@ void Addresses::Print() LOG_INFO(LogDev, "SetZoneToIndex: 0x{:x}", SetZoneToIndex - Base); LOG_INFO(LogDev, "CompletePickupAnimation: 0x{:x}", CompletePickupAnimation - Base); LOG_INFO(LogDev, "CanActivateAbility: 0x{:x}", CanActivateAbility - Base); + LOG_INFO(LogDev, "SpecConstructor: 0x{:x}", SpecConstructor - Base); + LOG_INFO(LogDev, "FrameStep: 0x{:x}", FrameStep - Base); + LOG_INFO(LogDev, "ObjectArray: 0x{:x}", ObjectArray - Base); } void Offsets::FindAll() @@ -309,8 +316,8 @@ void Addresses::Init() LoadPlaysetOriginal = decltype(LoadPlaysetOriginal)(Addresses::LoadPlayset); AFortGameModeAthena::SetZoneToIndexOriginal = decltype(AFortGameModeAthena::SetZoneToIndexOriginal)(Addresses::SetZoneToIndex); - // if (Engine_Version >= 421) ChunkedObjects = decltype(ChunkedObjects)(ObjectArray); - // else UnchunkedObjects = decltype(UnchunkedObjects)(ObjectArray); + if (Engine_Version >= 421) ChunkedObjects = decltype(ChunkedObjects)(ObjectArray); + else UnchunkedObjects = decltype(UnchunkedObjects)(ObjectArray); } std::vector Addresses::GetFunctionsToNull() diff --git a/Project Reboot 3.0/addresses.h b/Project Reboot 3.0/addresses.h index cf1aca8..c17f201 100644 --- a/Project Reboot 3.0/addresses.h +++ b/Project Reboot 3.0/addresses.h @@ -43,6 +43,8 @@ namespace Addresses extern inline uint64 SetZoneToIndex = 0; extern inline uint64 CompletePickupAnimation = 0; extern inline uint64 CanActivateAbility = 0; + extern inline uint64 SpecConstructor = 0; + extern inline uint64 FrameStep = 0; void SetupVersion(); // Finds Engine Version void FindAll(); diff --git a/Project Reboot 3.0/commands.h b/Project Reboot 3.0/commands.h new file mode 100644 index 0000000..eb220e0 --- /dev/null +++ b/Project Reboot 3.0/commands.h @@ -0,0 +1,186 @@ +#pragma once + +#include "reboot.h" +#include "FortPlayerControllerAthena.h" + +bool IsOperator(APlayerState* PlayerState, AFortPlayerController* PlayerController) +{ + auto IP = PlayerState->GetPtr("SavedNetworkAddress"); + 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)) + { + return true; + } + + return false; +} + +inline void SendMessageToConsole(AFortPlayerController* PlayerController, const FString& Msg) +{ + float MsgLifetime = 1; // unused by ue + FName TypeName = FName(); // auto set to "Event" + + // PlayerController->ClientMessage(Msg, TypeName, MsgLifetime); +} + +void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg) +{ + auto PlayerState = Cast(PlayerController->GetPlayerState()); + + // std::cout << "aa!\n"; + + if (!PlayerState || !IsOperator(PlayerState, PlayerController)) + return; + + std::vector Arguments; + auto OldMsg = Msg.ToString(); + + auto ReceivingController = PlayerController; // for now + auto ReceivingPlayerState = PlayerState; // for now + + auto firstBackslash = OldMsg.find_first_of("\\"); + auto lastBackslash = OldMsg.find_last_of("\\"); + + auto& ClientConnections = GetWorld()->Get("NetDriver")->Get>("ClientConnections"); + + /* if (firstBackslash == lastBackslash) + { + SendMessageToConsole(PlayerController, L"Warning: You have a backslash but no ending backslash, was this by mistake? Executing on you."); + } */ + + if (firstBackslash != lastBackslash && firstBackslash != std::string::npos && lastBackslash != std::string::npos) // we want to specify a player + { + std::string player = OldMsg; + + player = player.substr(firstBackslash + 1, lastBackslash - firstBackslash - 1); + + for (int i = 0; i < ClientConnections.Num(); i++) + { + auto CurrentPlayerController = Cast(ClientConnections.at(i)->Get("PlayerController")); + + if (!CurrentPlayerController) + continue; + + auto CurrentPlayerState = Cast(CurrentPlayerController->GetPlayerState()); + + if (!CurrentPlayerState) + continue; + + auto PlayerName = CurrentPlayerState->GetPlayerName(); + + if (PlayerName.ToString() == player) // hopefully we arent on adifferent thread + { + ReceivingController = CurrentPlayerController; + ReceivingPlayerState = CurrentPlayerState; + PlayerName.Free(); + break; + } + + PlayerName.Free(); + } + } + + if (!ReceivingController || !ReceivingPlayerState) + { + SendMessageToConsole(PlayerController, L"Unable to find player!"); + return; + } + + { + auto Message = Msg.ToString(); + + size_t start = Message.find('\\'); + while (start != std::string::npos) // remove the playername + { + size_t end = Message.find('\\', start + 1); + + if (end == std::string::npos) + break; + + Message.replace(start, end - start + 2, ""); + start = Message.find('\\'); + } + + int zz = 0; + + // std::cout << "Message Before: " << Message << '\n'; + + while (Message.find(" ") != -1) + { + auto arg = Message.substr(0, Message.find(' ')); + Arguments.push_back(arg); + // std::cout << std::format("[{}] {}\n", zz, arg); + Message.erase(0, Message.find(' ') + 1); + zz++; + } + + // if (zz == 0) + { + Arguments.push_back(Message); + // std::cout << std::format("[{}] {}\n", zz, Message); + zz++; + } + + // std::cout << "Message After: " << Message << '\n'; + } + + auto NumArgs = Arguments.size() == 0 ? 0 : Arguments.size() - 1; + + // std::cout << "NumArgs: " << NumArgs << '\n'; + + if (Arguments.size() >= 1) + { + auto& Command = Arguments[0]; + std::transform(Command.begin(), Command.end(), Command.begin(), ::tolower); + + if (Command == "giveitem") + { + if (NumArgs < 1) + { + SendMessageToConsole(PlayerController, L"Please provide a WID!"); + return; + } + + auto WorldInventory = ReceivingController->GetWorldInventory(); + + if (!WorldInventory) + { + SendMessageToConsole(PlayerController, L"No world inventory!"); + return; + } + + auto& weaponName = Arguments[1]; + int count = 1; + + try + { + if (NumArgs >= 2) + count = std::stoi(Arguments[2]); + } + catch (...) + { + } + + LOG_INFO(LogDev, "weaponName: {}", weaponName); + + auto WID = Cast(FindObject(weaponName, nullptr, ANY_PACKAGE)); + + if (!WID) + { + SendMessageToConsole(PlayerController, L"Invalid WID!"); + return; + } + + bool bShouldUpdate = false; + WorldInventory->AddItem(WID, &bShouldUpdate, count); + + if (bShouldUpdate) + WorldInventory->Update(); + + SendMessageToConsole(PlayerController, L"Granted item!"); + } + } +} \ No newline at end of file diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index a2e3813..41d40b4 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -10,10 +10,15 @@ #include "AbilitySystemComponent.h" #include "FortPlayerPawn.h" #include "globals.h" +#include "FortInventoryInterface.h" #include "Map.h" #include "events.h" #include "FortKismetLibrary.h" +#include "vehicles.h" +#include "UObjectArray.h" +#include "BuildingTrap.h" +#include "commands.h" enum ENetMode { @@ -173,6 +178,8 @@ DWORD WINAPI Main(LPVOID) AFortPlayerControllerAthena::ServerAcknowledgePossessionHook, nullptr, false); Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerController.ServerAttemptInventoryDrop"), AFortPlayerController::ServerAttemptInventoryDropHook, nullptr, false); + Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerController.ServerCheat"), + ServerCheatHook, nullptr, false); Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerController.ServerExecuteInventoryItem"), AFortPlayerController::ServerExecuteInventoryItemHook, nullptr, false); Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerController.ServerPlayEmoteItem"), @@ -191,14 +198,14 @@ DWORD WINAPI Main(LPVOID) Hooking::MinHook::Hook(FortPlayerPawnAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerPawn.ServerSendZiplineState"), AFortPlayerPawn::ServerSendZiplineStateHook, nullptr, false); - if (false) + // if (false) { - Hooking::MinHook::Hook(FortKismetLibraryDefault, FindObject(L"Script/FortniteGame.FortKismetLibrary.K2_GiveItemToPlayer"), - UFortKismetLibrary::K2_GiveItemToPlayerHook, (PVOID*)&UFortKismetLibrary::K2_GiveItemToPlayerOriginal, false, true); + // Hooking::MinHook::Hook(FortKismetLibraryDefault, FindObject(L"Script/FortniteGame.FortKismetLibrary.K2_GiveItemToPlayer"), + // UFortKismetLibrary::K2_GiveItemToPlayerHook, (PVOID*)&UFortKismetLibrary::K2_GiveItemToPlayerOriginal, false, true); Hooking::MinHook::Hook(FortKismetLibraryDefault, FindObject(L"/Script/FortniteGame.FortKismetLibrary.GiveItemToInventoryOwner"), UFortKismetLibrary::GiveItemToInventoryOwnerHook, (PVOID*)&UFortKismetLibrary::GiveItemToInventoryOwnerOriginal, false, true); - Hooking::MinHook::Hook(FortKismetLibraryDefault, FindObject(L"/Script/FortniteGame.FortKismetLibrary.K2_RemoveItemFromPlayer"), - UFortKismetLibrary::K2_RemoveItemFromPlayerHook, (PVOID*)&UFortKismetLibrary::K2_RemoveItemFromPlayerOriginal, false, true); + // Hooking::MinHook::Hook(FortKismetLibraryDefault, FindObject(L"/Script/FortniteGame.FortKismetLibrary.K2_RemoveItemFromPlayer"), + // UFortKismetLibrary::K2_RemoveItemFromPlayerHook, (PVOID*)&UFortKismetLibrary::K2_RemoveItemFromPlayerOriginal, false, true); } static auto ServerHandlePickupInfoFn = FindObject("/Script/FortniteGame.FortPlayerPawn.ServerHandlePickupInfo"); @@ -250,9 +257,12 @@ DWORD WINAPI Main(LPVOID) // Hooking::MinHook::Hook((PVOID)Addresses::OnDamageServer, (PVOID)ABuildingActor::OnDamageServerHook, (PVOID*)&ABuildingActor::OnDamageServerOriginal); // Hooking::MinHook::Hook((PVOID)Addresses::CollectGarbage, (PVOID)CollectGarbageHook, nullptr); Hooking::MinHook::Hook((PVOID)Addresses::PickTeam, (PVOID)AFortGameModeAthena::Athena_PickTeamHook); - Hooking::MinHook::Hook((PVOID)Addresses::SetZoneToIndex, (PVOID)AFortGameModeAthena::SetZoneToIndexHook, (PVOID*)&AFortGameModeAthena::SetZoneToIndexOriginal); + // Hooking::MinHook::Hook((PVOID)Addresses::SetZoneToIndex, (PVOID)AFortGameModeAthena::SetZoneToIndexHook, (PVOID*)&AFortGameModeAthena::SetZoneToIndexOriginal); Hooking::MinHook::Hook((PVOID)Addresses::CompletePickupAnimation, (PVOID)AFortPickup::CompletePickupAnimationHook, (PVOID*)&AFortPickup::CompletePickupAnimationOriginal); - // Hooking::MinHook::Hook((PVOID)Addresses::CanActivateAbility, ReturnTrueHook); + Hooking::MinHook::Hook((PVOID)Addresses::CanActivateAbility, ReturnTrueHook); // ahhh wtf + // Hooking::MinHook::Hook((PVOID)FindFunctionCall(L"ServerRemoveInventoryItem"), UFortInventoryInterface::RemoveInventoryItemHook); + + 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); @@ -267,10 +277,10 @@ DWORD WINAPI Main(LPVOID) MemberOffsets::DeathInfo::DeathTags = FindOffsetStruct("/Script/FortniteGame.DeathInfo", "DeathTags", false); MemberOffsets::DeathInfo::DeathLocation = FindOffsetStruct("/Script/FortniteGame.DeathInfo", "DeathLocation"); - MemberOffsets::DeathReport::Tags = FindOffsetStruct("FortniteGame.FortPlayerDeathReport", "Tags"); - MemberOffsets::DeathReport::KillerPawn = FindOffsetStruct("FortniteGame.FortPlayerDeathReport", "KillerPawn"); - MemberOffsets::DeathReport::KillerPlayerState = FindOffsetStruct("FortniteGame.FortPlayerDeathReport", "KillerPlayerState"); - MemberOffsets::DeathReport::DamageCauser = FindOffsetStruct("FortniteGame.FortPlayerDeathReport", "DamageCauser"); + MemberOffsets::DeathReport::Tags = FindOffsetStruct("/Script/FortniteGame.FortPlayerDeathReport", "Tags"); + MemberOffsets::DeathReport::KillerPawn = FindOffsetStruct("/Script/FortniteGame.FortPlayerDeathReport", "KillerPawn"); + MemberOffsets::DeathReport::KillerPlayerState = FindOffsetStruct("/Script/FortniteGame.FortPlayerDeathReport", "KillerPlayerState"); + MemberOffsets::DeathReport::DamageCauser = FindOffsetStruct("/Script/FortniteGame.FortPlayerDeathReport", "DamageCauser"); } /* auto GetMaxTickRateIndex = *Memcury::Scanner::FindStringRef(L"GETMAXTICKRATE") @@ -282,6 +292,8 @@ DWORD WINAPI Main(LPVOID) LOG_INFO(LogHook, "GetMaxTickRateIndex {}", GetMaxTickRateIndex); */ + + srand(time(0)); LOG_INFO(LogHook, "Finished!"); diff --git a/Project Reboot 3.0/finder.h b/Project Reboot 3.0/finder.h index e3a7264..6bebd6c 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -94,7 +94,20 @@ static inline uint64 FindProcessEvent() static inline uint64 FindObjectArray() { + if (Engine_Version >= 421) + return Memcury::Scanner::FindPattern("48 8B 05 ? ? ? ? 48 8B 0C C8 48 8B 04 D1").RelativeOffset(3).Get(); + auto addr = Memcury::Scanner::FindPattern("48 8B 05 ? ? ? ? 48 8D 14 C8 EB 03 49 8B D6 8B 42 08 C1 E8 1D A8 01 0F 85 ? ? ? ? F7 86 ? ? ? ? ? ? ? ?", false).RelativeOffset(3).Get(); // 4.16 + + if (Engine_Version >= 416 || Engine_Version <= 420) + { + addr = Memcury::Scanner::FindPattern("48 8B 05 ? ? ? ? 48 8D 1C C8 81 4B ? ? ? ? ? 49 63 76 30", false).RelativeOffset(3).Get(); + + if (!addr) + addr = Memcury::Scanner::FindPattern("48 8B 05 ? ? ? ? 48 8D 1C C8 81 4B ? ? ? ? ? 49 63 76 30", false).RelativeOffset(3).Get(); + } + + return addr; } static inline uint64 FindCreateNetDriver() @@ -240,6 +253,35 @@ static inline uint64 FindStaticLoadObject() return Addr.Get(); } +static inline uint64 FindSpecConstructor() +{ + if (Engine_Version == 420) + return Memcury::Scanner::FindPattern("80 61 29 F8 48 8B 44 24 ?").Get(); // 3.5 + + if (Engine_Version == 421) + return Memcury::Scanner::FindPattern("80 61 29 F8 48 8B 44 24 ?").Get(); // 6.21 + + if (Engine_Version == 422) + return Memcury::Scanner::FindPattern("80 61 29 F8 48 8B 44 24 ?").Get(); // was a guess + + if (Engine_Version == 423) + return Memcury::Scanner::FindPattern("80 61 29 F8 48 8B 44 24 ?").Get(); // was a guess + + if (Engine_Version == 424) + return Memcury::Scanner::FindPattern("80 61 29 F8 48 8B 44 24 ?").Get(); // 11.31 + + if (Engine_Version == 425) + return Memcury::Scanner::FindPattern("48 8B 44 24 ? 80 61 29 F8 80 61 31 FE 48 89 41 20 33 C0 89 41").Get(); + + if (Engine_Version == 426) + return Memcury::Scanner::FindPattern("80 61 31 FE 0F 57 C0 80 61 29 F0 48 8B 44 24 ? 48").Get(); + + if (Engine_Version == 427) + return Memcury::Scanner::FindPattern("80 61 31 FE 41 83 C9 FF 80 61 29 F0 48 8B 44 24 ? 48 89 41").Get(); + + return 0; +} + static inline uint64 FindCompletePickupAnimation() { if (Engine_Version == 420) @@ -615,6 +657,14 @@ static inline uint64 FindInternalTryActivateAbility() return FindBytes(Addr, { 0x4C, 0x89, 0x4C }, 1000, 0, true); } +static inline uint64 FindFrameStep() +{ + if (Engine_Version == 426) + return Memcury::Scanner::FindPattern("48 8B 41 20 4C 8B D2 48 8B D1 44 0F B6 08 48 FF C0 48 89 41 20 41").Get(); + + return 0; +} + static inline uint64 FindCanActivateAbility() { if (Engine_Version == 421 || Engine_Version == 422) diff --git a/Project Reboot 3.0/globals.h b/Project Reboot 3.0/globals.h index 7d1f466..9c301c7 100644 --- a/Project Reboot 3.0/globals.h +++ b/Project Reboot 3.0/globals.h @@ -3,7 +3,7 @@ namespace Globals { extern inline bool bCreative = false; - extern inline bool bGoingToPlayEvent = true; + extern inline bool bGoingToPlayEvent = false; extern inline bool bNoMCP = true; extern inline bool bLateGame = false; extern inline bool bAbilitiesEnabled = true; diff --git a/Project Reboot 3.0/reboot.h b/Project Reboot 3.0/reboot.h index 3fb41f8..be6c6a6 100644 --- a/Project Reboot 3.0/reboot.h +++ b/Project Reboot 3.0/reboot.h @@ -39,7 +39,7 @@ 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(); - return StaticFindObject(Class, nullptr, NameCWSTR); + return StaticFindObject(Class, Outer, NameCWSTR); } static inline UEngine* GetEngine() diff --git a/Project Reboot 3.0/vehicles.h b/Project Reboot 3.0/vehicles.h new file mode 100644 index 0000000..b242839 --- /dev/null +++ b/Project Reboot 3.0/vehicles.h @@ -0,0 +1,198 @@ +#pragma once + +#include "reboot.h" +#include "Stack.h" +#include "Actor.h" +#include "hooking.h" +#include "SoftObjectPtr.h" + +// Vehicle class name changes multiple times across versions, so I made it it's own file. + +static inline void ServerVehicleUpdate(UObject* Context, FFrame& Stack, void* Ret) +{ + auto Params = Stack.Locals; + + auto Vehicle = Cast(Context); + static auto RootComponentOffset = Vehicle->GetOffset("RootComponent"); + auto Mesh = /* Cast */(Vehicle->Get(RootComponentOffset)); + + FTransform Transform{}; + + static std::string StateStructName = FindObject("/Script/FortniteGame.ReplicatedPhysicsPawnState") ? "/Script/FortniteGame.ReplicatedPhysicsPawnState" : ""; + + if (StateStructName.empty()) + return; + + auto State = (void*)(__int64(Params) + 0); + + static auto RotationOffset = FindOffsetStruct(StateStructName, "Rotation"); + static auto TranslationOffset = FindOffsetStruct(StateStructName, "Translation"); + + if (std::floor(Engine_Version) >= 423) + { + float v50 = -2.0; + float v49 = 2.5; + + auto Rotation = (FQuat*)(__int64(State) + RotationOffset); + + Rotation->X -= v49; + Rotation->Y /= 0.3; + Rotation->Z -= v50; + Rotation->W /= -1.2; + + Transform.Rotation = *Rotation; + } + + Transform.Translation = *(FVector*)(__int64(State) + TranslationOffset); + Transform.Scale3D = FVector{ 1, 1, 1 }; + + bool bTeleport = true; // this maybe be false?? + bool bSweep = false; + + static auto K2_SetWorldTransformFn = FindObject(L"/Script/Engine.SceneComponent.K2_SetWorldTransform"); + static auto SetPhysicsLinearVelocityFn = FindObject(L"/Script/Engine.PrimitiveComponent.SetPhysicsLinearVelocity"); + static auto SetPhysicsAngularVelocityFn = FindObject(L"/Script/Engine.PrimitiveComponent.SetPhysicsAngularVelocity"); + static auto LinearVelocityOffset = FindOffsetStruct(StateStructName, "LinearVelocity"); + static auto AngularVelocityOffset = FindOffsetStruct(StateStructName, "AngularVelocity"); + static auto K2_SetWorldTransformParamSize = K2_SetWorldTransformFn->GetPropertiesSize(); + + auto K2_SetWorldTransformParams = Alloc(K2_SetWorldTransformParamSize); + + { + static auto NewTransformOffset = FindOffsetStruct("/Script/Engine.SceneComponent.K2_SetWorldTransform", "NewTransform"); + static auto bSweepOffset = FindOffsetStruct("/Script/Engine.SceneComponent.K2_SetWorldTransform", "bSweep"); + static auto bTeleportOffset = FindOffsetStruct("/Script/Engine.SceneComponent.K2_SetWorldTransform", "bTeleport"); + + *(FTransform*)(__int64(K2_SetWorldTransformParams) + NewTransformOffset) = Transform; + *(bool*)(__int64(K2_SetWorldTransformParams) + bSweepOffset) = bSweep; + *(bool*)(__int64(K2_SetWorldTransformParams) + bTeleportOffset) = bTeleport; + } + + Mesh->ProcessEvent(K2_SetWorldTransformFn, K2_SetWorldTransformParams); + // Mesh->bComponentToWorldUpdated = true; + + struct { FVector NewVel; bool bAddToCurrent; FName BoneName; } + UPrimitiveComponent_SetPhysicsLinearVelocity_Params{ + *(FVector*)(__int64(State) + LinearVelocityOffset), + 0, + FName() + }; + + struct { FVector NewAngVel; bool bAddToCurrent; FName BoneName; } + UPrimitiveComponent_SetPhysicsAngularVelocity_Params{ + *(FVector*)(__int64(State) + AngularVelocityOffset), + 0, + FName() + }; + + Mesh->ProcessEvent(SetPhysicsLinearVelocityFn, &UPrimitiveComponent_SetPhysicsLinearVelocity_Params); + Mesh->ProcessEvent(SetPhysicsAngularVelocityFn, &UPrimitiveComponent_SetPhysicsAngularVelocity_Params); +} + +static inline void AddVehicleHook() +{ + static auto FortPhysicsPawnDefault = FindObject("/Script/FortniteGame.Default__FortPhysicsPawn"); + + if (FortPhysicsPawnDefault) + { + Hooking::MinHook::Hook(FortPhysicsPawnDefault, FindObject("/Script/FortniteGame.FortPhysicsPawn.ServerMove"), + ServerVehicleUpdate, nullptr, false, true); + } +} + +static inline void SpawnVehicles() +{ + static auto FortAthenaVehicleSpawnerClass = FindObject("/Script/FortniteGame.FortAthenaVehicleSpawner"); + TArray AllVehicleSpawners = UGameplayStatics::GetAllActorsOfClass(GetWorld(), FortAthenaVehicleSpawnerClass); + + for (int i = 0; i < AllVehicleSpawners.Num(); i++) + { + auto VehicleSpawner = (AllVehicleSpawners.at(i)); + + static auto FortVehicleItemDefVariantsOffset = VehicleSpawner->GetOffset("FortVehicleItemDefVariants"); + + bool aa = true; + + static auto VIDClass = FindObject("/Script/FortniteGame.FortVehicleItemDefinition"); + + if (FortVehicleItemDefVariantsOffset != 0) + { + struct FVehicleWeightedDef + { + TSoftObjectPtr VehicleItemDef; + char pad[0x20]; // FScalableFloat Weight; // 0x0028(0x0020) (Edit, BlueprintVisible, BlueprintReadOnly) + }; + + auto FortVehicleItemDefVariants = VehicleSpawner->GetPtr>(FortVehicleItemDefVariantsOffset); + + if (FortVehicleItemDefVariants->Num() > 0) + { + aa = false; + auto& first = FortVehicleItemDefVariants->At(0); + + auto AssetPathName = first.VehicleItemDef.SoftObjectPtr.ObjectID.AssetPathName; + + if (!AssetPathName.ComparisonIndex.Value) + continue; + + auto VehicleItemDef = LoadObject(AssetPathName.ToString(), VIDClass); + + if (VehicleItemDef) + { + static auto VehicleActorClassOffset = VehicleItemDef->GetOffset("VehicleActorClass"); + + auto VehicleActorClassSoft = VehicleItemDef->GetPtr>(VehicleActorClassOffset); + + auto VehicleClassAssetPath = VehicleActorClassSoft->SoftObjectPtr.ObjectID.AssetPathName; + + if (!VehicleClassAssetPath.ComparisonIndex.Value) + continue; + + static auto BGAClass = FindObject("/Script/Engine.BlueprintGeneratedClass"); + auto VehicleActorClass = LoadObject(VehicleClassAssetPath.ToString(), BGAClass); +; + if (!VehicleActorClass) + continue; + + GetWorld()->SpawnActor(VehicleActorClass, VehicleSpawner->GetActorLocation(), VehicleSpawner->GetActorRotation().Quaternion()); + } + } + } + + if (aa) + { + static auto FortVehicleItemDefOffset = VehicleSpawner->GetOffset("FortVehicleItemDef"); + + auto FortVehicleItemDefSoft = VehicleSpawner->GetPtr>(FortVehicleItemDefOffset); + + auto FortVehicleItemDefAssetPath = FortVehicleItemDefSoft->SoftObjectPtr.ObjectID.AssetPathName; + + if (!FortVehicleItemDefAssetPath.ComparisonIndex.Value) + continue; + + auto FortVehicleItemDef = LoadObject(FortVehicleItemDefAssetPath.ToString(), VIDClass); + + if (!FortVehicleItemDef) + continue; + + static auto VehicleActorClassOffset = FortVehicleItemDef->GetOffset("VehicleActorClass"); + + auto VehicleActorClassSoft = FortVehicleItemDef->GetPtr>(VehicleActorClassOffset); + + auto VehicleActorClassAssetPath = VehicleActorClassSoft->SoftObjectPtr.ObjectID.AssetPathName; + + if (!VehicleActorClassAssetPath.ComparisonIndex.Value) + continue; + + static auto BGAClass = FindObject("/Script/Engine.BlueprintGeneratedClass"); + auto VehicleActorClass = LoadObject(VehicleActorClassAssetPath.ToString(), BGAClass); + + if (!VehicleActorClass) + continue; + + GetWorld()->SpawnActor(VehicleActorClass, VehicleSpawner->GetActorLocation(), VehicleSpawner->GetActorRotation().Quaternion()); + } + } + + AllVehicleSpawners.Free(); +} \ No newline at end of file