From ceb8b31bc0570dbb0bc17b50e96fefb0212f8369 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 31 Mar 2020 19:48:44 -0400 Subject: [PATCH] Add getspellname(spell_id) to Perl/Lua. --- zone/embparser_api.cpp | 17 +++++++++++++++++ zone/lua_general.cpp | 5 +++++ zone/questmgr.cpp | 9 +++++++++ zone/questmgr.h | 1 + 4 files changed, 32 insertions(+) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index cf55925b8..bb90d77ce 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -822,6 +822,22 @@ XS(XS__isdisctome) { XSRETURN(1); } +XS(XS__getspellname); +XS(XS__getspellname) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: quest::getspellname(uint32 spell_id)"); + + dXSTARG; + uint32 spell_id = (int) SvIV(ST(0)); + std::string spell_name = quest_manager.getspellname(spell_id); + + sv_setpv(TARG, spell_name.c_str()); + XSprePUSH; + PUSHTARG; + XSRETURN(1); +} + XS(XS__safemove); XS(XS__safemove) { dXSARGS; @@ -4011,6 +4027,7 @@ EXTERN_C XS(boot_quest) { newXS(strcpy(buf, "getguildidbycharid"), XS__getguildidbycharid, file); newXS(strcpy(buf, "getgroupidbycharid"), XS__getgroupidbycharid, file); newXS(strcpy(buf, "getraididbycharid"), XS__getraididbycharid, file); + newXS(strcpy(buf, "getspellname"), XS__getspellname, 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 9367cef21..ef07d3742 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -393,6 +393,10 @@ bool lua_is_disc_tome(int item_id) { return quest_manager.isdisctome(item_id); } +std::string lua_get_spell_name(uint32 spell_id) { + return quest_manager.getspellname(spell_id); +} + void lua_safe_move() { quest_manager.safemove(); } @@ -1648,6 +1652,7 @@ luabind::scope lua_register_general() { luabind::def("depop_zone", &lua_depop_zone), 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("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 0c36b876a..7fb1474fd 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -906,6 +906,15 @@ bool QuestManager::isdisctome(int item_id) { return(true); } +std::string QuestManager::getspellname(uint32 spell_id) { + if (!IsValidSpell(spell_id)) { + return "INVALID SPELL ID IN GETSPELLNAME"; + } + + std::string spell_name = GetSpellName(spell_id); + return spell_name; +} + void QuestManager::safemove() { QuestManagerCurrentQuestVars(); if (initiator && initiator->IsClient()) diff --git a/zone/questmgr.h b/zone/questmgr.h index 21d5b5db1..6ea7fcf38 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -107,6 +107,7 @@ public: void level(int newlevel); void traindisc(int discipline_tome_item_id); bool isdisctome(int item_id); + std::string getspellname(uint32 spell_id); void safemove(); void rain(int weather); void snow(int weather);