-1

I just recently began to study LUA and add-ons for WoW. I want to display the school of magic and the amount of damage in the chat, but my code does not work. Please see what I'm doing wrong.

local Congrats_EventFrame = CreateFrame("Frame")
CombatTextSetActiveUnit("player")
Congrats_EventFrame:RegisterEvent("COMBAT_TEXT_UPDATE")
Congrats_EventFrame:SetScript("OnEvent",
    function(arg1, arg2, arg3)
        print(arg1 .. ' - ' .. arg2 .. ' - ' .. arg3)
    end)

1 Answers1

0

See the "amount" parameter for SPELL_DAMAGE under https://wow.gamepedia.com/COMBAT_LOG_EVENT

local playerGUID = UnitGUID("player")
local MSG_SPELL_DAMAGE = "Your %s (%s) hit %s for %d damage!"

local f = CreateFrame("Frame")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self, event)
    self:OnEvent(event, CombatLogGetCurrentEventInfo())
end)

function f:OnEvent(event, ...)
    local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = ...
    local spellId, spellName, spellSchool
    local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand

    if subevent == "SPELL_DAMAGE" then
        spellId, spellName, spellSchool, amount = select(12, ...)
    end

    if amount and sourceGUID == playerGUID then
        local spell = spellId and GetSpellLink(spellId)
        print(MSG_SPELL_DAMAGE:format(spell, GetSchoolString(spellSchool), destName, amount))
    end
end

example

Ketho
  • 508
  • 3
  • 11
  • Oooh! It is so hard for me. And I speak English only through Google Translate. Excuse me for that. I meant to display the damage coming in for me (not the damage that I do to others). Can this be displayed? – maksim_pmi Oct 11 '19 at 18:48