diff --git a/repo.json b/repo.json index 690daa492..589e34ee6 100644 --- a/repo.json +++ b/repo.json @@ -1,5 +1,5 @@ { - "time": "20250404133502", + "time": "20250404181848", "url": "https://github.com/babalae/bettergi-scripts-list/archive/refs/heads/main.zip", "file": "repo.json", "indexes": [ @@ -31793,10 +31793,10 @@ { "name": "OCR购买食材", "type": "directory", - "hash": "4cfa7a41ffc18e0e8d9b5383cb11d1c1c0bdbdd0", + "hash": "55c02dfea8069770d63663271a59b5a78b8592db", "version": "1.20403", "author": "吉吉喵", - "description": "选择购买食材OCR~|~寻路杂货商,更新OCR版,对NPC和材料文字识别,一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买,10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。至少需要0.44版本bgi,增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买", + "description": "选择购买食材OCR~|~至少需要0.44版本bgi,对NPC和材料进行文字、图像识别。\n一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买。\n10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。\n咖啡豆在须弥、枫丹咖啡馆购买。\n增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买", "tags": [] }, { diff --git a/repo/js/OCR购买食材/assets/E_Dialogue.png b/repo/js/OCR购买食材/assets/E_Dialogue.png new file mode 100644 index 000000000..9114ff5bf Binary files /dev/null and b/repo/js/OCR购买食材/assets/E_Dialogue.png differ diff --git a/repo/js/OCR购买食材/assets/F_Dialogue.png b/repo/js/OCR购买食材/assets/F_Dialogue.png index 43f45e746..314a85f13 100644 Binary files a/repo/js/OCR购买食材/assets/F_Dialogue.png and b/repo/js/OCR购买食材/assets/F_Dialogue.png differ diff --git a/repo/js/OCR购买食材/assets/Pathing/枫丹咖啡厅露泽店主阿鲁埃.json b/repo/js/OCR购买食材/assets/Pathing/枫丹咖啡厅露泽店主阿鲁埃.json new file mode 100644 index 000000000..aae0ecfae --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/枫丹咖啡厅露泽店主阿鲁埃.json @@ -0,0 +1,58 @@ +{ + "info": { + "name": "枫丹咖啡厅露泽店主阿鲁埃", + "type": "collect", + "author": "吉吉喵", + "version": "1.0", + "description": "咖啡豆", + "bgiVersion": "0.42.3" + }, + "positions": [ + { + "id": 1, + "x": 4649.4873046875, + "y": 3467.8935546875, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": 4627.564453125, + "y": 3470.357421875, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 3, + "x": 4604.40869140625, + "y": 3510.25, + "action": "stop_flying", + "move_mode": "fly", + "action_params": "", + "type": "path" + }, + { + "id": 4, + "x": 4600.888671875, + "y": 3514.0810546875, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "target", + "locked": false + }, + { + "id": 5, + "x": 4599.888671875, + "y": 3516.081054687501, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "orientation" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/枫丹达莫维百货店主布希柯.json b/repo/js/OCR购买食材/assets/Pathing/枫丹达莫维百货店主布希柯.json new file mode 100644 index 000000000..cd6741b9d --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/枫丹达莫维百货店主布希柯.json @@ -0,0 +1,40 @@ +{ + "info": { + "name": "枫丹达莫维百货店主布希柯", + "type": "collect", + "author": "吉吉喵", + "version": "1.0", + "description": "杂货", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 4514.18, + "y": 3630.4, + "action_params": "", + "locked": false + }, + { + "id": 2, + "x": 4514.2802734375, + "y": 3604.35498046875, + "type": "path", + "move_mode": "fly", + "action": "stop_flying", + "action_params": "" + }, + { + "id": 3, + "x": 4470.1357421875, + "y": 3562.072265625, + "type": "path", + "move_mode": "fly", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/璃月万民堂老板卯师傅-2.json b/repo/js/OCR购买食材/assets/Pathing/璃月万民堂老板卯师傅-2.json new file mode 100644 index 000000000..3ce54c617 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/璃月万民堂老板卯师傅-2.json @@ -0,0 +1,55 @@ +{ + "info": { + "name": "璃月万民堂老板卯师傅", + "type": "collect", + "author": "吉吉喵", + "version": "", + "description": "璃月万民堂老板卯师傅备选", + "bgiVersion": "0.42.3" + }, + "positions": [ + { + "id": 1, + "x": 267.9150390625, + "y": -665.1591796875, + "action": "", + "move_mode": "walk", + "type": "teleport", + "locked": false + }, + { + "id": 2, + "x": 232.9345703125, + "y": -663.775390625, + "action": "", + "move_mode": "walk", + "type": "path" + }, + { + "id": 3, + "x": 231.1435546875, + "y": -671.79248046875, + "action": "", + "move_mode": "walk", + "type": "target", + "locked": false + }, + { + "id": 4, + "x": 226.2607421875, + "y": -672.33740234375, + "action": "", + "move_mode": "walk", + "type": "target", + "locked": false + }, + { + "id": 5, + "x": 227.591796875, + "y": -671.0654296875, + "action": "", + "move_mode": "walk", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/璃月万民堂老板卯师傅.json b/repo/js/OCR购买食材/assets/Pathing/璃月万民堂老板卯师傅.json new file mode 100644 index 000000000..f6b997e3f --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/璃月万民堂老板卯师傅.json @@ -0,0 +1,37 @@ +{ + "info": { + "name": "璃月万民堂老板卯师傅", + "type": "collect", + "author": "吉吉喵", + "version": "", + "description": "鱼肉+螃蟹", + "bgiVersion": "0.42.3" + }, + "positions": [ + { + "id": 1, + "x": 267.9150390625, + "y": -665.1591796875, + "action": "", + "move_mode": "walk", + "type": "teleport", + "locked": false + }, + { + "id": 2, + "x": 228.953125, + "y": -663.4853515625, + "action": "", + "move_mode": "walk", + "type": "path" + }, + { + "id": 3, + "x": 227.083984375, + "y": -668.10791015625, + "action": "", + "move_mode": "walk", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/璃月荣发商铺店主东升.json b/repo/js/OCR购买食材/assets/Pathing/璃月荣发商铺店主东升.json new file mode 100644 index 000000000..b41d4eff0 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/璃月荣发商铺店主东升.json @@ -0,0 +1,28 @@ +{ + "info": { + "name": "璃月荣发商铺店主东升", + "type": "collect", + "author": "吉吉喵", + "version": "1.0", + "description": "杂货", + "bgiVersion": "0.42.0" + }, + "positions": [ + { + "id": 1, + "action": "force_tp", + "move_mode": "walk", + "type": "teleport", + "x": 267.92, + "y": -665.01 + }, + { + "id": 2, + "x": 256.9208984375, + "y": -682.560546875, + "type": "path", + "move_mode": "walk", + "action": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/稻妻九十九物店主葵.json b/repo/js/OCR购买食材/assets/Pathing/稻妻九十九物店主葵.json new file mode 100644 index 000000000..8661478e5 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/稻妻九十九物店主葵.json @@ -0,0 +1,36 @@ +{ + "info": { + "name": "稻妻九十九物店主葵", + "type": "collect", + "author": "吉吉喵", + "version": "1.0", + "description": "杂货", + "bgiVersion": "0.42.0" + }, + "positions": [ + { + "id": 1, + "action": "force_tp", + "move_mode": "walk", + "type": "teleport", + "x": -4402.56, + "y": -3052.88 + }, + { + "id": 2, + "x": -4409.03125, + "y": -3067.2666015625, + "type": "path", + "move_mode": "walk", + "action": "" + }, + { + "id": 3, + "x": -4403.646484375, + "y": -3072.0263671875, + "type": "path", + "move_mode": "walk", + "action": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/稻妻志村屋店主志村勘兵卫.json b/repo/js/OCR购买食材/assets/Pathing/稻妻志村屋店主志村勘兵卫.json new file mode 100644 index 000000000..3a5e036b7 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/稻妻志村屋店主志村勘兵卫.json @@ -0,0 +1,44 @@ +{ + "info": { + "name": "稻妻志村屋店主志村堪兵卫", + "type": "collect", + "author": "吉吉喵", + "version": "1.0", + "description": "鱼肉+螃蟹", + "bgiVersion": "0.42.0" + }, + "positions": [ + { + "id": 1, + "action": "force_tp", + "move_mode": "walk", + "type": "teleport", + "x": -4402.56, + "y": -3052.88 + }, + { + "id": 2, + "x": -4409.03125, + "y": -3067.2666015625, + "type": "path", + "move_mode": "walk", + "action": "" + }, + { + "id": 3, + "x": -4421.849609375, + "y": -3084.564453125, + "type": "path", + "move_mode": "walk", + "action": "" + }, + { + "id": 4, + "x": -4425.07421875, + "y": -3082.072265625, + "type": "target", + "move_mode": "walk", + "action": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/蒙德百货销售员布兰琪.json b/repo/js/OCR购买食材/assets/Pathing/蒙德百货销售员布兰琪.json new file mode 100644 index 000000000..6d839404b --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/蒙德百货销售员布兰琪.json @@ -0,0 +1,36 @@ +{ + "info": { + "name": "蒙德百货销售员布兰琪", + "type": "collect", + "author": "吉吉喵", + "version": "1.0", + "description": "杂货", + "bgiVersion": "0.42.3" + }, + "positions": [ + { + "id": 1, + "x": -867.693359375, + "y": 2281.393310546875, + "action": "", + "move_mode": "walk", + "type": "teleport" + }, + { + "id": 2, + "x": -886.5966796875, + "y": 2259.00244140625, + "action": "", + "move_mode": "walk", + "type": "path" + }, + { + "id": 3, + "x": -894.9638671875, + "y": 2264.875244140625, + "action": "", + "move_mode": "walk", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/须弥城咖啡馆代理店长恩忒卡.json b/repo/js/OCR购买食材/assets/Pathing/须弥城咖啡馆代理店长恩忒卡.json new file mode 100644 index 000000000..b2a94e662 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/须弥城咖啡馆代理店长恩忒卡.json @@ -0,0 +1,70 @@ +{ + "info": { + "name": "须弥城普斯帕咖啡馆代理店长恩忒卡", + "type": "collect", + "author": "吉吉喵", + "version": "", + "description": "咖啡", + "bgiVersion": "0.42.3" + }, + "positions": [ + { + "id": 1, + "x": 2789.4375, + "y": -492.34375, + "action": "", + "move_mode": "walk", + "type": "teleport" + }, + { + "id": 2, + "x": 2789.125, + "y": -488.28125, + "action": "", + "move_mode": "walk", + "type": "path" + }, + { + "id": 3, + "x": 2772.20703125, + "y": -477.16259765625, + "action": "", + "move_mode": "walk", + "type": "path" + }, + { + "id": 4, + "x": 2770.71875, + "y": -465.90625, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 5, + "x": 2765.1025390625, + "y": -459.37548828125, + "action": "", + "move_mode": "walk", + "type": "path" + }, + { + "id": 6, + "x": 2745.6875, + "y": -462.09375, + "action": "", + "move_mode": "walk", + "type": "path" + }, + { + "id": 7, + "x": 2743.4736328125, + "y": -470.27734375, + "action": "combat_script", + "move_mode": "walk", + "action_params": "wait(0.5),keypress(F),wait(6),keydown(W),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),wait(0.5),keypress(SPACE),keyup(W)", + "type": "path" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/须弥城鱼贩珀姆.json b/repo/js/OCR购买食材/assets/Pathing/须弥城鱼贩珀姆.json new file mode 100644 index 000000000..2031ec3a1 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/须弥城鱼贩珀姆.json @@ -0,0 +1 @@ +{"info":{"name":"","type":""},"positions":[{"x":2788.5654296875,"y":-506.36279296875,"type":"teleport","move_mode":"walk"},{"x":2792.4580078125,"y":-519.3681640625,"type":"path","move_mode":"walk"},{"x":2799.9716796875,"y":-520.26806640625,"type":"path","move_mode":"walk"},{"x":2810.134765625,"y":-511.20947265625,"type":"path","move_mode":"walk"}]} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/须弥奥摩斯港鱼贩布特罗斯.json b/repo/js/OCR购买食材/assets/Pathing/须弥奥摩斯港鱼贩布特罗斯.json new file mode 100644 index 000000000..57421f746 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/须弥奥摩斯港鱼贩布特罗斯.json @@ -0,0 +1,28 @@ +{ + "info": { + "name": "须弥奥摩斯港鱼贩布特罗斯", + "type": "collect", + "author": "吉吉喵", + "version": "", + "description": "鱼肉+螃蟹", + "bgiVersion": "0.42.3" + }, + "positions": [ + { + "id": 1, + "x": 2679.8427734375, + "y": -1935.0341796875, + "action": "", + "move_mode": "walk", + "type": "teleport" + }, + { + "id": 2, + "x": 2658.712890625, + "y": -1930.0478515625, + "action": "", + "move_mode": "walk", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Pathing/须弥阿如村商人阿扎莱.json b/repo/js/OCR购买食材/assets/Pathing/须弥阿如村商人阿扎莱.json new file mode 100644 index 000000000..4bfbb2d13 --- /dev/null +++ b/repo/js/OCR购买食材/assets/Pathing/须弥阿如村商人阿扎莱.json @@ -0,0 +1 @@ +{"info":{"name":"","type":""},"positions":[{"x":4095.98828125,"y":-2025.9638671875,"type":"teleport","move_mode":"walk"},{"x":4099.64013671875,"y":-2010.21337890625,"type":"path","move_mode":"walk"},{"x":4095.404296875,"y":-1997.890625,"type":"path","move_mode":"walk"},{"x":4099.6630859375,"y":-1978.88427734375,"type":"path","move_mode":"walk"},{"x":4091.326171875,"y":-1980.173828125,"type":"path","move_mode":"walk"}]} \ No newline at end of file diff --git a/repo/js/OCR购买食材/assets/Picture/AlmondRo.png b/repo/js/OCR购买食材/assets/Picture/AlmondRo.png new file mode 100644 index 000000000..2c6a8421c Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/AlmondRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/CabbageRo.png b/repo/js/OCR购买食材/assets/Picture/CabbageRo.png new file mode 100644 index 000000000..75140c486 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/CabbageRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/CoffeeRo.png b/repo/js/OCR购买食材/assets/Picture/CoffeeRo.png new file mode 100644 index 000000000..0571fb15c Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/CoffeeRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/CrabRo.png b/repo/js/OCR购买食材/assets/Picture/CrabRo.png new file mode 100644 index 000000000..740da1aea Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/CrabRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/FengdaRo.png b/repo/js/OCR购买食材/assets/Picture/FengdaRo.png new file mode 100644 index 000000000..13cb976ae Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/FengdaRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/FermentRo.png b/repo/js/OCR购买食材/assets/Picture/FermentRo.png new file mode 100644 index 000000000..3c27cefbf Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/FermentRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/FishRo.png b/repo/js/OCR购买食材/assets/Picture/FishRo.png new file mode 100644 index 000000000..50acab49b Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/FishRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/MilkRo.png b/repo/js/OCR购买食材/assets/Picture/MilkRo.png new file mode 100644 index 000000000..b8fb88694 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/MilkRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/OnionRo.png b/repo/js/OCR购买食材/assets/Picture/OnionRo.png new file mode 100644 index 000000000..95edfb28d Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/OnionRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/PepperRo.png b/repo/js/OCR购买食材/assets/Picture/PepperRo.png new file mode 100644 index 000000000..3d138bf7a Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/PepperRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/PotatoRo.png b/repo/js/OCR购买食材/assets/Picture/PotatoRo.png new file mode 100644 index 000000000..90b9b4524 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/PotatoRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/RiceRo.png b/repo/js/OCR购买食材/assets/Picture/RiceRo.png new file mode 100644 index 000000000..d57170bd3 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/RiceRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/SaltRo.png b/repo/js/OCR购买食材/assets/Picture/SaltRo.png new file mode 100644 index 000000000..556835b38 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/SaltRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/ShrimpRo.png b/repo/js/OCR购买食材/assets/Picture/ShrimpRo.png new file mode 100644 index 000000000..606a38268 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/ShrimpRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/SpicesRo.png b/repo/js/OCR购买食材/assets/Picture/SpicesRo.png new file mode 100644 index 000000000..85deb68b5 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/SpicesRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/TofuRo.png b/repo/js/OCR购买食材/assets/Picture/TofuRo.png new file mode 100644 index 000000000..fe0a569d4 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/TofuRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/TomatoRo.png b/repo/js/OCR购买食材/assets/Picture/TomatoRo.png new file mode 100644 index 000000000..c67043cc7 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/TomatoRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/ToutuRo.png b/repo/js/OCR购买食材/assets/Picture/ToutuRo.png new file mode 100644 index 000000000..c0992c638 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/ToutuRo.png differ diff --git a/repo/js/OCR购买食材/assets/Picture/WheatRo.png b/repo/js/OCR购买食材/assets/Picture/WheatRo.png new file mode 100644 index 000000000..df3510928 Binary files /dev/null and b/repo/js/OCR购买食材/assets/Picture/WheatRo.png differ diff --git a/repo/js/OCR购买食材/main.js b/repo/js/OCR购买食材/main.js index c5075c89d..30ec5b5e7 100644 --- a/repo/js/OCR购买食材/main.js +++ b/repo/js/OCR购买食材/main.js @@ -1,23 +1,41 @@ -// 定义所有食材及其对应的路径文件和 NPC -const mondstadtGroceryFilePath = `assets/蒙德百货销售员布兰琪.json`; -const liyueGroceryFilePath = `assets/璃月荣发商铺店主东升.json`; -const liyueWanminFilePath = `assets/璃月万民堂老板卯师傅.json`; -const groceryFilePath = `assets/稻妻九十九物店主葵.json`; -const charcoalFilePath = `assets/稻妻志村屋店主志村勘兵卫.json`; -const fengdanGroceryFilePath = `assets/枫丹达莫维百货店主布希柯.json`; -const cafeLuzheFilePath = `assets/枫丹咖啡厅露泽店主阿鲁埃.json`; -const sumiCityFishPath = `assets/须弥城鱼贩珀姆.json`; -const omosPortFishPath = `assets/须弥奥摩斯港鱼贩布特罗斯.json`; -const azaleVillMerPath = `assets/须弥阿如村商人阿扎莱.json`; +// 定义所有食材的图像识别对象 +let FengdaRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/FengdaRo.png")); +let SaltRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/SaltRo.png")); +let PepperRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/PepperRo.png")); +let OnionRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/OnionRo.png")); +let MilkRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/MilkRo.png")); +let TomatoRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/TomatoRo.png")); +let SpicesRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/SpicesRo.png")); +let CabbageRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/CabbageRo.png")); +let PotatoRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/PotatoRo.png")); +let WheatRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/WheatRo.png")); +let RiceRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/RiceRo.png")); +let TofuRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/TofuRo.png")); +let AlmondRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/AlmondRo.png")); +let FishRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/FishRo.png")); +let CrabRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/CrabRo.png")); +let ShrimpRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/ShrimpRo.png")); +let CoffeeRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/CoffeeRo.png")); +let ToutuRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/ToutuRo.png")); +let FermentRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/Picture/FermentRo.png")); // 定义所有可能的食材,注意料理名字长度可能超过识图范围 const ingredients = [ - "枫达", "盐", "洋葱", "牛奶", "番茄", "香辛料", "卷心菜", "土豆", "小麦", "胡椒","稻米", "豆腐", "杏仁", "鱼肉", "螃蟹", "虾仁", "咖啡豆", "秃秃豆", "发酵果实汁" + "枫达", "盐", "胡椒", "洋葱", "牛奶", "番茄", "香辛料", "卷心菜", "土豆", "小麦", "稻米", "豆腐", "杏仁", "鱼肉", "螃蟹", "虾仁", "咖啡豆", "秃秃豆", "发酵果实汁" ]; -// 筛选出用户选择的食材及其对应的路径文件和 NPC -let selectedIngredients = []; // 在函数外部声明一次 -let selectedPaths = new Map(); +// 定义所有食材及其对应的路径文件和 NPC +const mondstadtGroceryFilePath = `assets/Pathing/蒙德百货销售员布兰琪.json`; +const liyueGroceryFilePath = `assets/Pathing/璃月荣发商铺店主东升.json`; +const liyueWanminFilePath = `assets/Pathing/璃月万民堂老板卯师傅.json`; +const groceryFilePath = `assets/Pathing/稻妻九十九物店主葵.json`; +const charcoalFilePath = `assets/Pathing/稻妻志村屋店主志村勘兵卫.json`; +const fengdanGroceryFilePath = `assets/Pathing/枫丹达莫维百货店主布希柯.json`; +const cafeLuzheFilePath = `assets/Pathing/枫丹咖啡厅露泽店主阿鲁埃.json`; +const sumiCitycafeFilePath = `assets/Pathing/须弥城咖啡馆代理店长恩忒卡.json`; +const sumiCityFishPath = `assets/Pathing/须弥城鱼贩珀姆.json`; +const omosPortFishPath = `assets/Pathing/须弥奥摩斯港鱼贩布特罗斯.json`; +const azaleVillMerPath = `assets/Pathing/须弥阿如村商人阿扎莱.json`; const ingredientPaths = { "枫达": [fengdanGroceryFilePath, cafeLuzheFilePath], @@ -36,10 +54,40 @@ const ingredientPaths = { "鱼肉": [liyueWanminFilePath, charcoalFilePath, sumiCityFishPath, omosPortFishPath, azaleVillMerPath], "螃蟹": [liyueWanminFilePath, charcoalFilePath, sumiCityFishPath, omosPortFishPath], "秃秃豆": [fengdanGroceryFilePath, azaleVillMerPath], - "咖啡豆": [cafeLuzheFilePath], + "咖啡豆": [sumiCitycafeFilePath, cafeLuzheFilePath], "香辛料": [azaleVillMerPath], "发酵果实汁": [fengdanGroceryFilePath] }; + +// 定义食材名称和图片文件名的映射表 +const ingredientImageMap = { + "枫达": "FengdaRo.png", + "盐": "SaltRo.png", + "洋葱": "OnionRo.png", + "牛奶": "MilkRo.png", + "番茄": "TomatoRo.png", + "卷心菜": "CabbageRo.png", + "土豆": "PotatoRo.png", + "小麦": "WheatRo.png", + "胡椒": "PepperRo.png", + "稻米": "RiceRo.png", + "虾仁": "ShrimpRo.png", + "豆腐": "TofuRo.png", + "杏仁": "AlmondRo.png", + "鱼肉": "FishRo.png", + "螃蟹": "CrabRo.png", + "秃秃豆": "ToutuRo.png", + "咖啡豆": "CoffeeRo.png", + "香辛料": "SpicesRo.png", + "发酵果实汁": "FermentRo.png", + // 可以继续添加更多食材的映射 +}; + +// 定义替换映射表 +const replacementMap = { + "监": "盐", + "卵": "卯" +}; // 定义所有NPC名,注意名字长度可能超过识图范围 const npcNames = { [mondstadtGroceryFilePath]: ["布兰琪"], @@ -50,10 +98,15 @@ const npcNames = { [fengdanGroceryFilePath]: ["布希柯"], [cafeLuzheFilePath]: ["阿鲁埃"], [sumiCityFishPath]: ["珀姆"], + [sumiCitycafeFilePath]: ["恩忒卡"], [omosPortFishPath]: ["布特罗斯"], [azaleVillMerPath]: ["阿扎莱"] }; +// 筛选出用户选择的食材及其对应的路径文件和 NPC +let selectedIngredients = []; // 在函数外部声明一次 +let selectedPaths = new Map(); + for (let ingredient of ingredients) { if (settings[ingredient]) { selectedIngredients.push(ingredient); @@ -82,12 +135,95 @@ async function simulateKeyOperations(key, duration) { await sleep(500); // 释放按键后等待 500 毫秒 } +// 定义一个函数用于购买食材 +async function purchaseIngredient(ingredient) { + log.info(`购买食材: ${ingredient}`); + // 模拟购买操作的后续点击 + await click(1600, 1020); await sleep(1000); // 购买 + await click(1181, 600); await sleep(200); // 选择100个 + await click(1320, 780); await sleep(1000); // 最终确认 + await click(1320, 780); await sleep(1000); // 点击空白 +} + +// 定义一个通用的图像识别函数 +function recognizeImage(templatePath, xMin, yMin, width, height) { + let template = file.ReadImageMatSync(templatePath); + let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height); + let result = captureGameRegion().find(recognitionObject); + return result.isExist() ? result : null; +} + +// 定义一个函数用于执行OCR识别 +async function performOcr(targetText, xRange, yRange, tolerance) { + // 调整区域范围以包含容错区间 + let adjustedXMin = xRange.min - tolerance; + let adjustedXMax = xRange.max + tolerance; + let adjustedYMin = yRange.min - tolerance; + let adjustedYMax = yRange.max + tolerance; + + // 在捕获的区域内进行OCR识别 + let ra = captureGameRegion(); + let resList = ra.findMulti(RecognitionObject.ocr( + adjustedXMin, adjustedYMin, + adjustedXMax - adjustedXMin, adjustedYMax - adjustedYMin + )); + + // 遍历识别结果,检查是否找到目标文本 + for (let i = 0; i < resList.count; i++) { + let res = resList[i]; + // 后处理:根据替换映射表检查和替换错误识别的字符 + let correctedText = res.text; + for (let [wrongChar, correctChar] of Object.entries(replacementMap)) { + correctedText = correctedText.replace(wrongChar, correctChar); + } + + if (correctedText.includes(targetText)) { + // 如果找到目标文本,直接返回坐标 + return { success: true, x: res.x, y: res.y, width: res.width, height: res.height }; + } + } + return { success: false }; // 未找到符合条件的文本 +} + +// 定义一个函数用于识别食材 +async function recognizeIngredient(ingredient) { + let recognized = false; + const clickOffset = 30; // 点击坐标偏移 + + // 尝试 OCR 识别 + let ocrResult = await performOcr(ingredient, { min: 210, max: 390 }, { min: 105, max: 950 }, 10); + if (ocrResult.success) { + log.info(`通过 OCR 识别找到食材: ${ingredient}`); + log.info(`坐标: x=${ocrResult.x}, y=${ocrResult.y}`); + await click(ocrResult.x, ocrResult.y + clickOffset); + await sleep(1000); + recognized = true; + } else { + // OCR 识别失败,尝试图像识别 + let imagePath = `assets/Picture/${ingredientImageMap[ingredient]}`; + if (!imagePath) { + log.error(`未找到食材 '${ingredient}' 的图片文件`); + return recognized; + } + let imageResult = recognizeImage(imagePath, 120, 90, 95, 865); + if (imageResult) { + log.info(`通过图像识别找到食材: ${ingredient}`); + imageResult.click(); + await sleep(1000); + recognized = true; + } else { + log.error(`未能识别到食材: ${ingredient}`); + } + } + + return recognized; +} + // 定义一个函数用于识别并点击用户选择的食材 async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) { log.info(`加载路径文件: ${filePath}`); await pathingScript.runFile(filePath); await sleep(1000); - // log.info("路径文件执行完成"); // 识别并交互 NPC const npcxRange = { min: 1190, max: 1320 }; // npc X轴区间 @@ -97,8 +233,6 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) const tolerance = 12; // 容错区间 const npctolerance = 5; // 容错区间 - let npcOcrResult = { success: false }; // 初始化 npcOcrResult - // 执行点击操作 async function performClickOperations(filePath) { if (filePath === liyueGroceryFilePath || filePath === groceryFilePath || filePath === sumiCityFishPath) { @@ -144,15 +278,13 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) log.error(`尝试 ${f_attempts + 1}:寻找 F 图标`); } } - // log.info(`F 图标x: ${fRes.x},y: ${fRes.y},width: ${fRes.width},height: ${fRes.height}`); // 获取 F 图标的中心点 Y 坐标 let centerYF = fRes.y + fRes.height / 2; // 在 F 图标右侧水平方向上识别 NPC 名称 let ocrResult = await performOcr(npcName, npcxRange, { min: fRes.y, max: fRes.y + fRes.height }, tolerance); - // log.info(`NPC 名称x: ${ocrResult.x},y: ${ocrResult.y},width: ${ocrResult.width},height: ${ocrResult.height}`); if (!ocrResult.success) { - log.error(`OCR 识别未找到 NPC: ${npcName}`); + log.error(`OCR 识别未找到 NPC: ${npcName},尝试滚动`); return false; } @@ -161,10 +293,9 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) // 检查 NPC 名称和 F 图标的中心点 Y 坐标是否在容错范围内 if (Math.abs(centerYnpcName - centerYF) <= npctolerance) { - // log.info(`NPC '${npcName}' 和 F 图标水平对齐,执行交互, NPC: ${centerYnpcName}, F 图标: ${centerYF}`); return true; } else { - log.info(`NPC '${npcName}' 和 F 图标未水平对齐,尝试滚动, NPC: ${centerYnpcName}, F 图标: ${centerYF}`); + log.info(`NPC '${npcName}' 和 F 图标未水平对齐, NPC: ${centerYnpcName}, F 图标: ${centerYF}`); return false; } } @@ -205,12 +336,6 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) // 记录已购买的食材 let purchasedIngredients = new Set(); - // 继续后续操作 - const ingredientXRange = { min: 210, max: 390 }; // X坐标范围 - const ingredientYRange = { min: 105, max: 960 }; // Y坐标范围 - const ingredientTolerance = 10; // 容错区间 - const clickOffset = 30; // 点击坐标容错 - let allIngredientsFound = false; // 标记是否所有食材都已找到 let scrollAttemptsForIngredients = 0; const maxScrollAttemptsForIngredients = 3; // 最大翻页次数 @@ -223,23 +348,16 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) log.info(`跳过已购买的食材: ${ingredient}`); continue; // 跳过已购买的食材 } + // await sleep(1000); - let ocrResult = await performOcr(ingredient, ingredientXRange, ingredientYRange, ingredientTolerance); - if (ocrResult.success) { - log.info(`识别到 '${ingredient}',坐标: x=${ocrResult.x}, y=${ocrResult.y}`); - await click(ocrResult.x, ocrResult.y + clickOffset); - await sleep(1000); - - // 模拟购买操作的后续点击 - await click(1600, 1020); await sleep(1000); // 购买 - await click(1181, 600); await sleep(200); // 选择100个 - await click(1320, 780); await sleep(1000); // 最终确认 - await click(1320, 780); await sleep(1000); // 点击空白 - - // 记录已购买的食材 + // 尝试识别食材 + let recognized = await recognizeIngredient(ingredient); + if (recognized) { + log.info(`识别到 '${ingredient}',执行购买操作`); + await purchaseIngredient(ingredient); purchasedIngredients.add(ingredient); } else { - log.error(`OCR 识别未找到 '${ingredient}'`); + log.error(`未能识别到食材: ${ingredient}`); allIngredientsFound = false; // 本轮有食材未找到 } } @@ -247,7 +365,7 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) if (!allIngredientsFound) { log.info(`在当前页面未找到所有食材,尝试翻页`); await PageScroll(1); // 每轮翻页滑动1次 - await sleep(600); + await sleep(1000); scrollAttemptsForIngredients++; } } @@ -279,9 +397,6 @@ async function clickSelectedIngredients(selectedIngredients, filePath, npcNames) log.error("未能找到正确的 NPC 或未成功交互,跳过该路径"); } - - - // 自动执行划页操作 async function PageScroll(scrollCount) { try { @@ -303,7 +418,6 @@ async function PageScroll(scrollCount) { leftButtonDown(); // 将鼠标移动到目标位置,模拟更自然的拖动操作 - // log.info("移动鼠标"); const steps = totalDistance / stepDistance; // 分成若干步移动 for (let j = 0; j < steps; j++) { @@ -321,52 +435,6 @@ async function PageScroll(scrollCount) { } } -// 定义替换映射表 -const replacementMap = { - "监": "盐", - "卵": "卯" -}; - -// 定义一个函数用于执行OCR识别 -async function performOcr(targetText, xRange, yRange, tolerance) { - // 调整区域范围以包含容错区间 - let adjustedXMin = xRange.min - tolerance; - let adjustedXMax = xRange.max + tolerance; - let adjustedYMin = yRange.min - tolerance; - let adjustedYMax = yRange.max + tolerance; - /*log.info(` - adjustedXMin: ${adjustedXMin} - adjustedXMax: ${adjustedXMax} - adjustedYMin: ${adjustedYMin} - adjustedYMax: ${adjustedYMax} -`);*/ - - // 在捕获的区域内进行OCR识别 - let ra = captureGameRegion(); - let resList = ra.findMulti(RecognitionObject.ocr( - adjustedXMin, adjustedYMin, - adjustedXMax - adjustedXMin, adjustedYMax - adjustedYMin - )); - // log.info(`OCR 识别数量: ${resList.count}`); - - // 遍历识别结果,检查是否找到目标文本 - for (let i = 0; i < resList.count; i++) { - let res = resList[i]; - // log.info("0CR结果-"+ res.text); - // 后处理:根据替换映射表检查和替换错误识别的字符 - let correctedText = res.text; - for (let [wrongChar, correctChar] of Object.entries(replacementMap)) { - correctedText = correctedText.replace(wrongChar, correctChar); - } - - if (correctedText.includes(targetText)) { - // 如果找到目标文本,直接返回坐标 - return { success: true, x: resList[i].x, y: resList[i].y, width: resList[i].width, height: resList[i].height }; // 找到符合条件的文本,返回坐标 - } - } - return { success: false }; // 未找到符合条件的文本 -} - // 主函数 async function AutoPath() { log.info("开始执行自动寻路任务"); diff --git a/repo/js/OCR购买食材/manifest.json b/repo/js/OCR购买食材/manifest.json index ac28fa8d5..99c8128fd 100644 --- a/repo/js/OCR购买食材/manifest.json +++ b/repo/js/OCR购买食材/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 1, "name": "选择购买食材OCR", "version": "1.20403", - "description": "寻路杂货商,更新OCR版,对NPC和材料文字识别,一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买,10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。至少需要0.44版本bgi,增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买", + "description": "至少需要0.44版本bgi,对NPC和材料进行文字、图像识别。\n一般食材杂货在蒙德、璃月、稻妻、枫丹杂货商购买。\n10鱼肉、10螃蟹在卯师傅、珀姆、布特罗斯、阿扎莱和志村勘兵卫购买。\n咖啡豆在须弥、枫丹咖啡馆购买。\n增加对话F图像识别,增加个别字识别容错;增加香辛料,在阿扎莱处购买", "authors": [ { "name": "吉吉喵"