Fixed mission progression

This commit is contained in:
EmosewaMC 2022-03-27 15:24:06 -07:00
parent 66b7c6522e
commit b459790b2f
2 changed files with 16 additions and 16 deletions

View File

@ -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<uint32_t> InventoryComponent::FindBuffs(const LOT lot, bool castOnEquip) const
std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip) const
{
std::vector<uint32_t> buffs;
if (item == nullptr) return buffs;
auto* table = CDClientManager::Instance()->GetTable<CDObjectSkillsTable>("ObjectSkills");
auto* behaviors = CDClientManager::Instance()->GetTable<CDSkillBehaviorTable>("SkillBehavior");
const auto results = table->Query([=](const CDObjectSkills& entry)
{
return entry.objectTemplate == static_cast<unsigned int>(lot);
return entry.objectTemplate == static_cast<unsigned int>(item->GetLot());
});
std::vector<uint32_t> buffs;
auto* missions = static_cast<MissionComponent*>(m_Parent->GetComponent(COMPONENT_TYPE_MISSION));
for (const auto& result : results)
@ -1449,8 +1449,8 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(const LOT lot, bool castOnEq
{
missions->Progress(MissionTaskType::MISSION_TASK_TYPE_SKILL, result.skillID);
}
buffs.push_back(static_cast<uint32_t>(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<uint32_t>(entry.behaviorID));
}
}
@ -1531,7 +1531,7 @@ std::vector<Item*> 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);

View File

@ -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<uint32_t> FindBuffs(LOT lot, bool castOnEquip) const;
std::vector<uint32_t> FindBuffs(Item* item, bool castOnEquip) const;
/**
* Initializes the equipped items with a list of items