Skip to content

Instantly share code, notes, and snippets.

@nazrhyn
Last active December 11, 2015 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazrhyn/4647348 to your computer and use it in GitHub Desktop.
Save nazrhyn/4647348 to your computer and use it in GitHub Desktop.
if UnitName("player") ~= "Shibumi" then return end
local DogTag = LibStub("LibDogTag-3.0")
-- This is the ID for the buff and not one of the class-specific IDs.
-- All of the class versions of Vengeance appear to share this buff ID.
local VENGEANCE_NAME = (GetSpellInfo(132365))
---- SAVE FRENZIED REGENERATION AMOUNT -----------------------------------
DTS_SavedValues = {
all = { desc = "all saved values" },
lastfr = {
desc = "last Frenzied Regeneration heal",
event = "LAST_FRENZIED_CHANGED",
value = 0,
},
maxfr = {
desc = "max Frenzied Regeneration heal",
event = "MAX_FRENZIED_CHANGED",
value = 0,
},
maxv = {
desc = "max attack power from Vengeance",
event = "MAX_VENGEANCE_CHANGED",
value = 0,
},
}
local frame = CreateFrame("FRAME")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:RegisterUnitEvent("UNIT_ATTACK_POWER", "player")
frame:SetScript("OnEvent", function(self, event, ...) return self[event](...) end)
frame.COMBAT_LOG_EVENT_UNFILTERED = function(...)
local _, eventType, _, sourceGUID = ...
if (eventType == "SPELL_HEAL") then
local spellId = select(12, ...)
if (sourceGUID == UnitGUID("player") and spellId == 22842) then
local value = select(15, ...)
DTS_SavedValues.lastfr.value = value
DogTag:FireEvent(DTS_SavedValues.lastfr.event)
if value > DTS_SavedValues.maxfr.value then
DTS_SavedValues.maxfr.value = value
DogTag:FireEvent(DTS_SavedValues.maxfr.event)
end
end
end
end
frame.UNIT_ATTACK_POWER = function()
local value = (select(15, UnitBuff("player", VENGEANCE_NAME)))
if (value and value > DTS_SavedValues.maxv.value) then
DTS_SavedValues.maxv.value = value
DogTag:FireEvent(DTS_SavedValues.maxv.event)
end
end
---- RESET COMMAND -------------------------------------------------------
SLASH_RESET_SAVED_VALUES1 = "/rsv"
local function resetSavedValue(value)
value = strlower(value)
local info = DTS_SavedValues[value]
if not info then
print(string.format("|cff0090ff%s|r - |cff00aa00%s|r cannot be reset.", SLASH_RESET_SAVED_VALUES1, value))
return
end
if value == "all" then
for k in pairs(DTS_SavedValues) do
if k ~= "all" then
resetSavedValue(k)
end
end
else
info.value = 0
DogTag:FireEvent(info.event)
print(string.format("|cff0090ff%s|r - The |cff6ce26c%s|r has been reset.", SLASH_RESET_SAVED_VALUES1, info.desc))
end
end
SlashCmdList["RESET_SAVED_VALUES"] = function(params)
if params == "" then
print(string.format("Arguments to |cff0090ff%s|r:", SLASH_RESET_SAVED_VALUES1))
for k,v in pairs(DTS_SavedValues) do
print(string.format(" |cff00aa00%s|r - Resets |cff6ce26c%s|r.%s", k, v.desc, (v.value and v.value > 0 and string.format(" (|cff5eb9ff%s|r)", v.value) or "")))
end
else
for arg in params:gmatch(" *([^ ]+) *") do
resetSavedValue(arg)
end
end
end
---- NEXT FRENZIED REGENERATION HEAL -------------------------------------
DogTag:AddTag(
"Unit",
"NextFrenziedHeal",
{
code = function(factor)
if GetShapeshiftForm() ~= 1 then
-- if not in bear form, don't calculate
-- even when shifted out of form, the game still reports a rage value
return 0
end
local apb, apadd, apsub = UnitAttackPower("player")
local ap = apb + apadd - apsub
local stam, agi, rage = UnitStat("player",3), UnitStat("player",2), UnitPower("player",1)
local heal = math.max(2 * (ap - agi * 2), stam * 2.5)
if rage < 60 then
heal = heal * (rage / 60)
end
return heal * factor
end,
arg = {
'factor', 'number;undef', 1,
'unit', 'string;undef', 'player'
},
ret = "number",
events = "UNIT_ATTACK_POWER#$unit;UNIT_STATS#$unit;UNIT_POWER#$unit;UNIT_DISPLAYPOWER#$unit",
doc = "Returns the amount for which Frenzied Regeneration will heal, given current conditions.",
example = '[NextFrenziedHeal] => "12000"; [NextFrenziedHeal(2)] => "24000"',
category = "Druid"
}
)
DogTag:AddTag(
"Unit",
"NFH",
{
alias = [=[NextFrenziedHeal(factor)]=],
arg = {
'factor', 'number;undef', 1
},
doc = "Returns the amount for which Frenzied Regeneration will heal, given current conditions.",
example = '[NFH] => "12000"; [NFH(2)] => "24000"',
category = "Druid"
}
)
---- LAST FRENZIED REGENERATION HEAL -------------------------------------
DogTag:AddTag(
"Unit",
"LastFrenziedHeal",
{
code = function()
return DTS_SavedValues.lastfr.value
end,
ret = "number",
events = DTS_SavedValues.lastfr.event,
doc = "Returns the amount of the last Frenzied Regeneration heal cast.",
example = '[LastFrenziedHeal] => "12000"',
category = "Druid"
}
)
DogTag:AddTag(
"Unit",
"LFH",
{
alias = [=[LastFrenziedHeal]=],
doc = "Returns the amount of the last Frenzied Regeneration heal cast.",
example = '[LFH] => "12000"',
category = "Druid"
}
)
---- MAX FRENZIED REGENERATION HEAL --------------------------------------
DogTag:AddTag(
"Unit",
"MaxFrenziedHeal",
{
code = function()
return DTS_SavedValues.maxfr.value
end,
ret = "number",
events = DTS_SavedValues.maxfr.event,
doc = "Returns the maximum Frenzied Regeneration heal seen since the last reset.",
example = '[MaxFrenziedHeal] => "250000"',
category = "Druid"
}
)
DogTag:AddTag(
"Unit",
"MFH",
{
alias = [=[MaxFrenziedHeal]=],
doc = "Returns the maximum Frenzied Regeneration heal seen since the last reset.",
example = '[MFH] => "250000"',
category = "Druid"
}
)
---- MAX VENGEANCE -------------------------------------------------------
DogTag:AddTag(
"Unit",
"MaxVengeance",
{
code = function()
return DTS_SavedValues.maxv.value
end,
ret = "number",
events = DTS_SavedValues.maxv.event,
doc = "Returns the maximum attack power from Vengeance since the last reset.",
example = '[MaxVengeance] => "128300"',
category = "Druid"
}
)
DogTag:AddTag(
"Unit",
"MV",
{
alias = [=[MaxVengeance]=],
doc = "Returns the maximum attack power from Vengeance since the last reset.",
example = '[MV] => "128300"',
category = "Druid"
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment