js: 精英规划、小怪规划、自动消耗复活药 (#741)
* 三个js更新 精英js:跟进死亡笔记400的路线包 * js;欸起飞,飞 * fix: 重命名 --------- Co-authored-by: 秋云 <[email protected]>
This commit is contained in:
1 parent
881188012e
commit
22ba06b7c8
312 files changed
+2723
-562
No files matched your search
@@ -0,0 +1,49 @@
|
||||
(async function () {
|
||||
// 从 settings 中获取最大循环次数,如果未配置则默认为 2000
|
||||
const maxLoopCount = parseInt(settings.maxLoopCount || 2000, 10);
|
||||
|
||||
// 从 settings 中获取排除时间(小时数),如果未配置则默认为 4
|
||||
const excludeHour = parseInt(settings.excludeTimeRange || 4, 10);
|
||||
|
||||
// 检查最大循环次数是否为有效数字
|
||||
if (isNaN(maxLoopCount) || maxLoopCount <= 0) {
|
||||
log.error("无效的最大循环次数,请输入一个正整数");
|
||||
return; // 退出整个程序
|
||||
}
|
||||
|
||||
// 检查排除时间是否为有效数字
|
||||
if (isNaN(excludeHour) || excludeHour < 0 || excludeHour > 23) {
|
||||
log.error("无效的排除时间,请输入一个0到23之间的整数");
|
||||
return; // 退出整个程序
|
||||
}
|
||||
|
||||
// 定义路径文件名
|
||||
const pathFileName = "信仰之跃.json";
|
||||
|
||||
// 执行循环
|
||||
for (let i = 0; i < maxLoopCount; i++) {
|
||||
// 获取当前时间
|
||||
const now = new Date();
|
||||
const currentHour = now.getHours(); // 获取当前时间的小时数
|
||||
const currentTime = now.toLocaleString(); // 获取完整的当前时间字符串
|
||||
|
||||
// 如果当前时间的小时数与排除时间相同,则退出循环
|
||||
if (currentHour === excludeHour) {
|
||||
log.info(`当前时间是 ${currentTime},与排除时间小时数相同,将退出循环`);
|
||||
break; // 退出循环
|
||||
}
|
||||
|
||||
// 记录当前时间
|
||||
log.info(`正在执行循环第 ${i + 1} 次,总共 ${maxLoopCount} 次,当前时间: ${currentTime}`);
|
||||
|
||||
try {
|
||||
// 运行路径追踪任务
|
||||
await pathingScript.runFile(pathFileName);
|
||||
} catch (error) {
|
||||
// 捕获并处理路径追踪任务中的错误
|
||||
log.error(`在第 ${i + 1} 次循环中运行路径追踪任务时发生错误: ${error.message}`);
|
||||
log.error("由于发生错误,将退出整个程序");
|
||||
return; // 退出整个程序
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "消耗复活料理@mno",
|
||||
"version": "1.0",
|
||||
"description": "通过信仰之跃消耗放在食品袋中的复活料理,注意,使用前请确保要消耗的复活料理在食品袋中并且装备食品袋小道具,目前存在一个已知的bug导致结束配置组时将花费过长的时间,建议直接关闭bgi程序来关闭本配置组",
|
||||
"authors": [
|
||||
{
|
||||
"name": "mno"
|
||||
}
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"name": "maxLoopCount",
|
||||
"type": "input-text",
|
||||
"label": "最大循环数"
|
||||
},
|
||||
{
|
||||
"name": "excludeTimeRange",
|
||||
"type": "input-text",
|
||||
"label": "不在某时运行"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"info": {
|
||||
"name": "信仰之跃",
|
||||
"type": "collect",
|
||||
"author": "mno",
|
||||
"version": "1.0",
|
||||
"description": "",
|
||||
"map_name": "Teyvat",
|
||||
"bgi_version": "0.45.0"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"id": 1,
|
||||
"x": 508.03515625,
|
||||
"y": -630.49072265625,
|
||||
"type": "teleport",
|
||||
"move_mode": "walk",
|
||||
"action": "",
|
||||
"action_params": ""
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"x": 499.87890625,
|
||||
"y": -686.18310546875,
|
||||
"type": "path",
|
||||
"move_mode": "fly",
|
||||
"action": "stop_flying",
|
||||
"action_params": "10000",
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"x": 501.3095703125,
|
||||
"y": -683.6240234375,
|
||||
"type": "path",
|
||||
"move_mode": "walk",
|
||||
"action": "combat_script",
|
||||
"action_params": "keypress(z),wait(5),keypress(1),wait(90)"
|
||||
}
|
||||
]
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -52,70 +52,58 @@
|
||||
dispatcher.addTimer(new RealtimeTimer("AutoPick"));
|
||||
}
|
||||
|
||||
// 判断操作模式是否为“执行路径文件”
|
||||
if (operationMode === "执行路径文件") {
|
||||
const pathGroupName = `${requiredMonsterCount}${excludeWaterFree ? '排除水免' : '包含水免'}${excludeHighRisk ? '排除高危' : '包含高危'}权重${weight}.txt`;
|
||||
const pathGroupFilePath = `route/${pathGroupName}`;
|
||||
// 判断操作模式是否为“执行路径文件”,若是则执行路径文件
|
||||
if (operationMode === "执行路径文件") {
|
||||
try {
|
||||
// 定义路径组文件的路径,使用 outputFolderName
|
||||
const pathGroupFilePath = `route/${outputFolderName}.txt`;
|
||||
|
||||
try {
|
||||
const savedRoutesContent = await file.readText(pathGroupFilePath);
|
||||
const savedRoutes = savedRoutesContent.trim().split('\n');
|
||||
for (let i = 0; i < savedRoutes.length; i++) {
|
||||
// 分离路线名称和时间戳
|
||||
const routeWithTimestamp = savedRoutes[i].trim();
|
||||
const [routeName, routeTimestamp] = routeWithTimestamp.split('::');
|
||||
log.info(`当前任务为第 ${i + 1}/${savedRoutes.length} 个`);
|
||||
const pathGroupContent = await file.readText(pathGroupFilePath);
|
||||
const savedRoutes = pathGroupContent.trim().split('\n');
|
||||
for (let i = 0; i < savedRoutes.length; i++) {
|
||||
const routeWithTimestamp = savedRoutes[i].trim();
|
||||
const [routeName, routeTimestamp] = routeWithTimestamp.split('::');
|
||||
log.info(`当前任务为第 ${i + 1}/${savedRoutes.length} 个`);
|
||||
const now = new Date(); // 获取开始时间
|
||||
const startTime = now.toISOString();
|
||||
if (enableCooldownCheck && startTime < routeTimestamp) {
|
||||
log.info(`当前路线 ${routeName} 未刷新,跳过任务`);
|
||||
continue; // 跳过当前循环
|
||||
}
|
||||
log.info(`当前路线 ${routeName} 已刷新或未启用CD检测,执行任务`);
|
||||
|
||||
// 获取开始时间
|
||||
const startTime = new Date();
|
||||
// 拼接路径文件的完整路径
|
||||
const pathingFilePath = `pathing/${routeName}.json`;
|
||||
// 执行路径文件
|
||||
await pathingScript.runFile(pathingFilePath);
|
||||
|
||||
// 比较当前时间戳与路线的时间戳
|
||||
if (enableCooldownCheck) {
|
||||
const routeDate = new Date(routeTimestamp);
|
||||
if (startTime <= routeDate) {
|
||||
log.info(`当前路线未刷新,跳过路线 ${routeName}`); // 修改后的日志输出
|
||||
continue; // 跳过当前路线
|
||||
}
|
||||
}
|
||||
// 如果启用了CD检测,获取结束时间并判断时间差
|
||||
if (enableCooldownCheck) {
|
||||
const endTime = new Date(); // 获取结束时间
|
||||
const timeDiff = endTime - now; // 计算时间差(单位:毫秒)
|
||||
if (timeDiff > 10000) { // 如果时间差大于10秒(10000毫秒)
|
||||
// 计算新的时间戳,增加12小时
|
||||
const newTimestamp = new Date(startTime).getTime() + 12 * 60 * 60 * 1000;
|
||||
const formattedNewTimestamp = new Date(newTimestamp).toISOString();
|
||||
const nextAvailableTime = new Date(formattedNewTimestamp).toLocaleString(); // 转换为本地时间格式
|
||||
log.info(`任务 ${routeName} 运行超过10秒且当前启用刷新CD检测,下一次可用时间为 ${nextAvailableTime}`);
|
||||
log.info(`新的时间戳为:${formattedNewTimestamp}`);
|
||||
|
||||
const pathingFilePath = `${pathingDir}${routeName}.json`;
|
||||
try {
|
||||
await pathingScript.runFile(pathingFilePath);
|
||||
// 获取结束时间
|
||||
const endTime = new Date();
|
||||
// 更新 savedRoutes 中对应部分的时间戳
|
||||
savedRoutes[i] = `${routeName}::${formattedNewTimestamp}`;
|
||||
|
||||
// 比较开始时间与结束时间
|
||||
const timeDiff = endTime.getTime() - startTime.getTime(); // 时间差(毫秒)
|
||||
if (enableCooldownCheck && timeDiff > 10000) { // 时间差大于10秒
|
||||
// 将路径组文件中对应的时间戳改为开始时间后12小时0分0秒
|
||||
const newTimestamp = new Date(startTime.getTime() + 12 * 60 * 60 * 1000).toISOString();
|
||||
const nextAvailableTime = new Date(newTimestamp).toLocaleString(); // 转换为本地时间格式
|
||||
|
||||
// 更新路径组文件中的时间戳
|
||||
const updatedRoutes = savedRoutes.map(route => {
|
||||
const [name, timestamp] = route.split('::');
|
||||
if (name === routeName) {
|
||||
return `${name}::${newTimestamp}`;
|
||||
}
|
||||
return route;
|
||||
}).join('\n');
|
||||
|
||||
await file.writeText(pathGroupFilePath, updatedRoutes);
|
||||
log.info(`本路线执行大于10秒,cd信息已更新,下一次可用时间为 ${nextAvailableTime}`);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`路径文件 ${pathingFilePath} 不存在,跳过该路径`);
|
||||
// 立即将更新后的内容写回文件
|
||||
const updatedContent = savedRoutes.join('\n');
|
||||
await file.writeText(pathGroupFilePath, updatedContent);
|
||||
}
|
||||
}
|
||||
log.info('所有路径运行完成');
|
||||
} catch (error) {
|
||||
log.error(`读取路径组文件 ${pathGroupFilePath} 时出错: ${error}`);
|
||||
}
|
||||
log.info('脚本执行完成');
|
||||
return; // 退出程序
|
||||
} catch (error) {
|
||||
log.error(`读取或写入路径组文件时出错: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 筛选、排序并选取路线
|
||||
// 筛选、排序并选取路线
|
||||
const indexPath = `index.txt`;
|
||||
try {
|
||||
const indexContent = await file.readText(indexPath);
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 312 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user