LUACN论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
热搜: YJWOW MagicStone BoL
查看: 205|回复: 7

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

[复制链接]
发表于 2023-10-7 15:48:37 | 显示全部楼层 |阅读模式
本帖最后由 一壶漂泊 于 2023-10-11 10:45 PM 编辑

目的是利用战斗事件监控法术是否暴击,求助哪里出问题了。
[Lua] 纯文本查看 复制代码
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 critical  then
                   print("暴击了")
                end
            end
        end
    end
end


回复

使用道具 举报

发表于 2023-10-7 22:19:14 | 显示全部楼层
I函数放到F里面或者F前面
回复 支持 1 反对 0

使用道具 举报

发表于 2023-10-9 11:40:50 | 显示全部楼层
参数的位置串了。event是第4个,在前面补个_,就好使了
回复 支持 1 反对 0

使用道具 举报

发表于 2023-10-7 16:11:57 | 显示全部楼层
请问现在1.12还能用战士的断筋替换压制吗?
回复 支持 反对

使用道具 举报

发表于 2023-10-8 09:56:15 | 显示全部楼层
[Lua] 纯文本查看 复制代码
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
[mw_shl_code=lua,true]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 编辑

[Lua] 纯文本查看 复制代码
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[i] 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个参数

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

小黑屋|手机版|Archiver|LUACN论坛

GMT+8, 2024-5-5 12:28 AM , Processed in 0.064776 second(s), 27 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表