diff --git a/Project Reboot 3.0/BGA.h b/Project Reboot 3.0/BGA.h index 3959b42..9397251 100644 --- a/Project Reboot 3.0/BGA.h +++ b/Project Reboot 3.0/BGA.h @@ -4,6 +4,7 @@ #include "GameplayStatics.h" #include "FortLootPackage.h" #include "FortPickup.h" +#include "BuildingGameplayActor.h" void SpawnBGAs() // hahah not "proper", there's a function that we can hook and it gets called on each spawner whenever playlist gets set, but it's fine. { @@ -12,6 +13,8 @@ void SpawnBGAs() // hahah not "proper", there's a function that we can hook and if (!BGAConsumableSpawnerClass) return; + auto GameState = Cast(GetWorld()->GetGameState()); + auto AllBGAConsumableSpawners = UGameplayStatics::GetAllActorsOfClass(GetWorld(), BGAConsumableSpawnerClass); LOG_INFO(LogDev, "AllBGAConsumableSpawners.Num(): {}", (int)AllBGAConsumableSpawners.Num()); @@ -20,7 +23,17 @@ void SpawnBGAs() // hahah not "proper", there's a function that we can hook and { auto BGAConsumableSpawner = AllBGAConsumableSpawners.at(i); auto SpawnLocation = BGAConsumableSpawner->GetActorLocation(); - SpawnLocation.Z += 100; + + if (FBuildingGameplayActorSpawnDetails::GetStruct()) + { + // todo handle? + + auto MapInfo = GameState->GetMapInfo(); + } + else + { + // SpawnLocation.Z += 100; + } static auto SpawnLootTierGroupOffset = BGAConsumableSpawner->GetOffset("SpawnLootTierGroup"); auto& SpawnLootTierGroup = BGAConsumableSpawner->Get(SpawnLootTierGroupOffset); @@ -41,7 +54,13 @@ void SpawnBGAs() // hahah not "proper", there's a function that we can hook and continue; } - auto ConsumableActor = GetWorld()->SpawnActor(StrongConsumableClass, SpawnLocation); + auto ConsumableActor = GetWorld()->SpawnActor(StrongConsumableClass, SpawnLocation); + + if (ConsumableActor) + { + // BeginDeferredActorSpawnFromClass ?? + // ConsumableActor->InitializeBuildingActor(nullptr, nullptr, true); // idk UFortKismetLibrary::SpawnBuildingGameplayActor does this + } } } diff --git a/Project Reboot 3.0/FortAbilitySet.h b/Project Reboot 3.0/FortAbilitySet.h index 3f0dcdb..130d966 100644 --- a/Project Reboot 3.0/FortAbilitySet.h +++ b/Project Reboot 3.0/FortAbilitySet.h @@ -48,22 +48,8 @@ public: return this->GetPtr>(GrantedGameplayEffectsOffset); } - void GiveToAbilitySystem(UAbilitySystemComponent* AbilitySystemComponent, UObject* SourceObject = nullptr) + void ApplyGrantedGameplayAffectsToAbilitySystem(UAbilitySystemComponent* AbilitySystemComponent) { - auto GameplayAbilities = GetGameplayAbilities(); - - for (int i = 0; i < GameplayAbilities->Num(); i++) - { - UClass* AbilityClass = GameplayAbilities->At(i); - - if (!AbilityClass) - continue; - - LOG_INFO(LogDev, "Giving AbilityClass {}", AbilityClass->GetFullName()); - - AbilitySystemComponent->GiveAbilityEasy(AbilityClass, SourceObject); - } - if (!FGameplayEffectApplicationInfoHard::GetStruct()) return; @@ -86,6 +72,25 @@ public: } } + void GiveToAbilitySystem(UAbilitySystemComponent* AbilitySystemComponent, UObject* SourceObject = nullptr) + { + auto GameplayAbilities = GetGameplayAbilities(); + + for (int i = 0; i < GameplayAbilities->Num(); i++) + { + UClass* AbilityClass = GameplayAbilities->At(i); + + if (!AbilityClass) + continue; + + LOG_INFO(LogDev, "Giving AbilityClass {}", AbilityClass->GetFullName()); + + AbilitySystemComponent->GiveAbilityEasy(AbilityClass, SourceObject); + } + + ApplyGrantedGameplayAffectsToAbilitySystem(AbilitySystemComponent); + } + static UClass* StaticClass() { static auto Class = FindObject("/Script/FortniteGame.FortAbilitySet"); diff --git a/Project Reboot 3.0/FortAthenaMapInfo.h b/Project Reboot 3.0/FortAthenaMapInfo.h index 8f8466d..f5cde36 100644 --- a/Project Reboot 3.0/FortAthenaMapInfo.h +++ b/Project Reboot 3.0/FortAthenaMapInfo.h @@ -1,12 +1,93 @@ #pragma once +#include + #include "Actor.h" #include "GameplayAbilityTypes.h" +#include "DataTableFunctionLibrary.h" + +static inline float CalcuateCurveMinAndMax(FScalableFloat* Min, FScalableFloat* Max) // returns 000 not 0.00 (forgot techinal name for this) +{ + float MinSpawnPercent = UDataTableFunctionLibrary::EvaluateCurveTableRow(Min->GetCurve().CurveTable, Min->GetCurve().RowName, 0); + float MaxSpawnPercent = UDataTableFunctionLibrary::EvaluateCurveTableRow(Max->GetCurve().CurveTable, Max->GetCurve().RowName, 0); + + std::random_device MinMaxRd; + std::mt19937 MinMaxGen(MinMaxRd()); + std::uniform_int_distribution<> MinMaxDis(MinSpawnPercent * 100, MaxSpawnPercent * 100 + 1); // + 1 ? + + float SpawnPercent = MinMaxDis(MinMaxGen); + + return SpawnPercent; +} + +struct FBuildingGameplayActorSpawnDetails +{ + static UStruct* GetStruct() + { + static auto Struct = FindObject("/Script/FortniteGame.BuildingGameplayActorSpawnDetails"); + return Struct; + } + + static int GetStructSize() { return GetStruct()->GetPropertiesSize(); } + + FScalableFloat* GetSpawnHeight() + { + static auto SpawnHeightOffset = FindOffsetStruct("/Script/FortniteGame.BuildingGameplayActorSpawnDetails", "SpawnHeight"); + return (FScalableFloat*)(__int64(this) + SpawnHeightOffset); + } + + UClass*& GetBuildingGameplayActorClass() + { + static auto BuildingGameplayActorClassOffset = FindOffsetStruct("/Script/FortniteGame.BuildingGameplayActorSpawnDetails", "BuildingGameplayActorClass"); + return *(UClass**)(__int64(this) + BuildingGameplayActorClassOffset); + } + + UClass*& GetTargetActorClass() + { + static auto TargetActorClassOffset = FindOffsetStruct("/Script/FortniteGame.BuildingGameplayActorSpawnDetails", "TargetActorClass"); + return *(UClass**)(__int64(this) + TargetActorClassOffset); + } +}; + +struct FVehicleClassDetails +{ + static UStruct* GetStruct() + { + static auto Struct = FindObject("/Script/FortniteGame.VehicleClassDetails"); + return Struct; + } + + static int GetStructSize() { return GetStruct()->GetPropertiesSize(); } + + TSoftObjectPtr& GetVehicleClass() + { + static auto VehicleClassOffset = FindOffsetStruct("/Script/FortniteGame.VehicleClassDetails", "VehicleClass"); + return *(TSoftObjectPtr*)(__int64(this) + VehicleClassOffset); + } + + FScalableFloat* GetVehicleMinSpawnPercent() + { + static auto VehicleMinSpawnPercentOffset = FindOffsetStruct("/Script/FortniteGame.VehicleClassDetails", "VehicleMinSpawnPercent"); + return (FScalableFloat*)(__int64(this) + VehicleMinSpawnPercentOffset); + } + + FScalableFloat* GetVehicleMaxSpawnPercent() + { + static auto VehicleMaxSpawnPercentOffset = FindOffsetStruct("/Script/FortniteGame.VehicleClassDetails", "VehicleMaxSpawnPercent"); + return (FScalableFloat*)(__int64(this) + VehicleMaxSpawnPercentOffset); + } +}; class AFortAthenaMapInfo : public AActor { public: + TArray& GetVehicleClassDetails() + { + static auto VehicleClassDetailsOffset = GetOffset("VehicleClassDetails"); + return Get>(VehicleClassDetailsOffset); + } + UClass*& GetAmmoBoxClass() { static auto AmmoBoxClassOffset = GetOffset("AmmoBoxClass"); @@ -42,4 +123,10 @@ public: static auto TreasureChestMaxSpawnPercentOffset = GetOffset("TreasureChestMaxSpawnPercent"); return GetPtr(TreasureChestMaxSpawnPercentOffset); } + + TArray& GetBuildingGameplayActorSpawnDetails() + { + static auto BuildingGameplayActorSpawnDetailsOffset = GetOffset("BuildingGameplayActorSpawnDetails"); + return Get>(BuildingGameplayActorSpawnDetailsOffset); + } }; \ No newline at end of file diff --git a/Project Reboot 3.0/FortAthenaVehicleSpawner.cpp b/Project Reboot 3.0/FortAthenaVehicleSpawner.cpp new file mode 100644 index 0000000..104d04f --- /dev/null +++ b/Project Reboot 3.0/FortAthenaVehicleSpawner.cpp @@ -0,0 +1,11 @@ +#include "FortAthenaVehicleSpawner.h" + +#include "vehicles.h" + +void AFortAthenaVehicleSpawner::SpawnVehicleHook(AFortAthenaVehicleSpawner* VehicleSpawner) +{ + // literally doesnt get called!!!! + + // LOG_INFO(LogDev, "omgonmg call!!!!\n\n"); + // SpawnVehicleFromSpawner(VehicleSpawner); +} \ No newline at end of file diff --git a/Project Reboot 3.0/FortAthenaVehicleSpawner.h b/Project Reboot 3.0/FortAthenaVehicleSpawner.h new file mode 100644 index 0000000..35823dc --- /dev/null +++ b/Project Reboot 3.0/FortAthenaVehicleSpawner.h @@ -0,0 +1,9 @@ +#pragma once + +#include "Actor.h" + +class AFortAthenaVehicleSpawner : public AActor +{ +public: + static void SpawnVehicleHook(AFortAthenaVehicleSpawner* VehicleSpawner); +}; \ No newline at end of file diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 351b6db..2bd264f 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -195,9 +195,9 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game static int LastNum2 = 1; - if (Globals::AmountOfListens != LastNum2) + if (AmountOfRestarts != LastNum2) { - LastNum2 = Globals::AmountOfListens; + LastNum2 = AmountOfRestarts; LOG_INFO(LogDev, "Presetup!"); @@ -432,9 +432,9 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game static int LastNum6 = 1; - if (Globals::AmountOfListens != LastNum6) + if (AmountOfRestarts != LastNum6) { - LastNum6 = Globals::AmountOfListens; + LastNum6 = AmountOfRestarts; if (Globals::bGoingToPlayEvent && DoesEventRequireLoading()) { @@ -448,9 +448,9 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game static int LastNum5 = 1; - if (Globals::AmountOfListens != LastNum5 && LastNum6 == Globals::AmountOfListens) // Make sure we loaded the event. + if (AmountOfRestarts != LastNum5 && LastNum6 == AmountOfRestarts) // Make sure we loaded the event. { - LastNum5 = Globals::AmountOfListens; + LastNum5 = AmountOfRestarts; if (Globals::bGoingToPlayEvent) { @@ -475,13 +475,6 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game return false; } - static int LastNum9 = 1; - - if (Globals::AmountOfListens != LastNum9) - { - LastNum9 = Globals::AmountOfListens; - } - auto MapInfo = GameState->GetMapInfo(); if (!MapInfo && Engine_Version >= 421) @@ -489,9 +482,9 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game static int LastNum = 1; - if (Globals::AmountOfListens != LastNum) + if (AmountOfRestarts != LastNum) { - LastNum = Globals::AmountOfListens; + LastNum = AmountOfRestarts; float Duration = 10000.f; float EarlyDuration = Duration; @@ -552,9 +545,10 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game static int LastNum3 = 1; - if (Globals::AmountOfListens != LastNum3) + if (AmountOfRestarts != LastNum3) { - LastNum3 = ++Globals::AmountOfListens; + LastNum3 = AmountOfRestarts; + ++Globals::AmountOfListens; LOG_INFO(LogNet, "Attempting to listen!"); @@ -580,8 +574,6 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game } } - LoopMutators([&](AFortAthenaMutator* Mutator) { LOG_INFO(LogGame, "Mutator {}", Mutator->GetPathName()); }); - Globals::bStartedListening = true; } @@ -613,17 +605,10 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game { // We are assuming it successfully became warmup. - static auto mutatorClass = FindObject("/Script/FortniteGame.FortAthenaMutator"); - auto AllMutators = UGameplayStatics::GetAllActorsOfClass(GetWorld(), mutatorClass); - std::vector> FunctionsToCall; - for (int i = 0; i < AllMutators.Num(); i++) - { - auto Mutator = (AFortAthenaMutator*)AllMutators.at(i); - - FunctionsToCall.push_back(std::make_pair(Mutator, Mutator->FindFunction("OnGamePhaseStepChanged"))); - } + LoopMutators([&](AFortAthenaMutator* Mutator) { LOG_INFO(LogGame, "Mutator {}", Mutator->GetPathName()); }); + LoopMutators([&](AFortAthenaMutator* Mutator) { FunctionsToCall.push_back(std::make_pair(Mutator, Mutator->FindFunction("OnGamePhaseStepChanged"))); }); static int LastNum1 = 3125; @@ -650,9 +635,6 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game FunctionToCallPair.first->ProcessEvent(FunctionToCallPair.second, a); FunctionToCallPair.first->ProcessEvent(FunctionToCallPair.second, ConstructOnGamePhaseStepChangedParams(EAthenaGamePhaseStep::Setup)); FunctionToCallPair.first->ProcessEvent(FunctionToCallPair.second, ConstructOnGamePhaseStepChangedParams(EAthenaGamePhaseStep::Warmup)); - // FunctionToCallPair.first->ProcessEvent(FunctionToCallPair.second, &StormFormingGamePhaseStep); - // FunctionToCallPair.first->ProcessEvent(FunctionToCallPair.second, &StormHoldingGamePhaseStep); - // FunctionToCallPair.first->ProcessEvent(FunctionToCallPair.second, &StormShrinkingGamePhaseStep); } } } @@ -1008,34 +990,14 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena LOG_INFO(LogDev, "Old ID: {}", PlayerStateAthena->GetWorldPlayerId()); LOG_INFO(LogDev, "PlayerID: {}", PlayerStateAthena->GetPlayerID()); - // if (PlayerStateAthena->GetWorldPlayerId() == -1) + PlayerStateAthena->GetWorldPlayerId() = PlayerStateAthena->GetPlayerID(); + + auto PlayerAbilitySet = GetPlayerAbilitySet(); + auto AbilitySystemComponent = PlayerStateAthena->GetAbilitySystemComponent(); + + if (PlayerAbilitySet) { - static int CurrentPlayerId = 1; - // static auto PlayerIdOffset = PlayerStateAthena->GetOffset("PlayerId"); // Unable to find tf - PlayerStateAthena->GetWorldPlayerId() = PlayerStateAthena->GetPlayerID(); // ++CurrentPlayerId; // PlayerStateAthena->Get(PlayerIdOffset); // - } - - { - static auto GameplayAbilitySet = (UFortAbilitySet*)(Fortnite_Version >= 8.30 ? // LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer") ? - LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer", UFortAbilitySet::StaticClass()) : - LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_DefaultPlayer.GAS_DefaultPlayer", UFortAbilitySet::StaticClass())); - - LOG_INFO(LogDev, "GameplayAbilitySet {}", __int64(GameplayAbilitySet)); - - auto AbilitySystemComponent = PlayerStateAthena->GetAbilitySystemComponent(); - - if (GameplayAbilitySet) - { - LOG_INFO(LogDev, "GameplayAbilitySet Name {}", GameplayAbilitySet->GetName()); - GameplayAbilitySet->GiveToAbilitySystem(AbilitySystemComponent); - } - - GET_PLAYLIST(GameState); - - if (CurrentPlaylist) - { - // CurrentPlaylist->ApplyModifiersToActor(PlayerStateAthena); // scuffed we need to do as pawn spawns - } + PlayerAbilitySet->GiveToAbilitySystem(AbilitySystemComponent); } struct FUniqueNetIdReplExperimental diff --git a/Project Reboot 3.0/FortGameModeAthena.h b/Project Reboot 3.0/FortGameModeAthena.h index fc9c48e..98ab025 100644 --- a/Project Reboot 3.0/FortGameModeAthena.h +++ b/Project Reboot 3.0/FortGameModeAthena.h @@ -7,6 +7,7 @@ #include "BuildingSMActor.h" #include "FortSafeZoneIndicator.h" #include "GameplayStatics.h" +#include "FortAbilitySet.h" #include "FortItemDefinition.h" struct FAircraftFlightInfo @@ -77,6 +78,17 @@ static void SetFoundationTransform(AActor* BuildingFoundation, const FTransform& } } +static inline UFortAbilitySet* GetPlayerAbilitySet() +{ + // There are some variables that contain this but it changes through versions soo.. + + static auto GameplayAbilitySet = (UFortAbilitySet*)(Fortnite_Version >= 8.30 + ? LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_AthenaPlayer.GAS_AthenaPlayer", UFortAbilitySet::StaticClass()) + : LoadObject(L"/Game/Abilities/Player/Generic/Traits/DefaultPlayer/GAS_DefaultPlayer.GAS_DefaultPlayer", UFortAbilitySet::StaticClass())); + + return GameplayAbilitySet; +} + static void ShowFoundation(AActor* BuildingFoundation, bool bShow = true) { if (!BuildingFoundation) diff --git a/Project Reboot 3.0/FortInventory.cpp b/Project Reboot 3.0/FortInventory.cpp index 7d4fde3..37a5214 100644 --- a/Project Reboot 3.0/FortInventory.cpp +++ b/Project Reboot 3.0/FortInventory.cpp @@ -119,24 +119,7 @@ std::pair, std::vector> AFortInventory::AddI if (NewItemInstance) { - auto OldItemGuid = NewItemInstance->GetItemEntry()->GetItemGuid(); - - if (false) - { - CopyStruct(NewItemInstance->GetItemEntry(), ItemEntry, FFortItemEntry::GetStructSize(), FFortItemEntry::GetStruct()); - } - else - { - NewItemInstance->GetItemEntry()->GetItemDefinition() = ItemEntry->GetItemDefinition(); - NewItemInstance->GetItemEntry()->GetCount() = ItemEntry->GetCount(); - NewItemInstance->GetItemEntry()->GetLoadedAmmo() = ItemEntry->GetLoadedAmmo(); - } - - NewItemInstance->GetItemEntry()->GetItemGuid() = OldItemGuid; - - NewItemInstance->GetItemEntry()->MostRecentArrayReplicationKey = -1; - NewItemInstance->GetItemEntry()->ReplicationID = -1; - NewItemInstance->GetItemEntry()->ReplicationKey = -1; + NewItemInstance->GetItemEntry()->CopyFromAnotherItemEntry(ItemEntry); if (OverrideCount != -1) NewItemInstance->GetItemEntry()->GetCount() = OverrideCount; @@ -414,6 +397,44 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int return true; } +void AFortInventory::SwapItem(const FGuid& ItemGuid, FFortItemEntry* NewItemEntry, int OverrideNewCount, std::pair* outEntries) +{ + auto NewCount = OverrideNewCount == -1 ? NewItemEntry->GetCount() : OverrideNewCount; + + auto ItemInstance = FindItemInstance(ItemGuid); + + if (!ItemInstance) + return; + + /* RemoveItem(ItemGuid, nullptr, ItemInstance->GetItemEntry()->GetCount(), true); + AddItem(NewItemEntry, nullptr, false, OverrideNewCount); + + return; */ + + // IDK WHY THIS DOESNT WORK + + static auto FortItemEntrySize = FFortItemEntry::GetStructSize(); + + auto& ReplicatedEntries = GetItemList().GetReplicatedEntries(); + + for (int i = 0; i < ReplicatedEntries.Num(); i++) + { + auto& ReplicatedEntry = ReplicatedEntries.At(i, FortItemEntrySize); + + if (ReplicatedEntry.GetItemGuid() == ItemGuid) + { + ReplicatedEntry.CopyFromAnotherItemEntry(NewItemEntry); + ItemInstance->GetItemEntry()->CopyFromAnotherItemEntry(NewItemEntry); + + ReplicatedEntry.GetCount() = NewCount; + ItemInstance->GetItemEntry()->GetCount() = NewCount; + + if (outEntries) + *outEntries = std::make_pair(ItemInstance->GetItemEntry(), &ReplicatedEntry); + } + } +} + void AFortInventory::ModifyCount(UFortItem* ItemInstance, int New, bool bRemove, std::pair* outEntries, bool bUpdate, bool bShowItemToast) { auto ReplicatedEntry = FindReplicatedEntry(ItemInstance->GetItemEntry()->GetItemGuid()); @@ -529,8 +550,7 @@ UFortItem* AFortInventory::FindItemInstance(const FGuid& Guid) FFortItemEntry* AFortInventory::FindReplicatedEntry(const FGuid& Guid) { - static auto FortItemEntryStruct = FindObject(L"/Script/FortniteGame.FortItemEntry"); - static auto FortItemEntrySize = FortItemEntryStruct->GetPropertiesSize(); + static auto FortItemEntrySize = FFortItemEntry::GetStructSize(); auto& ReplicatedEntries = GetItemList().GetReplicatedEntries(); diff --git a/Project Reboot 3.0/FortInventory.h b/Project Reboot 3.0/FortInventory.h index 55491de..ebc1f92 100644 --- a/Project Reboot 3.0/FortInventory.h +++ b/Project Reboot 3.0/FortInventory.h @@ -100,6 +100,7 @@ public: std::pair, std::vector> AddItem(FFortItemEntry* ItemEntry, bool* bShouldUpdate, bool bShowItemToast = false, int OverrideCount = -1); std::pair, std::vector> AddItem(UFortItemDefinition* ItemDefinition, bool* bShouldUpdate, int Count = 1, int LoadedAmmo = -1, bool bShowItemToast = false); bool RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int Count, bool bForceRemoval = false); + void SwapItem(const FGuid& ItemGuid, FFortItemEntry* NewItemEntry, int OverrideNewCount = -1, std::pair* outEntries = nullptr); void ModifyCount(UFortItem* ItemInstance, int New, bool bRemove = false, std::pair* outEntries = nullptr, bool bUpdate = true, bool bShowItemToast = false); UFortItem* GetPickaxeInstance(); diff --git a/Project Reboot 3.0/FortItem.h b/Project Reboot 3.0/FortItem.h index 1ac7a2e..54b4589 100644 --- a/Project Reboot 3.0/FortItem.h +++ b/Project Reboot 3.0/FortItem.h @@ -83,6 +83,12 @@ struct FFortItemEntry : FFastArraySerializerItem return *(int*)(__int64(this) + CountOffset); } + int& GetLevel() + { + static auto LevelOffset = FindOffsetStruct("/Script/FortniteGame.FortItemEntry", "Level"); + return *(int*)(__int64(this) + LevelOffset); + } + TArray& GetStateValues() { static auto StateValuesOffset = FindOffsetStruct("/Script/FortniteGame.FortItemEntry", "StateValues"); @@ -97,7 +103,7 @@ struct FFortItemEntry : FFastArraySerializerItem void CopyFromAnotherItemEntry(FFortItemEntry* OtherItemEntry, bool bCopyGuid = false) { - auto OldGuid = this->GetItemGuid(); + FGuid OldGuid = this->GetItemGuid(); if (false) { @@ -109,10 +115,17 @@ struct FFortItemEntry : FFastArraySerializerItem this->GetCount() = OtherItemEntry->GetCount(); this->GetLoadedAmmo() = OtherItemEntry->GetLoadedAmmo(); this->GetItemGuid() = OtherItemEntry->GetItemGuid(); + this->GetLevel() = OtherItemEntry->GetLevel(); } if (!bCopyGuid) this->GetItemGuid() = OldGuid; + + // should we do this? + + this->MostRecentArrayReplicationKey = -1; + this->ReplicationID = -1; + this->ReplicationKey = -1; } static UStruct* GetStruct() diff --git a/Project Reboot 3.0/FortLootPackage.cpp b/Project Reboot 3.0/FortLootPackage.cpp index 2fb6523..0857482 100644 --- a/Project Reboot 3.0/FortLootPackage.cpp +++ b/Project Reboot 3.0/FortLootPackage.cpp @@ -190,7 +190,7 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs { auto& Tag = GameplayTagContainer->GameplayTags.At(i); - for (auto Value : PlaylistOverrideLootTableData) + for (auto& Value : PlaylistOverrideLootTableData) { auto CurrentOverrideTag = Value.First; @@ -504,7 +504,7 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs auto ChosenLootPackageName = ChosenRowLootTierData->GetLootPackage().ToString(); - if (ChosenLootPackageName.contains(".Empty")) + if (ChosenLootPackageName.contains(".Empty")) // I don't think? { return PickLootDrops(TierGroupName, bPrint); // return LootDrops; @@ -581,6 +581,11 @@ std::vector PickLootDrops(FName TierGroupName, bool bPrint, int recurs { lootPackageCallsTotalWeight += CurrentLP->GetWeight(); lootPackageCalls.push_back(CurrentLP); + + if (bPrint) + { + LOG_INFO(LogDev, "Adding LootPackage: {}", CurrentLP->GetAnnotation().ToString()); + } } } } diff --git a/Project Reboot 3.0/FortLootPackage.h b/Project Reboot 3.0/FortLootPackage.h index 2057236..977c7f7 100644 --- a/Project Reboot 3.0/FortLootPackage.h +++ b/Project Reboot 3.0/FortLootPackage.h @@ -45,6 +45,12 @@ public: static auto CountOffset = FindOffsetStruct("/Script/FortniteGame.FortLootPackageData", "Count"); return *(int*)(__int64(this) + CountOffset); } + + FString& GetAnnotation() + { + static auto AnnotationOffset = FindOffsetStruct("/Script/FortniteGame.FortLootPackageData", "Annotation"); + return *(FString*)(__int64(this) + AnnotationOffset); + } }; struct FFortLootTierData diff --git a/Project Reboot 3.0/FortPawn.cpp b/Project Reboot 3.0/FortPawn.cpp index 15ecafc..579caa5 100644 --- a/Project Reboot 3.0/FortPawn.cpp +++ b/Project Reboot 3.0/FortPawn.cpp @@ -9,22 +9,21 @@ AFortWeapon* AFortPawn::EquipWeaponDefinition(UFortWeaponItemDefinition* WeaponD FGuid TrackerGuid{}; - struct { UObject* Def; FGuid Guid; AFortWeapon* Wep; } params{ WeaponData, ItemEntryGuid }; - struct { UObject* Def; FGuid Guid; FGuid TrackerGuid; AFortWeapon* Wep; } S16_params{ WeaponData, ItemEntryGuid, TrackerGuid }; - struct { UObject* Def; FGuid Guid; FGuid TrackerGuid; bool bDisableEquipAnimation; AFortWeapon* Wep; } S17_params{ WeaponData, ItemEntryGuid, TrackerGuid, false }; - if (Fortnite_Version < 16) { + struct { UObject* Def; FGuid Guid; AFortWeapon* Wep; } params{ WeaponData, ItemEntryGuid }; this->ProcessEvent(EquipWeaponDefinitionFn, ¶ms); return params.Wep; } else if (std::floor(Fortnite_Version) == 16) { + struct { UObject* Def; FGuid Guid; FGuid TrackerGuid; AFortWeapon* Wep; } S16_params{ WeaponData, ItemEntryGuid, TrackerGuid }; this->ProcessEvent(EquipWeaponDefinitionFn, &S16_params); return S16_params.Wep; } else { + struct { UObject* Def; FGuid Guid; FGuid TrackerGuid; bool bDisableEquipAnimation; AFortWeapon* Wep; } S17_params{ WeaponData, ItemEntryGuid, TrackerGuid, false }; this->ProcessEvent(EquipWeaponDefinitionFn, &S17_params); return S17_params.Wep; } diff --git a/Project Reboot 3.0/FortPickup.cpp b/Project Reboot 3.0/FortPickup.cpp index 4d33245..3d16302 100644 --- a/Project Reboot 3.0/FortPickup.cpp +++ b/Project Reboot 3.0/FortPickup.cpp @@ -189,6 +189,7 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup) FGuid NewSwappedItem = FGuid(-1, -1, -1, -1); + bool bForceDontAddItem = false; bool bForceOverflow = false; while (cpyCount > 0) @@ -214,9 +215,12 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup) bIsInventoryFull = (PrimarySlotsFilled /* - 6 */) >= 5; - if (bIsInventoryFull) // probs shouldnt do in loop but alr + if (bIsInventoryFull || (PlayerController->HasTryPickupSwap() ? PlayerController->ShouldTryPickupSwap() : false)) // probs shouldnt do in loop but alr { - if (ItemInstanceToSwap && ItemDefinitionToSwap->CanBeDropped() && !bHasSwapped) // swap + if (PlayerController->HasTryPickupSwap()) + PlayerController->ShouldTryPickupSwap() = false; + + if (ItemInstanceToSwap && ItemDefinitionToSwap->CanBeDropped() && !bHasSwapped && ItemDefGoingInPrimary) // swap { auto SwappedPickup = SpawnPickup(ItemEntryToSwap, PawnLoc, EFortPickupSourceTypeFlag::Player, EFortPickupSpawnSource::Unset, Pawn); @@ -228,13 +232,27 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup) bWasHoldingSameItemWhenSwap = CurrentWeapon->GetItemEntryGuid() == ItemInstanceToSwap->GetItemEntry()->GetItemGuid(); } + // THIS IS NOT PROPER! We should use the commented code but there are some bugs idk why. + WorldInventory->RemoveItem(CurrentItemGuid, nullptr, ItemEntryToSwap->GetCount(), true); + /* + auto NewItemCount = cpyCount > PickupItemDefinition->GetMaxStackSize() ? PickupItemDefinition->GetMaxStackSize() : cpyCount; + + std::pair Pairs; + WorldInventory->SwapItem(CurrentItemGuid, PickupEntry, cpyCount, &Pairs); + PairsToMarkDirty.push_back(Pairs); + + cpyCount -= NewItemCount; + */ + bHasSwapped = true; if constexpr (bTestPrinting) LOG_INFO(LogDev, "[{}] Swapping: {}", i, ItemDefinitionToSwap->GetFullName()); + // bForceDontAddItem = true; + continue; // ??? } } @@ -287,7 +305,7 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup) break; } - if (cpyCount > 0 && !bIsInventoryFull) + if (cpyCount > 0 && !bIsInventoryFull && !bForceDontAddItem) { if constexpr (bTestPrinting) LOG_INFO(LogDev, "Attempting to add to inventory."); diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 1bf4412..9bef356 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -885,7 +885,7 @@ void AFortPlayerController::DropSpecificItemHook(UObject* Context, FFrame& Stack void AFortPlayerController::ServerAttemptInventoryDropHook(AFortPlayerController* PlayerController, FGuid ItemGuid, int Count) { - LOG_INFO(LogDev, "ServerAttemptInventoryDropHook!"); + LOG_INFO(LogDev, "ServerAttemptInventoryDropHook Dropping: {}", Count); auto Pawn = PlayerController->GetMyFortPawn(); @@ -895,7 +895,7 @@ void AFortPlayerController::ServerAttemptInventoryDropHook(AFortPlayerController auto WorldInventory = PlayerController->GetWorldInventory(); auto ReplicatedEntry = WorldInventory->FindReplicatedEntry(ItemGuid); - if (!ReplicatedEntry) + if (!ReplicatedEntry || ReplicatedEntry->GetCount() < Count) return; auto ItemDefinition = Cast(ReplicatedEntry->GetItemDefinition()); @@ -908,7 +908,7 @@ void AFortPlayerController::ServerAttemptInventoryDropHook(AFortPlayerController if (!ItemDefinition->ShouldIgnoreRespawningOnDrop() && (DropBehaviorOffset != -1 ? ItemDefinition->GetDropBehavior() != EWorldItemDropBehavior::DestroyOnDrop : true)) { auto Pickup = AFortPickup::SpawnPickup(ReplicatedEntry, Pawn->GetActorLocation(), - EFortPickupSourceTypeFlag::Player, EFortPickupSpawnSource::Unset, Pawn); + EFortPickupSourceTypeFlag::Player, EFortPickupSpawnSource::Unset, Pawn, nullptr, true, Count); if (!Pickup) return; diff --git a/Project Reboot 3.0/FortPlayerController.h b/Project Reboot 3.0/FortPlayerController.h index 97739f1..5d8faf0 100644 --- a/Project Reboot 3.0/FortPlayerController.h +++ b/Project Reboot 3.0/FortPlayerController.h @@ -87,6 +87,18 @@ public: return CosmeticLoadout; } + bool& ShouldTryPickupSwap() + { + static auto bTryPickupSwapOffset = GetOffset("bTryPickupSwap"); + return Get(bTryPickupSwapOffset); + } + + bool HasTryPickupSwap() + { + static auto bTryPickupSwapOffset = GetOffset("bTryPickupSwap"); + return bTryPickupSwapOffset != -1; + } + bool DoesBuildFree(); void DropAllItems(const std::vector& IgnoreItemDefs, bool bIgnoreSecondaryQuickbar = false, bool bRemoveIfNotDroppable = false); void ApplyCosmeticLoadout(); diff --git a/Project Reboot 3.0/FortPlayerPawn.cpp b/Project Reboot 3.0/FortPlayerPawn.cpp index 78e3d85..1a3ffea 100644 --- a/Project Reboot 3.0/FortPlayerPawn.cpp +++ b/Project Reboot 3.0/FortPlayerPawn.cpp @@ -13,6 +13,59 @@ FFortAthenaLoadout* AFortPlayerPawn::GetCosmeticLoadout() return GetPtr(CosmeticLoadoutOffset); } +void AFortPlayerPawn::ServerHandlePickupWithRequestedSwapHook(UObject* Context, FFrame* Stack, void* Ret) +{ + auto Pawn = (AFortPlayerPawn*)Context; + auto Controller = Cast(Pawn->GetController()); + + if (!Controller) + return ServerHandlePickupWithRequestedSwapOriginal(Context, Stack, Ret); + + auto Params = Stack->Locals; + + static auto PickupOffset = FindOffsetStruct("/Script/FortniteGame.FortPlayerPawn.ServerHandlePickupWithRequestedSwap", "Pickup"); + static auto SwapOffset = FindOffsetStruct("/Script/FortniteGame.FortPlayerPawn.ServerHandlePickupWithRequestedSwap", "Swap"); + + auto Pickup = *(AFortPickup**)(__int64(Params) + PickupOffset); + auto& Swap = *(FGuid*)(__int64(Params) + SwapOffset); + + // LOG_INFO(LogDev, "Pickup: {}", Pickup->IsValidLowLevel() ? Pickup->GetFullName() : "BadRead"); + + if (!Pickup) + return ServerHandlePickupWithRequestedSwapOriginal(Context, Stack, Ret); + + static auto bPickedUpOffset = Pickup->GetOffset("bPickedUp"); + + if (Pickup->Get(bPickedUpOffset)) + { + LOG_INFO(LogDev, "Trying to pickup picked up weapon (Swap)?"); + return ServerHandlePickupWithRequestedSwapOriginal(Context, Stack, Ret); + } + + static auto IncomingPickupsOffset = Pawn->GetOffset("IncomingPickups"); + Pawn->Get>(IncomingPickupsOffset).Add(Pickup); + + auto PickupLocationData = Pickup->GetPickupLocationData(); + + PickupLocationData->GetPickupTarget() = Pawn; + PickupLocationData->GetFlyTime() = 0.40f; + PickupLocationData->GetItemOwner() = Pawn; + // PickupLocationData->GetStartDirection() = InStartDirection; + PickupLocationData->GetPickupGuid() = Swap; + + Controller->ShouldTryPickupSwap() = true; + + static auto OnRep_PickupLocationDataFn = FindObject(L"/Script/FortniteGame.FortPickup.OnRep_PickupLocationData"); + Pickup->ProcessEvent(OnRep_PickupLocationDataFn); + + Pickup->Get(bPickedUpOffset) = true; + + static auto OnRep_bPickedUpFn = FindObject(L"/Script/FortniteGame.FortPickup.OnRep_bPickedUp"); + Pickup->ProcessEvent(OnRep_bPickedUpFn); + + return ServerHandlePickupWithRequestedSwapOriginal(Context, Stack, Ret); +} + void AFortPlayerPawn::ServerChoosePart(EFortCustomPartType Part, UObject* ChosenCharacterPart) { static auto fn = FindObject("/Script/FortniteGame.FortPlayerPawn.ServerChoosePart"); diff --git a/Project Reboot 3.0/FortPlayerPawn.h b/Project Reboot 3.0/FortPlayerPawn.h index 567be0b..5346c4c 100644 --- a/Project Reboot 3.0/FortPlayerPawn.h +++ b/Project Reboot 3.0/FortPlayerPawn.h @@ -33,6 +33,7 @@ class AFortPlayerPawn : public AFortPawn public: static inline AActor* (*ServerOnExitVehicleOriginal)(AFortPlayerPawn* Pawn, ETryExitVehicleBehavior ExitForceBehavior); // actually returns AFortAthenaVehicle static inline void (*StartGhostModeExitOriginal)(UObject* Context, FFrame* Stack, void* Ret); + static inline void (*ServerHandlePickupWithRequestedSwapOriginal)(UObject* Context, FFrame* Stack, void* Ret); struct FFortAthenaLoadout* GetCosmeticLoadout(); void ServerChoosePart(EFortCustomPartType Part, class UObject* ChosenCharacterPart); @@ -43,6 +44,7 @@ public: UFortWeaponItemDefinition* GetVehicleWeaponDefinition(AFortAthenaVehicle* Vehicle); void UnEquipVehicleWeaponDefinition(UFortWeaponItemDefinition* VehicleWeaponDefinition); + static void ServerHandlePickupWithRequestedSwapHook(UObject* Context, FFrame* Stack, void* Ret); // we could native hook this but idk static void StartGhostModeExitHook(UObject* Context, FFrame* Stack, void* Ret); // we could native hook this but eh static AActor* ServerOnExitVehicleHook(AFortPlayerPawn* Pawn, ETryExitVehicleBehavior ExitForceBehavior); // actually returns AFortAthenaVehicle static void ServerSendZiplineStateHook(AFortPlayerPawn* Pawn, FZiplinePawnState InZiplineState); diff --git a/Project Reboot 3.0/GameModeBase.cpp b/Project Reboot 3.0/GameModeBase.cpp index c8e5fe8..83a7d28 100644 --- a/Project Reboot 3.0/GameModeBase.cpp +++ b/Project Reboot 3.0/GameModeBase.cpp @@ -72,11 +72,20 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll if (!PlayerStateAthena) return nullptr; + auto ASC = PlayerStateAthena->GetAbilitySystemComponent(); + GET_PLAYLIST(GameState); - if (CurrentPlaylist) + if (CurrentPlaylist) // Apply gameplay effects from playlist // We need to move this! { - CurrentPlaylist->ApplyModifiersToActor(PlayerStateAthena); // We need to move this! + CurrentPlaylist->ApplyModifiersToActor(PlayerStateAthena); + } + + auto PlayerAbilitySet = GetPlayerAbilitySet(); // Apply default gameplay effects // We need to move maybe? + + if (PlayerAbilitySet && ASC) + { + PlayerAbilitySet->ApplyGrantedGameplayAffectsToAbilitySystem(ASC); } if (NewPlayerAsAthena) @@ -91,10 +100,8 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll // TODO Check Playlist->bRequirePickaxeInStartingInventory auto CosmeticLoadout = NewPlayerAsAthena->GetCosmeticLoadoutOffset() != -1 ? NewPlayerAsAthena->GetCosmeticLoadout() : nullptr; - // LOG_INFO(LogDev, "CosmeticLoadout: {}", __int64(CosmeticLoadout)); auto CosmeticLoadoutPickaxe = CosmeticLoadout ? CosmeticLoadout->GetPickaxe() : nullptr; - // LOG_INFO(LogDev, "CosmeticLoadoutPickaxe: {}", __int64(CosmeticLoadoutPickaxe)); - // LOG_INFO(LogDev, "CosmeticLoadoutPickaxe Name: {}", CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->GetFullName() : "InvalidObject"); + static auto WeaponDefinitionOffset = FindOffsetStruct("/Script/FortniteGame.AthenaPickaxeItemDefinition", "WeaponDefinition", false); auto PickaxeDefinition = CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->Get(WeaponDefinitionOffset) @@ -114,10 +121,6 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll WorldInventory->AddItem(BuildingItemData_Floor, nullptr); WorldInventory->AddItem(BuildingItemData_Stair_W, nullptr); WorldInventory->AddItem(BuildingItemData_RoofS, 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->AddItem(FindObject(L"/Game/Athena/Items/Consumables/HappyGhost/WID_Athena_HappyGhost.WID_Athena_HappyGhost"), nullptr); /* if (Globals::bLateGame) { diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj b/Project Reboot 3.0/Project Reboot 3.0.vcxproj index 2e6fbac..52fb3af 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj @@ -198,6 +198,7 @@ + @@ -315,6 +316,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 d7ad13d..b29bc1f 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -259,6 +259,9 @@ Engine\Source\Runtime\CoreUObject\Private + + FortniteGame\Source\FortniteGame\Private\Vehicles + @@ -826,6 +829,9 @@ Engine\Source\Runtime\Core\Public\Misc + + FortniteGame\Source\FortniteGame\Public\Athena\Vehicle + diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index 540a13a..b43528d 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -40,6 +40,7 @@ #include "FortAthenaMutator_Barrier.h" #include "PlaysetLevelStreamComponent.h" +#include "FortAthenaVehicleSpawner.h" enum ENetMode { @@ -636,6 +637,9 @@ DWORD WINAPI Main(LPVOID) Hooking::MinHook::Hook(InventoryManagementLibraryDefault, FindObject(L"/Script/FortniteGame.InventoryManagementLibrary.SwapItems"), UInventoryManagementLibrary::SwapItemsHook, (PVOID*)&UInventoryManagementLibrary::SwapItemsOriginal, false, true); + Hooking::MinHook::Hook(FindObject("/Script/FortniteGame.Default__FortAthenaVehicleSpawner"), FindObject(L"/Script/FortniteGame.FortAthenaVehicleSpawner.SpawnVehicle"), + AFortAthenaVehicleSpawner::SpawnVehicleHook, nullptr, false); + static auto ServerHandlePickupInfoFn = FindObject(L"/Script/FortniteGame.FortPlayerPawn.ServerHandlePickupInfo"); if (ServerHandlePickupInfoFn) @@ -646,6 +650,8 @@ DWORD WINAPI Main(LPVOID) { Hooking::MinHook::Hook(FortPlayerPawnAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerPawn.ServerHandlePickup"), AFortPlayerPawn::ServerHandlePickupHook, nullptr, false); + Hooking::MinHook::Hook(FortPlayerPawnAthenaDefault, FindObject(L"/Script/FortniteGame.FortPlayerPawn.ServerHandlePickupWithRequestedSwap"), + AFortPlayerPawn::ServerHandlePickupWithRequestedSwapHook, (PVOID*)&AFortPlayerPawn::ServerHandlePickupWithRequestedSwapOriginal, false, true); } static auto PredictionKeyStruct = FindObject(L"/Script/GameplayAbilities.PredictionKey"); @@ -712,11 +718,18 @@ DWORD WINAPI Main(LPVOID) Hooking::MinHook::Hook((PVOID)Addresses::CompletePickupAnimation, (PVOID)AFortPickup::CompletePickupAnimationHook, (PVOID*)&AFortPickup::CompletePickupAnimationOriginal); Hooking::MinHook::Hook((PVOID)Addresses::CanActivateAbility, ReturnTrueHook); // ahhh wtf - // if (Fortnite_Version >= 2.5) - if (Engine_Version >= 419) + uint64 ServerRemoveInventoryItemFunctionCallBeginFunctionAddr = 0; + + if (Engine_Version >= 419) // Dude idk why but its getting the second ref kms { - auto ServerRemoveInventoryItemFunctionCallRef = Memcury::Scanner::FindPointerRef((PVOID)FindFunctionCall(L"ServerRemoveInventoryItem", - Fortnite_Version >= 16 ? std::vector{ 0x48, 0x8B, 0xC4 } : std::vector{ 0x48, 0x89, 0x5C }), 0, true); + std::vector ServerRemoveInventoryItemCallFunctionStarts = Engine_Version == 416 + ? std::vector{ 0x44, 0x88, 0x4C } + : Fortnite_Version >= 16 + ? std::vector{ 0x48, 0x8B, 0xC4 } + : std::vector{ 0x48, 0x89, 0x5C }; + + auto ServerRemoveInventoryItemCallFunctionCall = FindFunctionCall(L"ServerRemoveInventoryItem", ServerRemoveInventoryItemCallFunctionStarts); + auto ServerRemoveInventoryItemFunctionCallRef = Memcury::Scanner::FindPointerRef((PVOID)ServerRemoveInventoryItemCallFunctionCall, true); LOG_INFO(LogDev, "ServerRemoveInventoryItemFunctionCallRef: 0x{:x}", ServerRemoveInventoryItemFunctionCallRef.Get() - __int64(GetModuleHandleW(0))); @@ -736,12 +749,13 @@ DWORD WINAPI Main(LPVOID) break; } } - - Hooking::MinHook::Hook( - Memcury::Scanner(ServerRemoveInventoryItemFunctionCallBeginFunctionAddr).GetAs(), - UFortInventoryInterface::RemoveInventoryItemHook - ); } + else + { + + } + + Hooking::MinHook::Hook(Memcury::Scanner(ServerRemoveInventoryItemFunctionCallBeginFunctionAddr).GetAs(), UFortInventoryInterface::RemoveInventoryItemHook); // if (Fortnite_Version >= 13) Hooking::MinHook::Hook((PVOID)Addresses::SetZoneToIndex, (PVOID)SetZoneToIndexHook, (PVOID*)&SetZoneToIndexOriginal); @@ -799,9 +813,16 @@ DWORD WINAPI Main(LPVOID) LOG_INFO(LogHook, "Finished!"); - while (true) + if (false) { - Sleep(10000); + while (true) + { + Sleep(10000); + } + } + else + { + Sleep(-1); } return 0; diff --git a/Project Reboot 3.0/finder.h b/Project Reboot 3.0/finder.h index da9b96b..e1645f2 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -223,7 +223,7 @@ static inline uint64 FindInitHost() { if (Engine_Version == 427) // idk im dumb { - auto addr = Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 55 57 41 56 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B F1 4C 8D 05").Get(); + auto addr = Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 55 57 41 56 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B F1 4C 8D 05", false).Get(); if (!addr) // s18 addr = Memcury::Scanner::FindPattern("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 56 41 57 48 8D 68 A1 48 81 EC ? ? ? ? 48 8B F1 4C 8D 35 ? ? ? ? 4D").Get(); @@ -664,7 +664,7 @@ static inline uint64 FindSetZoneToIndex() // actually StartNewSafeZonePhase if (Engine_Version == 422) return Memcury::Scanner::FindPattern("E9 ? ? ? ? 48 8B C1 40 38 B9").RelativeOffset(1).Get(); // 7.40 - auto Addr = Memcury::Scanner::FindStringRef(L"FortGameModeAthena: No MegaStorm on SafeZone[%d]. GridCellThickness is less than 1.0.", true, 0, Fortnite_Version >= 16).Get(); + auto Addr = Memcury::Scanner::FindStringRef(L"FortGameModeAthena: No MegaStorm on SafeZone[%d]. GridCellThickness is less than 1.0.", true, 0, Engine_Version >= 427).Get(); // return FindBytes(Addr, { 0x40, 0x55 }, 30000, 0, true); if (!Addr) @@ -859,7 +859,9 @@ static inline uint64 FindActorGetNetMode() // return 0; if (Engine_Version == 500) + { return Memcury::Scanner::FindPattern("48 89 5C 24 ? 57 48 83 EC 20 F6 41 08 10 48 8B D9 0F 85 ? ? ? ? 48 8B 41 20 48 85 C0 0F 84 ? ? ? ? F7 40").Get(); + } if (Engine_Version == 427) { @@ -1132,10 +1134,7 @@ static inline uint64 FindChangeGameSessionId() if (Engine_Version >= 427) { - if (Fortnite_Version < 18) - return Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 70 4C 8B FA 4C").Get(); - else - return Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 70 4C 8B FA 4C").Get(); + return Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 70 4C 8B FA 4C").Get(); // no work on s18 } if (Fortnite_Version == 2.5) diff --git a/Project Reboot 3.0/vehicles.h b/Project Reboot 3.0/vehicles.h index 951b947..fed8ba1 100644 --- a/Project Reboot 3.0/vehicles.h +++ b/Project Reboot 3.0/vehicles.h @@ -5,6 +5,8 @@ #include "Actor.h" #include "hooking.h" #include "SoftObjectPtr.h" +#include "FortGameModeAthena.h" +#include "GameplayStatics.h" // Vehicle class name changes multiple times across versions, so I made it it's own file. @@ -188,107 +190,5 @@ static inline void SpawnVehicles2() auto Vehicle = SpawnVehicleFromSpawner(VehicleSpawner); } - AllVehicleSpawners.Free(); -} - -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", false); - - bool aa = true; - - static auto VIDClass = FindObject("/Script/FortniteGame.FortVehicleItemDefinition"); - - if (FortVehicleItemDefVariantsOffset != -1) - { - 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"); - - if (FortVehicleItemDefOffset == -1) - { - - } - - 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