fix zone on 16.50, fix infinite item bug, fix grappler crashing on some versions

This commit is contained in:
Milxnor
2023-04-02 12:23:42 -04:00
parent 20e9fb87df
commit f41b18f875
3 changed files with 30 additions and 9 deletions

View File

@@ -197,11 +197,35 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int
auto NewCount = ReplicatedEntry->GetCount() - Count; auto NewCount = ReplicatedEntry->GetCount() - Count;
if (NewCount > 0 || (ItemDefinition->ShouldPersistWhenFinalStackEmpty() && !bForceRemoval)) auto& ItemInstances = GetItemList().GetItemInstances();
{ auto& ReplicatedEntries = GetItemList().GetReplicatedEntries();
if (ItemDefinition->ShouldPersistWhenFinalStackEmpty())
NewCount = NewCount < 0 ? 0 : NewCount; // min(NewCount, 0) or something i forgot
bool bOverrideChangeStackSize = false;
if (ItemDefinition->ShouldPersistWhenFinalStackEmpty() && !bForceRemoval)
{
bool bIsFinalStack = true;
for (int i = 0; i < ItemInstances.Num(); i++)
{
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;
}
}
if (NewCount > 0 || bOverrideChangeStackSize)
{
ItemInstance->GetItemEntry()->GetCount() = NewCount; ItemInstance->GetItemEntry()->GetCount() = NewCount;
ReplicatedEntry->GetCount() = NewCount; ReplicatedEntry->GetCount() = NewCount;
@@ -214,9 +238,6 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int
static auto FortItemEntryStruct = FindObject<UStruct>(L"/Script/FortniteGame.FortItemEntry"); static auto FortItemEntryStruct = FindObject<UStruct>(L"/Script/FortniteGame.FortItemEntry");
static auto FortItemEntrySize = FortItemEntryStruct->GetPropertiesSize(); static auto FortItemEntrySize = FortItemEntryStruct->GetPropertiesSize();
auto& ItemInstances = GetItemList().GetItemInstances();
auto& ReplicatedEntries = GetItemList().GetReplicatedEntries();
for (int i = 0; i < ItemInstances.Num(); i++) for (int i = 0; i < ItemInstances.Num(); i++)
{ {
if (ItemInstances.at(i)->GetItemEntry()->GetItemGuid() == ItemGuid) if (ItemInstances.at(i)->GetItemEntry()->GetItemGuid() == ItemGuid)

View File

@@ -283,7 +283,7 @@ DWORD WINAPI Main(LPVOID)
break; break;
} }
if (*(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i) == 0x4C && *(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i + 1) == 0x8B) if (*(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i) == 0x4C && *(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i + 1) == 0x8B && *(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i + 2) == 0xDC)
{ {
OnPlayImpactFXAddr = OnPlayImpactFXPtrRef - i; OnPlayImpactFXAddr = OnPlayImpactFXPtrRef - i;
break; break;

View File

@@ -601,7 +601,7 @@ static inline uint64 FindSetZoneToIndex() // actually StartNewSafeZonePhase
// return Memcury::Scanner::FindPattern("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 C8 0F 29 78 B8 44 0F 29 40 ? 44 0F 29 48 ? 44 0F 29 50 ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 8B B1 ? ? ? ? 45 33 ED 89 54 24 70 44 8B FA 48 89 4C 24").Get(); // 18.40 // return Memcury::Scanner::FindPattern("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 C8 0F 29 78 B8 44 0F 29 40 ? 44 0F 29 48 ? 44 0F 29 50 ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 8B B1 ? ? ? ? 45 33 ED 89 54 24 70 44 8B FA 48 89 4C 24").Get(); // 18.40
// return Memcury::Scanner::FindPattern("40 55 53 56 41 55 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 18 48 8B").Get(); // 14.60 // return Memcury::Scanner::FindPattern("40 55 53 56 41 55 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 18 48 8B").Get(); // 14.60
auto Addr = Memcury::Scanner::FindStringRef(L"FortGameModeAthena: No MegaStorm on SafeZone[%d]. GridCellThickness is less than 1.0.", true, 0, Fortnite_Version >= 17).Get(); auto Addr = Memcury::Scanner::FindStringRef(L"FortGameModeAthena: No MegaStorm on SafeZone[%d]. GridCellThickness is less than 1.0.", true, 0, Fortnite_Version >= 16.50).Get();
// return FindBytes(Addr, { 0x40, 0x55 }, 30000, 0, true); // return FindBytes(Addr, { 0x40, 0x55 }, 30000, 0, true);
if (!Addr) if (!Addr)