From 358bd60716a152dba6a1d051f14c589fd75fa988 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 6 Apr 2020 01:36:46 -0400 Subject: [PATCH] Add getskillname(skill_id) to Perl/Lua. --- zone/embparser_api.cpp | 17 +++++++++++++++++ zone/lua_general.cpp | 5 +++++ zone/questmgr.cpp | 12 ++++++++++++ zone/questmgr.h | 1 + 4 files changed, 35 insertions(+) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index dfb23ddc8..0ddfb289a 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -838,6 +838,22 @@ XS(XS__getspellname) { XSRETURN(1); } +XS(XS__getskillname); +XS(XS__getskillname) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: quest::getskillname(int skill_id)"); + + dXSTARG; + int skill_id = (int) SvIV(ST(0)); + std::string skill_name = quest_manager.getskillname(skill_id); + + sv_setpv(TARG, skill_name.c_str()); + XSprePUSH; + PUSHTARG; + XSRETURN(1); +} + XS(XS__safemove); XS(XS__safemove) { dXSARGS; @@ -4117,6 +4133,7 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "getgroupidbycharid"), XS__getgroupidbycharid, file); newXS(strcpy(buf, "getraididbycharid"), XS__getraididbycharid, file); newXS(strcpy(buf, "getspellname"), XS__getspellname, file); + newXS(strcpy(buf, "getskillname"), XS__getskillname, file); newXS(strcpy(buf, "getlevel"), XS__getlevel, file); newXS(strcpy(buf, "getplayerburiedcorpsecount"), XS__getplayerburiedcorpsecount, file); newXS(strcpy(buf, "getplayercorpsecount"), XS__getplayercorpsecount, file); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 848348fbf..a3ed7b04a 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -397,6 +397,10 @@ std::string lua_get_spell_name(uint32 spell_id) { return quest_manager.getspellname(spell_id); } +std::string lua_get_skill_name(int skill_id) { + return quest_manager.getskillname(skill_id); +} + void lua_safe_move() { quest_manager.safemove(); } @@ -1673,6 +1677,7 @@ luabind::scope lua_register_general() { luabind::def("repop_zone", &lua_repop_zone), luabind::def("is_disc_tome", &lua_is_disc_tome), luabind::def("get_spell_name", (std::string(*)(uint32))&lua_get_spell_name), + luabind::def("get_skill_name", (std::string(*)(int))&lua_get_skill_name), luabind::def("safe_move", &lua_safe_move), luabind::def("rain", &lua_rain), luabind::def("snow", &lua_snow), diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 0a61361c6..6a568466e 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -915,6 +915,18 @@ std::string QuestManager::getspellname(uint32 spell_id) { return spell_name; } +std::string QuestManager::getskillname(int skill_id) { + if (skill_id >= 0 && skill_id < EQEmu::skills::SkillCount) { + std::map Skills = EQEmu::skills::GetSkillTypeMap(); + for (auto skills_iter : Skills) { + if (skill_id == skills_iter.first) { + return skills_iter.second; + } + } + } + return std::string(); +} + void QuestManager::safemove() { QuestManagerCurrentQuestVars(); if (initiator && initiator->IsClient()) diff --git a/zone/questmgr.h b/zone/questmgr.h index a3c7eab3d..50f077298 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -108,6 +108,7 @@ public: void traindisc(int discipline_tome_item_id); bool isdisctome(int item_id); std::string getspellname(uint32 spell_id); + std::string getskillname(int skill_id); void safemove(); void rain(int weather); void snow(int weather);