From 4ab2f1241dbc7789cbc368c0059237ce90e6cd30 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Mon, 10 Apr 2023 14:34:16 -0300 Subject: [PATCH] 'n_curado' 'n_dmg' 'c_curado' and 'c_dmg' renamed to 'n_total' and 'c_total' --- API.lua | 8 +- API.txt | 8 +- Definitions.lua | 27 ++-- boot.lua | 2 +- classes/class_custom.lua | 28 ++-- classes/class_damage.lua | 14 +- classes/class_heal.lua | 145 +++++++++++++++-- classes/class_spelldamage.lua | 8 +- classes/class_spellhealing.lua | 86 +++++----- frames/window_playerbreakdown_spells.lua | 195 ++++++++++++++++++----- functions/api2.lua | 8 +- functions/mixin.lua | 4 +- 12 files changed, 382 insertions(+), 151 deletions(-) diff --git a/API.lua b/API.lua index ecaeaa6d..b2c4ad0e 100644 --- a/API.lua +++ b/API.lua @@ -382,11 +382,11 @@ spell.successful_casted = how many times this spell has been casted successfully spell.n_min = minimal damage made on a normal hit. spell.n_max = max damage made on a normal hit. spell.n_amt = amount of normal hits. -spell.n_dmg = total amount made doing only normal hits. +spell.n_total = total amount made doing only normal hits. spell.c_min = minimal damage made on a critical hit. spell.c_max = max damage made on a critical hit. spell.c_amt = how many times this spell got a critical hit. -spell.c_dmg = total amount made doing only normal hits. +spell.c_total = total amount made doing only normal hits. spell.g_amt = how many glancing blows this spell has. spell.g_dmg = total damage made by glancing blows. spell.r_amt = total of times this spell got resisted by the target. @@ -438,11 +438,11 @@ spell.overheal = amount of overheal made by this spell. spell.n_min = minimal heal made on a normal hit. spell.n_max = max heal made on a normal hit. spell.n_amt = amount of normal hits. -spell.n_curado = total amount made doing only normal hits (weird name I know). +spell.n_total = total amount made doing only normal hits (weird name I know). spell.c_min = minimal heal made on a critical hit. spell.c_max = max heal made on a critical hit. spell.c_amt = how many times this spell got a critical hit. -spell.c_curado = total amount made doing only normal hits. +spell.c_total = total amount made doing only normal hits. spell.targets = hash table containing {["targetname"] = total healing done by this spell on this target} spell.targets_overheal = hash table containing {["targetname"] = total overhealing by this spell on this target} diff --git a/API.txt b/API.txt index dcad0775..b685f0dc 100644 --- a/API.txt +++ b/API.txt @@ -385,11 +385,11 @@ spell.successful_casted = how many times this spell has been casted successfully spell.n_min = minimal damage made on a normal hit. spell.n_max = max damage made on a normal hit. spell.n_amt = amount of normal hits. -spell.n_dmg = total amount made doing only normal hits. +spell.n_total = total amount made doing only normal hits. spell.c_min = minimal damage made on a critical hit. spell.c_max = max damage made on a critical hit. spell.c_amt = how many times this spell got a critical hit. -spell.c_dmg = total amount made doing only normal hits. +spell.c_total = total amount made doing only normal hits. spell.g_amt = how many glancing blows this spell has. spell.g_dmg = total damage made by glancing blows. spell.r_amt = total of times this spell got resisted by the target. @@ -442,11 +442,11 @@ spell.overheal = amount of overheal made by this spell. spell.n_min = minimal heal made on a normal hit. spell.n_max = max heal made on a normal hit. spell.n_amt = amount of normal hits. -spell.n_curado = total amount made doing only normal hits (weird name I know). +spell.n_total = total amount made doing only normal hits (weird name I know). spell.c_min = minimal heal made on a critical hit. spell.c_max = max heal made on a critical hit. spell.c_amt = how many times this spell got a critical hit. -spell.c_curado = total amount made doing only normal hits. +spell.c_total = total amount made doing only normal hits. spell.targets = hash table containing {["targetname"] = total healing done by this spell on this target} spell.targets_overheal = hash table containing {["targetname"] = total overhealing by this spell on this target} diff --git a/Definitions.lua b/Definitions.lua index 68f50813..ea52f6df 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -314,15 +314,17 @@ ---@field total number ---@field spellschool number ---@field counter number amount of hits ----@field c_amt number critical hits ----@field c_min number ----@field c_max number ----@field c_dmg number ----@field n_amt number normal hits ----@field n_dmg number total damage made by normal hits ----@field n_min number min damage made by normal hits ----@field n_max number max damage made by normal hits +---@field c_amt number critical hits by a damage or heal spell +---@field c_min number min damage or healing done by critical hits of the spell +---@field c_max number min damage or healing done by critical hits of the spell +---@field c_total number total damage or heal made by critical hits of the spell +---@field n_amt number normal hits by a damage or heal spell +---@field n_min number min damage or healing done by normal hits of the spell +---@field n_max number min damage or healing done by normal hits of the spell +---@field n_total number total damage or heal made by normal hits of the spell ---@field targets table store the [target name] = total value +---@field targets_overheal table +---@field targets_absorbs table ---@field id number --spellid ---@field successful_casted number successful casted times (only for enemies) ---@field g_amt number glacing hits @@ -333,6 +335,11 @@ ---@field b_dmg number ---@field a_amt number --absorved ---@field a_dmg number +---@field totalabsorb number healing absorbed +---@field absorbed number damage absorbed by shield | healing absorbed by buff or debuff +---@field overheal number +---@field totaldenied number + ---@class actor : table ---@field GetSpellContainer fun(actor: actor, containerType: string) @@ -449,9 +456,9 @@ ---@field c_amt number critical hits ---@field c_min number ---@field c_max number ----@field c_dmg number +---@field c_total number ---@field n_amt number normal hits ----@field n_dmg number total damage made by normal hits +---@field n_total number total damage made by normal hits ---@field n_min number min damage made by normal hits ---@field n_max number max damage made by normal hits ---@field successful_casted number successful casted times (only for enemies) diff --git a/boot.lua b/boot.lua index abc1b925..ee11d730 100644 --- a/boot.lua +++ b/boot.lua @@ -15,7 +15,7 @@ _detalhes.dont_open_news = true _detalhes.game_version = version _detalhes.userversion = version .. " " .. _detalhes.build_counter - _detalhes.realversion = 148 --core version, this is used to check API version for scripts and plugins (see alias below) + _detalhes.realversion = 149 --core version, this is used to check API version for scripts and plugins (see alias below) _detalhes.APIVersion = _detalhes.realversion --core version _detalhes.version = _detalhes.userversion .. " (core " .. _detalhes.realversion .. ")" --simple stirng to show to players diff --git a/classes/class_custom.lua b/classes/class_custom.lua index 006193e4..4e69681b 100644 --- a/classes/class_custom.lua +++ b/classes/class_custom.lua @@ -1820,7 +1820,7 @@ local role = DetailsFramework.UnitGroupRolesAssigned("player") - if (spell.n_dmg) then + if (spell.n_total) then local spellschool, schooltext = spell.spellschool, "" if (spellschool) then @@ -1885,12 +1885,12 @@ GC:AddLine("Normal Hits: ", spell.n_amt .. " (" ..floor( spell.n_amt/total_hits*100) .. "%)") GC:AddStatusBar (100, 1, R, G, B, A) - local n_average = spell.n_dmg / spell.n_amt - local T = (combat_time*spell.n_dmg)/spell.total + local n_average = spell.n_total / spell.n_amt + local T = (combat_time*spell.n_total)/spell.total local P = average/n_average*100 T = P*T/100 - GC:AddLine("Average / E-Dps: ", _detalhes:ToK (n_average) .. " / " .. format("%.1f",spell.n_dmg / T )) + GC:AddLine("Average / E-Dps: ", _detalhes:ToK (n_average) .. " / " .. format("%.1f",spell.n_total / T )) GC:AddStatusBar (100, 1, R, G, B, A) --GC:AddLine(" ") @@ -1899,11 +1899,11 @@ GC:AddStatusBar (100, 1, R, G, B, A) if (spell.c_amt > 0) then - local c_average = spell.c_dmg/spell.c_amt - local T = (combat_time*spell.c_dmg)/spell.total + local c_average = spell.c_total/spell.c_amt + local T = (combat_time*spell.c_total)/spell.total local P = average/c_average*100 T = P*T/100 - local crit_dps = spell.c_dmg / T + local crit_dps = spell.c_total / T GC:AddLine("Average / E-Dps: ", _detalhes:ToK (c_average) .. " / " .. _detalhes:comma_value (crit_dps)) else @@ -1913,7 +1913,7 @@ GC:AddStatusBar (100, 1, R, G, B, A) - elseif (spell.n_curado) then + elseif (spell.n_total) then local spellschool, schooltext = spell.spellschool, "" if (spellschool) then @@ -1945,12 +1945,12 @@ GC:AddLine("Normal Hits: ", spell.n_amt .. " (" ..floor( spell.n_amt/total_hits*100) .. "%)") GC:AddStatusBar (100, 1, R, G, B, A) - local n_average = spell.n_curado / spell.n_amt - local T = (combat_time*spell.n_curado)/spell.total + local n_average = spell.n_total / spell.n_amt + local T = (combat_time*spell.n_total)/spell.total local P = average/n_average*100 T = P*T/100 - GC:AddLine("Average / E-Dps: ", _detalhes:ToK (n_average) .. " / " .. format("%.1f",spell.n_curado / T )) + GC:AddLine("Average / E-Dps: ", _detalhes:ToK (n_average) .. " / " .. format("%.1f",spell.n_total / T )) GC:AddStatusBar (100, 1, R, G, B, A) --GC:AddLine(" ") @@ -1959,11 +1959,11 @@ GC:AddStatusBar (100, 1, R, G, B, A) if (spell.c_amt > 0) then - local c_average = spell.c_curado/spell.c_amt - local T = (combat_time*spell.c_curado)/spell.total + local c_average = spell.c_total/spell.c_amt + local T = (combat_time*spell.c_total)/spell.total local P = average/c_average*100 T = P*T/100 - local crit_dps = spell.c_curado / T + local crit_dps = spell.c_total / T GC:AddLine("Average / E-Hps: ", _detalhes:ToK (c_average) .. " / " .. _detalhes:comma_value (crit_dps)) else diff --git a/classes/class_damage.lua b/classes/class_damage.lua index d52b38e2..5f5f501c 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -4520,7 +4520,7 @@ function atributo_damage:MontaInfoDamageDone() --I guess this fills the list of ---@type number local totalDamageWithoutPet = actorObject.total_without_pet ---@type number - local actorTotalDamage = actorObject.total + local actorTotal = actorObject.total ---@type table local actorSpellsSorted = {} ---@type table @@ -4537,7 +4537,7 @@ function atributo_damage:MontaInfoDamageDone() --I guess this fills the list of end --actor spells - ---@type {[string]: number} + ---@type table local alreadyAdded = {} for spellId, spellTable in pairs(actorSpells) do ---@cast spellId number @@ -4632,7 +4632,7 @@ function atributo_damage:MontaInfoDamageDone() --I guess this fills the list of return t1.total > t2.total end) - actorSpellsSorted.totalValue = actorTotalDamage + actorSpellsSorted.totalValue = actorTotal actorSpellsSorted.combatTime = actorCombatTime --actorSpellsSorted has the spell infomation, need to pass to the summary tab @@ -5283,7 +5283,7 @@ function atributo_damage:MontaDetalhesDamageDone (spellId, spellLine, instance) --NORMAL local normal_hits = spellTable.n_amt if (normal_hits > 0) then - local normal_dmg = spellTable.n_dmg + local normal_dmg = spellTable.n_total local media_normal = normal_dmg/normal_hits local T = (meu_tempo*normal_dmg)/ max(spellTable.total, 0.001) local P = media/media_normal*100 @@ -5306,11 +5306,11 @@ function atributo_damage:MontaDetalhesDamageDone (spellId, spellLine, instance) --CRITICO if (spellTable.c_amt > 0) then - local media_critico = spellTable.c_dmg/spellTable.c_amt - local T = (meu_tempo*spellTable.c_dmg)/spellTable.total + local media_critico = spellTable.c_total/spellTable.c_amt + local T = (meu_tempo*spellTable.c_total)/spellTable.total local P = media/max(media_critico, 0.0001)*100 T = P*T/100 - local crit_dps = spellTable.c_dmg/T + local crit_dps = spellTable.c_total/T if (not crit_dps) then crit_dps = 0 end diff --git a/classes/class_heal.lua b/classes/class_heal.lua index 864f411c..9dd79480 100644 --- a/classes/class_heal.lua +++ b/classes/class_heal.lua @@ -122,11 +122,6 @@ end --tooltip function - -local function RefreshNpcHealingTakenBar(tabela, barra, instancia) - atributo_damage:UpdateNpcHealingTaken(tabela, tabela.minha_barra, barra.colocacao, instancia) -end - local on_switch_NHT_show = function(instance) --npc healing taken instance:TrocaTabela(instance, true, 1, 8) return true @@ -1868,8 +1863,138 @@ function atributo_heal:MontaInfoOverHealing() end function atributo_heal:MontaInfoHealingDone() + ---@type actor + local actorObject = self + ---@type instance + local instance = info.instancia + ---@type combat + local combatObject = instance:GetCombat() + ---@type string + local playerName = actorObject:Name() - --pegar as habilidade de dar sort no heal + ---@type number + local actorTotal = actorObject.total + ---@type table + local actorSpellsSorted = {} + ---@type table + local actorSpells = actorObject:GetSpellList() + + --get time + local actorCombatTime + if (Details.time_type == 1 or not actorObject.grupo) then + actorCombatTime = actorObject:Tempo() + elseif (Details.time_type == 2) then + actorCombatTime = info.instancia.showing:GetCombatTime() + end + + --actor spells + ---@type table + local alreadyAdded = {} + for spellId, spellTable in pairs(actorSpells) do + ---@cast spellId number + ---@cast spellTable spelltable + + spellTable.ChartData = nil + + ---@type string + local spellName = _GetSpellInfo(spellId) + if (spellName) then + ---@type number in which index the spell with the same name was stored + local index = alreadyAdded[spellName] + if (index) then + ---@type breakdownspelldata + local bkSpellData = actorSpellsSorted[index] + bkSpellData.spellIds[#bkSpellData.spellIds+1] = spellId + bkSpellData.spellTables[#bkSpellData.spellTables+1] = spellTable + bkSpellData.petNames[#bkSpellData.petNames+1] = "" + bkSpellData.bCanExpand = true + else + ---@type breakdownspelldata + local bkSpellData = { + id = spellId, + spellschool = spellTable.spellschool, + bIsExpanded = Details222.BreakdownWindow.IsSpellExpanded(spellId), + bCanExpand = false, + + spellIds = {spellId}, + spellTables = {spellTable}, --sub spell tables to show if the spell is expanded + petNames = {""}, + } + + actorSpellsSorted[#actorSpellsSorted+1] = bkSpellData + alreadyAdded[spellName] = #actorSpellsSorted + end + end + end + + --pets spells + local actorPets = actorObject:GetPets() + for _, petName in ipairs(actorPets) do + ---@type actor + local petActor = combatObject(DETAILS_ATTRIBUTE_HEAL, petName) + if (petActor) then --PET + local spells = petActor:GetSpellList() + for spellId, spellTable in pairs(spells) do + ---@cast spellId number + ---@cast spellTable spelltable + + spellTable.ChartData = nil + --PET + ---@type string + local spellName = _GetSpellInfo(spellId) + if (spellName) then + ---@type number in which index the spell with the same name was stored + local index = alreadyAdded[spellName] + if (index) then --PET + ---@type breakdownspelldata + local bkSpellData = actorSpellsSorted[index] + bkSpellData.spellIds[#bkSpellData.spellIds+1] = spellId + bkSpellData.spellTables[#bkSpellData.spellTables+1] = spellTable + bkSpellData.petNames[#bkSpellData.petNames+1] = petName + bkSpellData.bCanExpand = true + else --PET + ---@type breakdownspelldata + local bkSpellData = { + id = spellId, + spellschool = spellTable.spellschool, + expanded = Details222.BreakdownWindow.IsSpellExpanded(spellId), + bCanExpand = false, + + spellIds = {spellId}, + spellTables = {spellTable}, + petNames = {petName}, + } + actorSpellsSorted[#actorSpellsSorted+1] = bkSpellData + alreadyAdded[spellName] = #actorSpellsSorted + end + end + end + end + end + + for i = 1, #actorSpellsSorted do + ---@type breakdownspelldata + local bkSpellData = actorSpellsSorted[i] + Details:SumSpellTables(bkSpellData.spellTables, bkSpellData) + end + + --table.sort(actorSpellsSorted, Details.Sort2) + table.sort(actorSpellsSorted, function(t1, t2) + return t1.total > t2.total + end) + + actorSpellsSorted.totalValue = actorTotal + actorSpellsSorted.combatTime = actorCombatTime + + --actorSpellsSorted has the spell infomation, need to pass to the summary tab + + --cleanup + table.wipe(alreadyAdded) + + --send to the breakdown window + Details222.BreakdownWindow.SendSpellData(actorSpellsSorted, actorObject, combatObject, instance) + + if 1 then return end local instancia = info.instancia local total = self.total @@ -2306,7 +2431,7 @@ function atributo_heal:MontaDetalhesHealingDone (spellid, barra) --NORMAL local normal_hits = esta_magia.n_amt if (normal_hits > 0) then - local normal_curado = esta_magia.n_curado + local normal_curado = esta_magia.n_total local media_normal = normal_curado/normal_hits media_normal = max(media_normal, 0.000001) @@ -2337,11 +2462,11 @@ function atributo_heal:MontaDetalhesHealingDone (spellid, barra) --CRITICO if (esta_magia.c_amt > 0) then - local media_critico = esta_magia.c_curado/esta_magia.c_amt - local T = (meu_tempo*esta_magia.c_curado)/esta_magia.total + local media_critico = esta_magia.c_total/esta_magia.c_amt + local T = (meu_tempo*esta_magia.c_total)/esta_magia.total local P = media/max(media_critico, 0.0001)*100 T = P*T/100 - local crit_hps = esta_magia.c_curado/T + local crit_hps = esta_magia.c_total/T if (not crit_hps) then crit_hps = 0 end diff --git a/classes/class_spelldamage.lua b/classes/class_spelldamage.lua index 1218115d..1fc50ba3 100644 --- a/classes/class_spelldamage.lua +++ b/classes/class_spelldamage.lua @@ -41,13 +41,13 @@ --amount normal hits n_amt = 0, --total damage of normal hits - n_dmg = 0, + n_total = 0, --critical hits c_min = 0, c_max = 0, c_amt = 0, - c_dmg = 0, + c_total = 0, --glacing hits g_amt = 0, @@ -117,7 +117,7 @@ self.g_amt = self.g_amt+1 --amount � o total de dano elseif (critical) then - self.c_dmg = self.c_dmg+amount --amount � o total de dano + self.c_total = self.c_total+amount --amount � o total de dano self.c_amt = self.c_amt+1 --amount � o total de dano if (amount > self.c_max) then self.c_max = amount @@ -127,7 +127,7 @@ end else - self.n_dmg = self.n_dmg+amount + self.n_total = self.n_total+amount self.n_amt = self.n_amt+1 if (amount > self.n_max) then self.n_max = amount diff --git a/classes/class_spellhealing.lua b/classes/class_spellhealing.lua index 6a1c43bd..f0939aa0 100644 --- a/classes/class_spellhealing.lua +++ b/classes/class_spellhealing.lua @@ -1,96 +1,86 @@ --- heal ability file - local _detalhes = _G._detalhes + local Details = _G._detalhes local _ local addonName, Details222 = ... + local healingAbility = Details.habilidade_cura ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---constants - - local alvo_da_habilidade = _detalhes.alvo_da_habilidade - local habilidade_cura = _detalhes.habilidade_cura - local container_combatentes = _detalhes.container_combatentes - local container_heal_target = _detalhes.container_type.CONTAINER_HEALTARGET_CLASS - local container_playernpc = _detalhes.container_type.CONTAINER_PLAYERNPC - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---internals - - function habilidade_cura:NovaTabela (id, link) - - local _newHealSpell = { - + function healingAbility:NovaTabela(id) + ---@type spelltable + local spellTable = { + --spellId id = id, + --total amount of hits counter = 0, - - --totals - total = 0, + + --healing done total (healing done by normal hits + healing done by critical hits) + total = 0, + --absorbs total totalabsorb = 0, absorbed = 0, + --overheal total overheal = 0, + --heal denied totaldenied = 0, - --normal hits - n_min = 0, - n_max = 0, - n_amt = 0, - n_curado = 0, - - --critical hits - c_min = 0, - c_max = 0, - c_amt = 0, - c_curado = 0, + --healing done by normal hits + n_amt = 0, --amount of hits + n_min = 0, --min healing done by normal hits (non critical) + n_max = 0, --max healing done by normal hits (non critical) + n_total = 0, --total healing done by normal hits (non critical) + + --healing done by critical hits + c_amt = 0, --amount of hits + c_min = 0, --min healing done by critical hits + c_max = 0, --max healing done by critical hits + c_total = 0, --total healing done by critical hits --targets containers targets = {}, targets_overheal = {}, targets_absorbs = {} } - - return _newHealSpell + + return spellTable end - function habilidade_cura:Add (serial, nome, flag, amount, extraSpellID, absorbed, critical, overhealing, is_shield) - + function healingAbility:Add(serial, nome, flag, amount, extraSpellID, absorbed, critical, overhealing, bIsShield) amount = amount or 0 self.targets [nome] = (self.targets [nome] or 0) + amount if (absorbed == "SPELL_HEAL_ABSORBED") then self.counter = self.counter + 1 self.totaldenied = self.totaldenied + amount - + local healerName = critical - + --create the denied table spells, on the fly if (not self.heal_denied) then self.heal_denied = {} self.heal_denied_healers = {} end - + self.heal_denied [extraSpellID] = (self.heal_denied [extraSpellID] or 0) + amount self.heal_denied_healers [healerName] = (self.heal_denied_healers [healerName] or 0) + amount else - self.total = self.total + amount self.counter = self.counter + 1 - + if (absorbed and absorbed > 0) then self.absorbed = self.absorbed + absorbed end - + if (overhealing and overhealing > 0) then self.overheal = self.overheal + overhealing self.targets_overheal [nome] = (self.targets_overheal [nome] or 0) + overhealing end - - if (is_shield) then + + if (bIsShield) then self.totalabsorb = self.totalabsorb + amount self.targets_absorbs [nome] = (self.targets_absorbs [nome] or 0) + amount end - + if (critical) then - self.c_curado = self.c_curado+amount --amount � o total de dano + self.c_total = self.c_total+amount --amount � o total de dano self.c_amt = self.c_amt+1 --amount � o total de dano if (amount > self.c_max) then self.c_max = amount @@ -99,7 +89,7 @@ self.c_min = amount end else - self.n_curado = self.n_curado+amount + self.n_total = self.n_total+amount self.n_amt = self.n_amt+1 if (amount > self.n_max) then self.n_max = amount @@ -108,8 +98,6 @@ self.n_min = amount end end - end - end diff --git a/frames/window_playerbreakdown_spells.lua b/frames/window_playerbreakdown_spells.lua index e7e387d9..82e94f5b 100644 --- a/frames/window_playerbreakdown_spells.lua +++ b/frames/window_playerbreakdown_spells.lua @@ -72,7 +72,7 @@ function spellsTab.GetSpellBlockContainer() return spellsTab.TabFrame.SpellBlockContainer end ----@type {name: string, width: number, label: string, align: string, enabled: boolean}[] +---@type {name: string, width: number, label: string, align: string, enabled: boolean, attribute: number|nil}[] local columnInfo = { {name = "icon", width = 22, label = "", align = "center", enabled = true,}, {name = "target", width = 22, label = "", align = "center", enabled = true}, @@ -80,15 +80,50 @@ local columnInfo = { {name = "expand", label = "^", width = 16, align = "center", enabled = true}, {name = "name", label = "spell name", width = 246, align = "left", enabled = true}, {name = "amount", label = "total", width = 50, align = "left", enabled = true}, - {name = "persecond", label = "ps", width = 50, align = "left", enabled = false}, + {name = "persecond", label = "ps", width = 50, align = "left", enabled = true}, {name = "percent", label = "%", width = 50, align = "left", enabled = true}, - {name = "casts", label = "casts", width = 40, align = "left", enabled = false}, - {name = "critpercent", label = "crit %", width = 40, align = "left", enabled = false}, - {name = "hits", label = "hits", width = 40, align = "left", enabled = false}, - {name = "castavg", label = "cast avg", width = 50, align = "left", enabled = false}, - {name = "uptime", label = "uptime", width = 45, align = "left", enabled = false}, + {name = "casts", label = "casts", width = 40, align = "left", enabled = true}, + {name = "critpercent", label = "crit %", width = 40, align = "left", enabled = true}, + {name = "hits", label = "hits", width = 40, align = "left", enabled = true}, + {name = "castavg", label = "cast avg", width = 50, align = "left", enabled = true}, + {name = "uptime", label = "uptime", width = 45, align = "left", enabled = true}, + {name = "overheal", label = "overheal", width = 45, align = "left", enabled = true, attribute = DETAILS_ATTRIBUTE_HEAL}, + {name = "absorbed", label = "absorbed", width = 45, align = "left", enabled = true, attribute = DETAILS_ATTRIBUTE_HEAL}, } +function spellsTab.BuildHeaderTable() + ---@type {name: string, width: number, label: string, align: string, enabled: boolean}[] + local headerTable = {} + + ---@type instance + local instance = spellsTab.GetInstance() + + ---@type number, number + local mainAttribute, subAttribute = instance:GetDisplay() + + for i = 1, #columnInfo do + local columnData = columnInfo[i] + if (columnData.enabled) then + local bCanAdd = true + if (columnData.attribute) then + if (columnData.attribute ~= mainAttribute) then + bCanAdd = false + end + end + + if (bCanAdd) then + headerTable[#headerTable+1] = { + text = columnData.label, + width = columnData.width, + name = columnData.name, + --align = column.align, + } + end + end + end + return headerTable +end + --store the current spellbar selected, this is used to lock the spellblock container to the spellbar selected spellsTab.selectedSpellBar = nil @@ -149,23 +184,6 @@ function spellsTab.OnShownTab() spellsTab.GetSpellBlockContainer():ClearBlocks() end - -function spellsTab.BuildHeaderTable() - local headerTable = {} - for i = 1, #columnInfo do - local columnData = columnInfo[i] - if (columnData.enabled) then - headerTable[#headerTable+1] = { - text = columnData.label, - width = columnData.width, - name = columnData.name, - --align = column.align, - } - end - end - return headerTable -end - --called when the tab is getting created function spellsTab.OnCreateTabCallback(tabButton, tabFrame) spellBreakdownSettings = Details.breakdown_spell_tab @@ -307,7 +325,7 @@ function spellsTab.TrocaBackgroundInfo(tabFrame) --> spells tab | to be refactor end end -do --hide bars functions +do --hide bars functions - to be refactored --hide all the bars of the skills in the window info function spellsTab.HidaAllBarrasInfo() local allBars = _detalhes.playerDetailWindow.barras1 @@ -477,7 +495,9 @@ local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por no GameTooltip:Show() end - if (mainAttribute == DETAILS_ATTRIBUTE_DAMAGE and subAttribute == DETAILS_SUBATTRIBUTE_DAMAGEDONE) then + if (mainAttribute == DETAILS_ATTRIBUTE_DAMAGE) then --this should run within the damage class + local bShowDamageDone = subAttribute == DETAILS_SUBATTRIBUTE_DAMAGEDONE or subAttribute == DETAILS_SUBATTRIBUTE_DPS + ---@type number local blockIndex = 1 @@ -508,13 +528,6 @@ local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por no ---@type number local normalHitsAmt = spellTable.n_amt - --problem: spellTable is in facts bkSpellTable, fuck! - if (not normalHitsAmt) then - print(spellTable.spellTables, spellTable.petNames) - dumpt(spellTable) - return - end - if (normalHitsAmt > 0) then ---@type breakdownspellblock local normalHitsBlock = spellBlockContainer:GetBlock(blockIndex) @@ -533,13 +546,13 @@ local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por no blockLine2.leftText:SetText(Loc ["STRING_MINIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.n_min)) blockLine2.rightText:SetText(Loc ["STRING_MAXIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.n_max)) - local normalAverage = spellTable.n_dmg / math.max(normalHitsAmt, 0.0001) + local normalAverage = spellTable.n_total / math.max(normalHitsAmt, 0.0001) blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(normalAverage)) - local tempo = (elapsedTime * spellTable.n_dmg) / math.max(spellTable.total, 0.001) + local tempo = (elapsedTime * spellTable.n_total) / math.max(spellTable.total, 0.001) local normalAveragePercent = spellBar.average / normalAverage * 100 local normalTempoPercent = normalAveragePercent * tempo / 100 - blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.n_dmg / normalTempoPercent)) + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.n_total / normalTempoPercent)) end ---@type number @@ -562,13 +575,100 @@ local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por no blockLine2.leftText:SetText(Loc ["STRING_MINIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_min)) blockLine2.rightText:SetText(Loc ["STRING_MAXIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_max)) - local critAverage = spellTable.c_dmg / math.max(criticalHitsAmt, 0.0001) + local critAverage = spellTable.c_total / math.max(criticalHitsAmt, 0.0001) blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(critAverage)) - local tempo = (elapsedTime * spellTable.c_dmg) / math.max(spellTable.total, 0.001) + local tempo = (elapsedTime * spellTable.c_total) / math.max(spellTable.total, 0.001) local critAveragePercent = spellBar.average / critAverage * 100 local critTempoPercent = critAveragePercent * tempo / 100 - blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.c_dmg / critTempoPercent)) + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.c_total / critTempoPercent)) + end + + elseif (mainAttribute == DETAILS_ATTRIBUTE_HEAL) then --this should run within the heal class + ---@type number + local blockIndex = 1 + + ---@type number + local totalHits = spellTable.counter + + --damage section showing damage done sub section + --get the first spell block to use as summary + ---@type breakdownspellblock + local summaryBlock = spellBlockContainer:GetBlock(blockIndex) + summaryBlock:Show() + blockIndex = blockIndex + 1 + + do --update the texts in the summary block + local blockLine1, blockLine2, blockLine3 = summaryBlock:GetLines() + + blockLine1.leftText:SetText(Loc ["STRING_CAST"] .. ": " .. spellBar.amountCasts) --total amount of casts + blockLine1.rightText:SetText(Loc ["STRING_HITS"]..": " .. totalHits) --hits and uptime + + blockLine2.leftText:SetText(Loc ["STRING_DAMAGE"]..": " .. Details:Format(spellTable.total)) --total damage + blockLine2.rightText:SetText(Details:GetSpellSchoolFormatedName(spellTable.spellschool)) --spell school + + blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:Format(spellBar.average)) --average damage + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellBar.perSecond)) --dps + end + + --check if there's normal hits and build the block + ---@type number + local normalHitsAmt = spellTable.n_amt + + if (normalHitsAmt > 0) then + ---@type breakdownspellblock + local normalHitsBlock = spellBlockContainer:GetBlock(blockIndex) + normalHitsBlock:Show() + blockIndex = blockIndex + 1 + + local percent = normalHitsAmt / math.max(totalHits, 0.0001) * 100 + normalHitsBlock:SetValue(percent) + normalHitsBlock.sparkTexture:SetPoint("left", normalHitsBlock, "left", percent / 100 * normalHitsBlock:GetWidth() + spellBreakdownSettings.blockspell_spark_offset, 0) + normalHitsBlock:SetStatusBarColor(1, 1, 1, .5) + + local blockLine1, blockLine2, blockLine3 = normalHitsBlock:GetLines() + blockLine1.leftText:SetText(Loc ["STRING_NORMAL_HITS"]) + blockLine1.rightText:SetText(normalHitsAmt .. " [|cFFC0C0C0" .. string.format("%.1f", normalHitsAmt / math.max(totalHits, 0.0001) * 100) .. "%|r]") + + blockLine2.leftText:SetText(Loc ["STRING_MINIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.n_min)) + blockLine2.rightText:SetText(Loc ["STRING_MAXIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.n_max)) + + local normalAverage = spellTable.n_total / math.max(normalHitsAmt, 0.0001) + blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(normalAverage)) + + local tempo = (elapsedTime * spellTable.n_total) / math.max(spellTable.total, 0.001) + local normalAveragePercent = spellBar.average / normalAverage * 100 + local normalTempoPercent = normalAveragePercent * tempo / 100 + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.n_total / normalTempoPercent)) + end + + ---@type number + local criticalHitsAmt = spellTable.c_amt + if (criticalHitsAmt > 0) then + ---@type breakdownspellblock + local critHitsBlock = spellBlockContainer:GetBlock(blockIndex) + critHitsBlock:Show() + blockIndex = blockIndex + 1 + + local percent = criticalHitsAmt / math.max(totalHits, 0.0001) * 100 + critHitsBlock:SetValue(percent) + critHitsBlock.sparkTexture:SetPoint("left", critHitsBlock, "left", percent / 100 * critHitsBlock:GetWidth() + spellBreakdownSettings.blockspell_spark_offset, 0) + critHitsBlock:SetStatusBarColor(1, 1, 1, .5) + + local blockLine1, blockLine2, blockLine3 = critHitsBlock:GetLines() + blockLine1.leftText:SetText(Loc ["STRING_CRITICAL_HITS"]) + blockLine1.rightText:SetText(criticalHitsAmt .. " [|cFFC0C0C0" .. string.format("%.1f", criticalHitsAmt / math.max(totalHits, 0.0001) * 100) .. "%|r]") + + blockLine2.leftText:SetText(Loc ["STRING_MINIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_min)) + blockLine2.rightText:SetText(Loc ["STRING_MAXIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_max)) + + local critAverage = spellTable.c_total / math.max(criticalHitsAmt, 0.0001) + blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(critAverage)) + + local tempo = (elapsedTime * spellTable.c_total) / math.max(spellTable.total, 0.001) + local critAveragePercent = spellBar.average / critAverage * 100 + local critTempoPercent = critAveragePercent * tempo / 100 + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.c_total / critTempoPercent)) end end @@ -1071,12 +1171,12 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll spellBar:AddFrameToHeaderAlignment(text) textIndex = textIndex + 1 - elseif (header.name == "hits") then --ok + elseif (header.name == "hits") then text:SetText(spellTable.counter) spellBar:AddFrameToHeaderAlignment(text) textIndex = textIndex + 1 - elseif (header.name == "castavg") then --ok + elseif (header.name == "castavg") then spellBar.castAverage = value / amtCasts text:SetText(Details:Format(spellBar.castAverage)) spellBar:AddFrameToHeaderAlignment(text) @@ -1086,6 +1186,17 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll text:SetText(string.format("%.1f", uptime / combatTime * 100) .. "%") spellBar:AddFrameToHeaderAlignment(text) textIndex = textIndex + 1 + + elseif (header.name == "overheal") then + text:SetText(Details:Format(spellTable.overheal or 0)) + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "absorbed") then + text:SetText(Details:Format(spellTable.absorbed or 0)) + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + end end @@ -1227,7 +1338,7 @@ function spellsTab.CreateSpellScrollContainer(tabFrame) header_height = 14, } - local headerTable = spellsTab.BuildHeaderTable() + local headerTable = {} scrollFrame.Header = DetailsFramework:CreateHeader(scrollFrame, headerTable, headerOptions) scrollFrame.Header:SetPoint("topleft", scrollFrame, "topleft", 0, 0) diff --git a/functions/api2.lua b/functions/api2.lua index d0174682..a3ead385 100644 --- a/functions/api2.lua +++ b/functions/api2.lua @@ -964,11 +964,11 @@ function Details.UnitDamageSpellInfo (unitId, spellId, isLiteral, segment) spellInfo.regularMin = spellObject.n_min spellInfo.regularMax = spellObject.n_max spellInfo.regularHits = spellObject.n_amt - spellInfo.regularDamage = spellObject.n_dmg + spellInfo.regularDamage = spellObject.n_total spellInfo.criticalMin = spellObject.c_min spellInfo.criticalMax = spellObject.c_max spellInfo.criticalHits = spellObject.c_amt - spellInfo.criticalDamage = spellObject.c_dmg + spellInfo.criticalDamage = spellObject.c_total end return spellInfo @@ -1695,11 +1695,11 @@ function Details.UnitHealingSpellInfo (unitId, spellId, isLiteral, segment) spellInfo.regularMin = spellObject.n_min spellInfo.regularMax = spellObject.n_max spellInfo.regularHits = spellObject.n_amt - spellInfo.regularHealing = spellObject.n_dmg + spellInfo.regularHealing = spellObject.n_total spellInfo.criticalMin = spellObject.c_min spellInfo.criticalMax = spellObject.c_max spellInfo.criticalHits = spellObject.c_amt - spellInfo.criticalHealing = spellObject.c_dmg + spellInfo.criticalHealing = spellObject.c_total end return spellInfo diff --git a/functions/mixin.lua b/functions/mixin.lua index 42a07392..cc3f4937 100644 --- a/functions/mixin.lua +++ b/functions/mixin.lua @@ -132,9 +132,9 @@ local spellTable_FieldsToSum = { ["c_amt"] = true, ["c_min"] = true, ["c_max"] = true, - ["c_dmg"] = true, + ["c_total"] = true, ["n_amt"] = true, - ["n_dmg"] = true, + ["n_total"] = true, ["n_min"] = true, ["n_max"] = true, ["successful_casted"] = true,