JS:自动购买商品 v3.4.601 (#3352)

* Add files via upload

* JS:自动购买商品 v3.4.601

### v3.4.601
  - **优化**
    - 适配原神“月之八”版本UI变化
    - 优化进入商店购买页面的方式,现在脚本会自动检测是否成功进入商品界面,若未进入则自动重试。
    - 进入商店时不再盲目按F固定次数,避免在对话过程中多次按F误触其他选项或意外购买非目标商品。

* Add files via upload
This commit is contained in:
this-Fish authored and GitHub committed 2026-07-01 23:01:46 +08:00
1 parent 9d9f1f9fff
commit 2ff1ccbdfb
5 files changed
+50 -10

No files matched your search

+6
View File
@@ -257,6 +257,12 @@ A: 游戏内的刷新时间是**每天凌晨4点**。脚本会考虑这个时间
## 📅 更新日志
<details>
### v3.4.601
- **优化**
- 适配原神“月之八”版本UI变化
- 优化进入商店购买页面的方式,现在脚本会自动检测是否成功进入商品界面,若未进入则自动重试。
- 进入商店时不再盲目按F固定次数,避免在对话过程中多次按F误触其他选项或意外购买非目标商品。
### v3.3.6
- **修复**:周四刷新商品(狗粮商人)刷新时间计算错误
- 之前周一至周三尝试购买周四商品时,刷新时间会被错误记录到下周四
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

+43 -9
View File
@@ -1,4 +1,4 @@
//3.3.6
//3.4.601
// fakeLog 函数,使用方法:将本函数放在主函数前,调用时请务必使用await,否则可能出现v8白框报错
// 在js开头处伪造该js结束运行的日志信息,如 await fakeLog("js脚本", true, true, 0);
@@ -669,6 +669,7 @@ const othrtRo = {
"file": "assets/images/buyBtn.png"
}
}
const store_Page_Tags_Ro = RecognitionObject.TemplateMatch(file.ReadImageMatSync("assets/images/store_Page_Tags.png"), 50, 30, 60, 55)
// 获取游戏内时间(考虑4点刷新)
function getGameTime() {
@@ -871,19 +872,52 @@ async function spikChat(npcName) {
captureRegion.dispose();
}
await sleep(1500);
keyPress("VK_F");
await sleep(1500);
keyPress("VK_F");
await sleep(1500);
// 等待购买页面出现
if (await waitForPurchasePage(6)) {
logConditional(`已进入 ${npcName} 的购买页面`);
} else {
log.warn(`未能进入 ${npcName} 的购买页面,尝试继续...`);
}
return;
} else {
for (let i = 0; i < count; i++) {
keyPress("VK_F");
await sleep(1500);
// 通用NPC:按F与NPC交互,然后循环检测
keyPress("VK_F");
await sleep(1000);
if (await waitForPurchasePage(8)) {
logConditional(`已进入 ${npcName} 的购买页面`);
} else {
log.warn(`未能进入 ${npcName} 的购买页面,脚本可能无法正常购买`);
}
}
}
// ==================== 辅助函数:等待进入购买页面 ====================
async function waitForPurchasePage(maxAttempts = 8) {
// 强制使用 1080P 坐标系(与模板截图一致)
setGameMetrics(1920, 1080, 1);
for (let attempt = 0; attempt < maxAttempts; attempt++) {
// 检测是否已在购买页面
let capture = captureGameRegion();
try {
let result = capture.Find(store_Page_Tags_Ro);
if (result.isExist()) {
return true;//已進入
}
} finally {
capture.dispose();
}
// 未进入,按 F 推进对话
keyPress("VK_F");
await sleep(800); // 等待界面响应
}
return false;
}
// ==================== 商品识别对象映射表 ====================
let foodROMap = {}; // 键为商品名(中文),值为 RecognitionObject
+1 -1
View File
@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "自动购买商品",
"version": "3.3.601",
"version": "3.4.601",
"bgi_version": "0.60.1",
"description": "自动购买商品\n每天刷新商品:自动购买商品\n3天刷新商品:未到刷新日不购买该商品\n每周刷新商品:可指定每周购买商品",
"authors": [