JS脚本:刷肉适配exit_and_relogin,加入卡时间功能 (#475)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"info": {
|
||||
"name": "好感-张牙舞爪的恶党-循环(二净甸)",
|
||||
"type": "collect",
|
||||
"author": "起个名字好难的喵",
|
||||
"version": "1.0",
|
||||
"description": "",
|
||||
"bgiVersion": "0.43.5"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"id": 1,
|
||||
"action": "",
|
||||
"move_mode": "dash",
|
||||
"type": "path",
|
||||
"x": 3614.6240234375,
|
||||
"y": -521.58154296875,
|
||||
"action_params": ""
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"x": 3574.46875,
|
||||
"y": -501.7119140625,
|
||||
"type": "path",
|
||||
"move_mode": "dash",
|
||||
"action": "fight",
|
||||
"action_params": ""
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"x": 3605.1826171875,
|
||||
"y": -513.31982421875,
|
||||
"type": "path",
|
||||
"move_mode": "dash",
|
||||
"action": "",
|
||||
"action_params": ""
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"x": 3614.505859375,
|
||||
"y": -521.4970703125,
|
||||
"type": "path",
|
||||
"move_mode": "dash",
|
||||
"action": "exit_and_relogin",
|
||||
"action_params": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"info": {
|
||||
"name": "好感-张牙舞爪的恶党-循环(二净甸刷肉版)",
|
||||
"type": "collect",
|
||||
"author": "起个名字好难的喵",
|
||||
"version": "1.0",
|
||||
"description": "",
|
||||
"bgiVersion": "0.43.5"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"id": 1,
|
||||
"x": 3614.63,
|
||||
"y": -521.6,
|
||||
"action": "",
|
||||
"move_mode": "dash",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"x": 3578.08,
|
||||
"y": -500.75,
|
||||
"action": "fight",
|
||||
"move_mode": "dash",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"x": 3572.375,
|
||||
"y": -502.4375,
|
||||
"action": "",
|
||||
"move_mode": "walk",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"x": 3577.875,
|
||||
"y": -497.375,
|
||||
"action": "",
|
||||
"move_mode": "walk",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"x": 3578.78125,
|
||||
"y": -503.40625,
|
||||
"action": "",
|
||||
"move_mode": "walk",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"x": 3573.53125,
|
||||
"y": -497.9375,
|
||||
"action": "",
|
||||
"move_mode": "walk",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"x": 3576.03125,
|
||||
"y": -503.0625,
|
||||
"action": "",
|
||||
"move_mode": "walk",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"x": 3605.18,
|
||||
"y": -513.32,
|
||||
"action": "",
|
||||
"move_mode": "dash",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"x": 3614.63,
|
||||
"y": -521.6,
|
||||
"action": "exit_and_relogin",
|
||||
"move_mode": "dash",
|
||||
"action_params": "",
|
||||
"type": "path"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"info": {
|
||||
"name": "好感-张牙舞爪的恶党-触发位置(二净甸)",
|
||||
"type": "collect",
|
||||
"author": "起个名字好难的喵",
|
||||
"version": "1.0",
|
||||
"description": "",
|
||||
"bgiVersion": "0.43.5"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"id": 1,
|
||||
"action": "",
|
||||
"move_mode": "walk",
|
||||
"type": "teleport",
|
||||
"x": 3705.5322265625,
|
||||
"y": -497.45068359375,
|
||||
"action_params": ""
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"x": 3615.4814453125,
|
||||
"y": -521.2724609375,
|
||||
"type": "path",
|
||||
"move_mode": "fly",
|
||||
"action": "stop_flying",
|
||||
"action_params": "2500"
|
||||
},
|
||||
{
|
||||
"x": 3615.4814453125,
|
||||
"y": -521.2724609375,
|
||||
"type": "path",
|
||||
"move_mode": "walk",
|
||||
"action": "combat_script",
|
||||
"action_params": "wait(10)"
|
||||
},
|
||||
{
|
||||
"x": 3615.4814453125,
|
||||
"y": -521.2724609375,
|
||||
"type": "path",
|
||||
"move_mode": "walk",
|
||||
"action": "exit_and_relogin"
|
||||
}
|
||||
]
|
||||
}
|
||||
125
repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/main.js
Normal file
125
repo/js/AutoFriendshipEvilBaresItsFangsGetRawMeat/main.js
Normal file
@@ -0,0 +1,125 @@
|
||||
(async function () {
|
||||
|
||||
function logTimeTaken(startTime) {
|
||||
const currentTime = Date.now();
|
||||
const totalTimeInSeconds = (currentTime - startTime) / 1000;
|
||||
const minutes = Math.floor(totalTimeInSeconds / 60);
|
||||
const seconds = totalTimeInSeconds % 60;
|
||||
const formattedTime = `${minutes}分${seconds.toFixed(0).padStart(2, '0')}秒`;
|
||||
log.info(`当前运行总时长:${formattedTime}`);
|
||||
}
|
||||
|
||||
// powered by 秋云
|
||||
function calculateEstimatedCompletion(startTime, current, total) {
|
||||
if (current === 0) return "计算中...";
|
||||
const elapsedTime = Date.now() - startTime;
|
||||
const timePerTask = elapsedTime / current;
|
||||
const remainingTasks = total - current;
|
||||
const remainingTime = timePerTask * remainingTasks;
|
||||
const completionDate = new Date(Date.now() + remainingTime);
|
||||
return `${completionDate.toLocaleTimeString()} (约 ${Math.round(remainingTime / 60000)} 分钟)`;
|
||||
}
|
||||
|
||||
async function AutoPath(locationName) {
|
||||
try {
|
||||
let filePath = `assets/AutoPath/${locationName}.json`;
|
||||
await pathingScript.runFile(filePath);
|
||||
} catch (error) {
|
||||
log.error(`执行 ${locationName} 路径时发生错误`);
|
||||
log.error(error.message);
|
||||
}
|
||||
await sleep(1000);
|
||||
}
|
||||
|
||||
// 好感核心函数
|
||||
async function AutoFriendship(runTimes, statueTimes, GetMeatMode,startTime) {
|
||||
log.info(`导航至好感-张牙舞爪的恶党-触发位置(二净甸)`);
|
||||
await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`);
|
||||
|
||||
log.info(`已抵达预期位置,兽肉好感循环开始...`);
|
||||
|
||||
for (let i = 0; i < runTimes; i++) {
|
||||
if ((i + 1) % statueTimes === 0) {
|
||||
await genshin.tp(2297.60, -824.45); // 神像坐标
|
||||
await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`);
|
||||
log.info(`当前次数:${i + 1}/${runTimes}`);
|
||||
await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`);
|
||||
} else {
|
||||
log.info(`当前次数:${i + 1}/${runTimes}`);
|
||||
await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`);
|
||||
}
|
||||
const estimatedCompletion = calculateEstimatedCompletion(startTime, i + 1, runTimes);
|
||||
log.info(`已完成次数:${i + 1}/${runTimes}`);
|
||||
logTimeTaken(startTime);
|
||||
log.info(`预计完成时间:${estimatedCompletion}`);
|
||||
}
|
||||
log.info('兽肉好感已完成');
|
||||
}
|
||||
|
||||
// 刷肉相关参数
|
||||
let GetMeatMode = settings.GetMeatMode ? settings.GetMeatMode : false;
|
||||
let inputValue = settings.inputValue ? settings.inputValue : 300;
|
||||
let runTimes = GetMeatMode ? (isNaN(inputValue) ? 50 : Math.ceil(inputValue / 6)) : 10;
|
||||
// 神像相关参数
|
||||
let goStatue = settings.goStatue ? settings.goStatue : false;
|
||||
let statueTimes = goStatue ? (isNaN(settings.statueTimes) ? 5 : settings.statueTimes) : 0;
|
||||
// 卡时间相关参数
|
||||
if(settings.waitTimeMode){
|
||||
let maxTimes = settings.maxTimes ? settings.maxTimes : runTimes ;
|
||||
let waitTimeModeDay = settings.waitTimeModeDay
|
||||
const datePattern = /^\d{4}-\d{2}-\d{2}$/; // 日期正则
|
||||
if (!datePattern.test(settings.waitTimeModeDay)) {
|
||||
log.error(`检测到基准日期格式错误,当前输入值为:${waitTimeModeDay}`);
|
||||
waitTimeModeDay = "2025-03-31";
|
||||
log.info(`使用的基准日期为:${waitTimeModeDay}`);
|
||||
}
|
||||
const now = new Date();
|
||||
const benchmark = new Date(waitTimeModeDay + "T04:00:00");
|
||||
const timeDiff = now.getTime() - benchmark.getTime();
|
||||
const daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
|
||||
let period = Number(settings.waitTimeModePeriod);
|
||||
if(isNaN(period)){
|
||||
log.warn(`错误的卡时间模式周期 ${period}!使用 7 天作为周期。`);
|
||||
period = 7.0;
|
||||
}
|
||||
if(period < 1 || period > 48){
|
||||
log.warn(`卡时间模式周期 ${period} 超过范围!使用 7 天作为周期。`);
|
||||
period = 7.0;
|
||||
}
|
||||
const daysNormalized = daysDiff >= 0 ? daysDiff : period - (Math.abs(daysDiff) % period);
|
||||
runTimes = Math.ceil(maxTimes / period) * (daysNormalized % period + 1);
|
||||
}
|
||||
|
||||
// Main
|
||||
dispatcher.addTimer(new RealtimeTimer("AutoPick", { "forceInteraction": true }));
|
||||
const startTime = Date.now();
|
||||
let messages = [
|
||||
'请确保队伍满员,并为队伍配置相应的战斗策略',
|
||||
`使用的七天神像周期为: ${statueTimes}`,
|
||||
`计算后的运行次数为: ${runTimes}`,
|
||||
];
|
||||
for (let message of messages) {
|
||||
log.info(message);
|
||||
await sleep(500);
|
||||
}
|
||||
log.info('兽肉好感开始...');
|
||||
|
||||
// 切换队伍
|
||||
if (!!settings.partyName) {
|
||||
try {
|
||||
await genshin.tp(2297.60, -824.45);
|
||||
await sleep(3000);
|
||||
log.info("正在尝试切换至" + settings.partyName);
|
||||
await genshin.switchParty(settings.partyName);
|
||||
} catch {
|
||||
log.warn("队伍切换失败,可能处于联机模式或其他不可切换状态");
|
||||
await genshin.returnMainUi();
|
||||
}
|
||||
} else {
|
||||
await genshin.returnMainUi();
|
||||
}
|
||||
|
||||
await AutoFriendship(runTimes,statueTimes,GetMeatMode,startTime);
|
||||
log.info(`兽肉好感运行总时长:${LogTimeTaken(startTime)}`);
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "兽肉好感:自动好感度&刷两只鳄鱼兽肉&卡时间",
|
||||
"version": "1.2.0",
|
||||
"description": "通过突发事件:张牙舞爪的恶党刷兽肉,并顺带获取好感度(超过10次后不再获取),请使用满员好感度队伍,并为全体队伍角色配置相应的战斗策略",
|
||||
"authors": [
|
||||
{
|
||||
"name": "起个名字好难的喵"
|
||||
}
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js"
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"name": "partyName",
|
||||
"type": "input-text",
|
||||
"label": "需要切换的队伍名称(选填)"
|
||||
},
|
||||
{
|
||||
"name": "GetMeatMode",
|
||||
"type": "checkbox",
|
||||
"label": "开启刷兽肉模式【勾选才拾取兽肉】"
|
||||
},
|
||||
{
|
||||
"name": "inputValue",
|
||||
"type": "input-text",
|
||||
"label": "刷取个数(选填,默认为300)"
|
||||
},
|
||||
{
|
||||
"name": "waitTimeMode",
|
||||
"type": "checkbox",
|
||||
"label": "卡时间模式【基于运行次数、基准日期、周期确定需要运行次数】"
|
||||
},
|
||||
{
|
||||
"name": "waitTimeModeDay",
|
||||
"type": "input-text",
|
||||
"label": "卡时间模式基准日期(选填,默认为2025-03-31)"
|
||||
},
|
||||
{
|
||||
"name": "waitTimeModePeriod",
|
||||
"type": "input-text",
|
||||
"label": "卡时间模式周期(选填,默认为7天/循环)"
|
||||
},
|
||||
{
|
||||
"name": "maxTimes",
|
||||
"type": "input-text",
|
||||
"label": "最大运行次数(选填,卡时间模式下生效,默认为刷肉模式计算值)"
|
||||
},
|
||||
{
|
||||
"name": "goStatue",
|
||||
"type": "checkbox",
|
||||
"label": "开启定期前往七天神像"
|
||||
},
|
||||
{
|
||||
"name": "statueTimes",
|
||||
"type": "input-text",
|
||||
"label": "返回神像周期(选填,默认为5次/循环)"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user