mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
fix: consuming items not decrementing mission progress (#1827)
tested that consuming water no longer leaves a mission unable to be completed
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
#include "eUseItemResponse.h"
|
#include "eUseItemResponse.h"
|
||||||
#include "dZoneManager.h"
|
#include "dZoneManager.h"
|
||||||
#include "ChatPackets.h"
|
#include "ChatPackets.h"
|
||||||
|
#include "MissionComponent.h"
|
||||||
|
#include "eMissionTaskType.h"
|
||||||
|
|
||||||
#include "CDBrickIDTableTable.h"
|
#include "CDBrickIDTableTable.h"
|
||||||
#include "CDObjectSkillsTable.h"
|
#include "CDObjectSkillsTable.h"
|
||||||
@@ -268,9 +270,9 @@ bool Item::IsEquipped() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Item::Consume() {
|
bool Item::Consume() {
|
||||||
auto* skillsTable = CDClientManager::GetTable<CDObjectSkillsTable>();
|
auto* const skillsTable = CDClientManager::GetTable<CDObjectSkillsTable>();
|
||||||
|
|
||||||
auto skills = skillsTable->Query([this](const CDObjectSkills entry) {
|
const auto skills = skillsTable->Query([this](const CDObjectSkills& entry) {
|
||||||
return entry.objectTemplate == static_cast<uint32_t>(lot);
|
return entry.objectTemplate == static_cast<uint32_t>(lot);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -288,7 +290,12 @@ bool Item::Consume() {
|
|||||||
GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success);
|
GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
// Save this because if this is the last item in the inventory
|
||||||
|
// we may delete ourself (lol)
|
||||||
|
const auto myLot = this->lot;
|
||||||
inventory->GetComponent()->RemoveItem(lot, 1);
|
inventory->GetComponent()->RemoveItem(lot, 1);
|
||||||
|
auto* missionComponent = inventory->GetComponent()->GetParent()->GetComponent<MissionComponent>();
|
||||||
|
if (missionComponent) missionComponent->Progress(eMissionTaskType::GATHER, myLot, LWOOBJID_EMPTY, "", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
Reference in New Issue
Block a user