获取WoW 1.13中进攻伤害数值和魔法系别

我如何使用World Of WarCraft 1.13的api(lua语言)获取由其他玩家或怪物造成给我的伤害数值和魔法系别? 这是必要的,以便我可以使用

print("您收到了 " .. damageValue .. " " .. damageSchool .. " 伤害")

这样我就可以在聊天框中获得:

您收到了 100 火焰伤害

您收到了 50 物理伤害

等等。

点赞
用户1297035
用户1297035

经典战斗日志应该与零售版本几乎相同

请参见https://wow.gamepedia.com/COMBAT_LOG_EVENT

local playerGUID = UnitGUID("player")
local MSG_PLAYER_DAMAGE = "You received %d %s damage"

local damageEvents = {
    SWING_DAMAGE = true,
    SPELL_DAMAGE = true,
}

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 == "SWING_DAMAGE" then
        amount = select(12, ...)
    elseif subevent == "SPELL_DAMAGE" then
        spellId, spellName, spellSchool, amount = select(12, ...)
    end

    if damageEvents[subevent] and destGUID == playerGUID then
        print(MSG_PLAYER_DAMAGE:format(amount, GetSchoolString(spellSchool or 0x1)))
    end
end
2019-11-07 15:29:16