I copied the arena part and added handling for battlegrounds. I tested it in an unrated battleground and it seems to work fine (arena and RBG are untested). You'll just have to make the code into an addon for yourself.
This replaces the icon of your targets portrait with the specialization icon of your target, when in arena or battleground:
Code:
local SpecTextures = {};
for i = 1, GetNumClasses() do
local _, classTag, classID = GetClassInfo(i);
SpecTextures[classTag] = {};
for specID = 1, GetNumSpecializationsForClassID(classID) do
local _, specName, _, specIcon = GetSpecializationInfoForClassID(classID,specID);
SpecTextures[classTag][specName] = specIcon;
end;
end;
local TargetFrameSpec = CreateFrame("Frame");
TargetFrameSpec:RegisterEvent("PLAYER_TARGET_CHANGED");
TargetFrameSpec:SetScript("OnEvent",function()
if not UnitExists("target") then
return;
end;
local _, instanceType = IsInInstance();
if instanceType == "arena" then
for i = 1, 5 do
if UnitIsUnit("target","arena"..i) then
local icon = (select(4,GetSpecializationInfoByID(GetArenaOpponentSpec(i))));
if icon then
SetPortraitToTexture(TargetFrame.portrait,icon);
return;
end;
end;
end;
elseif instanceType == "pvp" then
for scoreIndex = 1, GetNumBattlefieldScores() do
local name, _, _, _, _, _, _, _, classTag, _, _, _, _, _, _, specName = GetBattlefieldScore(scoreIndex);
if GetUnitName("target",true) == name then
local icon = SpecTextures[classTag][specName];
if icon then
SetPortraitToTexture(TargetFrame.portrait,icon);
return;
end;
end;
end;
end;
end);