From 8eef7bb283d428f6f789c0ff14ef647a5265a821 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 19 Sep 2021 16:22:51 -0400 Subject: [PATCH] [Quest API] Add EVENT_COMBINE to Perl and Lua. (#1536) - Exports $container_slot in Perl. - Exports e.container_slot in Lua. Allows you to perform events when clicking combine in a tradeskill container. --- zone/embparser.cpp | 6 ++++++ zone/event_codes.h | 1 + zone/lua_parser.cpp | 2 ++ zone/lua_parser_events.cpp | 5 +++++ zone/lua_parser_events.h | 2 ++ zone/tradeskills.cpp | 8 ++++++++ 6 files changed, 24 insertions(+) diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 535e3c356..f4ea70356 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -122,6 +122,7 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_BOT_COMMAND", "EVENT_WARP", "EVENT_TEST_BUFF", + "EVENT_COMBINE", "EVENT_CONSIDER", "EVENT_CONSIDER_CORPSE" }; @@ -1657,6 +1658,11 @@ void PerlembParser::ExportEventVariables( break; } + case EVENT_COMBINE: { + ExportVar(package_name.c_str(), "container_slot", std::stoi(data)); + break; + } + default: { break; } diff --git a/zone/event_codes.h b/zone/event_codes.h index 87143d11e..4a915ce9c 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -90,6 +90,7 @@ typedef enum { EVENT_BOT_COMMAND, EVENT_WARP, EVENT_TEST_BUFF, + EVENT_COMBINE, EVENT_CONSIDER, EVENT_CONSIDER_CORPSE, _LargestEventID diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index 3a01c643f..641f24040 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -133,6 +133,7 @@ const char *LuaEvents[_LargestEventID] = { "event_bot_command", "event_warp", "event_test_buff", + "event_combine", "event_consider", "event_consider_corpse" }; @@ -222,6 +223,7 @@ LuaParser::LuaParser() { PlayerArgumentDispatch[EVENT_COMBINE_VALIDATE] = handle_player_combine_validate; PlayerArgumentDispatch[EVENT_BOT_COMMAND] = handle_player_bot_command; PlayerArgumentDispatch[EVENT_WARP] = handle_player_warp; + PlayerArgumentDispatch[EVENT_COMBINE] = handle_player_quest_combine; PlayerArgumentDispatch[EVENT_CONSIDER] = handle_player_consider; PlayerArgumentDispatch[EVENT_CONSIDER_CORPSE] = handle_player_consider_corpse; diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 4a0c154ca..0734c9e19 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -573,6 +573,11 @@ void handle_player_warp(QuestInterface* parse, lua_State* L, Client* client, std lua_setfield(L, -2, "from_z"); } +void handle_player_quest_combine(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers) { + lua_pushinteger(L, std::stoi(data)); + lua_setfield(L, -2, "container_slot"); + } + void handle_player_consider(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers) { lua_pushinteger(L, std::stoi(data)); lua_setfield(L, -2, "entity_id"); diff --git a/zone/lua_parser_events.h b/zone/lua_parser_events.h index 2b6512c15..850116075 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -105,6 +105,8 @@ void handle_player_bot_command(QuestInterface *parse, lua_State* L, Client* clie std::vector *extra_pointers); void handle_player_warp(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers); +void handle_player_quest_combine(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, + std::vector* extra_pointers); void handle_player_consider(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers); void handle_player_consider_corpse(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 4beaedf52..7e0ce5857 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -375,6 +375,14 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob } DBTradeskillRecipe_Struct spec; + + if (parse->EventPlayer(EVENT_COMBINE, user, std::to_string(in_combine->container_slot), 0) == 1) { + auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0); + user->QueuePacket(outapp); + safe_delete(outapp); + return; + } + if (!content_db.GetTradeRecipe(container, c_type, some_id, user->CharacterID(), &spec)) { LogTradeskillsDetail("[HandleCombine] Check 2");