feat: track shapeshift form and fire UPDATE_SHAPESHIFT_FORM events

Add UNIT_FIELD_BYTES_1 to all expansion update field tables (Classic=133,
TBC/WotLK=137). Byte 3 of this field contains the shapeshift form ID
(Bear=1, Cat=3, Travel=4, Moonkin=31, Tree=36, Battle Stance=17, etc.).

Track form changes in the VALUES update handler and fire
UPDATE_SHAPESHIFT_FORM + UPDATE_SHAPESHIFT_FORMS events when the
form changes. This enables stance bar addons and druid form tracking.

New Lua functions:
- GetShapeshiftForm() — returns current form ID (0 = no form)
- GetNumShapeshiftForms() — returns form count by class (Warrior=3,
  Druid=6, DK=3, Rogue=1, Priest=1, Paladin=3)
This commit is contained in:
Kelsi 2026-03-22 22:12:17 -07:00
parent b9a1b0244b
commit 587c0ef60d
8 changed files with 194 additions and 147 deletions

View file

@ -5013,6 +5013,33 @@ void LuaEngine::registerCoreAPI() {
{"IsInRaid", lua_IsInRaid},
{"GetPlayerMapPosition", lua_GetPlayerMapPosition},
{"GetPlayerFacing", lua_GetPlayerFacing},
{"GetShapeshiftForm", [](lua_State* L) -> int {
auto* gh = getGameHandler(L);
lua_pushnumber(L, gh ? gh->getShapeshiftFormId() : 0);
return 1;
}},
{"GetNumShapeshiftForms", [](lua_State* L) -> int {
// Return count based on player class
auto* gh = getGameHandler(L);
if (!gh) { lua_pushnumber(L, 0); return 1; }
uint8_t classId = gh->getPlayerClass();
// Druid: Bear(1), Aquatic(2), Cat(3), Travel(4), Moonkin/Tree(5/6)
// Warrior: Battle(1), Defensive(2), Berserker(3)
// Rogue: Stealth(1)
// Priest: Shadowform(1)
// Paladin: varies by level/talents
// DK: Blood Presence, Frost, Unholy (3)
switch (classId) {
case 1: lua_pushnumber(L, 3); break; // Warrior
case 2: lua_pushnumber(L, 3); break; // Paladin (auras)
case 4: lua_pushnumber(L, 1); break; // Rogue
case 5: lua_pushnumber(L, 1); break; // Priest
case 6: lua_pushnumber(L, 3); break; // Death Knight
case 11: lua_pushnumber(L, 6); break; // Druid
default: lua_pushnumber(L, 0); break;
}
return 1;
}},
{"GetMaxPlayerLevel", [](lua_State* L) -> int {
auto* reg = core::Application::getInstance().getExpansionRegistry();
auto* prof = reg ? reg->getActive() : nullptr;