diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index c5b4bec3..56bf26d8 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -1043,7 +1043,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) UpdateSlot(item->GetInfo().equipLocation, { item->GetId(), item->GetLot(), item->GetCount(), item->GetSlot() }); - if (item->GetParent() == LWOOBJID_EMPTY) ApplyBuff(item->GetLot()); + ApplyBuff(item); AddItemSkills(item->GetLot()); @@ -1071,7 +1071,7 @@ void InventoryComponent::UnEquipItem(Item* item) set->OnUnEquip(lot); } - if (item->GetParent() == LWOOBJID_EMPTY) RemoveBuff(item->GetLot()); + RemoveBuff(item); RemoveItemSkills(item->GetLot()); @@ -1089,9 +1089,9 @@ void InventoryComponent::UnEquipItem(Item* item) } } -void InventoryComponent::ApplyBuff(const LOT lot) const +void InventoryComponent::ApplyBuff(Item* item) const { - const auto buffs = FindBuffs(lot, true); + const auto buffs = FindBuffs(item, true); for (const auto buff : buffs) { @@ -1099,9 +1099,9 @@ void InventoryComponent::ApplyBuff(const LOT lot) const } } -void InventoryComponent::RemoveBuff(const LOT lot) const +void InventoryComponent::RemoveBuff(Item* item) const { - const auto buffs = FindBuffs(lot, false); + const auto buffs = FindBuffs(item, false); for (const auto buff : buffs) { @@ -1418,18 +1418,18 @@ uint32_t InventoryComponent::FindSkill(const LOT lot) return 0; } -std::vector InventoryComponent::FindBuffs(const LOT lot, bool castOnEquip) const +std::vector InventoryComponent::FindBuffs(Item* item, bool castOnEquip) const { + std::vector buffs; + if (item == nullptr) return buffs; auto* table = CDClientManager::Instance()->GetTable("ObjectSkills"); auto* behaviors = CDClientManager::Instance()->GetTable("SkillBehavior"); const auto results = table->Query([=](const CDObjectSkills& entry) { - return entry.objectTemplate == static_cast(lot); + return entry.objectTemplate == static_cast(item->GetLot()); }); - std::vector buffs; - auto* missions = static_cast(m_Parent->GetComponent(COMPONENT_TYPE_MISSION)); for (const auto& result : results) @@ -1449,8 +1449,8 @@ std::vector InventoryComponent::FindBuffs(const LOT lot, bool castOnEq { missions->Progress(MissionTaskType::MISSION_TASK_TYPE_SKILL, result.skillID); } - - buffs.push_back(static_cast(entry.behaviorID)); + // If item is not a proxy, add its buff to the added buffs. + if (item->GetParent() == LWOOBJID_EMPTY) buffs.push_back(static_cast(entry.behaviorID)); } } @@ -1531,7 +1531,7 @@ std::vector InventoryComponent::GenerateProxies(Item* parent) auto* inventory = GetInventory(ITEM_SETS); - auto* proxy = new Item(lot, inventory, inventory->FindEmptySlot(), 1, {}, parent->GetId(), false, parent->GetId()); + auto* proxy = new Item(lot, inventory, inventory->FindEmptySlot(), 1, {}, parent->GetId(), false); EquipItem(proxy); diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 22143802..0a4cfdb3 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -193,15 +193,15 @@ public: /** * Adds a buff related to equipping a lot to the entity - * @param lot the lot to find buffs for + * @param item the item to find buffs for */ - void ApplyBuff(LOT lot) const; + void ApplyBuff(Item* item) const; /** * Removes buffs related to equipping a lot from the entity - * @param lot the lot to find buffs for + * @param item the item to find buffs for */ - void RemoveBuff(LOT lot) const; + void RemoveBuff(Item* item) const; /** * Saves the equipped items into a temp state @@ -240,11 +240,11 @@ public: /** * Finds all the buffs related to a lot - * @param lot the lot to get the buffs for + * @param item the item to get the buffs for * @param castOnEquip if true, the skill missions for these buffs will be progressed * @return the buffs related to the specified lot */ - std::vector FindBuffs(LOT lot, bool castOnEquip) const; + std::vector FindBuffs(Item* item, bool castOnEquip) const; /** * Initializes the equipped items with a list of items