Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions MY_Cataclysm/src/MY_CataclysmMain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ local function InsertBuffListCache(aBuffList, szVia, nViaPriority)
for iid, aList in pairs(BUFF_LIST) do
if iid == id or (tab.szName and type(iid) == 'number' and Table_GetBuffName(iid, 1) == tab.szName) then
for i, p in X.ipairs_r(aList) do
if (not tab.nLevel or p.nLevel == tab.nLevel)
and (not tab.szStackOp or p.szStackOp == tab.szStackOp)
and (not tab.nStackNum or p.nStackNum == tab.nStackNum)
and (not tab.bOnlyMe or p.bOnlyMe == tab.bOnlyMe)
and (not tab.bOnlyMine or p.bOnlyMine == tab.bOnlyMine) then
if (not tab.nLevel or tab.nLevel == p.nLevel)
and (not tab.szStackOp or tab.szStackOp == p.szStackOp)
and (not tab.nStackNum or tab.nStackNum == p.nStackNum)
and (not tab.nPriority or tab.nPriority == p.nPriority)
and (not tab.bOnlyMe == not p.bOnlyMe)
and (not tab.bOnlyMine == not p.bOnlyMine)
and (not tab.bCaution == not p.bCaution)
and (not tab.bAttention == not p.bAttention)
and (not tab.bScreenHead == not p.bScreenHead) then
table.remove(aList, i)
end
end
Expand Down Expand Up @@ -111,6 +115,8 @@ local function UpdateTeamMonData()
v.nLevel = data.nLevel
end
v.nIcon = data.nIcon
v.szDisplay = v.szDisplay or data.szDisplay
v.szDisplay = v.szDisplay and X.RenderTemplateString(v.szDisplay, nil, -1, false, false)
table.insert(aBuff, v)
end
end
Expand Down
2 changes: 1 addition & 1 deletion MY_Cataclysm/src/MY_CataclysmParty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ function D.UpdateCharaterBuff(p, handle, tKeep)
local szCountdownKey = 'MY_CATACLYSM_' .. tBuff.dwID .. '_' .. tRule.szKey
FireUIEvent('MY_LIFEBAR_COUNTDOWN', dwCharID, 'BUFF', szCountdownKey, {
dwBuffID = tBuff.dwID,
szText = tBuff.szName,
szText = tRule.szDisplay or tBuff.szName,
nLogicFrame = tBuff.nEndFrame,
col = tRule.colScreenHead or tRule.col,
nPriority = tItem.nPriority,
Expand Down
1 change: 1 addition & 0 deletions MY_LifeBar/src/MY_LifeBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ X.RegisterEvent('PARTY_UPDATE_BASE_INFO', 'MY_LifeBar', onPartySetMark)

local function onLoadingEnd()
OVERWRITE_TITLE_EFFECT = {}
COUNTDOWN_CACHE = {} -- 清除缓存,防止不同地图分配相同ID,造成染色污染
end
X.RegisterEvent('LOADING_END', onLoadingEnd)
end
Expand Down
10 changes: 10 additions & 0 deletions MY_LifeBar/src/MY_LifeBar_Official.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,21 @@ local settings = {
MY_LifeBar_Official = X.CreateModule(settings)
end

--------------------------------------------------------------------------------
-- 事件注册
--------------------------------------------------------------------------------

X.RegisterEvent({'PLAYER_ENTER_SCENE', 'NPC_ENTER_SCENE'}, 'MY_LifeBar_Official', function()
local dwID = arg0
X.DelayCall(function() ApplyCaption(dwID) end)
X.DelayCall(200, function() ApplyCaption(dwID) end)
X.DelayCall(500, function() ApplyCaption(dwID) end)
end)
X.RegisterEvent('LOADING_END', 'MY_LifeBar_Official', function()
for dwID, _ in pairs(COUNTDOWN_CACHE) do
ResetCaption(dwID)
end
COUNTDOWN_CACHE = {}
end)

--[[#DEBUG BEGIN]]X.ReportModuleLoading(MODULE_PATH, 'FINISH')--[[#DEBUG END]]
6 changes: 5 additions & 1 deletion MY_LifeBar/src/MY_LifeBar_ScreenArrow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,11 @@ X.BreatheCall('MY_LifeBar_ScreenArrow', D.OnBreathe)
X.RegisterEvent('FIGHT_HINT', 'MY_LifeBar_ScreenArrow', D.RegisterFight)
X.RegisterEvent('LOGIN_GAME', 'MY_LifeBar_ScreenArrow', D.Init)
X.RegisterEvent('UI_SCALED' , 'MY_LifeBar_ScreenArrow', SetUIScale)

X.RegisterEvent('LOADING_END', 'MY_LifeBar_ScreenArrow', function()
CACHE[TARGET.NPC] = {}
CACHE[TARGET.PLAYER] = {}
CACHE[TARGET.DOODAD] = {}
end)
X.RegisterUserSettingsInit('MY_LifeBar_ScreenArrow', function()
D.bReady = true
end)
Expand Down
146 changes: 134 additions & 12 deletions MY_TeamMon/src/MY_TeamMon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ end
-- 核心优化变量
local MY_TEAM_MON_CORE_PLAYERID = 0
local MY_TEAM_MON_CORE_NAME = 0
local MY_TEAM_MON_MEMBER_CACHE = {}
local MY_TEAM_MON_MEMBER_ID_MAP = {}

local MY_TEAM_MON_MAX_INTERVAL = 300
local MY_TEAM_MON_MAX_CACHE = 3000 -- 最大的cache数量 主要是UI的问题
Expand Down Expand Up @@ -410,26 +412,44 @@ local function ParseCountdown(szCountdown)
local nTime = tonumber(aParams[1])
local szContent = aParams[2]
local szVoice
local nIcon, nFrame
local szParam, bUnknownParam, bParamRecognized
for i = 3, #aParams do
szParam = aParams[i]
bParamRecognized = false
-- 解析语音
if not szVoice and not bParamRecognized then
if szParam:sub(1, 3) == 'VO:'
or szParam:sub(1, 3) == 'VC:' then
szVoice = szParam:sub(4)
bParamRecognized = true
end
end
-- 解析图标
if not nIcon and not bParamRecognized then
if szParam:sub(1, 6) == 'nIcon:' then
nIcon = tonumber(szParam:sub(7))
bParamRecognized = true
end
end
-- 解析背景色
if not nFrame and not bParamRecognized then
if szParam:sub(1, 7) == 'nFrame:' then
nFrame = tonumber(szParam:sub(8))
bParamRecognized = true
end
end
if not bParamRecognized then
bUnknownParam = true
end
end
if nTime and szContent and nTime and szContent ~= '' and not bUnknownParam then
if nTime and szContent and szContent ~= '' and not bUnknownParam then
table.insert(aCountdown, {
nTime = nTime,
szContent = szContent,
szVoice = szVoice,
nIcon = nIcon,
nFrame = nFrame,
})
bPartError = false
end
Expand Down Expand Up @@ -469,10 +489,12 @@ local function ParseHPCountdown(szString)
local szContent = aParams[2]
local nTime
local szVoice
local nIcon, nFrame
local szParam, bUnknownParam, bParamRecognized
for i = 3, #aParams do
szParam = aParams[i]
bParamRecognized = false
-- 解析语音
if not szVoice and not bParamRecognized then
if szParam:sub(1, 3) == 'VO:'
or szParam:sub(1, 3) == 'VC:' then
Expand All @@ -486,6 +508,20 @@ local function ParseHPCountdown(szString)
bParamRecognized = true
end
end
-- 解析图标
if not nIcon and not bParamRecognized then
if szParam:sub(1, 6) == 'nIcon:' then
nIcon = tonumber(szParam:sub(7))
bParamRecognized = true
end
end
-- 解析背景色
if not nFrame and not bParamRecognized then
if szParam:sub(1, 7) == 'nFrame:' then
nFrame = tonumber(szParam:sub(8))
bParamRecognized = true
end
end
if not bParamRecognized then
bUnknownParam = true
end
Expand All @@ -497,6 +533,8 @@ local function ParseHPCountdown(szString)
szContent = szContent,
nTime = nTime,
szVoice = szVoice,
nIcon = nIcon,
nFrame = nFrame,
})
bPartError = false
end
Expand All @@ -517,6 +555,11 @@ local function ParseHPCountdown(szString)
return X.Clone(CACHE.HP_CD_STR[szString][1]), CACHE.HP_CD_STR[szString][2]
end

-- 判断是否为队友ID
local function IsTeamMemberID(dwID)
return dwID and MY_TEAM_MON_MEMBER_ID_MAP and MY_TEAM_MON_MEMBER_ID_MAP[dwID]
end

function D.OnFrameCreate()
this:RegisterEvent('MY_TEAM_MON_LOADING_END')
this:RegisterEvent('MY_TEAM_MON_CREATE_CACHE')
Expand Down Expand Up @@ -699,7 +742,10 @@ function D.OnEvent(szEvent)
elseif szEvent == 'LOADING_END' or szEvent == 'MY_TEAM_MON_CREATE_CACHE' or szEvent == 'MY_TEAM_MON_LOADING_END' then
D.FireCrossMapEvent('before')
D.CreateData(szEvent)
D.OnTeamEvent(szEvent)
X.DelayCall('MY_TeamMon__FireCrossMapEvent__after', D.FireCrossMapEvent, 'after')
elseif szEvent == 'PARTY_ADD_MEMBER' or szEvent == 'PARTY_DELETE_MEMBER' or szEvent == 'PARTY_DISBAND' then
D.OnTeamEvent(szEvent)
end
end

Expand Down Expand Up @@ -875,7 +921,7 @@ function D.CreateData(szEvent)
if v.szContent then
if v.szContent:find('{$me}') or v.szContent:find('{$team}') or v.bSearch or v.bReg then -- 具有通配符和搜索标记的数据不作 HIT 高速匹配策略考虑
table.insert(cache.OTHER, v)
elseif not cache.HIT[v.szContent] then -- 按照数据优先级顺序(地图>地图组>通用),同级按照下标先后顺序,只取第一个匹配结果
elseif not (cache.HIT[v.szContent] and cache.HIT[v.szContent][v.szTarget or 'sys']) then -- 按照数据优先级顺序(地图>地图组>通用),同级按照下标先后顺序,只取第一个匹配结果
cache.HIT[v.szContent] = cache.HIT[v.szContent] or {}
cache.HIT[v.szContent][v.szTarget or 'sys'] = v
end
Expand Down Expand Up @@ -1035,10 +1081,14 @@ function D.CountdownEvent(data, nClass, szSender, szReceiver, aBackreferences)
nIcon = v.nIcon or data.nIcon or 340,
nFrame = v.nFrame,
szContent = FilterCustomText(v.szName or data.szName, szSender, szReceiver, aBackreferences),
szRawName = v.szName or data.szName,
nTime = v.nTime,
nRefresh = v.nRefresh,
bTalk = v.bTeamChannel,
bHold = v.bHold,
szVoice = v.szVoice,
nNewtime = v.nNewtime,
bHoldFrame = v.bHoldFrame,
}
D.FireCountdownEvent(nType, szKey, tParam, szSender, szReceiver, aBackreferences)
end
Expand Down Expand Up @@ -1071,7 +1121,7 @@ function D.OnBuff(dwOwner, bDelete, bCanCancel, dwBuffID, nCount, nBuffLevel, dw
if MY_TEAM_MON_SHIELDED_TOTAL then
return
end
if MY_TEAM_MON_SHIELDED_OTHER_PLAYER and X.IsPlayer(dwSkillSrcID) and dwSkillSrcID ~= MY_TEAM_MON_CORE_PLAYERID then
if MY_TEAM_MON_SHIELDED_OTHER_PLAYER and X.IsPlayer(dwSkillSrcID) and dwSkillSrcID ~= MY_TEAM_MON_CORE_PLAYERID and not IsTeamMemberID(dwSkillSrcID) then
return
end
local szType = bCanCancel and 'BUFF' or 'DEBUFF'
Expand Down Expand Up @@ -1737,18 +1787,46 @@ function D.OnCallMessage(szEvent, szContent, dwNpcID, szNpcName)
dwReceiverID, szReceiver = nil
end
if bInParty and content:find('{$team}', nil, true) then
local c = content
for _, vv in ipairs(team.GetTeamMemberList()) do
if string.find(szContent, c:gsub('{$team}', team.GetClientTeamMemberName(vv)), nil, true) and (v.szTarget == szNpcName or v.szTarget == '%') then -- hit
data = v
dwReceiverID = vv
szReceiver = team.GetClientTeamMemberName(vv)
if v.bReg then
-- 正则模式(带{$team}):逆向排除,先遍历成员名,替换为{$team},不替换为空防止破坏位置约束,若替换成功,说明命中,再正则匹配剩余的内容,如此只用一次正则,节约性能
local nHitMemberID, szHitMemberName, szProcessedContent
-- 获取正则{$team}数量,决定后续成员名替换为{$team}次数
local _, nTeamCount = content:gsub('{$team}', '{$team}')
for _, member in ipairs(MY_TEAM_MON_MEMBER_CACHE) do
local szHitContent, nHitCount = string.gsub(szContent, member.szName, '{$team}', nTeamCount)
if nHitCount > 0 then
nHitMemberID = member.dwID
szHitMemberName = member.szName
szProcessedContent = szHitContent
break
end
end
if nHitMemberID and szHitMemberName then
local res = {string.find(szProcessedContent, content)}
if res[1] then
table.remove(res, 1)
table.remove(res, 1)
data = v
aBackreferences = res
dwReceiverID = nHitMemberID
szReceiver = szHitMemberName
break
end
end
else
local c = content
for _, vv in ipairs(team.GetTeamMemberList()) do
if string.find(szContent, c:gsub('{$team}', team.GetClientTeamMemberName(vv)), nil, true) and (v.szTarget == szNpcName or v.szTarget == '%') then -- hit
data = v
dwReceiverID = vv
szReceiver = team.GetClientTeamMemberName(vv)
break
end
end
if dwReceiverID and szReceiver then
break
end
end
if dwReceiverID and szReceiver then
break
end
elseif v.szTarget == szNpcName or v.szTarget == '%' then
if v.bReg then
local res = {string.find(szContent, content)}
Expand Down Expand Up @@ -2011,10 +2089,54 @@ function D.FireCrossMapEvent(szWhen)
D.OnCallMessage(szEvent, szContent)
end
MAP_ID = dwMapID

-- 组队模式下过图后系统没有推送BUFF刷新事件,这里手动补发一下,以后修复了再删除
local me = X.GetClientPlayer()
if me then
if me.IsInParty() then
for _, tBuff in X.ipairs_c(X.GetBuffList(me)) do
D.OnBuff(me.dwID, false, tBuff.bCanCancel, tBuff.dwID, tBuff.nStackNum, tBuff.nLevel, tBuff.dwSkillSrcID)
end
end
end
end
end
end

-- 团队成员事件 刷新团队成员排序缓存
function D.OnTeamEvent(szEvent)
local me = X.GetClientPlayer()
if not me then
return
end
local tMemberID = {}
local tMemberList = {}
if me.IsInParty() then
local team = GetClientTeam()
if team then
for _, vv in ipairs(team.GetTeamMemberList()) do
local tMemberData = {
dwID = vv,
szName = team.GetClientTeamMemberName(vv)
}
tMemberID[vv] = tMemberData
table.insert(tMemberList, tMemberData)
end
table.sort(tMemberList, function(a, b) return #a.szName > #b.szName end)
end
end
if #tMemberList == 0 then
local tMemberData = {
dwID = MY_TEAM_MON_CORE_PLAYERID,
szName = MY_TEAM_MON_CORE_NAME
}
tMemberID[MY_TEAM_MON_CORE_PLAYERID] = tMemberData
table.insert(tMemberList, tMemberData)
end
MY_TEAM_MON_MEMBER_CACHE = tMemberList
MY_TEAM_MON_MEMBER_ID_MAP = tMemberID
end

-- RegisterMsgMonitor
function D.RegisterMessage(bEnable)
if bEnable then
Expand Down
2 changes: 2 additions & 0 deletions MY_TeamMon/src/MY_TeamMon_BuffList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ function D.OnEvent(szEvent)
D.UpdateAnchor(this)
elseif szEvent == 'ON_ENTER_CUSTOM_UI_MODE' or szEvent == 'ON_LEAVE_CUSTOM_UI_MODE' then
UpdateCustomModeWindow(this, _L['Buff list'])
elseif szEvent == 'LOADING_END' then
D.handle:Clear()
end
end
function D.OnItemMouseEnter()
Expand Down
Loading
Loading