mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[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:
parent
e883703b2f
commit
90406e0328
@ -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,
|
||||
|
||||
@ -154,7 +154,11 @@ const char *QuestEventSubroutines[_LargestEventID] = {
|
||||
"EVENT_EQUIP_ITEM_CLIENT",
|
||||
"EVENT_UNEQUIP_ITEM_CLIENT",
|
||||
"EVENT_SKILL_UP",
|
||||
"EVENT_LANGUAGE_SKILL_UP"
|
||||
"EVENT_LANGUAGE_SKILL_UP",
|
||||
"EVENT_ALT_CURRENCY_MERCHANT_BUY",
|
||||
"EVENT_ALT_CURRENCY_MERCHANT_SELL",
|
||||
"EVENT_MERCHANT_BUY",
|
||||
"EVENT_MERCHANT_SELL"
|
||||
};
|
||||
|
||||
PerlembParser::PerlembParser() : perl(nullptr)
|
||||
@ -1708,6 +1712,28 @@ void PerlembParser::ExportEventVariables(
|
||||
break;
|
||||
}
|
||||
|
||||
case EVENT_ALT_CURRENCY_MERCHANT_BUY:
|
||||
case EVENT_ALT_CURRENCY_MERCHANT_SELL: {
|
||||
Seperator sep(data);
|
||||
ExportVar(package_name.c_str(), "currency_id", sep.arg[0]);
|
||||
ExportVar(package_name.c_str(), "npc_id", sep.arg[1]);
|
||||
ExportVar(package_name.c_str(), "merchant_id", sep.arg[2]);
|
||||
ExportVar(package_name.c_str(), "item_id", sep.arg[3]);
|
||||
ExportVar(package_name.c_str(), "item_cost", sep.arg[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case EVENT_MERCHANT_BUY:
|
||||
case EVENT_MERCHANT_SELL: {
|
||||
Seperator sep(data);
|
||||
ExportVar(package_name.c_str(), "npc_id", sep.arg[0]);
|
||||
ExportVar(package_name.c_str(), "merchant_id", sep.arg[1]);
|
||||
ExportVar(package_name.c_str(), "item_id", sep.arg[2]);
|
||||
ExportVar(package_name.c_str(), "item_quantity", sep.arg[3]);
|
||||
ExportVar(package_name.c_str(), "item_cost", sep.arg[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -98,6 +98,10 @@ typedef enum {
|
||||
EVENT_UNEQUIP_ITEM_CLIENT,
|
||||
EVENT_SKILL_UP,
|
||||
EVENT_LANGUAGE_SKILL_UP,
|
||||
EVENT_ALT_CURRENCY_MERCHANT_BUY,
|
||||
EVENT_ALT_CURRENCY_MERCHANT_SELL,
|
||||
EVENT_MERCHANT_BUY,
|
||||
EVENT_MERCHANT_SELL,
|
||||
_LargestEventID
|
||||
} QuestEventID;
|
||||
|
||||
|
||||
@ -4283,7 +4283,11 @@ luabind::scope lua_register_events() {
|
||||
luabind::value("equip_item_client", static_cast<int>(EVENT_EQUIP_ITEM_CLIENT)),
|
||||
luabind::value("unequip_item_client", static_cast<int>(EVENT_UNEQUIP_ITEM_CLIENT)),
|
||||
luabind::value("skill_up", static_cast<int>(EVENT_SKILL_UP)),
|
||||
luabind::value("language_skill_up", static_cast<int>(EVENT_LANGUAGE_SKILL_UP))
|
||||
luabind::value("language_skill_up", static_cast<int>(EVENT_LANGUAGE_SKILL_UP)),
|
||||
luabind::value("alt_currency_merchant_buy", static_cast<int>(EVENT_ALT_CURRENCY_MERCHANT_BUY)),
|
||||
luabind::value("alt_currency_merchant_sell", static_cast<int>(EVENT_ALT_CURRENCY_MERCHANT_SELL)),
|
||||
luabind::value("merchant_buy", static_cast<int>(EVENT_MERCHANT_BUY)),
|
||||
luabind::value("merchant_sell", static_cast<int>(EVENT_MERCHANT_SELL))
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +140,11 @@ const char *LuaEvents[_LargestEventID] = {
|
||||
"event_equip_item_client",
|
||||
"event_unequip_item_client",
|
||||
"event_skill_up",
|
||||
"event_language_skill_up"
|
||||
"event_language_skill_up",
|
||||
"event_alt_currency_merchant_buy",
|
||||
"event_alt_currency_merchant_sell",
|
||||
"event_merchant_buy",
|
||||
"event_merchant_sell"
|
||||
};
|
||||
|
||||
extern Zone *zone;
|
||||
@ -236,6 +240,10 @@ LuaParser::LuaParser() {
|
||||
PlayerArgumentDispatch[EVENT_UNEQUIP_ITEM_CLIENT] = handle_player_equip_item;
|
||||
PlayerArgumentDispatch[EVENT_SKILL_UP] = handle_player_skill_up;
|
||||
PlayerArgumentDispatch[EVENT_LANGUAGE_SKILL_UP] = handle_player_skill_up;
|
||||
PlayerArgumentDispatch[EVENT_ALT_CURRENCY_MERCHANT_BUY] = handle_player_alt_currency_merchant;
|
||||
PlayerArgumentDispatch[EVENT_ALT_CURRENCY_MERCHANT_SELL] = handle_player_alt_currency_merchant;
|
||||
PlayerArgumentDispatch[EVENT_MERCHANT_BUY] = handle_player_merchant;
|
||||
PlayerArgumentDispatch[EVENT_MERCHANT_SELL] = handle_player_merchant;
|
||||
|
||||
ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click;
|
||||
ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click;
|
||||
|
||||
@ -855,4 +855,40 @@ void handle_player_language_skill_up(QuestInterface* parse, lua_State* L, Client
|
||||
lua_setfield(L, -2, "skill_max");
|
||||
}
|
||||
|
||||
void handle_player_alt_currency_merchant(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector<std::any>* extra_pointers) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_setfield(L, -2, "currency_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_setfield(L, -2, "npc_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_setfield(L, -2, "merchant_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_setfield(L, -2, "item_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[4]));
|
||||
lua_setfield(L, -2, "item_cost");
|
||||
}
|
||||
|
||||
void handle_player_merchant(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector<std::any>* extra_pointers) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_setfield(L, -2, "npc_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_setfield(L, -2, "merchant_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_setfield(L, -2, "item_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_setfield(L, -2, "item_quantity");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[4]));
|
||||
lua_setfield(L, -2, "item_cost");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -119,6 +119,10 @@ void handle_player_skill_up(QuestInterface* parse, lua_State* L, Client* client,
|
||||
std::vector<std::any>* extra_pointers);
|
||||
void handle_player_language_skill_up(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers);
|
||||
void handle_player_alt_currency_merchant(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers);
|
||||
void handle_player_merchant(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any>* extra_pointers);
|
||||
|
||||
//Item
|
||||
void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQ::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user