From 02456ec7c66f9985a722c5b9f429836dcd58f58b Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 22 Mar 2026 21:01:56 -0700 Subject: [PATCH] feat: add GetMaxPlayerLevel and GetAccountExpansionLevel GetMaxPlayerLevel() returns the level cap for the active expansion: 60 (Classic/Turtle), 70 (TBC), 80 (WotLK). Used by XP bar addons and leveling trackers. GetAccountExpansionLevel() returns the expansion tier: 1 (Classic), 2 (TBC), 3 (WotLK). Used by addons that adapt features based on which expansion is active. Both read from the ExpansionRegistry's active profile at runtime. --- src/addons/lua_engine.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index c595085b..b78f979b 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -7,6 +7,7 @@ #include "core/application.hpp" #include "rendering/renderer.hpp" #include "audio/ui_sound_manager.hpp" +#include "game/expansion_profile.hpp" #include #include #include @@ -4935,6 +4936,22 @@ void LuaEngine::registerCoreAPI() { {"IsInRaid", lua_IsInRaid}, {"GetPlayerMapPosition", lua_GetPlayerMapPosition}, {"GetPlayerFacing", lua_GetPlayerFacing}, + {"GetMaxPlayerLevel", [](lua_State* L) -> int { + auto* reg = core::Application::getInstance().getExpansionRegistry(); + auto* prof = reg ? reg->getActive() : nullptr; + if (prof && prof->id == "wotlk") lua_pushnumber(L, 80); + else if (prof && prof->id == "tbc") lua_pushnumber(L, 70); + else lua_pushnumber(L, 60); + return 1; + }}, + {"GetAccountExpansionLevel", [](lua_State* L) -> int { + auto* reg = core::Application::getInstance().getExpansionRegistry(); + auto* prof = reg ? reg->getActive() : nullptr; + if (prof && prof->id == "wotlk") lua_pushnumber(L, 3); + else if (prof && prof->id == "tbc") lua_pushnumber(L, 2); + else lua_pushnumber(L, 1); + return 1; + }}, {"PlaySound", lua_PlaySound}, {"PlaySoundFile", lua_PlaySoundFile}, {"GetCVar", lua_GetCVar},