- fixed CC bars to work for any loc by using GetSpellInfo along with a list of spell ID's for each CC spell it supports (thanks to Arrowmaster/#wowace for the help!)

- made FocusCC basically an empty shell that just inherits from TargetCC and specifies a different unit (should have done this in the first place...)
- cleaned spacing/formatting in TargetCC module
This commit is contained in:
Parnic
2008-06-25 02:54:15 +00:00
parent eb0373450f
commit 546a19c2d8
3 changed files with 181 additions and 269 deletions

View File

@ -42,6 +42,7 @@ modules\SunderCount.lua
modules\GlobalCoolDown.lua
modules\SliceAndDice.lua
modules\TargetCC.lua
# - make sure FocusCC loads after TargetCC since it inherits
modules\FocusCC.lua
modules\FocusHealth.lua
modules\FocusMana.lua

View File

@ -1,179 +1,27 @@
local AceOO = AceLibrary("AceOO-2.0")
local FocusCC = AceOO.Class(IceUnitBar)
-- changed to inherit from the TargetCC bar since the only difference is the unit and the default placement
-- helps keep changes in one place and we don't have to duplicate the CC spell tables and they don't have to be globals
local FocusCC = AceOO.Class(TargetCC)
-- Constructor --
function FocusCC.prototype:init()
FocusCC.super.prototype.init(self, "FocusCC", "focus")
self.unit = "focus"
self.moduleSettings = {}
self.moduleSettings.desiredLerpTime = 0
-- self.moduleSettings.shouldAnimate = false
self:SetDefaultColor("CC:Stun", 0.85, 0.55, 0.2)
self:SetDefaultColor("CC:Incapacitate", 0.90, 0.6, 0.2)
self:SetDefaultColor("CC:Fear", 0.85, 0.2, 0.65)
self.debuffList = {}
self.debuffList["Kidney Shot"] = "Stun"
self.debuffList["Cheap Shot"] = "Stun"
self.debuffList["Mace Stun Effect"] = "Stun"
self.debuffList["Shadowfury"] = "Stun"
self.debuffList["Hammer of Justice"] = "Stun"
self.debuffList["Impact"] = "Stun"
self.debuffList["Blackout"] = "Stun"
self.debuffList["Intimidation"] = "Stun"
self.debuffList["Charge Stun"] = "Stun"
self.debuffList["Intercept Stun"] = "Stun"
self.debuffList["Revenge Stun"] = "Stun"
self.debuffList["Concussion Blow"] = "Stun"
self.debuffList["Bash"] = "Stun"
self.debuffList["Pounce"] = "Stun"
self.debuffList["Improved Concussive Shot"] = "Stun"
self.debuffList["Starfire Stun"] = "Stun"
self.debuffList["War Stomp"] = "Stun"
self.debuffList["Repentance"] = "Incapacitate"
self.debuffList["Sap"] = "Incapacitate"
self.debuffList["Gouge"] = "Incapacitate"
self.debuffList["Blind"] = "Incapacitate"
self.debuffList["Wyvern Sting"] = "Incapacitate"
self.debuffList["Scatter Shot"] = "Incapacitate"
self.debuffList["Sleep"] = "Incapacitate"
self.debuffList["Polymorph"] = "Incapacitate"
self.debuffList["Polymorph: Pig"] = "Incapacitate"
self.debuffList["Polymorph: Turtle"] = "Incapacitate"
self.debuffList["Hibernate"] = "Incapacitate"
self.debuffList["Freezing Trap Effect"] = "Incapacitate"
self.debuffList["Chastize"] = "Incapacitate"
self.debuffList["Maim"] = "Incapacitate"
self.debuffList["Banish"] = "Incapacitate"
self.debuffList["Shackle"] = "Incapacitate"
self.debuffList["Shackle Undead"] = "Incapacitate"
self.debuffList["Psychic Scream"] = "Fear"
self.debuffList["Fear"] = "Fear"
self.debuffList["Howl of Terror"] = "Fear"
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
FocusCC.super.prototype.init(self, "FocusCC", "focus")
end
-- 'Public' methods -----------------------------------------------------------
-- OVERRIDE
function FocusCC.prototype:Enable(core)
FocusCC.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_AURA", "UpdateFocusDebuffs")
self:ScheduleRepeatingEvent(self.elementName, self.UpdateFocusDebuffs, 0.1, self)
self:Show(false)
end
-- OVERRIDE
function FocusCC.prototype:GetDefaultSettings()
local settings = FocusCC.super.prototype.GetDefaultSettings(self)
settings["enabled"] = false
settings["shouldAnimate"] = false
settings["desiredLerpTime"] = nil
settings["lowThreshold"] = 0
settings["side"] = IceCore.Side.Left
settings["offset"] = 4
settings["usesDogTagStrings"] = false
return settings
end
function FocusCC.prototype:Disable(core)
FocusCC.super.prototype.Disable(self, core)
self:CancelScheduledEvent(self.elementName)
end
-- OVERRIDE
function FocusCC.prototype:GetOptions()
local opts = FocusCC.super.prototype.GetOptions(self)
opts["shouldAnimate"] = nil
opts["desiredLerpTime"] = nil
opts["lowThreshold"] = nil
opts["textSettings"].args["upperTextString"] = nil
opts["textSettings"].args["lowerTextString"] = nil
return opts
end
-- 'Protected' methods --------------------------------------------------------
function _GetMaxDebuffDuration(unitName, debuffNames)
local i = 1
local debuff, rank, texture, count, debuffType, duration, remaining = UnitDebuff(unitName, i)
local result = {nil, nil, nil}
while debuff do
if debuffNames[debuff] then
if result[0] then
if result[2] < remaining then
result = {debuff, duration, remaining}
end
else
result = {debuff, duration, remaining}
end
end
i = i + 1;
debuff, rank, texture, count, debuffType, duration, remaining = UnitDebuff(unitName, i)
end
return unpack(result)
end
function FocusCC.prototype:UpdateFocusDebuffs()
local name, duration, remaining = _GetMaxDebuffDuration(self.unit, self.debuffList)
local focusName = UnitName(self.unit)
if (name ~= nil) and (self.previousDebuff == nil) and (duration ~= nil) and (remaining ~= nil) then
self.previousDebuff = name
self.previousDebuffTarget = focusName
self.previousDebuffTime = GetTime() + duration
-- Parnic: Force the CurrScale to 1 so that the lerping doesn't make it animate up and back down
self.CurrScale = 1.0
elseif (self.previousDebuff ~= nil) then
if (focusName ~= self.previousDebuffTarget) then
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
elseif (GetTime() > self.previousDebuffTime) then
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
end
end
if (name ~= nil) then
self:Show(true)
if (duration ~= nil) then
self:UpdateBar(remaining / duration, "CC:" .. self.debuffList[name])
self:SetBottomText2(floor(remaining * 10) / 10)
else
self:UpdateBar(0, "CC:" .. self.debuffList[name])
self:SetBottomText2("")
end
self:SetBottomText1(name)
elseif not IceHUD.IceCore:IsInConfigMode() then
self:Show(false)
end
end
-- Load us up
IceHUD.FocusCC = FocusCC:new()

View File

@ -1,78 +1,141 @@
local AceOO = AceLibrary("AceOO-2.0")
local TargetCC = AceOO.Class(IceUnitBar)
-- needs to not be local so that we can inherit from it
TargetCC = AceOO.Class(IceUnitBar)
-- list of spell ID's for each CC type so we can avoid localization issues
local StunCCList = {
-- kidney shot
408,
-- cheap shot
1833,
-- mace stun effect
5530,
-- shadowfury
30283,
-- hammer of justice
853,
-- impact
12355,
-- blackout
15268,
-- intimidation
19577,
-- charge stun
7922,
-- intercept stun
30153,
-- revenge stun
12798,
-- concussion blow
12809,
-- bash
5211,
-- pounce
9005,
-- improved concussive shot
19407,
-- starfire stun
16922,
-- war stomp
20549
}
local IncapacitateCCList = {
-- Repentance
20066,
-- sap
6770,
-- gouge
1776,
-- blind
2094,
-- Wyvern Sting
19386,
-- Scatter Shot
19503,
-- Sleep
700,
-- Polymorph
118,
-- Polymorph: Pig
28272,
-- Polymorph: Turtle
28271,
-- Hibernate
2637,
-- Freezing Trap Effect
3355,
-- Chastise
44041,
-- Maim
22570,
-- Banish
710,
-- Shackle Undead
9484
}
local FearCCList = {
-- Psychic Scream
8122,
-- Fear
5782,
-- Howl of Terror
5484
}
-- Constructor --
function TargetCC.prototype:init()
TargetCC.super.prototype.init(self, "TargetCC", "target")
function TargetCC.prototype:init(moduleName, unit)
-- not sure if this is necessary...i think it is...this way, we can instantiate this bar on its own or as a parent class
if moduleName == nil or unit == nil then
TargetCC.super.prototype.init(self, "TargetCC", "target")
else
TargetCC.super.prototype.init(self, moduleName, unit)
end
self.unit = "target"
self.moduleSettings = {}
self.moduleSettings.desiredLerpTime = 0
-- self.moduleSettings.shouldAnimate = false
self.moduleSettings = {}
self.moduleSettings.desiredLerpTime = 0
-- self.moduleSettings.shouldAnimate = false
self:SetDefaultColor("CC:Stun", 0.85, 0.55, 0.2)
self:SetDefaultColor("CC:Incapacitate", 0.90, 0.6, 0.2)
self:SetDefaultColor("CC:Fear", 0.85, 0.2, 0.65)
self:SetDefaultColor("CC:Stun", 0.85, 0.55, 0.2)
self:SetDefaultColor("CC:Incapacitate", 0.90, 0.6, 0.2)
self:SetDefaultColor("CC:Fear", 0.85, 0.2, 0.65)
self.debuffList = {}
self:PopulateSpellList(self.debuffList, StunCCList, "Stun")
self:PopulateSpellList(self.debuffList, IncapacitateCCList, "Incapacitate")
self:PopulateSpellList(self.debuffList, FearCCList, "Fear")
self.debuffList = {}
self.debuffList["Kidney Shot"] = "Stun"
self.debuffList["Cheap Shot"] = "Stun"
self.debuffList["Mace Stun Effect"] = "Stun"
self.debuffList["Shadowfury"] = "Stun"
self.debuffList["Hammer of Justice"] = "Stun"
self.debuffList["Impact"] = "Stun"
self.debuffList["Blackout"] = "Stun"
self.debuffList["Intimidation"] = "Stun"
self.debuffList["Charge Stun"] = "Stun"
self.debuffList["Intercept Stun"] = "Stun"
self.debuffList["Revenge Stun"] = "Stun"
self.debuffList["Concussion Blow"] = "Stun"
self.debuffList["Bash"] = "Stun"
self.debuffList["Pounce"] = "Stun"
self.debuffList["Improved Concussive Shot"] = "Stun"
self.debuffList["Starfire Stun"] = "Stun"
self.debuffList["War Stomp"] = "Stun"
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
end
self.debuffList["Repentance"] = "Incapacitate"
self.debuffList["Sap"] = "Incapacitate"
self.debuffList["Gouge"] = "Incapacitate"
self.debuffList["Blind"] = "Incapacitate"
self.debuffList["Wyvern Sting"] = "Incapacitate"
self.debuffList["Scatter Shot"] = "Incapacitate"
self.debuffList["Sleep"] = "Incapacitate"
self.debuffList["Polymorph"] = "Incapacitate"
self.debuffList["Polymorph: Pig"] = "Incapacitate"
self.debuffList["Polymorph: Turtle"] = "Incapacitate"
self.debuffList["Hibernate"] = "Incapacitate"
self.debuffList["Freezing Trap Effect"] = "Incapacitate"
self.debuffList["Chastize"] = "Incapacitate"
self.debuffList["Maim"] = "Incapacitate"
self.debuffList["Banish"] = "Incapacitate"
self.debuffList["Shackle"] = "Incapacitate"
self.debuffList["Shackle Undead"] = "Incapacitate"
-- grabs the list of CC's and pulls the localized spell name using the wow api
function TargetCC.prototype:PopulateSpellList(debuffListVar, ccList, ccName)
local spellName
self.debuffList["Psychic Scream"] = "Fear"
self.debuffList["Fear"] = "Fear"
self.debuffList["Howl of Terror"] = "Fear"
for i=1,#ccList do
spellName = GetSpellInfo(ccList[i])
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
if spellName and spellName ~= "" then
debuffListVar[spellName] = ccName
end
end
end
-- 'Public' methods -----------------------------------------------------------
-- OVERRIDE
function TargetCC.prototype:Enable(core)
TargetCC.super.prototype.Enable(self, core)
TargetCC.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_AURA", "UpdateTargetDebuffs")
self:RegisterEvent("UNIT_AURA", "UpdateTargetDebuffs")
self:ScheduleRepeatingEvent(self.elementName, self.UpdateTargetDebuffs, 0.1, self)
self:ScheduleRepeatingEvent(self.elementName, self.UpdateTargetDebuffs, 0.1, self)
self:Show(false)
self:Show(false)
end
function TargetCC.prototype:Disable(core)
@ -83,17 +146,17 @@ end
-- OVERRIDE
function TargetCC.prototype:GetDefaultSettings()
local settings = TargetCC.super.prototype.GetDefaultSettings(self)
local settings = TargetCC.super.prototype.GetDefaultSettings(self)
settings["enabled"] = false
settings["shouldAnimate"] = false
settings["desiredLerpTime"] = nil
settings["lowThreshold"] = 0
settings["enabled"] = false
settings["shouldAnimate"] = false
settings["desiredLerpTime"] = nil
settings["lowThreshold"] = 0
settings["side"] = IceCore.Side.Left
settings["offset"] = 3
settings["usesDogTagStrings"] = false
return settings
return settings
end
-- OVERRIDE
@ -127,70 +190,70 @@ end
-- 'Protected' methods --------------------------------------------------------
function _GetMaxDebuffDuration(unitName, debuffNames)
local i = 1
local debuff, rank, texture, count, debuffType, duration, remaining = UnitDebuff(unitName, i)
local result = {nil, nil, nil}
local i = 1
local debuff, rank, texture, count, debuffType, duration, remaining = UnitDebuff(unitName, i)
local result = {nil, nil, nil}
while debuff do
if debuffNames[debuff] then
if result[0] then
if result[2] < remaining then
result = {debuff, duration, remaining}
end
else
result = {debuff, duration, remaining}
end
end
while debuff do
if debuffNames[debuff] then
if result[0] then
if result[2] < remaining then
result = {debuff, duration, remaining}
end
else
result = {debuff, duration, remaining}
end
end
i = i + 1;
i = i + 1;
debuff, rank, texture, count, debuffType, duration, remaining = UnitDebuff(unitName, i)
end
debuff, rank, texture, count, debuffType, duration, remaining = UnitDebuff(unitName, i)
end
return unpack(result)
return unpack(result)
end
function TargetCC.prototype:UpdateTargetDebuffs()
local name, duration, remaining = _GetMaxDebuffDuration(self.unit, self.debuffList)
local targetName = UnitName(self.unit)
local name, duration, remaining = _GetMaxDebuffDuration(self.unit, self.debuffList)
local targetName = UnitName(self.unit)
if (name ~= nil) and (self.previousDebuff == nil) and (duration ~= nil) and (remaining ~= nil) then
if (duration > 1) and (self.moduleSettings.alertParty) and ((GetNumPartyMembers() >= 1) or (GetNumRaidMembers() >= 1)) then
SendChatMessage(targetName .. ": " .. name .. " (" .. tostring(floor(remaining * 10) / 10) .. "/" .. tostring(duration) .. "s)", "PARTY")
end
if (name ~= nil) and (self.previousDebuff == nil) and (duration ~= nil) and (remaining ~= nil) then
if (duration > 1) and (self.moduleSettings.alertParty) and ((GetNumPartyMembers() >= 1) or (GetNumRaidMembers() >= 1)) then
SendChatMessage(targetName .. ": " .. name .. " (" .. tostring(floor(remaining * 10) / 10) .. "/" .. tostring(duration) .. "s)", "PARTY")
end
self.previousDebuff = name
self.previousDebuffTarget = targetName
self.previousDebuffTime = GetTime() + duration
self.previousDebuff = name
self.previousDebuffTarget = targetName
self.previousDebuffTime = GetTime() + duration
-- Parnic: Force the CurrScale to 1 so that the lerping doesn't make it animate up and back down
self.CurrScale = 1.0
elseif (self.previousDebuff ~= nil) then
if (targetName ~= self.previousDebuffTarget) then
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
elseif (GetTime() > self.previousDebuffTime) then
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
end
end
elseif (self.previousDebuff ~= nil) then
if (targetName ~= self.previousDebuffTarget) then
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
elseif (GetTime() > self.previousDebuffTime) then
self.previousDebuff = nil
self.previousDebuffTarget = nil
self.previousDebuffTime = nil
end
end
if (name ~= nil) then
self:Show(true)
if (name ~= nil) then
self:Show(true)
if (duration ~= nil) then
self:UpdateBar(remaining / duration, "CC:" .. self.debuffList[name])
self:SetBottomText2(floor(remaining * 10) / 10)
else
self:UpdateBar(0, "CC:" .. self.debuffList[name])
self:SetBottomText2("")
end
if (duration ~= nil) then
self:UpdateBar(remaining / duration, "CC:" .. self.debuffList[name])
self:SetBottomText2(floor(remaining * 10) / 10)
else
self:UpdateBar(0, "CC:" .. self.debuffList[name])
self:SetBottomText2("")
end
self:SetBottomText1(name)
else
self:Show(false)
end
self:SetBottomText1(name)
else
self:Show(false)
end
end
-- Load us up