如何使用lua语言中的api魔兽世界1.13获得伤害值和传入伤害魔法流派?其他玩家或暴徒对我造成的伤害。这是必要的,这样我就可以使用
print("You received " .. damageValue .. " " .. damageSchool .. " damage")
这样我就可以进入聊天:
你受到100点火焰伤害
你受到了50点物理伤害
等。
经典战斗日志应该与零售日志几乎相同
请参阅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