TA的每日心情 | 奋斗 2021-4-28 23:23 |
---|
签到天数: 20 天 [LV.4]偶尔看看III
|
本帖最后由 丨一朵丶大脑壳 于 2009-6-9 21:56 编辑
今天发现最可能的就是LUA了就连二测都有,不信用搜索 *.LUA 所以赶快去学习这个。同志加油哦。这下面可能是个更新的,但是还没确定引用的函数,所以不知道啦,争取在没公布之前,找到嘿嘿.
-----------------------------------------------------------------------------
local tNotifyList = {}
local NORMAL_FONT = 162
local STRESS_FONT = 163
function OnBattleFieldNotify(dwMapID, nNotifyType, nAvgQueueTime, nPassTime, nTimeIndex, nSerialNumber)
-- update data
if nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.QUEUE_INFO
or nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.JOIN_BATTLE_FIELD then
if not tNotifyList[dwMapID] then
tNotifyList[dwMapID] = {}
FireEvent("BATTLE_FIELD_STATE_UPDATE")
end
tNotifyList[dwMapID].nNotifyType = nNotifyType
tNotifyList[dwMapID].nAvgQueueTime = nAvgQueueTime
tNotifyList[dwMapID].nPassTime = nPassTime
tNotifyList[dwMapID].nTimeIndex = nTimeIndex
tNotifyList[dwMapID].nSerialNumber = nSerialNumber
elseif nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.LEAVE_BATTLE_FIELD then
CloseMessageBox("BattleField_Enter_" .. dwMapID)
tNotifyList[dwMapID] = nil
FireEvent("BATTLE_FIELD_STATE_UPDATE")
end
if nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.JOIN_BATTLE_FIELD then
if not tNotifyList[dwMapID].bRemind then
local tMsg =
{
szMessage = FormatString(
g_tStrings.STR_BATTLEFIELD_MESSAGE_ENTER,
GetBattleFieldQueueName(dwMapID, tNotifyList[dwMapID].nTimeIndex, tNotifyList[dwMapID].nSerialNumber)
),
szName = "BattleField_Enter_" .. dwMapID,
{szOption = g_tStrings.STR_HOTKEY_ENTER, fnAction = function() DoAcceptJoinBattleField(dwMapID, nTimeIndex, nSerialNumber) end, },
{szOption = g_tStrings.STR_HOTKEY_HIDE, },
{szOption = g_tStrings.STR_HOTKEY_LEAVE, fnAction = function() DoLeaveBattleFieldQueue(dwMapID) end, },
}
MessageBox(tMsg)
tNotifyList[dwMapID].bRemind = true
end
end
end
function GetCurrentBattleField()
return tNotifyList
end
function GetBattleFieldStateTip()
local szTip = nil
if IsInBattleField() then
local hScene = GetClientPlayer().GetScene()
local szBattleFiledName = GetBattleFieldQueueName(hScene.dwMapID, nil, hScene.GetSerialNumber())
if szBattleFiledName then
szTip = GetFormatText(g_tStrings.STR_BATTLEFIELD_FIGHTING, NORMAL_FONT) .. GetFormatText(szBattleFiledName, STRESS_FONT)
end
end
for dwMapID, tData in pairs(tNotifyList) do
local szSubTip = nil
if tData.nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.QUEUE_INFO then
szSubTip = FormatBattleFieldQueueTip(
GetBattleFieldQueueName(dwMapID, tData.nTimeIndex, tData.nSerialNumber),
tData.nPassTime,
tData.nAvgQueueTime
)
elseif tData.nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.JOIN_BATTLE_FIELD then
szSubTip = FormatBattleFieldJoinTip(
GetBattleFieldQueueName(dwMapID, tData.nTimeIndex, tData.nSerialNumber),
MAX_BATTLE_FIELD_OVERTIME - tData.nPassTime
)
end
if szSubTip then
if szTip then
szTip = szTip .. GetFormatText("\n\n", NORMAL_FONT) .. szSubTip
else
szTip = szSubTip
end
end
end
return szTip
end
function GetBattleFieldMenu()
local tMenu = nil
if IsInBattleField() then
tMenu = { { szOption = g_tStrings.STR_BATTLEFIELD_MENU_LEAVE, fnAction = function() LeaveBattleField() end, } }
end
for dwMapID, tData in pairs(tNotifyList) do
if tData.nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.QUEUE_INFO
or tData.nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.JOIN_BATTLE_FIELD then
if tMenu then
table.insert(tMenu, {bDevide = true})
else
tMenu = {}
end
table.insert(tMenu, { szOption = GetBattleFieldQueueName(dwMapID, tData.nTimeIndex, tData.nSerialNumber), bDisable = true, nFont = STRESS_FONT, })
if tData.nNotifyType == BATTLE_FIELD_NOTIFY_TYPE.JOIN_BATTLE_FIELD then
table.insert(tMenu, { szOption = g_tStrings.STR_BATTLEFIELD_MENU_ENTER, fnAction = function() DoAcceptJoinBattleField(dwMapID, tData.nTimeIndex, tData.nSerialNumber) end, })
end
table.insert(tMenu, { szOption = g_tStrings.STR_BATTLEFIELD_MENU_LEAVE, fnAction = function() DoLeaveBattleFieldQueue(dwMapID) end, })
end
end
return tMenu
end
function GetBattleFieldQueueName(dwMapID, nTimeIndex, nSerialNumber)
local szName = GetBattleFieldName(dwMapID)
if nSerialNumber and nSerialNumber ~= 0 then
szName = szName .. "(" .. nSerialNumber .. ")"
end
return szName
end
function HasBattleFieldInfo()
local hPlayer = GetClientPlayer()
if not hPlayer then
return false
end
local hScene = hPlayer.GetScene()
if IsBattleFieldMap(hScene.dwMapID) then
return true
end
for _, _ in pairs(tNotifyList) do
return true
end
end
function IsInBattleField()
local hPlayer = GetClientPlayer()
if hPlayer then
local hScene = hPlayer.GetScene()
return IsBattleFieldMap(hScene.dwMapID)
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function DoAcceptJoinBattleField(dwMapID, nTimeIndex, nSerialNumber)
CloseMessageBox("BattleField_Enter_" .. dwMapID)
tNotifyList[dwMapID] = nil
FireEvent("BATTLE_FIELD_STATE_UPDATE")
AcceptJoinBattleField(dwMapID, nTimeIndex, nSerialNumber)
end
function DoLeaveBattleFieldQueue(dwMapID)
CloseMessageBox("BattleField_Enter_" .. dwMapID)
tNotifyList[dwMapID] = nil
FireEvent("BATTLE_FIELD_STATE_UPDATE")
LeaveBattleFieldQueue(dwMapID)
end
function FormatBattleFieldTime(nTime)
local szTime
if nTime > 60 then
szTime = math.floor(nTime / 60) .. g_tStrings.STR_BUFF_H_TIME_M
else
szTime = nTime .. g_tStrings.STR_BUFF_H_TIME_S
end
return szTime
end
function FormatBattleFieldQueueTip(szBattleField, nPassTime, nAvgTime)
local szBattleField = GetFormatText(szBattleField, STRESS_FONT)
local szTip = FormatString(
g_tStrings.STR_BATTLEFIELD_QUEUE_WAIT,
"\"font=" .. NORMAL_FONT .. " </text>" .. szBattleField .. "<text>text=\""
)
szTip = szTip .. "\n"
szTip = "<text>text=\"" .. szTip .. "\" font=" .. NORMAL_FONT .. "</text>"
if nAvgTime > 0 then
szTip = szTip .. GetFormatText(g_tStrings.STR_BATTLEFIELD_QUEUE_AVGTIME, NORMAL_FONT)
szTip = szTip .. GetFormatText(FormatBattleFieldTime(nAvgTime) .. "\n", STRESS_FONT)
else
szTip = szTip .. GetFormatText(g_tStrings.STR_BATTLEFIELD_QUEUE_TIME_UNKNOW .. "\n", NORMAL_FONT)
end
szTip = szTip .. GetFormatText(g_tStrings.STR_BATTLEFIELD_QUEUE_PASSTIME, NORMAL_FONT)
szTip = szTip .. GetFormatText(FormatBattleFieldTime(nPassTime) .. "\n", STRESS_FONT)
return szTip
end
function FormatBattleFieldJoinTip(szBattleField, nLastTime)
local szBattleField = GetFormatText(szBattleField, STRESS_FONT)
local szLastTime = GetFormatText(FormatBattleFieldTime(nLastTime), STRESS_FONT)
local szTip = FormatString(
g_tStrings.STR_BATTLEFIELD_QUEUE_ENTER,
"\"font=" .. NORMAL_FONT .. " </text>" .. szBattleField .. "<text>text=\"",
"\"font=" .. NORMAL_FONT .. " </text>" .. szLastTime .. "<text>text=\""
)
return "<text>text=\"" .. szTip .. "\" font=" .. NORMAL_FONT .. "</text>"
end
RegisterEvent("BATTLE_FIELD_NOTIFY", function() OnBattleFieldNotify(arg3, arg0, arg1, arg2, arg4, arg5) end) |
评分
-
3
查看全部评分
-
|