mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 02:42:22 +01:00
Update FortPlayerController.cpp
This commit is contained in:
@@ -549,83 +549,179 @@ void AFortPlayerController::ServerAttemptInteractHook(UObject* Context, FFrame*
|
||||
}
|
||||
else if (ReceivingActor->IsA(BuildingItemCollectorActorClass))
|
||||
{
|
||||
auto WorldInventory = PlayerController->GetWorldInventory();
|
||||
|
||||
if (!WorldInventory)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
auto ItemCollector = ReceivingActor;
|
||||
static auto ActiveInputItemOffset = ItemCollector->GetOffset("ActiveInputItem");
|
||||
auto CurrentMaterial = ItemCollector->Get<UFortWorldItemDefinition*>(ActiveInputItemOffset); // InteractType->OptionalObjectData
|
||||
|
||||
if (!CurrentMaterial)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
int Index = 0;
|
||||
|
||||
// this is a weird way of getting the current item collection we are on.
|
||||
|
||||
static auto StoneItemData = FindObject<UFortResourceItemDefinition>(L"/Game/Items/ResourcePickups/StoneItemData.StoneItemData");
|
||||
static auto MetalItemData = FindObject<UFortResourceItemDefinition>(L"/Game/Items/ResourcePickups/MetalItemData.MetalItemData");
|
||||
|
||||
if (CurrentMaterial == StoneItemData)
|
||||
Index = 1;
|
||||
else if (CurrentMaterial == MetalItemData)
|
||||
Index = 2;
|
||||
|
||||
static auto ItemCollectionsOffset = ItemCollector->GetOffset("ItemCollections");
|
||||
auto& ItemCollections = ItemCollector->Get<TArray<FCollectorUnitInfo>>(ItemCollectionsOffset);
|
||||
|
||||
auto ItemCollection = ItemCollections.AtPtr(Index, FCollectorUnitInfo::GetPropertiesSize());
|
||||
|
||||
if (Fortnite_Version < 8.10)
|
||||
if (Engine_Version >= 424 && /*Fortnite_Version < 15 && */ReceivingActor->GetFullName().contains("Wumba"))
|
||||
{
|
||||
auto Cost = ItemCollection->GetInputCount()->GetValue();
|
||||
|
||||
if (!CurrentMaterial)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
auto MatInstance = WorldInventory->FindItemInstance(CurrentMaterial);
|
||||
|
||||
if (!MatInstance)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
bool bIsSidegrading = InteractionBeingAttempted == EInteractionBeingAttempted::SecondInteraction ? true : false;
|
||||
|
||||
LOG_INFO(LogDev, "bIsSidegrading: {}", (bool)bIsSidegrading);
|
||||
|
||||
struct FWeaponUpgradeItemRow
|
||||
{
|
||||
void* FTableRowBaseInheritance;
|
||||
UFortWeaponItemDefinition* CurrentWeaponDef; // 0x8(0x8)(Edit, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
|
||||
UFortWeaponItemDefinition* UpgradedWeaponDef; // 0x10(0x8)(Edit, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
|
||||
EFortWeaponUpgradeCosts WoodCost; // 0x18(0x1)(Edit, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
|
||||
EFortWeaponUpgradeCosts MetalCost; // 0x19(0x1)(Edit, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
|
||||
EFortWeaponUpgradeCosts BrickCost; // 0x1A(0x1)(Edit, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
|
||||
EFortWeaponUpgradeDirection Direction;
|
||||
};
|
||||
|
||||
static auto WumbaDataTable = FindObject<UDataTable>("/Game/Items/Datatables/AthenaWumbaData.AthenaWumbaData");
|
||||
|
||||
static auto LootPackagesRowMap = WumbaDataTable->GetRowMap();
|
||||
|
||||
auto Pawn = Cast<AFortPawn>(PlayerController->GetPawn());
|
||||
auto CurrentHeldWeapon = Pawn->GetCurrentWeapon();
|
||||
auto CurrentHeldWeaponDef = CurrentHeldWeapon->GetWeaponData();
|
||||
|
||||
auto Direction = bIsSidegrading ? EFortWeaponUpgradeDirection::Horizontal : EFortWeaponUpgradeDirection::Vertical;
|
||||
|
||||
LOG_INFO(LogDev, "Direction: {}", (int)Direction);
|
||||
|
||||
FWeaponUpgradeItemRow* FoundRow = nullptr;
|
||||
|
||||
for (int i = 0; i < LootPackagesRowMap.Pairs.Elements.Data.Num(); i++)
|
||||
{
|
||||
auto& Pair = LootPackagesRowMap.Pairs.Elements.Data.at(i).ElementData.Value;
|
||||
auto First = Pair.First;
|
||||
auto Row = (FWeaponUpgradeItemRow*)Pair.Second;
|
||||
|
||||
if (Row->CurrentWeaponDef == CurrentHeldWeaponDef && Row->Direction == Direction)
|
||||
{
|
||||
FoundRow = Row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!FoundRow)
|
||||
{
|
||||
LOG_WARN(LogGame, "Failed to find row!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto NewDefinition = FoundRow->UpgradedWeaponDef;
|
||||
|
||||
LOG_INFO(LogDev, "UpgradedWeaponDef: {}", NewDefinition->GetFullName());
|
||||
|
||||
int WoodCost = (int)FoundRow->WoodCost * 50;
|
||||
int StoneCost = (int)FoundRow->BrickCost * 50 - 400;
|
||||
int MetalCost = (int)FoundRow->MetalCost * 50 - 200;
|
||||
|
||||
if (bIsSidegrading)
|
||||
{
|
||||
WoodCost = 20;
|
||||
StoneCost = 20;
|
||||
MetalCost = 20;
|
||||
}
|
||||
|
||||
static auto WoodItemData = FindObject<UFortItemDefinition>("/Game/Items/ResourcePickups/WoodItemData.WoodItemData");
|
||||
static auto StoneItemData = FindObject<UFortItemDefinition>("/Game/Items/ResourcePickups/StoneItemData.StoneItemData");
|
||||
static auto MetalItemData = FindObject<UFortItemDefinition>("/Game/Items/ResourcePickups/MetalItemData.MetalItemData");
|
||||
|
||||
auto WorldInventory = PlayerController->GetWorldInventory();
|
||||
|
||||
auto WoodInstance = WorldInventory->FindItemInstance(WoodItemData);
|
||||
auto WoodCount = WoodInstance->GetItemEntry()->GetCount();
|
||||
|
||||
auto StoneInstance = WorldInventory->FindItemInstance(StoneItemData);
|
||||
auto StoneCount = StoneInstance->GetItemEntry()->GetCount();
|
||||
|
||||
auto MetalInstance = WorldInventory->FindItemInstance(MetalItemData);
|
||||
auto MetalCount = MetalInstance->GetItemEntry()->GetCount();
|
||||
|
||||
bool bShouldUpdate = false;
|
||||
|
||||
if (!WorldInventory->RemoveItem(MatInstance->GetItemEntry()->GetItemGuid(), &bShouldUpdate, Cost, true))
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
|
||||
WorldInventory->RemoveItem(WoodInstance->GetItemEntry()->GetItemGuid(), &bShouldUpdate, WoodCost);
|
||||
WorldInventory->RemoveItem(StoneInstance->GetItemEntry()->GetItemGuid(), &bShouldUpdate, StoneCost);
|
||||
WorldInventory->RemoveItem(MetalInstance->GetItemEntry()->GetItemGuid(), &bShouldUpdate, MetalCost);
|
||||
|
||||
WorldInventory->RemoveItem(CurrentHeldWeapon->GetItemEntryGuid(), &bShouldUpdate, 1, true);
|
||||
|
||||
WorldInventory->AddItem(NewDefinition, &bShouldUpdate);
|
||||
|
||||
if (bShouldUpdate)
|
||||
WorldInventory->Update();
|
||||
}
|
||||
|
||||
for (int z = 0; z < ItemCollection->GetOutputItemEntry()->Num(); z++)
|
||||
else
|
||||
{
|
||||
auto Entry = ItemCollection->GetOutputItemEntry()->AtPtr(z, FFortItemEntry::GetStructSize());
|
||||
|
||||
PickupCreateData CreateData;
|
||||
CreateData.ItemEntry = FFortItemEntry::MakeItemEntry(Entry->GetItemDefinition(), Entry->GetCount(), Entry->GetLoadedAmmo(), MAX_DURABILITY, Entry->GetLevel());
|
||||
CreateData.SpawnLocation = LocationToSpawnLoot;
|
||||
CreateData.PawnOwner = PlayerController->GetMyFortPawn(); // hmm
|
||||
CreateData.bShouldFreeItemEntryWhenDeconstructed = true;
|
||||
|
||||
AFortPickup::SpawnPickup(CreateData);
|
||||
}
|
||||
|
||||
static auto bCurrentInteractionSuccessOffset = ItemCollector->GetOffset("bCurrentInteractionSuccess", false);
|
||||
|
||||
if (bCurrentInteractionSuccessOffset != -1)
|
||||
{
|
||||
static auto bCurrentInteractionSuccessFieldMask = GetFieldMask(ItemCollector->GetProperty("bCurrentInteractionSuccess"));
|
||||
ItemCollector->SetBitfieldValue(bCurrentInteractionSuccessOffset, bCurrentInteractionSuccessFieldMask, true); // idek if this is needed
|
||||
}
|
||||
|
||||
static auto DoVendDeath = FindObject<UFunction>(L"/Game/Athena/Items/Gameplay/VendingMachine/B_Athena_VendingMachine.B_Athena_VendingMachine_C.DoVendDeath");
|
||||
|
||||
if (DoVendDeath)
|
||||
{
|
||||
ItemCollector->ProcessEvent(DoVendDeath);
|
||||
ItemCollector->K2_DestroyActor();
|
||||
auto WorldInventory = PlayerController->GetWorldInventory();
|
||||
|
||||
if (!WorldInventory)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
auto ItemCollector = ReceivingActor;
|
||||
static auto ActiveInputItemOffset = ItemCollector->GetOffset("ActiveInputItem");
|
||||
auto CurrentMaterial = ItemCollector->Get<UFortWorldItemDefinition*>(ActiveInputItemOffset); // InteractType->OptionalObjectData
|
||||
|
||||
if (!CurrentMaterial)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
int Index = 0;
|
||||
|
||||
// this is a weird way of getting the current item collection we are on.
|
||||
|
||||
static auto StoneItemData = FindObject<UFortResourceItemDefinition>(L"/Game/Items/ResourcePickups/StoneItemData.StoneItemData");
|
||||
static auto MetalItemData = FindObject<UFortResourceItemDefinition>(L"/Game/Items/ResourcePickups/MetalItemData.MetalItemData");
|
||||
|
||||
if (CurrentMaterial == StoneItemData)
|
||||
Index = 1;
|
||||
else if (CurrentMaterial == MetalItemData)
|
||||
Index = 2;
|
||||
|
||||
static auto ItemCollectionsOffset = ItemCollector->GetOffset("ItemCollections");
|
||||
auto& ItemCollections = ItemCollector->Get<TArray<FCollectorUnitInfo>>(ItemCollectionsOffset);
|
||||
|
||||
auto ItemCollection = ItemCollections.AtPtr(Index, FCollectorUnitInfo::GetPropertiesSize());
|
||||
|
||||
if (Fortnite_Version < 8.10)
|
||||
{
|
||||
auto Cost = ItemCollection->GetInputCount()->GetValue();
|
||||
|
||||
if (!CurrentMaterial)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
auto MatInstance = WorldInventory->FindItemInstance(CurrentMaterial);
|
||||
|
||||
if (!MatInstance)
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
bool bShouldUpdate = false;
|
||||
|
||||
if (!WorldInventory->RemoveItem(MatInstance->GetItemEntry()->GetItemGuid(), &bShouldUpdate, Cost, true))
|
||||
return ServerAttemptInteractOriginal(Context, Stack, Ret);
|
||||
|
||||
if (bShouldUpdate)
|
||||
WorldInventory->Update();
|
||||
}
|
||||
|
||||
for (int z = 0; z < ItemCollection->GetOutputItemEntry()->Num(); z++)
|
||||
{
|
||||
auto Entry = ItemCollection->GetOutputItemEntry()->AtPtr(z, FFortItemEntry::GetStructSize());
|
||||
|
||||
PickupCreateData CreateData;
|
||||
CreateData.ItemEntry = FFortItemEntry::MakeItemEntry(Entry->GetItemDefinition(), Entry->GetCount(), Entry->GetLoadedAmmo(), MAX_DURABILITY, Entry->GetLevel());
|
||||
CreateData.SpawnLocation = LocationToSpawnLoot;
|
||||
CreateData.PawnOwner = PlayerController->GetMyFortPawn(); // hmm
|
||||
CreateData.bShouldFreeItemEntryWhenDeconstructed = true;
|
||||
|
||||
AFortPickup::SpawnPickup(CreateData);
|
||||
}
|
||||
|
||||
static auto bCurrentInteractionSuccessOffset = ItemCollector->GetOffset("bCurrentInteractionSuccess", false);
|
||||
|
||||
if (bCurrentInteractionSuccessOffset != -1)
|
||||
{
|
||||
static auto bCurrentInteractionSuccessFieldMask = GetFieldMask(ItemCollector->GetProperty("bCurrentInteractionSuccess"));
|
||||
ItemCollector->SetBitfieldValue(bCurrentInteractionSuccessOffset, bCurrentInteractionSuccessFieldMask, true); // idek if this is needed
|
||||
}
|
||||
|
||||
static auto DoVendDeath = FindObject<UFunction>(L"/Game/Athena/Items/Gameplay/VendingMachine/B_Athena_VendingMachine.B_Athena_VendingMachine_C.DoVendDeath");
|
||||
|
||||
if (DoVendDeath)
|
||||
{
|
||||
ItemCollector->ProcessEvent(DoVendDeath);
|
||||
ItemCollector->K2_DestroyActor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1692,4 +1788,4 @@ void AFortPlayerController::ServerEndEditingBuildingActorHook(AFortPlayerControl
|
||||
EditTool->GetEditActor() = nullptr;
|
||||
EditTool->OnRep_EditActor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user