diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 4ccb0747e..8d089b182 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -118,6 +118,7 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_SPAWN_ZONE", "EVENT_DEATH_ZONE", "EVENT_USE_SKILL", + "EVENT_COMBINE_VALIDATE", }; PerlembParser::PerlembParser() : perl(nullptr) { @@ -1440,6 +1441,24 @@ void PerlembParser::ExportEventVariables(std::string &package_name, QuestEventID ExportVar(package_name.c_str(), "skill_level", sep.arg[1]); break; } + case EVENT_COMBINE_VALIDATE: { + Seperator sep(data); + ExportVar(package_name.c_str(), "recipe_id", extradata); + ExportVar(package_name.c_str(), "validate_type", sep.arg[0]); + + std::string zone_id = "-1"; + std::string tradeskill_id = "-1"; + if (strcmp(sep.arg[0], "check_zone") == 0) { + zone_id = sep.arg[1]; + } + else if (strcmp(sep.arg[0], "check_tradeskill") == 0) { + tradeskill_id = sep.arg[1]; + } + + ExportVar(package_name.c_str(), "zone_id", zone_id.c_str()); + ExportVar(package_name.c_str(), "tradeskill_id", tradeskill_id.c_str()); + break; + } default: { break; diff --git a/zone/event_codes.h b/zone/event_codes.h index bb623f041..4560cc767 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -86,6 +86,7 @@ typedef enum { EVENT_SPAWN_ZONE, EVENT_DEATH_ZONE, EVENT_USE_SKILL, + EVENT_COMBINE_VALIDATE, _LargestEventID } QuestEventID; diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index 7c7242e4c..437bc5121 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -123,7 +123,8 @@ const char *LuaEvents[_LargestEventID] = { "event_tick", "event_spawn_zone", "event_death_zone", - "event_use_skill" + "event_use_skill", + "event_combine_validate" }; extern Zone *zone; @@ -206,6 +207,7 @@ LuaParser::LuaParser() { PlayerArgumentDispatch[EVENT_RESPAWN] = handle_player_respawn; PlayerArgumentDispatch[EVENT_UNHANDLED_OPCODE] = handle_player_packet; PlayerArgumentDispatch[EVENT_USE_SKILL] = handle_player_use_skill; + PlayerArgumentDispatch[EVENT_COMBINE_VALIDATE] = handle_player_combine_validate; ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click; ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click; diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index e70c5de9f..f4f1dd3af 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -514,6 +514,31 @@ void handle_player_use_skill(QuestInterface *parse, lua_State* L, Client* client lua_setfield(L, -2, "skill_level"); } +void handle_player_combine_validate(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, + std::vector* extra_pointers) { + Seperator sep(data.c_str()); + lua_pushinteger(L, extra_data); + lua_setfield(L, -2, "recipe_id"); + + lua_pushstring(L, sep.arg[0]); + lua_setfield(L, -2, "validate_type"); + + int zone_id = -1; + int tradeskill_id = -1; + if (strcmp(sep.arg[0], "check_zone") == 0) { + zone_id = std::stoi(sep.arg[1]); + } + else if (strcmp(sep.arg[0], "check_tradeskill") == 0) { + tradeskill_id = std::stoi(sep.arg[1]); + } + + lua_pushinteger(L, zone_id); + lua_setfield(L, -2, "zone_id"); + + lua_pushinteger(L, tradeskill_id); + lua_setfield(L, -2, "tradeskill_id"); +} + //Item void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQEmu::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data, std::vector *extra_pointers) { diff --git a/zone/lua_parser_events.h b/zone/lua_parser_events.h index 44ba9b72f..0054b31e1 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -97,6 +97,8 @@ void handle_player_null(QuestInterface *parse, lua_State* L, Client* client, std std::vector *extra_pointers); void handle_player_use_skill(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector *extra_pointers); +void handle_player_combine_validate(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, + std::vector* extra_pointers); //Item void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQEmu::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data, diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 5113ad4b6..b4451119f 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -392,6 +392,15 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob } } + // final check for any additional quest requirements .. "check_zone" in this case - exported as variable [validate_type] + if (parse->EventPlayer(EVENT_COMBINE_VALIDATE, user, fmt::format("check_zone {}", zone->GetZoneID()), spec.recipe_id) != 0) { + user->Message(Chat::Emote, "You cannot make this combine because the location requirement has not been met."); + auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0); + user->QueuePacket(outapp); + safe_delete(outapp); + return; + } + // Send acknowledgement packets to client auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0); user->QueuePacket(outapp);