Skip to content

Instantly share code, notes, and snippets.

@jesseadams
Created June 12, 2011 06:14
Show Gist options
  • Save jesseadams/1021296 to your computer and use it in GitHub Desktop.
Save jesseadams/1021296 to your computer and use it in GitHub Desktop.
Hunter Misdirect Auto Announce
-- Config
local onlyAnnounceMine = false
local enabled = true
local whisperTargets = true
-- Environment Setup
local frame = CreateFrame("Frame", nil, UIParent);
local players = {}
-- Should Announce Check
function ShouldAnnounceMD(caster)
if not enabled then
return false
end
if onlyAnnounceMine and caster == UnitName("player") then
return true
elseif not onlyAnnounceMine and (UnitInParty(caster) or UnitInRaid(caster)) then
return true
else
return false
end
end
-- The Goods
function MDAnnounceProcessEvent(self, event, ...)
local timeStamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, col10, spellName, col12, spellType = ...
local inInstance, instanceType = IsInInstance()
message = nil
chatTYpe = nil
if spellName == "Misdirection" and ShouldAnnounceMD(sourceName) then
if event == "SPELL_CAST_SUCCESS" then
if not players[sourceName] then
players[sourceName] = {
successFlag = false,
initialEndFlag = false
}
end
message = sourceName .. "'s Misdirect is on " .. destName .. "."
if UnitIsPlayer(lastTargetOfMD) and whisperTargets then
SendChatMessage(sourceName .. "'s Misdirect is on YOU!!!", "WHISPER", nil, destName)
end
players[sourceName].successFlag = true
players[sourceName].initialEndFlag = false
elseif event == "SPELL_AURA_APPLIED" then
if players[sourceName] and players[sourceName].successFlag then
message = sourceName .. "'s MD is ACTIVE. Threat is building on " .. UnitName("target")
end
elseif event == "SPELL_AURA_REMOVED" then
if players[sourceName].initialEndFlag then
message = sourceName .. "'s MD had ended. DPS Bitches!"
players[sourceName].initialEndFlag = false
else
players[sourceName].initialEndFlag = true
end
players[sourceName].successFlag = false
end
if (instanceType == "raid") then
isAssist = UnitIsRaidOfficer("player")
if isAssist and players[sourceName].successFlag then
chatType = "RAID_WARNING"
else
chatType = "RAID"
end
elseif (instanceType == "party") then
chatType = "PARTY"
end
if message then
if chatType then
SendChatMessage(message, chatType)
else
print(message)
end
end
end
end
-- Dummy frame setup
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
frame:SetScript("OnEvent", MDAnnounceProcessEvent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment