local t4bf = CreateFrame('Frame'); |
t4bf:SetScript('OnEvent', function(self, event, ...) getglobal("T4B_"..event)(event, ...) end); |
t4bf:RegisterEvent("VARIABLES_LOADED") |
|
function T4B_VARIABLES_LOADED(event, ...) |
if T4BOpts == nil then |
T4BOpts = {} |
end |
|
if T4BOpts["macro"] == nil then |
T4BOpts["macro"] = false |
end |
|
if T4BOpts["spell"] == nil then |
T4BOpts["spell"] = true |
end |
t4bf:UnregisterEvent("VARIABLES_LOADED") |
t4bf:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") |
|
T4BAbout = LibStub("tekKonfig-AboutPanel").new(nil, "Thanks4Buff") |
|
-- Create the Main Options |
local T4BOptFrame = CreateFrame("Frame", "T4BOptions", InterfaceOptionsFramePanelContainer) |
T4BOptFrame.name = "General Options" |
T4BOptFrame.parent = "Thanks4Buff" |
local title, subtitle = LibStub("tekKonfig-Heading").new(T4BOptFrame, "Thanks 4 Buff Options", "This panel controls the various T4B options.") |
|
-- Add the option to have T4B create a buffing macro. |
local macrocheck = LibStub("tekKonfig-Checkbox").new(T4BOptFrame, nil, "Create a macro that can be used to automatically buff those that buff you?", "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -8) |
local checksound = macrocheck:GetScript("OnClick") |
macrocheck:SetScript("OnClick", function(self) checksound(self); T4BOpts["macro"] = not T4BOpts["macro"]; end) |
local _, englishName = UnitClass("player") |
if T4B_Buffs[englishName] == nil then |
macrocheck:Disable() |
macrocheck:SetChecked(false) |
else |
macrocheck:Enable() |
macrocheck:SetChecked(T4BOpts["macro"]) |
end |
|
-- Add the option to include the spellname |
local spellcheck = LibStub("tekKonfig-Checkbox").new(T4BOptFrame, nil, "Add the name of the buff to the thank you emote?", "TOPLEFT", macrocheck, "BOTTOMLEFT", -2, -8) |
local checksound = spellcheck:GetScript("OnClick") |
spellcheck:SetScript("OnClick", function(self) checksound(self); T4BOpts["spell"] = not T4BOpts["spell"]; end) |
spellcheck:SetChecked(T4BOpts["spell"]) |
|
InterfaceOptions_AddCategory(T4BOptFrame) |
end |
|
|
|
function T4B_COMBAT_LOG_EVENT_UNFILTERED(event, ...) |
local timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1, ...) |
local filter = bit.bor(COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, COMBATLOG_OBJECT_REACTION_FRIENDLY, COMBATLOG_OBJECT_CONTROL_MASK, COMBATLOG_OBJECT_TYPE_MASK) |
if eventType == "SPELL_AURA_APPLIED" and destGUID == UnitGUID("player") and (CombatLog_Object_IsA(sourceFlags, filter) == 1) then |
|
local emotetext |
if T4BOpts["spell"] then |
t4bf:SetScript('OnEvent', function(self, event, ...) |
--DEFAULT_CHAT_FRAME:AddMessage("Working # 1") |
local timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1, ...) |
local filter = bit.bor(COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, COMBATLOG_OBJECT_REACTION_FRIENDLY, COMBATLOG_OBJECT_CONTROL_MASK, COMBATLOG_OBJECT_TYPE_MASK) |
if eventType == "SPELL_AURA_APPLIED" and destGUID == UnitGUID("player") and (CombatLog_Object_IsA(sourceFlags, filter) == 1) then |
local spellId, spellName, spellSchool = select(9, ...) |
emotetext = T4B_Sayings["spell"][random(#(T4B_Sayings["spell"]))] |
emotetext = gsub(emotetext, "#s", spellName) |
else |
emotetext = T4B_Sayings["nospell"][random(#(T4B_Sayings["nospell"]))] |
end |
emotetext = gsub(emotetext, "#n", sourceName) |
|
SendChatMessage(emotetext, "EMOTE") |
local _, englishName = UnitClass("player") |
if not InCombatLockdown() and T4B_Buffs[englishName] then |
local t4bIndex = GetMacroIndexByName("T4B_Macro") |
local numglobal,numperchar = GetNumMacros(); |
|
local macrotext = "/targetexact "..sourceName.."\n/cast [exists] "..T4B_Buffs[englishName].."\n/targetlasttarget" |
|
if t4bIndex == 0 and numglobal < 36 then |
CreateMacro("T4B_Macro",120, macrotext, nil, nil) |
elseif t4bIndex > 0 then |
EditMacro(t4bIndex, "T4B_Macro", 120, macrotext, 1, 1) |
end |
end |
end |
end |
|
T4B_Buffs = {} |
T4B_Buffs = { |
["DRUID"] = GetSpellInfo(1126), --MotW |
["PALADIN"] = GetSpellInfo(20217), --BoK |
["PRIEST"] = GetSpellInfo(1243), --Fort |
["MAGE"] = GetSpellInfo(1459) --AI |
} |
|
T4B_Sayings = {} |
T4B_Sayings["spell"] = {} |
T4B_Sayings["spell"] = { |
"thanks #n for their #s.", |
"is grateful for #n's #s.", |
"appreciates #n's #s." |
} |
T4B_Sayings["nospell"] = {} |
T4B_Sayings["nospell"] = { |
"thanks #n.", |
"is grateful to #n.", |
"is appreciative towards #n." |
} |