Skip to content

Instantly share code, notes, and snippets.

@Resike
Created December 20, 2014 19:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Resike/07b1123570a8bbf63819 to your computer and use it in GitHub Desktop.
Save Resike/07b1123570a8bbf63819 to your computer and use it in GitHub Desktop.
Index: RecountMitigation.lua
===================================================================
--- RecountMitigation.lua (revision 26)
+++ RecountMitigation.lua (working copy)
@@ -12,15 +12,16 @@
local pairs = pairs
local math = math
-local UnitBuff = UnitBuff
-local UnitArmor = UnitArmor
+local GetCombatRatingBonus = GetCombatRatingBonus
local GetMastery = GetMastery
local GetSpellInfo = GetSpellInfo
-local UnitLevel = UnitLevel
local GetTime = GetTime
+local IsTalentSpell = IsTalentSpell
+local UnitArmor = UnitArmor
+local UnitBuff = UnitBuff
local UnitIsUnit = UnitIsUnit
+local UnitLevel = UnitLevel
local UnitName = UnitName
-local GetCombatRatingBonus = GetCombatRatingBonus
local GameTooltip = GameTooltip
@@ -40,7 +41,7 @@
local MAGICAL = 2
local ALL = 3
-local mAbsorbs = {
+--[[local mAbsorbs = {
[116631] = function() local _,_,_,_,_,_,_,_,_,_,_,_,_,_,v,_ = UnitBuff("player", "Colossus") return (v), nil end,
[77535] = function() local _,_,_,_,_,_,_,_,_,_,_,_,_,_,v,_ = UnitBuff("player", "Blood Shield") return (v), true end, --Physical Only (true)
[65148] = function() local _,_,_,_,_,_,_,_,_,_,_,_,_,_,v,_ = UnitBuff("player", "Sacred Shield") return (v), nil end,
@@ -56,7 +57,7 @@
[115295] = function() local _,_,_,_,_,_,_,_,_,_,_,_,_,_,v,_ = UnitBuff("player", "Guard") return (v), nil end,
[135286] = function() local _,_,_,_,_,_,_,_,_,_,_,_,_,_,v,_ = UnitBuff("player", "Tooth and Claw") return (v), true end, --Physical Only (true)
}
-local mLeft = {}
+local mLeft = {}]]
-- look at combining HTD events as they will be the only ones with times instead of nil. must add check when nessessary below
-- (value, school, type, customDuration)
@@ -183,10 +184,22 @@
[106] = 7587,
[107] = 8587,
[108] = 9718
-};
+}
+
+-- Also need to handle talent learned/removed events, and to check player buffs after logging in.
local mBuffs = {
- [71] = function() return (0.25), ALL, nil end, -- Defensive Stance (Unconfirmed)
+ [71] = function()
+ local spellName = GetSpellInfo(152276)
+ local talent = IsTalentSpell(spellName)
+ local reduceDamage
+ if talent then
+ reduceDamage = 0.25
+ else
+ reduceDamage = 0.20
+ end
+ return (reduceDamage), ALL, nil
+ end, -- Defensive Stance (Unconfirmed)
[871] = function() return (0.40), ALL, nil end, -- Shield Wall (Unconfirmed)
[14771] = function() return (0.06), ALL, nil end, -- Glyph of Inner Sanctum (Unconfirmed)
[15473] = function() return (0.15), ALL, nil end, -- Shadowform (Unconfirmed)
@@ -215,11 +228,20 @@
[63269] = function() return (0.40), PHYSICAL, nil end, -- Glyph of Cloak of Shadows (Unconfirmed)
[132403] = function() return (0.25 + (GetMastery()/200)), PHYSICAL, nil end, -- Shield of the Righteous
[137593] = function() return (0.20), ALL, nil end, -- Indomitable Primal Diamond (Meta Gem, Unconfirmed)
- [999998] = function() return (GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_TAKEN)/100), ALL, nil end, -- Versatility
+ [999998] = function()
+ return (GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_TAKEN) / 100), ALL, nil
+ end, -- Versatility
[999999] = function(l)
- local lvl
- if type(l) ~= "number" then lvl = 0 else lvl = l end
- return (UnitArmor("player")/(UnitArmor("player") + gtK[lvl] )), PHYSICAL, false end, -- Armor
+ local lvl
+ if type(l) ~= "number" then
+ lvl = 0
+ else
+ lvl = l
+ end
+ if gtK[lvl] then
+ return (UnitArmor("player") / (UnitArmor("player") + gtK[lvl])), PHYSICAL, false
+ end
+ end, -- Armor
[498] = function() return (0.40), MAGICAL, nil end, -- Divine Protection
[31821] = function() return (0.20), MAGICAL, nil end, -- Devotion Aura
[48707] = function() return (0.75), MAGICAL, nil end, -- Anti-Magic Shell (Unconfirmed)
@@ -244,7 +266,7 @@
TopNames = RL["Ability Name"],
TopCount = RL["Count"],
TopAmount = RL["Damage"],
- BotNames = RL["Player/Mob Name"],
+ BotNames = L["Protected"],
BotMin = RL["Min"],
BotAvg = RL["Avg"],
BotMax = RL["Max"],
@@ -319,7 +341,9 @@
-- --
----------------------------------------------------------------------
function RecountMitigation:mBuffApplied(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, auraType, amount)
- if not mBuffs[spellId] and not mAbsorbs[spellId] then return end
+ if not mBuffs[spellId] --[=[and not mAbsorbs[spellId]]=] then
+ return
+ end
if UnitIsUnit(dstName, "player") then dstName = UnitName("player") end
if UnitIsUnit(srcName, "player") then srcName = UnitName("player") end
@@ -342,9 +366,9 @@
end
--print("Mitigation Buff: ", spellName, "[", spellId, "] applied")
mActive[dstName][spellId] = timestamp
- if mAbsorbs[spellId] then
+ --[[if mAbsorbs[spellId] then
mLeft[spellId] = (mAbsorbs[spellId]())
- end
+ end]]
end
----------------------------------------------------------------------
-- --
@@ -352,7 +376,9 @@
-- --
----------------------------------------------------------------------
function RecountMitigation:mBuffRemoved(timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellId, spellName, spellSchool, auraType, amount)
- if not mBuffs[spellId] and not mBuffRemoveHTD[timestamp] and not mAbsorbs[spellId] then return end
+ if not mBuffs[spellId] and not mBuffRemoveHTD[timestamp] --[=[and not mAbsorbs[spellId]]=] then
+ return
+ end
if mBuffRemoveHTD[timestamp] then
dstName = mBuffRemoveHTD[timestamp]["dstName"]
spellId = timestamp
@@ -364,6 +390,25 @@
mActive[dstName][spellId] = nil
end
+function RecountMitigation:mSpellAbsorbed(...)
+ local _, _, _, _, _, _, _, _, srcSpellId = ...
+ if type(srcSpellId) == "number" then
+ local timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, srcSpellId, srcSpellName, srcSpellSchool, casterGUID, casterName, casterFlags, casterRaidFlags, spellId, spellName, spellSchool, absorbed = ...
+ -- Stance of the Sturdy Ox, Purgatory
+ if spellId == 115069 or spellId == 114556 then
+ return
+ end
+ RecountMitigation:AddDM("Absorbed", absorbed, spellName, dstName)
+ else
+ local timestamp, eventtype, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, casterGUID, casterName, casterFlags, casterRaidFlags, spellId, spellName, spellSchool, absorbed = ...
+ -- Stance of the Sturdy Ox, Purgatory
+ if spellId == 115069 or spellId == 114556 then
+ return
+ end
+ RecountMitigation:AddDM("Absorbed", absorbed, spellName, dstName)
+ end
+end
+
local mEvent =
{
["SWING_DAMAGE"] = RecountMitigation.MeleeDamage,
@@ -380,6 +425,7 @@
["SPELL_AURA_APPLIED"] = RecountMitigation.mBuffApplied,
["SPELL_AURA_REFRESH"] = RecountMitigation.mBuffApplied,
["SPELL_AURA_REMOVED"] = RecountMitigation.mBuffRemoved,
+ ["SPELL_ABSORBED"] = RecountMitigation.mSpellAbsorbed,
}
local mEventList
@@ -418,7 +464,7 @@
-- FUNCTION : CALCULATE DAMAGE MITIGATION --
-- --
----------------------------------------------------------------------
-function RecountMitigation:CalDM(source, victim, spellName, spellSchool, damage, spellId, timestamp, absorbed, blocked, resisted, srcGUID)
+function RecountMitigation:CalDM(source, victim, spellName, spellSchool, damage, spellId, timestamp, absorbed, blocked, resisted, srcGUID, ...)
if UnitIsUnit(victim, "player") then victim = UnitName("player") end
if UnitIsUnit(source, "player") then source = UnitName("player") end
if spellName == nil then
@@ -434,7 +480,7 @@
--------------
-- ABSORBED --
--------------
- if absorbed ~= nil then
+ --[[if absorbed ~= nil then
local mAbsorbed = absorbed
for mAbsorbId, mAbsorb in pairs(mAbsorbs) do
if mAbsorbs[mAbsorbId] then --Fix
@@ -469,7 +515,7 @@
RecountMitigation:AddDM("Absorbed", mAbsorbed, "Absorbed", victim)
mAbsorbed = 0
end
- end
+ end]]
--------------
-- RESISTED --
--------------
@@ -532,7 +578,7 @@
--if mAmount > 200000 then
-- print("Error? mAmount: ", mAmount, " OrgHit: ")
--end
- RecountMitigation:AddDM(spellName, mAmount, mSpellName, victim)
+ RecountMitigation:AddDM(mSpellName, mAmount, mSpellName, victim)
end
end --Fix
end --Fix
@@ -557,9 +603,10 @@
if num == 1 then
return RecountMitigation:Round100((data.Fights[Recount.db.profile.CurDataSet].TotalDamageMitigation or 0), (data.Fights[Recount.db.profile.CurDataSet].TotalDamageMitigation or 0)/((data.Fights[Recount.db.profile.CurDataSet].ActiveTime or 0) + Epsilon))
else
- return (data.Fights[Recount.db.profile.CurDataSet].TotalDamageMitigation or 0), {{data.Fights[Recount.db.profile.CurDataSet].DamageReducedBy, " "..L["'s Damage Mitigation Abilities"], DetailTitles.DamageReducedBy}, {data.Fights[Recount.db.profile.CurDataSet].DamageMitigation, L["'s Damage Mitigation"], DetailTitles.DamageMitigation}}
+ return (data.Fights[Recount.db.profile.CurDataSet].TotalDamageMitigation or 0), {{data.Fights[Recount.db.profile.CurDataSet].DamageMitigation, L["'s Damage Mitigation"], DetailTitles.DamageMitigation}, {data.Fights[Recount.db.profile.CurDataSet].DamageReducedBy, L["'s Damage Mitigation Abilities"], DetailTitles.DamageReducedBy}}
end
end
+
----------------------------------------------------------------------
-- --
-- FUNCTION : DAMAGE MITIGATION TOOLTIP --
@@ -578,7 +625,7 @@
tBreakdown[L["Damage Mitigated"]] = {}
tBreakdown[L["Damage Taken"]]["amount"] = (data.Fights[Recount.db.profile.CurDataSet].DamageTaken or 0)
tBreakdown[L["Damage Mitigated"]]["amount"] = (data.Fights[Recount.db.profile.CurDataSet].TotalDamageMitigation or 0)
- Recount:AddSortedTooltipData(L["of Incoming Damage"], tBreakdown,2)
+ Recount:AddSortedTooltipData(L["Incoming Damage"], tBreakdown,2)
GameTooltip:AddLine("")
local tSelfHeals = {}
tSelfHeals[L["Damage Self Healed"]] = {}
@@ -589,10 +636,10 @@
end
tSelfHeals[L["Damage Self Healed"]]["amount"] = (SelfHeals or 0) - (data.Fights[Recount.db.profile.CurDataSet].Absorbs or 0)
tSelfHeals[L["Damage Not Actioned"]]["amount"] = (data.Fights[Recount.db.profile.CurDataSet].DamageTaken or 0) - ((SelfHeals or 0) - (data.Fights[Recount.db.profile.CurDataSet].Absorbs or 0))
- Recount:AddSortedTooltipData(L["of Damage Taken"], tSelfHeals,2)
+ Recount:AddSortedTooltipData(L["Damage Taken"], tSelfHeals,2)
GameTooltip:AddLine("")
- Recount:AddSortedTooltipData(L["of Damage Mitigated (Top 3)"], data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].DamageReducedBy, 3)
- GameTooltip:AddLine("<"..RL["Click for more Details"]..">",0,0.9,0)
+ Recount:AddSortedTooltipData(L["Top 3 Mitigation"], data and data.Fights[Recount.db.profile.CurDataSet] and data.Fights[Recount.db.profile.CurDataSet].DamageMitigation, 3)
+ GameTooltip:AddLine("<"..RL["Click for more Details"]..">", 0, 0.9, 0)
end
-Recount:AddModeTooltip(L["Damage Mitigation"], RecountMitigation.DataModesDamageMitigation, RecountMitigation.TooltipFuncsDamageMitigation, nil,nil,nil,nil)
\ No newline at end of file
+Recount:AddModeTooltip(L["Damage Mitigation"], RecountMitigation.DataModesDamageMitigation, RecountMitigation.TooltipFuncsDamageMitigation, nil, nil, nil, nil)
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment