js:自动新消除 (#2795)
* js:狗粮批发2.0.2 修复了一个bug * js:自动新消除 自动点击并消除背包内指定类型物品的新 * Update manifest.json * Update main.js * js:锄地一条龙 修0006飞萤坠崖
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"info": {
|
||||
"authors": [
|
||||
{
|
||||
@@ -10,7 +10,7 @@
|
||||
"description": " 路线信息:该路线预计用时79.28秒,包含以下怪物:2只冰萤。",
|
||||
"enable_monster_loot_split": false,
|
||||
"hash_res": "26420463",
|
||||
"last_modified_time": 1767795932902,
|
||||
"last_modified_time": 1769453868704,
|
||||
"map_match_method": "",
|
||||
"map_name": "Teyvat",
|
||||
"name": "0006-蒙德-龙脊雪山-七天神像-西南-2只",
|
||||
@@ -31,27 +31,36 @@
|
||||
"y": 1174.619999999999
|
||||
},
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"action": "combat_script",
|
||||
"action_params": "wait(0.01)",
|
||||
"id": 2,
|
||||
"move_mode": "dash",
|
||||
"type": "path",
|
||||
"x": -1005.9500000000007,
|
||||
"y": 1155.5200000000004
|
||||
"x": -1008.310546875,
|
||||
"y": 1157.47998046875
|
||||
},
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"action": "combat_script",
|
||||
"action_params": "wait(0.01)",
|
||||
"id": 3,
|
||||
"move_mode": "dash",
|
||||
"type": "path",
|
||||
"x": -1003.861328125,
|
||||
"y": 1122.25048828125
|
||||
"x": -1005.822265625,
|
||||
"y": 1147.86767578125
|
||||
},
|
||||
{
|
||||
"action": "combat_script",
|
||||
"action_params": "wait(0.01)",
|
||||
"id": 4,
|
||||
"move_mode": "dash",
|
||||
"type": "path",
|
||||
"x": -1001.783203125,
|
||||
"y": 1138.103515625
|
||||
},
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 4,
|
||||
"id": 5,
|
||||
"move_mode": "jump",
|
||||
"type": "target",
|
||||
"x": -1004.3984375,
|
||||
@@ -60,7 +69,7 @@
|
||||
{
|
||||
"action": "combat_script",
|
||||
"action_params": "keypress(w);希诺宁 attack(0.3),e,keydown(w);玛薇卡 attack(0.3),e(hold),keydown(w);wait(2.5)",
|
||||
"id": 5,
|
||||
"id": 6,
|
||||
"move_mode": "jump",
|
||||
"type": "orientation",
|
||||
"x": -992.5,
|
||||
@@ -69,7 +78,7 @@
|
||||
{
|
||||
"action": "combat_script",
|
||||
"action_params": "wait(0.5)",
|
||||
"id": 6,
|
||||
"id": 7,
|
||||
"move_mode": "jump",
|
||||
"type": "path",
|
||||
"x": -992.5,
|
||||
@@ -78,7 +87,7 @@
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 7,
|
||||
"id": 8,
|
||||
"move_mode": "jump",
|
||||
"type": "path",
|
||||
"x": -977.8100000000013,
|
||||
@@ -87,7 +96,7 @@
|
||||
{
|
||||
"action": "fight",
|
||||
"action_params": "",
|
||||
"id": 8,
|
||||
"id": 9,
|
||||
"move_mode": "dash",
|
||||
"type": "path",
|
||||
"x": -966.9000000000015,
|
||||
@@ -96,7 +105,7 @@
|
||||
{
|
||||
"action": "combat_script",
|
||||
"action_params": "wait(1)",
|
||||
"id": 9,
|
||||
"id": 10,
|
||||
"move_mode": "walk",
|
||||
"type": "orientation",
|
||||
"x": -966.8899999999994,
|
||||
|
||||
1
repo/js/AutoNewsKiller/README.md
Normal file
@@ -0,0 +1 @@
|
||||
1. 适配1080p分辨率,其他分辨率不能使用属于正常现象,能够使用纯属巧合
|
||||
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/到底了.png
Normal file
|
After Width: | Height: | Size: 281 B |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/新.png
Normal file
|
After Width: | Height: | Size: 995 B |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/确认.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/筛选1.png
Normal file
|
After Width: | Height: | Size: 973 B |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/筛选2.png
Normal file
|
After Width: | Height: | Size: 924 B |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/任务1.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/任务2.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/养成道具1.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/养成道具2.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/圣遗物1.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/圣遗物2.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/小道具1.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/小道具2.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/摆设1.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/摆设2.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/材料1.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/材料2.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/武器1.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/武器2.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/贵重道具1.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/贵重道具2.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/食物1.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/背包界面/食物2.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
repo/js/AutoNewsKiller/assets/RecognitionObject/重置.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
25
repo/js/AutoNewsKiller/assets/滚轮下翻.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"macroEvents": [
|
||||
{
|
||||
"type": 6,
|
||||
"mouseX": 0,
|
||||
"mouseY": -300,
|
||||
"time": 0
|
||||
},
|
||||
{
|
||||
"type": 6,
|
||||
"mouseX": 0,
|
||||
"mouseY": 0,
|
||||
"time": 1
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"name": "",
|
||||
"description": "模拟鼠标滚轮向上滚动300单位",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"recordDpi": 1
|
||||
}
|
||||
}
|
||||
157
repo/js/AutoNewsKiller/main.js
Normal file
@@ -0,0 +1,157 @@
|
||||
const bottomRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/RecognitionObject/到底了.png"), 1282, 934, 1296 - 1282, 945 - 934);
|
||||
bottomRo.Threshold = 0.9;
|
||||
bottomRo.InitTemplate();
|
||||
const newRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/RecognitionObject/新.png"), 184, 132, 1285 - 184, 953 - 132);
|
||||
newRo.Threshold = 0.8;
|
||||
newRo.InitTemplate();
|
||||
let newCount = 0;
|
||||
(async function () {
|
||||
await genshin.tpToStatueOfTheSeven();
|
||||
await genshin.returnMainUi();
|
||||
keyPress("B");
|
||||
|
||||
let types = Array.from(settings.executingTypes);
|
||||
if (types.includes("全选")) {
|
||||
types = ["武器",
|
||||
"圣遗物",
|
||||
"养成道具",
|
||||
"食物",
|
||||
"材料",
|
||||
"小道具",
|
||||
"任务",
|
||||
"贵重道具",
|
||||
"摆设"]
|
||||
}
|
||||
for (let type of types) {
|
||||
|
||||
if (await findAndClick([`assets/RecognitionObject/背包界面/${type}1.png`, `assets/RecognitionObject/背包界面/${type}2.png`])) {
|
||||
log.info(`成功进入${type}界面,开始执行`);
|
||||
} else {
|
||||
await genshin.returnMainUi();
|
||||
keyPress("B");
|
||||
if (await findAndClick([`assets/RecognitionObject/背包界面/${type}1.png`, `assets/RecognitionObject/背包界面/${type}2.png`])) {
|
||||
log.info(`成功进入${type}界面,开始执行`);
|
||||
} else {
|
||||
log.info(`进入${type}界面失败`);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (type === "圣遗物") {
|
||||
await findAndClick([`assets/RecognitionObject/筛选1.png`, `assets/RecognitionObject/筛选2.png`]);
|
||||
await sleep(300);
|
||||
moveMouseTo(960, 540);
|
||||
await findAndClick(`assets/RecognitionObject/重置.png`);
|
||||
await sleep(300);
|
||||
await findAndClick(`assets/RecognitionObject/确认.png`);
|
||||
await sleep(300);
|
||||
}
|
||||
let scrolls = 0;
|
||||
while (scrolls < 200) {
|
||||
scrolls++
|
||||
try { await sleep(1) } catch (e) { break; }
|
||||
while (true) {
|
||||
let newRes = await findAndClick(newRo, true, 300, 16, 1, 50, 50);
|
||||
if (newRes) {
|
||||
newRes.click();
|
||||
log.info(`在${newRes.x},${newRes.y}找到一个新`);
|
||||
newCount++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let bottomres = await findAndClick(bottomRo, false, 2, 3, 1);
|
||||
if (bottomres) {
|
||||
moveMouseTo(139, 910);
|
||||
await scrollDown(2);
|
||||
bottomres = await findAndClick(bottomRo, false, 2, 3, 1);
|
||||
if (bottomres) {
|
||||
log.info(`到底了,${type}类型处理完毕`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
moveMouseTo(139, 910);
|
||||
await scrollDown(2);
|
||||
}
|
||||
}
|
||||
log.info(`本次运行共点击 ${newCount} 个新`);
|
||||
})();
|
||||
|
||||
/**
|
||||
* 通用找图/找RO并可选点击(支持单图片文件路径、单RO、图片文件路径数组、RO数组)
|
||||
* @param {string|string[]|RecognitionObject|RecognitionObject[]} target
|
||||
* @param {boolean} [doClick=true] 是否点击
|
||||
* @param {number} [timeout=3000] 识别时间上限(ms)
|
||||
* @param {number} [interval=50] 识别间隔(ms)
|
||||
* @param {number} [retType=0] 0-返回布尔;1-返回 Region 结果
|
||||
* @param {number} [preClickDelay=50] 点击前等待
|
||||
* @param {number} [postClickDelay=50] 点击后等待
|
||||
* @returns {boolean|Region} 根据 retType 返回是否成功或最终 Region
|
||||
*/
|
||||
async function findAndClick(target,
|
||||
doClick = true,
|
||||
timeout = 3000,
|
||||
interval = 50,
|
||||
retType = 0,
|
||||
preClickDelay = 50,
|
||||
postClickDelay = 50) {
|
||||
try {
|
||||
// 1. 统一转成 RecognitionObject 数组
|
||||
let ros = [];
|
||||
if (Array.isArray(target)) {
|
||||
ros = target.map(t =>
|
||||
(typeof t === 'string')
|
||||
? RecognitionObject.TemplateMatch(file.ReadImageMatSync(t))
|
||||
: t
|
||||
);
|
||||
} else {
|
||||
ros = [(typeof target === 'string')
|
||||
? RecognitionObject.TemplateMatch(file.ReadImageMatSync(target))
|
||||
: target];
|
||||
}
|
||||
|
||||
const start = Date.now();
|
||||
let found = null;
|
||||
|
||||
while (Date.now() - start <= timeout) {
|
||||
const gameRegion = captureGameRegion();
|
||||
try {
|
||||
// 依次尝试每一个 ro
|
||||
for (const ro of ros) {
|
||||
const res = gameRegion.find(ro);
|
||||
if (!res.isEmpty()) { // 找到
|
||||
found = res;
|
||||
if (doClick) {
|
||||
await sleep(preClickDelay);
|
||||
res.click();
|
||||
await sleep(postClickDelay);
|
||||
}
|
||||
break; // 成功即跳出 for
|
||||
}
|
||||
}
|
||||
if (found) break; // 成功即跳出 while
|
||||
} finally {
|
||||
gameRegion.dispose();
|
||||
}
|
||||
await sleep(interval); // 没找到时等待
|
||||
}
|
||||
|
||||
// 3. 按需返回
|
||||
return retType === 0 ? !!found : (found || null);
|
||||
|
||||
} catch (error) {
|
||||
log.error(`执行通用识图时出现错误:${error.message}`);
|
||||
return retType === 0 ? false : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向下滚动lines行(调用一次滚轮下翻脚本)
|
||||
* @param {number} [lines=1] 需要滚动的行数,默认 1 行
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function scrollDown(lines = 1) {
|
||||
lines = lines * 10;
|
||||
for (let i = 0; i < lines; i++) {
|
||||
await keyMouseScript.runFile(`assets/滚轮下翻.json`);
|
||||
}
|
||||
}
|
||||
14
repo/js/AutoNewsKiller/manifest.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "点击消除新",
|
||||
"version": "1.0",
|
||||
"description": "点击消除背包中的新",
|
||||
"authors": [
|
||||
{
|
||||
"name": "mno",
|
||||
"links": "https://github.com/Bedrockx"
|
||||
}
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js"
|
||||
}
|
||||
22
repo/js/AutoNewsKiller/settings.json
Normal file
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"name": "executingTypes",
|
||||
"type": "multi-checkbox",
|
||||
"label": "要执行的物品种类",
|
||||
"default": [
|
||||
"圣遗物"
|
||||
],
|
||||
"options": [
|
||||
"全选",
|
||||
"武器",
|
||||
"圣遗物",
|
||||
"养成道具",
|
||||
"食物",
|
||||
"材料",
|
||||
"小道具",
|
||||
"任务",
|
||||
"贵重道具",
|
||||
"摆设"
|
||||
]
|
||||
}
|
||||
]
|
||||