Add getnpcnamebyid(npc_id) to Perl/Lua.

This commit is contained in:
Alex
2020-04-06 00:09:57 -04:00
parent 4c348baabd
commit 02cac686b6
6 changed files with 48 additions and 0 deletions
+17
View File
@@ -2858,6 +2858,22 @@ XS(XS__getitemname) {
XSRETURN(1);
}
XS(XS__getnpcnamebyid);
XS(XS__getnpcnamebyid) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::getnpcnamebyid(uint32 npc_id)");
dXSTARG;
uint32 npc_id = (int) SvIV(ST(0));
const char *npc_name = quest_manager.getnpcnamebyid(npc_id);
sv_setpv(TARG, npc_name);
XSprePUSH;
PUSHTARG;
XSRETURN(1);
}
XS(XS__UpdateSpawnTimer);
XS(XS__UpdateSpawnTimer) {
dXSARGS;
@@ -4110,6 +4126,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "getinventoryslotid"), XS__getinventoryslotid, file);
newXS(strcpy(buf, "getitemname"), XS__getitemname, file);
newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file);
newXS(strcpy(buf, "getnpcnamebyid"), XS__getnpcnamebyid, file);
newXS(strcpy(buf, "get_spawn_condition"), XS__get_spawn_condition, file);
newXS(strcpy(buf, "getcharnamebyid"), XS__getcharnamebyid, file);
newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file);
+5
View File
@@ -890,6 +890,10 @@ int lua_get_group_id_by_char_id(uint32 char_id) {
return database.GetGroupIDByCharID(char_id);
}
const char *lua_get_npc_name_by_id(uint32 npc_id) {
return quest_manager.getnpcnamebyid(npc_id);
}
int lua_get_raid_id_by_char_id(uint32 char_id) {
return database.GetRaidIDByCharID(char_id);
}
@@ -1776,6 +1780,7 @@ luabind::scope lua_register_general() {
luabind::def("get_guild_name_by_id", &lua_get_guild_name_by_id),
luabind::def("get_guild_id_by_char_id", &lua_get_guild_id_by_char_id),
luabind::def("get_group_id_by_char_id", &lua_get_group_id_by_char_id),
luabind::def("get_npc_name_by_id", &lua_get_npc_name_by_id),
luabind::def("get_raid_id_by_char_id", &lua_get_raid_id_by_char_id),
luabind::def("create_instance", &lua_create_instance),
luabind::def("destroy_instance", &lua_destroy_instance),
+7
View File
@@ -2725,6 +2725,13 @@ std::string QuestManager::getitemname(uint32 item_id) {
return item_name;
}
const char *QuestManager::getnpcnamebyid(uint32 npc_id) {
if (npc_id > 0) {
return database.GetNPCNameByID(npc_id);
}
return "";
}
uint16 QuestManager::CreateInstance(const char *zone, int16 version, uint32 duration)
{
QuestManagerCurrentQuestVars();
+1
View File
@@ -260,6 +260,7 @@ public:
const char* getguildnamebyid(int guild_id);
int getguildidbycharid(uint32 char_id);
int getgroupidbycharid(uint32 char_id);
const char* getnpcnamebyid(uint32 npc_id);
int getraididbycharid(uint32 char_id);
void SetRunning(bool val);
bool IsRunning();