JS:自动购买每天&3天&每周刷新食材 (#1672)

上傳基本框架、供用戶自行下載修改、提供部份預設購買選項
This commit is contained in:
this-Fish
2025-08-23 09:07:29 +08:00
committed by GitHub
parent f6e3fde89d
commit 36b3e8f125
36 changed files with 2086 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
# 說明
## 本JS脚本只是基本框架
- 由于提瓦特贩卖食物的商人太多,做成选项会太长,不方便操作,因此只制作主要框架。
- 需要购买预设中没有的食材,可参照以下步骤操作
# 如何加入自定义食材
- 为方便后续维护,整个流程可分为以下五个主要步骤
步骤 1准备食材图片
- 进入游戏中的购买页面,截取你要添加的食材在界面上的显示图。
- 参考 assets/images/ 目录下已有的食材图片,调整截图为 90×90px。
- 将裁剪好的图片命名为 <食材名称>.png例如新食材.png并拷贝至项目的 assets/images/ 目录下。
步骤 2录制卖食物NPC的行走路径
- 启动脚本录制工具,前往并与“卖食物 NPC”互动的地图位置。
- 结束录制后,将生成的路径脚本文件重命名为 <食物NPC名称>.json例如新卖食物NPC.json
- 将此 JSON 文件放入项目的 assets/path/ 目录下。
步骤 3更新 settings.json
打开根目录下的 settings.json在合适的配置节点中
- 找到与“购买食材”相关的字段(参考其他已有选项)。
- 复制一组模板配置,并将其中的字段值,替换为你定义的“食材名称”。
- 示例结构:
```
,
{
"name": "新食材",
"type": "checkbox",
"label": "新食材",
"default": true
}
```
步骤 4修改 main.js
在 main.js 中,需要同时在两个数据结构里新增对应条目。
- npcData
- 参考文件末尾的注释,按格式插入一段新的 NPC 对象。
- 示例:
```
,
"新卖食物NPC": { // NPC名字
"name": "新卖食物NPC", // NPC名字
"enable": true,
"page": 1, // 商人卖的物品页数
"time": "any", //any 不调时间,day 早上8点, night 晚上8点
"path": "assets/path/新卖食物NPC.json", //写入 卖食物NPC路径名
"_1d_foods": ["新食材"]// 写入 新加入 每天刷新的 食材名字
"_3d_foods": ["新食材"]// 写入 新加入 每3天刷新的 食材名字
"_7d_foods": ["新食材"]// 写入 新加入 每週刷新的 食材名字
}
```
- foodsData
- 参考末尾注解,新增新的食材配置。
- 示例:
```
,
"新食材": {
"id": "新食材",
"name": "新食材",
"file": "assets/images/新食材.png"
}
```
步骤 5重新配置并运行
- 打开项目中的“配置组”界面,勾选或填写你新添加的“食材”采购项。
- 保存设置后,重启脚本并验证能否正确购买并交互。

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@@ -0,0 +1,80 @@
{
"info": {
"name": "丰泰",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755458383522,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 2358.486328125,
"y": 2414.624267578125,
"type": "teleport",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 2,
"x": 2383.8759765625,
"y": 2422.88525390625,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 3,
"x": 2403.166015625,
"y": 2451.765869140625,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": 2410.52734375,
"y": 2472.515625,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 5,
"x": 2411.5615234375,
"y": 2472.385498046875,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 6,
"x": 2416.25390625,
"y": 2470.166259765625,
"type": "path",
"move_mode": "fly",
"action": "",
"action_params": ""
},
{
"id": 7,
"x": 2419.7177734375,
"y": 2471.349365234375,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,44 @@
{
"info": {
"name": "兰巴德",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755878101790,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 2786.9990234375,
"y": -503.1044921875,
"type": "teleport",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 2,
"x": 2792.552734375,
"y": -494.91552734375,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 3,
"x": 2807.626953125,
"y": -485.35498046875,
"type": "target",
"move_mode": "walk",
"action": "combat_script",
"action_params": "wait(0.5),keypress(F),wait(7.5),a(3),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),keyup(W),wait(0.5),keydown(D),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),keyup(D),wait(1)"
}
]
}

View File

@@ -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": ""
}
]
}

View File

@@ -0,0 +1,62 @@
{
"info": {
"name": "夏安卡",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755882729510,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 9050.31640625,
"y": -1847.1708984375,
"action": "combat_script",
"move_mode": "walk",
"action_params": "wait(3)",
"type": "teleport"
},
{
"id": 2,
"x": 9097.8671875,
"y": -1854.76904296875,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 3,
"x": 9119.1484375,
"y": -1877.7939453125,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": 9106.8212890625,
"y": -1883.67822265625,
"type": "path",
"move_mode": "fly",
"action": "stop_flying",
"action_params": ""
},
{
"id": 5,
"x": 9108.3681640625,
"y": -1874.27490234375,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,107 @@
{
"info": {
"name": "安特曼",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755105350512,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 4258.6796875,
"y": 2704.254150390625,
"action": "combat_script",
"move_mode": "walk",
"action_params": "wait(3);",
"type": "teleport"
},
{
"id": 1,
"x": 4265.107421875,
"y": 2706.173095703125,
"action": "combat_script",
"move_mode": "walk",
"action_params": "wait(1);",
"type": "orientation"
},
{
"id": 2,
"x": 4265.107421875,
"y": 2706.173095703125,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "path"
},
{
"id": 3,
"x": 4272.7890625,
"y": 2705.315673828125,
"action": "",
"move_mode": "fly",
"action_params": "",
"type": "path"
},
{
"id": 4,
"x": 4292.75,
"y": 2715.16357421875,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 5,
"x": 4292.75,
"y": 2715.16357421875,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 6,
"x": 4296.80859375,
"y": 2731.96142578125,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 7,
"x": 4301.6787109375,
"y": 2744.9306640625,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "target"
},
{
"id": 8,
"x": 4296.6884765625,
"y": 2751.006103515625,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 9,
"x": 4293.88671875,
"y": 2754.57958984375,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "target"
}
]
}

View File

@@ -0,0 +1,80 @@
{
"info": {
"name": "小畑",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755877453473,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"action": "",
"move_mode": "walk",
"type": "teleport",
"x": -3635.791015625,
"y": -2528.8515625,
"action_params": ""
},
{
"id": 2,
"x": -3650.06640625,
"y": -2531.857421875,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 3,
"x": -3676.482421875,
"y": -2558.896484375,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": -3673.88671875,
"y": -2564.3662109375,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 5,
"x": -3668.982421875,
"y": -2564.150390625,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 6,
"x": -3664.9921875,
"y": -2562.474609375,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 7,
"x": -3667.560546875,
"y": -2561.896484375,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,80 @@
{
"info": {
"name": "巴巴克",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755880380798,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 2580.2822265625,
"y": -1901.78125,
"type": "teleport",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 2,
"x": 2520.576171875,
"y": -1894.04150390625,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 3,
"x": 2509.7666015625,
"y": -1898.10546875,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": 2509.0458984375,
"y": -1904.0712890625,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 5,
"x": 2503.0390625,
"y": -1932.6689453125,
"type": "path",
"move_mode": "fly",
"action": "stop_flying",
"action_params": "1500"
},
{
"id": 6,
"x": 2480.185546875,
"y": -1962.287109375,
"type": "path",
"move_mode": "dash",
"action": "",
"action_params": ""
},
{
"id": 7,
"x": 2470.3173828125,
"y": -1952.361328125,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -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": ""
}
]
}

View File

@@ -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"
}
]
}

View File

@@ -0,0 +1,135 @@
{
"info": {
"name": "朱特",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755105655794,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 2790.900390625,
"y": -480.8681640625,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "teleport"
},
{
"id": 2,
"x": 2790.9003,
"y": -480.8681,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "orientation",
"locked": false
},
{
"id": 3,
"x": 2788.1328125,
"y": -487.5517578125,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 4,
"x": 2771.341796875,
"y": -477.4921875,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 5,
"x": 2766.162109375,
"y": -455.5283203125,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 6,
"x": 2765.013671875,
"y": -439.556640625,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 7,
"x": 2785.671875,
"y": -433.083984375,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 8,
"x": 2791.416015625,
"y": -433.494140625,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "target"
},
{
"id": 9,
"x": 2796.025390625,
"y": -424.10693359375,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 10,
"x": 2787.1064453125,
"y": -412.7939453125,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 11,
"x": 2785.7255859375,
"y": -396.61865234375,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 12,
"x": 2773.41015625,
"y": -394.9638671875,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 13,
"x": 2772.9501953125,
"y": -398.20166015625,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "target"
}
]
}

View File

@@ -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": ""
}
]
}

View File

@@ -0,0 +1,35 @@
{
"info": {
"name": "神奇的霍普金斯",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755552575866,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"action": "",
"move_mode": "walk",
"type": "teleport",
"x": -867.2578125,
"y": 1992.55078125,
"action_params": ""
},
{
"id": 2,
"x": -874.9453125,
"y": 1974.10888671875,
"type": "target",
"move_mode": "dash",
"action": "",
"action_params": ""
}
]
}

View File

@@ -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": ""
}
]
}

View File

@@ -0,0 +1,71 @@
{
"info": {
"name": "莎拉",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755881926983,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": -875.50390625,
"y": 2277.739013671875,
"type": "teleport",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 2,
"x": -866.3203125,
"y": 2269.84423828125,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 3,
"x": -873.82421875,
"y": 2263.709228515625,
"type": "path",
"move_mode": "jump",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": -871.828125,
"y": 2252.876953125,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 5,
"x": -888.587890625,
"y": 2244.2392578125,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 6,
"x": -888.546875,
"y": 2240.7978515625,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,95 @@
{
"info": {
"name": "菲尔戈黛特",
"type": "collect",
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"authors": [
{
"name": "小鹰划船不用桨",
"links": ""
}
],
"tags": [],
"last_modified_time": 1755787602123,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 328.9580078125,
"y": 873.63818359375,
"type": "teleport",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 2,
"x": 324.8349609375,
"y": 883.72021484375,
"type": "orientation",
"move_mode": "walk",
"action": "combat_script",
"action_params": "wait(1)",
"locked": false
},
{
"id": 3,
"x": 324.8349609375,
"y": 883.72021484375,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": 334.140625,
"y": 890.552734375,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 5,
"x": 342.5732421875,
"y": 892.7685546875,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 6,
"x": 345.8505859375,
"y": 905.4677734375,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 7,
"x": 346.7978515625,
"y": 909.10205078125,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 8,
"x": 347.021484375,
"y": 909.1572265625,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,71 @@
{
"info": {
"name": "连芳",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755459619043,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 2358.486328125,
"y": 2414.624267578125,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "teleport"
},
{
"id": 2,
"x": 2358.1201171875,
"y": 2399.650146484375,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "path"
},
{
"id": 3,
"x": 2330.078125,
"y": 2355.36328125,
"type": "path",
"move_mode": "fly",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": 2337.689453125,
"y": 2334.9716796875,
"type": "path",
"move_mode": "fly",
"action": "stop_flying",
"action_params": "1500"
},
{
"id": 5,
"x": 2344.7685546875,
"y": 2326.4501953125,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 6,
"x": 2341.19140625,
"y": 2328.188720703125,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,53 @@
{
"info": {
"name": "钦特利",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755459811527,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 9050.31640625,
"y": -1847.1708984375,
"type": "teleport",
"move_mode": "walk",
"action": "combat_script",
"action_params": "wait(3)"
},
{
"id": 2,
"x": 9066.5966796875,
"y": -1848.400390625,
"action": "combat_script",
"move_mode": "walk",
"action_params": "wait(1)",
"type": "orientation"
},
{
"id": 3,
"x": 9066.5966796875,
"y": -1848.400390625,
"type": "path",
"move_mode": "walk",
"action": "",
"action_params": ""
},
{
"id": 4,
"x": 9069.109375,
"y": -1844.9423828125,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,89 @@
{
"info": {
"name": "阿桂",
"type": "collect",
"authors": [],
"version": "1.0",
"description": "",
"map_name": "Teyvat",
"bgi_version": "0.45.0",
"tags": [],
"last_modified_time": 1755881002590,
"enable_monster_loot_split": false,
"map_match_method": ""
},
"positions": [
{
"id": 1,
"x": 366.71484375,
"y": -502.51123046875,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "teleport"
},
{
"id": 2,
"x": 377.2236328125,
"y": -514.84228515625,
"action": "",
"move_mode": "jump",
"action_params": "",
"type": "path"
},
{
"id": 3,
"x": 392.994140625,
"y": -519.310546875,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "path"
},
{
"id": 4,
"x": 415.2880859375,
"y": -496.7744140625,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 5,
"x": 421.119140625,
"y": -486.3818359375,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "path"
},
{
"id": 6,
"x": 440.5869140625,
"y": -483.38134765625,
"action": "",
"move_mode": "walk",
"action_params": "",
"type": "path"
},
{
"id": 7,
"x": 434.595703125,
"y": -432.42529296875,
"action": "",
"move_mode": "dash",
"action_params": "",
"type": "path"
},
{
"id": 8,
"x": 433.8095703125,
"y": -427.994140625,
"type": "target",
"move_mode": "walk",
"action": "",
"action_params": ""
}
]
}

View File

@@ -0,0 +1,649 @@
const AFK = parseInt(settings.AKF) || 1; // 从settings读取用户选择的购买日
const AFKDay = AFK === 7 ? 0 : AFK; // 将7转换为0周日
const npcData = {
"莎拉": {
"name": "莎拉",
"enable": true,
"page": 4,
"time": "night",
"path": "assets/path/莎拉.json",
"_7d_foods": ["蟹黃"]
},
"神奇的霍普金斯": {
"name": "神奇的霍普金斯",
"enable": true,
"page": 2,
"time": "day",
"path": "assets/path/神奇的霍普金斯.json",
"_1d_foods": ["圣水"]
},
"ChefMao": {
"name": "香菱爹",
"enable": true,
"page": 5,
"time": "any",
"path": "assets/path/卯师父.json",
"_1d_foods": ["螃蟹"],
"_3d_foods": ["胡梦卜", "松茸"]
},
"UncleSun": {
"name": "奸商老孙",
"enable": true,
"page": 1,
"time": "day",
"path": "assets/path/老孙.json",
"_1d_foods": ["螃蟹"],
},
"阿桂": {
"name": "阿桂",
"enable": true,
"page": 2,
"time": "night",
"path": "assets/path/阿桂.json",
"_3d_foods": ["清心", "琉璃袋"]
},
"菲尔戈黛特": {
"name": "菲尔戈黛特",
"enable": true,
"page": 2,
"time": "any",
"path": "assets/path/菲尔戈黛特.json",
"_3d_foods": ["松茸", "琉璃袋"]
},
"丰泰": {
"name": "丰泰",
"enable": true,
"page": 2,
"time": "any",
"path": "assets/path/丰泰.json",
"_3d_foods": ["沉玉仙茗", "琉璃袋"],
"_7d_foods": ["蟹黃"]
},
"连芳": {
"name": "连芳",
"enable": true,
"page": 2,
"time": "any",
"path": "assets/path/连芳.json",
"_3d_foods": ["沉玉仙茗"]
},
"Obata": {
"name": "小畑",
"enable": true,
"page": 1,
"time": "any",
"path": "assets/path/小畑.json",
"_1d_foods": ["螃蟹"],
},
"ShimuraKanbei": {
"name": "志村勘兵卫",
"enable": true,
"page": 4,
"time": "any",
"path": "assets/path/志村勘兵卫.json",
"_1d_foods": ["螃蟹"],
"_3d_foods": ["堇瓜"]
},
"Zhute": {
"name": "朱特",
"enable": true,
"page": 1,
"time": "any",
"path": "assets/path/朱特.json",
"_3d_foods": ["帕蒂沙兰"]
},
"Butrus": {
"name": "布特罗斯",
"enable": true,
"page": 1,
"time": "any",
"path": "assets/path/布特罗斯.json",
"_1d_foods": ["螃蟹"],
},
"Pam": {
"name": "珀姆",
"enable": true,
"page": 1,
"time": "any",
"path": "assets/path/珀姆.json",
"_1d_foods": ["螃蟹"],
},
"Lambad": {
"name": "兰巴德",
"enable": true,
"page": 3,
"time": "any",
"path": "assets/path/兰巴德.json",
"_1d_foods": ["螃蟹"],
},
"巴巴克": {
"name": "巴巴克",
"enable": true,
"page": 1,
"time": "any",
"path": "assets/path/巴巴克.json",
"_3d_foods": ["清心", "琉璃袋"]
},
"Antman": {
"name": "安特曼",
"enable": true,
"page": 1,
"time": "any",
"path": "assets/path/安特曼.json",
"_1d_foods": ["螃蟹"],
"_3d_foods": ["海露花","汐藻"]
},
"钦特利": {
"name": "钦特利",
"enable": true,
"page": 1,
"time": "any",
"path": "assets/path/钦特利.json",
"_3d_foods": ["青蜜梅", "苦种"]
},
"夏安卡": {
"name": "夏安卡",
"enable": true,
"page": 3,
"time": "any",
"path": "assets/path/夏安卡.json",
"_7d_foods": ["蟹黃"]
}
// // 參考
// ,
// "新卖食物NPC": { // NPC名字
// "name": "新卖食物NPC", // NPC名字
// "enable": true,
// "page": 1, // 商人卖的物品页数
// "time": "any", //any 不调时间,day 早上8点, night 晚上8点
// "path": "assets/path/新卖食物NPC.json", //写入 卖食物NPC路径名
// "_3d__3d_foods": ["新食材"]// 写入 新加入 的 食材名字
// }
}
const foodsData = {
"huMengbu": {
"id": "huMengbu",
"name": "胡梦卜",
"file": "assets/images/huMengbu.png"
},
"viola": {
"id": "viola",
"name": "堇瓜",
"file": "assets/images/viola.png"
},
"romaritimeFlower": {
"id": "romaritimeFlower",
"name": "海露花",
"file": "assets/images/romaritimeFlower.png"
},
"Padisarah": {
"id": "Padisarah",
"name": "帕蒂沙兰",
"file": "assets/images/Padisarah.png"
},
"松茸": {
"id": "松茸",
"name": "松茸",
"file": "assets/images/松茸.png"
},
"沉玉仙茗": {
"id": "沉玉仙茗",
"name": "沉玉仙茗",
"file": "assets/images/沉玉仙茗.png"
},
"青蜜梅": {
"id": "青蜜梅",
"name": "青蜜梅",
"file": "assets/images/青蜜梅.png"
},
"苦种": {
"id": "苦种",
"name": "苦种",
"file": "assets/images/苦种.png"
},
"清心": {
"id": "清心",
"name": "清心",
"file": "assets/images/清心.png"
},
"琉璃袋": {
"id": "琉璃袋",
"name": "琉璃袋",
"file": "assets/images/琉璃袋.png"
},
"蟹黃": {
"id": "蟹黃",
"name": "蟹黃",
"file": "assets/images/蟹黃.png"
},
"crab": {
"id": "crab",
"name": "螃蟹",
"file": "assets/images/crab.png"
},
"tidalga": {
"id": "tidalga",
"name": "汐藻",
"file": "assets/images/tidalga.png"
}
// // 參考
// ,
// "新食材": {
// "id": "新食材",
// "name": "新食材",
// "file": "assets/images/新食材.png"
// }
};
const translationList = {};
const enableFoods = new Set([]);
const othrtRo = {
"buy": {
"name": "购买按钮",
"file": "assets/images/buyBtn.png"
}
}
// ==================== 新增函数:判断是否是刷新日 ====================
function isRefreshDay() {
// 1. 计算基准刷新时间的 UTC 毫秒值
// 2025-08-09 04:00 (GMT+8) == 2025-08-08 20:00Z
const baseUtcMs = Date.UTC(2025, 7, 8, 20, 0, 0);
// 2. 获取当前时间的 UTC 毫秒
const now = new Date();
const utcNowMs = now.getTime() + now.getTimezoneOffset() * 60 * 1000;
// 3. 构造 GMT+8 的时间对象
const gmt8Ms = utcNowMs + 8 * 60 * 60 * 1000;
const gmt8Date = new Date(gmt8Ms);
// 4. 如果还没到“当天”凌晨 4 点,算作前一天
if (gmt8Date.getHours() < 4) {
gmt8Date.setDate(gmt8Date.getDate() - 1);
// 加12小時避免常作前一天0:0至4:0
gmt8Date.setTime(gmt8Date.getTime() + 12 * 60 * 60 * 1000);
}
// 5. 计算天数差并判断是否为 3 的倍数
const daysDiff = Math.floor((gmt8Date.getTime() - baseUtcMs) / (24 * 60 * 60 * 1000));
return daysDiff >= 0 && daysDiff % 3 === 0;
}
// 获取游戏内时间考虑4点刷新
function getGameTime() {
const now = new Date();
const utcNowMs = now.getTime() + now.getTimezoneOffset() * 60 * 1000;
const gmt8Ms = utcNowMs + 8 * 60 * 60 * 1000;
const gmt8Date = new Date(gmt8Ms);
// 如果还没到凌晨4点算作前一天
if (gmt8Date.getHours() < 4) {
gmt8Date.setDate(gmt8Date.getDate() - 1);
}
return gmt8Date;
}
// 设置游戏时间
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);
}
// 地图追踪
async function autoPath(locationPath) {
try {
let filePath = locationPath;
await pathingScript.runFile(filePath);
sleep(2000);
return true;
} catch (error) {
log.error(`执行 ${locationName} 路径时发生错误`);
log.error(error.message);
}
return false;
}
// 平滑过渡函数(缓动效果)
function smoothStep(t) {
return t * t * (3 - 2 * t);
}
// 模拟鼠标移动到指定位置(带曲线路径)
async function naturalMove(initX, initY, targetX, targetY, duration, wiggle = 30) {
// 生成控制点(使路径形成曲线)
const controlX = (initX + targetX) / 2 + (Math.random() * wiggle * 2 - wiggle);
const controlY = (initY + targetY) / 2 + (Math.random() * wiggle * 2 - wiggle);
const steps = Math.max(duration / 20, 10); // 计算步数
for (let i = 0; i <= steps; i++) {
const progress = i / steps;
const t = smoothStep(progress); // 使用平滑过渡
// 二次贝塞尔曲线计算
const x = (1 - t) * (1 - t) * initX + 2 * (1 - t) * t * controlX + t * t * targetX;
const y = (1 - t) * (1 - t) * initY + 2 * (1 - t) * t * controlY + t * t * targetY;
moveMouseTo(Math.trunc(x), Math.trunc(y));
// 随机延迟使移动更自然
await sleep(Math.trunc(duration / steps * (0.8 + Math.random() * 0.4)));
}
// 确保最终位置准确
moveMouseTo(targetX, targetY);
}
// 切换下一页商品
async function nextFoodsPage() {
//设置脚本环境的游戏分辨率和DPI缩放
setGameMetrics(3840, 2160, 1.5);
let [initX, initY] = [1500, 1850];
let [targetX, targetY] = [1800, 260];
moveMouseTo(initX, initY);
leftButtonDown();
await naturalMove(initX, initY, targetX, targetY, 300);
// 按住了, 防止弹太远
await sleep(520);
leftButtonUp();
}
// 快速购买
async function qucikBuy() {
//设置脚本环境的游戏分辨率和DPI缩放
setGameMetrics(3840, 2160, 1.5);
let [buyBtnX, buyBtnY] = [3200, 2045];
let [confirmBtnX, confirmBtnY] = [2025, 1570];
let [addNumX, addNumY] = [2060, 1208];
// 等待界面切换
await sleep(200);
// 查找购买按钮
let captureRegion = captureGameRegion();
let buyBtn = captureRegion.Find(othrtRo.buy.ro);
if (buyBtn.isEmpty()) {
return false;
}
// 点击购买按钮
click(buyBtn.x * 2 + buyBtn.width, buyBtn.y * 2 + buyBtn.height);
// 等待购买窗口弹出
await sleep(300);
// 增加数量至最大
leftButtonDown();
await naturalMove(addNumX, addNumY, addNumX + 666, addNumY - 233, 100);
leftButtonUp();
// 点击确认按钮
click(confirmBtnX, confirmBtnY);
// 等待购买完成
await sleep(200);
// 点击空白关闭
click(buyBtnX, buyBtnY);
await sleep(200);
return true;
}
// 跳过对话
async function spikChat(npcName) {
count = 5
await sleep(1000);
for (let i = 0; i < count; i++) {
keyPress("VK_F");
await sleep(1300);
}
}
// 购买逻辑
async function buyFoods(npcName) {
// 设置脚本环境的游戏分辨率和DPI缩放
setGameMetrics(3840, 2160, 1.5);
let tempFoods = [...npcData[npcName].enableFoods];
// 多页购买
for (let i = 0; i < npcData[npcName].page; i++) {
log.info("购买列表: {foods}", [...tempFoods].join(", "));
// 获取一张截图
let captureRegion = captureGameRegion();
// 记录已经购买的物品
let boughtFoods = new Set([]);
// 匹配商品
for (let item of tempFoods) {
let resList = captureRegion.FindMulti(foodsData[item].ro);
for (let res of resList) {
log.info("找到物品: {i} 位置({x},{y},{h},{w})", foodsData[item].name, res.x, res.y, res.width, res.height);
// 移除已购买的物品
boughtFoods.add(item);
// 点击商品
click(res.x * 2 + res.width, res.y * 2 + res.height);
if (await qucikBuy()) {
log.info("购买成功: {item}", foodsData[item].name);
await sleep(1000);
// 重新截图
captureRegion = captureGameRegion();
}
else {
log.info("购买失败: {item}, 背包已经满或商品已售罄", foodsData[item].name);
}
}
}
// 从已购买物品中移除
tempFoods = tempFoods.filter(item => !boughtFoods.has(item));
// 若不是最后一页且还有未购买的物品
if (tempFoods.length > 0 && i !== npcData[npcName].page - 1) {
log.info("切换到下一页商品");
await nextFoodsPage();
// 最后一次切换界面, 等待UI回弹
if (i === npcData[npcName].page - 2) {
log.info("等待界面回弹");
await sleep(500);
}
}
}
}
// 初始化NPC商品
async function initNpcData() {
// 获取游戏内时间考虑4点刷新
const gameTime = getGameTime();
const gameDay = gameTime.getDay(); // 游戏内的星期几0-6
// log.info(`游戏内时间: ${gameTime}, 星期: ${gameDay}, 用户选择的购买日: ${AFKDay}`);
for (let [key, npc] of Object.entries(npcData)) {
// 翻译物品名称
let npcFoods = new Set([]);
// 添加每天刷新周期的商品(如果存在)
if (npc._1d_foods && npc._1d_foods.length > 0) {
npc._1d_foods.forEach(item => {
npcFoods.add(translationList[item]);
});
}
// ==================== 检查是否是刷新日 ====================
if (isRefreshDay()) {
// 添加3天刷新周期的商品如果存在
if (npc._3d_foods && npc._3d_foods.length > 0) {
npc._3d_foods.forEach(item => {
npcFoods.add(translationList[item]);
});
}
}
// ==================== 检查是否是用户选择的购买日 ====================
if (gameDay === AFKDay) {
// 添加7天刷新周期的商品如果存在
if (npc._7d_foods && npc._7d_foods.length > 0) {
npc._7d_foods.forEach(item => {
npcFoods.add(translationList[item]);
});
}
}
// 筛选已启用的商品
npc.enableFoods = [...enableFoods].filter(item => npcFoods.has(item));
// 如果没有启用的商品, 则不启用该NPC
if (npc.enableFoods.length === 0) {
npc.enable = false;
}
}
}
// 加载识别对象
async function initRo() {
try {
// 加载识别对象
for (let [key, item] of Object.entries(foodsData)) {
// 填充中英文对照表
translationList[item.name] = item.id;
// 判断启动商品、加载识别对象
if (settings[item.id]) {
enableFoods.add(item.id);
item.ro = RecognitionObject.TemplateMatch(file.ReadImageMatSync(item.file));
item.ro.Threshold = 0.75;
item.ro.Use3Channels = true;
}
}
// 加载其他识别对象
for (let [key, item] of Object.entries(othrtRo)) {
item.ro = RecognitionObject.TemplateMatch(file.ReadImageMatSync(item.file));
item.ro.Threshold = 0.85;
}
return true;
}
catch (error) {
log.error("加载识别对象时发生错误: {error}", error.message);
throw error;
}
}
(async function () {
// ==================== 初始化识别对象 ====================
await initRo();
log.info("识别对象初始化完成");
// ==================== 初始化NPC数据 ====================
await initNpcData();
log.info("NPC数据初始化完成");
// ==================== 自动购买 ====================
for (let [key, npc] of Object.entries(npcData)) {
if (npc.enable) {
await genshin.returnMainUi();
log.info("开始购买NPC: {npcName}", npc.name);
// 设置游戏时间
if (npc.time === "night") {
await setTime(20, 0); // 设置为晚上8点
}
else if (npc.time === "day") {
await setTime(8, 0); // 设置为早上8点
}
await autoPath(npc.path);
await spikChat(npc.name);
await buyFoods(key);
// 返回主界面
await genshin.returnMainUi();
log.info("完成购买NPC: {npcName}", npc.name);
}
else {
log.info("跳过未启用的NPC: {npcName}", npc.name);
}
}
})();

View File

@@ -0,0 +1,17 @@
{
"manifest_version": 1,
"name": "自动购买每天&3天&每周刷新食材",
"version": "1.0",
"description": "自动购买每天&3天&每周刷新食材\n每天刷新食材自动购买食材\n3天刷新食材未到刷新日不购买该食材\n每周刷新食材可指定每周购买食材",
"authors": [
{
"name": "蜜柑魚",
"links": "https://github.com/this-Fish"
}
],
"tags": [
"购买食材"
],
"settings_ui": "settings.json",
"main": "main.js"
}

View File

@@ -0,0 +1,101 @@
[
{
"name": "圣水",
"type": "checkbox",
"label": "每天刷新食材\n\n圣水",
"default": true
},
{
"name": "crab",
"type": "checkbox",
"label": "螃蟹",
"default": true
},
{
"name": "松茸",
"type": "checkbox",
"label": "-----------------\n3天刷新食材\n\n松茸",
"default": true
},
{
"name": "huMengbu",
"type": "checkbox",
"label": "胡梦卜",
"default": true
},
{
"name": "沉玉仙茗",
"type": "checkbox",
"label": "沉玉仙茗",
"default": true
},
{
"name": "清心",
"type": "checkbox",
"label": "清心",
"default": true
},
{
"name": "琉璃袋",
"type": "checkbox",
"label": "琉璃袋",
"default": true
},
{
"name": "viola",
"type": "checkbox",
"label": "堇瓜",
"default": true
},
{
"name": "Padisarah",
"type": "checkbox",
"label": "帕蒂沙兰",
"default": true
},
{
"name": "romaritimeFlower",
"type": "checkbox",
"label": "海露花",
"default": true
},
{
"name": "tidalga",
"type": "checkbox",
"label": "汐藻",
"default": true
},
{
"name": "苦种",
"type": "checkbox",
"label": "苦种",
"default": true
},
{
"name": "青蜜梅",
"type": "checkbox",
"label": "青蜜梅",
"default": true
},
{
"name": "AKF",
"type": "select",
"label": "-----------------\n每週一刷新食材\n\n可选週几買每週食材",
"options": [
"1",
"2",
"3",
"4",
"5",
"6",
"7"
],
"default": "2"
},
{
"name": "蟹黃",
"type": "checkbox",
"label": "蟹黃",
"default": true
}
]