From bfe2610a11149d6d2d7374d305f095f774869072 Mon Sep 17 00:00:00 2001 From: Milxnor Date: Sun, 7 May 2023 22:30:56 -0400 Subject: [PATCH] a bit fix some bug with remvoing items, add experimental stat saving for gadgets, fix shadow stones scuffy --- Project Reboot 3.0/Array.h | 26 ++++++ Project Reboot 3.0/AttributeSet.h | 20 +++++ Project Reboot 3.0/BGA.h | 7 +- Project Reboot 3.0/FortInventory.cpp | 82 +++++++------------ Project Reboot 3.0/FortInventory.h | 2 + Project Reboot 3.0/FortItem.cpp | 27 +++++- Project Reboot 3.0/FortItem.h | 19 ++--- Project Reboot 3.0/FortPickup.cpp | 4 +- Project Reboot 3.0/FortPickup.h | 4 +- Project Reboot 3.0/FortPlayerController.cpp | 75 +++++++++++++---- .../FortPlayerControllerAthena.cpp | 23 ++++-- Project Reboot 3.0/Object.cpp | 2 +- Project Reboot 3.0/Object.h | 2 +- .../Project Reboot 3.0.vcxproj.filters | 6 +- Project Reboot 3.0/bots.h | 4 +- Project Reboot 3.0/commands.h | 69 ++++++++++++++++ Project Reboot 3.0/dllmain.cpp | 6 +- Project Reboot 3.0/finder.h | 7 +- 18 files changed, 281 insertions(+), 104 deletions(-) diff --git a/Project Reboot 3.0/Array.h b/Project Reboot 3.0/Array.h index 5941185..1e68ace 100644 --- a/Project Reboot 3.0/Array.h +++ b/Project Reboot 3.0/Array.h @@ -71,6 +71,20 @@ public: ArrayMax = v3; } + int AddUnitialized2(SIZE_T NumBytesPerElement = sizeof(InElementType)) + { + const int OldArrayNum = ArrayNum; + + ArrayNum = OldArrayNum + 1; + + if (ArrayNum > ArrayMax) + { + ResizeArray(ArrayNum, NumBytesPerElement); + } + + return OldArrayNum; + } + void CopyFromArray(TArray& OtherArray, SIZE_T NumBytesPerElement = sizeof(InElementType)) { if (!OtherArray.ArrayNum && !ArrayMax) @@ -292,6 +306,18 @@ public: return -1; } + void FreeGood(SizeType Size = sizeof(InElementType)) + { + static void (*FreeOriginal)(void* Original) = decltype(FreeOriginal)(Addresses::Free); + + if (FreeOriginal) + FreeOriginal(Data); + + Data = nullptr; + ArrayNum = 0; + ArrayMax = 0; + } + void FreeReal(SizeType Size = sizeof(InElementType)) { if (!IsBadReadPtr(Data, 8) && ArrayNum > 0 && sizeof(InElementType) > 0) diff --git a/Project Reboot 3.0/AttributeSet.h b/Project Reboot 3.0/AttributeSet.h index 138ada1..042e319 100644 --- a/Project Reboot 3.0/AttributeSet.h +++ b/Project Reboot 3.0/AttributeSet.h @@ -32,4 +32,24 @@ struct FGameplayAttribute return NamePrivate->ToString(); } +}; + +struct FGameplayAttributeData +{ + float& GetBaseValue() + { + static auto BaseValueOffset = FindOffsetStruct("/Script/GameplayAbilities.GameplayAttributeData", "BaseValue"); + return *(float*)(__int64(this) + BaseValueOffset); + } + + float& GetCurrentValue() + { + static auto CurrentValueOffset = FindOffsetStruct("/Script/GameplayAbilities.GameplayAttributeData", "CurrentValue"); + return *(float*)(__int64(this) + CurrentValueOffset); + } +}; + +struct FFortGameplayAttributeData : public FGameplayAttributeData +{ + }; \ No newline at end of file diff --git a/Project Reboot 3.0/BGA.h b/Project Reboot 3.0/BGA.h index 44cbdfc..a760702 100644 --- a/Project Reboot 3.0/BGA.h +++ b/Project Reboot 3.0/BGA.h @@ -45,8 +45,10 @@ static inline void SpawnBGAs() // hahah not "proper", there's a function that we auto LootDrops = PickLootDrops(SpawnLootTierGroup, false); - for (auto& LootDrop : LootDrops) + for (int z = 0; z < LootDrops.size(); z++) { + auto& LootDrop = LootDrops.at(z); + static auto ConsumableClassOffset = LootDrop->GetItemDefinition()->GetOffset("ConsumableClass"); auto ConsumableClassSoft = LootDrop->GetItemDefinition()->GetPtr>(ConsumableClassOffset); @@ -115,7 +117,8 @@ static inline void SpawnBGAs() // hahah not "proper", there's a function that we // ConsumableActor->InitializeBuildingActor(nullptr, nullptr, true); // idk UFortKismetLibrary::SpawnBuildingGameplayActor does this - LOG_INFO(LogDev, "Spawned BGA {} at {} {} {}", ConsumableActor->GetName(), FinalSpawnTransform.Translation.X, FinalSpawnTransform.Translation.Y, FinalSpawnTransform.Translation.Z); + LOG_INFO(LogDev, "[{}/{}] Spawned BGA {} at {} {} {}", z, LootDrops.size(), ConsumableActor->GetName(), FinalSpawnTransform.Translation.X, FinalSpawnTransform.Translation.Y, FinalSpawnTransform.Translation.Z); + break; // ? } } } diff --git a/Project Reboot 3.0/FortInventory.cpp b/Project Reboot 3.0/FortInventory.cpp index 0e6d95e..5b42df8 100644 --- a/Project Reboot 3.0/FortInventory.cpp +++ b/Project Reboot 3.0/FortInventory.cpp @@ -132,19 +132,6 @@ std::pair, std::vector> AFortInventory::AddI NewItemInstances.push_back(NewItemInstance); - bool bEnableStateValues = false; // Addresses::FreeEntry; - - if (bEnableStateValues) - { - // FFortItemEntryStateValue* StateValue = Alloc(FFortItemEntryStateValue::GetStructSize(), true); - PadHexA8 StateValue{}; - ((FFortItemEntryStateValue*)&StateValue)->GetIntValue() = bShowItemToast; - ((FFortItemEntryStateValue*)&StateValue)->GetStateType() = EFortItemEntryState::ShouldShowItemToast; - ((FFortItemEntryStateValue*)&StateValue)->GetNameValue() = FName(0); - - NewItemInstance->GetItemEntry()->GetStateValues().AddPtr((FFortItemEntryStateValue*)&StateValue, FFortItemEntryStateValue::GetStructSize()); - } - ItemInstances.Add(NewItemInstance); auto ReplicatedEntryIdx = GetItemList().GetReplicatedEntries().Add(*NewItemInstance->GetItemEntry(), FFortItemEntry::GetStructSize()); // GetItemList().GetReplicatedEntries().AtPtr(ReplicatedEntryIdx, FFortItemEntry::GetStructSize())->GetIsReplicatedCopy() = true; @@ -273,63 +260,54 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int int OldCount = Count; - bool bLikeReallyForce = false; - if (Count < 0) // idk why i have this { Count = 0; bForceRemoval = true; - bLikeReallyForce = true; } auto& ItemInstances = GetItemList().GetItemInstances(); auto& ReplicatedEntries = GetItemList().GetReplicatedEntries(); - if (!bLikeReallyForce) + auto NewCount = ReplicatedEntry->GetCount() - Count; + + bool bOverrideChangeStackSize = false; + + if (ItemDefinition->ShouldPersistWhenFinalStackEmpty()) { - auto NewCount = ReplicatedEntry->GetCount() - Count; + bool bIsFinalStack = true; - bool bOverrideChangeStackSize = false; - - if (ItemDefinition->ShouldPersistWhenFinalStackEmpty()) + for (int i = 0; i < ItemInstances.Num(); i++) { - bool bIsFinalStack = true; + auto ItemInstance = ItemInstances.at(i); - for (int i = 0; i < ItemInstances.Num(); i++) + if (ItemInstance->GetItemEntry()->GetItemDefinition() == ItemDefinition && ItemInstance->GetItemEntry()->GetItemGuid() != ItemGuid) { - auto ItemInstance = ItemInstances.at(i); - - if (ItemInstance->GetItemEntry()->GetItemDefinition() == ItemDefinition && ItemInstance->GetItemEntry()->GetItemGuid() != ItemGuid) - { - bIsFinalStack = false; - break; - } - } - - if (bIsFinalStack) - { - NewCount = NewCount < 0 ? 0 : NewCount; // min(NewCount, 0) or something i forgot - bOverrideChangeStackSize = true; + bIsFinalStack = false; + break; } } - if (OldCount != -1 && (NewCount > 0 || bOverrideChangeStackSize)) + if (bIsFinalStack) { - ItemInstance->GetItemEntry()->GetCount() = NewCount; - ReplicatedEntry->GetCount() = NewCount; - - GetItemList().MarkItemDirty(ItemInstance->GetItemEntry()); - GetItemList().MarkItemDirty(ReplicatedEntry); - - return true; + NewCount = NewCount < 0 ? 0 : NewCount; // min(NewCount, 0) or something i forgot + bOverrideChangeStackSize = true; } - - if (NewCount < 0) // Hm - return false; } - static auto FortItemEntryStruct = FindObject(L"/Script/FortniteGame.FortItemEntry"); - static auto FortItemEntrySize = FortItemEntryStruct->GetPropertiesSize(); + if (OldCount != -1 && (NewCount > 0 || bOverrideChangeStackSize)) + { + ItemInstance->GetItemEntry()->GetCount() = NewCount; + ReplicatedEntry->GetCount() = NewCount; + + GetItemList().MarkItemDirty(ItemInstance->GetItemEntry()); + GetItemList().MarkItemDirty(ReplicatedEntry); + + return true; + } + + if (NewCount < 0) // Hm + return false; auto FortPlayerController = Cast(GetOwner()); @@ -368,10 +346,10 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int for (int i = 0; i < ReplicatedEntries.Num(); i++) { - if (ReplicatedEntries.at(i, FortItemEntrySize).GetItemGuid() == ItemGuid) + if (ReplicatedEntries.at(i, FFortItemEntry::GetStructSize()).GetItemGuid() == ItemGuid) { - FFortItemEntry::FreeItemEntry(ReplicatedEntries.AtPtr(i, FortItemEntrySize)); - ReplicatedEntries.Remove(i, FortItemEntrySize); + FFortItemEntry::FreeItemEntry(ReplicatedEntries.AtPtr(i, FFortItemEntry::GetStructSize())); + ReplicatedEntries.Remove(i, FFortItemEntry::GetStructSize()); break; } } diff --git a/Project Reboot 3.0/FortInventory.h b/Project Reboot 3.0/FortInventory.h index 726de37..fb14140 100644 --- a/Project Reboot 3.0/FortInventory.h +++ b/Project Reboot 3.0/FortInventory.h @@ -9,6 +9,8 @@ #include "reboot.h" +#define REMOVE_ALL_ITEMS -1 + static bool IsPrimaryQuickbar(UFortItemDefinition* ItemDefinition) { /* if (ItemDefinition->IsA(UFortDecoItemDefinition::StaticClass())) diff --git a/Project Reboot 3.0/FortItem.cpp b/Project Reboot 3.0/FortItem.cpp index 8488188..af55850 100644 --- a/Project Reboot 3.0/FortItem.cpp +++ b/Project Reboot 3.0/FortItem.cpp @@ -1,11 +1,34 @@ #include "FortItem.h" #include "FortWeaponItemDefinition.h" +#include "AbilitySystemComponent.h" + +void FFortItemEntry::SetStateValue(EFortItemEntryState StateType, int IntValue) +{ + for (int i = 0; i < GetStateValues().Num(); i++) + { + if (GetStateValues().at(i).GetStateType() == StateType) + { + GetStateValues().at(i).GetIntValue() = IntValue; + return; + } + } + + auto idx = GetStateValues().AddUnitialized2(FFortItemEntryStateValue::GetStructSize()); + + GetStateValues().AtPtr(idx, FFortItemEntryStateValue::GetStructSize())->GetIntValue() = IntValue; + GetStateValues().AtPtr(idx, FFortItemEntryStateValue::GetStructSize())->GetStateType() = StateType; + GetStateValues().AtPtr(idx, FFortItemEntryStateValue::GetStructSize())->GetNameValue() = FName(0); + + // idk some parentinventory stuff here + + // ItemEntry->bIsDirty = true; +} FFortItemEntry* FFortItemEntry::MakeItemEntry(UFortItemDefinition* ItemDefinition, int Count, int LoadedAmmo, float Durability) { - auto Entry = // (FFortItemEntry*)FMemory::Realloc(0, GetStructSize(), 0); - Alloc(GetStructSize()); + bool bUseFMemoryRealloc = false; // I don't think this works because sometimes we don't free it (oops). + auto Entry = Alloc(GetStructSize(), bUseFMemoryRealloc); if (!Entry) return nullptr; diff --git a/Project Reboot 3.0/FortItem.h b/Project Reboot 3.0/FortItem.h index 7548c8e..0cf743a 100644 --- a/Project Reboot 3.0/FortItem.h +++ b/Project Reboot 3.0/FortItem.h @@ -160,17 +160,12 @@ struct FFortItemEntry : FFastArraySerializerItem static auto GenericAttributeValuesOffset = FindOffsetStruct("/Script/FortniteGame.FortItemEntry", "GenericAttributeValues", false); if (GenericAttributeValuesOffset != -1) - { - // proper copying - + { this->GetGenericAttributeValues().CopyFromArray(OtherItemEntry->GetGenericAttributeValues()); - - /* for (int i = 0; i < OtherItemEntry->GetGenericAttributeValues().Num(); i++) - { - this->GetGenericAttributeValues().Add(OtherItemEntry->GetGenericAttributeValues().at(i)); - } */ } + this->GetStateValues().CopyFromArray(OtherItemEntry->GetStateValues(), FFortItemEntryStateValue::GetStructSize()); + // should we do this? this->MostRecentArrayReplicationKey = -1; @@ -178,6 +173,8 @@ struct FFortItemEntry : FFastArraySerializerItem this->ReplicationKey = -1; } + void SetStateValue(EFortItemEntryState StateType, int IntValue); + static UStruct* GetStruct() { static auto Struct = FindObject("/Script/FortniteGame.FortItemEntry"); @@ -207,13 +204,13 @@ struct FFortItemEntry : FFastArraySerializerItem if (GenericAttributeValuesOffset != -1) { - Entry->GetGenericAttributeValues().Free(); + Entry->GetGenericAttributeValues().FreeGood(); } - Entry->GetStateValues().Free(); + Entry->GetStateValues().FreeGood(); } - RtlZeroMemory(Entry, FFortItemEntry::GetStructSize()); + // RtlZeroMemory(Entry, FFortItemEntry::GetStructSize()); } static void FreeArrayOfEntries(TArray& tarray) diff --git a/Project Reboot 3.0/FortPickup.cpp b/Project Reboot 3.0/FortPickup.cpp index 5e26e42..29fdd5b 100644 --- a/Project Reboot 3.0/FortPickup.cpp +++ b/Project Reboot 3.0/FortPickup.cpp @@ -64,7 +64,9 @@ AFortPickup* AFortPickup::SpawnPickup(PickupCreateData& PickupData) if (Addresses::PickupInitialize) { - static void (*SetupPickup)(AFortPickup * Pickup, __int64 ItemEntry, TArray MultiItemPickupEntriesIGuess, bool bSplitOnPickup) + // Honestly this is the god function, it automatically handles special actors and automatically adds to state values, who else knows what it does. + + static void (*SetupPickup)(AFortPickup* Pickup, __int64 ItemEntry, TArray MultiItemPickupEntriesIGuess, bool bSplitOnPickup) = decltype(SetupPickup)(Addresses::PickupInitialize); TArray MultiItemPickupEntriesIGuess{}; diff --git a/Project Reboot 3.0/FortPickup.h b/Project Reboot 3.0/FortPickup.h index 0e055ca..3c1283d 100644 --- a/Project Reboot 3.0/FortPickup.h +++ b/Project Reboot 3.0/FortPickup.h @@ -24,7 +24,7 @@ namespace EFortPickupSourceTypeFlag return ContainerValue; } - static inline int64 GetFloorLootValue() + static inline int64 GetFloorLootValue() { static auto FloorLootValue = GetEnum() ? GetEnum()->GetValue("FloorLoot") : -1; return FloorLootValue; @@ -82,7 +82,7 @@ struct PickupCreateData { if (bShouldFreeItemEntryWhenDeconstructed) { - + // real } } }; diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 29f86e2..b0c920b 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -848,7 +848,7 @@ void AFortPlayerController::ServerCreateBuildingActorHook(UObject* Context, FFra bool bBuildFree = PlayerController->DoesBuildFree(); - LOG_INFO(LogDev, "MatInstance->GetItemEntry()->GetCount(): {}", MatInstance->GetItemEntry()->GetCount()); + // LOG_INFO(LogDev, "MatInstance->GetItemEntry()->GetCount(): {}", MatInstance->GetItemEntry()->GetCount()); bool bShouldDestroy = MatInstance && MatInstance->GetItemEntry() ? MatInstance->GetItemEntry()->GetCount() < 10 : true; @@ -977,25 +977,73 @@ void AFortPlayerController::ServerAttemptInventoryDropHook(AFortPlayerController if (!ItemDefinition->ShouldIgnoreRespawningOnDrop() && (DropBehaviorOffset != -1 ? ItemDefinition->GetDropBehavior() != EWorldItemDropBehavior::DestroyOnDrop : true)) { - /* if (auto GadgetItemDefintiion = Cast(ItemDefinition)) + if (false) { - for (int i = 0; i < GadgetItemDefintiion->GetTrackedAttributes().Num(); i++) + if (auto GadgetItemDefinition = Cast(ItemDefinition)) { - LOG_INFO(LogDev, "[{}] TrackedAttribute Attribute Name {}", i, GadgetItemDefintiion->GetTrackedAttributes().at(i).GetAttributePropertyName()); + auto PlayerState = Cast(PlayerController->GetPlayerState()); + auto ASC = PlayerState->GetAbilitySystemComponent(); - PadHexA8 StateValue{}; // Alloc(FFortItemEntryStateValue::GetStructSize(), true); - ((FFortItemEntryStateValue*)&StateValue)->GetIntValue() = 1; - ((FFortItemEntryStateValue*)&StateValue)->GetStateType() = EFortItemEntryState::GenericAttributeValueSet; - ((FFortItemEntryStateValue*)&StateValue)->GetNameValue() = FName(0); + if (GadgetItemDefinition->GetTrackedAttributes().Num() > 0) + { + ReplicatedEntry->SetStateValue(EFortItemEntryState::GenericAttributeValueSet, 1); + } - ReplicatedEntry->GetStateValues().AddPtr((FFortItemEntryStateValue*)&StateValue, FFortItemEntryStateValue::GetStructSize()); + std::vector AttributeValueVector; - ReplicatedEntry->GetGenericAttributeValues().Add(9); + for (int i = 0; i < GadgetItemDefinition->GetTrackedAttributes().Num(); i++) + { + auto& CurrentTrackedAttribute = GadgetItemDefinition->GetTrackedAttributes().at(i); + + // LOG_INFO(LogDev, "[{}] TrackedAttribute Attribute Property Name {}", i, GadgetItemDefinition->GetTrackedAttributes().at(i).GetAttributePropertyName()); + // LOG_INFO(LogDev, "[{}] TrackedAttribute Attribute Name {}", i, GadgetItemDefinition->GetTrackedAttributes().at(i).GetAttributeName()); + // LOG_INFO(LogDev, "[{}] TrackedAttribute Attribute Owner {}", i, GadgetItemDefinition->GetTrackedAttributes().at(i).AttributeOwner->GetPathName()); + + auto AbilitySystemComponent = PlayerState->GetAbilitySystemComponent(); + + int CurrentAttributeValue = -1; + + for (int i = 0; i < AbilitySystemComponent->GetSpawnedAttributes().Num(); i++) + { + auto CurrentSpawnedAttribute = AbilitySystemComponent->GetSpawnedAttributes().at(i); + + if (CurrentSpawnedAttribute->IsA(CurrentTrackedAttribute.AttributeOwner)) + { + auto PropertyOffset = CurrentSpawnedAttribute->GetOffset(CurrentTrackedAttribute.GetAttributePropertyName()); + + if (PropertyOffset != -1) + { + CurrentAttributeValue = CurrentSpawnedAttribute->GetPtr(PropertyOffset)->GetCurrentValue(); + break; // hm + } + } + } + + // LOG_INFO(LogDev, "CurrentAttributeValue: {}", CurrentAttributeValue); + + if (CurrentAttributeValue != -1) // Found the attribute. + { + // im so smart + + AttributeValueVector.push_back(CurrentAttributeValue); + } + } + + for (int z = 0; z < ReplicatedEntry->GetGenericAttributeValues().Num(); z++) // First value must be the current value // dont ask me why fortnite keeps the old values in it too.. + { + AttributeValueVector.push_back(ReplicatedEntry->GetGenericAttributeValues().at(z)); + } + + ReplicatedEntry->GetGenericAttributeValues().Free(); + + for (auto& AttributeValue : AttributeValueVector) + { + ReplicatedEntry->GetGenericAttributeValues().Add(AttributeValue); + } } - } */ + } - auto Pickup = AFortPickup::SpawnPickup(ReplicatedEntry, Pawn->GetActorLocation(), - EFortPickupSourceTypeFlag::GetPlayerValue(), 0, Pawn, nullptr, true, Count); + auto Pickup = AFortPickup::SpawnPickup(ReplicatedEntry, Pawn->GetActorLocation(), EFortPickupSourceTypeFlag::GetPlayerValue(), 0, Pawn, nullptr, true, Count); if (!Pickup) return; @@ -1337,7 +1385,6 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo if (WorldInventory) { - auto& ItemInstances = WorldInventory->GetItemList().GetItemInstances(); std::vector> GuidAndCountsToRemove; diff --git a/Project Reboot 3.0/FortPlayerControllerAthena.cpp b/Project Reboot 3.0/FortPlayerControllerAthena.cpp index 16ae693..764c515 100644 --- a/Project Reboot 3.0/FortPlayerControllerAthena.cpp +++ b/Project Reboot 3.0/FortPlayerControllerAthena.cpp @@ -46,9 +46,12 @@ void AFortPlayerControllerAthena::StartGhostModeHook(UObject* Context, FFrame* S auto PickaxeInstance = WorldInventory->GetPickaxeInstance(); + // LOG_INFO(LogDev, "PickaxeInstance: {}", __int64(PickaxeInstance)); + if (PickaxeInstance) { - WorldInventory->RemoveItem(PickaxeInstance->GetItemEntry()->GetItemGuid(), nullptr, PickaxeInstance->GetItemEntry()->GetCount(), true); + WorldInventory->RemoveItem(PickaxeInstance->GetItemEntry()->GetItemGuid(), nullptr, REMOVE_ALL_ITEMS, true); + // WorldInventory->Update(); } bool bShouldUpdate = false; @@ -59,7 +62,10 @@ void AFortPlayerControllerAthena::StartGhostModeHook(UObject* Context, FFrame* S return StartGhostModeOriginal(Context, Stack, Ret); // if (bShouldUpdate) - WorldInventory->Update(); + WorldInventory->Update(); + + PlayerController->AddPickaxeToInventory(); + WorldInventory->Update(); PlayerController->ServerExecuteInventoryItemHook(PlayerController, GhostModeItemInstance->GetItemEntry()->GetItemGuid()); PlayerController->ClientEquipItem(GhostModeItemInstance->GetItemEntry()->GetItemGuid(), true); @@ -103,23 +109,22 @@ void AFortPlayerControllerAthena::EndGhostModeHook(AFortPlayerControllerAthena* return EndGhostModeOriginal(PlayerController); auto PickaxeInstance = PlayerController->AddPickaxeToInventory(); - WorldInventory->Update(); WorldInventory->ForceNetUpdate(); PlayerController->ForceNetUpdate(); - if (PickaxeInstance) - { - PlayerController->ClientEquipItem(PickaxeInstance->GetItemEntry()->GetItemGuid(), true); - } - bool bShouldUpdate = false; int Count = GhostModeItemInstance->GetItemEntry()->GetCount(); // 1 bool bForceRemoval = true; // false WorldInventory->RemoveItem(GhostModeItemInstance->GetItemEntry()->GetItemGuid(), &bShouldUpdate, Count, bForceRemoval); // if (bShouldUpdate) - WorldInventory->Update(); + WorldInventory->Update(); + + if (PickaxeInstance) + { + PlayerController->ClientEquipItem(PickaxeInstance->GetItemEntry()->GetItemGuid(), true); + } return EndGhostModeOriginal(PlayerController); } diff --git a/Project Reboot 3.0/Object.cpp b/Project Reboot 3.0/Object.cpp index a4642fb..f86f75a 100644 --- a/Project Reboot 3.0/Object.cpp +++ b/Project Reboot 3.0/Object.cpp @@ -155,7 +155,7 @@ UPackage* UObject::GetOutermost() const } } -bool UObject::IsA(UClass* otherClass) +bool UObject::IsA(UStruct* otherClass) { UClass* super = ClassPrivate; diff --git a/Project Reboot 3.0/Object.h b/Project Reboot 3.0/Object.h index 1f09759..5f78ecc 100644 --- a/Project Reboot 3.0/Object.h +++ b/Project Reboot 3.0/Object.h @@ -57,7 +57,7 @@ public: FName GetFName() const { return NamePrivate; } class UPackage* GetOutermost() const; - bool IsA(UClass* Other); + bool IsA(class UStruct* Other); class UFunction* FindFunction(const std::string& ShortFunctionName); void* GetProperty(const std::string& ChildName, bool bWarnIfNotFound = true); 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 b3f47f1..dcdc61a 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -118,9 +118,6 @@ FortniteGame\Source\FortniteGame\Private\Items - - FortniteGame\Source\FortniteGame\Private\Items - FortniteGame\Source\FortniteGame\Private\Items @@ -268,6 +265,9 @@ FortniteGame\Source\FortniteGame\Private + + FortniteGame\Source\FortniteGame\Private\Items + diff --git a/Project Reboot 3.0/bots.h b/Project Reboot 3.0/bots.h index c4dfdd1..8a0c16b 100644 --- a/Project Reboot 3.0/bots.h +++ b/Project Reboot 3.0/bots.h @@ -190,7 +190,7 @@ namespace Bots auto GameState = Cast(GetWorld()->GetGameState()); auto GameMode = Cast(GetWorld()->GetGameMode()); - auto AllBuildingContainers = UGameplayStatics::GetAllActorsOfClass(GetWorld(), ABuildingContainer::StaticClass()); + // auto AllBuildingContainers = UGameplayStatics::GetAllActorsOfClass(GetWorld(), ABuildingContainer::StaticClass()); // for (int i = 0; i < GameMode->GetAlivePlayers().Num(); i++) for (auto& PlayerBot : AllPlayerBotsToTick) @@ -243,6 +243,6 @@ namespace Bots } */ } - AllBuildingContainers.Free(); + // AllBuildingContainers.Free(); } } \ No newline at end of file diff --git a/Project Reboot 3.0/commands.h b/Project Reboot 3.0/commands.h index 3f4e3fe..2202513 100644 --- a/Project Reboot 3.0/commands.h +++ b/Project Reboot 3.0/commands.h @@ -221,6 +221,75 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg) SendMessageToConsole(PlayerController, L"Printed!"); } + /* else if (Command == "debugattributes") + { + auto AbilitySystemComponent = ReceivingPlayerState->GetAbilitySystemComponent(); + + if (!AbilitySystemComponent) + { + SendMessageToConsole(PlayerController, L"No AbilitySystemComponent!"); + return; + } + + SendMessageToConsole(PlayerController, (L"AbilitySystemComponent->GetSpawnedAttributes().Num(): " + std::to_wstring(AbilitySystemComponent->GetSpawnedAttributes().Num())).c_str()); + + for (int i = 0; i < AbilitySystemComponent->GetSpawnedAttributes().Num(); i++) + { + auto CurrentAttributePathName = AbilitySystemComponent->GetSpawnedAttributes().at(i)->GetPathName(); + SendMessageToConsole(PlayerController, (L"SpawnedAttribute Name: " + std::wstring(CurrentAttributePathName.begin(), CurrentAttributePathName.end())).c_str()); + } + } + else if (Command == "debugcurrentitem") + { + auto Pawn = ReceivingController->GetMyFortPawn(); + + if (!Pawn) + { + SendMessageToConsole(PlayerController, L"No pawn!"); + return; + } + + auto CurrentWeapon = Pawn->GetCurrentWeapon(); + + if (!CurrentWeapon) + { + SendMessageToConsole(PlayerController, L"No CurrentWeapon!"); + return; + } + + auto WorldInventory = ReceivingController->GetWorldInventory(); + + if (!CurrentWeapon) + { + SendMessageToConsole(PlayerController, L"No WorldInventory!"); + return; + } + + auto ItemInstance = WorldInventory->FindItemInstance(CurrentWeapon->GetItemEntryGuid()); + auto ReplicatedEntry = WorldInventory->FindReplicatedEntry(CurrentWeapon->GetItemEntryGuid()); + + if (!ItemInstance) + { + SendMessageToConsole(PlayerController, L"Failed to find ItemInstance!"); + return; + } + + if (!ReplicatedEntry) + { + SendMessageToConsole(PlayerController, L"Failed to find ReplicatedEntry!"); + return; + } + + SendMessageToConsole(PlayerController, (L"ReplicatedEntry->GetGenericAttributeValues().Num(): " + std::to_wstring(ReplicatedEntry->GetGenericAttributeValues().Num())).c_str()); + SendMessageToConsole(PlayerController, (L"ReplicatedEntry->GetStateValues().Num(): " + std::to_wstring(ReplicatedEntry->GetStateValues().Num())).c_str()); + + for (int i = 0; i < ReplicatedEntry->GetStateValues().Num(); i++) + { + SendMessageToConsole(PlayerController, (L"[{}] StateValue Type: " + + std::to_wstring((int)ReplicatedEntry->GetStateValues().at(i, FFortItemEntryStateValue::GetStructSize()).GetStateType())).c_str() + ); + } + } */ else if (Command == "setpickaxe") { if (NumArgs < 1) diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index 18f4f70..ceaa341 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -493,7 +493,7 @@ DWORD WINAPI Main(LPVOID) Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerControllerZone.ServerRequestSeatChange"), AFortPlayerControllerAthena::ServerRequestSeatChangeHook, (PVOID*)&AFortPlayerControllerAthena::ServerRequestSeatChangeOriginal, false); - if (false) + // if (false) { Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerControllerGameplay.StartGhostMode"), // (Milxnor) TODO: This changes to a component in later seasons. AFortPlayerControllerAthena::StartGhostModeHook, (PVOID*)&AFortPlayerControllerAthena::StartGhostModeOriginal, false, true); // We can exec hook since it only gets called via blueprint. @@ -578,8 +578,8 @@ DWORD WINAPI Main(LPVOID) AFortPawn::NetMulticast_Athena_BatchedDamageCuesHook, (PVOID*)&AFortPawn::NetMulticast_Athena_BatchedDamageCuesOriginal, false, true); Hooking::MinHook::Hook(FortPlayerPawnAthenaDefault, FindObject(L"/Script/FortniteGame.FortPawn.MovingEmoteStopped"), AFortPawn::MovingEmoteStoppedHook, (PVOID*)&AFortPawn::MovingEmoteStoppedOriginal, false, true); - Hooking::MinHook::Hook(FortPlayerPawnAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerPawnAthena.OnCapsuleBeginOverlap") ? FindObject(L"/Script/FortniteGame.FortPlayerPawnAthena.OnCapsuleBeginOverlap") : FindObject(L"/Script/FortniteGame.FortPlayerPawn.OnCapsuleBeginOverlap"), - AFortPlayerPawnAthena::OnCapsuleBeginOverlapHook, (PVOID*)&AFortPlayerPawnAthena::OnCapsuleBeginOverlapOriginal, false, true); + // Hooking::MinHook::Hook(FortPlayerPawnAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerPawnAthena.OnCapsuleBeginOverlap") ? FindObject(L"/Script/FortniteGame.FortPlayerPawnAthena.OnCapsuleBeginOverlap") : FindObject(L"/Script/FortniteGame.FortPlayerPawn.OnCapsuleBeginOverlap"), + // AFortPlayerPawnAthena::OnCapsuleBeginOverlapHook, (PVOID*)&AFortPlayerPawnAthena::OnCapsuleBeginOverlapOriginal, false, true); Hooking::MinHook::Hook(FortKismetLibraryDefault, FindObject(L"/Script/FortniteGame.FortKismetLibrary.K2_RemoveFortItemFromPlayer"), UFortKismetLibrary::K2_RemoveFortItemFromPlayerHook, (PVOID*)&UFortKismetLibrary::K2_RemoveFortItemFromPlayerOriginal, false, true); diff --git a/Project Reboot 3.0/finder.h b/Project Reboot 3.0/finder.h index 34e3824..a4aab88 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -424,7 +424,12 @@ static inline uint64 FindGetPlayerViewpoint() static inline uint64 FindFree() { - auto addr = Memcury::Scanner::FindPattern("48 85 C9 74 2E 53 48 83 EC 20 48 8B D9").Get(); + return 0; + + uint64 addr = 0; + + if (Engine_Version >= 421 && Engine_Version <= 423) + addr = Memcury::Scanner::FindPattern("48 85 C9 74 2E 53 48 83 EC 20 48 8B D9").Get(); return addr; }