锄地一条龙新增新区域路线和新材料适配 (#1908)

* js:锄地一条龙1.6.0

* js:锄地路线测试更新

增加新怪物的图鉴识别

* js:锄地一条龙

更正拾取逻辑
This commit is contained in:
mno
2025-09-15 09:21:06 +08:00
committed by GitHub
parent 5d5bf4a704
commit 1e6c28e771
69 changed files with 1724 additions and 470 deletions

View File

@@ -94,6 +94,9 @@
---
### 更新日志
### 1.6.02025.09.14
1.增加路线:挪德卡莱希汐岛区域
2.增加选项,可拾取新材料
### 1.5.12025.08.28
1.优化检测坐标判断路线运行成功的机制
### 1.5.02025.08.27

View File

@@ -267,6 +267,30 @@
"type": "首领",
"tags": []
},
{
"name": "灼烜·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "辉电·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蔓结·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "凌晶·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "丘丘人",
"moraRate": 1,
@@ -603,6 +627,22 @@
"type": "首领",
"tags": []
},
{
"name": "荒野幽徒",
"moraRate": 1,
"type": "精英",
"tags": [
"狂猎"
]
},
{
"name": "荒野狂狩士",
"moraRate": 2,
"type": "精英",
"tags": [
"狂猎"
]
},
{
"name": "愚人众先遣队·火统游击兵",
"moraRate": 1,
@@ -675,6 +715,108 @@
"type": "精英",
"tags": []
},
{
"name": "愚人众特辖队·线列军",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·支援兵",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·榴铳手",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·先锋士",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·疗愈师",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·掷弹兵",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·火刃突击队",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·冰雹重炮手",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·雷霰近卫军",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·近战攻坚型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·近战斥候型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·强侦攻坚型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·强侦斥候型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·强侦地效型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·尖端全能攻坚型",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·尖端全能斥候型",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·尖端火力地效型",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "遗迹守卫",
"moraRate": 1,
@@ -879,6 +1021,12 @@
"type": "首领",
"tags": []
},
{
"name": "重拳出击鸭",
"moraRate": 1,
"type": "首领",
"tags": []
},
{
"name": "盗宝团·斥候",
"moraRate": 1,
@@ -1759,6 +1907,30 @@
"type": "精英",
"tags": []
},
{
"name": "蕴光奇羊",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蕴光刃犀",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蕴光璇蛸",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蕴光月幻蝶",
"moraRate": 1,
"type": "首领",
"tags": []
},
{
"name": "裂空的魔龙",
"moraRate": 1,

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -1,4 +1,4 @@
//当前js版本 1.5.1
//当前js版本 1.6.0
//拾取时上下滑动的时间
let timeMoveUp;
@@ -63,11 +63,19 @@ let warnMessage = [];
const blacklistKeywords = ocrPickupJson["黑名单"];
targetItems = await readFolder(targetItemPath, false);
if (settings.enableNewTargets) {
const newItems = await readFolder('assets/newTargets', false);
// 逐个 push
for (const f of newItems) targetItems.push(f);
}
//模板匹配对象处理
if (pickupMode === "模板匹配拾取,默认只拾取狗粮") {
for (const targetItem of targetItems) {
targetItem.template = file.ReadImageMatSync(targetItem.fullPath);
targetItem.itemName = targetItem.fileName.replace(/\.png$/, '');
//log.info(targetItem.itemName);
}
}
timeMoveUp = Math.round(timeMove * 0.45);
@@ -624,7 +632,7 @@ async function runPath(pathFilePath, map_name, whitelistKeywords, blacklistKeywo
let itemName = null;
// 在捕获的区域内进行模板匹配识别
for (const targetItem of targetItems) {
let recognitionObject = RecognitionObject.TemplateMatch(targetItem.template, 1220, centerYF - 35, 70, 70);
let recognitionObject = RecognitionObject.TemplateMatch(targetItem.template, 1200, centerYF - 35, 160, 70);
result = gameRegion.find(recognitionObject);
if (result.isExist()) {
itemName = targetItem.itemName;

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "锄地一条龙",
"version": "1.5.1",
"version": "1.6.0",
"description": "一站式解决自动化锄地支持只拾取狗粮请仔细阅读README.md后使用",
"authors": [
{

View File

@@ -0,0 +1,159 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时206.68秒包含以下怪物5只雷史莱姆、2只变异雷史莱姆、3只打手丘丘人、1只木盾丘丘暴徒、2只蕴光奇羊。",
"enable_monster_loot_split": false,
"last_modified_time": 1757858338851,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7101挪德卡莱希汐岛西南",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10973.5283203125,
"y": 1682.45703125
},
{
"action": "fight",
"action_params": "",
"id": 2,
"move_mode": "dash",
"type": "path",
"x": 10992.5,
"y": 1706.75
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "dash",
"type": "path",
"x": 10987.556640625,
"y": 1743.72900390625
},
{
"action": "",
"action_params": "",
"id": 4,
"move_mode": "dash",
"type": "path",
"x": 11011.0546875,
"y": 1752.83837890625
},
{
"action": "fight",
"action_params": "",
"id": 5,
"move_mode": "dash",
"type": "path",
"x": 11069.8671875,
"y": 1775.5615234375
},
{
"action": "",
"action_params": "",
"id": 6,
"move_mode": "dash",
"type": "path",
"x": 11069.8671875,
"y": 1775.5615234375
},
{
"action": "fight",
"action_params": "",
"id": 7,
"move_mode": "jump",
"type": "path",
"x": 11076.4931640625,
"y": 1714.462890625
},
{
"action": "",
"action_params": "",
"id": 8,
"move_mode": "dash",
"type": "path",
"x": 11104.9423828125,
"y": 1717.1787109375
},
{
"action": "fight",
"action_params": "",
"id": 9,
"move_mode": "dash",
"type": "path",
"x": 11184.3173828125,
"y": 1687.4521484375
},
{
"action": "",
"action_params": "",
"id": 10,
"move_mode": "walk",
"type": "teleport",
"x": 11060.90234375,
"y": 1592.326171875
},
{
"action": "",
"action_params": "",
"id": 11,
"move_mode": "dash",
"type": "path",
"x": 11050.9375,
"y": 1577.4697265625
},
{
"action": "",
"action_params": "",
"id": 12,
"move_mode": "fly",
"type": "path",
"x": 11030.7431640625,
"y": 1556.23486328125
},
{
"action": "stop_flying",
"action_params": "",
"id": 13,
"move_mode": "fly",
"type": "path",
"x": 11046.912109375,
"y": 1542.6259765625
},
{
"action": "fight",
"action_params": "",
"id": 14,
"move_mode": "dash",
"type": "path",
"x": 11075.181640625,
"y": 1533.96875
},
{
"action": "fight",
"action_params": "",
"id": 15,
"move_mode": "dash",
"type": "path",
"x": 11075.181640625,
"y": 1533.96875
}
]
}

View File

@@ -0,0 +1,108 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时155.36秒包含以下怪物1只愚人众特辖队·先锋士、1只愚人众特辖队·掷弹兵、1只愚人众特辖队·雷霰近卫军、1只凌晶·霜夜灵嗣。",
"enable_monster_loot_split": false,
"last_modified_time": 1757850486965,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7102挪德卡莱希汐岛北1",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10789.009765625,
"y": 2277.678466796875
},
{
"action": "fight",
"action_params": "",
"id": 2,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10758.0146484375,
"y": 2311.341552734375
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "dash",
"type": "path",
"x": 10758.0146484375,
"y": 2311.341552734375
},
{
"action": "",
"action_params": "",
"id": 4,
"move_mode": "dash",
"type": "path",
"x": 10737.3251953125,
"y": 2375.56640625
},
{
"action": "fight",
"action_params": "",
"id": 5,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10735.4462890625,
"y": 2408.2099609375
},
{
"action": "",
"action_params": "",
"id": 6,
"move_mode": "dash",
"type": "path",
"x": 10735.4462890625,
"y": 2408.2099609375
},
{
"action": "",
"action_params": "",
"id": 7,
"move_mode": "dash",
"type": "path",
"x": 10707.880859375,
"y": 2478.90966796875
},
{
"action": "fight",
"action_params": "",
"id": 8,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10690.67578125,
"y": 2477.87353515625
},
{
"action": "combat_script",
"action_params": "wait(1)",
"id": 9,
"move_mode": "dash",
"type": "path",
"x": 10690.67578125,
"y": 2477.87353515625
}
]
}

View File

@@ -0,0 +1,79 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时99.36秒包含以下怪物3只丘丘风行游侠。",
"enable_monster_loot_split": false,
"last_modified_time": 1757850938960,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7103挪德卡莱希汐岛北2",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10789.009765625,
"y": 2277.678466796875
},
{
"action": "",
"action_params": "",
"id": 2,
"move_mode": "dash",
"type": "path",
"x": 10751.10546875,
"y": 2277.8349609375
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "dash",
"type": "path",
"x": 10754.814453125,
"y": 2233.7265625
},
{
"action": "",
"action_params": "",
"id": 4,
"move_mode": "jump",
"type": "path",
"x": 10754.66796875,
"y": 2223.5322265625
},
{
"action": "fight",
"action_params": "",
"id": 5,
"locked": false,
"move_mode": "walk",
"type": "path",
"x": 10763.3896484375,
"y": 2206.59228515625
},
{
"action": "combat_script",
"action_params": "wait(1)",
"id": 6,
"move_mode": "walk",
"type": "path",
"x": 10763.3896484375,
"y": 2206.59228515625
}
]
}

View File

@@ -0,0 +1,108 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时175.66秒包含以下怪物2只水史莱姆、2只冰史莱姆、2只嗜雷·兽境幼兽、2只荒野幽徒、2只蕴光璇蛸。",
"enable_monster_loot_split": false,
"last_modified_time": 1757851234855,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7104挪德卡莱希汐岛中1",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10828.3359375,
"y": 1936.04931640625
},
{
"action": "fight",
"action_params": "",
"id": 2,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10936.826171875,
"y": 1913.34521484375
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "dash",
"type": "path",
"x": 10936.826171875,
"y": 1913.34521484375
},
{
"action": "",
"action_params": "",
"id": 4,
"move_mode": "dash",
"type": "path",
"x": 10897.375,
"y": 1967.490234375
},
{
"action": "fight",
"action_params": "",
"id": 5,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10893.82421875,
"y": 2008.7529296875
},
{
"action": "",
"action_params": "",
"id": 6,
"move_mode": "dash",
"type": "path",
"x": 10893.82421875,
"y": 2008.7529296875
},
{
"action": "",
"action_params": "",
"id": 7,
"move_mode": "dash",
"type": "path",
"x": 10893.1669921875,
"y": 2064.507568359375
},
{
"action": "fight",
"action_params": "",
"id": 8,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10907.8076171875,
"y": 2067.474365234375
},
{
"action": "combat_script",
"action_params": "wait(1)",
"id": 9,
"move_mode": "dash",
"type": "orientation",
"x": 10907.8076171875,
"y": 2067.474365234375
}
]
}

View File

@@ -0,0 +1,180 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时181.77秒包含以下怪物2只水史莱姆、1只大型水史莱姆、2只凌晶·霜夜灵嗣。",
"enable_monster_loot_split": false,
"last_modified_time": 1757851601648,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7105挪德卡莱希汐岛中2",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10754.3466796875,
"y": 2061.1728515625
},
{
"action": "",
"action_params": "",
"id": 2,
"move_mode": "dash",
"type": "path",
"x": 10765.8232421875,
"y": 2056.236328125
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "dash",
"type": "path",
"x": 10775.8896484375,
"y": 2052.828125
},
{
"action": "",
"action_params": "",
"id": 4,
"move_mode": "dash",
"type": "path",
"x": 10783.970703125,
"y": 2044.412109375
},
{
"action": "fight",
"action_params": "",
"id": 5,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10750.9970703125,
"y": 2001.2412109375
},
{
"action": "combat_script",
"action_params": "wait(1)",
"id": 6,
"move_mode": "dash",
"type": "orientation",
"x": 10750.9970703125,
"y": 2001.2412109375
},
{
"action": "",
"action_params": "",
"id": 7,
"move_mode": "walk",
"type": "teleport",
"x": 10754.3466796875,
"y": 2061.171630859375
},
{
"action": "",
"action_params": "",
"id": 8,
"move_mode": "dash",
"type": "path",
"x": 10734.02734375,
"y": 2049.311767578125
},
{
"action": "stop_flying",
"action_params": "1500",
"id": 9,
"move_mode": "fly",
"type": "path",
"x": 10729.2509765625,
"y": 2046.77685546875
},
{
"action": "",
"action_params": "",
"id": 10,
"move_mode": "dash",
"type": "path",
"x": 10735.62109375,
"y": 2060.714111328125
},
{
"action": "fight",
"action_params": "",
"id": 11,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10752.8232421875,
"y": 2067.874267578125
},
{
"action": "",
"action_params": "",
"id": 12,
"move_mode": "dash",
"type": "path",
"x": 10752.8232421875,
"y": 2067.874267578125
},
{
"action": "",
"action_params": "",
"id": 13,
"move_mode": "dash",
"type": "path",
"x": 10768.83984375,
"y": 2075.16357421875
},
{
"action": "",
"action_params": "",
"id": 14,
"move_mode": "jump",
"type": "path",
"x": 10770.7138671875,
"y": 2092.34375
},
{
"action": "stop_flying",
"action_params": "",
"id": 15,
"move_mode": "fly",
"type": "path",
"x": 10773.4033203125,
"y": 2099.35302734375
},
{
"action": "fight",
"action_params": "",
"id": 16,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10780.1591796875,
"y": 2104.132080078125
},
{
"action": "combat_script",
"action_params": "wait(1)",
"id": 17,
"move_mode": "dash",
"type": "orientation",
"x": 10780.1591796875,
"y": 2104.132080078125
}
]
}

View File

@@ -0,0 +1,117 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时145.72秒包含以下怪物2只水史莱姆、1只大型水史莱姆、1只凌晶·霜夜灵嗣、1只愚人众特辖队·先锋士、1只愚人众特辖队·火刃突击队。",
"enable_monster_loot_split": false,
"last_modified_time": 1757854181778,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7106挪德卡莱希汐岛东南1",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10416.7421875,
"y": 1657.3515625
},
{
"action": "stop_flying",
"action_params": "200",
"id": 2,
"move_mode": "fly",
"type": "path",
"x": 10430.326171875,
"y": 1653.125
},
{
"action": "fight",
"action_params": "",
"id": 3,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10441.9521484375,
"y": 1653.94140625
},
{
"action": "",
"action_params": "",
"id": 4,
"move_mode": "dash",
"type": "path",
"x": 10441.9521484375,
"y": 1653.94140625
},
{
"action": "",
"action_params": "",
"id": 5,
"move_mode": "dash",
"type": "path",
"x": 10450.5322265625,
"y": 1667.5068359375
},
{
"action": "fight",
"action_params": "",
"id": 6,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10480.04296875,
"y": 1678.396484375
},
{
"action": "",
"action_params": "",
"id": 7,
"move_mode": "dash",
"type": "path",
"x": 10480.04296875,
"y": 1678.396484375
},
{
"action": "",
"action_params": "",
"id": 8,
"move_mode": "dash",
"type": "path",
"x": 10562.0859375,
"y": 1676.6083984375
},
{
"action": "fight",
"action_params": "",
"id": 9,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10584.279296875,
"y": 1729.9638671875
},
{
"action": "combat_script",
"action_params": "wait(1)",
"id": 10,
"move_mode": "dash",
"type": "orientation",
"x": 10584.279296875,
"y": 1729.9638671875
}
]
}

View File

@@ -0,0 +1,70 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时91.9秒包含以下怪物2只冰箭丘丘人、1只木盾丘丘暴徒、1只蕴光刃犀。",
"enable_monster_loot_split": false,
"last_modified_time": 1757854305966,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7107挪德卡莱希汐岛东南2",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10553.2548828125,
"y": 1793.7978515625
},
{
"action": "fight",
"action_params": "",
"id": 2,
"move_mode": "dash",
"type": "path",
"x": 10581.2626953125,
"y": 1815.0263671875
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "walk",
"type": "teleport",
"x": 10553.2548828125,
"y": 1793.7978515625
},
{
"action": "fight",
"action_params": "",
"id": 4,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10493.4130859375,
"y": 1802.5556640625
},
{
"action": "combat_script",
"action_params": "wait(1)",
"id": 5,
"move_mode": "dash",
"type": "orientation",
"x": 10493.4130859375,
"y": 1802.5556640625
}
]
}

View File

@@ -0,0 +1,79 @@
{
"info": {
"authors": [
{
"links": "",
"name": "mno"
}
],
"bgi_version": "0.45.0",
"description": " 路线信息该路线预计用时76.94秒包含以下怪物2只水史莱姆、1只蕴光璇蛸。",
"enable_monster_loot_split": false,
"last_modified_time": 1757854419993,
"map_match_method": "",
"map_name": "Teyvat",
"name": "7108挪德卡莱希汐岛东南3",
"tags": [
"挪德卡莱"
],
"type": "collect",
"version": "1.0"
},
"positions": [
{
"action": "",
"action_params": "",
"id": 1,
"move_mode": "walk",
"type": "teleport",
"x": 10524.8857421875,
"y": 1931.7197265625
},
{
"action": "",
"action_params": "",
"id": 2,
"move_mode": "dash",
"type": "path",
"x": 10571.5283203125,
"y": 1939.64404296875
},
{
"action": "",
"action_params": "",
"id": 3,
"move_mode": "walk",
"type": "path",
"x": 10600.79296875,
"y": 1952.7431640625
},
{
"action": "",
"action_params": "",
"id": 4,
"move_mode": "fly",
"type": "path",
"x": 10643.279296875,
"y": 1946.044921875
},
{
"action": "stop_flying",
"action_params": "",
"id": 5,
"move_mode": "fly",
"type": "path",
"x": 10641.3837890625,
"y": 1915.642578125
},
{
"action": "fight",
"action_params": "",
"id": 6,
"locked": false,
"move_mode": "dash",
"type": "path",
"x": 10642.470703125,
"y": 1907.181640625
}
]
}

View File

@@ -46,10 +46,15 @@
"default": "模板匹配拾取,默认只拾取狗粮"
},
{
"name": "rollingDelay",
"type": "input-text",
"label": "滚轮滚动后延时(毫秒),观察到漏捡时建议调大",
"default": "25"
"name": "disableSelfOptimization",
"type": "checkbox",
"label": "勾选后禁用根据运行记录优化路线选择的功能\n完全使用路线原有信息"
},
{
"name": "enableNewTargets",
"type": "checkbox",
"label": "勾选后使用模板匹配拾取模式时将会拾取新材料\n默认为挪德卡莱地区所有怪物材料\n可在assets/newTargets文件中查看并调整",
"default": "true"
},
{
"name": "pickupDelay",

View File

@@ -217,6 +217,30 @@
"type": "首领",
"tags": []
},
{
"name": "灼烜·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "辉电·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蔓结·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "凌晶·霜夜灵嗣",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "丘丘人",
"moraRate": 1,
@@ -543,7 +567,9 @@
"name": "深邃拟覆叶",
"moraRate": 3,
"type": "精英",
"tags": ["次数盾"]
"tags": [
"次数盾"
]
},
{
"name": "深邃摹结株",
@@ -551,6 +577,22 @@
"type": "首领",
"tags": []
},
{
"name": "荒野幽徒",
"moraRate": 1,
"type": "精英",
"tags": [
"狂猎"
]
},
{
"name": "荒野狂狩士",
"moraRate": 2,
"type": "精英",
"tags": [
"狂猎"
]
},
{
"name": "愚人众先遣队·火统游击兵",
"moraRate": 1,
@@ -623,6 +665,108 @@
"type": "精英",
"tags": []
},
{
"name": "愚人众特辖队·线列军",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·支援兵",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·榴铳手",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·先锋士",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·疗愈师",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·掷弹兵",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·火刃突击队",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·冰雹重炮手",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "愚人众特辖队·雷霰近卫军",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·近战攻坚型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·近战斥候型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·强侦攻坚型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·强侦斥候型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·强侦地效型",
"moraRate": 1,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·尖端全能攻坚型",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·尖端全能斥候型",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "巡陆艇·尖端火力地效型",
"moraRate": 2,
"type": "普通",
"tags": []
},
{
"name": "遗迹守卫",
"moraRate": 1,
@@ -827,6 +971,12 @@
"type": "首领",
"tags": []
},
{
"name": "重拳出击鸭",
"moraRate": 1,
"type": "首领",
"tags": []
},
{
"name": "盗宝团·斥候",
"moraRate": 1,
@@ -1707,6 +1857,30 @@
"type": "精英",
"tags": []
},
{
"name": "蕴光奇羊",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蕴光刃犀",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蕴光璇蛸",
"moraRate": 1,
"type": "精英",
"tags": []
},
{
"name": "蕴光月幻蝶",
"moraRate": 1,
"type": "首领",
"tags": []
},
{
"name": "裂空的魔龙",
"moraRate": 1,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,461 +1,3 @@
// 定义替换映射表
const replacementMap = {
"监": "盐",
"卵": "卯"
};
async function readFolder(folderPath, onlyJson) {
log.info(`开始读取文件夹:${folderPath}`);
// 新增一个堆栈,初始时包含 folderPath
const folderStack = [folderPath];
// 新增一个数组,用于存储文件信息对象
const files = [];
// 当堆栈不为空时,继续处理
while (folderStack.length > 0) {
// 从堆栈中弹出一个路径
const currentPath = folderStack.pop();
// 读取当前路径下的所有文件和子文件夹路径
const filesInSubFolder = file.ReadPathSync(currentPath);
// 临时数组,用于存储子文件夹路径
const subFolders = [];
for (const filePath of filesInSubFolder) {
if (file.IsFolder(filePath)) {
// 如果是文件夹,先存储到临时数组中
subFolders.push(filePath);
} else {
// 如果是文件,根据 onlyJson 判断是否存储
if (onlyJson) {
if (filePath.endsWith(".json")) {
const fileName = filePath.split('\\').pop(); // 提取文件名
const folderPathArray = filePath.split('\\').slice(0, -1); // 提取文件夹路径数组
files.push({
fullPath: filePath,
fileName: fileName,
folderPathArray: folderPathArray
});
//log.info(`找到 JSON 文件:${filePath}`);
}
} else {
const fileName = filePath.split('\\').pop(); // 提取文件名
const folderPathArray = filePath.split('\\').slice(0, -1); // 提取文件夹路径数组
files.push({
fullPath: filePath,
fileName: fileName,
folderPathArray: folderPathArray
});
//log.info(`找到文件:${filePath}`);
}
}
}
// 将临时数组中的子文件夹路径按原顺序压入堆栈
folderStack.push(...subFolders.reverse()); // 反转子文件夹路径
}
return files;
}
async function getMonsterCounts() {
// 初始化结果对象
const monsterCounts = {};
async function scrollPage(totalDistance, stepDistance = 10, delayMs = 5) {
moveMouseTo(400, 750); // 移动到屏幕水平中心垂直750坐标
await sleep(50);
leftButtonDown();
// 计算滚动方向和总步数
const isDownward = totalDistance < 0; // 如果totalDistance为负数则向下滑动
const steps = Math.ceil(Math.abs(totalDistance) / stepDistance); // 使用绝对值计算步数
for (let j = 0; j < steps; j++) {
const remainingDistance = Math.abs(totalDistance) - j * stepDistance;
const moveDistance = remainingDistance < stepDistance ? remainingDistance : stepDistance;
// 根据滚动方向调整移动方向
const direction = isDownward ? 1 : -1; // 向下滑动为正方向,向上滑动为负方向
moveMouseBy(0, 1.2 * direction * moveDistance); // 根据方向调整滚动方向
await sleep(delayMs);
}
await sleep(200);
leftButtonUp();
await sleep(100);
}
await genshin.returnMainUi(); // 返回主界面
keyPress("VK_ESCAPE"); // 打开派蒙菜单
await sleep(1500); // 等待1.5秒
// 1. 识别并点击【图鉴】
const archiveTemplate = RecognitionObject.TemplateMatch(
file.readImageMatSync("assets/RecognitionObject/图鉴.png"),
0, 0, 1920, 1080
);
const archiveRegion = captureGameRegion().find(archiveTemplate);
if (!archiveRegion.isEmpty()) {
archiveRegion.click();
}
await sleep(3000); // 等待3秒
// 2. 识别并点击【生物志】
const faunaTemplate = RecognitionObject.TemplateMatch(
file.readImageMatSync("assets/RecognitionObject/生物志.png"),
0, 0, 1920, 1080
);
const faunaRegion = captureGameRegion().find(faunaTemplate);
if (!faunaRegion.isEmpty()) {
faunaRegion.click();
}
await sleep(400);
click(1355, 532);
await sleep(2000); // 等待2秒
// 3. 循环处理怪物识别
// 读取 name.txt 文件中的怪物名称列表
const monsterList = file.readTextSync("assets/name.txt").split('\n').filter(name => name.trim() !== '');
let monsterNum = 1;
let previousMonsterCount = -1;
let failCount = 0;
for (let i = 0; i < monsterList.length; i++) {
const monsterId = monsterList[i];
let monsterRegion = null;
let pageTurnsUp = 0;
while (pageTurnsUp < 5) {
let pageTurns = 0;
while (pageTurns < 5) {
let tryTimes = 0;
while (tryTimes < 5) {
// 4a. 识别怪物图片
const monsterTemplate = RecognitionObject.TemplateMatch(
file.readImageMatSync(`assets/monster/${monsterId.trim()}.png`),
0, 0, 1920, 1080
);
monsterRegion = captureGameRegion().find(monsterTemplate);
if (!monsterRegion.isEmpty()) {
break; // 识别到怪物,跳出翻页循环
}
//未识别到时重试
tryTimes++;
}
if (!monsterRegion.isEmpty()) {
break; // 识别到怪物,跳出翻页循环
}
// 未识别到则向下翻页
await scrollPage(300); // 调用翻页函数
pageTurns++;
}
if (!monsterRegion.isEmpty()) {
break; // 识别到怪物,跳出翻页循环
}
// 未识别到则向上翻页
await scrollPage(-1800); // 调用翻页函数
pageTurnsUp++;
}
if (!monsterRegion || monsterRegion.isEmpty()) {
log.info(`怪物: ${monsterId.trim()}, 没有找到`);
monsterCounts[monsterId.trim()] = -1;
continue; // 达到翻页上限仍未找到,处理下一个怪物
}
monsterRegion.click(); // 点击怪物图标
await sleep(10); // 等待界面加载
// 4b. 识别数量区域870,1000,100,30
const countRegion = new ImageRegion(
captureGameRegion().SrcMat,
830, 980,
null, // owner 参数设置为 null
null, // converter 参数设置为 null
null // drawContent 参数设置为 null
);
// 创建OCR识别对象
const ocrObject = RecognitionObject.Ocr(830, 980, 140, 70);
const countResults = countRegion.findMulti(ocrObject);
let monsterCount = "-1";
if (countResults.count > 0) {
for (let i = 0; i < countResults.count; i++) {
const text = countResults[i].text;
const numbers = text.match(/\d+/);
if (numbers) {
monsterCount = numbers[0];
break;
}
}
}
if ((monsterCount === -1 || monsterCount === previousMonsterCount) && failCount <= 5) {
log.warn(`识别失败或结果与上次相同,重新识别第 ${i + 1} 个怪物 ${monsterId}`);
i--; // 将索引减 1使得下一次循环重新执行当前索引
failCount++;//失败计数加一
continue; // 跳过当前迭代的剩余部分
} else {
failCount = 0;//重置失败计数
}
previousMonsterCount = monsterCount;
// 4c. 输出日志
log.info(`NO.${monsterNum} 怪物名称: ${monsterId.trim()}, 数量: ${monsterCount}`);
monsterNum++;
// 4d. 存储结果到对象
monsterCounts[monsterId.trim()] = monsterCount;
}
return monsterCounts;
}
// 定义所有图标的图像识别对象,每个图片都有自己的识别区域
let CharacterMenuRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/CharacterMenu.png"), 60, 991, 38, 38);
// 定义一个函数用于识别图像
async function recognizeImage(recognitionObject, timeout = 5000) {
log.info(`开始图像识别,超时时间: ${timeout}ms`);
let startTime = Date.now();
while (Date.now() - startTime < timeout) {
try {
// 尝试识别图像
let imageResult = captureGameRegion().find(recognitionObject);
if (imageResult) {
log.info(`成功识别图像,坐标: x=${imageResult.x}, y=${imageResult.y}`);
return { success: true, x: imageResult.x, y: imageResult.y };
}
} catch (error) {
log.error(`识别图像时发生异常: ${error.message}`);
}
await sleep(500); // 短暂延迟,避免过快循环
}
log.warn(`经过多次尝试,仍然无法识别图像`);
return { success: false };
}
// 定义一个函数用于识别文字并点击
async function recognizeTextAndClick(targetText, ocrRegion, timeout = 5000) {
log.info(`开始文字识别,目标文本: ${targetText},区域: x=${ocrRegion.x}, y=${ocrRegion.y}, width=${ocrRegion.width}, height=${ocrRegion.height}`);
let startTime = Date.now();
while (Date.now() - startTime < timeout) {
try {
// 尝试 OCR 识别
let resList = captureGameRegion().findMulti(RecognitionObject.ocr(ocrRegion.x, ocrRegion.y, ocrRegion.width, ocrRegion.height)); // 指定识别区域
// 遍历识别结果,检查是否找到目标文本
for (let res of resList) {
// 后处理:根据替换映射表检查和替换错误识别的字符
let correctedText = res.text;
for (let [wrongChar, correctChar] of Object.entries(replacementMap)) {
correctedText = correctedText.replace(new RegExp(wrongChar, 'g'), correctChar);
}
if (correctedText.includes(targetText)) {
// 如果找到目标文本,计算并点击文字的中心坐标
let centerX = res.x + res.width / 2;
let centerY = res.y + res.height / 2;
log.info(`识别到目标文本: ${correctedText},点击坐标: x=${centerX}, y=${centerY}`);
await click(centerX, centerY);
await sleep(500); // 确保点击后有足够的时间等待
return { success: true, x: centerX, y: centerY };
}
}
} catch (error) {
log.warn(`页面标志识别失败,正在进行重试... 错误信息: ${error.message}`);
}
await sleep(1000); // 短暂延迟,避免过快循环
}
log.warn(`经过多次尝试,仍然无法识别文字: ${targetText}`);
return { success: false };
}
// 定义一个独立的函数用于在指定区域进行 OCR 识别并输出识别内容
async function recognizeTextInRegion(ocrRegion, timeout = 5000) {
log.info(`开始 OCR 识别,区域: x=${ocrRegion.x}, y=${ocrRegion.y}, width=${ocrRegion.width}, height=${ocrRegion.height}`);
let startTime = Date.now();
while (Date.now() - startTime < timeout) {
try {
// 在指定区域进行 OCR 识别
let ocrResult = captureGameRegion().find(RecognitionObject.ocr(ocrRegion.x, ocrRegion.y, ocrRegion.width, ocrRegion.height));
if (ocrResult) {
log.info(`OCR 识别成功,原始文本: ${ocrResult.text}`);
// 后处理:根据替换映射表检查和替换错误识别的字符
let correctedText = ocrResult.text;
for (let [wrongChar, correctChar] of Object.entries(replacementMap)) {
correctedText = correctedText.replace(new RegExp(wrongChar, 'g'), correctChar);
}
log.info(`修正后文本: ${correctedText}`);
return correctedText; // 返回识别到的内容
} else {
log.warn(`OCR 识别区域未找到内容`);
return null; // 如果 OCR 未识别到内容,返回 null
}
} catch (error) {
log.error(`OCR 摩拉数识别失败,错误信息: ${error.message}`);
}
await sleep(500); // 短暂延迟,避免过快循环
}
log.warn(`经过多次尝试,仍然无法在指定区域识别到文字`);
return null; // 如果未识别到文字,返回 null
}
// 定义 mora 函数
async function mora() {
log.info("开始执行 mora 函数");
// 设置游戏分辨率和 DPI 缩放比例
setGameMetrics(1920, 1080, 1);
log.info("游戏分辨率和 DPI 设置完成");
// 返回游戏主界面
await genshin.returnMainUi();
log.info("返回游戏主界面");
// 按下 C 键
keyPress("C");
log.info("按下 C 键");
await sleep(1500);
let recognized = false;
// 识别“角色菜单”图标或“天赋”文字
let startTime = Date.now();
while (Date.now() - startTime < 5000) {
// 尝试识别“角色菜单”图标
let characterMenuResult = await recognizeImage(CharacterMenuRo, 5000);
if (characterMenuResult.success) {
await click(177, 433);
log.info("点击角色菜单图标");
await sleep(500);
recognized = true;
break;
}
// 尝试识别“天赋”文字
let targetText = "天赋";
let ocrRegion = { x: 133, y: 395, width: 115, height: 70 }; // 设置对应的识别区域
let talentResult = await recognizeTextAndClick(targetText, ocrRegion);
if (talentResult.success) {
log.info(`点击天赋文字,坐标: x=${talentResult.x}, y=${talentResult.y}`);
recognized = true;
break;
}
await sleep(1000); // 短暂延迟,避免过快循环
}
// 如果识别到了“角色菜单”或“天赋”,则识别“摩拉数值”
if (recognized) {
let ocrRegionMora = { x: 1620, y: 25, width: 152, height: 46 }; // 设置对应的识别区域
let recognizedText = await recognizeTextInRegion(ocrRegionMora);
if (recognizedText) {
log.info(`成功识别到摩拉数值: ${recognizedText}`);
return recognizedText; // 返回识别到的摩拉数值
} else {
log.warn("未能识别到摩拉数值。");
}
} else {
log.warn("未能识别到角色菜单或天赋,跳过摩拉数值识别。");
}
await sleep(500);
await genshin.returnMainUi();
log.info("返回游戏主界面");
return null; // 如果未能识别到摩拉数值,返回 null
}
// 定义自定义函数 basename用于获取文件名
function basename(filePath) {
const lastSlashIndex = filePath.lastIndexOf('\\'); // 或者使用 '/',取决于你的路径分隔符
return filePath.substring(lastSlashIndex + 1);
}
async function fakeLog(name, isJs, isStart, duration) {
await sleep(10);
const currentTime = Date.now();
// 参数检查
if (typeof name !== 'string') {
log.error("参数 'name' 必须是字符串类型!");
return;
}
if (typeof isJs !== 'boolean') {
log.error("参数 'isJs' 必须是布尔型!");
return;
}
if (typeof isStart !== 'boolean') {
log.error("参数 'isStart' 必须是布尔型!");
return;
}
if (typeof currentTime !== 'number' || !Number.isInteger(currentTime)) {
log.error("参数 'currentTime' 必须是整数!");
return;
}
if (typeof duration !== 'number' || !Number.isInteger(duration)) {
log.error("参数 'duration' 必须是整数!");
return;
}
// 将 currentTime 转换为 Date 对象并格式化为 HH:mm:ss.sss
const date = new Date(currentTime);
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
const formattedTime = `${hours}:${minutes}:${seconds}.${milliseconds}`;
// 将 duration 转换为分钟和秒,并保留三位小数
const durationInSeconds = duration / 1000; // 转换为秒
const durationMinutes = Math.floor(durationInSeconds / 60);
const durationSeconds = (durationInSeconds % 60).toFixed(3); // 保留三位小数
// 使用四个独立的 if 语句处理四种情况
if (isJs && isStart) {
// 处理 isJs = true 且 isStart = true 的情况
const logMessage = `正在伪造js开始的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 开始执行JS脚本: "${name}"`;
log.debug(logMessage);
}
if (isJs && !isStart) {
// 处理 isJs = true 且 isStart = false 的情况
const logMessage = `正在伪造js结束的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 脚本执行结束: "${name}", 耗时: ${durationMinutes}${durationSeconds}\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------`;
log.debug(logMessage);
}
if (!isJs && isStart) {
// 处理 isJs = false 且 isStart = true 的情况
const logMessage = `正在伪造地图追踪开始的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 开始执行地图追踪任务: "${name}"`;
log.debug(logMessage);
}
if (!isJs && !isStart) {
// 处理 isJs = false 且 isStart = false 的情况
const logMessage = `正在伪造地图追踪结束的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 脚本执行结束: "${name}", 耗时: ${durationMinutes}${durationSeconds}\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------`;
log.debug(logMessage);
}
}
// 主逻辑
(async function () {
const name1 = "锄地路线测试";
@@ -889,3 +431,454 @@ async function fakeLog(name, isJs, isStart, duration) {
const duration4 = 0; // JS 开始时,耗时为 0
await fakeLog(name1, true, true, duration4);
})();
async function readFolder(folderPath, onlyJson) {
log.info(`开始读取文件夹:${folderPath}`);
// 新增一个堆栈,初始时包含 folderPath
const folderStack = [folderPath];
// 新增一个数组,用于存储文件信息对象
const files = [];
// 当堆栈不为空时,继续处理
while (folderStack.length > 0) {
// 从堆栈中弹出一个路径
const currentPath = folderStack.pop();
// 读取当前路径下的所有文件和子文件夹路径
const filesInSubFolder = file.ReadPathSync(currentPath);
// 临时数组,用于存储子文件夹路径
const subFolders = [];
for (const filePath of filesInSubFolder) {
if (file.IsFolder(filePath)) {
// 如果是文件夹,先存储到临时数组中
subFolders.push(filePath);
} else {
// 如果是文件,根据 onlyJson 判断是否存储
if (onlyJson) {
if (filePath.endsWith(".json")) {
const fileName = filePath.split('\\').pop(); // 提取文件名
const folderPathArray = filePath.split('\\').slice(0, -1); // 提取文件夹路径数组
files.push({
fullPath: filePath,
fileName: fileName,
folderPathArray: folderPathArray
});
//log.info(`找到 JSON 文件:${filePath}`);
}
} else {
const fileName = filePath.split('\\').pop(); // 提取文件名
const folderPathArray = filePath.split('\\').slice(0, -1); // 提取文件夹路径数组
files.push({
fullPath: filePath,
fileName: fileName,
folderPathArray: folderPathArray
});
//log.info(`找到文件:${filePath}`);
}
}
}
// 将临时数组中的子文件夹路径按原顺序压入堆栈
folderStack.push(...subFolders.reverse()); // 反转子文件夹路径
}
return files;
}
async function getMonsterCounts() {
/* 0. 读取怪物列表 */
const raw = file.readTextSync('assets/info.json');
const monsterList = JSON.parse(raw).map(it => it.name);
const monsterCounts = {};
/* 1. 外层循环:最多 3 次进入生物志 */
let attempt = 0;
while (attempt < 3) {
attempt++;
log.info(`${attempt} 次尝试进入生物志`);
await genshin.returnMainUi();
keyPress('VK_ESCAPE');
await sleep(1500);
const archiveTpl = RecognitionObject.TemplateMatch(
file.readImageMatSync('assets/RecognitionObject/图鉴.png'), 0, 0, 1920, 1080);
if (!(await findAndClick(archiveTpl))) continue;
const faunaTpl = RecognitionObject.TemplateMatch(
file.readImageMatSync('assets/RecognitionObject/生物志.png'), 0, 0, 1920, 1080);
if (!(await findAndClick(faunaTpl))) continue;
click(1355, 532);
await sleep(2000);
break;
}
if (attempt >= 3) {
log.error('连续 3 次无法进入生物志,脚本终止');
await genshin.returnMainUi();
return {};
}
/* ===== 工具函数 ===== */
async function findAndClick(target, maxAttempts = 20) {
for (let attempts = 0; attempts < maxAttempts; attempts++) {
const gameRegion = captureGameRegion();
try {
const result = gameRegion.find(target);
if (result.isExist()) {
result.click();
return true; // 成功立刻返回
}
} catch (err) {
} finally {
gameRegion.dispose();
}
if (attempts < maxAttempts - 1) { // 最后一次不再 sleep
await sleep(50);
}
}
//log.error("已达到重试次数上限,仍未找到目标");
return false;
}
async function scrollPage(totalDistance, stepDistance = 10, delayMs = 5) {
moveMouseTo(400, 750); // 移动到屏幕水平中心垂直750坐标
await sleep(50);
leftButtonDown();
// 计算滚动方向和总步数
const isDownward = totalDistance < 0; // 如果totalDistance为负数则向下滑动
const steps = Math.ceil(Math.abs(totalDistance) / stepDistance); // 使用绝对值计算步数
for (let j = 0; j < steps; j++) {
const remainingDistance = Math.abs(totalDistance) - j * stepDistance;
const moveDistance = remainingDistance < stepDistance ? remainingDistance : stepDistance;
// 根据滚动方向调整移动方向
const direction = isDownward ? 1 : -1; // 向下滑动为正方向,向上滑动为负方向
moveMouseBy(0, 1.2 * direction * moveDistance); // 根据方向调整滚动方向
await sleep(delayMs);
}
await sleep(200);
leftButtonUp();
await sleep(500);
}
async function readKillCount(maxTry = 5) {
const ocrObj = RecognitionObject.Ocr(865, 980, 150, 50);
for (let t = 0; t < maxTry; t++) {
const region = captureGameRegion();
const results = region.findMulti(ocrObj);
region.dispose();
for (let i = 0; i < results.count; i++) {
const str = results[i].text.trim();
// 必须是纯数字
if (/^\d+$/.test(str)) {
return { success: true, count: parseInt(str, 10) };
}
}
if (t < maxTry - 1) await sleep(200); // 最后一次不重试
}
return { success: false, count: -1 };
}
async function readKillCountStable(prevCount, sameTolerance = 5) {
let lastCount = -1;
for (let r = 0; r < sameTolerance; r++) {
await sleep(50 * r);
//log.info(`执行第${r}次ocr`)
const ocrRet = await readKillCount(5);
if (!ocrRet.success) break; // 真的读不到数字就放弃
lastCount = ocrRet.count;
if (lastCount !== prevCount) return { success: true, count: lastCount }; // 变了→成功
}
// 3 次仍相同→返回最后一次相同值
return { success: true, count: lastCount };
}
async function findMonsterIcon(monsterId, iconRetry = 3) {
const tpl = RecognitionObject.TemplateMatch(
file.readImageMatSync(`assets/monster/${monsterId.trim()}.png`), 130, 80, 670, 970);
let pageTurnsUp = 0;
while (pageTurnsUp < 1) {
let pageTurns = 0;
while (pageTurns < 2) {
//log.info("执行一次模板识别");
if (await findAndClick(tpl, iconRetry)) return true;
await scrollPage(300);
pageTurns++;
}
for (let j = 0; j < 2; j++) {
await scrollPage(-300);
}
pageTurnsUp++;
}
return false;
}
/* ===== 主循环 ===== */
let prevCount = -1; // 上一轮 OCR 结果
let retryMask = 0; // 位掩码:第 i 位为 1 表示已回退过
let prevFinalCount = -1; // 上一只怪物的最终击杀数
for (let i = 0; i < monsterList.length; i++) {
const monsterId = monsterList[i];
let time0 = new Date();
/* 1. 找怪 + OCR */
if (!(await findMonsterIcon(monsterId, 3))) {
log.info(`怪物: ${monsterId.trim()}, 未找到图标`);
monsterCounts[monsterId.trim()] = -1;
prevCount = -1; // 重置
continue;
}
let time1 = new Date();
//log.info(`寻找图标用时${time1 - time0}`);
/* 2. OCR与上一只结果比较原地重试 3 次 */
const ocr = await readKillCountStable(prevFinalCount, 3);
const count = ocr.success ? ocr.count : -1;
let time2 = new Date();
//log.info(`ocr用时${time2 - time1}`);
/* 2. 结果相同且本行还没回退过 → 回退一次 */
if (count === prevCount && !(retryMask & (1 << i))) {
retryMask |= (1 << i); // 标记已回退
i--; // 回退同一 i 一次
continue;
}
/* 3. 正常记录 */
monsterCounts[monsterId.trim()] = count;
log.info(`怪物: ${monsterId.trim()}, 数量: ${count}`);
prevCount = count;
prevFinalCount = count; // 记录本次最终值,供下一只比对
}
return monsterCounts;
}
// 定义 mora 函数
async function mora() {
// 定义所有图标的图像识别对象,每个图片都有自己的识别区域
let CharacterMenuRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/CharacterMenu.png"), 60, 991, 38, 38);
// 定义一个函数用于识别图像
async function recognizeImage(recognitionObject, timeout = 5000) {
log.info(`开始图像识别,超时时间: ${timeout}ms`);
let startTime = Date.now();
while (Date.now() - startTime < timeout) {
try {
// 尝试识别图像
let imageResult = captureGameRegion().find(recognitionObject);
if (imageResult) {
log.info(`成功识别图像,坐标: x=${imageResult.x}, y=${imageResult.y}`);
return { success: true, x: imageResult.x, y: imageResult.y };
}
} catch (error) {
log.error(`识别图像时发生异常: ${error.message}`);
}
await sleep(500); // 短暂延迟,避免过快循环
}
log.warn(`经过多次尝试,仍然无法识别图像`);
return { success: false };
}
// 定义一个函数用于识别文字并点击
async function recognizeTextAndClick(targetText, ocrRegion, timeout = 5000) {
log.info(`开始文字识别,目标文本: ${targetText},区域: x=${ocrRegion.x}, y=${ocrRegion.y}, width=${ocrRegion.width}, height=${ocrRegion.height}`);
let startTime = Date.now();
while (Date.now() - startTime < timeout) {
try {
// 尝试 OCR 识别
let resList = captureGameRegion().findMulti(RecognitionObject.ocr(ocrRegion.x, ocrRegion.y, ocrRegion.width, ocrRegion.height)); // 指定识别区域
// 遍历识别结果,检查是否找到目标文本
for (let res of resList) {
// 后处理:根据替换映射表检查和替换错误识别的字符
let correctedText = res.text;
if (correctedText.includes(targetText)) {
// 如果找到目标文本,计算并点击文字的中心坐标
let centerX = res.x + res.width / 2;
let centerY = res.y + res.height / 2;
log.info(`识别到目标文本: ${correctedText},点击坐标: x=${centerX}, y=${centerY}`);
await click(centerX, centerY);
await sleep(500); // 确保点击后有足够的时间等待
return { success: true, x: centerX, y: centerY };
}
}
} catch (error) {
log.warn(`页面标志识别失败,正在进行重试... 错误信息: ${error.message}`);
}
await sleep(1000); // 短暂延迟,避免过快循环
}
log.warn(`经过多次尝试,仍然无法识别文字: ${targetText}`);
return { success: false };
}
// 定义一个独立的函数用于在指定区域进行 OCR 识别并输出识别内容
async function recognizeTextInRegion(ocrRegion, timeout = 5000) {
log.info(`开始 OCR 识别,区域: x=${ocrRegion.x}, y=${ocrRegion.y}, width=${ocrRegion.width}, height=${ocrRegion.height}`);
let startTime = Date.now();
while (Date.now() - startTime < timeout) {
try {
// 在指定区域进行 OCR 识别
let ocrResult = captureGameRegion().find(RecognitionObject.ocr(ocrRegion.x, ocrRegion.y, ocrRegion.width, ocrRegion.height));
if (ocrResult) {
log.info(`OCR 识别成功,原始文本: ${ocrResult.text}`);
// 后处理:根据替换映射表检查和替换错误识别的字符
let correctedText = ocrResult.text;
log.info(`修正后文本: ${correctedText}`);
return correctedText; // 返回识别到的内容
} else {
log.warn(`OCR 识别区域未找到内容`);
return null; // 如果 OCR 未识别到内容,返回 null
}
} catch (error) {
log.error(`OCR 摩拉数识别失败,错误信息: ${error.message}`);
}
await sleep(500); // 短暂延迟,避免过快循环
}
log.warn(`经过多次尝试,仍然无法在指定区域识别到文字`);
return null; // 如果未识别到文字,返回 null
}
log.info("开始执行 mora 函数");
// 设置游戏分辨率和 DPI 缩放比例
setGameMetrics(1920, 1080, 1);
log.info("游戏分辨率和 DPI 设置完成");
// 返回游戏主界面
await genshin.returnMainUi();
log.info("返回游戏主界面");
// 按下 C 键
keyPress("C");
log.info("按下 C 键");
await sleep(1500);
let recognized = false;
// 识别“角色菜单”图标或“天赋”文字
let startTime = Date.now();
while (Date.now() - startTime < 5000) {
// 尝试识别“角色菜单”图标
let characterMenuResult = await recognizeImage(CharacterMenuRo, 5000);
if (characterMenuResult.success) {
await click(177, 433);
log.info("点击角色菜单图标");
await sleep(500);
recognized = true;
break;
}
// 尝试识别“天赋”文字
let targetText = "天赋";
let ocrRegion = { x: 133, y: 395, width: 115, height: 70 }; // 设置对应的识别区域
let talentResult = await recognizeTextAndClick(targetText, ocrRegion);
if (talentResult.success) {
log.info(`点击天赋文字,坐标: x=${talentResult.x}, y=${talentResult.y}`);
recognized = true;
break;
}
await sleep(1000); // 短暂延迟,避免过快循环
}
// 如果识别到了“角色菜单”或“天赋”,则识别“摩拉数值”
if (recognized) {
let ocrRegionMora = { x: 1620, y: 25, width: 152, height: 46 }; // 设置对应的识别区域
let recognizedText = await recognizeTextInRegion(ocrRegionMora);
if (recognizedText) {
log.info(`成功识别到摩拉数值: ${recognizedText}`);
return recognizedText; // 返回识别到的摩拉数值
} else {
log.warn("未能识别到摩拉数值。");
}
} else {
log.warn("未能识别到角色菜单或天赋,跳过摩拉数值识别。");
}
await sleep(500);
await genshin.returnMainUi();
log.info("返回游戏主界面");
return null; // 如果未能识别到摩拉数值,返回 null
}
async function fakeLog(name, isJs, isStart, duration) {
await sleep(10);
const currentTime = Date.now();
// 参数检查
if (typeof name !== 'string') {
log.error("参数 'name' 必须是字符串类型!");
return;
}
if (typeof isJs !== 'boolean') {
log.error("参数 'isJs' 必须是布尔型!");
return;
}
if (typeof isStart !== 'boolean') {
log.error("参数 'isStart' 必须是布尔型!");
return;
}
if (typeof currentTime !== 'number' || !Number.isInteger(currentTime)) {
log.error("参数 'currentTime' 必须是整数!");
return;
}
if (typeof duration !== 'number' || !Number.isInteger(duration)) {
log.error("参数 'duration' 必须是整数!");
return;
}
// 将 currentTime 转换为 Date 对象并格式化为 HH:mm:ss.sss
const date = new Date(currentTime);
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
const formattedTime = `${hours}:${minutes}:${seconds}.${milliseconds}`;
// 将 duration 转换为分钟和秒,并保留三位小数
const durationInSeconds = duration / 1000; // 转换为秒
const durationMinutes = Math.floor(durationInSeconds / 60);
const durationSeconds = (durationInSeconds % 60).toFixed(3); // 保留三位小数
// 使用四个独立的 if 语句处理四种情况
if (isJs && isStart) {
// 处理 isJs = true 且 isStart = true 的情况
const logMessage = `正在伪造js开始的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 开始执行JS脚本: "${name}"`;
log.debug(logMessage);
}
if (isJs && !isStart) {
// 处理 isJs = true 且 isStart = false 的情况
const logMessage = `正在伪造js结束的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 脚本执行结束: "${name}", 耗时: ${durationMinutes}${durationSeconds}\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------`;
log.debug(logMessage);
}
if (!isJs && isStart) {
// 处理 isJs = false 且 isStart = true 的情况
const logMessage = `正在伪造地图追踪开始的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 开始执行地图追踪任务: "${name}"`;
log.debug(logMessage);
}
if (!isJs && !isStart) {
// 处理 isJs = false 且 isStart = false 的情况
const logMessage = `正在伪造地图追踪结束的日志记录\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`→ 脚本执行结束: "${name}", 耗时: ${durationMinutes}${durationSeconds}\n\n` +
`[${formattedTime}] [INF] BetterGenshinImpact.Service.ScriptService\n` +
`------------------------------`;
log.debug(logMessage);
}
}

View File

@@ -1,16 +1,15 @@
{
"manifest_version": 1,
"name": "锄地路线测试",
"version": "1.0",
"version": "1.1",
"description": "用于测试锄地路线的怪物信息运行时间并根据运行记录修改description字段以适配js锄地一条龙",
"authors": [
{
"name": "mno",
"links": "https://github.com/Bedrockx"
"name": "mno"
},
{
"name": "Tool_tingsu",
"links": "https://github.com/Tooltingsu"
"link": ""
}
],
"settings_ui": "settings.json",