From a0f427b491606da497b8ce222b696d1c1ab8bd5e Mon Sep 17 00:00:00 2001 From: Milxnor Date: Sun, 21 May 2023 10:54:43 -0400 Subject: [PATCH] fix looting bug --- Project Reboot 3.0/BuildingContainer.cpp | 11 +++++++++++ Project Reboot 3.0/BuildingContainer.h | 6 ++++++ Project Reboot 3.0/FortGameModeAthena.cpp | 2 +- Project Reboot 3.0/FortLootPackage.cpp | 9 +++++++-- Project Reboot 3.0/FortPlayerController.cpp | 9 ++++++--- Project Reboot 3.0/NameTypes.h | 16 ++++++++++------ Project Reboot 3.0/UnrealNames.cpp | 2 +- Project Reboot 3.0/commands.h | 3 ++- Project Reboot 3.0/vendingmachine.h | 4 ++-- 9 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Project Reboot 3.0/BuildingContainer.cpp b/Project Reboot 3.0/BuildingContainer.cpp index d0ff6d1..60157f3 100644 --- a/Project Reboot 3.0/BuildingContainer.cpp +++ b/Project Reboot 3.0/BuildingContainer.cpp @@ -6,6 +6,11 @@ bool ABuildingContainer::SpawnLoot(AFortPawn* Pawn) { + if (!Pawn) + return false; + + this->ForceNetUpdate(); + auto GameMode = Cast(GetWorld()->GetGameMode()); FVector LocationToSpawnLoot = this->GetActorLocation() + this->GetActorRightVector() * 70.f + this->GetActorUpVector() * 50.f; @@ -36,5 +41,11 @@ bool ABuildingContainer::SpawnLoot(AFortPawn* Pawn) auto NewPickup = AFortPickup::SpawnPickup(CreateData); } + if (!this->IsDestroyed()) + { + this->ForceNetUpdate(); + // a buncha other stuff + } + return true; } \ No newline at end of file diff --git a/Project Reboot 3.0/BuildingContainer.h b/Project Reboot 3.0/BuildingContainer.h index a1d14b6..14cf097 100644 --- a/Project Reboot 3.0/BuildingContainer.h +++ b/Project Reboot 3.0/BuildingContainer.h @@ -45,6 +45,12 @@ public: return Get(LootNoiseRangeOffset); } + void BounceContainer() + { + static auto BounceContainerFn = FindObject("/Script/FortniteGame.BuildingContainer.BounceContainer"); + this->ProcessEvent(BounceContainerFn); + } + bool SpawnLoot(AFortPawn* Pawn); static UClass* StaticClass() diff --git a/Project Reboot 3.0/FortGameModeAthena.cpp b/Project Reboot 3.0/FortGameModeAthena.cpp index 406a0fd..80fce3d 100644 --- a/Project Reboot 3.0/FortGameModeAthena.cpp +++ b/Project Reboot 3.0/FortGameModeAthena.cpp @@ -453,7 +453,7 @@ bool AFortGameModeAthena::Athena_ReadyToStartMatchHook(AFortGameModeAthena* Game if (Fortnite_Season == 6) { - if (Fortnite_Version != 6.10) + if (Fortnite_Version > 6.10) { auto Lake = FindObject(L"/Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_Lake1"); auto Lake2 = FindObject(L"/Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_Lake2"); diff --git a/Project Reboot 3.0/FortLootPackage.cpp b/Project Reboot 3.0/FortLootPackage.cpp index cba3fb7..fd8151d 100644 --- a/Project Reboot 3.0/FortLootPackage.cpp +++ b/Project Reboot 3.0/FortLootPackage.cpp @@ -49,12 +49,17 @@ void CollectDataTablesRows(const std::vector& DataTables, LOOTING_M for (auto CurrentDataTable : DataTablesToIterate) { - for (auto& CurrentPair : CurrentDataTable->GetRowMap()) + for (TPair& CurrentPair : CurrentDataTable->GetRowMap()) { if (Check(CurrentPair.Key(), (RowStructType*)CurrentPair.Value())) { - // LOG_INFO(LogDev, "row: {} comp {} num: {} passed check!", CurrentPair.Key().ToString(), CurrentPair.Key().ComparisonIndex.Value, CurrentPair.Key().Number); + // LOG_INFO(LogDev, "Setting key with {} comp {} num: {} then iterating through map!", CurrentPair.Key().ToString(), CurrentPair.Key().ComparisonIndex.Value, CurrentPair.Key().Number); (*OutMap)[CurrentPair.Key()] = (RowStructType*)CurrentPair.Value(); + + /* for (auto PairInOutMap : *OutMap) + { + // LOG_INFO(LogDev, "Current Row Key {} comp {} num: {}!", PairInOutMap.first.ToString(), PairInOutMap.first.ComparisonIndex.Value, PairInOutMap.first.Number); + } */ } } } diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index 04f6ce7..1fad788 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -445,13 +445,16 @@ void AFortPlayerController::ServerAttemptInteractHook(UObject* Context, FFrame* // LOG_INFO(LogInteraction, "bAlreadySearchedFieldMask: {}", bAlreadySearchedFieldMask); + BuildingContainer->SpawnLoot(PlayerController->GetMyFortPawn()); + BuildingContainer->SetBitfieldValue(bAlreadySearchedOffset, bAlreadySearchedFieldMask, true); (*(int*)(__int64(SearchBounceData) + SearchAnimationCountOffset))++; + BuildingContainer->BounceContainer(); + + BuildingContainer->ForceNetUpdate(); // ? static auto OnRep_bAlreadySearchedFn = FindObject(L"/Script/FortniteGame.BuildingContainer.OnRep_bAlreadySearched"); - BuildingContainer->ProcessEvent(OnRep_bAlreadySearchedFn); - - BuildingContainer->SpawnLoot(PlayerController->GetMyFortPawn()); + // BuildingContainer->ProcessEvent(OnRep_bAlreadySearchedFn); // if (BuildingContainer->ShouldDestroyOnSearch()) // BuildingContainer->K2_DestroyActor(); diff --git a/Project Reboot 3.0/NameTypes.h b/Project Reboot 3.0/NameTypes.h index 3b9bc12..68bde9d 100644 --- a/Project Reboot 3.0/NameTypes.h +++ b/Project Reboot 3.0/NameTypes.h @@ -1,10 +1,11 @@ #pragma once #include "inc.h" +#include "log.h" struct FNameEntryId { - uint32 Value; + uint32 Value; // well depends on version if its int32 or uint32 i think FNameEntryId() : Value(0) {} @@ -59,17 +60,20 @@ struct FName return Compare(Other) < 0; } */ - FORCEINLINE bool operator<(const FName& Other) const + FORCEINLINE bool operator<(const FName& Rhs) const { - return GetComparisonIndexFast() < Other.GetComparisonIndexFast(); + auto res = this->ComparisonIndex == Rhs.ComparisonIndex ? /* (Number - Rhs.Number) < 0 */ Number < Rhs.Number : this->ComparisonIndex < Rhs.ComparisonIndex; + // LOG_INFO(LogDev, "LHS ({} {}) RHS ({} {}) RESULT {}", this->ComparisonIndex.Value, this->Number, Rhs.ComparisonIndex.Value, Rhs.Number, res); + return res; + // return GetComparisonIndexFast() < Rhs.GetComparisonIndexFast() || (GetComparisonIndexFast() == Rhs.GetComparisonIndexFast() && GetNumber() < Rhs.GetNumber()); // (Milxnor) BRO IDK - if (GetComparisonIndexFast() == Other.GetComparisonIndexFast()) + if (GetComparisonIndexFast() == Rhs.GetComparisonIndexFast()) { - return GetNumber() - Other.GetNumber(); + return (GetNumber() - Rhs.GetNumber()) < 0; } - return GetComparisonIndexFast() < Other.GetComparisonIndexFast(); + return GetComparisonIndexFast() < Rhs.GetComparisonIndexFast(); } }; \ No newline at end of file diff --git a/Project Reboot 3.0/UnrealNames.cpp b/Project Reboot 3.0/UnrealNames.cpp index 2b8d2dc..18ffecc 100644 --- a/Project Reboot 3.0/UnrealNames.cpp +++ b/Project Reboot 3.0/UnrealNames.cpp @@ -63,7 +63,7 @@ int32 FName::Compare(const FName& Other) const } */ } - return 0; + return GetComparisonIndexFast() < Other.GetComparisonIndexFast(); } std::string FName::ToString() diff --git a/Project Reboot 3.0/commands.h b/Project Reboot 3.0/commands.h index b722a1f..17909e4 100644 --- a/Project Reboot 3.0/commands.h +++ b/Project Reboot 3.0/commands.h @@ -118,6 +118,7 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg) auto Message = Msg.ToString(); size_t start = Message.find('\\'); + while (start != std::string::npos) // remove the playername { size_t end = Message.find('\\', start + 1); @@ -133,7 +134,7 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg) // std::cout << "Message Before: " << Message << '\n'; - while (Message.find(" ") != -1) + while (Message.find(" ") != std::string::npos) { auto arg = Message.substr(0, Message.find(' ')); Arguments.push_back(arg); diff --git a/Project Reboot 3.0/vendingmachine.h b/Project Reboot 3.0/vendingmachine.h index a5dacdd..5f82182 100644 --- a/Project Reboot 3.0/vendingmachine.h +++ b/Project Reboot 3.0/vendingmachine.h @@ -129,7 +129,7 @@ static inline void FillItemCollector(ABuildingItemCollectorActor* ItemCollector, if (LootDrops.size() == 0) { // LOG_WARN(LogGame, "Failed to find LootDrops for vending machine loot tier: {}", LootTier); - // ItemCollectorIt--; // retry (?) + ItemCollectorIt--; // retry (?) continue; } @@ -253,7 +253,7 @@ static inline void FillVendingMachines() for (int i = 0; i < ThingAndWeights.size(); i++) { - LOG_INFO(LogDev, "[{}] bruh: {}", i, ThingAndWeights.at(i)); + // LOG_INFO(LogDev, "[{}] bruh: {}", i, ThingAndWeights.at(i)); } std::map PickedRarities;