[Quest API] Add GetBodyTypeName() to Perl/Lua. (#1863)

* [Quest API] Add GetBodyTypeName() to Perl/Lua.
- Add GetBodyTypeName() and GetBodyTypeMap() helper methods.
- Add quest::getbodytypename(bodytype_id) to Perl.
- Add eq.get_body_type_name(bodytype_id) to Lua.

* ShowStats() cleanup.
This commit is contained in:
Kinglykrab
2021-12-03 19:52:42 -05:00
committed by GitHub
parent e09f28c62c
commit 01a671918a
8 changed files with 119 additions and 10 deletions
+18
View File
@@ -8057,6 +8057,23 @@ XS(XS__getlanguagename) {
}
}
XS(XS__getbodytypename);
XS(XS__getbodytypename) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::getbodytypename(uint32 bodytype_id)");
{
dXSTARG;
uint32 bodytype_id = (uint32) SvUV(ST(0));
std::string bodytype_name = quest_manager.getbodytypename(bodytype_id);
sv_setpv(TARG, bodytype_name.c_str());
XSprePUSH;
PUSHTARG;
XSRETURN(1);
}
}
/*
This is the callback perl will look for to setup the
quest package's XSUBs
@@ -8337,6 +8354,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "forcedoorclose"), XS__forcedoorclose, file);
newXS(strcpy(buf, "forcedooropen"), XS__forcedooropen, file);
newXS(strcpy(buf, "getaaexpmodifierbycharid"), XS__getaaexpmodifierbycharid, file);
newXS(strcpy(buf, "getbodytypename"), XS__getbodytypename, file);
newXS(strcpy(buf, "getcharidbyname"), XS__getcharidbyname, file);
newXS(strcpy(buf, "getclassname"), XS__getclassname, file);
newXS(strcpy(buf, "getcleannpcnamebyid"), XS__getcleannpcnamebyid, file);
+12 -2
View File
@@ -215,8 +215,18 @@ void command_npcedit(Client *c, const Seperator *sep)
if (strcasecmp(sep->arg[1], "bodytype") == 0) {
c->Message(
Chat::Yellow,
fmt::format("NPC ID {} is now using Bodytype {} .", npc_id, atoi(sep->arg[2])).c_str());
std::string query = fmt::format("UPDATE npc_types SET bodytype = {} WHERE id = {}", atoi(sep->arg[2]), npc_id);
fmt::format(
"NPC ID {} is now using Bodytype {} ({}).",
npc_id,
EQ::constants::GetBodyTypeName(static_cast<bodyType>(std::stoul(sep->arg[2]))),
std::stoul(sep->arg[2])
).c_str()
);
std::string query = fmt::format(
"UPDATE npc_types SET bodytype = {} WHERE id = {}",
std::stoul(sep->arg[2]),
npc_id
);
content_db.QueryDatabase(query);
return;
}
+5
View File
@@ -3359,6 +3359,10 @@ std::string lua_get_language_name(int language_id) {
return quest_manager.getlanguagename(language_id);
}
std::string lua_get_body_type_name(uint32 bodytype_id) {
return quest_manager.getbodytypename(bodytype_id);
}
#define LuaCreateNPCParse(name, c_type, default_value) do { \
cur = table[#name]; \
if(luabind::type(cur) != LUA_TNIL) { \
@@ -3804,6 +3808,7 @@ luabind::scope lua_register_general() {
luabind::def("get_spell", &lua_get_spell),
luabind::def("get_faction_name", &lua_get_faction_name),
luabind::def("get_language_name", &lua_get_language_name),
luabind::def("get_body_type_name", &lua_get_body_type_name),
/*
Cross Zone
+13 -1
View File
@@ -1765,12 +1765,24 @@ void Mob::ShowStats(Client* client)
}
// Body
auto bodytype_name = EQ::constants::GetBodyTypeName(target->GetBodyType());
client->Message(
Chat::White,
fmt::format(
"Body | Size: {:.2f} Type: {}",
target->GetSize(),
target->GetBodyType()
(
bodytype_name.empty() ?
fmt::format(
"{}",
target->GetBodyType()
) :
fmt::format(
"{} ({})",
bodytype_name,
target->GetBodyType()
)
)
).c_str()
);
+4
View File
@@ -1044,6 +1044,10 @@ std::string QuestManager::getlanguagename(int language_id) {
return EQ::constants::GetLanguageName(language_id);
}
std::string QuestManager::getbodytypename(uint32 bodytype_id) {
return EQ::constants::GetBodyTypeName(static_cast<bodyType>(bodytype_id));
}
void QuestManager::safemove() {
QuestManagerCurrentQuestVars();
if (initiator && initiator->IsClient())
+1
View File
@@ -117,6 +117,7 @@ public:
std::string getskillname(int skill_id);
std::string getfactionname(int faction_id);
std::string getlanguagename(int language_id);
std::string getbodytypename(uint32 bodytype_id);
void safemove();
void rain(int weather);
void snow(int weather);