mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
feat: add UnitGroupRolesAssigned for LFG role display in raid frames
Returns "TANK", "HEALER", "DAMAGER", or "NONE" based on the WotLK LFG roles bitmask from SMSG_GROUP_LIST. Used by raid frame addons (Grid, VuhDo, Healbot) to display role icons next to player names.
This commit is contained in:
parent
d8c0820c76
commit
24e2069225
1 changed files with 24 additions and 0 deletions
|
|
@ -540,6 +540,29 @@ static int lua_UnitDetailedThreatSituation(lua_State* L) {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnitGroupRolesAssigned(unit) → "TANK", "HEALER", "DAMAGER", or "NONE"
|
||||||
|
static int lua_UnitGroupRolesAssigned(lua_State* L) {
|
||||||
|
auto* gh = getGameHandler(L);
|
||||||
|
if (!gh) { lua_pushstring(L, "NONE"); return 1; }
|
||||||
|
const char* uid = luaL_optstring(L, 1, "player");
|
||||||
|
std::string uidStr(uid);
|
||||||
|
for (char& c : uidStr) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||||
|
uint64_t guid = resolveUnitGuid(gh, uidStr);
|
||||||
|
if (guid == 0) { lua_pushstring(L, "NONE"); return 1; }
|
||||||
|
const auto& pd = gh->getPartyData();
|
||||||
|
for (const auto& m : pd.members) {
|
||||||
|
if (m.guid == guid) {
|
||||||
|
// WotLK roles bitmask: 0x02=Tank, 0x04=Healer, 0x08=DPS
|
||||||
|
if (m.roles & 0x02) { lua_pushstring(L, "TANK"); return 1; }
|
||||||
|
if (m.roles & 0x04) { lua_pushstring(L, "HEALER"); return 1; }
|
||||||
|
if (m.roles & 0x08) { lua_pushstring(L, "DAMAGER"); return 1; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lua_pushstring(L, "NONE");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// UnitCanAttack(unit, otherUnit) → boolean
|
// UnitCanAttack(unit, otherUnit) → boolean
|
||||||
static int lua_UnitCanAttack(lua_State* L) {
|
static int lua_UnitCanAttack(lua_State* L) {
|
||||||
auto* gh = getGameHandler(L);
|
auto* gh = getGameHandler(L);
|
||||||
|
|
@ -3318,6 +3341,7 @@ void LuaEngine::registerCoreAPI() {
|
||||||
{"UnitIsTapped", lua_UnitIsTapped},
|
{"UnitIsTapped", lua_UnitIsTapped},
|
||||||
{"UnitIsTappedByPlayer", lua_UnitIsTappedByPlayer},
|
{"UnitIsTappedByPlayer", lua_UnitIsTappedByPlayer},
|
||||||
{"UnitIsTappedByAllThreatList", lua_UnitIsTappedByAllThreatList},
|
{"UnitIsTappedByAllThreatList", lua_UnitIsTappedByAllThreatList},
|
||||||
|
{"UnitGroupRolesAssigned", lua_UnitGroupRolesAssigned},
|
||||||
{"UnitCanAttack", lua_UnitCanAttack},
|
{"UnitCanAttack", lua_UnitCanAttack},
|
||||||
{"UnitCanCooperate", lua_UnitCanCooperate},
|
{"UnitCanCooperate", lua_UnitCanCooperate},
|
||||||
{"UnitCreatureFamily", lua_UnitCreatureFamily},
|
{"UnitCreatureFamily", lua_UnitCreatureFamily},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue