Created
December 21, 2014 01:39
-
-
Save Resike/827f52fae8e928e28495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
@@ -213,13 +226,21 @@ | |
[86659] = function() return (0.50), ALL, 8 end, -- Guardian of Ancient Kings -- maybe monitor buff instead | |
[30482] = function() return (0.06), PHYSICAL, nil end, -- Molten Armor (Unconfirmed) | |
[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 | |
+ [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" or l == -1 then | |
+ lvl = 0 | |
+ else | |
+ lvl = l | |
+ end | |
+ local base, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player") | |
+ return effectiveArmor / (effectiveArmor + gtK[lvl]), PHYSICAL, false | |
+ 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) | |
@@ -227,10 +248,10 @@ | |
} | |
-local mBuffRemoveHTD = {} | |
+local mBuffRemoveHTD = { } | |
-local DetailTitles={} | |
-DetailTitles.DamageMitigation={ | |
+local DetailTitles = { } | |
+DetailTitles.DamageMitigation = { | |
TopNames = RL["Ability Name"], | |
TopCount = RL["Count"], | |
TopAmount = RL["Damage"], | |
@@ -240,11 +261,11 @@ | |
BotMax = RL["Max"], | |
BotAmount = RL["Count"] | |
} | |
-DetailTitles.DamageReducedBy={ | |
+DetailTitles.DamageReducedBy = { | |
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"], | |
@@ -251,8 +272,8 @@ | |
BotAmount = RL["Count"] | |
} | |
-local mActive={} | |
-local Epsilon=0.000000000000000001 | |
+local mActive = { } | |
+local Epsilon = 0.000000000000000001 | |
local math_floor = math.floor | |
function RecountMitigation:Round100(num) | |
return math_floor((num * 100) + 0.5) / 100 | |
@@ -264,9 +285,9 @@ | |
RecountMitigation:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", "CombatLogEvent") | |
RecountMitigation:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "mEventHTD") | |
local _ | |
- RecountMitigation:mBuffApplied(GetTime(), _, _, "player", _, _, "player", _, 999998, "Versatility")--apply armor to player as a buff | |
- RecountMitigation:mBuffApplied(GetTime(), _, _, "player", _, _, "player", _, 999999, "Armor")--apply armor to player as a buff | |
- --need to apply meta gem to player as a buff here and also add/remove when changing helmet | |
+ RecountMitigation:mBuffApplied(GetTime(), _, _, "player", _, _, "player", _, 999998, "Versatility") -- Apply Versatility to player as a buff | |
+ RecountMitigation:mBuffApplied(GetTime(), _, _, "player", _, _, "player", _, 999999, "Armor") -- Apply Armor to player as a buff | |
+ -- Need to apply meta gem to player as a buff here and also add/remove when changing helmet | |
end | |
function RecountMitigation:OnDisable() | |
RecountMitigation:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") | |
@@ -319,7 +340,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 +365,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 +375,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 +389,31 @@ | |
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 = ... | |
+ if dstGUID ~= casterGUID then | |
+ return | |
+ end | |
+ -- 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 = ... | |
+ if dstGUID ~= casterGUID then | |
+ return | |
+ end | |
+ -- 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 +430,7 @@ | |
["SPELL_AURA_APPLIED"] = RecountMitigation.mBuffApplied, | |
["SPELL_AURA_REFRESH"] = RecountMitigation.mBuffApplied, | |
["SPELL_AURA_REMOVED"] = RecountMitigation.mBuffRemoved, | |
+ ["SPELL_ABSORBED"] = RecountMitigation.mSpellAbsorbed, | |
} | |
local mEventList | |
@@ -418,7 +469,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 +485,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 +520,7 @@ | |
RecountMitigation:AddDM("Absorbed", mAbsorbed, "Absorbed", victim) | |
mAbsorbed = 0 | |
end | |
- end | |
+ end]] | |
-------------- | |
-- RESISTED -- | |
-------------- | |
@@ -481,7 +532,9 @@ | |
---------------------------- | |
local dstDRBuffs = mActive[victim] | |
if not dstDRBuffs then return end | |
- if damage <= 0 and ((absorbed or 0) + (blocked or 0) + (resisted or 0)) <= 0 then return end | |
+ if damage <= 0 and ((absorbed or 0) + (blocked or 0) + (resisted or 0)) <= 0 then | |
+ return | |
+ end | |
local mPhysical = 0 | |
local mMagical = 0 | |
local mPhysicalTotal = 0 | |
@@ -490,11 +543,11 @@ | |
if dmBuffed then | |
if mBuffs[mSpellId] then --Fix | |
if ({mBuffs[mSpellId]()}) [2] == PHYSICAL or ({mBuffs[mSpellId]()}) [2] == ALL then | |
- mPhysical = 1 - ((1-mPhysical)*(1-(mBuffs[mSpellId](UnitLevel("target"))))) | |
+ mPhysical = 1 - ((1 - mPhysical) * (1 - (mBuffs[mSpellId](UnitLevel("target"))))) | |
mPhysicalTotal = mPhysicalTotal + (mBuffs[mSpellId](UnitLevel("target"))) | |
end | |
if ({mBuffs[mSpellId]()}) [2] == MAGICAL or ({mBuffs[mSpellId]()}) [2] == ALL then | |
- mMagical = 1 - ((1-mMagical)*(1-(mBuffs[mSpellId]()))) | |
+ mMagical = 1 - ((1 - mMagical) * (1 - (mBuffs[mSpellId]()))) | |
mMagicalTotal = mMagicalTotal + (mBuffs[mSpellId]()) | |
end | |
end | |
@@ -510,7 +563,7 @@ | |
damage = ((absorbed or 0) + (blocked or 0) + (resisted or 0)) | |
end | |
if mBuffs[mSpellId] then | |
- mAmount = math_floor((((math.ceil(damage/(1-mPhysical))*mPhysical) / mPhysicalTotal)*((mBuffs[mSpellId](UnitLevel("target")))))+0.5+Epsilon) | |
+ mAmount = math_floor((((math.ceil(damage/(1 - mPhysical)) * mPhysical) / mPhysicalTotal) * ((mBuffs[mSpellId](UnitLevel("target"))))) + 0.5 + Epsilon) | |
end | |
end | |
if spellSchool ~= SPELLSCHOOL_PHYSICAL and (({mBuffs[mSpellId]()}) [2] == MAGICAL or ({mBuffs[mSpellId]()}) [2] == ALL) then | |
@@ -518,7 +571,7 @@ | |
damage = ((absorbed or 0) + (blocked or 0) + (resisted or 0)) | |
end | |
if mBuffs[mSpellId] then | |
- mAmount = math_floor((((math.ceil(damage/(1-mMagical))*mMagical) / mMagicalTotal)*((mBuffs[mSpellId]())))+0.5+Epsilon) | |
+ mAmount = math_floor((((math.ceil(damage / (1 - mMagical)) * mMagical) / mMagicalTotal) * ((mBuffs[mSpellId]()))) + 0.5 + Epsilon) | |
end | |
end | |
if mAmount > 0 then | |
@@ -529,10 +582,7 @@ | |
if mSpellId == 999998 then | |
mSpellName = "Versatility" | |
end | |
- --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 +607,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 +629,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 +640,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