Add getskillname(skill_id) to Perl/Lua.

This commit is contained in:
Alex 2020-04-06 01:36:46 -04:00
parent 4c348baabd
commit 358bd60716
4 changed files with 35 additions and 0 deletions

View File

@ -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);

View File

@ -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),

View File

@ -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<EQEmu::skills::SkillType, std::string> 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())

View File

@ -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);