mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-26 16:46:31 +00:00
fix the wu man (#1743)
This commit is contained in:
parent
347fc46f01
commit
f78baee534
@ -28,7 +28,8 @@ enum eInventoryType : uint32_t {
|
|||||||
DONATION,
|
DONATION,
|
||||||
VAULT_MODELS,
|
VAULT_MODELS,
|
||||||
ITEM_SETS, //internal, technically this is BankBehaviors.
|
ITEM_SETS, //internal, technically this is BankBehaviors.
|
||||||
INVALID // made up, for internal use!!!, Technically this called the ALL inventory.
|
INVALID, // made up, for internal use!!!, Technically this called the ALL inventory.
|
||||||
|
ALL, // Use this to search all inventories instead of a specific one.
|
||||||
};
|
};
|
||||||
|
|
||||||
class InventoryType {
|
class InventoryType {
|
||||||
|
@ -150,11 +150,11 @@ uint32_t InventoryComponent::GetLotCount(const LOT lot) const {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t InventoryComponent::GetLotCountNonTransfer(LOT lot) const {
|
uint32_t InventoryComponent::GetLotCountNonTransfer(LOT lot, bool includeVault) const {
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
|
|
||||||
for (const auto& inventory : m_Inventories) {
|
for (const auto& inventory : m_Inventories) {
|
||||||
if (IsTransferInventory(inventory.second->GetType())) continue;
|
if (IsTransferInventory(inventory.second->GetType(), includeVault)) continue;
|
||||||
|
|
||||||
count += inventory.second->GetLotCount(lot);
|
count += inventory.second->GetLotCount(lot);
|
||||||
}
|
}
|
||||||
@ -305,21 +305,35 @@ bool InventoryComponent::RemoveItem(const LOT lot, const uint32_t count, eInvent
|
|||||||
LOG("Attempted to remove 0 of item (%i) from the inventory!", lot);
|
LOG("Attempted to remove 0 of item (%i) from the inventory!", lot);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (inventoryType == INVALID) inventoryType = Inventory::FindInventoryTypeForLot(lot);
|
if (inventoryType != eInventoryType::ALL) {
|
||||||
auto* inventory = GetInventory(inventoryType);
|
if (inventoryType == INVALID) inventoryType = Inventory::FindInventoryTypeForLot(lot);
|
||||||
if (!inventory) return false;
|
auto* inventory = GetInventory(inventoryType);
|
||||||
|
if (!inventory) return false;
|
||||||
|
|
||||||
auto left = std::min<uint32_t>(count, inventory->GetLotCount(lot));
|
auto left = std::min<uint32_t>(count, inventory->GetLotCount(lot));
|
||||||
if (left != count) return false;
|
if (left != count) return false;
|
||||||
|
|
||||||
while (left > 0) {
|
while (left > 0) {
|
||||||
auto* item = FindItemByLot(lot, inventoryType, false, ignoreBound);
|
auto* item = FindItemByLot(lot, inventoryType, false, ignoreBound);
|
||||||
if (!item) break;
|
if (!item) break;
|
||||||
const auto delta = std::min<uint32_t>(left, item->GetCount());
|
const auto delta = std::min<uint32_t>(left, item->GetCount());
|
||||||
item->SetCount(item->GetCount() - delta, silent);
|
item->SetCount(item->GetCount() - delta, silent);
|
||||||
left -= delta;
|
left -= delta;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
auto left = count;
|
||||||
|
for (const auto& inventory : m_Inventories | std::views::values) {
|
||||||
|
while (left > 0 && inventory->GetLotCount(lot) > 0) {
|
||||||
|
auto* item = inventory->FindItemByLot(lot, false, ignoreBound);
|
||||||
|
if (!item) break;
|
||||||
|
const auto delta = std::min<uint32_t>(item->GetCount(), left);
|
||||||
|
item->SetCount(item->GetCount() - delta, silent);
|
||||||
|
left -= delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return left == 0;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType inventory, const uint32_t count, const bool showFlyingLot, bool isModMoveAndEquip, const bool ignoreEquipped, const int32_t preferredSlot) {
|
void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType inventory, const uint32_t count, const bool showFlyingLot, bool isModMoveAndEquip, const bool ignoreEquipped, const int32_t preferredSlot) {
|
||||||
@ -1318,8 +1332,8 @@ BehaviorSlot InventoryComponent::FindBehaviorSlot(const eItemType type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InventoryComponent::IsTransferInventory(eInventoryType type) {
|
bool InventoryComponent::IsTransferInventory(eInventoryType type, bool includeVault) {
|
||||||
return type == VENDOR_BUYBACK || type == VAULT_ITEMS || type == VAULT_MODELS || type == TEMP_ITEMS || type == TEMP_MODELS || type == MODELS_IN_BBB;
|
return type == VENDOR_BUYBACK || (includeVault && (type == VAULT_ITEMS || type == VAULT_MODELS)) || type == TEMP_ITEMS || type == TEMP_MODELS || type == MODELS_IN_BBB;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t InventoryComponent::FindSkill(const LOT lot) {
|
uint32_t InventoryComponent::FindSkill(const LOT lot) {
|
||||||
|
@ -100,7 +100,7 @@ public:
|
|||||||
* @param lot the lot to search for
|
* @param lot the lot to search for
|
||||||
* @return the amount of items this entity possesses of the specified lot
|
* @return the amount of items this entity possesses of the specified lot
|
||||||
*/
|
*/
|
||||||
uint32_t GetLotCountNonTransfer(LOT lot) const;
|
uint32_t GetLotCountNonTransfer(LOT lot, bool includeVault = true) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the items that are currently equipped by this entity
|
* Returns the items that are currently equipped by this entity
|
||||||
@ -373,7 +373,7 @@ public:
|
|||||||
* @param type the inventory type to check
|
* @param type the inventory type to check
|
||||||
* @return if the inventory type is a temp inventory
|
* @return if the inventory type is a temp inventory
|
||||||
*/
|
*/
|
||||||
static bool IsTransferInventory(eInventoryType type);
|
static bool IsTransferInventory(eInventoryType type, bool includeVault = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the skill related to the passed LOT from the ObjectSkills table
|
* Finds the skill related to the passed LOT from the ObjectSkills table
|
||||||
|
@ -8,16 +8,11 @@ void AmTeapotServer::OnUse(Entity* self, Entity* user) {
|
|||||||
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
||||||
if (!inventoryComponent) return;
|
if (!inventoryComponent) return;
|
||||||
|
|
||||||
auto* blueFlowerItem = inventoryComponent->FindItemByLot(BLUE_FLOWER_LEAVES, eInventoryType::ITEMS);
|
|
||||||
if (!blueFlowerItem) {
|
|
||||||
blueFlowerItem = inventoryComponent->FindItemByLot(BLUE_FLOWER_LEAVES, eInventoryType::VAULT_ITEMS);
|
|
||||||
if (!blueFlowerItem) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The client allows you to use the teapot only if you have a stack of 10 leaves in some inventory somewhere.
|
// The client allows you to use the teapot only if you have a stack of 10 leaves in some inventory somewhere.
|
||||||
if (blueFlowerItem->GetCount() >= 10) {
|
if (inventoryComponent->GetLotCountNonTransfer(BLUE_FLOWER_LEAVES, false) >= 10) {
|
||||||
blueFlowerItem->SetCount(blueFlowerItem->GetCount() - 10);
|
inventoryComponent->RemoveItem(BLUE_FLOWER_LEAVES, 10, eInventoryType::ALL);
|
||||||
inventoryComponent->AddItem(WU_S_IMAGINATION_TEA, 1);
|
inventoryComponent->AddItem(WU_S_IMAGINATION_TEA, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user