fix 19.10 teams + issue with picking up

This commit is contained in:
Milxnor
2023-03-28 20:11:30 -04:00
parent 65668f8235
commit a2b07de07e
5 changed files with 43 additions and 8 deletions

View File

@@ -61,7 +61,10 @@ AFortPickup* AFortPickup::SpawnPickup(UFortItemDefinition* ItemDef, FVector Loca
char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
{
// LOG_INFO(LogDev, "Woah!");
constexpr bool bTestPrinting = false; // we could just use our own logger but eh
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "CompletePickupAnimationHook!");
auto Pawn = Cast<AFortPlayerPawn>(Pickup->GetPickupLocationData()->GetPickupTarget());
@@ -92,10 +95,10 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
auto ItemInstanceToSwap = WorldInventory->FindItemInstance(CurrentItemGuid);
if (!ItemInstanceToSwap)
return CompletePickupAnimationOriginal(Pickup);
// if (!ItemInstanceToSwap)
// return CompletePickupAnimationOriginal(Pickup);
auto ItemEntryToSwap = ItemInstanceToSwap->GetItemEntry();
auto ItemEntryToSwap = ItemInstanceToSwap ? ItemInstanceToSwap->GetItemEntry() : nullptr;
auto ItemDefinitionToSwap = ItemEntryToSwap ? Cast<UFortWorldItemDefinition>(ItemEntryToSwap->GetItemDefinition()) : nullptr;
bool bHasSwapped = false;
@@ -106,6 +109,9 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
std::vector<std::pair<FFortItemEntry*, FFortItemEntry*>> PairsToMarkDirty; // vector of sets or something so no duplicates??
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "Start cpyCount: {}", cpyCount);
bool bForceOverflow = false;
while (cpyCount > 0)
@@ -126,6 +132,8 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
PrimarySlotsFilled++;
}
// LOG_INFO(LogDev, "[{}] PrimarySlotsFilled: {}", i, PrimarySlotsFilled);
bIsInventoryFull = (PrimarySlotsFilled /* - 6 */) >= 5;
if (bIsInventoryFull) // probs shouldnt do in loop but alr
@@ -139,12 +147,18 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
bHasSwapped = true;
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "[{}] Swapping: {}", i, ItemDefinitionToSwap->GetFullName());
continue; // ???
}
}
if (CurrentItemEntry->GetItemDefinition() == PickupItemDefinition)
{
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "[{}] Found stack of item!", i);
if (CurrentItemEntry->GetCount() < PickupItemDefinition->GetMaxStackSize())
{
int OverStack = CurrentItemEntry->GetCount() + cpyCount - PickupItemDefinition->GetMaxStackSize();
@@ -158,6 +172,9 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
bEverStacked = true;
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "[{}] We are stacking {}.", i, AmountToStack);
// if (cpyCount > 0)
// break;
}
@@ -167,6 +184,9 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
if ((bIsInventoryFull || bForceOverflow) && cpyCount > 0) // overflow
{
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "[{}] Overflow", i);
UFortWorldItemDefinition* ItemDefinitionToSpawn = PickupItemDefinition;
int AmountToSpawn = cpyCount > PickupItemDefinition->GetMaxStackSize() ? PickupItemDefinition->GetMaxStackSize() : cpyCount;
@@ -181,6 +201,9 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
if (cpyCount > 0 && !bIsInventoryFull)
{
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "Attempting to add to inventory.");
if (bDoesStackExist ? PickupItemDefinition->DoesAllowMultipleStacks() : true)
{
auto NewItemCount = cpyCount > PickupItemDefinition->GetMaxStackSize() ? PickupItemDefinition->GetMaxStackSize() : cpyCount;
@@ -188,6 +211,9 @@ char AFortPickup::CompletePickupAnimationHook(AFortPickup* Pickup)
auto NewItem = WorldInventory->AddItem(PickupItemDefinition, nullptr,
NewItemCount, PickupEntry->GetLoadedAmmo(), true);
if constexpr (bTestPrinting)
LOG_INFO(LogDev, "Added item with count {} to inventory.", NewItemCount);
// if (NewItem)
cpyCount -= NewItemCount;
}

View File

@@ -985,19 +985,22 @@ static inline uint64 FindPickTeam()
{
if (Engine_Version == 426)
{
auto testAddr = Memcury::Scanner::FindPattern("88 54 24 10 53 56 41 54 41 55 41 56 48 83 EC 60 4C 8B A1").Get(); // 14.60 ????
auto testAddr = Memcury::Scanner::FindPattern("88 54 24 10 53 56 41 54 41 55 41 56 48 83 EC 60 4C 8B A1").Get(); // 14.60 what is happening lol ????
if (testAddr)
return testAddr;
}
else if (Engine_Version == 500)
return Memcury::Scanner::FindPattern("48 89 5C 24 ? 88 54 24 10 55 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 70 45 33 ED 4D").Get(); // 19.10
else if (Engine_Version >= 427) // different start
return Memcury::Scanner::FindPattern("48 89 5C 24 ? 88 54 24 10 55 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 70 4C 8B A1").Get();
auto Addr = Memcury::Scanner::FindStringRef(L"PickTeam for [%s] used beacon value [%d]", false);
auto Addr = Memcury::Scanner::FindStringRef(L"PickTeam for [%s] used beacon value [%d]", false, 0, Engine_Version >= 427); // todo check if its just s18+ but this doesn't matter for now cuz we hardcode sig
if (!Addr.Get())
Addr = Memcury::Scanner::FindStringRef(L"PickTeam for [%s] used beacon value [%s]");
Addr = Memcury::Scanner::FindStringRef(L"PickTeam for [%s] used beacon value [%s]"); // i don't even know what version this is
return FindBytes(Addr, Fortnite_Version <= 2.5 ? std::vector<uint8_t>{ 0x48, 0x89, 0x6C } : std::vector<uint8_t>{ 0x40, 0x55 }, 1000, 0, true);
}

View File

@@ -101,7 +101,7 @@ inline __int64 GetFunctionIdxOrPtr(UFunction* Function)
if ((*(uint8_t*)(NativeAddr + i) == 0x41 && *(uint8_t*)(NativeAddr + i + 1) == 0xFF)) // wtf ue500
{
LOG_INFO(LogDev, "Uhhhhhh report this to milxnor if u not on 19.10 {}", Function->GetName());
LOG_INFO(LogDev, "Uhhhhhh report this to milxnor if u not on 18.40+ {}", Function->GetName());
bFoundValidate = true;
continue;
}

View File

@@ -347,6 +347,8 @@ static UObject* GetPlaylistToUse()
// Playlist = FindObject("/MoleGame/Playlists/Playlist_MoleGame.Playlist_MoleGame");
// Playlist = FindObject("/Game/Athena/Playlists/DADBRO/Playlist_DADBRO_Squads_8.Playlist_DADBRO_Squads_8");
Playlist = FindObject("/Game/Athena/Playlists/Playlist_DefaultDuo.Playlist_DefaultDuo");
if (Globals::bCreative)
Playlist = FindObject("/Game/Athena/Playlists/Creative/Playlist_PlaygroundV2.Playlist_PlaygroundV2");

View File

@@ -2,3 +2,7 @@
F7 - Start event
F8 - Start Aircraft
## TODO
- Rewrite picking up code.