Merge branch 'main' into main

This commit is contained in:
Aaron Kimbrell
2022-05-24 19:00:52 -05:00
committed by GitHub
169 changed files with 3164 additions and 1954 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#pragma once
#include "dCommonVars.h"
#include "LDFFormat.h"
/**
* An item that's equipped, generally as a smaller return type than the regular Item class
@@ -26,4 +27,9 @@ struct EquippedItem
* The slot this item is stored in
*/
uint32_t slot = 0;
/**
* The configuration of the item with any extra data
*/
std::vector<LDFBaseData*> config = {};
};

View File

@@ -90,17 +90,21 @@ int32_t Inventory::FindEmptySlot()
{
if (free <= 6) // Up from 1
{
if (type != ITEMS && type != VAULT_ITEMS)
if (type != ITEMS && type != VAULT_ITEMS && type != eInventoryType::VAULT_MODELS)
{
uint32_t newSize = size;
if (type == MODELS || type == VAULT_MODELS)
if (type == MODELS)
{
newSize = 240;
}
else if (type == eInventoryType::VENDOR_BUYBACK)
{
newSize += 9u;
}
else
{
newSize += 20;
newSize += 10u;
}
if (newSize > GetSize())

View File

@@ -14,7 +14,7 @@
class Inventory;
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector<LDFBaseData*>& config, const LWOOBJID parent, LWOOBJID subKey)
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector<LDFBaseData*>& config, const LWOOBJID parent, LWOOBJID subKey, eLootSourceType lootSourceType)
{
if (!Inventory::IsValidItem(lot))
{
@@ -46,7 +46,8 @@ Item::Item(
bool showFlyingLoot,
bool isModMoveAndEquip,
LWOOBJID subKey,
bool bound)
bool bound,
eLootSourceType lootSourceType)
{
if (!Inventory::IsValidItem(lot))
{
@@ -80,8 +81,7 @@ Item::Item(
inventory->AddManagedItem(this);
auto* entity = inventory->GetComponent()->GetParent();
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast<int>(this->count), subKey);
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast<int>(this->count), subKey, lootSourceType);
if (isModMoveAndEquip)
{
@@ -148,7 +148,7 @@ PreconditionExpression* Item::GetPreconditionExpression() const
return preconditions;
}
void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot)
void Item::SetCount(const uint32_t value, const bool silent, const bool disassemble, const bool showFlyingLoot, eLootSourceType lootSourceType)
{
if (value == count)
{
@@ -176,7 +176,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
if (value > count)
{
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta);
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType);
}
else
{
@@ -340,7 +340,7 @@ bool Item::UseNonEquip()
return false;
}
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result);
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
}
inventory->GetComponent()->RemoveItem(lot, 1);
@@ -374,7 +374,7 @@ void Item::Disassemble(const eInventoryType inventoryType)
for (const auto mod : modArray)
{
inventory->GetComponent()->AddItem(mod, 1, inventoryType);
inventory->GetComponent()->AddItem(mod, 1, eLootSourceType::LOOT_SOURCE_DELETION, inventoryType);
}
}
}
@@ -472,7 +472,7 @@ void Item::DisassembleModel()
continue;
}
GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1);
GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::LOOT_SOURCE_DELETION);
}
}

View File

@@ -36,7 +36,8 @@ public:
bool bound,
const std::vector<LDFBaseData*>& config,
LWOOBJID parent,
LWOOBJID subKey
LWOOBJID subKey,
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE
);
/**
@@ -62,7 +63,8 @@ public:
bool showFlyingLoot = true,
bool isModMoveAndEquip = false,
LWOOBJID subKey = LWOOBJID_EMPTY,
bool bound = false
bool bound = false,
eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE
);
~Item();
@@ -86,7 +88,7 @@ public:
* @param disassemble if items were removed, this returns all the sub parts of the item individually if it had assembly part lots
* @param showFlyingLoot shows flying loot to the client, if not silent
*/
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true);
void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE);
/**
* Returns the number of items this item represents (e.g. for stacks)