mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
[Quest API] Implement eq.handin() and quest::handin() (#4718)
* [Quest API] Implement eq.handin() and quest::handin() * Fix MQ using new API style
This commit is contained in:
+22
-2
@@ -618,16 +618,36 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
item_list.emplace_back(inst);
|
||||
}
|
||||
|
||||
auto handin_npc = tradingWith->CastToNPC();
|
||||
|
||||
m_external_handin_money_returned = {};
|
||||
m_external_handin_items_returned = {};
|
||||
bool has_aggro = tradingWith->CheckAggro(this);
|
||||
if (parse->HasQuestSub(tradingWith->GetNPCTypeID(), EVENT_TRADE) && !has_aggro) {
|
||||
// This CheckHandin call enables eq.handin and quest::handin to recognize the hand-in context.
|
||||
// It initializes the first hand-in bucket, which is then reused for the EVENT_TRADE subroutine.
|
||||
std::map<std::string, uint32> handin = {
|
||||
{"copper", trade->cp},
|
||||
{"silver", trade->sp},
|
||||
{"gold", trade->gp},
|
||||
{"platinum", trade->pp}
|
||||
};
|
||||
|
||||
for (EQ::ItemInstance *inst: items) {
|
||||
if (!inst || !inst->GetItem()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string item_id = fmt::format("{}", inst->GetItem()->ID);
|
||||
handin[item_id] += inst->GetCharges();
|
||||
}
|
||||
|
||||
handin_npc->CheckHandin(this, handin, {}, items);
|
||||
|
||||
parse->EventNPC(EVENT_TRADE, tradingWith->CastToNPC(), this, "", 0, &item_list);
|
||||
LogNpcHandinDetail("EVENT_TRADE triggered for NPC [{}]", tradingWith->GetNPCTypeID());
|
||||
}
|
||||
|
||||
auto handin_npc = tradingWith->CastToNPC();
|
||||
|
||||
// this is a catch-all return for items that weren't consumed by the EVENT_TRADE subroutine
|
||||
// it's possible we have a quest NPC that doesn't have an EVENT_TRADE subroutine
|
||||
// we can't double fire the ReturnHandinItems() event, so we need to check if it's already been processed from EVENT_TRADE
|
||||
|
||||
Reference in New Issue
Block a user