diff --git a/common/emu_constants.cpp b/common/emu_constants.cpp index a6a45c0d3..0d5f3c8cd 100644 --- a/common/emu_constants.cpp +++ b/common/emu_constants.cpp @@ -19,6 +19,8 @@ #include "emu_constants.h" #include "languages.h" +#include "data_verification.h" +#include "bodytypes.h" int16 EQ::invtype::GetInvTypeSize(int16 inv_type) { @@ -148,8 +150,9 @@ const char *EQ::constants::GetStanceName(StanceType stance_type) { } int EQ::constants::ConvertStanceTypeToIndex(StanceType stance_type) { - if (stance_type >= EQ::constants::stancePassive && stance_type <= EQ::constants::stanceBurnAE) + if (EQ::ValueWithin(stance_type, EQ::constants::stancePassive, EQ::constants::stanceBurnAE)) { return (stance_type - EQ::constants::stancePassive); + } return 0; } @@ -191,7 +194,7 @@ const std::map& EQ::constants::GetLanguageMap() std::string EQ::constants::GetLanguageName(int language_id) { - if (language_id >= LANG_COMMON_TONGUE && language_id <= LANG_UNKNOWN) { + if (EQ::ValueWithin(language_id, LANG_COMMON_TONGUE, LANG_UNKNOWN)) { auto languages = EQ::constants::GetLanguageMap(); return languages[language_id]; } @@ -213,7 +216,7 @@ const std::map& EQ::constants::GetLDoNThemeMap() std::string EQ::constants::GetLDoNThemeName(uint32 theme_id) { - if (theme_id >= LDoNThemes::Unused && theme_id <= LDoNThemes::TAK) { + if (EQ::ValueWithin(theme_id, LDoNThemes::Unused, LDoNThemes::TAK)) { auto ldon_themes = EQ::constants::GetLDoNThemeMap(); return ldon_themes[theme_id]; } @@ -235,12 +238,64 @@ const std::map& EQ::constants::GetFlyModeMap() std::string EQ::constants::GetFlyModeName(uint8 flymode_id) { - if ( - flymode_id >= GravityBehavior::Ground && - flymode_id <= GravityBehavior::LevitateWhileRunning - ) { + if (EQ::ValueWithin(flymode_id, GravityBehavior::Ground, GravityBehavior::LevitateWhileRunning)) { auto flymodes = EQ::constants::GetFlyModeMap(); return flymodes[flymode_id]; } return std::string(); } + +const std::map& EQ::constants::GetBodyTypeMap() +{ + static const std::map bodytype_map = { + { BT_Humanoid, "Humanoid" }, + { BT_Lycanthrope, "Lycanthrope" }, + { BT_Undead, "Undead" }, + { BT_Giant, "Giant" }, + { BT_Construct, "Construct" }, + { BT_Extraplanar, "Extraplanar" }, + { BT_Magical, "Magical" }, + { BT_SummonedUndead, "Summoned Undead" }, + { BT_RaidGiant, "Raid Giant" }, + { BT_RaidColdain, "Raid Coldain" }, + { BT_NoTarget, "Untargetable" }, + { BT_Vampire, "Vampire" }, + { BT_Atenha_Ra, "Aten Ha Ra" }, + { BT_Greater_Akheva, "Greater Akheva" }, + { BT_Khati_Sha, "Khati Sha" }, + { BT_Seru, "Seru" }, + { BT_Grieg_Veneficus, "Grieg Veneficus" }, + { BT_Draz_Nurakk, "Draz Nurakk" }, + { BT_Zek, "Zek" }, + { BT_Luggald, "Luggald" }, + { BT_Animal, "Animal" }, + { BT_Insect, "Insect" }, + { BT_Monster, "Monster" }, + { BT_Summoned, "Summoned" }, + { BT_Plant, "Plant" }, + { BT_Dragon, "Dragon" }, + { BT_Summoned2, "Summoned 2" }, + { BT_Summoned3, "Summoned 3" }, + { BT_Dragon2, "Dragon 2" }, + { BT_VeliousDragon, "Velious Dragon" }, + { BT_Familiar, "Familiar" }, + { BT_Dragon3, "Dragon 3" }, + { BT_Boxes, "Boxes" }, + { BT_Muramite, "Muramite" }, + { BT_NoTarget2, "Untargetable 2" }, + { BT_SwarmPet, "Swarm Pet" }, + { BT_MonsterSummon, "Monster Summon" }, + { BT_InvisMan, "Invisible Man" }, + { BT_Special, "Special" }, + }; + return bodytype_map; +} + +std::string EQ::constants::GetBodyTypeName(bodyType bodytype_id) +{ + auto bodytypes = EQ::constants::GetBodyTypeMap(); + if (!bodytypes[bodytype_id].empty()) { + return bodytypes[bodytype_id]; + } + return std::string(); +} \ No newline at end of file diff --git a/common/emu_constants.h b/common/emu_constants.h index c49dc7730..88ca7f924 100644 --- a/common/emu_constants.h +++ b/common/emu_constants.h @@ -22,6 +22,7 @@ #include "eq_limits.h" #include "emu_versions.h" +#include "bodytypes.h" #include @@ -241,6 +242,9 @@ namespace EQ extern const std::map& GetFlyModeMap(); std::string GetFlyModeName(uint8 flymode_id); + extern const std::map& GetBodyTypeMap(); + std::string GetBodyTypeName(bodyType bodytype_id); + const int STANCE_TYPE_FIRST = stancePassive; const int STANCE_TYPE_LAST = stanceBurnAE; const int STANCE_TYPE_COUNT = stanceBurnAE; diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 58984cce5..65dd1bde7 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -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); diff --git a/zone/gm_commands/npcedit.cpp b/zone/gm_commands/npcedit.cpp index 922b93bf2..66b483384 100755 --- a/zone/gm_commands/npcedit.cpp +++ b/zone/gm_commands/npcedit.cpp @@ -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(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; } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 62777f76b..f0213f0b4 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -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 diff --git a/zone/mob.cpp b/zone/mob.cpp index 7babbeb82..dc59d444c 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -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() ); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 92b8b0b37..c8242117b 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -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_id)); +} + void QuestManager::safemove() { QuestManagerCurrentQuestVars(); if (initiator && initiator->IsClient()) diff --git a/zone/questmgr.h b/zone/questmgr.h index 205142003..1836ae289 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -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);