Energy and Resources Revamp

- Energy overflow when using spells are now tracked (using a spell which gives energy and the energy gained passses the max amount of energy).
- Energy overflow with classses with auto energy restoration like rogues are also tracked.
- Resources now are shown as resource per second instead of per minute.
This commit is contained in:
Tercioo
2019-05-04 11:35:38 -03:00
parent 5e5fd97e55
commit cc57155d71
4 changed files with 114 additions and 13 deletions
+7 -7
View File
File diff suppressed because one or more lines are too long
+33 -3
View File
@@ -74,6 +74,8 @@ function atributo_energy:NovaTabela (serial, nome, link)
tipo = class_type,
total = alphabetical,
totalover = alphabetical,
passiveover = alphabetical,
received = alphabetical,
resource = alphabetical,
alternatepower = alphabetical,
@@ -241,7 +243,7 @@ function atributo_energy:AtualizarResources (qual_barra, colocacao, instancia)
porcentagem = porcentagem .. "%"
end
local rightText = formated_resource .. bars_brackets[1] .. formated_rps .. bars_separator .. porcentagem .. bars_brackets[2]
local rightText = formated_resource .. bars_brackets[1] .. formated_rps .. " r/s" .. bars_separator .. porcentagem .. bars_brackets[2]
if (UsingCustomRightText) then
esta_barra.texto_direita:SetText (_string_replace (instancia.row_info.textR_custom_text, formated_resource, formated_rps, porcentagem, self, instancia.showing, instancia, rightText))
else
@@ -799,7 +801,7 @@ function atributo_energy:ToolTip (instancia, numero, barra, keydown)
if (resource_string) then
local icon = _detalhes.resource_icons [self.resource_type]
GameCooltip:AddLine (resource_string, _cstr ("%.2f", self.resource / instancia.showing:GetCombatTime()) .. " per minute", 1, "white")
GameCooltip:AddLine (resource_string, floor (self.resource) .. " (" .. _cstr ("%.2f", self.resource / instancia.showing:GetCombatTime()) .. " per second)", 1, "white")
GameCooltip:AddIcon (icon.file, 1, 1, 16, 16, unpack (icon.coords))
GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], resource_bg_coords, resource_bg_color, true)
@@ -914,7 +916,6 @@ function atributo_energy:ToolTipRegenRecebido (instancia, numero, barra, keydown
end
--> players
reset_tooltips_table()
i = 1
@@ -981,6 +982,35 @@ function atributo_energy:ToolTipRegenRecebido (instancia, numero, barra, keydown
end
end
--> player generators
local allGeneratorSpells = {}
local allGenerated = 0
for spellid, spellObject in _pairs (self.spells._ActorTable) do
tinsert (allGeneratorSpells, {spellObject, spellObject.total, spellObject.totalover})
allGenerated = allGenerated + spellObject.total
end
table.sort (allGeneratorSpells, _detalhes.Sort2)
_detalhes:AddTooltipSpellHeaderText (self.nome .. " Generators", headerColor, #allGeneratorSpells, [[Interface\HELPFRAME\HelpIcon-HotIssues]], 0.21875, 0.78125, 0.21875, 0.78125)
_detalhes:AddTooltipHeaderStatusbar (r, g, b, 1)
for i = 1, #allGeneratorSpells do
local thisGenerator = allGeneratorSpells [i]
local spellName, _, spellIcon = GetSpellInfo (thisGenerator[1].id)
GameCooltip:AddLine (spellName, FormatTooltipNumber (_, thisGenerator[2]) .. " (|cFFFF5555overflow: " .. FormatTooltipNumber (_, thisGenerator[3]) .. "|r | " .. _cstr ("%.1f", (thisGenerator[2] / allGenerated) * 100).."%)")
GameCooltip:AddIcon (spellIcon, nil, nil, icon_size.W, icon_size.H, .1, .9, .1, .9)
_detalhes:AddTooltipBackgroundStatusbar()
end
--auto regen overflow
_detalhes:AddTooltipSpellHeaderText (self.nome .. " Auto Regen Overflow", headerColor, 1, [[Interface\CHARACTERFRAME\Disconnect-Icon]], 0.3, 0.7, 0.3, 0.7)
_detalhes:AddTooltipHeaderStatusbar (r, g, b, 1)
GameCooltip:AddLine ("Auto Regen Overflow", FormatTooltipNumber (_, self.passiveover) .. " ( " .. _cstr ("%.1f", self.passiveover / (self.passiveover + self.total) * 100) .. "%)")
GameCooltip:AddIcon ([[Interface\COMMON\Indicator-Red]], nil, nil, icon_size.W, icon_size.H)
_detalhes:AddTooltipBackgroundStatusbar()
return true
end
+3 -1
View File
@@ -28,16 +28,18 @@
id = id,
counter = 0,
total = 0,
totalover = 0,
targets = {}
}
return _newEnergySpell
end
function habilidade_energy:Add (serial, nome, flag, amount, who_nome, powertype)
function habilidade_energy:Add (serial, nome, flag, amount, who_nome, powertype, overpower)
self.counter = self.counter + 1
self.total = self.total + amount
self.totalover = self.totalover + overpower
self.targets [nome] = (self.targets [nome] or 0) + amount
end
+71 -2
View File
@@ -91,6 +91,8 @@
local raid_members_cache = setmetatable ({}, _detalhes.weaktable)
--> tanks
local tanks_members_cache = setmetatable ({}, _detalhes.weaktable)
--> auto regen
local auto_regen_cache = setmetatable ({}, _detalhes.weaktable)
--> bitfield swap cache
local bitfield_swap_cache = {}
--> damage and heal last events
@@ -276,6 +278,20 @@
["141265"] = true,
}
--> regen overflow
local auto_regen_power_specs = {
[103] = Enum.PowerType.Energy, --druid feral
[259] = Enum.PowerType.Energy, --rogue ass
[260] = Enum.PowerType.Energy, --rogue outlaw
[261] = Enum.PowerType.Energy, --rogue sub
[254] = Enum.PowerType.Focus, --hunter mm
[253] = Enum.PowerType.Focus, --hunter bm
[255] = Enum.PowerType.Focus, --hunter survival
[268] = Enum.PowerType.Energy, --monk brewmaster
[269] = Enum.PowerType.Energy, --monk windwalker
}
local _auto_regen_thread
local AUTO_REGEN_PRECISION = 2
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> internal functions
@@ -2750,8 +2766,27 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
end)
local regen_power_overflow_check = function()
if (not _in_combat) then
return
end
for playerName, powerType in _pairs (auto_regen_cache) do
local currentPower = UnitPower (playerName, powerType) or 0
local maxPower = UnitPowerMax (playerName, powerType) or 1
if (currentPower == maxPower) then
--power overflow
local energyObject = energy_cache [playerName]
if (energyObject) then
energyObject.passiveover = energyObject.passiveover + AUTO_REGEN_PRECISION
end
end
end
end
-- ~energy ~resource
function parser:energize (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, spelltype, amount, powertype, p6, p7)
function parser:energize (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, spelltype, amount, overpower, powertype, altpower)
------------------------------------------------------------------------------------------------
--> early checks and fixes
@@ -2773,11 +2808,14 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--> check if is valid
if (not energy_types [powertype] and not is_resource) then
return
elseif (is_resource) then
powertype = is_resource
amount = 0
end
overpower = overpower or 0
--[[statistics]]-- _detalhes.statistics.energy_calls = _detalhes.statistics.energy_calls + 1
_current_energy_container.need_refresh = true
@@ -2833,6 +2871,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (not is_resource) then
--amount = amount - overpower
--> add to targets
este_jogador.targets [alvo_name] = (este_jogador.targets [alvo_name] or 0) + amount
@@ -2845,6 +2885,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--> regen produced amount
este_jogador.total = este_jogador.total + amount
este_jogador.totalover = este_jogador.totalover + overpower
--> target regenerated amount
jogador_alvo.received = jogador_alvo.received + amount
@@ -2861,7 +2902,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
--return spell:Add (alvo_serial, alvo_name, alvo_flags, amount, who_name, powertype)
return spell_energy_func (spell, alvo_serial, alvo_name, alvo_flags, amount, who_name, powertype)
return spell_energy_func (spell, alvo_serial, alvo_name, alvo_flags, amount, who_name, powertype, overpower)
else
--> is a resource
@@ -5085,6 +5126,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
_table_wipe (raid_members_cache)
_table_wipe (tanks_members_cache)
_table_wipe (auto_regen_cache)
_table_wipe (bitfield_swap_cache)
_table_wipe (ignore_actors)
@@ -5101,6 +5143,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (role == "TANK") then
tanks_members_cache [_UnitGUID ("raid"..i)] = true
end
if (auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("raid" .. i)]]) then
auto_regen_cache [name] = auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("raid" .. i)]]
end
end
elseif (_IsInGroup()) then
@@ -5115,6 +5161,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (role == "TANK") then
tanks_members_cache [_UnitGUID ("party"..i)] = true
end
if (auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("party" .. i)]]) then
auto_regen_cache [name] = auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("party" .. i)]]
end
end
--player
@@ -5127,6 +5177,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (role == "TANK") then
tanks_members_cache [_UnitGUID ("player")] = true
end
if (auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("player")]]) then
auto_regen_cache [name] = auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("player")]]
end
else
local name = GetUnitName ("player", true)
@@ -5144,6 +5198,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
end
end
if (auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("player")]]) then
auto_regen_cache [name] = auto_regen_power_specs [_detalhes.cached_specs [_UnitGUID ("player")]]
end
end
if (_detalhes.iam_a_tank) then
@@ -5191,6 +5249,17 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
_recording_ability_with_buffs = _detalhes.RecordPlayerAbilityWithBuffs
_in_combat = _detalhes.in_combat
if (_in_combat) then
if (not _auto_regen_thread or _auto_regen_thread._cancelled) then
_auto_regen_thread = C_Timer.NewTicker (AUTO_REGEN_PRECISION / 10, regen_power_overflow_check)
end
else
if (_auto_regen_thread and not _auto_regen_thread._cancelled) then
_auto_regen_thread:Cancel()
_auto_regen_thread = nil
end
end
if (_detalhes.hooks ["HOOK_COOLDOWN"].enabled) then
_hook_cooldowns = true
else