account for consumables

This commit is contained in:
Aaron Kimbrell
2025-09-03 04:16:35 -05:00
parent 14716185fb
commit e15dfd4353
2 changed files with 11 additions and 19 deletions

View File

@@ -1168,16 +1168,12 @@ LOT InventoryComponent::GetConsumable() const {
void InventoryComponent::AddItemSkills(const LOT lot) { void InventoryComponent::AddItemSkills(const LOT lot) {
const auto info = Inventory::FindItemComponent(lot); const auto info = Inventory::FindItemComponent(lot);
const auto slot = FindBehaviorSlot(info.equipLocation); const auto slot = FindBehaviorSlot(info.equipLocation, static_cast<eItemType>(info.itemType));
if (slot == BehaviorSlot::Invalid) { if (slot == BehaviorSlot::Invalid) return;
return;
}
const auto index = m_Skills.find(slot); const auto index = m_Skills.find(slot);
const auto skill = FindSkill(lot); const auto skill = FindSkill(lot);
SetSkill(slot, skill); SetSkill(slot, skill);
} }
@@ -1203,17 +1199,11 @@ void InventoryComponent::FixInvisibleItems() {
void InventoryComponent::RemoveItemSkills(const LOT lot) { void InventoryComponent::RemoveItemSkills(const LOT lot) {
const auto info = Inventory::FindItemComponent(lot); const auto info = Inventory::FindItemComponent(lot);
const auto slot = FindBehaviorSlot(info.equipLocation); const auto slot = FindBehaviorSlot(info.equipLocation, static_cast<eItemType>(info.itemType));
if (slot == BehaviorSlot::Invalid) return;
if (slot == BehaviorSlot::Invalid) {
return;
}
const auto index = m_Skills.find(slot); const auto index = m_Skills.find(slot);
if (index == m_Skills.end()) return;
if (index == m_Skills.end()) {
return;
}
const auto old = index->second; const auto old = index->second;
@@ -1223,7 +1213,6 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) {
if (slot == BehaviorSlot::Primary) { if (slot == BehaviorSlot::Primary) {
m_Skills.insert_or_assign(BehaviorSlot::Primary, 1); m_Skills.insert_or_assign(BehaviorSlot::Primary, 1);
GameMessages::SendAddSkill(m_Parent, 1, BehaviorSlot::Primary); GameMessages::SendAddSkill(m_Parent, 1, BehaviorSlot::Primary);
} }
} }
@@ -1315,8 +1304,10 @@ void InventoryComponent::RemoveDatabasePet(LWOOBJID id) {
m_Pets.erase(id); m_Pets.erase(id);
} }
BehaviorSlot InventoryComponent::FindBehaviorSlot(const std::string& equipLocation) { BehaviorSlot InventoryComponent::FindBehaviorSlot(const std::string& equipLocation, const eItemType itemType) {
if (equipLocation == "special_r") { if (itemType == eItemType::CONSUMABLE) {
return BehaviorSlot::Consumable;
} else if (equipLocation == "special_r") {
return BehaviorSlot::Primary; return BehaviorSlot::Primary;
} else if (equipLocation == "hair") { } else if (equipLocation == "hair") {
return BehaviorSlot::Head; return BehaviorSlot::Head;

View File

@@ -364,9 +364,10 @@ public:
/** /**
* Returns the behavior slot for the given equipment location * Returns the behavior slot for the given equipment location
* @param equipLocation the equipment location to find the behavior slot for * @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 * @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 * Checks if the inventory type is a temp inventory