WoW Classic (1.13) добавляет события: COMBAT_TEXT_UPDATE. Как исправить мой код? - PullRequest
0 голосов
/ 11 октября 2019

Я только недавно начал изучать LUA и дополнения для WoW. Я хочу отобразить школу магии и количество урона в чате, но мой код не работает. Пожалуйста, посмотрите, что я делаю не так.

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 Ответ

0 голосов
/ 11 октября 2019

См. Параметр «количество» для SPELL_DAMAGE в разделе 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

...