You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2506 lines
83 KiB

local _detalhes = _G.Details
local _ = nil
4 years ago
_detalhes.custom_function_cache = {}
local addonName, Details222 = ...
local Details = _detalhes
4 years ago
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--local pointers
local format = string.format
local floor = math.floor
local sort = table.sort
local tinsert = table.insert
local ipairs = ipairs
local unpack = table.unpack or unpack
local _GetSpellInfo = Details.getspellinfo
3 years ago
local IsInRaid = IsInRaid
local IsInGroup = IsInGroup
local stringReplace = Details.string.replace
local GetSpellLink = GetSpellLink or C_Spell.GetSpellLink --api local
3 years ago
local Loc = LibStub("AceLocale-3.0"):GetLocale("Details")
4 years ago
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--constants
4 years ago
local classCustom = Details.atributo_custom
3 years ago
classCustom.mt = {__index = classCustom}
4 years ago
3 years ago
local combatContainers = {
4 years ago
["damagedone"] = 1,
["healdone"] = 2,
}
3 years ago
--hold the mini custom objects
classCustom._InstanceActorContainer = {}
classCustom._InstanceLastCustomShown = {}
classCustom._InstanceLastCombatShown = {}
classCustom._TargetActorsProcessed = {}
4 years ago
local ToKFunctions = Details.ToKFunctions
3 years ago
local SelectedToKFunction = ToKFunctions[1]
4 years ago
local UsingCustomRightText = false
local UsingCustomLeftText = false
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--core
4 years ago
3 years ago
function classCustom:GetCombatContainerIndex (attribute)
return combatContainers [attribute]
4 years ago
end
function classCustom:RefreshWindow(instanceObject, combatObject, force, export)
3 years ago
--get the custom object
local customObject = instanceObject:GetCustomObject()
4 years ago
if (not customObject) then
return instanceObject:ResetAttribute()
4 years ago
end
3 years ago
--save the custom name in the instance
instanceObject.customName = customObject.name
4 years ago
3 years ago
--get the container holding the custom actor objects for this instance
local instance_container = classCustom:GetInstanceCustomActorContainer (instanceObject)
4 years ago
local last_shown = classCustom._InstanceLastCustomShown [instanceObject:GetId()]
if (last_shown and last_shown ~= customObject:GetName()) then
4 years ago
instance_container:WipeCustomActorContainer()
end
classCustom._InstanceLastCustomShown [instanceObject:GetId()] = customObject:GetName()
4 years ago
local last_combat_shown = classCustom._InstanceLastCombatShown [instanceObject:GetId()]
if (last_combat_shown and last_combat_shown ~= combatObject) then
4 years ago
instance_container:WipeCustomActorContainer()
end
classCustom._InstanceLastCombatShown [instanceObject:GetId()] = combatObject
4 years ago
3 years ago
--declare the main locals
4 years ago
local total = 0
local top = 0
local amount = 0
3 years ago
--check if is a custom script (if has .script)
if (customObject:IsScripted()) then
3 years ago
--be save reseting the values on every refresh
4 years ago
instance_container:ResetCustomActorContainer()
local func
local scriptTypeName = "search"
4 years ago
if (Details.custom_function_cache [instanceObject.customName]) then
func = Details.custom_function_cache [instanceObject.customName]
4 years ago
else
local errortext
func, errortext = loadstring (customObject.script)
4 years ago
if (func) then
DetailsFramework:SetEnvironment(func)
Details.custom_function_cache [instanceObject.customName] = func
4 years ago
else
Details:Msg("|cFFFF9900error compiling code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext)
4 years ago
end
if (customObject.tooltip) then
local tooltip_script, errortext = loadstring (customObject.tooltip)
4 years ago
if (tooltip_script) then
DetailsFramework:SetEnvironment(tooltip_script)
Details.custom_function_cache [instanceObject.customName .. "Tooltip"] = tooltip_script
4 years ago
else
Details:Msg("|cFFFF9900error compiling tooltip code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext)
4 years ago
end
scriptTypeName = "tooltip"
4 years ago
end
3 years ago
if (customObject.total_script) then
local total_script, errortext = loadstring (customObject.total_script)
4 years ago
if (total_script) then
DetailsFramework:SetEnvironment(total_script)
Details.custom_function_cache [instanceObject.customName .. "Total"] = total_script
4 years ago
else
Details:Msg("|cFFFF9900error compiling total code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext)
4 years ago
end
scriptTypeName = "total"
4 years ago
end
3 years ago
if (customObject.percent_script) then
local percent_script, errortext = loadstring (customObject.percent_script)
4 years ago
if (percent_script) then
DetailsFramework:SetEnvironment(percent_script)
Details.custom_function_cache [instanceObject.customName .. "Percent"] = percent_script
4 years ago
else
Details:Msg("|cFFFF9900error compiling percent code for custom display " .. (instanceObject.customName or "") .. " |r:", errortext)
4 years ago
end
scriptTypeName = "percent"
4 years ago
end
end
3 years ago
4 years ago
if (not func) then
Details:Msg(Loc ["STRING_CUSTOM_FUNC_INVALID"], func)
Details:EndRefresh (instanceObject, 0, combatObject, combatObject [1])
4 years ago
end
3 years ago
local okey, _total, _top, _amount = pcall (func, combatObject, instance_container, instanceObject)
4 years ago
if (not okey) then
local errorText = _total
Details:Msg("|cFFFF9900error on display " .. customObject:GetName() .. " (" .. scriptTypeName .. ")|r:", errorText)
return Details:EndRefresh(instanceObject, 0, combatObject, combatObject[1])
4 years ago
end
3 years ago
4 years ago
total = _total or 0
top = _top or 0
amount = _amount or 0
3 years ago
4 years ago
else --does not have a .script
3 years ago
--get the attribute
local attribute = customObject:GetAttribute() --"damagedone"
4 years ago
3 years ago
--get the custom function(actor, source, target, spellid)
local func = classCustom [attribute]
--get the combat container
4 years ago
local container_index = self:GetCombatContainerIndex (attribute)
local combat_container = combatObject [container_index]._ActorTable
4 years ago
3 years ago
--build container
total, top, amount = classCustom:BuildActorList (func, customObject.source, customObject.target, customObject.spellid, combatObject, combat_container, container_index, instance_container, instanceObject, customObject)
4 years ago
end
if (customObject:IsSpellTarget()) then
3 years ago
amount = classCustom._TargetActorsProcessedAmt
total = classCustom._TargetActorsProcessedTotal
top = classCustom._TargetActorsProcessedTop
4 years ago
end
if (amount == 0) then
if (force) then
if (instanceObject:IsGroupMode()) then
for i = 1, instanceObject.rows_fit_in_window do
Details.FadeHandler.Fader(instanceObject.barras [i], "in", Details.fade_speed)
4 years ago
end
end
end
instanceObject:EsconderScrollBar()
return Details:EndRefresh (instanceObject, total, combatObject, nil)
4 years ago
end
3 years ago
4 years ago
if (amount > #instance_container._ActorTable) then
amount = #instance_container._ActorTable
end
combatObject.totals [customObject:GetName()] = total
3 years ago
4 years ago
instance_container:Sort()
instance_container:Remap()
3 years ago
4 years ago
if (export) then
3 years ago
4 years ago
-- key name value need to be formated
if (customObject) then
3 years ago
local percent_script = Details.custom_function_cache [instanceObject.customName .. "Percent"]
local total_script = Details.custom_function_cache [instanceObject.customName .. "Total"]
4 years ago
local okey
3 years ago
for index, actor in ipairs(instance_container._ActorTable) do
4 years ago
local percent, ptotal
3 years ago
4 years ago
if (percent_script) then
okey, percent = pcall (percent_script, floor(actor.value), top, total, combatObject, instanceObject, actor)
4 years ago
if (not okey) then
Details:Msg("|cFFFF9900percent script error|r:", percent)
return Details:EndRefresh (instanceObject, 0, combatObject, combatObject [1])
4 years ago
end
else
3 years ago
percent = format ("%.1f", floor(actor.value) / total * 100)
4 years ago
end
3 years ago
4 years ago
if (total_script) then
local okey, value = pcall (total_script, floor(actor.value), top, total, combatObject, instanceObject, actor)
4 years ago
if (not okey) then
Details:Msg("|cFFFF9900total script error|r:", value)
return Details:EndRefresh (instanceObject, 0, combatObject, combatObject [1])
4 years ago
end
3 years ago
if (type(value) == "number") then
4 years ago
value = SelectedToKFunction (_, value)
end
ptotal = value
else
3 years ago
ptotal = SelectedToKFunction (_, floor(actor.value))
4 years ago
end
3 years ago
4 years ago
actor.report_value = ptotal .. " (" .. percent .. "%)"
3 years ago
4 years ago
if (actor.id) then
if (actor.id == 1) then
3 years ago
actor.report_name = GetSpellLink(6603)
4 years ago
elseif (actor.id > 10) then
3 years ago
actor.report_name = GetSpellLink(actor.id)
4 years ago
else
actor.report_name = actor.nome
end
else
actor.report_name = actor.nome
end
end
end
3 years ago
4 years ago
return total, instance_container._ActorTable, top, amount, "report_name"
end
3 years ago
instanceObject:RefreshScrollBar (amount)
4 years ago
classCustom:Refresh (instanceObject, instance_container, combatObject, force, total, top, customObject)
3 years ago
return Details:EndRefresh (instanceObject, total, combatObject, combatObject [container_index])
4 years ago
end
3 years ago
function classCustom:BuildActorList (func, source, target, spellid, combat, combat_container, container_index, instance_container, instance, custom_object)
4 years ago
local total = 0
local top = 0
local amount = 0
3 years ago
--check if is a spell target custom
4 years ago
if (custom_object:IsSpellTarget()) then
Details:Destroy(classCustom._TargetActorsProcessed)
3 years ago
classCustom._TargetActorsProcessedAmt = 0
classCustom._TargetActorsProcessedTotal = 0
classCustom._TargetActorsProcessedTop = 0
4 years ago
instance_container:ResetCustomActorContainer()
end
3 years ago
4 years ago
if (source == "[all]") then
3 years ago
for _, actor in ipairs(combat_container) do
4 years ago
local actortotal = func (_, actor, source, target, spellid, combat, instance_container)
if (actortotal > 0) then
total = total + actortotal
amount = amount + 1
3 years ago
4 years ago
if (actortotal > top) then
top = actortotal
end
3 years ago
instance_container:SetValue(actor, actortotal)
4 years ago
end
end
3 years ago
4 years ago
elseif (source == "[raid]") then
3 years ago
if (Details.in_combat and instance.segmento == 0 and not export) then
4 years ago
if (container_index == 1) then
combat_container = Details.cache_damage_group
4 years ago
elseif (container_index == 2) then
combat_container = Details.cache_healing_group
4 years ago
end
end
3 years ago
for _, actor in ipairs(combat_container) do
4 years ago
if (actor.grupo) then
if (not func) then
Details:Msg("error on class_custom 'func' is invalid, backtrace:", debugstack())
return
end
local actortotal = func (_, actor, source, target, spellid, combat, instance_container)
if (actortotal > 0) then
total = total + actortotal
amount = amount + 1
3 years ago
4 years ago
if (actortotal > top) then
top = actortotal
end
3 years ago
instance_container:SetValue(actor, actortotal)
4 years ago
end
3 years ago
4 years ago
end
end
3 years ago
4 years ago
elseif (source == "[player]") then
local pindex = combat [container_index]._NameIndexTable [Details.playername]
4 years ago
if (pindex) then
local actor = combat [container_index]._ActorTable [pindex]
local actortotal = func (_, actor, source, target, spellid, combat, instance_container)
3 years ago
4 years ago
if (actortotal > 0) then
total = total + actortotal
amount = amount + 1
3 years ago
4 years ago
if (actortotal > top) then
top = actortotal
end
3 years ago
instance_container:SetValue(actor, actortotal)
4 years ago
end
end
else
local pindex = combat [container_index]._NameIndexTable [source]
if (pindex) then
local actor = combat [container_index]._ActorTable [pindex]
local actortotal = func (_, actor, source, target, spellid, combat, instance_container)
3 years ago
4 years ago
if (actortotal > 0) then
total = total + actortotal
amount = amount + 1
3 years ago
4 years ago
if (actortotal > top) then
top = actortotal
end
3 years ago
instance_container:SetValue(actor, actortotal)
4 years ago
end
end
end
3 years ago
4 years ago
return total, top, amount
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--refresh functions
4 years ago
3 years ago
function classCustom:Refresh (instance, instance_container, combat, force, total, top, custom_object)
4 years ago
local whichRowLine = 1
local barContainer = instance.barras
local percentageType = instance.row_info.percent_type
3 years ago
local combatElapsedTime = combat:GetCombatTime()
4 years ago
UsingCustomLeftText = instance.row_info.textL_enable_custom_text
UsingCustomRightText = instance.row_info.textR_enable_custom_text
3 years ago
--total bar
local bUseTotalbar = false
4 years ago
if (instance.total_bar.enabled) then
bUseTotalbar = true
3 years ago
if (instance.total_bar.only_in_group and (not IsInGroup() and not IsInRaid())) then
bUseTotalbar = false
4 years ago
end
end
local percent_script = Details.custom_function_cache [instance.customName .. "Percent"]
local total_script = Details.custom_function_cache [instance.customName .. "Total"]
3 years ago
4 years ago
local bars_show_data = instance.row_info.textR_show_data
local bars_brackets = instance:GetBarBracket()
local bars_separator = instance:GetBarSeparator()
if (instance.bars_sort_direction == 1) then --top to bottom
3 years ago
if (bUseTotalbar and instance.barraS[1] == 1) then
3 years ago
4 years ago
whichRowLine = 2
local iter_last = instance.barraS[2]
if (iter_last == instance.rows_fit_in_window) then
iter_last = iter_last - 1
end
3 years ago
local row1 = barContainer [1]
4 years ago
row1.minha_tabela = nil
3 years ago
row1.lineText1:SetText(Loc ["STRING_TOTAL"])
row1.lineText4:SetText(Details:ToK2 (total) .. " (" .. Details:ToK (total / combatElapsedTime) .. ")")
3 years ago
row1:SetValue(100)
local r, g, b = unpack(instance.total_bar.color)
row1.textura:SetVertexColor(r, g, b)
row1.icone_classe:SetTexture(instance.total_bar.icon)
row1.icone_classe:SetTexCoord(0.0625, 0.9375, 0.0625, 0.9375)
Details.FadeHandler.Fader(row1, "out")
4 years ago
for i = instance.barraS[1], iter_last, 1 do
instance_container._ActorTable[i]:UpdateBar (barContainer, whichRowLine, percentageType, i, total, top, instance, force, percent_script, total_script, combat, bars_show_data, bars_brackets, bars_separator)
4 years ago
whichRowLine = whichRowLine+1
end
3 years ago
4 years ago
else
for i = instance.barraS[1], instance.barraS[2], 1 do
instance_container._ActorTable[i]:UpdateBar (barContainer, whichRowLine, percentageType, i, total, top, instance, force, percent_script, total_script, combat, bars_show_data, bars_brackets, bars_separator)
4 years ago
whichRowLine = whichRowLine+1
end
end
3 years ago
4 years ago
elseif (instance.bars_sort_direction == 2) then --bottom to top
3 years ago
if (bUseTotalbar and instance.barraS[1] == 1) then
3 years ago
4 years ago
whichRowLine = 2
local iter_last = instance.barraS[2]
if (iter_last == instance.rows_fit_in_window) then
iter_last = iter_last - 1
end
3 years ago
local row1 = barContainer [1]
4 years ago
row1.minha_tabela = nil
3 years ago
row1.lineText1:SetText(Loc ["STRING_TOTAL"])
row1.lineText4:SetText(Details:ToK2 (total) .. " (" .. Details:ToK (total / combatElapsedTime) .. ")")
3 years ago
row1:SetValue(100)
local r, g, b = unpack(instance.total_bar.color)
row1.textura:SetVertexColor(r, g, b)
row1.icone_classe:SetTexture(instance.total_bar.icon)
row1.icone_classe:SetTexCoord(0.0625, 0.9375, 0.0625, 0.9375)
Details.FadeHandler.Fader(row1, "out")
for i = iter_last, instance.barraS[1], -1 do --vai atualizar s� o range que esta sendo mostrado
instance_container._ActorTable[i]:UpdateBar (barContainer, whichRowLine, percentageType, i, total, top, instance, force, percent_script, total_script, combat, bars_show_data, bars_brackets, bars_separator)
4 years ago
whichRowLine = whichRowLine+1
end
3 years ago
4 years ago
else
3 years ago
for i = instance.barraS[2], instance.barraS[1], -1 do --vai atualizar s� o range que esta sendo mostrado
instance_container._ActorTable[i]:UpdateBar (barContainer, whichRowLine, percentageType, i, total, top, instance, force, percent_script, total_script, combat, bars_show_data, bars_brackets, bars_separator)
4 years ago
whichRowLine = whichRowLine+1
end
end
3 years ago
end
4 years ago
if (force) then
if (instance:IsGroupMode()) then
for i = whichRowLine, instance.rows_fit_in_window do
3 years ago
Details.FadeHandler.Fader(instance.barras [i], "in", Details.fade_speed)
4 years ago
end
end
end
3 years ago
instance:AutoAlignInLineFontStrings()
4 years ago
end
3 years ago
4 years ago
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--custom object functions
4 years ago
local actor_class_color_r, actor_class_color_g, actor_class_color_b
3 years ago
function classCustom:UpdateBar (row_container, index, percentage_type, rank, total, top, instance, is_forced, percent_script, total_script, combat, bars_show_data, bars_brackets, bars_separator)
local row = row_container[index]
4 years ago
local previous_table = row.minha_tabela
row.colocacao = rank
row.minha_tabela = self
self.minha_barra = row
local percent
local okey
3 years ago
--percent
4 years ago
if (percent_script) then
--local value, top, total, combat, instance = ...
3 years ago
okey, percent = pcall (percent_script, self.value, top, total, combat, instance, self)
4 years ago
if (not okey) then
Details:Msg("|cFFFF9900error on custom display function|r:", percent)
return Details:EndRefresh (instance, 0, combat, combat [1])
4 years ago
end
else
if (percentage_type == 1) then
percent = format("%.1f", self.value / total * 100) .. "%"
elseif (percentage_type == 2) then
percent = format("%.1f", self.value / top * 100) .. "%"
end
end
if (not percent) then
percent = ""
end
3 years ago
--total done
4 years ago
if (total_script) then
3 years ago
local okey, value = pcall (total_script, self.value, top, total, combat, instance, self)
4 years ago
if (not okey) then
Details:Msg("|cFFFF9900error on custom display function|r:", value)
return Details:EndRefresh (instance, 0, combat, combat [1])
4 years ago
end
if (instance.use_multi_fontstrings) then
if (type(value) == "string") then
instance:SetInLineTexts(row, "", value, percent) --usando essa linha
4 years ago
else
instance:SetInLineTexts(row, "", SelectedToKFunction(_, value), percent)
4 years ago
end
else
3 years ago
if (type(value) == "number") then
row.lineText4:SetText(SelectedToKFunction (_, value) .. bars_brackets[1] .. percent .. bars_brackets[2])
4 years ago
else
3 years ago
row.lineText4:SetText(value .. bars_brackets[1] .. percent .. bars_brackets[2])
4 years ago
end
row.lineText3:SetText("")
row.lineText2:SetText("")
end
else
local formatedValue = SelectedToKFunction(_, self.value)
local rightText = formatedValue .. bars_brackets[1] .. percent .. bars_brackets[2]
4 years ago
if (UsingCustomRightText) then
row.lineText4:SetText(stringReplace(instance.row_info.textR_custom_text, formatedValue, "", percent, self, combat, instance, rightText))
4 years ago
else
if (instance.use_multi_fontstrings) then
instance:SetInLineTexts(row, "", formatedValue, percent)
4 years ago
else
3 years ago
row.lineText4:SetText(rightText)
4 years ago
row.lineText3:SetText("")
row.lineText2:SetText("")
end
end
end
3 years ago
local row_value = floor((self.value / top) * 100)
4 years ago
-- update tooltip function --
if (self.id) then
local school = Details.spell_school_cache[self.nome]
4 years ago
if (school) then
local schoolColor = Details.spells_school[school]
if (not schoolColor) then
schoolColor = Details.spells_school[1]
4 years ago
end
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
4 years ago
else
local schoolColor = Details.spells_school[1]
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
4 years ago
end
else
actor_class_color_r, actor_class_color_g, actor_class_color_b = self:GetBarColor()
end
3 years ago
self:RefreshBarra2(row, instance, previous_table, is_forced, row_value, index, row_container)
3 years ago
4 years ago
end
3 years ago
function classCustom:RefreshBarra2 (esta_barra, instancia, tabela_anterior, forcar, esta_porcentagem, whichRowLine, barras_container)
--primeiro colocado
4 years ago
if (esta_barra.colocacao == 1) then
if (not tabela_anterior or tabela_anterior ~= esta_barra.minha_tabela or forcar) then
3 years ago
esta_barra:SetValue(100)
4 years ago
if (esta_barra.hidden or esta_barra.fading_in or esta_barra.faded) then
3 years ago
Details.FadeHandler.Fader(esta_barra, "out")
4 years ago
end
3 years ago
return self:RefreshBarra(esta_barra, instancia)
4 years ago
else
return
end
else
if (esta_barra.hidden or esta_barra.fading_in or esta_barra.faded) then
3 years ago
esta_barra:SetValue(esta_porcentagem)
Details.FadeHandler.Fader(esta_barra, "out")
4 years ago
if (instancia.row_info.texture_class_colors) then
3 years ago
esta_barra.textura:SetVertexColor(actor_class_color_r, actor_class_color_g, actor_class_color_b)
4 years ago
end
if (instancia.row_info.texture_background_class_color) then
3 years ago
esta_barra.background:SetVertexColor(actor_class_color_r, actor_class_color_g, actor_class_color_b)
4 years ago
end
3 years ago
return self:RefreshBarra(esta_barra, instancia)
4 years ago
else
3 years ago
--agora esta comparando se a tabela da barra � diferente da tabela na atualiza��o anterior
if (not tabela_anterior or tabela_anterior ~= esta_barra.minha_tabela or forcar) then --aqui diz se a barra do jogador mudou de posi��o ou se ela apenas ser� atualizada
esta_barra:SetValue(esta_porcentagem)
esta_barra.last_value = esta_porcentagem --reseta o ultimo valor da barra
if (Details.is_using_row_animations and forcar) then
4 years ago
esta_barra.tem_animacao = 0
3 years ago
esta_barra:SetScript("OnUpdate", nil)
4 years ago
end
3 years ago
return self:RefreshBarra(esta_barra, instancia)
elseif (esta_porcentagem ~= esta_barra.last_value) then --continua mostrando a mesma tabela ent�o compara a porcentagem
--apenas atualizar
if (Details.is_using_row_animations) then
3 years ago
4 years ago
local upRow = barras_container [whichRowLine-1]
if (upRow) then
if (upRow.statusbar:GetValue() < esta_barra.statusbar:GetValue()) then
3 years ago
esta_barra:SetValue(esta_porcentagem)
4 years ago
else
instancia:AnimarBarra (esta_barra, esta_porcentagem)
end
else
instancia:AnimarBarra (esta_barra, esta_porcentagem)
end
else
3 years ago
esta_barra:SetValue(esta_porcentagem)
4 years ago
end
esta_barra.last_value = esta_porcentagem
end
end
end
end
3 years ago
function classCustom:RefreshBarra(thisBar, instanceObject, bFromResize)
4 years ago
local class, enemy, arena_enemy, arena_ally = self.classe, self.enemy, self.arena_enemy, self.arena_ally
3 years ago
if (bFromResize) then
4 years ago
if (self.id) then
local schoolData = Details.spell_school_cache[self.nome]
if (schoolData) then
local schoolColor = Details.spells_school[schoolData]
if (not schoolColor) then
schoolColor = Details.spells_school[1]
4 years ago
end
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
4 years ago
else
local schoolColor = Details.spells_school[1]
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
4 years ago
end
else
actor_class_color_r, actor_class_color_g, actor_class_color_b = self:GetBarColor()
end
end
self:SetBarColors(thisBar, instanceObject, actor_class_color_r, actor_class_color_g, actor_class_color_b)
4 years ago
3 years ago
--we need a customized icon settings for custom displays.
4 years ago
if (self.classe == "UNKNOW") then
thisBar.icone_classe:SetTexture("Interface\\LFGFRAME\\LFGROLE_BW")
thisBar.icone_classe:SetTexCoord(.25, .5, 0, 1)
thisBar.icone_classe:SetVertexColor(1, 1, 1)
4 years ago
elseif (self.classe == "UNGROUPPLAYER") then
if (self.enemy) then
if (Details.faction_against == "Horde") then
thisBar.icone_classe:SetTexture("Interface\\ICONS\\Achievement_Character_Orc_Male")
thisBar.icone_classe:SetTexCoord(0, 1, 0, 1)
4 years ago
else
thisBar.icone_classe:SetTexture("Interface\\ICONS\\Achievement_Character_Human_Male")
thisBar.icone_classe:SetTexCoord(0, 1, 0, 1)
4 years ago
end
else
if (Details.faction_against == "Horde") then
thisBar.icone_classe:SetTexture("Interface\\ICONS\\Achievement_Character_Human_Male")
thisBar.icone_classe:SetTexCoord(0, 1, 0, 1)
4 years ago
else
thisBar.icone_classe:SetTexture("Interface\\ICONS\\Achievement_Character_Orc_Male")
thisBar.icone_classe:SetTexCoord(0, 1, 0, 1)
4 years ago
end
end
thisBar.icone_classe:SetVertexColor(1, 1, 1)
3 years ago
4 years ago
elseif (self.classe == "PET") then
thisBar.icone_classe:SetTexture(instanceObject.row_info.icon_file)
thisBar.icone_classe:SetTexCoord(0.25, 0.49609375, 0.75, 1)
thisBar.icone_classe:SetVertexColor(actor_class_color_r, actor_class_color_g, actor_class_color_b)
4 years ago
else
if (self.id) then
thisBar.icone_classe:SetTexCoord(0.078125, 0.921875, 0.078125, 0.921875)
thisBar.icone_classe:SetTexture(self.icon)
4 years ago
else
if (instanceObject.row_info.use_spec_icons) then
4 years ago
if ((self.spec and self.spec ~= 0) or (self.my_actor.spec and self.my_actor.spec ~= 0)) then
thisBar.icone_classe:SetTexture(instanceObject.row_info.spec_file)
thisBar.icone_classe:SetTexCoord(unpack(Details.class_specs_coords[self.spec or self.my_actor.spec]))
4 years ago
else
thisBar.icone_classe:SetTexture([[Interface\AddOns\Details\images\classes_small]])
thisBar.icone_classe:SetTexCoord(unpack(Details.class_coords[self.classe]))
4 years ago
end
else
thisBar.icone_classe:SetTexture(instanceObject.row_info.icon_file)
thisBar.icone_classe:SetTexCoord(unpack(Details.class_coords[self.classe]))
4 years ago
end
end
thisBar.icone_classe:SetVertexColor(1, 1, 1)
4 years ago
end
3 years ago
--left text
self:SetBarLeftText(thisBar, instanceObject, enemy, arena_enemy, arena_ally, UsingCustomLeftText)
4 years ago
thisBar.lineText1:SetSize(thisBar:GetWidth() - thisBar.lineText4:GetStringWidth() - 20, 15)
3 years ago
end
4 years ago
3 years ago
function classCustom:CreateCustomActorContainer()
return setmetatable({
4 years ago
_NameIndexTable = {},
_ActorTable = {}
3 years ago
}, {__index = classCustom})
4 years ago
end
3 years ago
function classCustom:ResetCustomActorContainer()
for _, actor in ipairs(self._ActorTable) do
actor.value = actor.value - floor(actor.value)
--actor.value = _detalhes:GetOrderNumber(actor.nome)
4 years ago
end
end
3 years ago
function classCustom:WipeCustomActorContainer()
Details:Destroy(self._ActorTable)
Details:Destroy(self._NameIndexTable)
4 years ago
end
3 years ago
function classCustom:GetValue (actor)
local actor_table = self:GetActorTable(actor)
4 years ago
return actor_table.value
end
3 years ago
4 years ago
-- ~add
3 years ago
function classCustom:AddValue (actor, actortotal, checktop, name_complement)
local actor_table = self:GetActorTable(actor, name_complement)
4 years ago
if (not getmetatable(actor)) then
3 years ago
setmetatable(actor,classCustom.mt)
4 years ago
end
actor_table.my_actor = actor
actor_table.value = actor_table.value + actortotal
3 years ago
4 years ago
if (checktop) then
3 years ago
if (actor_table.value > classCustom._TargetActorsProcessedTop) then
classCustom._TargetActorsProcessedTop = actor_table.value
4 years ago
end
end
3 years ago
4 years ago
return actor_table.value
end
3 years ago
function classCustom:SetValue(actor, actortotal, name_complement)
local actor_table = self:GetActorTable(actor, name_complement)
4 years ago
actor_table.my_actor = actor
actor_table.value = actortotal
end
3 years ago
function classCustom:UpdateClass(actors)
4 years ago
actors.new_actor.classe = actors.actor.classe
end
3 years ago
function classCustom:HasActor(actor)
return self._NameIndexTable[actor.nome or actor.name] and true or false
4 years ago
end
3 years ago
function classCustom:GetNumActors()
4 years ago
return #self._ActorTable
end
3 years ago
function classCustom:GetTotalAndHighestValue()
4 years ago
local total, top = 0, 0
3 years ago
for i, actor in ipairs(self._ActorTable) do
4 years ago
if (actor.value > top) then
top = actor.value
end
total = total + actor.value
end
return total, top
end
3 years ago
4 years ago
local icon_cache = {}
3 years ago
function classCustom:GetActorTable(actor, name_complement)
local index = self._NameIndexTable[actor.nome or actor.name]
4 years ago
if (index) then
3 years ago
return self._ActorTable[index]
4 years ago
else
3 years ago
--if is a spell object
4 years ago
local class
if (actor.id) then
3 years ago
local spellname, _, icon = _GetSpellInfo(actor.id)
if (not icon_cache[spellname] and spellname) then
icon_cache[spellname] = icon
4 years ago
elseif (not spellname) then
spellname = ""
end
3 years ago
4 years ago
actor.nome = spellname
actor.name = spellname
actor.classe = actor.spellschool
class = actor.spellschool
3 years ago
local index = self._NameIndexTable[actor.nome]
4 years ago
if (index) then
3 years ago
return self._ActorTable[index]
4 years ago
end
3 years ago
4 years ago
else
class = actor.classe or actor.class
if (not class or class == "UNKNOWN") then
class = "UNKNOW"
end
if (class == "UNKNOW") then
3 years ago
--try once again
class = Details:GetClass(actor.nome or actor.name)
4 years ago
if (class and class ~= "UNKNOW") then
actor.classe = class
end
end
end
3 years ago
local newActor = setmetatable({
4 years ago
nome = actor.nome or actor.name,
classe = class,
value = Details:GetOrderNumber(),
4 years ago
is_custom = true,
color = actor.color,
3 years ago
}, classCustom.mt)
newActor.customColor = actor.customColor
3 years ago
newActor.name_complement = name_complement
newActor.displayName = actor.displayName or (Details:GetOnlyName(newActor.nome) .. (name_complement or ""))
3 years ago
newActor:SetSpecId(actor.spec)
newActor.enemy = actor.enemy
newActor.role = actor.role
newActor.arena_enemy = actor.arena_enemy
newActor.arena_ally = actor.arena_ally
newActor.arena_team = actor.arena_team
4 years ago
if (actor.id) then
3 years ago
newActor.id = actor.id
4 years ago
--icon
3 years ago
if (icon_cache[actor.nome]) then
newActor.icon = icon_cache[actor.nome]
4 years ago
else
3 years ago
local _, _, icon = _GetSpellInfo(actor.id)
4 years ago
if (icon) then
3 years ago
icon_cache[actor.nome] = icon
newActor.icon = icon
4 years ago
end
end
else
3 years ago
if (not newActor.classe) then
newActor.classe = Details:GetClass(actor.nome or actor.name) or "UNKNOW"
4 years ago
end
3 years ago
if (newActor.classe == "UNGROUPPLAYER") then
--atributo_custom:ScheduleTimer("UpdateClass", 5, {newActor = newActor, actor = actor})
Details.Schedules.NewTimer(5, classCustom.UpdateClass, self, {new_actor = newActor, actor = actor})
4 years ago
end
end
index = #self._ActorTable+1
3 years ago
self._ActorTable[index] = newActor
self._NameIndexTable[actor.nome or actor.name] = index
return newActor
4 years ago
end
end
3 years ago
function classCustom:GetInstanceCustomActorContainer (instance)
if (not classCustom._InstanceActorContainer [instance:GetId()]) then
classCustom._InstanceActorContainer [instance:GetId()] = self:CreateCustomActorContainer()
4 years ago
end
3 years ago
return classCustom._InstanceActorContainer [instance:GetId()]
4 years ago
end
3 years ago
function classCustom:CreateCustomDisplayObject()
return setmetatable({
4 years ago
name = "new custom",
icon = [[Interface\ICONS\TEMP]],
author = "unknown",
attribute = "damagedone",
source = "[all]",
target = "[all]",
spellid = false,
script = false,
3 years ago
}, {__index = classCustom})
4 years ago
end
3 years ago
local custom_sort = function(t1, t2)
4 years ago
return t1.value > t2.value
end
3 years ago
function classCustom:Sort (container)
4 years ago
container = container or self
3 years ago
sort (container._ActorTable, custom_sort)
4 years ago
end
3 years ago
function classCustom:Remap()
4 years ago
local map = self._NameIndexTable
local actors = self._ActorTable
for i = 1, #actors do
map [actors[i].nome] = i
end
end
function classCustom:ToolTip (instanceObject, barNumber, rowObject, keydown)
3 years ago
--get the custom object
local customObject = instanceObject:GetCustomObject()
3 years ago
if (customObject.notooltip) then
4 years ago
return
end
3 years ago
--get the actor
local actorObject = self.my_actor
3 years ago
if (actorObject.id) then
Details:AddTooltipSpellHeaderText (select(1, _GetSpellInfo(actorObject.id)), "yellow", 1, select(3, _GetSpellInfo(actorObject.id)), 0.90625, 0.109375, 0.15625, 0.875, false, 18)
4 years ago
else
Details:AddTooltipSpellHeaderText (customObject:GetName(), "yellow", 1, customObject:GetIcon(), 0.90625, 0.109375, 0.15625, 0.875, false, 18)
4 years ago
end
3 years ago
Details:AddTooltipHeaderStatusbar (1, 1, 1, 0.6)
3 years ago
if (customObject:IsScripted()) then
if (customObject.tooltip) then
local func = Details.custom_function_cache [instanceObject.customName .. "Tooltip"]
local okey, errortext = pcall(func, actorObject, instanceObject.showing, instanceObject, keydown)
4 years ago
if (not okey) then
Details:Msg("|cFFFF9900error on custom display tooltip function|r:", errortext)
4 years ago
return false
end
end
else
3 years ago
--get the attribute
local attribute = customObject:GetAttribute()
3 years ago
local container_index = classCustom:GetCombatContainerIndex (attribute)
--get the tooltip function
local func = classCustom [attribute .. "Tooltip"]
--build the tooltip
func (_, actorObject, customObject.target, customObject.spellid, instanceObject.showing, instanceObject)
4 years ago
end
3 years ago
4 years ago
return true
end
3 years ago
function classCustom:GetName()
4 years ago
return self.name
end
3 years ago
function classCustom:GetIcon()
4 years ago
return self.icon
end
3 years ago
function classCustom:GetAuthor()
4 years ago
return self.author
end
3 years ago
function classCustom:GetDesc()
4 years ago
return self.desc
end
3 years ago
function classCustom:GetAttribute()
4 years ago
return self.attribute
end
3 years ago
function classCustom:GetSource()
4 years ago
return self.source
end
3 years ago
function classCustom:GetTarget()
4 years ago
return self.target
end
3 years ago
function classCustom:GetSpellId()
4 years ago
return self.spellid
end
3 years ago
function classCustom:GetScript()
4 years ago
return self.script
end
3 years ago
function classCustom:GetScriptToolip()
4 years ago
return self.tooltip
end
3 years ago
function classCustom:GetScriptTotal()
4 years ago
return self.total_script
end
3 years ago
function classCustom:GetScriptPercent()
4 years ago
return self.percent_script
end
3 years ago
function classCustom:SetName (name)
4 years ago
self.name = name
end
3 years ago
function classCustom:SetIcon (path)
4 years ago
self.icon = path
end
3 years ago
function classCustom:SetAuthor (author)
4 years ago
self.author = author
end
3 years ago
function classCustom:SetDesc (desc)
4 years ago
self.desc = desc
end
3 years ago
function classCustom:SetAttribute (newattribute)
4 years ago
self.attribute = newattribute
end
3 years ago
function classCustom:SetSource (source)
4 years ago
self.source = source
end
3 years ago
function classCustom:SetTarget (target)
4 years ago
self.target = target
end
3 years ago
function classCustom:SetSpellId (spellid)
4 years ago
self.spellid = spellid
end
3 years ago
function classCustom:SetScript(code)
4 years ago
self.script = code
end
3 years ago
function classCustom:SetScriptToolip (code)
4 years ago
self.tooltip = code
end
3 years ago
function classCustom:IsScripted()
4 years ago
return self.script and true or false
end
3 years ago
function classCustom:IsSpellTarget()
4 years ago
return self.spellid and self.target and true
end
3 years ago
function classCustom:RemoveCustom (index)
if (not Details.tabela_instancias) then
3 years ago
--do not remove customs while the addon is loading.
4 years ago
return
end
3 years ago
table.remove (Details.custom, index)
3 years ago
for _, instance in ipairs(Details.tabela_instancias) do
3 years ago
if (instance.atributo == 5 and instance.sub_atributo == index) then
4 years ago
instance:ResetAttribute()
elseif (instance.atributo == 5 and instance.sub_atributo > index) then
instance.sub_atributo = instance.sub_atributo - 1
instance.sub_atributo_last [5] = 1
else
instance.sub_atributo_last [5] = 1
end
end
3 years ago
Details.switch:OnRemoveCustom (index)
4 years ago
end
3 years ago
--export for plugins
function Details:RemoveCustomObject (object_name)
for index, object in ipairs(Details.custom) do
4 years ago
if (object.name == object_name) then
3 years ago
return classCustom:RemoveCustom (index)
4 years ago
end
end
end
3 years ago
function Details:ResetCustomFunctionsCache()
Details:Destroy(Details.custom_function_cache)
4 years ago
end
3 years ago
function Details.refresh:r_atributo_custom()
3 years ago
--check for non used temp displays
if (Details.tabela_instancias) then
4 years ago
for i = #Details.custom, 1, -1 do
local custom_object = Details.custom [i]
4 years ago
if (custom_object.temp) then
3 years ago
--check if there is a instance showing this custom
4 years ago
local showing = false
3 years ago
for index, instance in ipairs(Details.tabela_instancias) do
3 years ago
if (instance.atributo == 5 and instance.sub_atributo == i) then
4 years ago
showing = true
end
end
3 years ago
4 years ago
if (not showing) then
3 years ago
classCustom:RemoveCustom (i)
4 years ago
end
end
end
end
3 years ago
--restore metatable and indexes
for index, custom_object in ipairs(Details.custom) do
3 years ago
setmetatable(custom_object, classCustom)
custom_object.__index = classCustom
4 years ago
end
end
function Details.clear:c_atributo_custom()
for _, custom_object in ipairs(Details.custom) do
4 years ago
custom_object.__index = nil
end
end
3 years ago
function classCustom:UpdateSelectedToKFunction()
SelectedToKFunction = ToKFunctions [Details.ps_abbreviation]
FormatTooltipNumber = ToKFunctions [Details.tooltip.abbreviation]
TooltipMaximizedMethod = Details.tooltip.maximize_method
3 years ago
classCustom:UpdateDamageDoneBracket()
classCustom:UpdateHealingDoneBracket()
4 years ago
end
3 years ago
function Details:InstallCustomObject (object)
4 years ago
local have = false
if (object.script_version) then
for _, custom in ipairs(Details.custom) do
4 years ago
if (custom.name == object.name and (custom.script_version and custom.script_version >= object.script_version) ) then
have = true
break
end
end
else
for _, custom in ipairs(Details.custom) do
4 years ago
if (custom.name == object.name) then
have = true
break
end
end
end
3 years ago
4 years ago
if (not have) then
for i, custom in ipairs(Details.custom) do
4 years ago
if (custom.name == object.name) then
table.remove (Details.custom, i)
4 years ago
break
end
end
setmetatable(object, Details.atributo_custom)
object.__index = Details.atributo_custom
Details.custom [#Details.custom+1] = object
4 years ago
end
end
function Details222.GetCustomDisplayIDByName(customDisplayName)
for customDisplayID, customObject in ipairs(Details.custom) do
if (customObject.name == customDisplayName) then
return customDisplayID
end
end
end
function Details:AddDefaultCustomDisplays()
4 years ago
local PotionUsed = {
name = Loc ["STRING_CUSTOM_POT_DEFAULT"],
icon = [[Interface\ICONS\INV_Potion_03]],
attribute = false,
spellid = false,
author = "Terciob",
4 years ago
desc = Loc ["STRING_CUSTOM_POT_DEFAULT_DESC"],
source = false,
target = false,
script_version = 8,
import_string = "1EvBVnkoq4FlxKwDWDjCn6Q0kfD7kL(YwruUMOLK7JaoGPX3rSrgZwLV4F73yJ5LMxjPDfBBzHXZZZmEMhg7p0FHVxoRGhH9x57HkeRzCFVhWcejn)x89YWWROIG8iojt47LYIqPYWFGslW9LHcwM(3cuk83i2MvibCdHMlq0iSm8lYqhhh5e5e9s0pydsS2jjLX4w6hAREnhlk4uzyVEYWbdYfCc9fNeghm2Q3NCgM0RVb2)qd3Vn8MBSvohwYN6P8GCIVxmopY3ZBn7vz4RRzkMid3cXNmKJiXYWICm8BKmmJjim4LXfkKGyynqomnIvqfyUJVNgLpG4UkW2pQljV6Fg2tIyu)Nh(N3(5H367rrBW(EZn8CjqCyRkdNMsIv7vce)fSqD3oCSKnZw9V4ifNIkYfSn3ZOWwkfZBXYstA4Qz9vrvzmI2OYiAJUPV5hfBhmaq3K22qYJalJemUcEds1omLKlMLSuqsjITJvwLR9xBIo6jSq)QPGXwp84IXUt9cgVyX3DVB5Ihd(BxV7TlXnMzGfYLzJKtsuOg03qGQGsTXtYqeEU1bWhs(GBMidlVgmGrt3cffPOTaX1l(foRiRXesIm0QfcJCZFszXC9sSST1KI2SGQltsy13G8yC1Uje9jO0C8(MV)tANP17)a3XRksacvKjiBWVjNFe4lxXsT911cAE0oMGnbpfc1wy1RCH9S33Z6mYb97rZfnHuv7hdCscdQrbFfHO)Qq3IcScEqghBSd2CZzQkxrEtfjrDF6ROTWFhECSmjaniTs)hK41jG6kWVn7(LEbZNTWD2ZbUpyFCC0PJwOC2Kq1LUFtZjZD)(jJNQR9kOe8c85xMMMqRTm8Vay6mjBiBMgSoqqmn(8gnyakoUzpvu1BB6ep763rDB0444)rPU2UvTVoqNCr88WKVl9MxAN5v2xEYUYRPNulJQJb34(vFFCo71k9WsT0PU3fmB(Jph89XUpemE6utVH3okQNPBuJZc0Q0YpvEYwrdNS7yTDJRV4IBd5kNr4lTzPdSBq(bogTr0D3PPJzGdA9ShFf(a6fZStPvOD7f7PRu(4eX4x1QdxDOTRcZ1fwDs05891)SLTUszmvoXU7EVtjJtA07rBSujQvz2zlnAnRz1Th(BHVHb6)t5tGPdlh3EuZC3hCCw942ibCkJvfc9rFemwQGKvpf9Bt87mt9XMGUEK33POENfX)5iA)HksFPIYVtr4par32H)ZWHW6xE8IYqmYixwf5U0e2f8jQNqQ0NUut1KpfYIwTbQJD474gfRSQ5NAEhZpMdY7yQUDsb8cwJjVSwC632boywTc)fLo4ou0)Po2engoDQOiFfcoy07rCPQ12x47))d",
4 years ago
script = [[
local combatObject, customContainer, instanceObject = ...
4 years ago
local total, top, amount = 0, 0, 0
4 years ago
--get the misc actor container
local listOfUtilityActors = combatObject:GetActorList(DETAILS_ATTRIBUTE_MISC)
4 years ago
--do the loop:
for _, actorObject in ipairs(listOfUtilityActors) do
4 years ago
--only player in group
if (actorObject:IsGroupPlayer()) then
local bFoundPotion = false
4 years ago
--get the spell debuff uptime container
local debuffUptimeContainer = actorObject:GetSpellContainer("debuff")
if (debuffUptimeContainer) then
4 years ago
--potion of focus (can't use as pre-potion, so, its amount is always 1
local focusPotion = debuffUptimeContainer:GetSpell(DETAILS_FOCUS_POTION_ID)
if (focusPotion) then
4 years ago
total = total + 1
bFoundPotion = true
4 years ago
if (top < 1) then
top = 1
end
3 years ago
--add amount to the player
customContainer:AddValue(actorObject, 1)
4 years ago
end
end
4 years ago
--get the spell buff uptime container
local buffUptimeContainer = actorObject:GetSpellContainer("buff")
if (buffUptimeContainer) then
for spellId, potionPower in pairs(LIB_OPEN_RAID_ALL_POTIONS) do
local spellTable = buffUptimeContainer:GetSpell(spellId)
if (spellTable) then
local used = spellTable.activedamt
4 years ago
if (used and used > 0) then
total = total + used
bFoundPotion = true
4 years ago
if (used > top) then
top = used
end
3 years ago
--add amount to the player
customContainer:AddValue(actorObject, used)
4 years ago
end
end
end
end
if (bFoundPotion) then
4 years ago
amount = amount + 1
3 years ago
end
4 years ago
end
end
4 years ago
--return:
return total, top, amount
]],
tooltip = [[
local actorObject, combatObject, instanceObject = ...
local iconSize = 20
local buffUptimeContainer = actorObject:GetSpellContainer("buff")
if (buffUptimeContainer) then
for spellId, potionPower in pairs(LIB_OPEN_RAID_ALL_POTIONS) do
local spellTable = buffUptimeContainer:GetSpell(spellId)
if (spellTable) then
local used = spellTable.activedamt
if (used and used > 0) then
local spellName, _, spellIcon = GetSpellInfo(spellId)
GameCooltip:AddLine(spellName, used)
GameCooltip:AddIcon(spellIcon, 1, 1, iconSize, iconSize)
Details:AddTooltipBackgroundStatusbar()
end
end
4 years ago
end
end
]],
total_script = [[
local value, top, total, combat, instance = ...
return math.floor(value) .. " "
]],
percent_script = [[
local value, top, total, combat, instance = ...
value = math.floor(value)
return ""
]],
4 years ago
}
3 years ago
4 years ago
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_POT_DEFAULT"] and (custom.script_version and custom.script_version >= PotionUsed.script_version) ) then
have = true
break
end
end
if (not have) then
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_POT_DEFAULT"]) then
table.remove (self.custom, i)
end
end
setmetatable(PotionUsed, Details.atributo_custom)
PotionUsed.__index = Details.atributo_custom
4 years ago
self.custom [#self.custom+1] = PotionUsed
end
4 years ago
4 years ago
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- /run _detalhes:AddDefaultCustomDisplays()
local Healthstone = {
name = Loc ["STRING_CUSTOM_HEALTHSTONE_DEFAULT"],
icon = [[Interface\ICONS\INV_Stone_04]],
attribute = false,
3 years ago
spellid = false,
author = "Terciob",
4 years ago
desc = Loc ["STRING_CUSTOM_HEALTHSTONE_DEFAULT_DESC"],
source = false,
target = false,
script = [[
local combatObject, instanceContainer, instanceObject = ...
local total, top, amount = 0, 0, 0
local listOfHealingActors = combatObject:GetActorList(DETAILS_ATTRIBUTE_HEAL)
for _, actorObject in ipairs(listOfHealingActors) do
local listOfSpells = actorObject:GetSpellList()
local found = false
for spellId, spellTable in pairs(listOfSpells) do
if (LIB_OPEN_RAID_HEALING_POTIONS[spellId]) then
instanceContainer:AddValue(actorObject, spellTable.total)
total = total + spellTable.total
if (top < spellTable.total) then
top = spellTable.total
end
found = true
4 years ago
end
end
if (found) then
amount = amount + 1
4 years ago
end
end
return total, top, amount
4 years ago
]],
3 years ago
tooltip = [[
local actorObject, combatObject, instanceObject = ...
local spellContainer = actorObject:GetSpellContainer("spell")
local iconSize = 20
local allHealingPotions = {6262}
for spellId, potionPower in pairs(LIB_OPEN_RAID_ALL_POTIONS) do
allHealingPotions[#allHealingPotions+1] = spellId
4 years ago
end
for i = 1, #allHealingPotions do
local spellId = allHealingPotions[i]
local spellTable = spellContainer:GetSpell(spellId)
if (spellTable) then
local spellName, _, spellIcon = GetSpellInfo(spellId)
GameCooltip:AddLine(spellName, Details:ToK(spellTable.total))
GameCooltip:AddIcon(spellIcon, 1, 1, iconSize, iconSize)
GameCooltip:AddStatusBar (100, 1, 0, 0, 0, 0.75)
end
4 years ago
end
4 years ago
]],
percent_script = false,
total_script = false,
script_version = 18,
4 years ago
}
4 years ago
-- /run _detalhes:AddDefaultCustomDisplays()
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_HEALTHSTONE_DEFAULT"] and (custom.script_version and custom.script_version >= Healthstone.script_version) ) then
have = true
break
end
end
if (not have) then
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_HEALTHSTONE_DEFAULT"]) then
table.remove (self.custom, i)
end
end
setmetatable(Healthstone, Details.atributo_custom)
Healthstone.__index = Details.atributo_custom
4 years ago
self.custom [#self.custom+1] = Healthstone
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
local DamageActivityTime = {
name = Loc ["STRING_CUSTOM_ACTIVITY_DPS"],
icon = [[Interface\Buttons\UI-MicroStream-Red]],
attribute = false,
spellid = false,
author = "Details!",
desc = Loc ["STRING_CUSTOM_ACTIVITY_DPS_DESC"],
source = false,
target = false,
script_version = 4,
4 years ago
total_script = [[
local value, top, total, combat, instance = ...
3 years ago
local minutos, segundos = math.floor(value/60), math.floor(value%60)
4 years ago
return minutos .. "m " .. segundos .. "s"
]],
percent_script = [[
local value, top, total, combat, instance = ...
3 years ago
return string.format("%.1f", value/top*100)
4 years ago
]],
script = [[
local combatObject, instanceContainer, instanceObject = ...
4 years ago
local total, amount = 0, 0
--get the damager actors
local listOfDamageActors = combatObject:GetActorList(DETAILS_ATTRIBUTE_DAMAGE)
3 years ago
for _, actorObject in ipairs(listOfDamageActors) do
if (actorObject:IsGroupPlayer()) then
local activity = actorObject:Tempo()
4 years ago
total = total + activity
amount = amount + 1
3 years ago
--add amount to the player
instanceContainer:AddValue(actorObject, activity)
4 years ago
end
end
3 years ago
4 years ago
--return:
return total, combatObject:GetCombatTime(), amount
4 years ago
]],
tooltip = [[
3 years ago
4 years ago
]],
}
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_ACTIVITY_DPS"] and (custom.script_version and custom.script_version >= DamageActivityTime.script_version) ) then
have = true
break
end
end
if (not have) then
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_ACTIVITY_DPS"]) then
table.remove (self.custom, i)
end
end
setmetatable(DamageActivityTime, Details.atributo_custom)
DamageActivityTime.__index = Details.atributo_custom
4 years ago
self.custom [#self.custom+1] = DamageActivityTime
end
local HealActivityTime = {
name = Loc ["STRING_CUSTOM_ACTIVITY_HPS"],
icon = [[Interface\Buttons\UI-MicroStream-Green]],
attribute = false,
spellid = false,
author = "Details!",
desc = Loc ["STRING_CUSTOM_ACTIVITY_HPS_DESC"],
source = false,
target = false,
script_version = 3,
4 years ago
total_script = [[
local value, top, total, combat, instance = ...
3 years ago
local minutos, segundos = math.floor(value/60), math.floor(value%60)
4 years ago
return minutos .. "m " .. segundos .. "s"
]],
percent_script = [[
local value, top, total, combat, instance = ...
3 years ago
return string.format("%.1f", value/top*100)
4 years ago
]],
script = [[
local combatObject, instanceContainer, instanceObject = ...
local total, amount = 0, 0
4 years ago
--get the healing actors
local listOfHealingActors = combatObject:GetActorList(DETAILS_ATTRIBUTE_HEAL)
3 years ago
for _, actorObject in ipairs(listOfHealingActors) do
if (actorObject:IsGroupPlayer()) then
local activity = actorObject:Tempo()
4 years ago
total = total + activity
amount = amount + 1
3 years ago
--add amount to the player
instanceContainer:AddValue (actorObject, activity)
4 years ago
end
end
3 years ago
4 years ago
--return:
return total, combatObject:GetCombatTime(), amount
4 years ago
]],
tooltip = [[
3 years ago
4 years ago
]],
}
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_ACTIVITY_HPS"] and (custom.script_version and custom.script_version >= HealActivityTime.script_version) ) then
have = true
break
end
end
if (not have) then
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_ACTIVITY_HPS"]) then
table.remove (self.custom, i)
end
end
setmetatable(HealActivityTime, Details.atributo_custom)
HealActivityTime.__index = Details.atributo_custom
4 years ago
self.custom [#self.custom+1] = HealActivityTime
end
3 years ago
4 years ago
---------------------------------------
3 years ago
4 years ago
----------------------------------------------------------------------------------------------------------------------------------------------------
--doas
local CC_Done = {
name = Loc ["STRING_CUSTOM_CC_DONE"],
icon = [[Interface\ICONS\Spell_Frost_FreezingBreath]],
attribute = false,
spellid = false,
author = "Details!",
desc = "Show the crowd control amount for each player.",
source = false,
target = false,
script_version = 11,
script = [[
local combat, instance_container, instance = ...
local total, top, amount = 0, 0, 0
local misc_actors = combat:GetActorList (DETAILS_ATTRIBUTE_MISC)
3 years ago
for index, character in ipairs(misc_actors) do
4 years ago
if (character.cc_done and character:IsPlayer()) then
3 years ago
local cc_done = floor(character.cc_done)
4 years ago
instance_container:AddValue (character, cc_done)
total = total + cc_done
if (cc_done > top) then
top = cc_done
end
amount = amount + 1
end
end
return total, top, amount
]],
tooltip = [[
local actor, combat, instance = ...
local spells = {}
3 years ago
for spellid, spell in pairs(actor.cc_done_spells._ActorTable) do
tinsert(spells, {spellid, spell.counter})
4 years ago
end
table.sort (spells, _detalhes.Sort2)
3 years ago
for index, spell in ipairs(spells) do
local name, _, icon = GetSpellInfo(spell [1])
GameCooltip:AddLine(name, spell [2])
4 years ago
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
local targets = {}
3 years ago
for playername, amount in pairs(actor.cc_done_targets) do
tinsert(targets, {playername, amount})
4 years ago
end
table.sort (targets, _detalhes.Sort2)
_detalhes:AddTooltipSpellHeaderText ("Targets", "yellow", #targets)
3 years ago
local class, _, _, _, _, r, g, b = _detalhes:GetClass(actor.nome)
4 years ago
_detalhes:AddTooltipHeaderStatusbar (1, 1, 1, 0.6)
3 years ago
for index, target in ipairs(targets) do
GameCooltip:AddLine(target[1], target [2])
4 years ago
_detalhes:AddTooltipBackgroundStatusbar()
3 years ago
local class, _, _, _, _, r, g, b = _detalhes:GetClass(target [1])
4 years ago
if (class and class ~= "UNKNOW") then
local texture, l, r, t, b = _detalhes:GetClassIcon(class)
4 years ago
GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small_alpha", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height, l, r, t, b)
else
GameCooltip:AddIcon ("Interface\\GossipFrame\\IncompleteQuestIcon", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
--
end
]],
total_script = [[
local value, top, total, combat, instance = ...
3 years ago
return floor(value)
4 years ago
]],
}
3 years ago
4 years ago
-- /run _detalhes:AddDefaultCustomDisplays()
3 years ago
4 years ago
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_CC_DONE"] and (custom.script_version and custom.script_version >= CC_Done.script_version) ) then
have = true
break
end
end
if (not have) then
setmetatable(CC_Done, Details.atributo_custom)
CC_Done.__index = Details.atributo_custom
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_CC_DONE"]) then
table.remove (self.custom, i)
3 years ago
tinsert(self.custom, i, CC_Done)
4 years ago
have = true
end
end
if (not have) then
self.custom [#self.custom+1] = CC_Done
end
3 years ago
end
4 years ago
----------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
local CC_Received = {
name = Loc ["STRING_CUSTOM_CC_RECEIVED"],
icon = [[Interface\ICONS\Spell_Frost_ChainsOfIce]],
attribute = false,
spellid = false,
author = "Details!",
desc = "Show the amount of crowd control received for each player.",
source = false,
target = false,
script_version = 3,
script = [[
local combat, instance_container, instance = ...
local total, top, amt = 0, 0, 0
local misc_actors = combat:GetActorList (DETAILS_ATTRIBUTE_MISC)
DETAILS_CUSTOM_CC_RECEIVED_CACHE = DETAILS_CUSTOM_CC_RECEIVED_CACHE or {}
wipe (DETAILS_CUSTOM_CC_RECEIVED_CACHE)
3 years ago
for index, character in ipairs(misc_actors) do
4 years ago
if (character.cc_done and character:IsPlayer()) then
3 years ago
for player_name, amount in pairs(character.cc_done_targets) do
4 years ago
local target = combat (1, player_name) or combat (2, player_name)
if (target and target:IsPlayer()) then
instance_container:AddValue (target, amount)
total = total + amount
if (amount > top) then
top = amount
end
if (not DETAILS_CUSTOM_CC_RECEIVED_CACHE [player_name]) then
DETAILS_CUSTOM_CC_RECEIVED_CACHE [player_name] = true
amt = amt + 1
end
end
end
3 years ago
4 years ago
end
end
return total, top, amt
]],
tooltip = [[
local actor, combat, instance = ...
local name = actor:name()
local spells, from = {}, {}
local misc_actors = combat:GetActorList (DETAILS_ATTRIBUTE_MISC)
3 years ago
for index, character in ipairs(misc_actors) do
4 years ago
if (character.cc_done and character:IsPlayer()) then
local on_actor = character.cc_done_targets [name]
if (on_actor) then
3 years ago
tinsert(from, {character:name(), on_actor})
for spellid, spell in pairs(character.cc_done_spells._ActorTable) do
4 years ago
local spell_on_actor = spell.targets [name]
if (spell_on_actor) then
local has_spell
3 years ago
for index, spell_table in ipairs(spells) do
4 years ago
if (spell_table [1] == spellid) then
spell_table [2] = spell_table [2] + spell_on_actor
has_spell = true
end
end
if (not has_spell) then
3 years ago
tinsert(spells, {spellid, spell_on_actor})
4 years ago
end
end
3 years ago
end
4 years ago
end
end
end
table.sort (from, _detalhes.Sort2)
table.sort (spells, _detalhes.Sort2)
3 years ago
for index, spell in ipairs(spells) do
local name, _, icon = GetSpellInfo(spell [1])
GameCooltip:AddLine(name, spell [2])
4 years ago
_detalhes:AddTooltipBackgroundStatusbar()
3 years ago
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
4 years ago
end
_detalhes:AddTooltipSpellHeaderText ("From", "yellow", #from)
_detalhes:AddTooltipHeaderStatusbar (1, 1, 1, 0.6)
3 years ago
for index, t in ipairs(from) do
GameCooltip:AddLine(t[1], t[2])
4 years ago
_detalhes:AddTooltipBackgroundStatusbar()
3 years ago
local class, _, _, _, _, r, g, b = _detalhes:GetClass(t [1])
4 years ago
if (class and class ~= "UNKNOW") then
local texture, l, r, t, b = _detalhes:GetClassIcon(class)
4 years ago
GameCooltip:AddIcon ("Interface\\AddOns\\Details\\images\\classes_small_alpha", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height, l, r, t, b)
else
GameCooltip:AddIcon ("Interface\\GossipFrame\\IncompleteQuestIcon", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
3 years ago
end
4 years ago
end
]],
total_script = [[
local value, top, total, combat, instance = ...
3 years ago
return floor(value)
4 years ago
]],
}
3 years ago
4 years ago
-- /run _detalhes:AddDefaultCustomDisplays()
3 years ago
4 years ago
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_CC_RECEIVED"] and (custom.script_version and custom.script_version >= CC_Received.script_version) ) then
have = true
break
end
end
if (not have) then
setmetatable(CC_Received, Details.atributo_custom)
CC_Received.__index = Details.atributo_custom
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_CC_RECEIVED"]) then
table.remove (self.custom, i)
3 years ago
tinsert(self.custom, i, CC_Received)
4 years ago
have = true
end
end
if (not have) then
self.custom [#self.custom+1] = CC_Received
end
3 years ago
end
4 years ago
----------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
local MySpells = {
name = Loc ["STRING_CUSTOM_MYSPELLS"],
icon = [[Interface\CHATFRAME\UI-ChatIcon-Battlenet]],
attribute = false,
spellid = false,
author = "Details!",
desc = Loc ["STRING_CUSTOM_MYSPELLS_DESC"],
source = false,
target = false,
script_version = 10,
4 years ago
script = [[
--get the parameters passed
local combat, instance_container, instance = ...
--declade the values to return
local total, top, amount = 0, 0, 0
local player
local pet_attribute
3 years ago
local role = DetailsFramework.UnitGroupRolesAssigned("player")
4 years ago
local spec = DetailsFramework.GetSpecialization()
role = spec and DetailsFramework.GetSpecializationRole (spec) or role
if (role == "DAMAGER") then
player = combat (DETAILS_ATTRIBUTE_DAMAGE, _detalhes.playername)
pet_attribute = DETAILS_ATTRIBUTE_DAMAGE
3 years ago
elseif (role == "HEALER") then
4 years ago
player = combat (DETAILS_ATTRIBUTE_HEAL, _detalhes.playername)
pet_attribute = DETAILS_ATTRIBUTE_HEAL
else
player = combat (DETAILS_ATTRIBUTE_DAMAGE, _detalhes.playername)
pet_attribute = DETAILS_ATTRIBUTE_DAMAGE
end
--do the loop
if (player) then
local spells = player:GetSpellList()
3 years ago
for spellid, spell in pairs(spells) do
4 years ago
instance_container:AddValue (spell, spell.total)
total = total + spell.total
if (top < spell.total) then
top = spell.total
end
amount = amount + 1
end
3 years ago
for _, PetName in ipairs(player.pets) do
4 years ago
local pet = combat (pet_attribute, PetName)
if (pet) then
3 years ago
for spellid, spell in pairs(pet:GetSpellList()) do
instance_container:AddValue (spell, spell.total, nil, " (" .. PetName:gsub((" <.*"), "") .. ")")
4 years ago
total = total + spell.total
if (top < spell.total) then
top = spell.total
end
amount = amount + 1
end
end
end
end
--return the values
return total, top, amount
]],
3 years ago
4 years ago
tooltip = [[
--config:
--Background RBG and Alpha:
local R, G, B, A = 0, 0, 0, 0.75
local R, G, B, A = 0.1960, 0.1960, 0.1960, 0.8697
--get the parameters passed
local spell, combat, instance = ...
--get the cooltip object (we dont use the convencional GameTooltip here)
local GC = GameCooltip
3 years ago
GC:SetOption("YSpacingMod", 0)
4 years ago
3 years ago
local role = DetailsFramework.UnitGroupRolesAssigned("player")
4 years ago
if (spell.n_total) then
3 years ago
4 years ago
local spellschool, schooltext = spell.spellschool, ""
if (spellschool) then
local t = Details.spells_school [spellschool]
4 years ago
if (t and t.name) then
schooltext = t.formated
end
end
3 years ago
4 years ago
local total_hits = spell.counter
local combat_time = instance.showing:GetCombatTime()
3 years ago
4 years ago
local debuff_uptime_total, cast_string = "", ""
local misc_actor = instance.showing (4, Details.playername)
4 years ago
if (misc_actor) then
local debuff_uptime = misc_actor.debuff_uptime_spells and misc_actor.debuff_uptime_spells._ActorTable [spell.id] and misc_actor.debuff_uptime_spells._ActorTable [spell.id].uptime
if (debuff_uptime) then
3 years ago
debuff_uptime_total = floor(debuff_uptime / instance.showing:GetCombatTime() * 100)
4 years ago
end
3 years ago
local spellName = GetSpellInfo(spell.id)
local amountOfCasts = combat:GetSpellCastAmount(Details.playername, spellName)
3 years ago
if (amountOfCasts == 0) then
amountOfCasts = "(|cFFFFFF00?|r)"
4 years ago
end
cast_string = cast_string .. amountOfCasts
4 years ago
end
3 years ago
4 years ago
--Cooltip code
3 years ago
GC:AddLine("Casts:", cast_string or "?")
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
4 years ago
if (debuff_uptime_total ~= "") then
3 years ago
GC:AddLine("Uptime:", (debuff_uptime_total or "?") .. "%")
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
end
3 years ago
GC:AddLine("Hits:", spell.counter)
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
4 years ago
local average = spell.total / total_hits
3 years ago
GC:AddLine("Average:", _detalhes:ToK (average))
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
GC:AddLine("E-Dps:", _detalhes:ToK (spell.total / combat_time))
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
GC:AddLine("School:", schooltext)
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
--GC:AddLine(" ")
GC:AddLine("Normal Hits: ", spell.n_amt .. " (" ..floor( spell.n_amt/total_hits*100) .. "%)")
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
local n_average = spell.n_total / spell.n_amt
local T = (combat_time*spell.n_total)/spell.total
4 years ago
local P = average/n_average*100
T = P*T/100
3 years ago
GC:AddLine("Average / E-Dps: ", _detalhes:ToK (n_average) .. " / " .. format("%.1f",spell.n_total / T ))
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
--GC:AddLine(" ")
GC:AddLine("Critical Hits: ", spell.c_amt .. " (" ..floor( spell.c_amt/total_hits*100) .. "%)")
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
4 years ago
if (spell.c_amt > 0) then
local c_average = spell.c_total/spell.c_amt
local T = (combat_time*spell.c_total)/spell.total
4 years ago
local P = average/c_average*100
T = P*T/100
local crit_dps = spell.c_total / T
3 years ago
GC:AddLine("Average / E-Dps: ", _detalhes:ToK (c_average) .. " / " .. _detalhes:comma_value (crit_dps))
4 years ago
else
3 years ago
GC:AddLine("Average / E-Dps: ", "0 / 0")
4 years ago
end
3 years ago
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
elseif (spell.n_total) then
3 years ago
4 years ago
local spellschool, schooltext = spell.spellschool, ""
if (spellschool) then
local t = _detalhes.spells_school [spellschool]
if (t and t.name) then
schooltext = t.formated
end
end
3 years ago
4 years ago
local total_hits = spell.counter
local combat_time = instance.showing:GetCombatTime()
3 years ago
4 years ago
--Cooltip code
3 years ago
GC:AddLine("Hits:", spell.counter)
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
4 years ago
local average = spell.total / total_hits
3 years ago
GC:AddLine("Average:", _detalhes:ToK (average))
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
GC:AddLine("E-Hps:", _detalhes:ToK (spell.total / combat_time))
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
GC:AddLine("School:", schooltext)
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
--GC:AddLine(" ")
GC:AddLine("Normal Hits: ", spell.n_amt .. " (" ..floor( spell.n_amt/total_hits*100) .. "%)")
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
local n_average = spell.n_total / spell.n_amt
local T = (combat_time*spell.n_total)/spell.total
4 years ago
local P = average/n_average*100
T = P*T/100
3 years ago
GC:AddLine("Average / E-Dps: ", _detalhes:ToK (n_average) .. " / " .. format("%.1f",spell.n_total / T ))
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
--GC:AddLine(" ")
GC:AddLine("Critical Hits: ", spell.c_amt .. " (" ..floor( spell.c_amt/total_hits*100) .. "%)")
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
3 years ago
4 years ago
if (spell.c_amt > 0) then
local c_average = spell.c_total/spell.c_amt
local T = (combat_time*spell.c_total)/spell.total
4 years ago
local P = average/c_average*100
T = P*T/100
local crit_dps = spell.c_total / T
3 years ago
GC:AddLine("Average / E-Hps: ", _detalhes:ToK (c_average) .. " / " .. _detalhes:comma_value (crit_dps))
4 years ago
else
3 years ago
GC:AddLine("Average / E-Hps: ", "0 / 0")
4 years ago
end
3 years ago
4 years ago
GC:AddStatusBar (100, 1, R, G, B, A)
end
]],
3 years ago
4 years ago
percent_script = [[
local value, top, total, combat, instance = ...
3 years ago
local dps = _detalhes:ToK (floor(value) / combat:GetCombatTime())
local percent = string.format("%.1f", value/total*100)
4 years ago
return dps .. ", " .. percent
]],
}
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_MYSPELLS"] and (custom.script_version and custom.script_version >= MySpells.script_version) ) then
have = true
break
end
end
if (not have) then
setmetatable(MySpells, Details.atributo_custom)
MySpells.__index = Details.atributo_custom
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_MYSPELLS"]) then
table.remove (self.custom, i)
3 years ago
tinsert(self.custom, i, MySpells)
4 years ago
have = true
end
end
if (not have) then
self.custom [#self.custom+1] = MySpells
end
3 years ago
end
4 years ago
----------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
local DamageOnSkullTarget = {
name = Loc ["STRING_CUSTOM_DAMAGEONSKULL"],
icon = [[Interface\TARGETINGFRAME\UI-RaidTargetingIcon_8]],
attribute = false,
spellid = false,
author = "Details!",
desc = Loc ["STRING_CUSTOM_DAMAGEONSKULL_DESC"],
source = false,
target = false,
script_version = 3,
script = [[
--get the parameters passed
local Combat, CustomContainer, Instance = ...
--declade the values to return
local total, top, amount = 0, 0, 0
3 years ago
--raid target flags:
-- 128: skull
4 years ago
-- 64: cross
-- 32: square
-- 16: moon
-- 8: triangle
-- 4: diamond
-- 2: circle
-- 1: star
3 years ago
4 years ago
--do the loop
3 years ago
for _, actor in ipairs(Combat:GetActorList (DETAILS_ATTRIBUTE_DAMAGE)) do
4 years ago
if (actor:IsPlayer()) then
if (actor.raid_targets [128]) then
CustomContainer:AddValue (actor, actor.raid_targets [128])
3 years ago
end
4 years ago
end
end
--if not managed inside the loop, get the values of total, top and amount
total, top = CustomContainer:GetTotalAndHighestValue()
amount = CustomContainer:GetNumActors()
--return the values
return total, top, amount
]],
tooltip = [[
--get the parameters passed
local actor, combat, instance = ...
--get the cooltip object (we dont use the convencional GameTooltip here)
local GameCooltip = GameCooltip
--Cooltip code
local format_func = Details:GetCurrentToKFunction()
--Cooltip code
local RaidTargets = actor.raid_targets
local DamageOnStar = RaidTargets [128]
if (DamageOnStar) then
--RAID_TARGET_8 is the built-in localized word for 'Skull'.
3 years ago
GameCooltip:AddLine(RAID_TARGET_8 .. ":", format_func (_, DamageOnStar))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_8", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
]],
}
3 years ago
4 years ago
-- /run _detalhes:AddDefaultCustomDisplays()
3 years ago
4 years ago
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DAMAGEONSKULL"] and (custom.script_version and custom.script_version >= DamageOnSkullTarget.script_version) ) then
have = true
break
end
end
if (not have) then
setmetatable(DamageOnSkullTarget, Details.atributo_custom)
DamageOnSkullTarget.__index = Details.atributo_custom
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DAMAGEONSKULL"]) then
table.remove (self.custom, i)
3 years ago
tinsert(self.custom, i, DamageOnSkullTarget)
4 years ago
have = true
end
end
if (not have) then
self.custom [#self.custom+1] = DamageOnSkullTarget
end
3 years ago
end
4 years ago
----------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
local DamageOnAnyTarget = {
name = Loc ["STRING_CUSTOM_DAMAGEONANYMARKEDTARGET"],
icon = [[Interface\TARGETINGFRAME\UI-RaidTargetingIcon_5]],
attribute = false,
spellid = false,
author = "Details!",
desc = Loc ["STRING_CUSTOM_DAMAGEONANYMARKEDTARGET_DESC"],
source = false,
target = false,
script_version = 3,
script = [[
--get the parameters passed
local Combat, CustomContainer, Instance = ...
--declade the values to return
local total, top, amount = 0, 0, 0
--do the loop
3 years ago
for _, actor in ipairs(Combat:GetActorList (DETAILS_ATTRIBUTE_DAMAGE)) do
4 years ago
if (actor:IsPlayer()) then
local total = (actor.raid_targets [1] or 0) --star
total = total + (actor.raid_targets [2] or 0) --circle
total = total + (actor.raid_targets [4] or 0) --diamond
total = total + (actor.raid_targets [8] or 0) --tiangle
total = total + (actor.raid_targets [16] or 0) --moon
total = total + (actor.raid_targets [32] or 0) --square
total = total + (actor.raid_targets [64] or 0) --cross
3 years ago
4 years ago
if (total > 0) then
CustomContainer:AddValue (actor, total)
end
end
end
--if not managed inside the loop, get the values of total, top and amount
total, top = CustomContainer:GetTotalAndHighestValue()
amount = CustomContainer:GetNumActors()
--return the values
return total, top, amount
]],
tooltip = [[
--get the parameters passed
local actor, combat, instance = ...
--get the cooltip object
local GameCooltip = GameCooltip
local format_func = Details:GetCurrentToKFunction()
--Cooltip code
local RaidTargets = actor.raid_targets
local DamageOnStar = RaidTargets [1]
if (DamageOnStar) then
3 years ago
GameCooltip:AddLine(RAID_TARGET_1 .. ":", format_func (_, DamageOnStar))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_1", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
local DamageOnCircle = RaidTargets [2]
if (DamageOnCircle) then
3 years ago
GameCooltip:AddLine(RAID_TARGET_2 .. ":", format_func (_, DamageOnCircle))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_2", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
local DamageOnDiamond = RaidTargets [4]
if (DamageOnDiamond) then
3 years ago
GameCooltip:AddLine(RAID_TARGET_3 .. ":", format_func (_, DamageOnDiamond))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_3", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
local DamageOnTriangle = RaidTargets [8]
if (DamageOnTriangle) then
3 years ago
GameCooltip:AddLine(RAID_TARGET_4 .. ":", format_func (_, DamageOnTriangle))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_4", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
local DamageOnMoon = RaidTargets [16]
if (DamageOnMoon) then
3 years ago
GameCooltip:AddLine(RAID_TARGET_5 .. ":", format_func (_, DamageOnMoon))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_5", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
local DamageOnSquare = RaidTargets [32]
if (DamageOnSquare) then
3 years ago
GameCooltip:AddLine(RAID_TARGET_6 .. ":", format_func (_, DamageOnSquare))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_6", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
local DamageOnCross = RaidTargets [64]
if (DamageOnCross) then
3 years ago
GameCooltip:AddLine(RAID_TARGET_7 .. ":", format_func (_, DamageOnCross))
4 years ago
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcon_7", 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
Details:AddTooltipBackgroundStatusbar()
end
]],
}
3 years ago
4 years ago
-- /run _detalhes:AddDefaultCustomDisplays()
3 years ago
4 years ago
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DAMAGEONANYMARKEDTARGET"] and (custom.script_version and custom.script_version >= DamageOnAnyTarget.script_version) ) then
have = true
break
end
end
if (not have) then
setmetatable(DamageOnAnyTarget, Details.atributo_custom)
DamageOnAnyTarget.__index = Details.atributo_custom
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DAMAGEONANYMARKEDTARGET"]) then
table.remove (self.custom, i)
3 years ago
tinsert(self.custom, i, DamageOnAnyTarget)
4 years ago
have = true
end
end
if (not have) then
self.custom [#self.custom+1] = DamageOnAnyTarget
end
3 years ago
end
4 years ago
----------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
local DynamicOverallDamage = {
name = Loc ["STRING_CUSTOM_DYNAMICOVERAL"], --"Dynamic Overall Damage",
displayName = Loc ["STRING_ATTRIBUTE_DAMAGE_DONE"],
4 years ago
icon = [[Interface\Buttons\Spell-Reset]],
attribute = false,
spellid = false,
author = "Details!",
desc = "Show overall damage done on the fly.",
source = false,
target = false,
3 years ago
script_version = 8,
4 years ago
script = [[
--init:
local combat, instance_container, instance = ...
local total, top, amount = 0, 0, 0
3 years ago
4 years ago
--get the overall combat
3 years ago
local OverallCombat = Details:GetCombat(-1)
4 years ago
--get the current combat
3 years ago
local CurrentCombat = Details:GetCombat(0)
4 years ago
if (not OverallCombat.GetActorList or not CurrentCombat.GetActorList) then
return 0, 0, 0
end
3 years ago
4 years ago
--get the damage actor container for overall
local damage_container_overall = OverallCombat:GetActorList ( DETAILS_ATTRIBUTE_DAMAGE )
--get the damage actor container for current
local damage_container_current = CurrentCombat:GetActorList ( DETAILS_ATTRIBUTE_DAMAGE )
3 years ago
4 years ago
--do the loop:
3 years ago
for _, player in ipairs( damage_container_overall ) do
4 years ago
--only player in group
if (player:IsGroupPlayer()) then
instance_container:AddValue (player, player.total)
end
end
3 years ago
4 years ago
if (Details.in_combat) then
3 years ago
for _, player in ipairs( damage_container_current ) do
4 years ago
--only player in group
if (player:IsGroupPlayer()) then
3 years ago
instance_container:AddValue (player, player.total)
4 years ago
end
end
end
3 years ago
4 years ago
total, top = instance_container:GetTotalAndHighestValue()
amount = instance_container:GetNumActors()
3 years ago
4 years ago
--return:
return total, top, amount
]],
tooltip = [[
--get the parameters passed
local actor, combat, instance = ...
--get the cooltip object (we dont use the convencional GameTooltip here)
local GameCooltip = GameCooltip2
--Cooltip code
--get the overall combat
3 years ago
local OverallCombat = Details:GetCombat(-1)
4 years ago
--get the current combat
3 years ago
local CurrentCombat = Details:GetCombat(0)
4 years ago
local AllSpells = {}
local playerTotal = 0
--overall
3 years ago
local player = OverallCombat [1]:GetActor(actor.nome)
if (player) then
playerTotal = playerTotal + player.total
local playerSpells = player:GetSpellList()
for spellID, spellTable in pairs(playerSpells) do
AllSpells [spellID] = spellTable.total
end
4 years ago
end
--current
if (Details.in_combat) then
3 years ago
local player = CurrentCombat [1]:GetActor(actor.nome)
4 years ago
if (player) then
playerTotal = playerTotal + player.total
local playerSpells = player:GetSpellList()
3 years ago
for spellID, spellTable in pairs(playerSpells) do
4 years ago
AllSpells [spellID] = (AllSpells [spellID] or 0) + (spellTable.total or 0)
end
end
end
local sortedList = {}
3 years ago
for spellID, total in pairs(AllSpells) do
tinsert(sortedList, {spellID, total})
4 years ago
end
table.sort (sortedList, Details.Sort2)
local format_func = Details:GetCurrentToKFunction()
--build the tooltip
local topSpellTotal = sortedList and sortedList[1] and sortedList[1][2] or 0
3 years ago
for i, t in ipairs(sortedList) do
local spellID, total = unpack(t)
4 years ago
if (total > 1) then
3 years ago
local spellName, _, spellIcon = Details.GetSpellInfo(spellID)
4 years ago
local spellPercent = total / playerTotal * 100
local formatedSpellPercent = format("%.1f", spellPercent)
3 years ago
4 years ago
if (string.len(formatedSpellPercent) < 4) then
formatedSpellPercent = formatedSpellPercent .. "0"
end
3 years ago
GameCooltip:AddLine(spellName, format_func (_, total) .. " " .. formatedSpellPercent .. "%")
4 years ago
Details:AddTooltipBackgroundStatusbar(false, total / topSpellTotal * 100)
GameCooltip:AddIcon (spellIcon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height, 0.078125, 0.921875, 0.078125, 0.921875)
3 years ago
4 years ago
end
end
]],
3 years ago
4 years ago
total_script = [[
local value, top, total, combat, instance = ...
return value
]],
percent_script = [[
local value, top, total, combat, instance = ...
--get the time of overall combat
3 years ago
local OverallCombatTime = Details:GetCombat(-1):GetCombatTime()
4 years ago
--get the time of current combat if the player is in combat
if (Details.in_combat) then
3 years ago
local CurrentCombatTime = Details:GetCombat(0):GetCombatTime()
4 years ago
OverallCombatTime = OverallCombatTime + CurrentCombatTime
end
3 years ago
4 years ago
--calculate the DPS and return it as percent
local totalValue = value
3 years ago
4 years ago
--build the string
local ToK = Details:GetCurrentToKFunction()
local s = ToK (_, value / OverallCombatTime)
3 years ago
4 years ago
return s
]],
}
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DYNAMICOVERAL"] and (custom.script_version and custom.script_version >= DynamicOverallDamage.script_version) ) then
have = true
break
end
end
if (not have) then
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DYNAMICOVERAL"]) then
table.remove (self.custom, i)
end
end
setmetatable(DynamicOverallDamage, Details.atributo_custom)
DynamicOverallDamage.__index = Details.atributo_custom
4 years ago
self.custom [#self.custom+1] = DynamicOverallDamage
end
3 years ago
4 years ago
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
4 years ago
local DamageOnShields = {
name = Loc ["STRING_CUSTOM_DAMAGEONSHIELDS"],
icon = [[Interface\ICONS\Spell_Holy_PowerWordShield]],
attribute = false,
spellid = false,
author = "Details!",
desc = "Damage done to shields",
source = false,
target = false,
script_version = 1,
script = [[
--get the parameters passed
local Combat, CustomContainer, Instance = ...
--declade the values to return
local total, top, amount = 0, 0, 0
--do the loop
3 years ago
for index, actor in ipairs(Combat:GetActorList(1)) do
4 years ago
if (actor:IsPlayer()) then
3 years ago
4 years ago
--get the actor total damage absorbed
local totalAbsorb = actor.totalabsorbed
3 years ago
4 years ago
--get the damage absorbed by all the actor pets
3 years ago
for petIndex, petName in ipairs(actor.pets) do
local pet = Combat :GetActor(1, petName)
4 years ago
if (pet) then
totalAbsorb = totalAbsorb + pet.totalabsorbed
end
end
3 years ago
4 years ago
--add the value to the actor on the custom container
3 years ago
CustomContainer:AddValue (actor, totalAbsorb)
4 years ago
end
end
--loop end
--if not managed inside the loop, get the values of total, top and amount
total, top = CustomContainer:GetTotalAndHighestValue()
amount = CustomContainer:GetNumActors()
--return the values
return total, top, amount
]],
tooltip = [[
--get the parameters passed
local actor, Combat, instance = ...
--get the cooltip object (we dont use the convencional GameTooltip here)
local GameCooltip = GameCooltip
--Cooltip code
--get the actor total damage absorbed
local totalAbsorb = actor.totalabsorbed
local format_func = Details:GetCurrentToKFunction()
--get the damage absorbed by all the actor pets
3 years ago
for petIndex, petName in ipairs(actor.pets) do
local pet = Combat :GetActor(1, petName)
4 years ago
if (pet) then
totalAbsorb = totalAbsorb + pet.totalabsorbed
end
end
3 years ago
GameCooltip:AddLine(actor:Name(), format_func (_, actor.totalabsorbed))
4 years ago
Details:AddTooltipBackgroundStatusbar()
3 years ago
for petIndex, petName in ipairs(actor.pets) do
local pet = Combat :GetActor(1, petName)
4 years ago
if (pet) then
totalAbsorb = totalAbsorb + pet.totalabsorbed
3 years ago
GameCooltip:AddLine(petName, format_func (_, pet.totalabsorbed))
Details:AddTooltipBackgroundStatusbar()
4 years ago
end
end
]],
}
local have = false
3 years ago
for _, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DAMAGEONSHIELDS"] and (custom.script_version and custom.script_version >= DamageOnShields.script_version) ) then
have = true
break
end
end
if (not have) then
3 years ago
for i, custom in ipairs(self.custom) do
4 years ago
if (custom.name == Loc ["STRING_CUSTOM_DAMAGEONSHIELDS"]) then
table.remove (self.custom, i)
end
end
setmetatable(DamageOnShields, Details.atributo_custom)
DamageOnShields.__index = Details.atributo_custom
4 years ago
self.custom [#self.custom+1] = DamageOnShields
3 years ago
end
---------------------------------------
Details:ResetCustomFunctionsCache()
3 years ago
4 years ago
end