[Quest API] Add Merchant Events to Perl/Lua. (#2452)

- Add EVENT_ALT_CURRENCY_MERCHANT_BUY to Perl/Lua.
- Add EVENT_ALT_CURRENCY_MERCHANT_SELL to Perl/Lua.
- Add EVENT_MERCHANT_BUY to Perl/Lua.
- Add EVENT_MERCHANT_SELL to Perl/Lua.

This will allow server operators to track or do specific stuff based on if a person buys X item from Y NPC or whatever.
This commit is contained in:
Kinglykrab
2022-09-28 04:02:42 -04:00
committed by GitHub
parent e883703b2f
commit 90406e0328
7 changed files with 126 additions and 3 deletions
+41
View File
@@ -2575,6 +2575,16 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app)
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, CharacterID(), event_desc);
}
const auto& export_string = fmt::format(
"{} {} {} {} {}",
alt_cur_id,
tar->GetNPCTypeID(),
tar->MerchantType,
item->ID,
cost
);
parse->EventPlayer(EVENT_ALT_CURRENCY_MERCHANT_BUY, this, export_string, 0);
AddAlternateCurrencyValue(alt_cur_id, -((int32)cost));
int16 charges = 1;
if (item->MaxCharges != 0)
@@ -2730,6 +2740,16 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app)
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, CharacterID(), event_desc);
}
const auto& export_string = fmt::format(
"{} {} {} {} {}",
alt_cur_id,
tar->GetNPCTypeID(),
tar->MerchantType,
item->ID,
cost
);
parse->EventPlayer(EVENT_ALT_CURRENCY_MERCHANT_SELL, this, export_string, 0);
FastQueuePacket(&outapp);
AddAlternateCurrencyValue(alt_cur_id, cost);
Save(1);
@@ -13222,6 +13242,16 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
if (RuleB(EventLog, RecordBuyFromMerchant))
LogMerchant(this, tmp, mpo->quantity, mpo->price, item, true);
const auto& export_string = fmt::format(
"{} {} {} {} {}",
tmp->GetNPCTypeID(),
tmp->CastToNPC()->MerchantType,
item_id,
mpo->quantity,
mpo->price
);
parse->EventPlayer(EVENT_MERCHANT_BUY, this, export_string, 0);
if ((RuleB(Character, EnableDiscoveredItems)))
{
if (!GetGM() && !IsDiscovered(item_id))
@@ -13379,6 +13409,17 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
}
// end QS code
const auto& export_string = fmt::format(
"{} {} {} {} {}",
vendor->GetNPCTypeID(),
vendor->CastToNPC()->MerchantType,
itemid,
mp->quantity,
price
);
parse->EventPlayer(EVENT_MERCHANT_SELL, this, export_string, 0);
// Now remove the item from the player, this happens regardless of outcome
DeleteItemInInventory(
mp->itemslot,