local class = select(2, UnitClass("player")) --ARE YOU A PRIEST?-- if class ~= "PRIEST" then return end --DEFINE MY LOCALS-- local Broadcaster = LibStub("AceAddon-3.0"):GetAddon("Broadcaster") local Priest = Broadcaster:NewModule("Priest", "AceEvent-3.0", "AceConsole-3.0") ------------------- local L = LibStub("AceLocale-3.0"):GetLocale("Broadcaster") local db, msgs local list, replacee, replacer, custom, msg local pick = {"Default", "Custom", "Both"} local player = UnitName("player") local resurrectionSpellID = { [2006] = true, --rank 1 resurrection [2010] = true, --rank 2 resurrection [10880] = true, --rank 3 resurrection [10881] = true, --rank 4 resurrection [20770] = true, --rank 5 resurrection [25435] = true --rank 6 resurrection } local defaults = { profile = { resenable = true, reschoose = "Default", }, } local options = { res = { name = L["Resurrection"], type = "group", arg = class, args = { enable = { name = L["Enable"], desc = L["Announce messages for this spell."], type = "toggle", order = 1, get = function() return db.resenable end, set = function() db.resenable = not db.resenable end, }, pick = { name = L["Pull messages from..."], desc = L["Use the default messages, your own, or both."], type = "select", order = 2, values = {L["Default"], L["Custom"], L["Both"]}, get = function() for k, v in pairs(pick) do if db.reschoose == v then return k end end end, set = function(_, choose) db.reschoose = pick[choose] end, }, custom = { name = L["Custom messages"], desc = L["Enter in any custom messages you would like to use, one per line."].."\n\n%t = "..L["the spell's target"], type = "input", order = 3, multiline = true, width = "double", get = function() return db.customres end, set = function(_, value) db.customres = value end, }, }, }, } -- INITIALIZE ADDON -- function Priest:OnInitialize() self.db = Broadcaster.db:RegisterNamespace(class, defaults) db = self.db.profile coredb = Broadcaster.db.profile msgs = BroadcasterPriestMsgs Broadcaster:InjectOptions(class, options) end function Priest:OnEnable() self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") end -- CREATE AND SEND MESSAGES -- function Priest:CompileMessage(list, custom, replacee, replacer) if custom then local pool = (#list + #custom) if math.random(pool) <= #custom then list = custom end end local max = #list local random = math.random(max) if replacee and replacer then msg = string.gsub(list[random], replacee, replacer) else msg = list[random] end if coredb.channel == L["Self"] then self:Print(msg) else SendChatMessage(msg, coredb.channel) end custom, replacee, replacer = nil end -------------------------------------- --VOODOO MAGIC STUFF-- -------------------------------------- function Broadcaster:COMBAT_LOG_EVENT_UNFILTERED(event, _, eventType, _, srcName, _, _, _, dstFlags, spellID, spellName, spellSchool, eID, eName) if not coredb.standby then if eventType == "SPELL_CAST_START" and srcName == player then --AND AM I CASTING RESURRECTION?-- if resurrectionSpellID[spellID] then list = msgs.Resurrection if db.reschoose == "Custom" then list = {strsplit("\n", db.customres)} elseif db.reschoose == "Both" then custom = {strsplit("\n", db.customres)} end self:CompileMessage(list, custom) end end end end