lua - 获得伤害值和魔法学派受到的伤害(WoW 1.13)
问题描述
如何使用 lua 语言的 api World Of WarCraft 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
推荐阅读
- python - 如何从 2 个不同的字符串和 concat 中获取字符串的一部分?
- java - 在两个不同的 vbo 之间进行插值时,网格面会失去方向
- javascript - 如何获取列表中卡片的 ID 或索引?
- mysql - 错误代码:1111。存储过程中组函数的使用无效
- javascript - 选择值未正确增加/减少 js 中的总数
- azure - 如何使用数据工厂截断 Dynamics 365 实体(并复制到 Azure 数据湖)?
- r - 在R中过滤后计算给定列中唯一元素的数量
- bash - 在 10.000 中随机选择 5.000 个数字的代码
- c++ - 字符串到 ascii hex/int 值
- scala - 在 scala 类型层次结构中忽略泛型参数