Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Name: GridStatusSearingPlasma
- Revision: $Revision: 10108 $
- Developed by: Kulldon @ US-Hyjal ([email protected])
- Description: Status indicator for remaining absorb value of Searing Plasma for the Spine of Deathwing encounter.
- ]]
- --{{{ Libraries
- local L = LibStub("AceLocale-3.0"):GetLocale("GridStatusSearingPlasma")
- --}}}
- local GridRoster = Grid:GetModule("GridRoster")
- local GridStatusSearingPlasma = Grid:GetModule("GridStatus"):NewModule("GridStatusSearingPlasma")
- GridStatusSearingPlasma.menuName = L["Searing Plasma"]
- -- Add new valid spells here by spell ID
- local validSpells = {
- --17, -- Power Word: Shield
- 105479, -- Searing Plasma 10N
- 109363, -- Searing Plasma 10H
- 109362, -- Searing Plasma 25N
- 109364, -- Searing Plasma 25H
- };
- --{{{ AceDB defaults
- GridStatusSearingPlasma.defaultDB = {
- searingPlasma = {
- enable = true,
- priority = 90,
- color = { r = 1, g = 0, b = 0, a = 1 },
- mark1Color = { r = 0, g = 1, b = 0, a = 1 },
- mark1Threshold = 50000,
- mark2Color = { r = 1, g = 1, b = 0, a = 1 },
- mark2Threshold = 150000,
- mark3Color = { r = 1, g = 0, b = 0, a = 1 },
- mark3Threshold = 280000,
- useCombatLog = true,
- },
- }
- --}}}
- local settings
- --{{{ Options
- local amountOptions = {
- ["mark1threshold"] = {
- type = "range",
- name = L["Low absorb threshold"],
- desc = L["The threshold below which the absorb is considered low."],
- max = 400000,
- min = 1,
- step = 500,
- get = function()
- return settings.searingPlasma.mark1Threshold
- end,
- set = function(_, v)
- settings.searingPlasma.mark1Threshold = v
- end,
- width = 'full',
- order = 87,
- },
- ["mark2threshold"] = {
- type = "range",
- name = L["Medium absorb threshold"],
- desc = L["The threshold below which the absorb is considered medium."],
- max = 400000,
- min = 1,
- step = 500,
- get = function()
- return settings.searingPlasma.mark2Threshold
- end,
- set = function(_, v)
- settings.searingPlasma.mark2Threshold = v
- end,
- width = 'full',
- order = 88,
- },
- ["mark3threshold"] = {
- type = "range",
- name = L["High absorb threshold"],
- desc = L["The threshold below which the absorb is considered high."],
- max = 400000,
- min = 1,
- step = 500,
- get = function()
- return settings.searingPlasma.mark3Threshold
- end,
- set = function(_, v)
- settings.searingPlasma.mark3Threshold = v
- end,
- width = 'full',
- order = 89,
- },
- ["mark1color"] = {
- type = "color",
- name = L["Low absorb color"],
- desc = L["Color for absorb amount below the low absorb threshold."],
- order = 90,
- hasAlpha = true,
- get = function ()
- local color = settings.searingPlasma.mark1Color
- return color.r, color.g, color.b, color.a
- end,
- set = function (_, r, g, b, a)
- local color = settings.searingPlasma.mark1Color
- color.r = r
- color.g = g
- color.b = b
- color.a = a or 1
- end,
- },
- ["mark2color"] = {
- type = "color",
- name = L["Medium absorb color"],
- desc = L["Color for absorb amount below the medium absorb threshold."],
- order = 91,
- hasAlpha = true,
- get = function ()
- local color = settings.searingPlasma.mark2Color
- return color.r, color.g, color.b, color.a
- end,
- set = function (_, r, g, b, a)
- local color = settings.searingPlasma.mark2Color
- color.r = r
- color.g = g
- color.b = b
- color.a = a or 1
- end,
- },
- ["mark3color"] = {
- type = "color",
- name = L["High absorb color"],
- desc = L["Color for absorb amount below the high absorb threshold."],
- order = 92,
- hasAlpha = true,
- get = function ()
- local color = settings.searingPlasma.mark3Color
- return color.r, color.g, color.b, color.a
- end,
- set = function (_, r, g, b, a)
- local color = settings.searingPlasma.mark3Color
- color.r = r
- color.g = g
- color.b = b
- color.a = a or 1
- end,
- },
- }
- --}}}
- local absorbUnit = {};
- local absorbHeal = {};
- function GridStatusSearingPlasma:OnInitialize()
- self.super.OnInitialize(self)
- self:RegisterStatus("searingPlasma", L["Searing Plasma"], amountOptions, true)
- settings = GridStatusSearingPlasma.db.profile
- settings.searingPlasma.useCombatLog = true
- end
- function GridStatusSearingPlasma:OnStatusEnable(status)
- if status == "searingPlasma" then
- self:RegisterMessage("Grid_UnitJoined")
- self:CombatLogParsing(true)
- end
- end
- function GridStatusSearingPlasma:OnStatusDisable(status)
- if status == "searingPlasma" then
- self:UnregisterMessage("Grid_UnitJoined")
- self:CombatLogParsing(false)
- end
- end
- function GridStatusSearingPlasma:CombatLogParsing(enable)
- if enable then
- self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
- self:RegisterEvent("PLAYER_REGEN_ENABLED");
- else
- for guid, unitid in GridRoster:IterateRoster() do
- self:Clear(guid)
- end
- self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
- self:UnregisterEvent("PLAYER_REGEN_ENABLED");
- end
- end
- function GridStatusSearingPlasma:PLAYER_REGEN_ENABLED()
- GridStatusSearingPlasma:Reset();
- end
- function GridStatusSearingPlasma:Reset()
- self.super.Reset(self)
- absorbUnit = {}
- absorbHeal = {}
- for guid, unitid in GridRoster:IterateRoster() do
- self:Clear(guid)
- end
- end
- function GridStatusSearingPlasma:UseCombatLog(useCombatLog)
- settings.searingPlasma.useCombatLog = useCombatLog
- if not settings.searingPlasma.enable then
- return
- end
- if settings.searingPlasma.useCombatLog == useCombatLog then
- return
- end
- self:CombatLogParsing(true)
- end
- function GridStatusSearingPlasma:Print(...)
- if type(...) == 'table' then
- print("GridStatusSearingPlasma: "..unpack(...))
- else
- print("GridStatusSearingPlasma: ".. ...)
- end
- end
- function GridStatusSearingPlasma:Grid_UnitJoined(_, unitGUID, unitid)
- self:Clear(unitGUID)
- end
- function GridStatusSearingPlasma:Clear(unitGUID)
- self.core:SendStatusLost(unitGUID, "searingPlasma")
- end
- function GridStatusSearingPlasma:FormatText(amount)
- local text
- if amount > 999 then
- text = string.format("%d", amount/1000.0)
- --shieldText = string.format("%.1fk", amount/1000.0)
- else
- text = string.format("%3.0f", amount)
- end
- return text
- end
- function GridStatusSearingPlasma:SendAbsorbStatus(unitGUID, amount)
- local color = settings.searingPlasma.color
- if amount < settings.searingPlasma.mark1Threshold then
- color = settings.searingPlasma.mark1Color
- elseif amount < settings.searingPlasma.mark2Threshold then
- color = settings.searingPlasma.mark2Color
- elseif amount < settings.searingPlasma.mark3Threshold then
- color = settings.searingPlasma.mark3Color
- end
- -- DEBUG
- --self:Print("SendAbsorbStatus: " .. unitGUID .. ", " .. amount);
- self.core:SendStatusGained(unitGUID, "searingPlasma",
- settings.searingPlasma.priority,
- nil,
- color,
- self:FormatText(amount))
- end
- local function isValidSpell(id)
- if id and type(id) == "number" then
- for i,v in pairs(validSpells) do
- if id == v then return true end
- end
- end
- return false
- end
- function GridStatusSearingPlasma:COMBAT_LOG_EVENT_UNFILTERED(_, timestamp, eventType, hideCaster, srcGUID, srcName, srcFlags, srcRaidFlags, dstGUID, dstName, dstFlags, dstRaidFlags, ...)
- if not GridRoster:IsGUIDInRaid(dstGUID) then
- return
- end
- local spellId, amount, absorbed;
- if eventType == "SPELL_AURA_APPLIED" or eventType == "SPELL_AURA_APPLIED_DOSE" then
- spellId, _, _, _, amount = ...;
- --self:Print(spellId, amount);
- --self:Print(dstGUID .. " " .. spellId .. " " .. (amount or 0))
- self:AddAbsorb(spellId, dstGUID, amount);
- elseif eventType == "SPELL_AURA_REMOVED" then
- spellId, _, _, _, amount = ...;
- --self:Print(spellId, amount);
- self:RemoveAbsorb(spellId, dstGUID, amount);
- elseif eventType == "SPELL_HEAL" or eventType == "SPELL_PERIODIC_HEAL" then
- spellId, _, _, amount, _, absorbed = ...;
- --self:Print(spellId .. ", " .. amount .. ", " .. (absorbed or 0));
- -- DEBUG
- --self:HealAbsorb(dstGUID, amount);
- self:HealAbsorb(dstGUID, absorbed);
- end
- end
- function GridStatusSearingPlasma:AddAbsorb(id, guid, amount)
- -- Check valid spell
- if not isValidSpell(id) then return end
- -- DEBUG
- --self:Print("AddAbsorb -- id: "..id .. ", amount: " .. amount)
- absorbUnit[guid] = amount;
- absorbHeal[guid] = 0;
- self:SendAbsorbStatus(guid, amount)
- end
- function GridStatusSearingPlasma:RemoveAbsorb(id, guid)
- -- Check valid spell
- if not isValidSpell(id) then return end
- -- DEBUG
- --self:Print("RemoveAbsorb -- id: "..id)
- absorbUnit[guid] = nil;
- absorbHeal[guid] = nil;
- self:Clear(guid)
- end
- function GridStatusSearingPlasma:HealAbsorb(guid, absorbed)
- -- Check valid spell
- -- DEBUG
- --self:Print("HealAbsorb -- absorbed: ".. (absorbed or 0))
- if absorbUnit[guid] then
- --self:Print("HealAbsorb -- absorbUnitFound")
- absorbHeal[guid] = absorbHeal[guid] + (absorbed or 0)
- -- Check if remaining value
- local remainder = absorbUnit[guid] - absorbHeal[guid];
- if remainder and remainder > 0 then
- -- DEBUG
- --self:Print("HealAbsorb -- remainder: ".. remainder)
- -- Update
- self:SendAbsorbStatus(guid, remainder)
- elseif remainder <= 0 then
- self:SendAbsorbStatus(guid, 0)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment