Skip to content

Commit

Permalink
Fixed private msg command: 11&22&33
Browse files Browse the repository at this point in the history
  • Loading branch information
haimanman committed Apr 16, 2017
1 parent 3cc01b7 commit 36a1b32
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 47 deletions.
21 changes: 21 additions & 0 deletions HM_0Base/HM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ local _HM = {
tMenuTrace = {},
tEvent = {},
tBgMsgHandle = {},
tPmCmdHandle = {},
tHotkey = {},
tDelayCall = {},
tBreatheCall = {},
Expand Down Expand Up @@ -1446,6 +1447,12 @@ HM.RegisterBgMsg = function(szKey, fnAction)
_HM.tBgMsgHandle[szKey] = fnAction
end

-- 注册/反注册简易的密聊指令
-- (void) HM.RegisterPmCmd(string szCmd[, funcfnAction])
HM.RegisterPmCmd = function(szCmd, fnAction)
_HM.tPmCmdHandle[szCmd] = fnAction
end

-- 注册用户定义数据,支持全局变量数组遍历
-- (void) HM.RegisterCustomData(string szVarPath)
HM.RegisterCustomData = function(szVarPath)
Expand Down Expand Up @@ -3155,6 +3162,20 @@ HM.AppendPlayerMenu(function()
fnAction = _HM.TogglePanel
}
end)
-- private msg command
RegisterMsgMonitor(function(szMsg)
local szPrefix = "<text>text=" .. EncodeComponentsString(g_tStrings.STR_TALK_HEAD_WHISPER_REPLY)
if string.sub(szMsg, 1, string.len(szPrefix)) == szPrefix then
for k, v in pairs(_HM.tPmCmdHandle) do
if StringFindW(szMsg, "text=" .. EncodeComponentsString(k)) then
local szName = string.match(szMsg, "text=\"%[(.-)%]\"")
if szName then
return pcall(v, szName, k)
end
end
end
end
end, {"MSG_WHISPER"})

-- Load skill extend data
_HM.tSkillEx = LoadLUAData("interface\\HM\\HM_0Base\\skill_ex.jx3dat") or {}
Expand Down
35 changes: 9 additions & 26 deletions HM_Locker/HM_Locker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,31 +207,6 @@ _HM_Locker.OnEnter = function()
end
end

-- player talk to quick select target
-- arg0:dwTalkerID,arg1:nChannel,arg2:bEcho,arg3:szName
_HM_Locker.OnPlayerTalk = function()
if not HM_Locker.bWhisperSel then return end
local me = GetClientPlayer()
if me and arg0 == me.dwID and arg1 == PLAYER_TALK_CHANNEL.WHISPER and arg2 == true then
local t = me.GetTalkData()
if t and #t == 1 and t[1].type == "text" and (t[1].text == "11" or (HM_TargetList and t[1].text == "33")) then
local szName = arg3
for _, v in ipairs(HM.GetAllPlayer()) do
if v.szName == arg3 then
if t[1].text == "11" then
HM.SetTarget(TARGET.PLAYER, v.dwID)
else
HM_TargetList.AddFocus(v.dwID)
end
break
end
end
elseif #t == 1 and t[1].type == "text" and t[1].text == "66" and arg3 == me.szName then
HM_Locker.tLowerForce[21] = not HM_Locker.tLowerForce[21]
end
end
end

-- register locker
_HM_Locker.AddLocker(_HM_Locker.CheckLockFight)
_HM_Locker.AddLocker(_HM_Locker.CheckDuel)
Expand Down Expand Up @@ -619,7 +594,6 @@ HM.RegisterEvent("NPC_LEAVE_SCENE", _HM_Locker.OnLeave)
HM.RegisterEvent("PLAYER_LEAVE_SCENE", _HM_Locker.OnLeave)
HM.RegisterEvent("NPC_ENTER_SCENE", _HM_Locker.OnEnter)
HM.RegisterEvent("PLAYER_ENTER_SCENE", _HM_Locker.OnEnter)
HM.RegisterEvent("PLAYER_TALK", _HM_Locker.OnPlayerTalk)
HM.RegisterEvent("SYS_MSG", _HM_Locker.OnCheckDuel)

-- add to HM panel
Expand All @@ -629,6 +603,15 @@ HM.RegisterPanel(_L["Lock/Select"], 3353, _L["Target"], _HM_Locker.PS)
HM.AddHotKey("SmartTarget", _L["Smart select target"], _HM_Locker.SearchTarget)
HM.AddHotKey("OnlyPlayer", _L["TAB player only"], _HM_Locker.SearchOnlyPlayer)

-- quick target use "11"
HM.RegisterPmCmd("11", function(szName)
for _, v in ipairs(HM.GetAllPlayer()) do
if v.szName == szName then
return HM.SetTarget(TARGET.PLAYER, v.dwID)
end
end
end)

-- public api
HM_Locker.AddLocker = _HM_Locker.AddLocker
HM_Locker.SetPrevTarget = _HM_Locker.SetPrevTarget
26 changes: 9 additions & 17 deletions HM_RedName/HM_RedName.lua
Original file line number Diff line number Diff line change
Expand Up @@ -592,22 +592,6 @@ _HM_RedName.OnBreathe = function()
_HM_RedName.AddWorldBreathe()
end

-- player talk to quick select target
-- arg0:dwTalkerID,arg1:nChannel,arg2:bEcho,arg3:szName
_HM_RedName.OnPlayerTalk = function()
local me = GetClientPlayer()
if me and arg0 == me.dwID and arg1 == PLAYER_TALK_CHANNEL.WHISPER and arg2 == true then
local t = me.GetTalkData()
if t and #t == 1 and t[1].type == "text" and t[1].text == "22" then
if _HM_RedName.tShareData[arg3] then
_HM_RedName.RemoveShare(arg3)
else
_HM_RedName.ConnShare(arg3)
end
end
end
end

-- bg talk
_HM_RedName.OnBgHear = function(nChannel, dwID, szName, data, bSelf)
if bSelf then -- 过滤自己
Expand Down Expand Up @@ -768,7 +752,6 @@ end
---------------------------------------------------------------------
-- 注册事件、初始化
---------------------------------------------------------------------
HM.RegisterEvent("PLAYER_TALK", _HM_RedName.OnPlayerTalk)
HM.BreatheCall("HM_RedName", _HM_RedName.OnBreathe)
HM.RegisterBgMsg("HM_REDNAME", _HM_RedName.OnBgHear)
-- add to HM collector
Expand All @@ -777,5 +760,14 @@ HM.RegisterPanel(_L["Nearby players"], 3293, nil, _HM_RedName.PS)
-- hotkey
HM.AddHotKey("AroundInfo", _L["Publish nearby stats"], _HM_RedName.ShowAroundInfo)

-- quick share use "22"
HM.RegisterPmCmd("22", function(szName)
if _HM_RedName.tShareData[arg3] then
_HM_RedName.RemoveShare(arg3)
else
_HM_RedName.ConnShare(arg3)
end
end)

-- public api
HM_RedName.ShowAroundInfo = _HM_RedName.ShowAroundInfo
13 changes: 13 additions & 0 deletions HM_TargetList/HM_TargetList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,19 @@ HM.RegisterEvent("LOADING_END", function()
end
end)

-- quick focus use "33"
HM.RegisterPmCmd("33", function(szName)
for _, v in ipairs(HM.GetAllPlayer()) do
if v.szName == szName then
if _HM_TargetList.IsFocus(v.dwID) then
_HM_TargetList.DelFocus(v.dwID)
else
_HM_TargetList.AddFocus(v.dwID)
end
end
end
end)

-- add to HM panel
HM.RegisterPanel(_L["Focus/TargetList"], 299, _L["Target"], _HM_TargetList.PS)

Expand Down
8 changes: 4 additions & 4 deletions HM_ToolBox/HM_ToolBox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1312,10 +1312,10 @@ HM.RegisterEvent("CHAT_PANEL_OPEN", function() _HM_ToolBox.HookChatPanel(arg0) e
HM.RegisterEvent("RELOAD_UI_ADDON_BEGIN", _HM_ToolBox.OnReloadUIAddon)
HM.RegisterEvent("RELOAD_UI_ADDON_END", _HM_ToolBox.OnChatPanelInit)
-- 记录点名聊天
RegisterMsgMonitor(_HM_ToolBox.OnRecordWhisperAt, {
"MSG_NORMAL", "MSG_MAP", "MSG_BATTLE_FILED", "MSG_PARTY", "MSG_SCHOOL",
"MSG_GUILD", "MSG_WORLD", "MSG_CAMP", "MSG_TEAM", "MSG_FRIEND"
})
--RegisterMsgMonitor(_HM_ToolBox.OnRecordWhisperAt, {
-- "MSG_NORMAL", "MSG_MAP", "MSG_BATTLE_FILED", "MSG_PARTY", "MSG_SCHOOL",
-- "MSG_GUILD", "MSG_WORLD", "MSG_CAMP", "MSG_TEAM", "MSG_FRIEND"
--})
HM.RegisterBgMsg("HM_BROAD", _HM_ToolBox.OnBgBroad)

-- add to HM collector
Expand Down

0 comments on commit 36a1b32

Please sign in to comment.