fix looting bug

This commit is contained in:
Milxnor
2023-05-21 10:54:43 -04:00
parent a2d621560a
commit a0f427b491
9 changed files with 46 additions and 16 deletions

View File

@@ -6,6 +6,11 @@
bool ABuildingContainer::SpawnLoot(AFortPawn* Pawn)
{
if (!Pawn)
return false;
this->ForceNetUpdate();
auto GameMode = Cast<AFortGameModeAthena>(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;
}

View File

@@ -45,6 +45,12 @@ public:
return Get<float>(LootNoiseRangeOffset);
}
void BounceContainer()
{
static auto BounceContainerFn = FindObject<UFunction>("/Script/FortniteGame.BuildingContainer.BounceContainer");
this->ProcessEvent(BounceContainerFn);
}
bool SpawnLoot(AFortPawn* Pawn);
static UClass* StaticClass()

View File

@@ -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<AActor>(L"/Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_Lake1");
auto Lake2 = FindObject<AActor>(L"/Game/Athena/Maps/Athena_POI_Foundations.Athena_POI_Foundations.PersistentLevel.LF_Lake2");

View File

@@ -49,12 +49,17 @@ void CollectDataTablesRows(const std::vector<UDataTable*>& DataTables, LOOTING_M
for (auto CurrentDataTable : DataTablesToIterate)
{
for (auto& CurrentPair : CurrentDataTable->GetRowMap())
for (TPair<FName, uint8_t*>& 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);
} */
}
}
}

View File

@@ -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<UFunction>(L"/Script/FortniteGame.BuildingContainer.OnRep_bAlreadySearched");
BuildingContainer->ProcessEvent(OnRep_bAlreadySearchedFn);
BuildingContainer->SpawnLoot(PlayerController->GetMyFortPawn());
// BuildingContainer->ProcessEvent(OnRep_bAlreadySearchedFn);
// if (BuildingContainer->ShouldDestroyOnSearch())
// BuildingContainer->K2_DestroyActor();

View File

@@ -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();
}
};

View File

@@ -63,7 +63,7 @@ int32 FName::Compare(const FName& Other) const
} */
}
return 0;
return GetComparisonIndexFast() < Other.GetComparisonIndexFast();
}
std::string FName::ToString()

View File

@@ -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);

View File

@@ -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<int, int> PickedRarities;