|
只需要在shujian.lua 最上面加上require "supervisor"
查看/jiankan()
然后从新创建一个supervisor.lua 把下面所有内容都粘贴进去,就可以运行了,对新手可能没多大帮助,主要是lua爱好者有点用。方便查看mushs出错在哪里,便于自己整理。
-- supervisor.lua
local supervisor = {}
-- ==================== 全局模式定义 ====================
local failure_patterns = {
-- 通用失败模式
{pattern = "任务失败", type = "failure"},
{pattern = "失败", type = "failure"},
{pattern = "失误", type = "failure"},
{pattern = "搞砸", type = "failure"},
-- 放弃模式
{pattern = "任务放弃", type = "abandon"},
{pattern = "放弃", type = "abandon"},
{pattern = "任务拒绝", type = "abandon"},
{pattern = "路太远了", type = "abandon"},
{pattern = "太远了", type = "abandon"},
{pattern = "不接了", type = "abandon"},
{pattern = "不做了", type = "abandon"}
}
-- ==================== 任务显示名称映射 ====================
local TASK_DISPLAY_NAMES = {
["xueshan"] = "雪山任务",
["huashan"] = "华山任务",
["wudang"] = "武当任务",
["songxin"] = "送信任务",
["tdh"] = "天地会任务",
["changle"] = "长乐帮任务",
["hubiao"] = "护镖任务",
["dami"] = "大米任务",
["letter"] = "失落信笺",
["shenlong"] = "神龙任务",
["xuncheng"] = "巡城任务",
["gaibang"] = "丐帮任务",
["songshan"] = "嵩山任务",
["zhuoshe"] = "捉蛇任务",
["baoxiao"] = "报效国家",
["guanfu"] = "官府任务",
["lhsjob"] = "龙虎山任务",
["lksjob"] = "烂柯山任务",
["jgsjob"] = "九宫山任务",
["hsjob"] = "少林护送",
["zcjob"] = "做菜任务"
}
-- ==================== 任务状态配置表 ====================
local TASK_STATUS_CONFIG = {
-- 龙虎山任务配置
["龙虎山任务"] = {
stages = {
daofa_spell_complete = {
condition = function() return _G.job and _G.job.task_type == "daofa" and _G.flag and _G.flag.spell_complete end,
stage_name = "施法完成",
detail = function() return "已成功施展"..(_G.job.spell_name or "道法") end,
progress = 90,
risk = "低",
advice = "向天师复命"
},
daofa_casting = {
condition = function() return _G.job and _G.job.task_type == "daofa" end,
stage_name = "施法中",
detail = function() return "施展"..(_G.job.spell_name or "道法").."法术" end,
progress = 40,
risk = "中",
advice = "专注精神,控制法力"
},
zhaohun_success = {
condition = function() return _G.job and _G.job.task_type == "zhaohun" and _G.flag and _G.flag.soul_captured end,
stage_name = "招魂成功",
detail = "已成功招回魂魄",
progress = 85,
risk = "中",
advice = "小心魂魄反噬"
},
zhaohun_casting = {
condition = function() return _G.job and _G.job.task_type == "zhaohun" end,
stage_name = "招魂中",
detail = "正在进行招魂仪式",
progress = 35,
risk = "高",
advice = "准备符咒,防止恶灵"
},
default = {
condition = function() return true end,
stage_name = "接取任务",
detail = "向龙虎山天师领取任务",
progress = 10,
risk = "低",
advice = "准备好道法技能"
}
},
target_info = function()
return "任务类型: "..((_G.job and _G.job.task_type) or "未知")
end,
progress_details = function()
return {
"道法等级: "..((_G.job and _G.job.taoism_level) or "入门"),
"法力消耗: "..((_G.job and _G.job.mana_cost) or "0")
}
end
},
-- 烂柯山任务配置
["烂柯山任务"] = {
stages = {
chess_won = {
condition = function() return _G.flag and _G.flag.chess_won end,
stage_name = "对弈胜利",
detail = function() return "已赢得"..(_G.job.chess_type or "").."对弈" end,
progress = 95,
risk = "低",
advice = "领取对弈奖励"
},
chess_playing = {
condition = function() return _G.flag and _G.flag.chess_playing end,
stage_name = "对弈中",
detail = function() return "正在进行"..(_G.job.chess_type or "").."对弈" end,
progress = 50,
risk = "中",
advice = "专注思考,谨慎落子"
},
chess_prepare = {
condition = function() return _G.job and _G.job.chess_type end,
stage_name = "准备对弈",
detail = function() return "准备"..(_G.job.chess_type or "").."对弈" end,
progress = 20,
risk = "低",
advice = "研究棋谱,做好准备"
},
default = {
condition = function() return true end,
stage_name = "接取任务",
detail = "前往烂柯山接取对弈任务",
progress = 5,
risk = "低",
advice = "准备好棋艺技能"
}
},
target_info = function()
return _G.job and _G.job.chess_type and "棋类: ".._G.job.chess_type or "未知棋类"
end,
progress_details = function()
return {
"对弈状态: "..((_G.flag and _G.flag.chess_playing) and "进行中" or ((_G.flag and _G.flag.chess_won) and "胜利" or "准备")),
"棋局步数: "..((_G.job and _G.job.move_count) or "0")
}
end
},
-- 九宫山任务配置
["九宫山任务"] = {
stages = {
puzzle_solved = {
condition = function() return _G.flag and _G.flag.puzzle_solved end,
stage_name = "破解完成",
detail = "已成功破解九宫谜题",
progress = 90,
risk = "低",
advice = "领取谜题奖励"
},
puzzle_solving = {
condition = function() return _G.job and _G.job.puzzle_type end,
stage_name = "解谜中",
detail = function() return "破解"..(_G.job.puzzle_type or "").."类型谜题" end,
progress = 30,
risk = "中",
advice = "运用算术和逻辑推理"
},
default = {
condition = function() return true end,
stage_name = "准备解谜",
detail = "前往九宫山准备解谜",
progress = 10,
risk = "低",
advice = "准备好算术能力"
}
},
target_info = function()
return _G.job and _G.job.puzzle_type and "谜题类型: ".._G.job.puzzle_type or "未知谜题"
end,
progress_details = function()
return {
"解谜进度: "..((_G.job and _G.job.solve_progress) or "0%"),
"尝试次数: "..((_G.job and _G.job.attempt_count) or "0")
}
end
},
-- 少林护送配置
["少林护送"] = {
stages = {
escort_safe = {
condition = function() return _G.flag and _G.flag.escort_safe end,
stage_name = "护送完成",
detail = "已安全护送到目的地",
progress = 100,
risk = "低",
advice = "返回少林复命"
},
mob_attacking = {
condition = function() return _G.flag and _G.flag.mob_attacking end,
stage_name = "退敌中",
detail = "击退袭击的敌人",
progress = 60,
risk = "高",
advice = "使用少林武功保护目标"
},
escorting = {
condition = function() return _G.job and _G.job.protect_target end,
stage_name = "护送中",
detail = function() return "护送".._G.job.protect_target.."前往"..((_G.job and _G.job.destination) or "") end,
progress = 40,
risk = "中",
advice = "保持目标在视线范围内"
},
default = {
condition = function() return true end,
stage_name = "接取任务",
detail = "向少林领取护送任务",
progress = 10,
risk = "低",
advice = "准备好佛门武功"
}
},
target_info = function()
if _G.job and _G.job.protect_target then
local info = "护送目标: ".._G.job.protect_target
if _G.job.target_id then
info = info .. "(".._G.job.target_id..")"
end
return info
end
return "无目标"
end,
progress_details = function()
return {
"目标状态: "..((_G.flag and _G.flag.escort_safe) and "安全" or ((_G.flag and _G.flag.mob_attacking) and "危险" or "正常")),
"敌人数量: "..((_G.job and _G.job.enemy_count) or "未知")
}
end
},
-- 护镖任务配置
["护镖任务"] = {
stages = {
escort_complete = {
condition = function() return _G.flag and _G.flag.escort_complete end,
stage_name = "任务完成",
detail = "已安全护送镖车到达",
progress = 100,
risk = "低",
advice = "返回镖局领取报酬"
},
under_attack = {
condition = function() return _G.flag and _G.flag.under_attack end,
stage_name = "抵御劫匪",
detail = "正在抵御劫匪攻击",
progress = 50,
risk = "高",
advice = "保护镖车,击退劫匪"
},
escorting = {
condition = function() return _G.job and _G.job.carriage end,
stage_name = "护送中",
detail = function() return "护送镖车前往"..((_G.job and _G.job.destination) or "") end,
progress = 30,
risk = "中",
advice = "保持警惕,注意沿途安全"
},
default = {
condition = function() return true end,
stage_name = "接取任务",
detail = "向镖局领取护镖任务",
progress = 5,
risk = "低",
advice = "选择适合的护镖路线"
}
},
target_info = function()
return _G.job and _G.job.destination and "目的地: ".._G.job.destination or "未知目的地"
end,
progress_details = function()
return {
"镖车状态: "..((_G.flag and _G.flag.under_attack) and "被攻击" or "安全"),
"路程进度: "..((_G.job and _G.job.route_progress) or "0%")
}
end
},
-- 做菜任务配置
["做菜任务"] = {
stages = {
cooking = {
condition = function()
if _G.job and _G.job.ingredients then
local collected, total = 0, 0
for _, ingredient in pairs(_G.job.ingredients) do
total = total + 1
if ingredient.collected then collected = collected + 1 end
end
return collected == total and total > 0
end
return false
end,
stage_name = "烹饪中",
detail = "食材已齐,开始烹饪",
progress = 80,
risk = "低",
advice = "使用烹饪技能制作美食"
},
collecting = {
condition = function() return _G.job and _G.job.ingredients end,
stage_name = "收集食材",
detail = function()
local collected, total = 0, 0
for _, ingredient in pairs(_G.job.ingredients) do
total = total + 1
if ingredient.collected then collected = collected + 1 end
end
return "收集"..collected.."/"..total.."种食材"
end,
progress = function()
local collected, total = 0, 0
for _, ingredient in pairs(_G.job.ingredients) do
total = total + 1
if ingredient.collected then collected = collected + 1 end
end
return total > 0 and math.floor((collected / total) * 60) or 30
end,
risk = "低",
advice = "按照食谱寻找所需食材"
},
default = {
condition = function() return true end,
stage_name = "接取任务",
detail = "向洪七公学习做菜",
progress = 5,
risk = "低",
advice = "准备好后向洪七公请教"
}
},
target_info = function()
if _G.job and _G.job.ingredients then
local collected, total = 0, 0
for _, ingredient in pairs(_G.job.ingredients) do
total = total + 1
if ingredient.collected then collected = collected + 1 end
end
return "食材进度: "..collected.."/"..total
end
return "准备食材"
end,
progress_details = function()
return {
"任务类型: "..((_G.job and _G.job.dish_type) or "未知菜肴"),
"烹饪等级: "..((_G.job and _G.job.cooking_level) or "学习中")
}
end
}
}
-- ==================== 通用状态模式匹配 ====================
local COMMON_STAGE_PATTERNS = {
{pattern = "战斗中", progress = 60, risk = "高", advice = "使用武功击败目标"},
{pattern = "交手中", progress = 60, risk = "高", advice = "注意使用克制武功"},
{pattern = "寻找中", progress = 30, risk = "低", advice = "扩大搜索范围"},
{pattern = "搜索中", progress = 30, risk = "低", advice = "注意观察周围环境"},
{pattern = "已完成", progress = 90, risk = "低", advice = "返回复命"},
{pattern = "完成", progress = 90, risk = "低", advice = "领取奖励"},
{pattern = "接取任务", progress = 10, risk = "低", advice = "准备开始任务"},
{pattern = "前往", progress = 20, risk = "低", advice = "使用轻功加速移动"}
}
-- ==================== 辅助函数:生成进度条 ====================
function supervisor.generate_progress_bar(percentage, width)
width = width or 10
local bars = math.floor(percentage / 100 * width)
local spaces = width - bars
local bar = "[" .. string.rep("■", bars) .. string.rep("□", spaces) .. "]"
return string.format("%s %d%%", bar, percentage)
end
-- ==================== 辅助函数:计算预计时间 ====================
function supervisor.calculate_eta(progress)
if progress >= 80 then return "1分钟内"
elseif progress >= 60 then return "2-3分钟"
elseif progress >= 40 then return "3-5分钟"
elseif progress >= 20 then return "5-8分钟"
else return "8-10分钟"
end
end
-- ==================== 统一任务状态获取函数 ====================
function supervisor.get_unified_detailed_status(task_type)
local config = TASK_STATUS_CONFIG[task_type]
local status = {
task_name = task_type,
task_type = string.lower(string.gsub(task_type, "任务", "")),
current_stage = "进行中",
stage_detail = "",
progress = 20,
risk_level = "中",
advice = "按照任务流程执行",
target_info = "无目标信息",
eta = "未知",
progress_details = {}
}
-- 如果有配置,使用配置逻辑
if config then
for stage_name, stage_config in pairs(config.stages) do
if stage_config.condition and stage_config.condition() then
status.current_stage = stage_config.stage_name
status.stage_detail = type(stage_config.detail) == "function" and stage_config.detail() or stage_config.detail
status.progress = type(stage_config.progress) == "function" and stage_config.progress() or stage_config.progress
status.risk_level = stage_config.risk
status.advice = stage_config.advice
break
end
end
if config.target_info then
status.target_info = config.target_info()
end
if config.progress_details then
status.progress_details = config.progress_details()
end
else
-- 通用模式匹配
local state = supervisor.get_real_state()
for _, pattern in ipairs(COMMON_STAGE_PATTERNS) do
if string.find(state.location, pattern.pattern) then
status.current_stage = pattern.pattern
status.stage_detail = "正在" .. pattern.pattern
status.progress = pattern.progress
status.risk_level = pattern.risk
status.advice = pattern.advice
break
end
end
end
status.eta = supervisor.calculate_eta(status.progress)
return status
end
-- ==================== 保留特殊任务的独立函数 ====================
function supervisor.get_huashan_detailed_status()
local status = {}
status.task_name = "华山任务"
status.task_type = "huashan"
-- 基于实际的 huashan.lua 代码分析状态
if _G.job and _G.job.name == "huashan" then
-- 任务进行中
if _G.flag and _G.flag.jobmark then
local jobmark = _G.flag.jobmark
if jobmark == "hsnpcgo" then
if _G.hsjob2 and _G.hsjob2 == 1 then
status.current_stage = "第二次巡逻-寻找蒙面人"
status.stage_detail = "第二次巡逻:在松树林寻找抢走令牌的蒙面人"
status.progress = 60
else
status.current_stage = "第一次巡逻-寻找蒙面人"
status.stage_detail = "第一次巡逻:在松树林寻找抢走令牌的蒙面人"
status.progress = 20
end
status.risk_level = "低"
status.advice = "在松树林中搜索蒙面人"
elseif jobmark == "hsfindactgo" then
if _G.hsjob2 and _G.hsjob2 == 1 then
status.current_stage = "第二次巡逻-追击目标"
status.stage_detail = "第二次巡逻:追击蒙面人" .. (_G.job.target or "") .. "到" .. (_G.job.where or "")
status.progress = 70
else
status.current_stage = "第一次巡逻-追击目标"
status.stage_detail = "第一次巡逻:追击蒙面人" .. (_G.job.target or "") .. "到" .. (_G.job.where or "")
status.progress = 40
end
status.risk_level = "中"
status.advice = "快速前往目标地点"
elseif jobmark == "hsgetcorpse" then
if _G.hsjob2 and _G.hsjob2 == 1 then
status.current_stage = "第二次巡逻-处理尸体"
status.stage_detail = "第二次巡逻:处理" .. (_G.job.target or "") .. "的尸体"
status.progress = 80
else
status.current_stage = "第一次巡逻-处理尸体"
status.stage_detail = "第一次巡逻:处理" .. (_G.job.target or "") .. "的尸体"
status.progress = 60
end
status.risk_level = "低"
status.advice = "获取尸体并斩首"
elseif jobmark == "bkyls" then
if _G.hsjob2 and _G.hsjob2 == 1 then
status.current_stage = "第二次巡逻-返回祭坛"
status.stage_detail = "第二次巡逻:返回祭坛找岳灵珊画押令牌"
status.progress = 85
else
status.current_stage = "第一次巡逻-返回祭坛"
status.stage_detail = "第一次巡逻:返回祭坛找岳灵珊画押令牌"
status.progress = 70
end
status.risk_level = "低"
status.advice = "前往祭坛找岳灵珊"
elseif jobmark == "ylsback" then
status.current_stage = "任务完成"
status.stage_detail = "向岳不群复命领取奖励"
status.progress = 95
status.risk_level = "低"
status.advice = "ask yue about 完成"
elseif jobmark == "ylslbcx" then
status.current_stage = "准备第二次巡逻"
status.stage_detail = "向岳灵珊询问力不从心,开始第二次巡逻"
status.progress = 50
status.risk_level = "低"
status.advice = "ask yue lingshan about 力不从心"
else
if _G.hsjob2 and _G.hsjob2 == 1 then
status.current_stage = "第二次巡逻中"
status.stage_detail = "执行第二次华山巡逻任务"
status.progress = 55
else
status.current_stage = "第一次巡逻中"
status.stage_detail = "执行第一次华山巡逻任务"
status.progress = 30
end
status.risk_level = "中"
status.advice = "按照任务流程执行"
end
else
-- 战斗状态
if _G.flag and _G.flag.find and _G.flag.find == 1 then
if _G.hsjob2 and _G.hsjob2 == 1 then
status.current_stage = "第二次巡逻-战斗中"
status.stage_detail = "第二次巡逻:与" .. (_G.job.target or "目标") .. "交战中"
status.progress = 75
else
status.current_stage = "第一次巡逻-战斗中"
status.stage_detail = "第一次巡逻:与" .. (_G.job.target or "目标") .. "交战中"
status.progress = 50
end
status.risk_level = "高"
status.advice = "使用武功击败目标"
else
if _G.hsjob2 and _G.hsjob2 == 1 then
status.current_stage = "第二次巡逻中"
status.stage_detail = "执行第二次华山巡逻任务"
status.progress = 55
else
status.current_stage = "第一次巡逻中"
status.stage_detail = "执行第一次华山巡逻任务"
status.progress = 30
end
status.risk_level = "中"
status.advice = "保持警惕,注意安全"
end
end
-- 如果有目标信息
if _G.job.target and _G.job.target ~= "任务目标" then
status.target_info = "目标: " .. _G.job.target
end
-- 如果有位置信息
if _G.job.where then
status.target_info = (status.target_info or "") .. " 位置: " .. _G.job.where
end
-- 令牌状态显示
if _G.hsjob2 and _G.hsjob2 == 1 then
status.target_info = (status.target_info or "") .. " (令牌: 第二次巡逻)"
else
status.target_info = (status.target_info or "") .. " (令牌: 第一次巡逻)"
end
else
-- 默认状态 - 接取任务
status.current_stage = "接取任务"
status.stage_detail = "向岳不群领取巡逻任务"
status.progress = 10
status.risk_level = "低"
status.advice = "ask yue buqun about job"
end
-- 搜索次数信息
if _G.job and _G.job.lost and _G.job.lost > 0 then
status.progress_details = {
"搜索次数: " .. _G.job.lost,
"巡逻轮次: " .. ((_G.hsjob2 and _G.hsjob2 == 1) and "第二次" or "第一次")
}
else
status.progress_details = {
"任务阶段: " .. (status.current_stage or "准备中"),
"巡逻轮次: " .. ((_G.hsjob2 and _G.hsjob2 == 1) and "第二次" or "第一次")
}
end
-- 确保有状态字段
status.status = status.current_stage or "进行中"
status.eta = supervisor.calculate_eta(status.progress)
return status
end
function supervisor.get_wudang_detailed_status()
local status = {}
status.task_name = "武当惩恶扬善"
status.task_type = "wudang"
if _G.flag and _G.flag.robber then
status.current_stage = "战斗中"
status.stage_detail = "与"..((_G.job and _G.job.target) or "恶贼").."交手中"
status.progress = 70
status.risk_level = "高"
status.advice = "注意使用克制武功,准备恢复药品"
elseif _G.wdsearch_get == 1 then
status.current_stage = "已发现目标"
status.stage_detail = "已找到"..((_G.job and _G.job.target) or "目标")..",准备战斗"
status.progress = 50
status.risk_level = "中"
status.advice = "确认目标后立即开始战斗"
elseif _G.job and _G.job.lost and _G.job.lost > 0 then
status.current_stage = "搜索中"
status.stage_detail = "第".._G.job.lost.."次搜索"..((_G.job and _G.job.where) or "目标区域")
status.progress = 30 + (_G.job.lost * 5)
status.risk_level = "低"
status.advice = "扩大搜索范围,注意观察周围环境"
else
status.current_stage = "前往目标"
status.stage_detail = "正在前往"..((_G.job and _G.job.where) or "任务地点")
status.progress = 20
status.risk_level = "低"
status.advice = "使用轻功加速移动"
end
if _G.job and _G.job.target then
status.target_info = _G.job.target
if _G.job.id then
status.target_info = status.target_info .. "(".._G.job.id..")"
end
if _G.wudang_npc_party then
status.target_info = status.target_info .. " - ".._G.wudang_npc_party
end
end
if _G.sxjob and _G.sxjob.skills then
status.skill_info = "使用".._G.sxjob.skills
end
if _G.job and _G.job.level then
status.difficulty = "难度: ".._G.job.level
end
status.eta = supervisor.calculate_eta(status.progress)
status.progress_details = {
"搜索次数: "..((_G.job and _G.job.lost) or 0).."/3",
"目标状态: "..(_G.wdsearch_get == 1 and "已发现" or "寻找中")
}
return status
end
function supervisor.get_xueshan_detailed_status()
local status = {}
status.task_name = "雪山抢美女"
status.task_type = "xueshan"
if _G.tmp and _G.tmp.kill then
status.current_stage = "抢美女中"
status.stage_detail = "已击败保镖,正在抢走美女"
status.progress = 80
status.risk_level = "中"
status.advice = "使用'sa beauty'命令抢走美女"
elseif _G.guard_id and _G.job and _G.job.target then
status.current_stage = "战斗中"
status.stage_detail = "与保镖"..(_G.gdcname or _G.job.target).."交手中"
status.progress = 60
status.risk_level = "高"
status.advice = "优先击败保镖,注意自身气血"
elseif _G.flag and _G.flag.wait == 1 then
status.current_stage = "已发现目标"
status.stage_detail = "已找到美女,正在评估保镖"
status.progress = 40
status.risk_level = "中"
status.advice = "查看保镖信息,准备战斗"
elseif _G.job and _G.job.lost and _G.job.lost > 0 then
status.current_stage = "寻找美女"
status.stage_detail = "第".._G.job.lost.."次寻找美女"
status.progress = 20 + (_G.job.lost * 10)
status.risk_level = "低"
status.advice = "在"..((_G.job and _G.job.where) or "目标区域").."寻找美女"
else
status.current_stage = "前往地点"
status.stage_detail = "前往"..((_G.job and _G.job.where) or "任务地点")
status.progress = 10
status.risk_level = "低"
status.advice = "快速到达目标地点"
end
if _G.gdcname then
status.target_info = "保镖: ".._G.gdcname
if _G.guard_id then
status.target_info = status.target_info .. "(".._G.guard_id..")"
end
elseif _G.job and _G.job.where then
status.target_info = "美女在: ".._G.job.where
end
status.eta = supervisor.calculate_eta(status.progress)
status.progress_details = {
"寻找次数: "..((_G.job and _G.job.lost) or 0).."/5",
"保镖状态: "..((_G.tmp and _G.tmp.kill) and "已击败" or (_G.guard_id and "战斗中" or "未发现"))
}
return status
end
function supervisor.get_guanfu_detailed_status()
local status = {}
status.task_name = "官府追捕"
status.task_type = "guanfu"
if _G.job and _G.job.criminal then
if _G.flag and _G.flag.criminal_caught then
status.current_stage = "押送犯人"
status.stage_detail = "已捕获".._G.job.criminal..",正在押送"
status.progress = 80
status.risk_level = "中"
status.advice = "小心犯人同伙劫囚"
else
status.current_stage = "追捕中"
status.stage_detail = "追捕逃犯".._G.job.criminal.."在"..((_G.job and _G.job.where) or "")
status.progress = 40
status.risk_level = "高"
status.advice = "使用官府武功制服逃犯"
end
status.target_info = "逃犯: ".._G.job.criminal
if _G.job.id then
status.target_info = status.target_info .. "(".._G.job.id..")"
end
if _G.wanted_level then
status.difficulty = "通缉等级: ".._G.wanted_level
end
else
status.current_stage = "接取通缉"
status.stage_detail = "向官府领取通缉任务"
status.progress = 10
status.risk_level = "低"
status.advice = "查看通缉令选择任务"
end
status.eta = supervisor.calculate_eta(status.progress)
status.progress_details = {
"追捕状态: "..((_G.flag and _G.flag.criminal_caught) and "已捕获" or "追捕中"),
"危险程度: "..(_G.wanted_level or "未知")
}
return status
end
function supervisor.get_songxin_detailed_status()
local status = {}
status.task_name = "大理送信"
status.task_type = "songxin"
if _G.letter_to and _G.letter_where then
if _G.flag and _G.flag.songxin_delivered then
status.current_stage = "完成送信"
status.stage_detail = "已送信给".._G.letter_to
status.progress = 90
status.risk_level = "低"
status.advice = "送信完成"
else
status.current_stage = "寻找收信人"
status.stage_detail = "在".._G.letter_where.."寻找".._G.letter_to
status.progress = 40
status.risk_level = "低"
status.advice = "使用询问命令找到收信人"
end
status.target_info = "收信人: ".._G.letter_to.." (".._G.letter_where..")"
else
status.current_stage = "接取任务"
status.stage_detail = "领取送信任务"
status.progress = 10
status.risk_level = "低"
status.advice = "准备好后询问送信"
end
status.eta = supervisor.calculate_eta(status.progress)
status.progress_details = {
"送信状态: "..((_G.flag and _G.flag.songxin_delivered) and "已完成" or "进行中"),
"目标地点: "..(_G.letter_where or "未知")
}
return status
end
-- ==================== 任务状态详细查询 ====================
function supervisor.get_detailed_task_status()
local current_task = supervisor.get_current_task_name()
local state = supervisor.get_real_state()
-- 基础任务信息
local task_info = {
name = current_task,
status = "未知",
progress = 0,
target = "无",
location = state.location,
detail = "",
estimated_time = "未知",
risk_level = "低",
suggestions = {}
}
-- 根据当前任务名称获取详细状态
local detailed_status
if current_task == "华山任务" then
detailed_status = supervisor.get_huashan_detailed_status()
elseif current_task == "官府任务" then
detailed_status = supervisor.get_guanfu_detailed_status()
elseif current_task == "护镖任务" then
detailed_status = supervisor.get_hubiao_detailed_status()
elseif current_task == "少林护送" then
detailed_status = supervisor.get_husong_detailed_status()
elseif current_task == "做菜任务" then
detailed_status = supervisor.get_hqgzc_detailed_status()
elseif current_task == "九宫山任务" then
detailed_status = supervisor.get_jiugongshan_detailed_status()
elseif current_task == "烂柯山任务" then
detailed_status = supervisor.get_lankeshan_detailed_status()
elseif current_task == "龙虎山任务" then
detailed_status = supervisor.get_lhsjob_detailed_status()
elseif current_task == "送信任务" then
detailed_status = supervisor.get_songxin_detailed_status()
elseif current_task == "武当任务" then
detailed_status = supervisor.get_wudang_detailed_status()
elseif current_task == "雪山任务" then
detailed_status = supervisor.get_xueshan_detailed_status()
else
-- 使用统一状态获取
detailed_status = supervisor.get_unified_detailed_status(current_task)
end
-- 确保返回的表有所有必需的字段
return {
name = detailed_status.name or current_task or "未知任务",
status = detailed_status.status or detailed_status.current_stage or task_info.status,
progress = detailed_status.progress or task_info.progress,
target = detailed_status.target or detailed_status.target_info or task_info.target,
location = detailed_status.location or state.location,
detail = detailed_status.stage_detail or detailed_status.detail or task_info.detail,
estimated_time = detailed_status.eta or detailed_status.estimated_time or task_info.estimated_time,
risk_level = detailed_status.risk_level or task_info.risk_level,
suggestions = detailed_status.advice and {detailed_status.advice} or detailed_status.suggestions or task_info.suggestions
}
end
-- ==================== 错误诊断对象结构 ====================
local error_diagnosis = {
idle_detection = {
last_action_time = os.time(),
last_location = "",
idle_count = 0,
idle_reasons = {},
last_failure_task = nil,
last_abandon_task = nil,
last_abandon_time = 0,
last_abandon_reason = ""
},
command_errors = {
recent_commands = {},
failed_commands = {},
pathfinding_errors = {}
},
script_errors = {
syntax_errors = {},
logic_errors = {},
timeout_errors = {},
current_task_start = nil,
current_task_name = nil
},
-- 增强死亡检测
death_detection = {
death_count = 0,
last_death_time = 0,
last_death_reason = "",
last_death_analysis = nil,
death_locations = {},
total_deaths = 0
}
}
-- ==================== 任务数据统计结构 ====================
local task_statistics = {
today = {
total_tasks = 0,
completed_tasks = 0,
failed_tasks = 0,
abandoned_tasks = 0,
total_time = 0,
total_exp = 0,
tasks_completed = {},
start_time = os.time(),
start_exp = 0,
-- 按任务类型统计
task_type_stats = {
-- 主体任务(主要经验来源)
["送信任务"] = {success = 0, failure = 0, abandon = 0},
["华山任务"] = {success = 0, failure = 0, abandon = 0},
["武当任务"] = {success = 0, failure = 0, abandon = 0},
["雪山任务"] = {success = 0, failure = 0, abandon = 0},
["天地会任务"] = {success = 0, failure = 0, abandon = 0},
["护镖任务"] = {success = 0, failure = 0, abandon = 0},
["官府任务"] = {success = 0, failure = 0, abandon = 0},
["报效国家"] = {success = 0, failure = 0, abandon = 0},
-- 每日任务(有限制次数)
["失落信笺"] = {success = 0, failure = 0, abandon = 0},
["捉蛇任务"] = {success = 0, failure = 0, abandon = 0},
-- 新手任务(初期)
["巡城任务"] = {success = 0, failure = 0, abandon = 0},
["丐帮任务"] = {success = 0, failure = 0, abandon = 0},
["嵩山任务"] = {success = 0, failure = 0, abandon = 0},
-- 辅助任务(较少做)
["长乐帮任务"] = {success = 0, failure = 0, abandon = 0},
["大米任务"] = {success = 0, failure = 0, abandon = 0},
["神龙任务"] = {success = 0, failure = 0, abandon = 0},
-- 特殊奖励任务(非经验奖励)
["龙虎山任务"] = {success = 0, failure = 0, abandon = 0},
["烂柯山任务"] = {success = 0, failure = 0, abandon = 0},
["做菜任务"] = {success = 0, failure = 0, abandon = 0}
}
},
history = {},
current_task = nil
}
-- ==================== 修复任务完成记录函数 ====================
function supervisor.record_task_completion_by_function(func_name, w)
local task_name = supervisor.get_current_task_name()
local exp = 0
local pot = 0
local gold = 0
-- 根据函数名和参数解析经验潜能
if func_name == "job_exp_tdh" then
task_name = "天地会任务"
exp = tonumber(w[2]) or 0
pot = tonumber(w[3]) or 0
elseif func_name == "jobExpExtra" then
task_name = "额外奖励"
exp = tonumber(w[2]) or 0
elseif func_name == "job_exp_xueshan" then
task_name = "雪山任务"
exp = tonumber(w[2]) or 0
pot = tonumber(w[3]) or 0
elseif func_name == "job_exp_wudang" then
task_name = "武当任务"
exp = tonumber(w[2]) or 0
pot = tonumber(w[3]) or 0
elseif func_name == "job_exp_huashan" then
task_name = "华山任务"
exp = tonumber(w[2]) or 0
pot = tonumber(w[3]) or 0
elseif func_name == "job_exp_dolost" then
task_name = "失落信笺"
exp = tonumber(w[3]) or 0
pot = tonumber(w[4]) or 0
elseif func_name == "job_exp_songxin" then
task_name = "送信任务"
exp = tonumber(w[2]) or 0
pot = tonumber(w[3]) or 0
elseif func_name == "job_exp_guanfu" then
task_name = "官府任务"
gold = tonumber(w[2]) or 0
pot = tonumber(w[3]) or 0
exp = tonumber(w[5]) or 0
elseif func_name == "job_exp_gb" then
if _G.job and _G.job.name == "gaibang" then
task_name = "丐帮任务"
else
task_name = "嵩山任务"
end
exp = tonumber(w[2]) or 0
pot = tonumber(w[1]) or 0
elseif func_name == "job_exp_gblu" then
task_name = "报效国家"
exp = tonumber(w[1]) or 0
pot = tonumber(w[2]) or 0
elseif func_name == "job_exp_shenlong" then
task_name = "神龙任务"
exp = tonumber(w[1]) or 0
pot = tonumber(w[2]) or 0
elseif func_name == "job_exp_xuncheng" then
task_name = "巡城任务"
exp = tonumber(w[2]) or 0
pot = tonumber(w[3]) or 0
elseif func_name == "job_exp_clb" then
task_name = "长乐帮任务"
exp = tonumber(w[1]) or 0
pot = tonumber(w[2]) or 0
elseif func_name == "job_exp_hubiao" then
task_name = "护镖任务"
exp = tonumber(w[1]) or 0
pot = tonumber(w[2]) or 0
gold = tonumber(w[3]) or 0
else
task_name = task_name or "未知任务"
for i = 1, #w do
local num = tonumber(w[i])
if num then
if exp == 0 then exp = num
elseif pot == 0 then pot = num
elseif gold == 0 then gold = num end
end
end
end
if task_name ~= "" and task_name ~= "无任务执行" then
supervisor.record_task_completion(task_name, exp, pot, gold)
end
end
-- ==================== 直接监控 job.lua 奖励函数 ====================
function supervisor.setup_job_reward_monitor()
supervisor.original_job_functions = {}
local reward_functions = {
"job_exp_tdh", "jobExpExtra", "job_exp_dummy", "job_exp_xueshan",
"job_exp_wudang", "job_exp_huashan", "job_exp_dolost", "job_rep_dolost",
"job_exp_shenlong", "job_exp_songxin", "job_exp_xuncheng", "job_exp_gb",
"job_exp_zs", "job_exp_gblu", "job_exp_guanfu", "job_exp_clb", "job_exp_hubiao"
}
for _, func_name in ipairs(reward_functions) do
if _G[func_name] then
supervisor.original_job_functions[func_name] = _G[func_name]
_G[func_name] = function(n, l, w)
local result = supervisor.original_job_functions[func_name](n, l, w)
supervisor.record_task_completion_by_function(func_name, w)
return result
end
end
end
local failure_functions = {"job_gblu_fail", "jobtdhfail"}
for _, func_name in ipairs(failure_functions) do
if _G[func_name] then
supervisor.original_job_functions[func_name] = _G[func_name]
_G[func_name] = function(n, l, w)
local result = supervisor.original_job_functions[func_name](n, l, w)
supervisor.record_task_failure_by_function(func_name, w)
return result
end
end
end
ColourNote("yellow", "", "监控系统: 已挂接 job.lua 奖励监控")
end
-- ==================== 增强失败监控 ====================
function supervisor.setup_job_failure_monitor()
_G.original_print = _G.original_print or print
_G.print = function(...)
local args = {...}
local text = table.concat(args, " ")
for _, pattern_info in ipairs(failure_patterns) do
if string.find(text, pattern_info.pattern) then
local task_name = supervisor.get_current_task_name()
if pattern_info.type == "failure" then
supervisor.record_task_failure(task_name, text)
else
supervisor.record_task_abandon(task_name, text)
end
break
end
end
return _G.original_print(...)
end
end
-- ==================== 死亡检测函数 ====================
function supervisor.setup_death_detection()
local death_patterns = {
"你死了", "你被杀死", "你重伤昏迷", "你眼前一黑", "你败了",
"你被击中死穴", "你精血亏损", "你受伤过重", "你已经陷入半昏迷状态",
"你被活活砍死", "你被活活打死", "你被毒发身亡", "你力尽而亡"
}
supervisor.update_death_count_from_score()
_G.original_print = _G.original_print or print
_G.print = function(...)
local args = {...}
local text = table.concat(args, " ")
local death_detected = false
local death_reason = ""
for _, pattern in ipairs(death_patterns) do
if string.find(text, pattern) then
death_detected = true
death_reason = text
break
end
end
if death_detected then
supervisor.update_death_count_from_score()
if error_diagnosis.death_detection.total_deaths > error_diagnosis.death_detection.death_count then
supervisor.record_death(death_reason)
end
end
for _, pattern_info in ipairs(failure_patterns) do
if string.find(text, pattern_info.pattern) then
local task_name = supervisor.get_current_task_name()
if pattern_info.type == "failure" then
supervisor.record_task_failure(task_name, text)
else
supervisor.record_task_abandon(task_name, text)
end
break
end
end
return _G.original_print(...)
end
end
-- 从游戏数据获取死亡次数
function supervisor.update_death_count_from_score()
if _G.score and _G.score.swcs then
local current_deaths = tonumber(_G.score.swcs) or 0
error_diagnosis.death_detection.total_deaths = current_deaths
if current_deaths > error_diagnosis.death_detection.death_count then
error_diagnosis.death_detection.death_count = current_deaths
end
end
end
-- 分析死亡原因并提供具体建议
function supervisor.analyze_death_reason(death_reason, location)
local analysis = {
reason = "",
cause = "",
suggestion = ""
}
if string.find(death_reason, "饿死") or string.find(death_reason, "渴死") or
string.find(death_reason, "饥渴") then
analysis.reason = "饥饿口渴死亡"
analysis.cause = "自动吃喝系统失效"
analysis.suggestion = "检查脚本,确保饥饿度/口渴度检测准确,设置合理的吃喝阈值"
elseif string.find(death_reason, "中毒") or string.find(death_reason, "毒发") then
analysis.reason = "中毒身亡"
analysis.cause = "中毒检测或治疗不及时"
analysis.suggestion = "检查脚本,确保中毒状态检测准确,设置自动治疗条件"
elseif string.find(death_reason, "精血亏损") or string.find(death_reason, "气血") then
analysis.reason = "气血耗尽"
analysis.cause = "血量监控失效或恢复不及时"
analysis.suggestion = "检查脚本,设置合理的恢复阈值,确保打坐/吃药触发正常"
elseif string.find(death_reason, "昏迷") and string.find(death_reason, "打死") then
analysis.reason = "昏迷后被击杀"
analysis.cause = "昏迷状态检测不准确或恢复机制失效"
analysis.suggestion = "检查脚本,设置自动恢复或逃跑机制"
elseif string.find(death_reason, "武器被打掉") or string.find(death_reason, " disarm") then
analysis.reason = "武器被打落后死亡"
analysis.cause = "武器丢失检测和重新装备机制失效"
analysis.suggestion = "检查脚本的武器状态监控,添加武器丢失后的自动重装备逻辑"
elseif string.find(death_reason, "路径") or string.find(death_reason, "迷路") or
string.find(death_reason, "卡住") then
analysis.reason = "路径错误导致死亡"
analysis.cause = "路径寻找算法出错或地图数据不准确"
analysis.suggestion = "检查脚本,更新地图数据,添加路径错误恢复机制"
elseif string.find(death_reason, "被土匪") or string.find(death_reason, "被强盗") or
string.find(death_reason, "被(.+)杀死") then
local state = supervisor.get_real_state()
if state.hp < 20 then
analysis.reason = "低血量战斗死亡"
analysis.cause = "血量过低时仍继续战斗"
analysis.suggestion = "检查脚本的血量安全阈值,设置低血量自动逃跑或恢复"
else
analysis.reason = "战斗能力不足死亡"
analysis.cause = "武功等级或装备不足以应对当前敌人"
analysis.suggestion = "检查脚本,确保只挑战能力范围内的敌人,调整任务难度"
end
elseif string.find(death_reason, "内力耗尽") or string.find(death_reason, "真气不足") then
analysis.reason = "内力耗尽死亡"
analysis.cause = "内力监控或恢复机制失效"
analysis.suggestion = "检查脚本,设置合理的内力恢复阈值,确保打坐触发"
else
analysis.reason = "战斗系统异常"
analysis.cause = "战斗脚本逻辑错误或状态检测失效"
analysis.suggestion = "全面检查脚本,确保状态检测、技能使用、逃跑机制都正常工作"
end
local current_state = supervisor.get_real_state()
if analysis.cause == "自动吃喝系统失效" then
if _G.eat_drink and _G.eat_drink.enabled == false then
analysis.cause = analysis.cause .. " (吃喝功能被禁用)"
analysis.suggestion = analysis.suggestion .. ",请启用自动吃喝功能"
end
end
if analysis.cause == "血量监控失效或恢复不及时" then
if current_state.hp < 30 then
analysis.cause = analysis.cause .. " (死亡时血量" .. current_state.hp .. "%)"
analysis.suggestion = analysis.suggestion .. ",将恢复阈值提高到40%以上"
end
end
return analysis
end
-- 记录死亡
function supervisor.record_death(reason)
local current_time = os.time()
local location = supervisor.get_real_state().location
if current_time - error_diagnosis.death_detection.last_death_time < 30 then
return
end
local death_count = error_diagnosis.death_detection.total_deaths
local death_analysis = supervisor.analyze_death_reason(reason, location)
error_diagnosis.death_detection.last_death_time = current_time
error_diagnosis.death_detection.last_death_reason = reason
error_diagnosis.death_detection.last_death_analysis = death_analysis
table.insert(error_diagnosis.death_detection.death_locations, {
time = os.date("%H:%M:%S"),
location = location,
reason = reason,
analysis = death_analysis
})
ColourNote("red", "", "═" .. string.rep("═", 50) .. "═")
ColourNote("red", "", "║ 死亡分析报告 ║")
ColourNote("red", "", "═" .. string.rep("═", 50) .. "═")
ColourNote("red", "", "死亡次数: 第" .. death_count .. "次死亡")
ColourNote("orange", "", "死亡原因: " .. death_analysis.reason)
ColourNote("orange", "", "根本原因: " .. death_analysis.cause)
ColourNote("yellow", "", "脚本建议: " .. death_analysis.suggestion)
ColourNote("white", "", "死亡位置: " .. location)
ColourNote("white", "", "死亡时间: " .. os.date("%H:%M:%S"))
ColourNote("red", "", "═" .. string.rep("═", 50) .. "═")
supervisor.update_display_in_realtime()
end
-- 提取简短的死亡原因
function supervisor.extract_short_death_reason(full_reason)
local reason_patterns = {
{"被(.+)杀死", "被%1"},
{"被(.+)砍死", "被%1砍死"},
{"被(.+)打死", "被%1打死"},
{"中毒身亡", "毒发身亡"},
{"精血亏损", "精血亏损"},
{"重伤昏迷", "重伤昏迷"},
{"力尽而亡", "力尽而亡"},
{"陷入半昏迷", "重伤昏迷"}
}
for _, pattern_info in ipairs(reason_patterns) do
local pattern, replacement = pattern_info[1], pattern_info[2]
local short_reason = string.match(full_reason, pattern)
if short_reason then
return string.gsub(short_reason, pattern, replacement)
end
end
if string.len(full_reason) > 20 then
return string.sub(full_reason, 1, 20) .. "..."
else
return full_reason
end
end
-- ==================== 通用任务失败记录 ====================
function supervisor.record_task_failure(task_name, reason)
if not error_diagnosis.idle_detection.last_failure_task or
error_diagnosis.idle_detection.last_failure_task ~= task_name then
task_statistics.today.failed_tasks = task_statistics.today.failed_tasks + 1
task_statistics.today.total_tasks = task_statistics.today.total_tasks + 1
if task_statistics.today.task_type_stats[task_name] then
task_statistics.today.task_type_stats[task_name].failure =
task_statistics.today.task_type_stats[task_name].failure + 1
end
ColourNote("red", "", string.format("任务失败: %s, 原因: %s, 今日第%d个失败任务",
task_name, reason or "未知", task_statistics.today.failed_tasks))
error_diagnosis.idle_detection.last_failure_task = task_name
supervisor.update_display_in_realtime()
end
end
function supervisor.record_task_abandon(task_name, reason)
local current_time = os.time()
if error_diagnosis.idle_detection.last_abandon_task == task_name and
current_time - error_diagnosis.idle_detection.last_abandon_time < 300 then
return
end
task_statistics.today.abandoned_tasks = task_statistics.today.abandoned_tasks + 1
task_statistics.today.total_tasks = task_statistics.today.total_tasks + 1
if not task_statistics.today.task_type_stats[task_name] then
task_statistics.today.task_type_stats[task_name] = {success = 0, failure = 0, abandon = 0}
end
task_statistics.today.task_type_stats[task_name].abandon =
(task_statistics.today.task_type_stats[task_name].abandon or 0) + 1
ColourNote("orange", "", string.format("任务放弃: %s, 原因: %s, 今日第%d个放弃任务",
task_name, reason or "未知", task_statistics.today.abandoned_tasks))
error_diagnosis.idle_detection.last_abandon_task = task_name
error_diagnosis.idle_detection.last_abandon_time = current_time
error_diagnosis.idle_detection.last_abandon_reason = reason
supervisor.update_display_in_realtime()
end
-- ==================== 记录任务失败 ====================
function supervisor.record_task_failure_by_function(func_name, w)
local task_name = supervisor.get_current_task_name() or "未知任务"
task_statistics.today.failed_tasks = task_statistics.today.failed_tasks + 1
task_statistics.today.total_tasks = task_statistics.today.total_tasks + 1
if task_statistics.today.task_type_stats[task_name] then
task_statistics.today.task_type_stats[task_name].failure = task_statistics.today.task_type_stats[task_name].failure + 1
end
ColourNote("red", "", string.format("任务失败: %s, 今日第%d个失败任务", task_name, task_statistics.today.failed_tasks))
supervisor.update_display_in_realtime()
end
-- ==================== 记录任务完成 ====================
function supervisor.record_task_completion(task_name, exp, pot, gold)
if _G.job and _G.job.finish then
task_statistics.today.completed_tasks = _G.job.finish
task_statistics.today.total_tasks = _G.job.finish
else
task_statistics.today.completed_tasks = task_statistics.today.completed_tasks + 1
task_statistics.today.total_tasks = task_statistics.today.total_tasks + 1
end
if _G.job and _G.job.expGain then
task_statistics.today.total_exp = _G.job.expGain
else
task_statistics.today.total_exp = task_statistics.today.total_exp + exp
end
if task_statistics.today.task_type_stats[task_name] then
task_statistics.today.task_type_stats[task_name].success = task_statistics.today.task_type_stats[task_name].success + 1
end
ColourNote("green", "", string.format("任务完成: %s, 经验+%d, 潜能+%d, 今日第%d个任务",
task_name, exp, pot, task_statistics.today.completed_tasks))
supervisor.update_display_in_realtime()
end
-- ==================== 实时更新显示 ====================
function supervisor.update_display_in_realtime()
-- 实时更新逻辑
end
-- ==================== 发呆检测系统 ====================
function supervisor.detect_idle_status()
local current_time = os.time()
local current_location = supervisor.get_real_state().location
local idle_time = current_time - error_diagnosis.idle_detection.last_action_time
if error_diagnosis.idle_detection.last_action_time > current_time then
error_diagnosis.idle_detection.last_action_time = current_time
return false, {}
end
local is_normal_busy = false
if _G.condition and _G.condition.busy and _G.condition.busy > 0 then
is_normal_busy = true
end
if _G.job and _G.job.name and _G.job.name ~= "none" and _G.job.name ~= "idle" then
is_normal_busy = true
end
if is_normal_busy then
error_diagnosis.idle_detection.last_action_time = current_time
return false, {}
end
if idle_time > 120 then
local reasons = supervisor.analyze_idle_reasons(current_location, idle_time)
error_diagnosis.idle_detection.idle_reasons = reasons
error_diagnosis.idle_detection.idle_count = error_diagnosis.idle_detection.idle_count + 1
return true, reasons
end
if current_location ~= error_diagnosis.idle_detection.last_location then
error_diagnosis.idle_detection.last_action_time = current_time
error_diagnosis.idle_detection.last_location = current_location
end
return false, {}
end
function supervisor.analyze_idle_reasons(location, idle_time)
local reasons = {}
if _G.job and _G.job.stage then
local stage = _G.job.stage
if stage == "ask" and idle_time > 60 then
table.insert(reasons, "任务询问阶段卡住")
elseif stage == "moving" and idle_time > 120 then
table.insert(reasons, "路径寻找失败")
elseif stage == "fighting" and idle_time > 90 then
table.insert(reasons, "战斗状态异常")
end
end
if _G.hp then
if _G.hp.qixue_per and _G.hp.qixue_per < 10 then
table.insert(reasons, "气血过低导致无法行动")
end
if _G.hp.jingli and _G.hp.jingli < 10 then
table.insert(reasons, "精力耗尽无法移动")
end
if _G.hp.neili and _G.hp.neili < 5 then
table.insert(reasons, "内力不足无法使用轻功")
end
end
if string.find(location, "客栈") or string.find(location, "酒店") then
table.insert(reasons, "可能在客栈休息但未设置自动恢复")
end
if string.find(location, "当铺") or string.find(location, "钱庄") then
table.insert(reasons, "可能在处理物品但逻辑卡住")
end
if #reasons == 0 then
table.insert(reasons, "脚本可能等待特定条件或触发器失效")
end
return reasons
end
-- ==================== 发呆监控循环 ====================
function supervisor.safe_idle_monitor_loop()
if supervisor and supervisor.detect_idle_status then
local is_idle, reasons = supervisor.detect_idle_status()
if is_idle and #reasons > 0 then
ColourNote("orange", "", "发呆警告: 已停滞" .. math.floor((os.time() - error_diagnosis.idle_detection.last_action_time)/60) .. "分钟")
ColourNote("orange", "", "可能原因: " .. table.concat(reasons, ", "))
end
DoAfterSpecial(30, "supervisor.safe_idle_monitor_loop()", 12)
else
ColourNote("red", "", "监控系统: idle_monitor_loop 初始化失败")
end
end
-- ==================== 基础数据函数 ====================
function supervisor.get_real_account_info()
local name = "未知账号"
local id = "未知ID"
if _G.score then
if _G.score.name and _G.score.name ~= "无名" then
name = _G.score.name
end
if _G.score.id and _G.score.id ~= "无名" then
id = _G.score.id
end
end
if _G.hp and _G.hp.name and _G.hp.name ~= "无名" then
name = _G.hp.name
end
if _G.myAccount and _G.myAccount ~= "unknown" then
name = _G.myAccount
end
if _G.Account and _G.Account ~= "unknown" then
name = _G.Account
end
if name and string.find(name, "%(") and string.find(name, "%)") then
local name_part, id_part = string.match(name, "(.+)%((.+)%)")
if name_part and id_part then
name = name_part
id = id_part
end
end
if id == "未知ID" then
if _G.myID and _G.myID ~= "unknown" then
id = _G.myID
elseif _G.g_id then
id = tostring(_G.g_id)
else
id = os.date("%m%d%H%M")
end
end
return name, id
end
-- 在文件开头添加全局变量
local last_abandon_check = {
time = 0,
location = "",
task_name = ""
}
function supervisor.get_real_state()
local state = {
hp = 100,
mp = 100,
location = "未知",
exp = 0,
jingli = 100
}
if _G.score and _G.score.loc and _G.score.loc ~= "" then
state.location = _G.score.loc
if string.find(state.location, "任务拒绝") or string.find(state.location, "路太远了") or
string.find(state.location, "不接了") or string.find(state.location, "不做了") then
local abandoned_task = supervisor.get_current_task_name()
local current_time = os.time()
if abandoned_task ~= "无任务执行" and
(last_abandon_check.task_name ~= abandoned_task or
last_abandon_check.location ~= state.location or
current_time - last_abandon_check.time > 30) then
supervisor.record_task_abandon(abandoned_task, state.location)
last_abandon_check.time = current_time
last_abandon_check.location = state.location
last_abandon_check.task_name = abandoned_task
end
end
else
state.location = "未知位置"
end
return state
end
function supervisor.get_current_exp()
local exp = 0
if _G.hp and _G.hp.exp then
local exp_str = tostring(_G.hp.exp)
exp_str = string.gsub(exp_str, ",", "")
exp = tonumber(exp_str) or 0
elseif _G.score and _G.score.exp then
local exp_str = tostring(_G.score.exp)
exp_str = string.gsub(exp_str, ",", "")
exp = tonumber(exp_str) or 0
else
exp = tonumber(GetVariable("last_known_exp")) or 0
end
return exp
end
function supervisor.get_current_task_name()
if _G.job and _G.job.name and _G.job.name ~= "none" then
local task_name_map = {
["xueshan"] = "雪山任务",
["huashan"] = "华山任务",
["wudang"] = "武当任务",
["songxin"] = "送信任务",
["tdh"] = "天地会任务",
["changle"] = "长乐帮任务",
["hubiao"] = "护镖任务",
["dami"] = "大米任务",
["letter"] = "失落的信件",
["shenlong"] = "神龙任务",
["xuncheng"] = "巡城任务",
["gaibang"] = "丐帮任务",
["songshan"] = "嵩山任务",
["zhuoshe"] = "捉蛇任务",
["baoxiao"] = "报效国家",
["guanfu"] = "官府任务"
}
return task_name_map[_G.job.name] or _G.job.name
end
if _G.score and _G.score.zt then
local status = _G.score.zt
local task_map = {
["雪山"] = "雪山任务",
["华山"] = "华山任务",
["武当"] = "武当任务",
["送信"] = "送信任务",
["天地会"] = "天地会任务",
["长乐帮"] = "长乐帮任务",
["护镖"] = "护镖任务",
["大米"] = "大米任务",
["失落的信件"] = "失落的信件",
["神龙"] = "神龙任务",
["巡城"] = "巡城任务",
["丐帮"] = "丐帮任务",
["嵩山"] = "嵩山任务",
["捉蛇"] = "捉蛇任务",
["报效国家"] = "报效国家",
["官府"] = "官府任务"
}
for pattern, task_name in pairs(task_map) do
if string.find(status, pattern) then
return task_name
end
end
end
return "无任务执行"
end
function supervisor.get_real_time_tasks()
if _G.job and _G.job.name and _G.job.name ~= "" and _G.job.name ~= "none" then
local task_name = _G.job.name
local task_name_map = {
["xueshan"] = "雪山任务",
["huashan"] = "华山任务",
["wudang"] = "武当任务",
["songxin"] = "送信任务",
["tdh"] = "天地会任务",
["changle"] = "长乐帮任务",
["hubiao"] = "护镖任务",
["dami"] = "大米任务",
["letter"] = "失落的信件",
["shenlong"] = "神龙任务",
["xuncheng"] = "巡城任务",
["gaibang"] = "丐帮任务",
["songshan"] = "嵩山任务",
["zhuoshe"] = "捉蛇任务",
["baoxiao"] = "报效国家",
["guanfu"] = "官府任务"
}
local display_name = task_name_map[task_name] or task_name
local progress = 20
if _G.job and _G.job.stage then
local stage = _G.job.stage
if task_name == "xueshan" then
if stage == "ask" then progress = 30
elseif stage == "moving" then progress = 60
elseif stage == "fighting" then progress = 90
elseif stage == "reward" then progress = 100
end
else
if stage == "ask" then progress = 25
elseif stage == "moving" then progress = 50
elseif stage == "fighting" then progress = 75
elseif stage == "reward" then progress = 100
end
end
end
return {
{
name = display_name,
status = "执行中",
progress = progress,
start_time = os.time() - 60
}
}
end
return {}
end
-- ==================== 边框配置 ====================
local BORDER_CONFIG = {
width = 8,
padding = 3,
content_width = 40
}
-- ==================== 边框函数 ====================
function supervisor.print_top_border()
ColourNote("yellow", "", "╔" .. string.rep("═", BORDER_CONFIG.width + 26) .. "╗")
end
function supervisor.print_bottom_border()
ColourNote("silver", "", "╚" .. string.rep("═", BORDER_CONFIG.width + 26) .. "╝")
end
function supervisor.print_divider()
ColourNote("yellow", "", "╠" .. string.rep("═", BORDER_CONFIG.width + 26) .. "╣")
end
function supervisor.print_section_divider()
ColourNote("silver", "", "╠" .. string.rep("═", BORDER_CONFIG.width + 26) .. "╣")
end
function supervisor.print_center_line(content, color)
local text_len = string.len(content)
local total_width = BORDER_CONFIG.width + 60
local left_pad = math.floor((total_width - text_len) / 2)
local right_pad = total_width - text_len - left_pad
local line = "║" .. string.rep(" ", left_pad) .. content .. string.rep(" ", right_pad) .. "║"
if color then
ColourNote(color, "", line)
else
ColourNote("white", "", line)
end
end
function supervisor.print_line(content, color)
local padding = BORDER_CONFIG.width + 60 - string.len(content) - 2
if padding < 0 then padding = 0 end
local line = "║ " .. content .. string.rep(" ", padding) .. " ║"
if color then
ColourNote(color, "", line)
else
ColourNote("white", "", line)
end
end
function supervisor.print_header(title)
supervisor.print_top_border()
supervisor.print_center_line("", "yellow")
supervisor.print_center_line(title, "yellow")
supervisor.print_center_line("", "yellow")
supervisor.print_divider()
end
function supervisor.print_section_header(title)
supervisor.print_line("╠ " .. title, "cyan")
supervisor.print_section_divider()
end
function supervisor.jiankan()
local account_name, account_id = supervisor.get_real_account_info()
local current_state = supervisor.get_real_state()
local real_tasks = supervisor.get_real_time_tasks()
local run_time = os.time() - task_statistics.today.start_time
local current_exp = supervisor.get_current_exp()
local start_exp = task_statistics.today.start_exp or current_exp
if start_exp == 0 and current_exp > 100000 then
start_exp = current_exp
task_statistics.today.start_exp = current_exp
end
local online_exp_gained = math.max(current_exp - start_exp, 0)
local exp_per_hour = 0
if run_time > 0 then
exp_per_hour = math.floor(online_exp_gained * 3600 / run_time)
end
local total_completed_tasks = 0
if _G.job and _G.job.finish then
total_completed_tasks = _G.job.finish
else
total_completed_tasks = task_statistics.today.completed_tasks
end
ColourNote("white", "black", string.rep("\n", 2))
supervisor.print_header("智能任务监控系统 - 集成统计版")
supervisor.print_section_header("基础信息")
supervisor.print_line("账号姓名: " .. account_name)
supervisor.print_line("账号ID: " .. account_id)
supervisor.print_line("运行时间: " .. supervisor.format_time(run_time))
supervisor.print_line("监控状态: 运行中 (集成job.lua)")
supervisor.print_line("系统时间: " .. os.date("%H:%M:%S"))
supervisor.print_section_divider()
supervisor.print_section_header("状态信息")
supervisor.print_line("生命值: " .. supervisor.get_progress_bar(current_state.hp) .. " " .. current_state.hp .. "%")
supervisor.print_line("内力值: " .. supervisor.get_progress_bar(current_state.mp) .. " " .. current_state.mp .. "%")
supervisor.print_line("精力值: " .. supervisor.get_progress_bar(current_state.jingli) .. " " .. current_state.jingli .. "%")
supervisor.print_line("当前位置: " .. current_state.location)
supervisor.print_section_divider()
supervisor.print_section_header("任务信息")
local detailed_task = supervisor.get_detailed_task_status()
-- 确保所有字段都有值
local task_name = detailed_task.name or "未知任务"
local task_status = detailed_task.status or "未知"
local task_progress = detailed_task.progress or 0
local task_target = detailed_task.target or "无"
local task_detail = detailed_task.detail or ""
local task_eta = detailed_task.estimated_time or "未知"
local task_risk = detailed_task.risk_level or "低"
supervisor.print_line("当前任务: " .. task_name)
supervisor.print_line("任务状态: " .. task_status)
supervisor.print_line("任务进度: " .. supervisor.get_progress_bar(task_progress) .. " " .. task_progress .. "%")
if task_target ~= "无" then
supervisor.print_line("任务目标: " .. task_target)
end
if task_detail ~= "" then
supervisor.print_line("任务详情: " .. task_detail)
end
supervisor.print_line("预计完成: " .. task_eta)
supervisor.print_line("风险等级: " .. task_risk)
if detailed_task.suggestions and #detailed_task.suggestions > 0 then
supervisor.print_line("执行建议: " .. detailed_task.suggestions[1], "yellow")
end
supervisor.print_section_divider()
supervisor.print_section_header("任务统计")
supervisor.print_line("--- 主体任务 ---", "cyan")
local main_tasks = {"送信任务", "华山任务", "武当任务", "雪山任务", "天地会任务", "护镖任务", "官府任务", "报效国家"}
local has_main_stats = false
for _, task_name in ipairs(main_tasks) do
local stats = task_statistics.today.task_type_stats[task_name]
if stats then
local success = stats.success or 0
local failure = stats.failure or 0
local abandon = stats.abandon or 0
if success > 0 or failure > 0 or abandon > 0 then
supervisor.print_line(task_name .. ": " .. success .. "成功 " .. failure .. "失败 " .. abandon .. "放弃")
has_main_stats = true
end
end
end
if not has_main_stats then
supervisor.print_line("暂无主体任务统计")
end
supervisor.print_line("--- 每日任务 ---", "yellow")
local daily_tasks = {"失落信笺", "捉蛇任务"}
local has_daily_stats = false
for _, task_name in ipairs(daily_tasks) do
local stats = task_statistics.today.task_type_stats[task_name]
if stats then
local success = stats.success or 0
local failure = stats.failure or 0
local abandon = stats.abandon or 0
if success > 0 or failure > 0 or abandon > 0 then
supervisor.print_line(task_name .. ": " .. success .. "成功 " .. failure .. "失败 " .. abandon .. "放弃")
has_daily_stats = true
end
end
end
if not has_daily_stats then
supervisor.print_line("暂无每日任务统计")
end
supervisor.print_line("--- 特殊任务 ---", "green")
local special_tasks = {"龙虎山任务", "烂柯山任务", "做菜任务"}
local has_special_stats = false
for _, task_name in ipairs(special_tasks) do
local stats = task_statistics.today.task_type_stats[task_name]
if stats then
local success = stats.success or 0
local failure = stats.failure or 0
local abandon = stats.abandon or 0
if success > 0 or failure > 0 or abandon > 0 then
supervisor.print_line(task_name .. ": " .. success .. "成功 " .. failure .. "失败 " .. abandon .. "放弃")
has_special_stats = true
end
end
end
if not has_special_stats then
supervisor.print_line("暂无特殊任务统计")
end
supervisor.print_line("--- 其他任务 ---", "white")
local other_tasks = {"巡城任务", "丐帮任务", "嵩山任务", "长乐帮任务", "大米任务", "神龙任务"}
local has_other_stats = false
for _, task_name in ipairs(other_tasks) do
local stats = task_statistics.today.task_type_stats[task_name]
if stats then
local success = stats.success or 0
local failure = stats.failure or 0
local abandon = stats.abandon or 0
if success > 0 or failure > 0 or abandon > 0 then
supervisor.print_line(task_name .. ": " .. success .. "成功 " .. failure .. "失败 " .. abandon .. "放弃")
has_other_stats = true
end
end
end
if not has_other_stats then
supervisor.print_line("暂无其他任务统计")
end
supervisor.print_section_divider()
supervisor.print_section_header("总体统计")
supervisor.print_line("任务成功: " .. task_statistics.today.completed_tasks .. " 个任务", "green")
supervisor.print_line("任务失败: " .. task_statistics.today.failed_tasks .. " 个任务", "red")
supervisor.print_line("任务放弃: " .. task_statistics.today.abandoned_tasks .. " 个任务", "orange")
supervisor.print_line("任务共完成: " .. total_completed_tasks .. " 个任务", "cyan")
supervisor.print_section_divider()
supervisor.print_section_header("效率统计")
supervisor.print_line("总在线: " .. supervisor.format_time(run_time))
supervisor.print_line("在线获得: " .. online_exp_gained .. " 经验点")
supervisor.print_line("任务效率: " .. exp_per_hour .. " 点/小时")
supervisor.print_line("监控经验: " .. task_statistics.today.total_exp .. " 点")
supervisor.print_line("开始经验: " .. start_exp)
supervisor.print_line("当前经验: " .. current_exp)
supervisor.print_section_divider()
supervisor.print_section_header("脚本错误诊断")
supervisor.update_death_count_from_score()
local death_count = error_diagnosis.death_detection.total_deaths
if death_count > 0 then
local death_display = "在线死亡:" .. death_count .. " 次"
if error_diagnosis.death_detection.last_death_reason ~= "" then
local short_reason = supervisor.extract_short_death_reason(error_diagnosis.death_detection.last_death_reason)
death_display = death_display .. " 死亡原因(" .. short_reason .. ")"
end
supervisor.print_line(death_display, "red")
if error_diagnosis.death_detection.last_death_analysis then
local analysis = error_diagnosis.death_detection.last_death_analysis
supervisor.print_line("根本原因: " .. analysis.cause, "orange")
supervisor.print_line("脚本建议: " .. analysis.suggestion, "yellow")
end
if error_diagnosis.death_detection.last_death_time > 0 then
local time_ago = os.time() - error_diagnosis.death_detection.last_death_time
local minutes_ago = math.floor(time_ago / 60)
if minutes_ago > 0 then
supervisor.print_line("发生时间: " .. minutes_ago .. "分钟前", "orange")
else
supervisor.print_line("发生时间: 刚刚", "orange")
end
end
else
supervisor.print_line("在线死亡:0 次", "green")
supervisor.print_line("系统状态: 各监控脚本运行正常", "green")
end
local is_idle, reasons = supervisor.detect_idle_status()
if is_idle then
local idle_minutes = math.floor((os.time() - error_diagnosis.idle_detection.last_action_time)/60)
supervisor.print_line("发呆检测: 已停滞 " .. idle_minutes .. " 分钟", "red")
for i, reason in ipairs(reasons) do
if i <= 2 then
supervisor.print_line("卡住原因: " .. reason, "orange")
end
end
supervisor.print_line("处理建议: 检查脚本触发条件或手动干预", "yellow")
else
supervisor.print_line("执行状态: 运行正常", "green")
end
supervisor.print_section_divider()
supervisor.print_center_line("")
supervisor.print_center_line("集成统计系统 - 数据同步完成", "yellow")
supervisor.print_center_line("")
supervisor.print_bottom_border()
ColourNote("white", "", "")
end
-- ==================== 辅助函数 ====================
function supervisor.format_time(seconds)
if not seconds or seconds <= 0 then
return "0分"
end
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
if hours > 0 then
return string.format("%d小时%d分", hours, minutes)
else
return string.format("%d分", minutes)
end
end
function supervisor.get_progress_bar(percentage)
local bars = math.floor((percentage or 0) / 10)
return string.rep("■", bars) .. string.rep("□", 10 - bars)
end
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
-- ==================== 系统初始化 ====================
function supervisor.full_initialization()
local current_exp = supervisor.get_current_exp()
if current_exp > 100000 and (not task_statistics.today.start_exp or task_statistics.today.start_exp == 0) then
if not task_statistics.today.start_time then
task_statistics.today.start_time = os.time()
end
task_statistics.today.start_exp = current_exp
ColourNote("yellow", "", string.format("监控系统: 重新加载,设置开始经验=%d", current_exp))
else
task_statistics.today.start_exp = current_exp
task_statistics.today.start_time = os.time()
ColourNote("yellow", "", string.format("监控系统: 首次启动,开始经验=%d", current_exp))
end
supervisor.update_death_count_from_score()
supervisor.setup_job_reward_monitor()
supervisor.setup_job_failure_monitor()
supervisor.setup_death_detection()
DoAfterSpecial(5, "supervisor.safe_idle_monitor_loop()", 12)
local death_count = error_diagnosis.death_detection.total_deaths
ColourNote("green", "", "智能监控系统已启动")
ColourNote("green", "", "使用: jiankan() 查看状态")
if death_count > 0 then
ColourNote("red", "", string.format("当前死亡次数: %d", death_count))
end
end
-- ==================== 全局函数注册 ====================
if not _G.jiankan then
_G.jiankan = supervisor.jiankan
end
if not _G.supervisor then
_G.supervisor = supervisor
end
if not _G.reset_monitor then
_G.reset_monitor = function()
local current_exp = supervisor.get_current_exp()
task_statistics.today.start_exp = current_exp
task_statistics.today.start_time = os.time()
task_statistics.today.completed_tasks = 0
task_statistics.today.failed_tasks = 0
task_statistics.today.abandoned_tasks = 0
task_statistics.today.total_tasks = 0
task_statistics.today.total_exp = 0
for task_name, _ in pairs(task_statistics.today.task_type_stats) do
task_statistics.today.task_type_stats[task_name] = {success = 0, failure = 0, abandon = 0}
end
ColourNote("green", "", "监控统计已重置")
ColourNote("green", "", string.format("新的开始经验: %d", current_exp))
end
end
if not _G.update_deaths then
_G.update_deaths = function()
supervisor.update_death_count_from_score()
local death_count = error_diagnosis.death_detection.total_deaths
ColourNote("yellow", "", string.format("当前死亡次数: %d", death_count))
end
end
-- 立即初始化
supervisor.full_initialization()
return supervisor |
评分
-
1
查看全部评分
-
|