JS脚本:feat 兽肉好感OCR识别突发任务是否触发 (#652)
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
// 优先使用小地图坐标
|
// 优先使用小地图坐标
|
||||||
await genshin.returnMainUi();
|
await genshin.returnMainUi();
|
||||||
currentPosition = genshin.getPositionFromMap();
|
currentPosition = genshin.getPositionFromMap();
|
||||||
log.info(`当前小地图坐标: X=${currentPosition.X}, Y=${currentPosition.Y}`);
|
// log.info(`当前小地图坐标: X=${currentPosition.X}, Y=${currentPosition.Y}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 如果失败,使用大地图坐标
|
// 如果失败,使用大地图坐标
|
||||||
log.warn(`获取小地图坐标失败,使用大地图坐标。错误信息: ${error}`);
|
log.warn(`获取小地图坐标失败,使用大地图坐标。错误信息: ${error}`);
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
keyPress("M");
|
keyPress("M");
|
||||||
await sleep(2000);
|
await sleep(2000);
|
||||||
currentPosition = genshin.getPositionFromBigMap();
|
currentPosition = genshin.getPositionFromBigMap();
|
||||||
log.info(`当前大地图坐标: X=${currentPosition.X}, Y=${currentPosition.Y}`);
|
// log.info(`当前大地图坐标: X=${currentPosition.X}, Y=${currentPosition.Y}`);
|
||||||
keyPress("Escape");
|
keyPress("Escape");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,11 +60,9 @@
|
|||||||
const dy = currentPosition.Y - targetPosition.Y;
|
const dy = currentPosition.Y - targetPosition.Y;
|
||||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
log.info(`与目标坐标的距离为: ${distance}`);
|
|
||||||
|
|
||||||
// 判断距离是否在允许范围内
|
// 判断距离是否在允许范围内
|
||||||
if (distance <= maxDistance) {
|
if (distance <= maxDistance) {
|
||||||
log.info("距离在突发任务范围内,循环继续");
|
log.info(`距离:${distance} 在突发任务范围内,循环继续`);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
log.warn("距离超出突发任务范围,执行触发线路");
|
log.warn("距离超出突发任务范围,执行触发线路");
|
||||||
@@ -73,7 +71,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 好感核心函数
|
// 好感核心函数
|
||||||
async function AutoFriendship(runTimes, statueTimes, GetMeatMode, startTime) {
|
async function AutoFriendship(runTimes, statueTimes, GetMeatMode, delayTime, startTime) {
|
||||||
for (let i = 0; i < runTimes; i++) {
|
for (let i = 0; i < runTimes; i++) {
|
||||||
if ((i + 1) % statueTimes === 0) { // 判断当前循环次数否达到去神像设置值
|
if ((i + 1) % statueTimes === 0) { // 判断当前循环次数否达到去神像设置值
|
||||||
await genshin.tpToStatueOfTheSeven();
|
await genshin.tpToStatueOfTheSeven();
|
||||||
@@ -81,24 +79,45 @@
|
|||||||
} else if (!await comparePosition()) { // 对比触发位置坐标,如果不符合预期坐标则重新执行触发线路
|
} else if (!await comparePosition()) { // 对比触发位置坐标,如果不符合预期坐标则重新执行触发线路
|
||||||
log.info(`导航至突发任务(张牙舞爪的恶党)触发位置(二净甸)`);
|
log.info(`导航至突发任务(张牙舞爪的恶党)触发位置(二净甸)`);
|
||||||
await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`);
|
await AutoPath(`好感-张牙舞爪的恶党-触发位置(二净甸)`);
|
||||||
|
await sleep(delayTime);
|
||||||
notification.send(`已抵达突发任务(张牙舞爪的恶党)触发位置`);
|
notification.send(`已抵达突发任务(张牙舞爪的恶党)触发位置`);
|
||||||
}
|
}
|
||||||
// 开启急速拾取
|
// 开启急速拾取
|
||||||
dispatcher.addTimer(new RealtimeTimer("AutoPick", {
|
dispatcher.addTimer(new RealtimeTimer("AutoPick", {
|
||||||
"forceInteraction": true
|
"forceInteraction": true
|
||||||
}));
|
}));
|
||||||
log.info(`当前次数:${i + 1}/${runTimes}`);
|
await genshin.relogin();
|
||||||
await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`);
|
|
||||||
// 关闭急速拾取
|
// OCR识别是否触发任务
|
||||||
dispatcher.addTimer(new RealtimeTimer("AutoPick", {
|
let ocrStatus = false;
|
||||||
"forceInteraction": false
|
for (let c = 0; c < 3; c++) {
|
||||||
}));
|
let captureRegion = captureGameRegion();
|
||||||
// 判定本轮循环是否执行完毕
|
let resList = captureRegion.findMulti(RecognitionObject.ocr(0, 200, 300, 300));
|
||||||
if (await comparePosition()) {
|
for (let o = 0; o < resList.count; o++) {
|
||||||
log.info(`已完成次数:${i + 1}/${runTimes}`);
|
let res = resList[o];
|
||||||
|
if (res.text.includes("打倒") || res.text.includes("所有") || res.text.includes("鳄") || res.text.includes("鱼") || res.text.includes("张牙") || res.text.includes("舞爪") || res.text.includes("的") || res.text.includes("恶党")) {
|
||||||
|
ocrStatus = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ocrStatus) {
|
||||||
|
log.info(`当前次数:${i + 1}/${runTimes}`);
|
||||||
|
await AutoPath(`好感-张牙舞爪的恶党-循环${GetMeatMode ? '(二净甸刷肉版)' : '(二净甸)'}`);
|
||||||
|
// 关闭急速拾取
|
||||||
|
dispatcher.addTimer(new RealtimeTimer("AutoPick", {
|
||||||
|
"forceInteraction": false
|
||||||
|
}));
|
||||||
|
// 判定本轮循环是否执行完毕
|
||||||
|
if (await comparePosition()) {
|
||||||
|
log.info(`已完成次数:${i + 1}/${runTimes}`);
|
||||||
|
} else {
|
||||||
|
i = i - 1; // 退回这次次数
|
||||||
|
log.warn(`判定本轮循环执行失败,退回本轮执行次数:${i + 1}/${runTimes}`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
i = i - 1; // 退回这次次数
|
break;
|
||||||
log.warn(`判定本轮循环执行失败,退回本轮执行次数:${i + 1}/${runTimes}`);
|
|
||||||
}
|
}
|
||||||
const estimatedCompletion = calculateEstimatedCompletion(startTime, i + 1, runTimes);
|
const estimatedCompletion = calculateEstimatedCompletion(startTime, i + 1, runTimes);
|
||||||
logTimeTaken(startTime);
|
logTimeTaken(startTime);
|
||||||
@@ -114,6 +133,8 @@
|
|||||||
// 神像相关参数
|
// 神像相关参数
|
||||||
let goStatue = settings.goStatue ? settings.goStatue : false;
|
let goStatue = settings.goStatue ? settings.goStatue : false;
|
||||||
let statueTimes = goStatue ? (isNaN(settings.statueTimes) ? 5 : settings.statueTimes) : 0;
|
let statueTimes = goStatue ? (isNaN(settings.statueTimes) ? 5 : settings.statueTimes) : 0;
|
||||||
|
// 延迟相关
|
||||||
|
let delayTime = settings.delayTime ? settings.delayTime * 1000 : 0;
|
||||||
// 卡时间相关参数
|
// 卡时间相关参数
|
||||||
if (settings.waitTimeMode) {
|
if (settings.waitTimeMode) {
|
||||||
let maxTimes = settings.maxTimes ? settings.maxTimes : runTimes;
|
let maxTimes = settings.maxTimes ? settings.maxTimes : runTimes;
|
||||||
@@ -170,7 +191,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
await AutoFriendship(runTimes, statueTimes, GetMeatMode, startTime);
|
await AutoFriendship(runTimes, statueTimes, GetMeatMode, delayTime, startTime);
|
||||||
log.info(`兽肉好感运行总时长:${logTimeTaken(startTime)}`);
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 1,
|
"manifest_version": 1,
|
||||||
"name": "兽肉好感:自动好感度&刷两只鳄鱼兽肉&卡时间",
|
"name": "兽肉好感:自动好感度&刷两只鳄鱼兽肉&卡时间",
|
||||||
"version": "1.3.3",
|
"version": "1.3.4",
|
||||||
"description": "通过突发事件:张牙舞爪的恶党刷兽肉,并顺带获取好感度(好感度超过10次后不再获取),请使用满员好感度队伍,并为全体队伍角色配置相应的战斗策略",
|
"description": "通过突发事件:张牙舞爪的恶党刷兽肉,并顺带获取好感度(好感度超过10次后不再获取),请使用满员好感度队伍,并为全体队伍角色配置相应的战斗策略",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "起个名字好难的喵"
|
"name": "起个名字好难的喵",
|
||||||
|
"links":"https://github.com/MisakaAldrich"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings_ui": "settings.json",
|
"settings_ui": "settings.json",
|
||||||
|
|||||||
@@ -43,5 +43,10 @@
|
|||||||
"name": "statueTimes",
|
"name": "statueTimes",
|
||||||
"type": "input-text",
|
"type": "input-text",
|
||||||
"label": "返回神像周期(选填,默认为5次/循环)"
|
"label": "返回神像周期(选填,默认为5次/循环)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "delayTime",
|
||||||
|
"type": "input-text",
|
||||||
|
"label": "到达触发地点后的延迟时间(秒)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user