WoWInterface SVN BabySeal

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

BabySeal.lua New file
0,0 → 1,222
--[[
BabySeal
by Ailae of Emeriss-EU
 
Warns if you enter combat without an active
Seal (Paladins)/Shout (Warriors)/Armor buff (Warlocks).
Also warns if the buff expires while in combat, with
an option to have an advance warning.
]]
 
local class, pguid, db
local isBuffPlayer = false
 
local BabySeal = CreateFrame("Frame", nil, UIParent)
BabySeal:RegisterEvent("PLAYER_ENTERING_WORLD")
 
BabySeal:SetScript("OnEvent", function(self, event, ...)
self[event](self, ...)
end)
 
local spells = {}
local spellIDs = {
["PALADIN"] = {
31801, -- Seal of Truth
20164, -- Seal of Justice
20165, -- Seal of Insight
20154, -- Seal of Righteousness
},
["WARRIOR"] = {
6673, -- Battle Shout
8076, -- Strength of Earth (exclusive with BS)
57330, -- Horn of Winter (exclusive with BS)
93435, -- Roar of Courage (exclusive with BS)
469, -- Commanding Shout
21562, -- Power Word: Fortitude (exclusive with CS)
90364, -- Qiraji Fortitude (exclusive with CS)
},
["WARLOCK"] = {
687, -- Demon Armor
28176, -- Fel Armor
},
["DEATHKNIGHT"] = {
57330, -- Horn of Winter
6673, -- Battle Shout (exclusive with HoW)
8076, -- Strength of Earth (exclusive with HoW)
93435, -- Roar of Courage (exclusive with HoW)
},
["PRIEST"] = {
588, -- Inner Fire
15286, -- Vampiric Embrace
},
["SHAMAN"] = {
324, -- Lightning Shield
52127, -- Water Shield
},
}
 
local messages = {}
local msgs = {
["PALADIN"] = {
["combat"] = "No active seal.",
["expired"] = "Seal expired.",
["notify"] = "Seal expires soon.",
},
["WARRIOR"] = {
["combat"] = "No active shout.",
["expired"] = "Shout expired.",
["notify"] = "Shout expires soon.",
},
["WARLOCK"] = {
["combat"] = "No active armor buff.",
["expired"] = "Armor buff expired.",
["notify"] = "Armor buff expires soon.",
},
["DEATHKNIGHT"] = {
["combat"] = "No active horn.",
["expired"] = "Horn expired.",
["notify"] = "Horn expires soon.",
},
["PRIEST"] = {
["combat"] = "Missing armor buff.",
["expired"] = "Armor buff expired.",
["notify"] = "Armor buff expires soon.",
},
["SHAMAN"] = {
["combat"] = "Missing shield.",
["expired"] = "Shield expired.",
["notify"] = "Shield expires soon.",
},
}
 
local prefix = "|cff00aaffBabySeal:|r |cffff0000Warning!|r"
 
-- output message
function BabySeal:Complain(message)
if BabySeal.db.rWframe then
RaidNotice_AddMessage(RaidWarningFrame, message, ChatTypeInfo["RAID_WARNING"])
else
print(prefix, message)
end
 
if BabySeal.db.playSound then
PlaySound("RaidWarning")
end
end
 
-- store spells with correct locale (should work at least)
function BabySeal:StoreSpells()
local name
for k, v in ipairs(spellIDs[class]) do
name, _, _, _, _, _, _, _, _ = GetSpellInfo(v)
if not spells[name] and name then
spells[name] = true
end
end
BabySealSpells = spells -- for debug purposes
end
 
-- scan if there is a seal active
function BabySeal:ScanSpells()
local spell, caster
for k, v in pairs(spells) do
spell, _, _, _, _, _, _, caster, _, _, _ = UnitAura("player", k)
 
-- if we found an active seal and player cast it, bail out
if spell and caster == "player" then
isBuffPlayer = true
return spell
else
-- if the player is a Warrior or DK and the spell exists but was not cast
-- by the player, an equivalent is active.
if spell and (class == "WARRIOR" or class == "DEATHKNIGHT") and not caster == "player" then
isBuffPlayer = false
return spell
end
end
end
 
return nil -- if we get to this point, there was no seal active
end
 
function BabySeal:PLAYER_ENTERING_WORLD()
class = select(2, UnitClass("player"))
pguid = UnitGUID("player")
if spellIDs[class] then
-- check that SavedVars exists, otherwise create 'em
if not BabySealSV then
BabySealSV = {
playSound = false,
rWframe = false,
notify = true,
}
end
 
messages = msgs[class]
BabySeal.db = BabySealSV
 
self:StoreSpells()
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("SPELLS_CHANGED")
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
end
 
local expires = 0
function BabySeal:ActivateNotify(spell)
expires = select(7, UnitAura("player", spell))
self:SetScript("OnUpdate", BabySeal_OnUpdate)
end
 
local timer = 0
function BabySeal_OnUpdate(self, elapsed)
timer = timer + elapsed
if timer < 1 then return end
 
timer = 0
 
if expires - GetTime() <= 5 then
self:Complain(messages["notify"])
self:SetScript("OnUpdate", nil)
end
end
 
function BabySeal:PLAYER_REGEN_DISABLED()
local activeSpell = BabySeal:ScanSpells()
if not activeSpell then
self:Complain(messages["combat"])
elseif BabySeal.db.notify then
self:ActivateNotify(activeSpell)
end
 
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
 
function BabySeal:PLAYER_REGEN_ENABLED()
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:SetScript("OnUpdate", nil) -- nil this, no need to check if it's expiring when it doesn't matter
end
 
-- CLEU-event instead of UNIT_AURA, since the idea was for it to only announce once that the seal faded
function BabySeal:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellID, spellName, spellSchool, auraType, ...)
if destGUID ~= pguid or auraType ~= "BUFF" or not spells[spellName] then return end
 
 
if event == "SPELL_AURA_REMOVED" then
if isBuffPlayer and not self:ScanSpells() then
self:Complain(messages["expired"])
end
elseif BabySeal.db.notify and isBuffPlayer and (event == "SPELL_AURA_APPLIED" or combatEvent == "SPELL_AURA_REFRESH") then
self:ActivateNotify(spellName)
end
end
 
function BabySeal:SPELLS_CHANGED()
self:StoreSpells()
end
 
-- slash'n'hack? no?
SlashCmdList["BabySeal"] = function() InterfaceOptionsFrame_OpenToCategory("BabySeal") end
SLASH_BabySeal1 = "/babyseal"
SLASH_BabySeal2 = "/bs"
\ No newline at end of file
BabySeal.toc New file
0,0 → 1,9
## Interface: 40000
## Title: BabySeal
## Notes: Warns when entering combat without apropriate classbuff
## Author: Ailae
## Version: 40000.wowi:revision
## SavedVariables: BabySealSV
 
BabySeal.lua
BabySealOptions.lua
BabySealOptions.lua New file
0,0 → 1,93
--[[
BabySealOptions
by Ailae of Emeriss-EU
 
Toggle options regarding where output should go and
whether you want a spiffy sound or not.
 
Bunch of credits to Tekkub, was looking at some of his (her?) code when
putting this together.
]]
 
local BabySealOptions = CreateFrame("Frame", nil, UIParent)
BabySealOptions.name = "BabySeal"
BabySealOptions:Hide()
 
BabySealOptions:SetScript("OnShow", function(self)
local db = _G.BabySealSV
 
-- header
self.header = self:CreateFontString(nil, "ARTWORK")
self.header:SetPoint("TOPLEFT", 16, -16)
self.header:SetFontObject(SystemFont_Shadow_Large)
self.header:SetTextColor(1, 0.82, 0)
self.header:SetText("BabySeal Options")
 
-- infotext
self.info = self:CreateFontString(nil, "ARTWORK")
self.info:SetPoint("TOPLEFT", self.header, "BOTTOMLEFT", 0, -4)
self.info:SetPoint("RIGHT", -32, 0)
self.info:SetFontObject(SystemFont_Shadow_Med1)
self.info:SetWidth(400)
self.info:SetJustifyH("LEFT")
self.info:SetText("Toggle some stuff to your liking.")
 
-- checkbox for raidoutput
local raidCheck = CreateFrame("CheckButton", nil, self, "InterfaceOptionsCheckButtonTemplate")
raidCheck:SetPoint("TOPLEFT", self.info, "BOTTOMLEFT", 0, -10)
raidCheck:SetChecked(db.rWself)
raidCheck:SetScript("OnClick", function(self)
if db.rWframe then
self:SetChecked(false)
db.rWframe = false
else
self:SetChecked(true)
db.rWframe = true
end
end)
 
raidCheck.text = raidCheck:CreateFontString(nil, "ARTWORK")
raidCheck.text:SetPoint("LEFT", raidCheck, "RIGHT", 4, 0)
raidCheck.text:SetFontObject(SystemFont_Shadow_Med1)
raidCheck.text:SetText("Toggle to output warnings to the |cff9aff99RaidWarning frame|r.")
 
-- checkbox for audiowarning
local audioCheck = CreateFrame("CheckButton", nil, self, "InterfaceOptionsCheckButtonTemplate")
audioCheck:SetPoint("TOPLEFT", raidCheck, "BOTTOMLEFT", 0, -4)
audioCheck:SetChecked(db.playSound)
audioCheck:SetScript("OnClick", function(self)
if db.playSound then
self:SetChecked(false)
db.playSound = false
else
self:SetChecked(true)
db.playSound = true
end
end)
audioCheck.text = self:CreateFontString(nil, "ARTWORK")
audioCheck.text:SetPoint("LEFT", audioCheck, "RIGHT", 4, 0)
audioCheck.text:SetFontObject(SystemFont_Shadow_Med1)
audioCheck.text:SetText("Toggle to play the |cff9aff99RaidWarning sound|r.")
 
-- checkbox for imminent seal expiration
local sealCheck = CreateFrame("CheckButton", nil, self, "InterfaceOptionsCheckButtonTemplate")
sealCheck:SetPoint("TOPLEFT", audioCheck, "BOTTOMLEFT", 0, -4)
sealCheck:SetChecked(db.notify)
sealCheck:SetScript("OnClick", function(self)
if db.notify then
self:SetChecked(false)
db.notify = false
else
self:SetChecked(true)
db.notify = true
end
end)
sealCheck.text = self:CreateFontString(nil, "ARTWORK")
sealCheck.text:SetPoint("LEFT", sealCheck, "RIGHT", 4, 0)
sealCheck.text:SetFontObject(SystemFont_Shadow_Med1)
sealCheck.text:SetText("Toggle to get a |cff9aff99warning in advance|r before your seal expires.")
 
self:SetScript("OnShow", nil)
end)
 
InterfaceOptions_AddCategory(BabySealOptions)
\ No newline at end of file