diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index d4a7a63c..3158c6e3 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -1168,16 +1168,12 @@ LOT InventoryComponent::GetConsumable() const { void InventoryComponent::AddItemSkills(const LOT lot) { const auto info = Inventory::FindItemComponent(lot); - const auto slot = FindBehaviorSlot(info.equipLocation); + const auto slot = FindBehaviorSlot(info.equipLocation, static_cast(info.itemType)); - if (slot == BehaviorSlot::Invalid) { - return; - } + if (slot == BehaviorSlot::Invalid) return; const auto index = m_Skills.find(slot); - const auto skill = FindSkill(lot); - SetSkill(slot, skill); } @@ -1203,17 +1199,11 @@ void InventoryComponent::FixInvisibleItems() { void InventoryComponent::RemoveItemSkills(const LOT lot) { const auto info = Inventory::FindItemComponent(lot); - const auto slot = FindBehaviorSlot(info.equipLocation); - - if (slot == BehaviorSlot::Invalid) { - return; - } + const auto slot = FindBehaviorSlot(info.equipLocation, static_cast(info.itemType)); + if (slot == BehaviorSlot::Invalid) return; const auto index = m_Skills.find(slot); - - if (index == m_Skills.end()) { - return; - } + if (index == m_Skills.end()) return; const auto old = index->second; @@ -1223,7 +1213,6 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) { if (slot == BehaviorSlot::Primary) { m_Skills.insert_or_assign(BehaviorSlot::Primary, 1); - GameMessages::SendAddSkill(m_Parent, 1, BehaviorSlot::Primary); } } @@ -1315,8 +1304,10 @@ void InventoryComponent::RemoveDatabasePet(LWOOBJID id) { m_Pets.erase(id); } -BehaviorSlot InventoryComponent::FindBehaviorSlot(const std::string& equipLocation) { - if (equipLocation == "special_r") { +BehaviorSlot InventoryComponent::FindBehaviorSlot(const std::string& equipLocation, const eItemType itemType) { + if (itemType == eItemType::CONSUMABLE) { + return BehaviorSlot::Consumable; + } else if (equipLocation == "special_r") { return BehaviorSlot::Primary; } else if (equipLocation == "hair") { return BehaviorSlot::Head; diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index a7e9b21e..fd401615 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -364,9 +364,10 @@ public: /** * Returns the behavior slot for the given equipment location * @param equipLocation the equipment location to find the behavior slot for + * @param itemType the type of item to find the behavior slot for, to check for consumables * @return the behavior slot for the given equipment location */ - static BehaviorSlot FindBehaviorSlot(const std::string& equipLocation); + static BehaviorSlot FindBehaviorSlot(const std::string& equipLocation, const eItemType itemType); /** * Checks if the inventory type is a temp inventory