求助事件大佬帮忙看看
想自己写一个利用事件监测技能有没有施放成功并计时的脚本。但是老是获取不到技能施放成功的数据,,不知道是哪里没写对lua
local SPELL_NAME = "复仇者之盾" -- 要检测的技能名称
local IN_COMBAT = false -- 标记玩家是否处于战斗状态
local function CheckCombatLog()
local _, event, _, sourceName, _, _, _, destName, _, _, _, spellName = CombatLogGetCurrentEventInfo()
if event == "COMBAT_LOG_EVENT_UNFILTERED" and spellName == SPELL_NAME and sourceName == UnitName("player") and string.find(arg1, "复仇者之盾命中") then
print("技能命中目标:" .. destName)
end
end
local function ToggleInCombat()
IN_COMBAT = not IN_COMBAT
if IN_COMBAT then
print("进入战斗状态")
else
print("脱离战斗状态")
end
end
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_REGEN_DISABLED" then
ToggleInCombat()
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
elseif event == "PLAYER_REGEN_ENABLED" then
ToggleInCombat()
frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
elseif event == "COMBAT_LOG_EVENT_UNFILTERED" and IN_COMBAT then
CheckCombatLog()
end
end)
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
感觉写的有点绕…直接注册COMBAT_LOG_EVENT_UNFILTERED,然后用api是否战斗中,接着再做技能判断应该看着简洁点 这边写了战斗的事件确实有点啰嗦了,不过怎么样简洁的写判断战斗记录事件的关键字,例如XX技能命中 local frame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local timestamp, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellID, spellName, spellSchool, extraSpellID, extraSpellName = ...
if eventType == "SPELL_CAST_SUCCESS" and spellName == "复仇者之盾" and sourceName == UnitName("player") then
print("技能命中成功!")
end
end
end)
--优化了精简了一下脚本,但是还是获取不到~是不是函数不对 看着像gpt写的…一般gpt写都要各阶段测试。打开调试命令,同时多print各种变量,如sourceName spellName eventType,逐个分析e 监控是否成功释放的话
用spell cast success不是更方便吗
战斗日志参数有点多 刚上游戏看了下,UNIT_SPELLCAST_SUCCEEDED这个时间335就有,直接用这个吧 收到!顶顶更健康!!!!收到!顶顶更健康!!!!收到!顶顶更健康!!!!88
页:
[1]