From d64f2e40c5c8017a182bae51bd13d7e36c2b64b4 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Sun, 4 Jun 2017 19:57:21 -0400 Subject: [PATCH] Implement EVENT_USE_SKILL in Perl/Lua. - Exports skill_id and skill_level in Perl/Lua whenever a skill is used (bash, kick, taunt, etc.) --- zone/client.cpp | 4 +++- zone/embparser.cpp | 7 +++++++ zone/event_codes.h | 1 + zone/lua_general.cpp | 3 ++- zone/lua_parser.cpp | 4 +++- zone/lua_parser_events.cpp | 9 +++++++++ zone/lua_parser_events.h | 2 ++ 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 5f35c6916..741b41e72 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -2337,7 +2337,9 @@ bool Client::CheckIncreaseSkill(EQEmu::skills::SkillType skillid, Mob *against_w return false; int skillval = GetRawSkill(skillid); int maxskill = GetMaxSkillAfterSpecializationRules(skillid, MaxSkill(skillid)); - + char buffer[24] = { 0 }; + snprintf(buffer, 23, "%d %d", skillid, skillval); + parse->EventPlayer(EVENT_USE_SKILL, this, buffer, 0); if(against_who) { if(against_who->GetSpecialAbility(IMMUNE_AGGRO) || against_who->IsClient() || diff --git a/zone/embparser.cpp b/zone/embparser.cpp index f76c2ea6a..80f6ace11 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -117,6 +117,7 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_TICK", "EVENT_SPAWN_ZONE", "EVENT_DEATH_ZONE", + "EVENT_USE_SKILL", }; PerlembParser::PerlembParser() : perl(nullptr) { @@ -1441,6 +1442,12 @@ void PerlembParser::ExportEventVariables(std::string &package_name, QuestEventID ExportVar(package_name.c_str(), "killed_npc_id", sep.arg[4]); break; } + case EVENT_USE_SKILL:{ + Seperator sep(data); + ExportVar(package_name.c_str(), "skill_id", sep.arg[0]); + ExportVar(package_name.c_str(), "skill_level", sep.arg[1]); + break; + } default: { break; diff --git a/zone/event_codes.h b/zone/event_codes.h index 1b0e18505..bb623f041 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -85,6 +85,7 @@ typedef enum { EVENT_TICK, EVENT_SPAWN_ZONE, EVENT_DEATH_ZONE, + EVENT_USE_SKILL, _LargestEventID } QuestEventID; diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index bc6205c85..1d71fd2f3 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1738,7 +1738,8 @@ luabind::scope lua_register_events() { luabind::value("unhandled_opcode", static_cast(EVENT_UNHANDLED_OPCODE)), luabind::value("tick", static_cast(EVENT_TICK)), luabind::value("spawn_zone", static_cast(EVENT_SPAWN_ZONE)), - luabind::value("death_zone", static_cast(EVENT_DEATH_ZONE)) + luabind::value("death_zone", static_cast(EVENT_DEATH_ZONE)), + luabind::value("use_skill", static_cast(EVENT_USE_SKILL)) ]; } diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index 92f0adbea..edd4d71db 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -120,7 +120,8 @@ const char *LuaEvents[_LargestEventID] = { "event_unhandled_opcode", "event_tick", "event_spawn_zone", - "event_death_zone" + "event_death_zone", + "event_use_skill" }; extern Zone *zone; @@ -202,6 +203,7 @@ LuaParser::LuaParser() { PlayerArgumentDispatch[EVENT_LEAVE_AREA] = handle_player_area; PlayerArgumentDispatch[EVENT_RESPAWN] = handle_player_respawn; PlayerArgumentDispatch[EVENT_UNHANDLED_OPCODE] = handle_player_packet; + PlayerArgumentDispatch[EVENT_USE_SKILL] = handle_player_use_skill; 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 f01af5a6d..e70c5de9f 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -505,6 +505,15 @@ 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) { + Seperator sep(data.c_str()); + lua_pushinteger(L, std::stoi(sep.arg[0])); + lua_setfield(L, -2, "skill_id"); + + lua_pushinteger(L, std::stoi(sep.arg[1])); + lua_setfield(L, -2, "skill_level"); +} + //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 42315ed0b..44ba9b72f 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -95,6 +95,8 @@ void handle_player_packet(QuestInterface *parse, lua_State* L, Client* client, s std::vector *extra_pointers); void handle_player_null(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data, 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); //Item void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQEmu::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data,