js:千星奇域循环 (#2211)
* js:千星奇域循环 用于循环进入指定千星奇域关卡刷经验/完成纪行(氨气艾草) * Delete 狗粮.zip * Update repo/js/1000StarsLoop/main.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: 躁动的氨气 <131591012+zaodonganqi@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/全部奇域.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/前往大厅.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/开始游戏.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/搜索.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/搜索奇域.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/确认返回.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/返回大厅.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/返回提瓦特.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
repo/js/1000StarsLoop/assets/RecognitionObject/进入.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
86
repo/js/1000StarsLoop/main.js
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
// 主逻辑
|
||||||
|
let content = settings.content || "7108700065";
|
||||||
|
let maxAttempts = (+settings.maxAttempts) || 15;
|
||||||
|
let delay = (+settings.delay) || 250;
|
||||||
|
let attempts = 0;
|
||||||
|
let entered = false;
|
||||||
|
(async function () {
|
||||||
|
|
||||||
|
//循环指定次数
|
||||||
|
while (attempts < maxAttempts) {
|
||||||
|
await genshin.returnMainUi();
|
||||||
|
attempts++;
|
||||||
|
log.info(`开始第${attempts}次循环`);
|
||||||
|
await sleep(2000);
|
||||||
|
keyPress("F6");
|
||||||
|
await sleep(250);
|
||||||
|
if (!await ClickPNG("全部奇域")) {
|
||||||
|
await sleep(250);
|
||||||
|
await genshin.returnMainUi();
|
||||||
|
keyPress("F6");
|
||||||
|
if (!await ClickPNG("全部奇域")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await sleep(250);
|
||||||
|
if (!await ClickPNG("搜索奇域")) continue;
|
||||||
|
await sleep(250);
|
||||||
|
log.info(`搜索${content}`);
|
||||||
|
await sleep(1000);
|
||||||
|
inputText(content);
|
||||||
|
await sleep(500);
|
||||||
|
if (!await ClickPNG("搜索")) continue;
|
||||||
|
await sleep(250);
|
||||||
|
const result = await ClickPNG("进入");
|
||||||
|
await sleep(250);
|
||||||
|
//log.info(`结果是${result}`);
|
||||||
|
if (!result) {
|
||||||
|
log.warn("未找到标识,尝试点击固定位置");
|
||||||
|
click(400, 300);
|
||||||
|
}
|
||||||
|
await sleep(250);
|
||||||
|
if (!entered) {
|
||||||
|
entered = await ClickPNG("前往大厅");
|
||||||
|
if (!await ClickPNG("开始游戏", 600)) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
entered = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await sleep(250);
|
||||||
|
await ClickPNG("开始游戏")
|
||||||
|
}
|
||||||
|
await sleep(250);
|
||||||
|
if (!await ClickPNG("返回大厅", 600)) continue;
|
||||||
|
await sleep(250);
|
||||||
|
}
|
||||||
|
if (settings.returnGenshin) {
|
||||||
|
log.info("勾选了返回提瓦特,开始返回");
|
||||||
|
await genshin.returnMainUi();
|
||||||
|
await sleep(1000);
|
||||||
|
keyPress("F2");
|
||||||
|
await ClickPNG("返回提瓦特");
|
||||||
|
await ClickPNG("确认返回");
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
async function ClickPNG(png, maxAttempts = 40) {
|
||||||
|
log.info(`尝试找到并点击${png},等待至多${maxAttempts * 50}毫秒`);
|
||||||
|
moveMouseTo(1920, 1080);
|
||||||
|
const pngRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync(`assets/RecognitionObject/${png}.png`));
|
||||||
|
pngRo.Threshold = 0.95;
|
||||||
|
pngRo.InitTemplate();
|
||||||
|
return await findAndClick(pngRo, maxAttempts);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function findAndClick(target, maxAttempts = 5) {
|
||||||
|
for (let i = 0; i < maxAttempts; i++) {
|
||||||
|
const rg = captureGameRegion();
|
||||||
|
try {
|
||||||
|
const res = rg.find(target);
|
||||||
|
if (res.isExist()) { await sleep(delay); res.click(); return true; }
|
||||||
|
} finally { rg.dispose(); }
|
||||||
|
if (i < maxAttempts - 1) await sleep(50);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
14
repo/js/1000StarsLoop/manifest.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"manifest_version": 1,
|
||||||
|
"name": "千星奇域循环",
|
||||||
|
"version": "1.0",
|
||||||
|
"description": "重复进入指定千星奇域关卡并循环一定次数",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "mno"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": "千星奇域",
|
||||||
|
"settings_ui": "settings.json",
|
||||||
|
"main": "main.js"
|
||||||
|
}
|
||||||
25
repo/js/1000StarsLoop/settings.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "content",
|
||||||
|
"type": "input-text",
|
||||||
|
"label": "输入搜索内容(名称或GUID)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "maxAttempts",
|
||||||
|
"type": "input-text",
|
||||||
|
"label": "循环次数",
|
||||||
|
"default": 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "returnGenshin",
|
||||||
|
"type": "checkbox",
|
||||||
|
"label": "结束后是否返回提瓦特",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "delay",
|
||||||
|
"type": "input-text",
|
||||||
|
"label": "按键延迟(毫秒),观察到卡住时适当调大",
|
||||||
|
"default": 250
|
||||||
|
}
|
||||||
|
]
|
||||||