Commit 06a73cfe authored by Azilroka's avatar Azilroka

Fix Role Icons

parent 86036f1d
......@@ -7,14 +7,6 @@ local pairs, select, random = pairs, select, random
-- GLOBALS: hooksecurefunc
local GetNumClasses = GetNumClasses
local GetClassInfo = GetClassInfo
local GetNumSpecializationsForClassID = GetNumSpecializationsForClassID
local GetSpecializationInfoForClassID = GetSpecializationInfoForClassID
local GetNumBattlefieldScores = GetNumBattlefieldScores
local GetBattlefieldScore = GetBattlefieldScore
local IsInInstance = IsInInstance
local GetUnitName = GetUnitName
local UnitGroupRolesAssigned = UnitGroupRolesAssigned
local UnitIsConnected = UnitIsConnected
......@@ -24,27 +16,6 @@ local rolePaths = {
DAMAGER = [[Interface\AddOns\ElvUI_BenikUI\media\textures\roleIcons\dps.tga]]
}
local specNameToRole = {}
for i = 1, GetNumClasses() do
local _, class, classID = GetClassInfo(i)
specNameToRole[class] = {}
for j = 1, GetNumSpecializationsForClassID(classID) do
local _, spec, _, _, _, role = GetSpecializationInfoForClassID(classID, j)
specNameToRole[class][spec] = role
end
end
local function GetBattleFieldIndexFromUnitName(name)
local nameFromIndex
for index = 1, GetNumBattlefieldScores() do
nameFromIndex = GetBattlefieldScore(index)
if nameFromIndex == name then
return index
end
end
return nil
end
function BU:UpdateRoleIcon()
local lfdrole = self.GroupRoleIndicator
if not self.db then return; end
......@@ -54,28 +25,12 @@ function BU:UpdateRoleIcon()
return
end
local isInstance, instanceType = IsInInstance()
local role
if isInstance and instanceType == "pvp" then
local name = GetUnitName(self.unit, true)
local index = GetBattleFieldIndexFromUnitName(name)
if index then
local _, _, _, _, _, _, _, _, classToken, _, _, _, _, _, _, talentSpec = GetBattlefieldScore(index)
if classToken and talentSpec then
role = specNameToRole[classToken][talentSpec]
else
role = UnitGroupRolesAssigned(self.unit) --Fallback
end
else
role = UnitGroupRolesAssigned(self.unit) --Fallback
end
else
role = UnitGroupRolesAssigned(self.unit)
if self.isForced and role == 'NONE' then
local role = UnitGroupRolesAssigned(self.unit)
if self.isForced and role == 'NONE' then
local rnd = random(1, 3)
role = rnd == 1 and "TANK" or (rnd == 2 and "HEALER" or (rnd == 3 and "DAMAGER"))
end
role = rnd == 1 and "TANK" or (rnd == 2 and "HEALER" or (rnd == 3 and "DAMAGER"))
end
if (self.isForced or UnitIsConnected(self.unit)) and ((role == "DAMAGER" and db.damager) or (role == "HEALER" and db.healer) or (role == "TANK" and db.tank)) then
lfdrole:SetTexture(rolePaths[role])
lfdrole:Show()
......@@ -109,4 +64,4 @@ f:SetScript("OnEvent", function(self, event)
if BUI.SLE or E.db.benikui.unitframes.misc.svui == false then return end
SetRoleIcons()
end)
\ No newline at end of file
end)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment