From b459790b2ff299f3beae39df84dc0edaad1f06fa Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:24:06 -0700 Subject: [PATCH 1/3] Fixed mission progression --- dGame/dComponents/InventoryComponent.cpp | 26 ++++++++++++------------ dGame/dComponents/InventoryComponent.h | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) 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..f754a7fb 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -195,13 +195,13 @@ public: * Adds a buff related to equipping a lot to the entity * @param lot the lot 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 */ - void RemoveBuff(LOT lot) const; + void RemoveBuff(Item* item) const; /** * Saves the equipped items into a temp state @@ -244,7 +244,7 @@ public: * @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 From e43517efe66f73bec80f2fd7744d8d245480a53c Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:28:21 -0700 Subject: [PATCH 2/3] comments --- dGame/dComponents/InventoryComponent.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index f754a7fb..43fdb084 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -193,13 +193,13 @@ 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(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(Item* item) const; From a7cd2f4d9bd1cf0420d29b95031562f62487c3f7 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:37:05 -0700 Subject: [PATCH 3/3] comments --- dGame/dComponents/InventoryComponent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 43fdb084..0a4cfdb3 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -240,7 +240,7 @@ 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 */