Files
Project-Reboot-3.0/Project Reboot 3.0/FortInventoryInterface.cpp
Milxnor ffbba9e9a4 a lot
fix 7.20, >2.5 emoting, fix removing item bug on >2.5, fix equipping being buggy on >2.5, added ammo depletion to 1.11+
2023-04-02 16:38:53 -04:00

51 lines
1.5 KiB
C++

#include "FortInventoryInterface.h"
#include "reboot.h"
#include "FortPlayerControllerAthena.h"
char UFortInventoryInterface::RemoveInventoryItemHook(__int64 a1, FGuid a2, int Count, char bForceRemoveFromQuickBars, char bForceRemoval)
{
// kms bruh
static auto FortPlayerControllerSuperSize = (*(UClass**)(__int64(FindObject<UClass>("/Script/FortniteGame.FortPlayerController")) + Offsets::SuperStruct))->GetPropertiesSize();
int SuperAdditionalOffset = Engine_Version >= 427 ? 16 : 8;
auto ControllerObject = (UObject*)(__int64(a1) - (FortPlayerControllerSuperSize + SuperAdditionalOffset));
LOG_INFO(LogDev, "bForceRemoval: {}", (bool)bForceRemoval);
// LOG_INFO(LogDev, "FortPlayerControllerSuperSize: {}", FortPlayerControllerSuperSize);
// LOG_INFO(LogDev, "ControllerObject: {}", ControllerObject->GetFullName());
if (!ControllerObject)
return false;
auto PlayerController = Cast<AFortPlayerControllerAthena>(ControllerObject);
if (!PlayerController)
return false;
auto WorldInventory = PlayerController->GetWorldInventory();
if (!WorldInventory)
return false;
bool bShouldUpdate = false;
WorldInventory->RemoveItem(a2, &bShouldUpdate, Count, bForceRemoval);
if (bShouldUpdate)
WorldInventory->Update();
if (Engine_Version < 424)
{
auto Pawn = PlayerController->GetMyFortPawn();
if (Pawn)
{
auto CurrentWeapon = Pawn->GetCurrentWeapon();
if (CurrentWeapon)
WorldInventory->CorrectLoadedAmmo(CurrentWeapon->GetItemEntryGuid(), CurrentWeapon->GetAmmoCount());
}
}
return true;
}