From a2de829df8f468bdb97cb792a921b9a04b75de02 Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 12 Jun 2026 15:52:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B2=99=E5=B7=B4=E5=85=8B?= =?UTF-8?q?=E6=94=BB=E5=9F=8E=EF=BC=9A=E5=BD=B1=E4=B9=8B=E9=81=93=E5=BC=80?= =?UTF-8?q?=E6=94=BE=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA21:30-21:50?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=B6=88=E9=9D=9E=E6=94=BB=E5=9F=8E=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=BC=A0=E9=80=81=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QuestDiary/游戏功能/沙巴克/沙巴克攻城.lua | 213 +++++++++--------- 1 file changed, 104 insertions(+), 109 deletions(-) diff --git a/Mirserver/Mir200/Envir/QuestDiary/游戏功能/沙巴克/沙巴克攻城.lua b/Mirserver/Mir200/Envir/QuestDiary/游戏功能/沙巴克/沙巴克攻城.lua index 658ad059..a1c60cf6 100644 --- a/Mirserver/Mir200/Envir/QuestDiary/游戏功能/沙巴克/沙巴克攻城.lua +++ b/Mirserver/Mir200/Envir/QuestDiary/游戏功能/沙巴克/沙巴克攻城.lua @@ -11,94 +11,94 @@ end ---============================================================ ---- +--- 配置区 ---============================================================ local Cfg = {} -Cfg.palaceMapId = "0150" -- ʹͼID -Cfg.shadowMapId = "d701" -- Ӱ֮ͼID --- ɳ +Cfg.palaceMapId = "0150" -- 皇宫地图ID +Cfg.shadowMapId = "d701" -- 影之道地图ID +-- 首沙奖励 Cfg.firstWarYuanbao = { yuanbao = 10000, gold = 100000000, } --- ƽʱ +-- 平时奖励 Cfg.normalGold = 50000000 -- 5000w --- ֲ +-- 分布奖励 Cfg.reward = {} Cfg.reward[0] = 0 Cfg.reward[1] = 90 Cfg.reward[2] = 10 -Cfg._Player = {} -- +Cfg._Player = {} -- 玩家数据 --- -Cfg.minRelevel = 3 -- ת -Cfg.minMinutes = 15 -- ڳ +-- 参与条件 +Cfg.minRelevel = 3 -- 最低转生 +Cfg.minMinutes = 15 -- 最少在场分钟 --- ʹ͵㣨4㣩 +-- 皇宫传送点(4个随机点) Cfg.palacePoints = { - { x = 7, y = 17 }, -- ʹ͵㣨1㣩 - { x = 11, y = 21 }, -- ʹ͵㣨4㣩 - { x = 18, y = 13 }, -- ʹ͵㣨4㣩 - { x = 12, y = 10 }, -- ʹ͵㣨4㣩 + { x = 7, y = 17 }, -- 皇宫传送点(1个随机点) + { x = 11, y = 21 }, -- 皇宫传送点(4个随机点) + { x = 18, y = 13 }, -- 皇宫传送点(4个随机点) + { x = 12, y = 10 }, -- 皇宫传送点(4个随机点) } --- ɳ͵ +-- 沙区域传送点 Cfg.MovePoints = { - { mapId = "3", x = 644, y = 290 }, -- - { mapId = "3", x = 675, y = 340 }, -- ɳ - { mapId = "3", x = 635, y = 315 }, -- - { mapId = "3", x = 670, y = 282 }, -- · - { mapId = Cfg.shadowMapId, x = 34, y = 125 }, -- Ӱ֮ + { mapId = "3", x = 644, y = 290 }, -- 复活点 + { mapId = "3", x = 675, y = 340 }, -- 沙大门 + { mapId = "3", x = 635, y = 315 }, -- 武器店 + { mapId = "3", x = 670, y = 282 }, -- 衣服店 + { mapId = Cfg.shadowMapId, x = 34, y = 125 }, -- 影之道 } --- ãܼԹɳ0=,1=һ...6= -Cfg.warDays = { [3] = true, [6] = true } -- +-- 攻城日配置(周几可以攻沙,0=周日,1=周一...6=周六) +Cfg.warDays = { [3] = true, [6] = true } -- 周三、周六 --- ʱ䣨ÿִУصжڣ +-- 攻城时间(每天执行,回调内判断星期) Cfg.scheduleTime = { - notice15 = "15:00:00", -- 15ǰ - notice19 = "19:00:00", -- 19ǰ + notice15 = "15:00:00", -- 15点提前公告 + notice19 = "19:00:00", -- 19点提前公告 warStart = "20:55:00", - settle = "22:05:00", -- 225ֽ㽱 + settle = "22:05:00", -- 22点5分结算奖励 } ShabaKeOBJ.cfg = Cfg ---============================================================ ---- ƻעᣨȫֱϵͳ.luaͳһעᣩ +--- 计划任务注册(插入全局表,由系统任务.lua统一注册) ---============================================================ ShabaKeOBJ.Scheduled = { [200] = { - name = "ɳͿ15Ԥ", + name = "沙巴克15点预告", time = Cfg.scheduleTime.notice15, itype = 1, func = "SBK_onNotice15", param = nil, }, [201] = { - name = "ɳͿ19Ԥ", + name = "沙巴克19点预告", time = Cfg.scheduleTime.notice19, itype = 1, func = "SBK_onNotice19", param = nil, }, [202] = { - name = "ɳͿ˹ǿʼ", + name = "沙巴克攻城开始", time = Cfg.scheduleTime.warStart, - itype = 1, --* ÿִУصж + itype = 1, --* 每天执行,回调内判断星期 func = "SBK_onWarStart", param = nil, }, [203] = { - name = "ɳͿ˻", + name = "沙巴克活动结算", time = Cfg.scheduleTime.settle, itype = 1, func = "SBK_onSettle", @@ -106,38 +106,38 @@ ShabaKeOBJ.Scheduled = { }, } ----* ȫּƻ +---* 插入全局计划任务表 for i, v in pairs(ShabaKeOBJ.Scheduled or {}) do table.insert(RebotOBJ.Scheduled, v) end ----* ǰ˵õĺ +---* 允许前端调用的函数 ShabaKeOBJ.allowFunc = { "move" } ----* ȫ +---* 全服公告 local function SBK_announce(msg) sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":30}', msg)) end ----* жϽǷΪɳգɳǿΪɳգ +---* 判断今天是否为攻沙日(合区首沙当天强制为攻沙日) local function SBK_isTodayWarDay() if (Sys.getint(VarCfg.Global.int.hf) > Sys.getint(VarCfg.Global.int.CastleNum)) then return true end - -- жڼos.date "*t" wday: 1=,2=һ...7= + -- 正常判断星期几(os.date "*t" 中 wday: 1=周日,2=周一...7=周六) local wday = os.date("*t").wday - -- תΪ 0=,1=һ...6= ö + -- 转换为 0=周日,1=周一...6=周六 与配置对齐 local dayIndex = wday - 1 return Cfg.warDays[dayIndex] == true end ----* жǷɳ +---* 判断是否首沙 local function SBK_checkFirstWar() local flag = Sys.getint(VarCfg.Global.int.CastleNum) or 0 return flag == 0 @@ -145,15 +145,15 @@ end ---============================================================ ---- ʱ״̬ +--- 运行时状态 ---============================================================ local SBK = {} SBK._state = function() return castleinfo(5) -end --- ɳ״̬ +end --- 攻沙运行状态 SBK._isFirstWar = function() return SBK_checkFirstWar() -end -- Ƿɳ +end -- 是否首沙 SBK._doorOpen = function() if not SBK._state then return true @@ -164,7 +164,7 @@ SBK._doorOpen = function() return false end return true -end -- ״̬ +end -- 城门状态 SBK._shadowOpen = function() if not SBK._state then @@ -172,26 +172,30 @@ SBK._shadowOpen = function() end local t = os.date("*t") - if t.hour > 21 or (t.hour == 21 and t.min >= 40) then - return false + -- 影之道开放时间:21:30-21:50 + if t.hour < 21 or (t.hour == 21 and t.min < 30) then + return false -- 21:30前关闭 end - return true -end -- Ӱ֮״̬ + if t.hour > 21 or (t.hour == 21 and t.min >= 50) then + return false -- 21:50后关闭 + end + return true -- 21:30-21:50之间开启 +end -- 影之道状态 SBK._castlemaster = function() return castleinfo(3) -end -- ɳ᳤ +end -- 沙会长 SBK._castleName = function() return castleinfo(2) -end -- ɳл +end -- 沙城行会名 ShabaKeOBJ.SBK = SBK --- _ +-- 基类_主窗体 function ShabaKeOBJ:main(actor, ...) local info = { ... } local data = {} @@ -206,37 +210,37 @@ end ---============================================================ ---- ƻصȫֺã +--- 计划任务回调(全局函数,由引擎调用) ---============================================================ ----* 15:00 ǰ +---* 15:00 提前公告 function SBK_onNotice15() if not SBK_isTodayWarDay() then return end - SBK_announce("[ɳͿ]21:00ս,л׼!") + SBK_announce("[沙巴克]今晚21:00将开启攻城战,请各行会做好准备!") end ----* 19:00 ǰ +---* 19:00 提前公告 function SBK_onNotice19() if not SBK_isTodayWarDay() then return end - SBK_announce("[ɳͿ]ս21:00㿪,лװ!") + SBK_announce("[沙巴克]攻城战将于21:00点开启,请各行会整装待发!") end ----* 21:00 ǿʼ +---* 21:00 攻城开始 function SBK_onWarStart() - -- жϽǷɳ + -- 判断今天是否攻沙日 if not SBK_isTodayWarDay() then return end repaircastle() addattacksabukall() - -- ȫ + -- 全服公告 if SBK._isFirstWar() then - SBK_announce("[ɳͿ]״ιսʽ!ʹѿ!") + SBK_announce("[沙巴克]首次攻城战正式打响!皇宫大门已开启!") else - SBK_announce("[ɳͿ]սʽ!ʹѿ!") + SBK_announce("[沙巴克]攻城战正式打响!皇宫大门已开启!") end end ----* 22:00 +---* 22:00 结算 function SBK_onSettle() Cfg._Player = {} @@ -246,20 +250,20 @@ function SBK_onSettle() local _guild = getbaseinfo(actor, ConstCfg.gbase.guild) if _guild ~= "" then - local _time = Player.getTLint(actor, VarCfg.Player.TL.int[""]) + local _time = Player.getTLint(actor, VarCfg.Player.TL.int["攻城区域计秒"]) if _time >= Cfg.minMinutes * 60 then local _relevel = getbaseinfo(actor, ConstCfg.gbase.renew_level) or 0 if _relevel >= Cfg.minRelevel then local _Identity = castleidentity(actor) Cfg._Player[_Identity] = Cfg._Player[_Identity] or {} table.insert(Cfg._Player[_Identity], actor) - -- Player.setTLint(actor, VarCfg.Player.TL.int[""], 0) + -- Player.setTLint(actor, VarCfg.Player.TL.int["攻城区域计秒"], 0) end end end end - -- ȷǷΪ״ɳͿ˹ + -- 确定是否为首次沙巴克攻城 local isFirstWar = SBK._isFirstWar() local totalGold = 0 local totalYuanbao = 0 @@ -267,47 +271,47 @@ function SBK_onSettle() if isFirstWar then totalYuanbao = Cfg.firstWarYuanbao.yuanbao totalGold = Cfg.firstWarYuanbao.gold - warLabel = "״" + warLabel = "首次" else totalGold = Cfg.normalGold end - local mailId = 1001 -- ɳͿ˹ǽʼID + local mailId = 1001 -- 沙巴克攻城奖励邮件ID for _Identity, _player_list in pairs(Cfg._Player or {}) do local ratio = Cfg.reward[_Identity] or 0 if ratio > 0 and #_player_list > 0 then - -- ÿ˷ֵý + -- 按比例计算该身份组每人分得奖励 local perGold = math.floor(totalGold * ratio / 100 / #_player_list) local perYuanbao = 0 if isFirstWar then perYuanbao = math.floor(totalYuanbao * ratio / 100 / #_player_list) end - local identityName = _Identity == 0 and "ʧܷ" or (_Identity == 1 and "ʤ" or "ɳϴ") + local identityName = _Identity == 0 and "失败方" or (_Identity == 1 and "胜利方" or "沙城老大") for _, actor in ipairs(_player_list) do local name = getbaseinfo(actor, ConstCfg.gbase.name) if name and name ~= "" then - -- ʼ: Ʒ##󶨱 + -- 构建邮件附件内容: 物品名#数量#绑定标记 local rewards = "" if isFirstWar and perYuanbao > 0 then - rewards = "Ԫ#" .. perYuanbao .. "#0" + rewards = "绑定元宝#" .. perYuanbao .. "#0" end if perGold > 0 then if rewards ~= "" then rewards = rewards .. "&" end - rewards = rewards .. "󶨽#" .. perGold .. "#0" + rewards = rewards .. "绑定金币#" .. perGold .. "#0" end if rewards ~= "" then - local title = "ɳͿ˹ǽ" + local title = "沙巴克攻城奖励" local memo if _Identity == 0 then - memo = string.format("%sɳͿ˹սΪ%s룬²뽱", warLabel, identityName) + memo = string.format("您在%s沙巴克攻城战中作为%s参与,获得以下参与奖励!", warLabel, identityName) else - memo = string.format("ϲ%sɳͿ˹սΪ%s½", warLabel, identityName) + memo = string.format("恭喜您在%s沙巴克攻城战中作为%s获得以下奖励!", warLabel, identityName) end sendmail("#" .. name, mailId, title, memo, rewards) end @@ -317,14 +321,14 @@ function SBK_onSettle() end end ----* ʹżŹر,ӵ +---* 皇宫门及侧门关闭,进入连接点出发 function ShabaKeOBJ.onbeforeroute(actor, mapId, x, y, info) if not SBK._state() then return end if not SBK._doorOpen() and mapId == Cfg.palaceMapId then - Func.sendmsg9(actor, "[ɳͿ]:#70|ʹѹر,ֹ!") + Func.sendmsg9(actor, "[沙巴克]:#70|皇宫已关闭,禁止进入!") info.bool = false end end @@ -335,26 +339,22 @@ GameEvent.add(EventCfg.onbeforeroute, ShabaKeOBJ.onbeforeroute, ShabaKeOBJ) ---============================================================ ---- Ӱ֮ +--- 影之道传送入口 ---============================================================ function ShabaKeOBJ:shadowTransfer(actor) - if not SBK._state() then - Func.sendmsg9(actor, "[ɳͿ]:#70|ǰǹʱ!") - return - end - + -- 取消非攻城时间限制,只检查影之道开放时间 if not SBK._shadowOpen() then - Func.sendmsg9(actor, "[ɳͿ]:#70|Ӱ֮ѹر!") + Func.sendmsg9(actor, "[沙巴克]:#70|影之道传送已关闭!开放时间:21:30-21:50") return end local relevel = getbaseinfo(actor, ConstCfg.gbase.renew_level) or 0 if relevel < Cfg.minRelevel then - Func.sendmsg9(actor, string.format("[ɳͿ]:#70|Ҫ%dתϲܽ!", Cfg.minRelevel)) + Func.sendmsg9(actor, string.format("[沙巴克]:#70|需要%d转以上才能进入!", Cfg.minRelevel)) return end - -- ͵ʹ4֮һ + -- 随机传送到皇宫4点之一 local idx = math.random(1, #Cfg.palacePoints) local pt = Cfg.palacePoints[idx] mapmove(actor, Cfg.palaceMapId, pt.x, pt.y, 3, 0) @@ -363,12 +363,7 @@ end function ShabaKeOBJ:move(actor, p1, p2, p3, data) local id = data[1] - - if not SBK._state() then - Func.sendmsg9(actor, "[ɳͿ]:#70|ǰǹʱ!") - return - end - + -- 取消非攻城时间限制,允许随时传送 local cfg = Cfg.MovePoints[id] if not cfg then @@ -377,7 +372,7 @@ function ShabaKeOBJ:move(actor, p1, p2, p3, data) if id == 5 then if not SBK._shadowOpen() then - Func.sendmsg9(actor, "[ɳͿ]:#70|Ӱ֮δ!") + Func.sendmsg9(actor, "[沙巴克]:#70|影之道传送未开启!") return end end @@ -386,46 +381,46 @@ function ShabaKeOBJ:move(actor, p1, p2, p3, data) mapmove(actor, cfg.mapId, cfg.x, cfg.y, 3, 0) end ----* ǿʼʱ +---* 攻城开始时触发 function castlewarstart(sys) if not iskuafuserver() then Sys.addint(VarCfg.Global.int.CastleNum, 1) - sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":30}', "[ɳ֪ͨ]ɳͿ˹Ѿʼ!")) - sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":60}', "[ɳ֪ͨ]ɳͿ˹Ѿʼ!")) - sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":90}', "[ɳ֪ͨ]ɳͿ˹Ѿʼ!")) + sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":30}', "[攻沙通知]沙巴克攻城已经开始!")) + sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":60}', "[攻沙通知]沙巴克攻城已经开始!")) + sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":90}', "[攻沙通知]沙巴克攻城已经开始!")) end local player_list = getplayerlst(1) for _, actor in ipairs(player_list or {}) do - if not hastimerex(VarCfg.Timer["ɳʱ"]) then - setontimer(actor, VarCfg.Timer["ɳʱ"], 1) + if not hastimerex(VarCfg.Timer["攻沙定时器"]) then + setontimer(actor, VarCfg.Timer["攻沙定时器"], 1) end end end ----* ǽʱ +---* 攻城结束时触发 function castlewarend() - sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":30}', "[ɳ֪ͨ]ɳͿ˹Ѿ!")) - sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":60}', "[ɳ֪ͨ]ɳͿ˹Ѿ!")) - sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":90}', "[ɳ֪ͨ]ɳͿ˹Ѿ!")) + sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":30}', "[攻沙通知]沙巴克攻城已经结束!")) + sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":60}', "[攻沙通知]沙巴克攻城已经结束!")) + sendmsg(-1, 2, string.format('{"Msg":"%s","FColor":251,"BColor":0,"Type":5,"Y":90}', "[攻沙通知]沙巴克攻城已经结束!")) local player_list = getplayerlst(1) for _, actor in ipairs(player_list or {}) do - if hastimerex(VarCfg.Timer["ɳʱ"]) then - setofftimer(actor, VarCfg.Timer["ɳʱ"]) + if hastimerex(VarCfg.Timer["攻沙定时器"]) then + setofftimer(actor, VarCfg.Timer["攻沙定时器"]) end end end ---============================================================ ---- ¼ +--- 事件处理 ---============================================================ ----* ½ ɳͿڼʱ +---* 人物登陆 沙巴克期间计时 GameEvent.add(EventCfg.onLogin, function(actor) if ShabaKeOBJ.SBK._state() then - if not hastimerex(VarCfg.Timer["ɳʱ"]) then - setontimer(actor, VarCfg.Timer["ɳʱ"], 1) + if not hastimerex(VarCfg.Timer["攻沙定时器"]) then + setontimer(actor, VarCfg.Timer["攻沙定时器"], 1) end end end, ShabaKeOBJ)