一壶漂泊 发表于 2023-10-7 15:48:37

战斗事件求助!!!-已解决 感谢大佬

本帖最后由 一壶漂泊 于 2023-10-11 10:45 PM 编辑

目的是利用战斗事件监控法术是否暴击,求助哪里出问题了。
F=F or CreateFrame("Frame")
F:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
F:SetScript("OnEvent",I)

I= function(_,_,event,sourceGUID,_,_,_,_,_,_,spellName,_,_,_,_,_,_,_,critical)
    if event == "SPELL_DAMAGE" then
      if (sourceGUID == UnitGUID("player")) then
            if (
                spellName =="霜火之箭" or
                spellName =="灼烧" or
                spellName =="火球术" or
                spellName =="活动炸弹" or
                spellName =="不死鸟之焰" or
                spellName =="火焰冲击"
            ) then
                if criticalthen
                   print("暴击了")
                end
            end
      end
    end
end

贾维斯117 发表于 2023-10-7 22:19:14

I函数放到F里面或者F前面

xueying 发表于 2023-10-9 11:40:50

参数的位置串了。event是第4个,在前面补个_,就好使了

huoshan52 发表于 2023-10-7 16:11:57

请问现在1.12还能用战士的断筋替换压制吗?

懒动行不行 发表于 2023-10-8 09:56:15

local playerGUID = UnitGUID("player")
local MSG_CRITICAL_HIT = "Your %s critically hit %s for %d damage!"

local f = CreateFrame("Frame")
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self, event)
        local _, subevent, _, sourceGUID, _, _, _, _, destName = CombatLogGetCurrentEventInfo()
        local spellId, amount, critical

        if subevent == "SWING_DAMAGE" then
                amount, _, _, _, _, _, critical = select(12, CombatLogGetCurrentEventInfo())
        elseif subevent == "SPELL_DAMAGE" then
                spellId, _, _, amount, _, _, _, _, _, critical = select(12, CombatLogGetCurrentEventInfo())
        end

        if critical and sourceGUID == playerGUID then
                -- get the link of the spell or the MELEE globalstring
                local action = spellId and GetSpellLink(spellId) or MELEE
                print(MSG_CRITICAL_HIT:format(action, destName, amount))
        end
end)

一壶漂泊 发表于 2023-10-8 13:40:10

懒动行不行 发表于 2023-10-8 09:56 AM
local playerGUID = UnitGUID("player")
local MSG_CRITICAL_HIT = "Your %s criti ...

CombatLogGetCurrentEventInfo()
看官方说明 这个函数是8.0加入的

懒动行不行 发表于 2023-10-8 14:05:55

一壶漂泊 发表于 2023-10-8 01:40 PM
CombatLogGetCurrentEventInfo()
看官方说明 这个函数是8.0加入的

如果涉及到高版本的API,可以自己改下

懒动行不行 发表于 2023-10-9 16:18:05

本帖最后由 懒动行不行 于 2023-10-9 04:19 PM 编辑

F=CreateFrame("Frame")
F:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
F:SetScript("OnEvent",function(self,event)
local spellschool={"霜火之箭","灼烧","火球术","活动炸弹","不死鸟之焰","火焰冲击"}
local subevent=Select(2,"COMBAT_LOG_EVENT_UNFILTERED")
local spellname=Select(13,"COMBAT_LOG_EVENT_UNFILTERED")
local amount=Select(15,"COMBAT_LOG_EVENT_UNFILTERED")
local critical=Select(21,"COMBAT_LOG_EVENT_UNFILTERED")
if subevent==SPELL_DAMAGE then
for i=1,#spellschool do
if spellname==spellschool and critical then
SendChatMessage("my"..spellname.."critically hits for"..amount.."damage!")
break
end
end
end
end)

不知道这样是否可以,没办法上游戏验证
我觉得楼主的问题出现在I的函数,第一个参数应该是self,第2个是事件本身,第3个开始才是COMBAT_LOG_EVENT_UNFILTERED的参数,就像楼上说的,你代码中的EVENT应该是放到第4个参数

页: [1]
查看完整版本: 战斗事件求助!!!-已解决 感谢大佬