Originally Posted by
Vx-Odessa-xV
..but I was asking for the coding to write a macro that performs this function so I could do this with multiple spells across multiple characters.
Well, an addon works on all your characters. I updated the code I did for you a little bit, so it now has the yelling part (Blizzard made this function only work in instanced content) and works with multiple spells. It should be clear how to add additional spells. With this, your friend doesn't have to fiddle around with (m)any macros anymore, but can configure everything in one place.
Code:
local function OnEvent(self, event, ...)
IDsOfSpellToAnnounce =
{
Paladin_AvengingWrath = {31884}, -- https://www.wowhead.com/spell=31884/avenging-wrath
Paladin_HolyLight = {82326}, -- https://www.wowhead.com/spell=82326/holy-light
Priest_PowerWordShield = {17} -- https://www.wowhead.com/spell=17/power-word-shield
}
SentencesToAnnounce =
{
Paladin_AvengingWrath = {"We Strike with the Wrath of the Righteous!"},
Paladin_HolyLight = {"By the Holy Light, let me heal your wounds!"},
Priest_PowerWordShield = {"Shields up!"}
}
if ( event == "PLAYER_LOGIN" ) then
self:UnregisterEvent("PLAYER_LOGIN");
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
elseif (event == "COMBAT_LOG_EVENT_UNFILTERED") then
local _, eventType, _, _, sourceName, _, _, _, _, _, _, spellID, _, _, _ = CombatLogGetCurrentEventInfo()
if (eventType == "SPELL_CAST_SUCCESS") and sourceName == UnitName("player") then
for index, value in pairs(IDsOfSpellToAnnounce) do
IDOfSpellCastedByPlayer = IDsOfSpellToAnnounce[index][1]
if IDOfSpellCastedByPlayer == spellID then
SentenceForSpellCastedByPlayer = SentencesToAnnounce[index][1]
PlayerIsInInstance, _ = IsInInstance()
if PlayerIsInInstance then
Message = (SentenceForSpellCastedByPlayer .. " " ..GetSpellLink(spellID))
SendChatMessage(Message, "YELL")
else
Message = ("says: " ..SentenceForSpellCastedByPlayer .. " " ..GetSpellLink(spellID))
SendChatMessage(Message, "EMOTE")
end
end
end
end
end
end
local OdessaSpellAnnouncer = CreateFrame("Frame")
OdessaSpellAnnouncer:RegisterEvent("PLAYER_LOGIN")
OdessaSpellAnnouncer:SetScript("OnEvent", OnEvent)