From 6a07c4c1c3bdb51d347718d2f888e654d4e5e84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=AC=E9=9B=A8=E2=99=AA?= Date: Thu, 6 Mar 2025 20:52:28 +0800 Subject: [PATCH] =?UTF-8?q?[JS=E8=84=9A=E6=9C=AC]=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E9=A3=9F=E6=9D=90-=E8=87=AA=E5=8A=A8=E8=B4=AD=E7=89=A9=20(#397?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 注销系统用户的js脚本 一个注销系统用户的js脚本,用于用于远程本地多用户桌面 * 一个购买食材-自动购物的JS脚本 一个自动买菜脚本, 目前添加了15个NPC * [JS脚本]买菜脚本BUG修复 修复了志村勘兵卫寻路问题. * [JS脚本]购买食材-自动购物BUG修复 1、修复了一键购买时sleep时间较短,小概率跳过部分商品的BUG 2、修复了少女体型角色在无移速加成时,稻妻杂物NPC葵的寻路BUG * [JS脚本][BUG修复]购买食材-自动购物 修复了阻塞函数genshin.returnMainUi()未加await导致外部报错的BUG :) * [JS脚本]自动加工食材 自动食材加工, 可自动获取加工完成食材,可指定制作食材 --- .../AutoProcess/assets/AutoPath/找厨房.json | 30 +++ repo/js/AutoProcess/main.js | 178 ++++++++++++++ repo/js/AutoProcess/manifest.json | 14 ++ repo/js/AutoProcess/settings.json | 7 + repo/js/买菜/NPC_list.json | 100 ++++++++ repo/js/买菜/assets/AutoPath/东升.json | 30 +++ repo/js/买菜/assets/AutoPath/卯师父.json | 39 +++ repo/js/买菜/assets/AutoPath/哈马维.json | 75 ++++++ repo/js/买菜/assets/AutoPath/小畑.json | 121 +++++++++ repo/js/买菜/assets/AutoPath/布兰琪.json | 39 +++ repo/js/买菜/assets/AutoPath/布希柯.json | 57 +++++ repo/js/买菜/assets/AutoPath/布特罗斯.json | 30 +++ repo/js/买菜/assets/AutoPath/志村勘兵卫.json | 39 +++ repo/js/买菜/assets/AutoPath/珀姆.json | 39 +++ repo/js/买菜/assets/AutoPath/老孙.json | 102 ++++++++ repo/js/买菜/assets/AutoPath/老高.json | 93 +++++++ repo/js/买菜/assets/AutoPath/莎拉.json | 39 +++ repo/js/买菜/assets/AutoPath/葵.json | 30 +++ repo/js/买菜/assets/AutoPath/阿扎莱.json | 66 +++++ repo/js/买菜/assets/AutoPath/阿鲁埃.json | 57 +++++ repo/js/买菜/main.js | 229 ++++++++++++++++++ repo/js/买菜/manifest.json | 14 ++ repo/js/买菜/settings.json | 67 +++++ 23 files changed, 1495 insertions(+) create mode 100644 repo/js/AutoProcess/assets/AutoPath/找厨房.json create mode 100644 repo/js/AutoProcess/main.js create mode 100644 repo/js/AutoProcess/manifest.json create mode 100644 repo/js/AutoProcess/settings.json create mode 100644 repo/js/买菜/NPC_list.json create mode 100644 repo/js/买菜/assets/AutoPath/东升.json create mode 100644 repo/js/买菜/assets/AutoPath/卯师父.json create mode 100644 repo/js/买菜/assets/AutoPath/哈马维.json create mode 100644 repo/js/买菜/assets/AutoPath/小畑.json create mode 100644 repo/js/买菜/assets/AutoPath/布兰琪.json create mode 100644 repo/js/买菜/assets/AutoPath/布希柯.json create mode 100644 repo/js/买菜/assets/AutoPath/布特罗斯.json create mode 100644 repo/js/买菜/assets/AutoPath/志村勘兵卫.json create mode 100644 repo/js/买菜/assets/AutoPath/珀姆.json create mode 100644 repo/js/买菜/assets/AutoPath/老孙.json create mode 100644 repo/js/买菜/assets/AutoPath/老高.json create mode 100644 repo/js/买菜/assets/AutoPath/莎拉.json create mode 100644 repo/js/买菜/assets/AutoPath/葵.json create mode 100644 repo/js/买菜/assets/AutoPath/阿扎莱.json create mode 100644 repo/js/买菜/assets/AutoPath/阿鲁埃.json create mode 100644 repo/js/买菜/main.js create mode 100644 repo/js/买菜/manifest.json create mode 100644 repo/js/买菜/settings.json diff --git a/repo/js/AutoProcess/assets/AutoPath/找厨房.json b/repo/js/AutoProcess/assets/AutoPath/找厨房.json new file mode 100644 index 00000000..321afe28 --- /dev/null +++ b/repo/js/AutoProcess/assets/AutoPath/找厨房.json @@ -0,0 +1,30 @@ +{ + "info": { + "name": "找厨房", + "type": "collect", + "author": "听雨♪", + "version": "1.1", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "x": 267.939453125, + "y": -665.13134765625, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": 254.6251423712256, + "y": -680.625, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/AutoProcess/main.js b/repo/js/AutoProcess/main.js new file mode 100644 index 00000000..ca7660f0 --- /dev/null +++ b/repo/js/AutoProcess/main.js @@ -0,0 +1,178 @@ +// main.js + +const settingsInput = settings.process + +const FoodItems = { + 1: { name: '面粉', coordinate: [240, 260] }, + 2: { name: '兽肉', coordinate: [435, 260] }, + 3: { name: '鱼肉', coordinate: [630, 260] }, + 4: { name: '神秘肉加工产物', coordinate: [825, 260] }, + 5: { name: '奶油', coordinate: [1020, 260] }, + 6: { name: '熏禽肉', coordinate: [1215, 260] }, + 7: { name: '黄油', coordinate: [1410, 260] }, + 8: { name: '火腿', coordinate: [1605, 260] }, + 9: { name: '糖', coordinate: [240, 500] }, + 10: { name: '香辛料', coordinate: [435, 500] }, + 11: { name: '蟹黄', coordinate: [630, 500] }, + 12: { name: '果酱', coordinate: [825, 500] }, + 13: { name: '奶酪', coordinate: [1020, 500] }, + 14: { name: '培根', coordinate: [1215, 500] }, + 15: { name: '香肠', coordinate: [1410, 500] } +}; + +const coordinates = { + process: [1350, 64], + claimAll: [327, 1367], + cook: [2250, 1368], + amountStart: [990, 790], + confirm: [1577, 1011] +} + + +function validateAndStoreNumbers(input) { + // 定义存储结果的数组 + let storedNumbers = []; + + // 使用正则表达式检测是否符合期望格式 + const regex = /^(\b([1-9]|1[0-5])\b)(, (\b([1-9]|1[0-5])\b))*$/; + + // 检测输入字符串是否符合正则表达式 + if (regex.test(input)) { + // 将输入字符串按逗号和空格分割成数组 + const numbers = input.split(', '); + + // 将分割后的数字字符串转换为整数并存储到数组中 + storedNumbers = numbers.map(Number); + + return storedNumbers; + } else { + return false + } + + +} + +async function QucikCook() { + // 点击Cook + click(...coordinates.cook); + await sleep(100); // 等待窗口弹出 + + // 选中左边点 + moveMouseTo(...coordinates.amountStart); + await sleep(100); + leftButtonDown(); + await sleep(50); + + // 向右滑动 + moveMouseBy(1200, 0); + await sleep(200); + leftButtonUp(); + await sleep(100); + + // 点击弹出页的确认 + click(...coordinates.confirm); + await sleep(500); + + // 点击空白处关闭 + click(...coordinates.confirm); + await sleep(200); +} + +async function AutoPath(locationName) { + try { + let filePath = `assets/AutoPath/${locationName}.json`; + await pathingScript.runFile(filePath); + + return true; + } catch (error) { + log.error(`执行 ${locationName} 路径时发生错误`); + log.error(error.message); + } + + return false; +} + +(async function () { + + // 提醒别带内鬼 + log.warn("建议不要带某些靠近能灭火的\"内鬼\"角色.") + + + // 判断设置合法性 + var items = []; + + if (settingsInput) { + items = validateAndStoreNumbers(settingsInput); + if (items) { + const names = items + .map(id => FoodItems[id] ? FoodItems[id].name : null) // 检查是否存在 + .filter(name => name !== null) // 过滤掉不存在的项 + .join(', '); + log.info("已从设置中读取内容: ")| + await sleep(100) + log.info(names) + + } else { + log.info("设置所填内容不合法, 请仔细阅读设置要求, 或者在群里问其他玩家") + + return + } + + } else { + log.info("还没有设置需要制作食材呢") + log.info("请在调试器里添加本脚本->右键JS脚本->修改JS脚本自定义配置.") + + return + } + + // 前往灶台 + if (!await AutoPath("找厨房")) { + return + } + + + //设置脚本环境的游戏分辨率和DPI缩放 + setGameMetrics(2560, 1440, 1.5); + + // 交互, 进入烹饪界面 + await sleep(500) + keyPress("F") + await sleep(1000) + click(...coordinates.process) + await sleep(1000) + + // 收菜 + click(...coordinates.claimAll) + await sleep(500) + click(...coordinates.claimAll) + await sleep(500) + + // 批量Cook + for (let item of items) { + // 选择目标 + click(...FoodItems[item].coordinate) + await sleep(300) + + await QucikCook() + + log.info(`${FoodItems[item].name} = 制作完成 :)`); + await sleep(200) + } + + // 返回主菜单 + await genshin.returnMainUi() + + // 后退一下, 防止某些内鬼灭火 + keyDown("S") + await sleep(2000) + keyUp("S") + + log.info("┌────────────────────────────┐") + log.info(" 感谢您的使用, 任务已全部完成") + log.info(" 拜拜") + log.info(" Done.") + log.info("└────────────────────────────┘") + + + +})(); \ No newline at end of file diff --git a/repo/js/AutoProcess/manifest.json b/repo/js/AutoProcess/manifest.json new file mode 100644 index 00000000..ab7c4403 --- /dev/null +++ b/repo/js/AutoProcess/manifest.json @@ -0,0 +1,14 @@ +{ + "manifest_version": 1, + "name": "自动食材加工", + "version": "1.0", + "description": "自动食材加工, 可自动获取加工完成食材,可指定制作食材.", + "authors": [ + { + "name": "听雨♪", + "link": "https://github.com/TingYu-lulumi" + } + ], + "settings_ui": "settings.json", + "main": "main.js" +} \ No newline at end of file diff --git a/repo/js/AutoProcess/settings.json b/repo/js/AutoProcess/settings.json new file mode 100644 index 00000000..17eff947 --- /dev/null +++ b/repo/js/AutoProcess/settings.json @@ -0,0 +1,7 @@ +[ + { + "name": "process", + "type": "input-text", + "label": "下面输入框填: 需要加工的食材, 序号为加工界面依次排序,\n英文逗号空格[, ]隔开, 不要输入括号, 只填数字逗号和空格\n如:\n[1, 5, 8, 9, 13](别填括号) 代表加工: 面粉, 奶油, 火腿, 糖, 奶酪" + } +] \ No newline at end of file diff --git a/repo/js/买菜/NPC_list.json b/repo/js/买菜/NPC_list.json new file mode 100644 index 00000000..d3d3ce75 --- /dev/null +++ b/repo/js/买菜/NPC_list.json @@ -0,0 +1,100 @@ +{ + "dongsheng": { + "npc_name": "东升", + "location_name": "东升", + "item_count": 12, + "spik_count": 4, + "daytimeOnly": 0 + }, + "laosun": { + "npc_name": "老孙", + "location_name": "老孙", + "item_count": 3, + "spik_count": 5, + "daytimeOnly": 1 + }, + "laogao": { + "npc_name": "老高", + "location_name": "老高", + "item_count": 3, + "spik_count": 5, + "daytimeOnly": 1 + }, + "maoshifu": { + "npc_name": "香菱她爹", + "location_name": "卯师父", + "item_count": 16, + "spik_count": 5, + "daytimeOnly": 0 + }, + "shala": { + "npc_name": "莎拉", + "location_name": "莎拉", + "item_count": 14, + "spik_count": 5, + "daytimeOnly": 0 + }, + "buluqi": { + "npc_name": "布兰琪", + "location_name": "布兰琪", + "item_count": 8, + "spik_count": 5, + "daytimeOnly": 0 + }, + "kui": { + "npc_name": "葵", + "location_name": "葵", + "item_count": 12, + "spik_count": 4, + "daytimeOnly": 0 + }, + "zckbw": { + "npc_name": "志村勘兵卫", + "location_name": "志村勘兵卫", + "item_count": 12, + "spik_count": 4, + "daytimeOnly": 0 + }, + "pomu": { + "npc_name": "珀姆", + "location_name": "珀姆", + "item_count": 4, + "spik_count": 4, + "daytimeOnly": 0 + }, + "hamawei": { + "npc_name": "哈马维", + "location_name": "哈马维", + "item_count": 13, + "spik_count": 5, + "daytimeOnly": 0 + }, + "buteluosi": { + "npc_name": "布特罗斯", + "location_name": "布特罗斯", + "item_count": 3, + "spik_count": 4, + "daytimeOnly": 0 + }, + "azhalai": { + "npc_name": "阿扎莱", + "location_name": "阿扎莱", + "item_count": 10, + "spik_count": 4, + "daytimeOnly": 2 + }, + "alue": { + "npc_name": "阿鲁埃", + "location_name": "阿鲁埃", + "item_count": 4, + "spik_count": 4, + "daytimeOnly": 0 + }, + "buxike": { + "npc_name": "布希柯", + "location_name": "布希柯", + "item_count": 14, + "spik_count": 4, + "daytimeOnly": 0 + } +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/东升.json b/repo/js/买菜/assets/AutoPath/东升.json new file mode 100644 index 00000000..f9c260dd --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/东升.json @@ -0,0 +1,30 @@ +{ + "info": { + "name": "ds", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 267.9560546875, + "y": -665.14794921875, + "action_params": "" + }, + { + "id": 2, + "x": 257.146484375, + "y": -682.4951171875, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/卯师父.json b/repo/js/买菜/assets/AutoPath/卯师父.json new file mode 100644 index 00000000..02032c10 --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/卯师父.json @@ -0,0 +1,39 @@ +{ + "info": { + "name": "卯师父", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 267.9580078125, + "y": -665.1201171875, + "action_params": "" + }, + { + "id": 2, + "x": 226.04296875, + "y": -660.0048828125, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": 227.4072265625, + "y": -668.20751953125, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/哈马维.json b/repo/js/买菜/assets/AutoPath/哈马维.json new file mode 100644 index 00000000..2ae080ed --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/哈马维.json @@ -0,0 +1,75 @@ +{ + "info": { + "name": "哈马维", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 2786.9755859375, + "y": -503.09130859375, + "action_params": "" + }, + { + "id": 2, + "x": 2788.0830078125, + "y": -488.28173828125, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": 2771.4755859375, + "y": -476.07421875, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 4, + "x": 2763.0478515625, + "y": -453.83349609375, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 5, + "x": 2760.521484375, + "y": -439.513671875, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 6, + "x": 2778.63671875, + "y": -435.7626953125, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 7, + "x": 2778.24609375, + "y": -430.80810546875, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/小畑.json b/repo/js/买菜/assets/AutoPath/小畑.json new file mode 100644 index 00000000..bf5b1da3 --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/小畑.json @@ -0,0 +1,121 @@ +{ + "info": { + "name": "小畑", + "type": "collect", + "author": "听雨♪", + "version": "", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "x": -3812.7041015625, + "y": -2546.6064453125, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": -3811.9248046875, + "y": -2567.5771484375, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 3, + "x": -3727.125996598583, + "y": -2570.25, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 4, + "x": -3720.250047457075, + "y": -2569.625 + }, + { + "id": 5, + "x": -3713.6250949141504, + "y": -2568.5 + }, + { + "id": 6, + "x": -3706.7501423712256, + "y": -2567.875 + }, + { + "id": 7, + "x": -3700.625284742451, + "y": -2566.875 + }, + { + "id": 8, + "x": -3693.2480542599114, + "y": -2564.875 + }, + { + "id": 9, + "x": -3684.874810171699, + "y": -2562.375 + }, + { + "id": 10, + "x": -3680.4998576287744, + "y": -2561.25 + }, + { + "id": 11, + "x": -3677.6251423712256, + "y": -2558.125 + }, + { + "id": 12, + "x": -3675.5, + "y": -2558.25, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 13, + "x": -3674.124952542925, + "y": -2560.125 + }, + { + "id": 14, + "x": -3672.624952542925, + "y": -2564, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 15, + "x": -3670.2495728863214, + "y": -2567.75 + }, + { + "id": 16, + "x": -3666.0014237122596, + "y": -2566 + }, + { + "id": 17, + "x": -3667.37571185613, + "y": -2561.125, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/布兰琪.json b/repo/js/买菜/assets/AutoPath/布兰琪.json new file mode 100644 index 00000000..9fe3e20a --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/布兰琪.json @@ -0,0 +1,39 @@ +{ + "info": { + "name": "布兰琪", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": -867.720703125, + "y": 2281.377685546875, + "action_params": "" + }, + { + "id": 2, + "x": -893.705078125, + "y": 2258.10791015625, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": -895.7216796875, + "y": 2264.712890625, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/布希柯.json b/repo/js/买菜/assets/AutoPath/布希柯.json new file mode 100644 index 00000000..5c0b2a1c --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/布希柯.json @@ -0,0 +1,57 @@ +{ + "info": { + "name": "布希柯", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 4508.96875, + "y": 3630.584228515625, + "action_params": "" + }, + { + "id": 2, + "x": 4514.79296875, + "y": 3605.441650390625, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": 4497.20556640625, + "y": 3586.030029296875, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 4, + "x": 4475.7421875, + "y": 3559.308837890625, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 5, + "x": 4470.52685546875, + "y": 3560.251708984375, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/布特罗斯.json b/repo/js/买菜/assets/AutoPath/布特罗斯.json new file mode 100644 index 00000000..f08a1e8b --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/布特罗斯.json @@ -0,0 +1,30 @@ +{ + "info": { + "name": "布特罗斯", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 2679.8427734375, + "y": -1935.005859375, + "action_params": "" + }, + { + "id": 2, + "x": 2659.951171875, + "y": -1928.943359375, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/志村勘兵卫.json b/repo/js/买菜/assets/AutoPath/志村勘兵卫.json new file mode 100644 index 00000000..f5f2e5f1 --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/志村勘兵卫.json @@ -0,0 +1,39 @@ +{ + "info": { + "name": "志村勘兵卫", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "x": -4402.5703125, + "y": -3053.0234375, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": -4418.000213556839, + "y": -3083.5625, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 3, + "x": -4424.500332199528, + "y": -3080.375, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/珀姆.json b/repo/js/买菜/assets/AutoPath/珀姆.json new file mode 100644 index 00000000..325a8940 --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/珀姆.json @@ -0,0 +1,39 @@ +{ + "info": { + "name": "珀姆", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 2786.958984375, + "y": -503.0859375, + "action_params": "" + }, + { + "id": 2, + "x": 2809.5712890625, + "y": -514.7138671875, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": 2811.244140625, + "y": -509.603515625, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/老孙.json b/repo/js/买菜/assets/AutoPath/老孙.json new file mode 100644 index 00000000..64d92cde --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/老孙.json @@ -0,0 +1,102 @@ +{ + "info": { + "name": "买鱼-1", + "type": "buy", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "x": 263.5, + "y": -672.5, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": 247.5, + "y": -664.5, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 3, + "x": 214.5, + "y": -661.5, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 4, + "x": 192.5, + "y": -682, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 5, + "x": 162.5, + "y": -681, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 6, + "x": 157.5000949141504, + "y": -630.375, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 7, + "x": 139.99022999999943, + "y": -608.2969000000003, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 8, + "x": 162.32030999999915, + "y": -592.3183600000002, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 9, + "x": 167.29102000000057, + "y": -599.75684, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 10, + "x": 163.2538999999997, + "y": -603.9433600000002, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/老高.json b/repo/js/买菜/assets/AutoPath/老高.json new file mode 100644 index 00000000..1df3d260 --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/老高.json @@ -0,0 +1,93 @@ +{ + "info": { + "name": "牢高", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "x": 263.5, + "y": -672.5, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": 247.5, + "y": -664.5, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 3, + "x": 214.5, + "y": -661.5, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 4, + "x": 192.5, + "y": -682, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 5, + "x": 162.5, + "y": -681, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 6, + "x": 157.5000949141504, + "y": -630.375, + "action": "", + "move_mode": "run", + "action_params": "", + "type": "path" + }, + { + "id": 7, + "x": 139.99022999999943, + "y": -608.2969000000003, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 8, + "x": 162.32030999999915, + "y": -592.3183600000002, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "path" + }, + { + "id": 9, + "x": 158.751953125, + "y": -586.27294921875, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/莎拉.json b/repo/js/买菜/assets/AutoPath/莎拉.json new file mode 100644 index 00000000..1b760bcf --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/莎拉.json @@ -0,0 +1,39 @@ +{ + "info": { + "name": "莎拉", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": -867.7138671875, + "y": 2281.37646484375, + "action_params": "" + }, + { + "id": 2, + "x": -891.755859375, + "y": 2255.769775390625, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": -888.6591796875, + "y": 2240.89892578125, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/葵.json b/repo/js/买菜/assets/AutoPath/葵.json new file mode 100644 index 00000000..a5f93297 --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/葵.json @@ -0,0 +1,30 @@ +{ + "info": { + "name": "葵", + "type": "collect", + "author": "听雨♪", + "version": "1.1", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "x": -4402.5390625, + "y": -3053.0341796875, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "teleport" + }, + { + "id": 2, + "x": -4402.687357628773, + "y": -3072.3125, + "action": "", + "move_mode": "walk", + "action_params": "", + "type": "target" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/阿扎莱.json b/repo/js/买菜/assets/AutoPath/阿扎莱.json new file mode 100644 index 00000000..65cb5607 --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/阿扎莱.json @@ -0,0 +1,66 @@ +{ + "info": { + "name": "阿扎莱", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 4096.03125, + "y": -2025.9755859375, + "action_params": "" + }, + { + "id": 2, + "x": 4085.078125, + "y": -2018.173828125, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": 4076.845703125, + "y": -1995.6533203125, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 4, + "x": 4100.158203125, + "y": -1986.6904296875, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 5, + "x": 4100.736328125, + "y": -1979.58837890625, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + }, + { + "id": 6, + "x": 4091.5751953125, + "y": -1980.16015625, + "type": "path", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/assets/AutoPath/阿鲁埃.json b/repo/js/买菜/assets/AutoPath/阿鲁埃.json new file mode 100644 index 00000000..dd3a8a7e --- /dev/null +++ b/repo/js/买菜/assets/AutoPath/阿鲁埃.json @@ -0,0 +1,57 @@ +{ + "info": { + "name": "ale", + "type": "collect", + "author": "听雨♪", + "version": "1.0", + "description": "", + "bgiVersion": "0.35.1" + }, + "positions": [ + { + "id": 1, + "action": "", + "move_mode": "walk", + "type": "teleport", + "x": 4645.490234375, + "y": 3467.8603515625, + "action_params": "" + }, + { + "id": 2, + "x": 4635.865234375, + "y": 3475.1591796875, + "type": "path", + "move_mode": "fly", + "action": "", + "action_params": "" + }, + { + "id": 3, + "x": 4639.42724609375, + "y": 3505.39697265625, + "type": "path", + "move_mode": "fly", + "action": "", + "action_params": "" + }, + { + "id": 4, + "x": 4622.95654296875, + "y": 3509.7421875, + "type": "path", + "move_mode": "fly", + "action": "stop_flying", + "action_params": "" + }, + { + "id": 5, + "x": 4602.0556640625, + "y": 3515.504150390625, + "type": "target", + "move_mode": "walk", + "action": "", + "action_params": "" + } + ] +} \ No newline at end of file diff --git a/repo/js/买菜/main.js b/repo/js/买菜/main.js new file mode 100644 index 00000000..01f28d8f --- /dev/null +++ b/repo/js/买菜/main.js @@ -0,0 +1,229 @@ +// main.js + + +let NPC_list = {}; + +async function setTime(hour, minute) { + // 关于setTime + // 原作者: Tim + // 脚本名称: SetTimeMinute - 精确调整游戏时间到分钟 + // 脚本版本: 1.0 + // Hash: f5c2547dfc286fc643c733d630f775e8fbf12971 + + // 设置游戏分辨率和DPI缩放 + setGameMetrics(1920, 1080, 1); + // 圆心坐标 + const centerX = 1441; + const centerY = 501.6; + // 半径 + const r1 = 30; + const r2 = 150; + const r3 = 300; + const stepDuration = 50; + + function getPosition(r, index) { + let angle = index * Math.PI / 720; + return [Math.round(centerX + r * Math.cos(angle)), Math.round(centerY + r * Math.sin(angle))]; + } + async function mouseClick(x, y) { + moveMouseTo(x, y); + await sleep(50); + leftButtonDown(); + await sleep(50); + leftButtonUp(); + await sleep(stepDuration); + } + async function mouseClickAndMove(x1, y1, x2, y2) { + moveMouseTo(x1, y1); + await sleep(50); + leftButtonDown(); + await sleep(50); + moveMouseTo(x2, y2); + await sleep(50); + leftButtonUp(); + await sleep(stepDuration); + } + async function setTime(hour, minute) { + const end = (hour + 6) * 60 + minute-20; + const n = 3; + for (let i = - n + 1; i < 1; i++) { + let [x,y] = getPosition(r1, end + i * 1440 / n); + await mouseClick(x, y); + } + let [x1,y1] = getPosition(r2, end + 5); + let [x2, y2] = getPosition(r3, end + 20 + 0.5); + await mouseClickAndMove(x1, y1, x2, y2); + } + + let h = Math.floor(hour+minute/60); + const m = Math.floor(hour*60+minute)-h*60; + h = ((h % 24) + 24) % 24; + log.info(`设置时间到 ${h} 点 ${m} 分`); + await keyPress("Escape"); + await sleep(1000); + await click(50,700); + await sleep(2000); + await setTime(h, m); + await sleep(1000); + await click(1500,1000);//确认 + await sleep(18000); + await keyPress("Escape"); + await sleep(2000); + await keyPress("Escape"); + await sleep(2000); + + // 最后恢复到听雨的分辨率 + setGameMetrics(2560, 1440, 1.5); +} + + +// 快速购买 +async function QucikBuy(count = 1) { + + for (let i = 0; i < count; i++) { + // 点击购买/兑换 + click(2230, 1370); + await sleep(100); // 等待窗口弹出 + + // 选中左边点 + moveMouseTo(1000, 806); + await sleep(100); + leftButtonDown(); + await sleep(50); + + // 向右滑动 + moveMouseBy(1200, 0); + await sleep(200); + leftButtonUp(); + await sleep(100); + + // 点击弹出页的购买/兑换 1560, 1040 + click(1560, 1040); + await sleep(500); + + // 点击空白处关闭 + click(936, 230); + await sleep(2000); + + } +} + +// 跳过对话 +async function Spik(count) { + await sleep(100); + for (let i = 0; i < count; i++) { + keyPress("VK_F"); + await sleep(2000); + } +} + +async function AutoPath(locationName) { + try { + let filePath = `assets/AutoPath/${locationName}.json`; + await pathingScript.runFile(filePath); + sleep(2000); + + return true; + } catch (error) { + log.error(`执行 ${locationName} 路径时发生错误`); + log.error(error.message); + } + + return false; +} + +async function AutoBuy(npc) { + let npc_name = NPC_list[npc].npc_name; + + log.info(`自动寻路, 前往 ${npc_name} 所在`) + + if (await AutoPath(NPC_list[npc].location_name)) { + + await Spik(NPC_list[npc].spik_count); + + log.info("已打开商店界面") + + await QucikBuy(NPC_list[npc].item_count); + + await sleep(1000); + await genshin.returnMainUi(); + log.info(`${npc_name} 的商品购买完毕`) + + + } else { + log.error("寻路错误, 跳过购买任务") + }; +} + +(async function () { + + // ==================== 加载NPC列表 =================== + + try { + const NPCText = file.readTextSync("NPC_list.json"); + NPC_list = JSON.parse(NPCText); + log.info("NPC信息加载完成"); + } catch (e) { + log.error("NPC信息文件损坏,脚本终止"); + return; + } + + //设置脚本环境的游戏分辨率和DPI缩放 + setGameMetrics(2560, 1440, 1.5); + + log.info("┌───────────────────────────────────────────────────┐"); + log.info(" 在设置中勾选禁用的NPC.") + await sleep(400); + log.info(" 调试器添加脚本后, 右键脚本->修改JS脚本自定义配置.") + await sleep(400); + log.info(" 但是, BetterGI有Bug, 只能现实9个设置...") + await sleep(400); + log.info(" 要不, 你直接删掉不想要的NPC文件吧, 删除方法: ") + await sleep(400); + log.info(" JS脚本->打开目录->进入当前项目/assets/AutoPath文件夹") + await sleep(400); + log.info("└───────────────────────────────────────────────────┘") + await sleep(400); + + + try { + for (let key in NPC_list) { + + let name = NPC_list[key].npc_name; + + log.info(`======== 当前目标NPC: ${name} ========`); + await sleep(400); + + if (settings[key]) { + log.info(` 玩家已标记, 跳过`); + continue; + }; + + if (NPC_list[key].daytimeOnly == 1) { + log.info("当前NPC只有白天才刷新, 调整时间"); + await sleep(3000); + await setTime(9, 0); + } else if (NPC_list[key].daytimeOnly == 2) { + log.info("当前NPC只有晚上更合适, 调整时间"); + await sleep(3000); + await setTime(20, 0); + } + + + + await AutoBuy(key); + await sleep(2000); + }; + + } catch (e) { + log.error(`发生异常: ${e.message}`); + await sleep(3000); + } finally { + + log.info("┌────────────────────────────┐") + log.info(" 感谢您的使用, 任务已全部完成") + log.info(" 拜拜") + log.info(" Done.") + log.info("└────────────────────────────┘") + } +})(); \ No newline at end of file diff --git a/repo/js/买菜/manifest.json b/repo/js/买菜/manifest.json new file mode 100644 index 00000000..bbe35a03 --- /dev/null +++ b/repo/js/买菜/manifest.json @@ -0,0 +1,14 @@ +{ + "manifest_version": 1, + "name": "购买食材-自动购物", + "version": "1.0.3", + "description": "一个自动买菜脚本, 目前只添加了15个NPC. 一些NPC商人的信息作者可能不知道, 白淞镇、离岛、竞技场NPC无法识别坐标信息.", + "authors": [ + { + "name": "听雨♪", + "link": "https://github.com/TingYu-lulumi" + } + ], + "settings_ui": "settings.json", + "main": "main.js" +} \ No newline at end of file diff --git a/repo/js/买菜/settings.json b/repo/js/买菜/settings.json new file mode 100644 index 00000000..c5049407 --- /dev/null +++ b/repo/js/买菜/settings.json @@ -0,0 +1,67 @@ +[ + { + "name": "dongsheng", + "type": "checkbox", + "label": "东升" + }, + { + "name": "laosun", + "type": "checkbox", + "label": "老孙" + }, + { + "name": "laogao", + "type": "checkbox", + "label": "老高" + }, + { + "name": "maoshifu", + "type": "checkbox", + "label": "卯师父" + }, + { + "name": "shala", + "type": "checkbox", + "label": "莎拉" + }, + { + "name": "buluqi", + "type": "checkbox", + "label": "布兰琪" + }, + { + "name": "kui", + "type": "checkbox", + "label": "葵" + }, + { + "name": "zckbw", + "type": "checkbox", + "label": "志村勘兵卫" + }, + { + "name": "pomu", + "type": "checkbox", + "label": "珀姆" + }, + { + "name": "buteluosi", + "type": "checkbox", + "label": "布特罗斯" + }, + { + "name": "ahalai", + "type": "checkbox", + "label": "阿扎莱" + }, + { + "name": "alue", + "type": "checkbox", + "label": "阿鲁埃" + }, + { + "name": "buxike", + "type": "checkbox", + "label": "布希柯" + } +] \ No newline at end of file