Compare commits
40
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00f680f4ec | ||
|
|
36c2e25792 | ||
|
|
6b9ac1b5d0 | ||
|
|
6071b4096f | ||
|
|
dc1c25ee00 | ||
|
|
8ca6830c4b | ||
|
|
e5aa33c577 | ||
|
|
a76767499d | ||
|
|
3470c5e30b | ||
|
|
10ee93e8bb | ||
|
|
255bf653e8 | ||
|
|
4a17383f86 | ||
|
|
edc5580267 | ||
|
|
dfef6ddf30 | ||
|
|
0cc48ce6d8 | ||
|
|
6be85a03af | ||
|
|
e78d54ba2a | ||
|
|
1fd45c42b1 | ||
|
|
e06b105365 | ||
|
|
83637172fd | ||
|
|
b0a1bb019c | ||
|
|
304147f965 | ||
|
|
99a17010d2 | ||
|
|
fb527a13c4 | ||
|
|
2ea663b0ff | ||
|
|
bbf1be3de9 | ||
|
|
3586e37c69 | ||
|
|
4896d0344a | ||
|
|
c1d0a53110 | ||
|
|
0eedfb6969 | ||
|
|
d0c02717e8 | ||
|
|
2a53fb9742 | ||
|
|
bd8451a190 | ||
|
|
ee500b2971 | ||
|
|
b0a1715ba3 | ||
|
|
33760242ea | ||
|
|
7d91fba327 | ||
|
|
8956c306c2 | ||
|
|
a7dac95468 | ||
|
|
dea40ce177 |
No files matched your search
@@ -4,12 +4,23 @@ title: "[bug] "
|
||||
labels:
|
||||
- BUG
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Checklist before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复问题 / I have searched existing issues and confirmed this is not a duplicate
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem"
|
||||
required: true
|
||||
- label: 我愿意为了解决这个问题尽自己所能 / I am willing to do my part to help resolve this issue
|
||||
- type: textarea
|
||||
id: environment
|
||||
attributes:
|
||||
label: 系统环境
|
||||
description: System Environment,例如系统版本、运行环境
|
||||
placeholder: Win11 / BetterGI 0.58.0 / .NET 8
|
||||
description: System environment,例如操作系统版本、运行时版本、显卡驱动版本
|
||||
placeholder: Windows 11 24H2 (26100.3775) / .NET Desktop Runtime 8.0.15 / NVIDIA 572.83
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
@@ -17,15 +28,23 @@ body:
|
||||
attributes:
|
||||
label: BetterGI 版本号
|
||||
description: BetterGI Version
|
||||
placeholder: 0.58.0
|
||||
placeholder: e.g. 0.58.0
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: Description of the issue
|
||||
placeholder: 请详细描述你遇到的问题,可直接粘贴日志并附带截图
|
||||
description: Describe the actual behavior and impact
|
||||
placeholder: 请描述实际出现的问题,以及这个问题对使用造成了什么影响 / Describe the actual behavior and impact
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: 期望结果
|
||||
description: Expected behavior
|
||||
placeholder: 请描述你期望出现的正确行为或结果 / Describe the expected behavior or result
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
@@ -34,8 +53,22 @@ body:
|
||||
label: 复现步骤
|
||||
description: Reproduction steps
|
||||
placeholder: |-
|
||||
1. 打开……
|
||||
2. 点击……
|
||||
3. 出现……
|
||||
1. 打开…… / Open ...
|
||||
2. 点击…… / Click ...
|
||||
3. 出现…… / Observe ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: 日志与附件
|
||||
description: Logs and attachments,可直接拖拽上传日志文件、压缩包、截图或视频
|
||||
placeholder: |-
|
||||
可在这里补充日志和附件说明 / Add logs and attachment notes here:
|
||||
- 可直接粘贴关键日志片段 / Paste key log snippets directly
|
||||
- 可拖拽上传日志文件或压缩包 / Drag and drop log files or archives
|
||||
- 可拖拽上传截图、录屏或演示视频 / Drag and drop screenshots or videos
|
||||
- 若附件较多,请说明对应的时间点、任务名称或异常现象 / If there are many files, explain the relevant timestamps or symptoms
|
||||
- 提交前请注意移除账号、路径等隐私信息 / Remove private information before submitting
|
||||
validations:
|
||||
required: false
|
||||
@@ -1,9 +1,9 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 官方文档 / Document
|
||||
url: https://bgi.huiyadan.com/doc.html
|
||||
url: https://www.bettergi.com/doc.html
|
||||
about: 请在提出问题前阅读文档 / Read the document before submit the issue
|
||||
|
||||
- name: 常见问题 / FAQ
|
||||
url: https://bgi.huiyadan.com/faq.html
|
||||
url: https://www.bettergi.com/faq.html
|
||||
about: 常见的用户提出的问题 / Common questions asked by users
|
||||
@@ -4,12 +4,26 @@ title: "[feature] "
|
||||
labels:
|
||||
- 功能建议
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复建议 / I have searched existing issues and confirmed this is not a duplicate request
|
||||
required: true
|
||||
- label: 我已确认当前版本中尚未提供该功能,或至少没有等价实现 / I have confirmed this feature, or an equivalent one, is not already available in the current version
|
||||
required: true
|
||||
- label: 我认为这个需求能为更多用户带来明确收益,而不仅仅是个人偏好 / I believe this request provides clear value to a broader group of users, not just my personal preference
|
||||
required: true
|
||||
- label: 我理解这个需求可能因实现成本、维护成本或项目方向而暂不采纳 / I understand this request may not be accepted due to implementation cost, maintenance cost, or project direction
|
||||
required: true
|
||||
- type: textarea
|
||||
id: request
|
||||
attributes:
|
||||
label: 功能请求
|
||||
description: Feature Request
|
||||
placeholder: 请简要说明你希望新增什么能力
|
||||
placeholder: 请简要说明你希望新增什么能力 / Briefly describe the capability you want to add
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
@@ -17,7 +31,15 @@ body:
|
||||
attributes:
|
||||
label: 使用场景
|
||||
description: Use Case
|
||||
placeholder: 这个功能要解决什么问题?在哪些场景下使用?
|
||||
placeholder: 这个功能要解决什么问题?在哪些场景下使用? / What problem does this feature solve, and when would it be used?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: impact
|
||||
attributes:
|
||||
label: 潜在影响
|
||||
description: Potential Impact
|
||||
placeholder: 请说明这个功能是否可能带来新的问题、维护成本、使用门槛或兼容性影响;如果没有,请填写“无” / Describe any potential downsides such as new issues, maintenance cost, usability barriers, or compatibility impact. Write "None" if there are no obvious downsides.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
@@ -25,6 +47,6 @@ body:
|
||||
attributes:
|
||||
label: 补充信息
|
||||
description: Optional
|
||||
placeholder: 可选,补充示意图、参考方案或限制条件
|
||||
placeholder: "可选,补充示意图、交互草图、参考链接或相关背景信息 / Optional: add mockups, interaction sketches, reference links, or other background information"
|
||||
validations:
|
||||
required: false
|
||||
@@ -2,11 +2,21 @@ name: Feel free to express / 自由描述
|
||||
description: 记录你想反馈的内容 / Share general feedback
|
||||
title: "[feedback] "
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复反馈 / I have searched existing issues and confirmed this is not duplicate feedback
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题或覆盖我的反馈 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem or cover my feedback"
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 描述
|
||||
description: Description
|
||||
placeholder: 请描述你想反馈的内容
|
||||
placeholder: 请描述你想反馈的内容 / Describe what you want to share
|
||||
validations:
|
||||
required: true
|
||||
@@ -4,12 +4,22 @@ title: "[question] "
|
||||
labels:
|
||||
- 问题咨询
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复问题 / I have searched existing issues and confirmed this is not a duplicate question
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem"
|
||||
required: true
|
||||
- type: textarea
|
||||
id: question
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: Problem Description
|
||||
placeholder: 请清楚描述你的问题
|
||||
placeholder: 请清楚描述你的问题 / Clearly describe your question
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
@@ -17,6 +27,6 @@ body:
|
||||
attributes:
|
||||
label: 已尝试内容
|
||||
description: Screenshots / logs / what you already tried
|
||||
placeholder: 可附上截图、日志,以及你已经尝试过的排查过程
|
||||
placeholder: 可附上截图、日志,以及你已经尝试过的排查过程 / Add screenshots, logs, and what you have already tried
|
||||
validations:
|
||||
required: true
|
||||
@@ -4,12 +4,22 @@ title: "[suggestion] "
|
||||
labels:
|
||||
- 功能建议
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: 提交确认 / Checklist
|
||||
description: Please confirm the following before submitting
|
||||
options:
|
||||
- label: 我已经搜索过现有 issue,确认这不是重复建议 / I have searched existing issues and confirmed this is not a duplicate suggestion
|
||||
required: true
|
||||
- label: "我已阅读过[文档](https://www.bettergi.com/doc.html),确认文档的内容无法解决我的问题或覆盖我的建议 / I have read the [documentation](https://www.bettergi.com/doc.html) and confirmed it does not solve my problem or cover my suggestion"
|
||||
required: true
|
||||
- type: textarea
|
||||
id: suggestion
|
||||
attributes:
|
||||
label: 建议内容
|
||||
description: Suggestion
|
||||
placeholder: 请描述你的建议内容
|
||||
placeholder: 请描述你的建议内容 / Describe your suggestion
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
@@ -17,6 +27,6 @@ body:
|
||||
attributes:
|
||||
label: 预期收益
|
||||
description: Expected Benefit
|
||||
placeholder: 这个建议会给用户或项目带来什么帮助?
|
||||
placeholder: 这个建议会给用户或项目带来什么帮助? / What benefits would this suggestion bring to users or the project?
|
||||
validations:
|
||||
required: true
|
||||
@@ -6,7 +6,7 @@ providers:
|
||||
openAiCompatible:
|
||||
enabled: true
|
||||
baseUrl: https://api.openai.com/v1
|
||||
model: gpt-5.2-codex
|
||||
model: gpt-5.4
|
||||
apiStyle: responses
|
||||
timeoutMs: 30000
|
||||
|
||||
@@ -135,7 +135,7 @@ issues:
|
||||
highConfidence: 0.93
|
||||
reviewMin: 0.82
|
||||
similarityComment:
|
||||
enabled: true
|
||||
enabled: false
|
||||
commentAnchor: issue-bot:similar-issues
|
||||
minScore: 0.3
|
||||
maxCandidates: 3
|
||||
|
||||
+9
-1
@@ -30,9 +30,17 @@ github_actions_cache/
|
||||
|
||||
# Rider
|
||||
.idea
|
||||
.trae
|
||||
|
||||
.claude
|
||||
CLAUDE.md
|
||||
AGENTS.md
|
||||
|
||||
__pycache__/
|
||||
|
||||
|
||||
# Trae
|
||||
.trae/*
|
||||
!.trae/rules/
|
||||
!.trae/rules/**
|
||||
!.trae/skills/
|
||||
!.trae/skills/**
|
||||
@@ -0,0 +1,80 @@
|
||||
本项目使用了 WPF-UI、 CommunityToolkit.Mvvm、Microsoft.Xaml.Behaviors.Wpf 来实现 MVVM 架构。在编写代码的时候请注意:
|
||||
|
||||
### 主要依赖框架
|
||||
#### UI 框架
|
||||
- **WPF-UI (4.0.2)** - 现代化 WPF UI 框架
|
||||
- **gong-wpf-dragdrop(3.2.1)** - 拖拽框架
|
||||
|
||||
#### MVVM 框架
|
||||
- **CommunityToolkit.Mvvm (8.2.2)** - 微软官方 MVVM 工具包
|
||||
- 所有 ViewModel 必须继承自 `ObservableObject`
|
||||
- 使用 `[ObservableProperty]` 特性自动生成属性
|
||||
- 使用 `[RelayCommand]` 特性自动生成命令
|
||||
- **Microsoft.Xaml.Behaviors.Wpf(1.1.122)** - WPF 行为扩展库
|
||||
- 请尽量使用 Behaviors 库来实现交互,避免不符合 MVVM 规范的交互事件触发方式。
|
||||
|
||||
### 其他框架使用要求
|
||||
请优先使用 Newtonsoft.Json 作为json序列化工具,但是如果这个模型已经被System.Text.Json序列化过了,那么就直接使用System.Text.Json反序列化。
|
||||
|
||||
## MVVM 架构规则
|
||||
|
||||
### 基础架构
|
||||
|
||||
### ViewModel 编写规范
|
||||
|
||||
1. **继承规则**
|
||||
```csharp
|
||||
public partial class ExampleViewModel : ViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string _title = "";
|
||||
|
||||
[RelayCommand]
|
||||
private void DoSomething()
|
||||
{
|
||||
// 实现逻辑
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **属性命名**
|
||||
- 私有字段使用下划线前缀: `_fieldName`
|
||||
- 公共属性使用 PascalCase: `PropertyName`
|
||||
- 使用 `[ObservableProperty]` 自动生成属性
|
||||
|
||||
3. **命令实现**
|
||||
- 使用 `[RelayCommand]` 特性
|
||||
- 异步命令使用 `[RelayCommand]` + `async Task`
|
||||
|
||||
### View 编写规范
|
||||
|
||||
1. **代码后置**
|
||||
```csharp
|
||||
public partial class ExamplePage : UserControl
|
||||
{
|
||||
public ExampleViewModel ViewModel { get; }
|
||||
|
||||
public ExamplePage(ExampleViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel;
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **XAML 绑定**
|
||||
- 使用 `{Binding}` 语法绑定 ViewModel 属性
|
||||
- 命令绑定: `Command="{Binding ExampleCommand}"`
|
||||
- 避免在 XAML 中编写复杂逻辑
|
||||
|
||||
### 依赖注入规范
|
||||
|
||||
1. **服务注册**
|
||||
```csharp
|
||||
// 在 App.xaml.cs 中注册
|
||||
services.AddView<ExamplePage, ExampleViewModel>();
|
||||
services.AddSingleton<IExampleService, ExampleService>();
|
||||
```
|
||||
|
||||
最后,程序能够编译就认为成功,无需实际运行程序。
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
name: "github-issue-triage"
|
||||
description: "Reads GitHub issues, extracts reporter details and <=10MB attachments/images, then decides discuss/research vs direct fix vs implementation plan. Invoke when user shares an issue URL."
|
||||
---
|
||||
|
||||
# GitHub Issue Triage
|
||||
|
||||
用于处理 GitHub issue 链接,并在结合当前仓库代码后给出执行路径。
|
||||
|
||||
## 触发时机
|
||||
|
||||
- 用户提供 GitHub issue URL,并希望你分析内容后继续行动
|
||||
- 需要先读取 issue 创建者信息、附件或图片,再决定如何推进
|
||||
- 需要判断是先讨论研究、直接修复,还是先制定方案
|
||||
|
||||
## 输入
|
||||
|
||||
- 必填:GitHub issue URL,例如 `https://github.com/<owner>/<repo>/issues/<id>`
|
||||
- 可选:用户额外上下文(复现步骤、期望行为、优先级)
|
||||
|
||||
## 执行流程
|
||||
|
||||
1. 读取 issue 内容
|
||||
- 获取标题、正文、标签、状态、创建者、创建时间
|
||||
- 提取创建者在 issue 中提供的关键信息(正文 + 创建者本人评论)
|
||||
- 区分“创建者信息”与“其他参与者讨论”
|
||||
|
||||
2. 收集附件与图片(限制 10MB)
|
||||
- 从 issue 正文和创建者评论中提取附件/图片链接
|
||||
- 对每个链接获取文件大小与类型,只有 `<= 10MB` 才下载
|
||||
- 优先下载图片(png/jpg/jpeg/webp/gif)与问题复现相关附件
|
||||
- 记录已下载与跳过原因(超限、类型不符、不可访问)
|
||||
|
||||
3. 结合代码库研判
|
||||
- 先做高层语义检索定位相关模块,再做符号/关键字精查
|
||||
- 找到与 issue 直接相关的代码路径、入口点、可能影响范围
|
||||
- 判断是否已有类似问题处理逻辑、开关、兜底或已知限制
|
||||
|
||||
4. 路径决策
|
||||
- 讨论研究问题:信息不足、无法稳定复现、需求存在歧义、外部依赖阻塞
|
||||
- 直接修复问题:根因清晰、改动范围可控、验收标准明确
|
||||
- 计划方案:涉及跨模块改造、兼容性权衡、需要分阶段实施
|
||||
|
||||
5. 执行动作
|
||||
- 若“直接修复问题”:直接修改代码并完成必要验证
|
||||
- 若“计划方案”:输出分步计划、影响面、风险与验证策略
|
||||
- 若“讨论研究问题”:给出需要补充的信息与建议实验步骤
|
||||
|
||||
## 输出格式
|
||||
|
||||
- Issue 摘要:标题、创建者、关键诉求、复现线索
|
||||
- 创建者信息提炼:仅保留创建者提供的有效信息
|
||||
- 附件处理结果:下载清单(<=10MB)与跳过清单(含原因)
|
||||
- 代码关联分析:相关模块、关键函数、潜在根因
|
||||
- 决策结论:讨论研究 / 直接修复 / 计划方案
|
||||
- 下一步:立即执行项
|
||||
|
||||
## 质量要求
|
||||
|
||||
- 必须优先依据创建者提供的信息,不被无关评论干扰
|
||||
- 必须在代码层面给出证据,不做纯主观结论
|
||||
- 决策应可执行,并且与当前仓库结构一致
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
name: "release-note-generator"
|
||||
description: "Generates release notes from git commits/diffs and outputs one Chinese MD file. Invoke when user asks for release notes bounded by previous non-alpha version."
|
||||
---
|
||||
|
||||
# Release Note Generator
|
||||
|
||||
用于基于当前仓库的 git 历史自动生成发布说明,确保不遗漏提交,并为每条变更记录追加提交人的 GitHub ID(`@id`)。默认输出一个 Markdown 文件到 `.trae/documents` 目录:变更内容。
|
||||
|
||||
## 触发时机
|
||||
|
||||
- 用户要求生成 Release Note / 更新日志
|
||||
- 用户要求基于最近提交和实际代码变更做汇总
|
||||
- 用户要求以“上一个非 alpha 版本”为边界统计变更
|
||||
|
||||
## 输入约定
|
||||
|
||||
- 默认分支当前 `HEAD`
|
||||
- 版本边界规则:从最新提交向后遍历,遇到“提交信息包含版本号且不含 alpha”的最近一个提交作为边界
|
||||
- 若用户指定分支、Tag 或版本正则,优先使用用户指定
|
||||
- 未指定时,默认输出文档路径为:`.trae/documents/release_notes-<version>.md`
|
||||
|
||||
## 实战经验(本项目)
|
||||
|
||||
- 不直接依赖终端长输出:大量 `git log` 在终端中容易被截断,导致误判“提交缺失”
|
||||
- 不用 `|` 等普通分隔符解析:提交标题可能包含分隔符,必须使用 NUL 分隔(`\x00`)保证可解析
|
||||
- 统一 UTF-8:PowerShell 下中文提交信息可能乱码,调用 git 时需显式设置输出编码
|
||||
- 避免在 `RunCommand` 的内联脚本中直接硬编码中文常量(标题、分类名、文件名):在 Windows/PowerShell 链路中可能被替换为 `?`
|
||||
- 发布文件名使用 ASCII:不要在文件名中使用中文(如 `ReleaseNotes-变更内容-<version>.md`),否则编码异常时会变成非法字符 `?` 导致写文件失败
|
||||
- 中文文案仅放在 Markdown 内容里,并在写入后做一次乱码校验:若出现 `???`、`### ??` 等占位符,必须重新生成
|
||||
- 明确分支范围:优先使用 `HEAD` 可达历史,必要时用 `--first-parent` 辅助核对发布主线
|
||||
- 先计数再明细:先取 `rev-list --count`,再逐条采集,最后做数量一致性校验
|
||||
- 版本边界要可回退:目标版本不存在时,自动回退到最近可识别的“上一非 alpha 版本”并在结果中声明
|
||||
|
||||
## 日志采集方式(强制)
|
||||
|
||||
- 必须使用 Python 脚本拉取 commit 与 diff,不直接用终端拼接命令产出最终结果
|
||||
- Python 内通过 `subprocess.run([...], check=True, capture_output=True, text=True, encoding="utf-8", errors="replace")` 调 git
|
||||
- git 命令需附加编码参数:`-c i18n.logOutputEncoding=utf8 -c core.quotepath=false`
|
||||
- 提交元数据推荐格式:`--pretty=format:%H%x00%h%x00%an%x00%ae%x00%ad%x00%s%x00`,按 `\x00` 解析
|
||||
- diff 证据至少包含:
|
||||
- 区间总览:`git diff --shortstat <base>..<head>`
|
||||
- 文件变更:`git diff --name-status <base>..<head>`
|
||||
- 行级统计:`git diff --numstat <base>..<head>`
|
||||
- 必要时单提交详情:`git show --name-status --numstat --format= <sha>`
|
||||
- Python 脚本需输出结构化数据(JSON/对象)后再生成 release note 文本
|
||||
- 若通过终端执行 Python,优先将中文文案写成 `\\uXXXX` 形式或由程序运行期拼接,避免命令传输阶段损坏字符
|
||||
|
||||
## 执行流程
|
||||
|
||||
1. 获取提交序列(防遗漏)
|
||||
- 从 `HEAD` 向后扫描提交,定位边界提交 `boundary_commit`
|
||||
- 使用可识别 SemVer 的正则提取版本号(例如 `v1.2.3`、`1.2.3`)
|
||||
- 判断“非 alpha”时使用大小写不敏感匹配:提交信息不包含 `alpha`
|
||||
- 生成统计区间:`(boundary_commit, HEAD]`,边界提交本身不计入变更列表
|
||||
- 使用 Python 执行 git 并解析 NUL 分隔结果,禁止依赖终端显示内容做解析
|
||||
|
||||
2. 完整性校验(必须)
|
||||
- 先取区间提交总数 `N`
|
||||
- 再逐条收集区间内每个 commit 的详情
|
||||
- 输出前校验“已收集条数 == N”,不一致则重新拉取,直到一致
|
||||
- 若存在 merge,额外给出 `--first-parent` 视角的校验结果,避免发布主线理解偏差
|
||||
|
||||
3. 采集每条提交的证据
|
||||
- 提交元数据:hash、标题、作者、时间
|
||||
- 实际改动:由 Python 采集 `--name-status`、`--numstat`、`--shortstat` 与必要 diff 片段
|
||||
- 将提交按功能模块归类(如 UI、任务、配置、脚本、基础设施等)
|
||||
|
||||
4. 提炼发布内容
|
||||
- 先按用户指定分类规则归类;若未指定,使用更接近 GitHub Releases 页面的默认分类顺序:
|
||||
1) 新功能
|
||||
2) 地图遮罩
|
||||
3) 独立任务
|
||||
4) JS相关
|
||||
5) 其他
|
||||
- 分类名尽量贴近业务语义:例如“地图追踪”“自动剧情”“七圣召唤”等可作为二级小节并入对应一级分类
|
||||
- 无法稳定归类的小变更统一放入“其他”
|
||||
- 每条摘要都要可追溯到至少一个 commit
|
||||
- 识别“变更最大点”并在首屏摘要中突出展示
|
||||
- 主体正文只展示可读的变更描述,不在分类正文中堆叠 hash
|
||||
- 完整提交清单放在文末,避免正文可读性下降
|
||||
- 输出文案需去掉 Conventional Commits 前缀:至少移除 `feat:`、`fix:`(区分大小写不敏感),再写入分类正文与完整提交清单
|
||||
|
||||
5. 生成提交人 GitHub ID(逐条记录追加 `@id`)
|
||||
- 必须以“当前方式”解析:对区间内每个 commit 逐条调用 GitHub 提交接口,禁止仅依赖本地 `author name`:
|
||||
- 接口:`https://api.github.com/repos/<owner>/<repo>/commits/<sha>`
|
||||
- 请求头至少包含:`Accept: application/vnd.github+json`、`User-Agent: <custom>`
|
||||
- 解析顺序固定:优先 `author.login`,为空时取 `committer.login`
|
||||
- 必须保证覆盖全量区间提交:
|
||||
- 对每个 SHA 单独请求并记录结果
|
||||
- 输出前校验“已解析 login 数 == 区间提交数”,不一致则进入回退链
|
||||
- 回退链(仅当 API 某条未命中时):
|
||||
- 先用“同区间内已解析结果”做映射回填(同 author email / 同 author name)
|
||||
- 再解析 GitHub noreply 邮箱:
|
||||
- `[email protected]` -> `@login`
|
||||
- `[email protected]` -> `@login`
|
||||
- 再回退 `.atom`:`https://github.com/<owner>/<repo>/commits/<branch>.atom` 按 SHA 匹配 `<entry>` 获取 `<author><name>`
|
||||
- 最后才允许作者名标准化兜底,并明确标记为推断
|
||||
- 为每条变更记录绑定对应作者的 `@id`
|
||||
- 若一条汇总涉及多个 commit,按去重后多作者格式追加:`@id1 @id2`
|
||||
|
||||
## 输出格式(强制,需贴近 GitHub Releases 风格)
|
||||
|
||||
必须产出 1 个文件:
|
||||
|
||||
1. 变更内容文件(全中文)
|
||||
- 文件路径:`.trae/documents/ReleaseNotes-<version>.md`(文件名必须 ASCII)
|
||||
- 内容结构(推荐模板):
|
||||
- 一级标题:`## <version> <版本主题>`(示例:`## 0.58 月之五适配`)
|
||||
- 开场一句话:版本背景或问候语(可选,1~2 句)
|
||||
- 分类正文:按以下顺序输出存在内容的分类:
|
||||
- `新功能`
|
||||
- `地图遮罩`
|
||||
- `独立任务`
|
||||
- `JS相关`
|
||||
- `其他`(必须保留,即使只有 1 条)
|
||||
- 分类内每条为单行 bullet,格式:
|
||||
- `<变更描述> (#PR号可选) @githubId`
|
||||
- 若某条由多人提交,使用:`@id1 @id2`
|
||||
- 文末追加“完整提交清单”(倒序,不能缺项,每条带 `@id`)
|
||||
- 在标题下方补充统计信息:`边界提交 / 区间 / 提交数 / shortstat`
|
||||
|
||||
补充要求:
|
||||
- 变更内容文件必须全中文
|
||||
- 仅内容全中文;文件名必须为 ASCII,避免 Windows 下出现 `?` 非法路径
|
||||
- 风格贴近 GitHub Releases:简洁分段、先讲用户可感知变化,再给完整清单
|
||||
- 正文优先使用自然语言,不直接复制 commit 原文
|
||||
- 分类不允许缺失“其他”
|
||||
- 内容中不保留 `feat:`、`fix:` 前缀
|
||||
- 生成后必须执行乱码检查:若命中 `\\?{2,}` 或 `### \\?+`,视为失败并重生成
|
||||
|
||||
## 质量门槛
|
||||
|
||||
- 不允许遗漏区间内任意 commit
|
||||
- 不允许仅基于 commit 标题,必须结合实际代码改动
|
||||
- 每条变更记录必须带作者 `@id`,不允许只在末尾集中列出
|
||||
- 必须通过 Python 脚本获取日志与 diff,禁止直接依赖终端长输出结果
|
||||
- 解析 `@id` 时必须逐条调用 GitHub Commit API(`/repos/<owner>/<repo>/commits/<sha>`),不得以本地昵称直接替代
|
||||
- 未找到边界版本时,必须明确说明并给出当前采用的兜底范围
|
||||
- 分类默认遵循“新功能 / 地图遮罩 / 独立任务 / JS相关 / 其他”,其中“其他”必须出现
|
||||
- Markdown 文件必须实际落盘到仓库中的 `.trae/documents` 目录
|
||||
- 不允许输出出现乱码占位符(如 `???`、`??` 分类名);发现即判定为不合格
|
||||
@@ -282,6 +282,12 @@ public partial class App : Application
|
||||
{
|
||||
try
|
||||
{
|
||||
// 忽略V8引擎释放后pending的Task回调抛出的异常
|
||||
if (IsV8EngineReleasedException(e.Exception))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HandleException(e.Exception);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -294,6 +300,21 @@ public partial class App : Application
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsV8EngineReleasedException(Exception? ex)
|
||||
{
|
||||
while (ex != null)
|
||||
{
|
||||
if (ex.Message?.Contains("V8 object has been released") == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
ex = ex.InnerException;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
|
||||
private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyName>BetterGI</AssemblyName>
|
||||
<Version>0.60.0</Version>
|
||||
<Version>0.60.2-alpha.3</Version>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<PackageReference Include="BetterGI.VCRuntime" Version="14.44.35208" />
|
||||
<PackageReference Include="BetterGI.Assets.Map" Version="1.0.18" />
|
||||
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.20" />
|
||||
<PackageReference Include="BetterGI.Assets.Model" Version="1.0.22" />
|
||||
<PackageReference Include="BetterGI.Assets.Other" Version="1.0.15" />
|
||||
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
|
||||
@@ -47,4 +47,10 @@ public partial class GenshinStartConfig : ObservableObject
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _startGameWithCmd = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启动前自动关闭原神 HDR(删除原神 HDR 对应注册表键)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _autoDisableGenshinHdrEnabled = true;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public partial class PathingPartyConfig : ObservableObject
|
||||
{
|
||||
// 配置是否启用,不启用会使用地图追踪内的条件配置
|
||||
[ObservableProperty]
|
||||
private bool _enabled = false;
|
||||
private bool _enabled = true;
|
||||
|
||||
// 是否启用自动拾取
|
||||
[ObservableProperty]
|
||||
@@ -124,7 +124,7 @@ public partial class PathingPartyConfig : ObservableObject
|
||||
|
||||
//启用自动战斗配置
|
||||
[ObservableProperty]
|
||||
private bool _autoFightEnabled = false;
|
||||
private bool _autoFightEnabled = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private AutoFightConfig _autoFightConfig = new();
|
||||
|
||||
@@ -407,11 +407,11 @@ public class BgiOnnxFactory
|
||||
break;
|
||||
case ProviderType.Cpu:
|
||||
sessionOptions.AppendExecutionProvider_CPU();
|
||||
if (model.Name.Contains("PpOcr") || model.Name.Contains("Yap"))
|
||||
{
|
||||
sessionOptions.IntraOpNumThreads = 2; // 限制算子内部并行线程数
|
||||
sessionOptions.InterOpNumThreads = 1; // 限制算子间并行线程数(顺序执行)
|
||||
}
|
||||
// if (model.Name.Contains("PpOcr") || model.Name.Contains("Yap"))
|
||||
// {
|
||||
// sessionOptions.IntraOpNumThreads = 2; // 限制算子内部并行线程数
|
||||
// sessionOptions.InterOpNumThreads = 1; // 限制算子间并行线程数(顺序执行)
|
||||
// }
|
||||
break;
|
||||
case ProviderType.Dnnl:
|
||||
sessionOptions.AppendExecutionProvider_Dnnl();
|
||||
|
||||
@@ -44,6 +44,11 @@ public class BgiOnnxModel
|
||||
/// </summary>
|
||||
public static readonly BgiOnnxModel BgiWorld = Register("BgiTree", @"Assets\Model\World\bgi_world.onnx");
|
||||
|
||||
/// <summary>
|
||||
/// 矿物识别模型
|
||||
/// </summary>
|
||||
public static readonly BgiOnnxModel BgiMine = Register("BgiMine", @"Assets\Model\Mine\bgi_mine.onnx");
|
||||
|
||||
/// <summary>
|
||||
/// 角色识别
|
||||
/// </summary>
|
||||
|
||||
@@ -1,42 +1,99 @@
|
||||
using BetterGenshinImpact.Model;
|
||||
using System;
|
||||
using BetterGenshinImpact.Model;
|
||||
using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script;
|
||||
|
||||
public class CancellationContext : Singleton<CancellationContext>
|
||||
{
|
||||
public CancellationTokenSource Cts { get; set; } = new();
|
||||
private readonly object _sync = new();
|
||||
public CancellationTokenSource Cts { get; private set; } = new();
|
||||
public bool IsManualStop { get; private set; }
|
||||
|
||||
public bool IsCancellationRequested
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
return !disposed && Cts.IsCancellationRequested;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
|
||||
public void Set()
|
||||
{
|
||||
Cts = new CancellationTokenSource();
|
||||
IsManualStop = false;
|
||||
disposed = false;
|
||||
lock (_sync)
|
||||
{
|
||||
Cts = new CancellationTokenSource();
|
||||
IsManualStop = false;
|
||||
disposed = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void ManualCancel()
|
||||
{
|
||||
if (!disposed)
|
||||
CancellationTokenSource cts;
|
||||
lock (_sync)
|
||||
{
|
||||
if (disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsManualStop = true;
|
||||
Cts.Cancel();
|
||||
cts = Cts;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// 并发 Clear 可能已释放 CTS,这里视为已取消/已清理。
|
||||
}
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
if (!disposed)
|
||||
CancellationTokenSource cts;
|
||||
lock (_sync)
|
||||
{
|
||||
Cts.Cancel();
|
||||
if (disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cts = Cts;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// 并发 Clear 可能已释放 CTS,这里视为已取消/已清理。
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Cts.Dispose();
|
||||
disposed = true;
|
||||
CancellationTokenSource cts;
|
||||
lock (_sync)
|
||||
{
|
||||
if (disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cts = Cts;
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
cts.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,15 @@ public class Genshin
|
||||
/// </summary>
|
||||
public double ScreenDpiScale => TaskContext.Instance().DpiScale;
|
||||
|
||||
/// <summary>
|
||||
/// 通过 OCR 识别当前角色的 UID
|
||||
/// </summary>
|
||||
/// <returns>UID 数字,如果识别失败则返回 0</returns>
|
||||
public Task<int> Uid()
|
||||
{
|
||||
return Task.FromResult(Bv.Uid());
|
||||
}
|
||||
|
||||
public Lazy<NavigationInstance> LazyNavigationInstance { get; } = new(() =>
|
||||
{
|
||||
var matchingMethod = TaskContext.Instance().Config.PathingConditionConfig.MapMatchingMethod;
|
||||
@@ -418,4 +427,17 @@ public class Genshin
|
||||
throw new ArgumentException($"无效的分钟值: {minute},必须是 0-59 之间的整数字符", nameof(minute));
|
||||
await new SetTimeTask().Start(h, m, CancellationContext.Instance.Cts.Token, skip);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// 莉奈娅挖矿,调试使用,暂时注释
|
||||
// /// </summary>
|
||||
// /// <param name="mineCount">射箭次数,默认1</param>
|
||||
// /// <param name="scanRounds">大循环寻矿次数。不传则默认5;传单个数字时与射箭次数相同</param>
|
||||
// public async Task StartMining(int? mineCount = null, int? scanRounds = null)
|
||||
// {
|
||||
// var actualMine = mineCount ?? 1;
|
||||
// var actualScan = scanRounds ?? (mineCount ?? 5);
|
||||
// if (actualScan < actualMine) actualScan = actualMine;
|
||||
// await new LinneaMiningTask(actualScan, actualMine).Start(CancellationContext.Instance.Cts.Token);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Script.Utils;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.View;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
/// <summary>
|
||||
/// HTML遮罩层 - JS脚本依赖类
|
||||
/// 提供窗口管理与消息通信功能
|
||||
/// </summary>
|
||||
public class HtmlMask : IDisposable
|
||||
{
|
||||
private static readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = false
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 通信消息结构
|
||||
/// </summary>
|
||||
public class Message
|
||||
{
|
||||
public string Url { get; set; } = "";
|
||||
public JsonElement? Data { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? RequestId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 脚本到HTML的待推送队列
|
||||
/// </summary>
|
||||
private static readonly ConcurrentDictionary<string, ConcurrentQueue<Message>> _toHtmlQueues = new();
|
||||
|
||||
/// <summary>
|
||||
/// HTML到脚本的消息队列
|
||||
/// </summary>
|
||||
private static readonly ConcurrentDictionary<string, ConcurrentQueue<Message>> _fromHtmlQueues = new();
|
||||
|
||||
/// <summary>
|
||||
/// JS到HTML请求的等待句柄,用于request-response匹配
|
||||
/// </summary>
|
||||
private static readonly ConcurrentDictionary<string, TaskCompletionSource<string>> _jsPendingRequests = new();
|
||||
|
||||
/// <summary>
|
||||
/// requestId到windowId的映射,用于窗口关闭时取消对应的pending请求
|
||||
/// </summary>
|
||||
private static readonly ConcurrentDictionary<string, string> _requestWindowMap = new();
|
||||
|
||||
private readonly string _workDir;
|
||||
private readonly List<string> _openedWindows = [];
|
||||
private readonly object _openedWindowsLock = new();
|
||||
private bool _disposed;
|
||||
|
||||
public HtmlMask(string workDir)
|
||||
{
|
||||
_workDir = workDir;
|
||||
}
|
||||
|
||||
#region 窗口管理
|
||||
|
||||
/// <summary>
|
||||
/// 显示HTML遮罩窗口
|
||||
/// </summary>
|
||||
public string Show(string url, string? id = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
throw new ArgumentException("URL不能为空");
|
||||
|
||||
string finalUrl;
|
||||
|
||||
if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
finalUrl = url;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 禁止 file:// 绝对路径,仅允许脚本目录下的相对路径
|
||||
string absPath = ScriptUtils.NormalizePath(_workDir, url);
|
||||
finalUrl = new Uri(absPath).AbsoluteUri;
|
||||
}
|
||||
|
||||
string windowId = HtmlMaskWindow.Show(finalUrl, id, _workDir);
|
||||
|
||||
_toHtmlQueues[windowId] = new ConcurrentQueue<Message>();
|
||||
_fromHtmlQueues[windowId] = new ConcurrentQueue<Message>();
|
||||
lock (_openedWindowsLock) { _openedWindows.Add(windowId); }
|
||||
|
||||
return windowId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogError(ex, "打开HTML遮罩失败: {Url}", url);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭指定窗口
|
||||
/// </summary>
|
||||
public bool Close(string id)
|
||||
{
|
||||
lock (_openedWindowsLock) { _openedWindows.Remove(id); }
|
||||
CleanupQueues(id);
|
||||
return HtmlMaskWindow.Close(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭所有由本实例打开的窗口
|
||||
/// </summary>
|
||||
public void CloseAll()
|
||||
{
|
||||
List<string> windows;
|
||||
lock (_openedWindowsLock)
|
||||
{
|
||||
windows = [.. _openedWindows];
|
||||
_openedWindows.Clear();
|
||||
}
|
||||
foreach (var windowId in windows)
|
||||
{
|
||||
CleanupQueues(windowId);
|
||||
HtmlMaskWindow.Close(windowId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有窗口ID
|
||||
/// </summary>
|
||||
public string[] GetWindowIds() => HtmlMaskWindow.GetWindowIds();
|
||||
|
||||
/// <summary>
|
||||
/// 窗口是否存在
|
||||
/// </summary>
|
||||
public bool Exists(string id) => HtmlMaskWindow.Exists(id);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息通信
|
||||
|
||||
/// <summary>
|
||||
/// 发送消息到HTML(单向推送)
|
||||
/// </summary>
|
||||
public void Send(string windowId, string url, string jsonData)
|
||||
{
|
||||
if (!HtmlMaskWindow.Exists(windowId) || !_toHtmlQueues.TryGetValue(windowId, out var queue))
|
||||
throw new InvalidOperationException($"HTML遮罩窗口不存在或已关闭: {windowId}");
|
||||
|
||||
queue.Enqueue(new Message
|
||||
{
|
||||
Url = url,
|
||||
Data = ParseData(jsonData)
|
||||
});
|
||||
|
||||
HtmlMaskWindow.NotifyFlush(windowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送请求到HTML并等待响应
|
||||
/// </summary>
|
||||
/// <param name="windowId">目标窗口ID</param>
|
||||
/// <param name="url">接口路径</param>
|
||||
/// <param name="jsonData">JSON数据</param>
|
||||
/// <param name="timeoutMs">超时毫秒,0表示无限等待</param>
|
||||
public async Task<string?> Request(string windowId, string url, string jsonData, int timeoutMs = 0)
|
||||
{
|
||||
var requestId = Guid.NewGuid().ToString("N");
|
||||
var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_jsPendingRequests[requestId] = tcs;
|
||||
_requestWindowMap[requestId] = windowId;
|
||||
|
||||
try
|
||||
{
|
||||
if (!HtmlMaskWindow.Exists(windowId) || !_toHtmlQueues.TryGetValue(windowId, out var queue))
|
||||
throw new InvalidOperationException($"HTML遮罩窗口不存在或已关闭: {windowId}");
|
||||
|
||||
queue.Enqueue(new Message
|
||||
{
|
||||
Url = url,
|
||||
Data = ParseData(jsonData),
|
||||
RequestId = requestId
|
||||
});
|
||||
|
||||
HtmlMaskWindow.NotifyFlush(windowId);
|
||||
|
||||
if (timeoutMs > 0)
|
||||
{
|
||||
using var cts = new System.Threading.CancellationTokenSource(timeoutMs);
|
||||
await using var registration = cts.Token.Register(() =>
|
||||
{
|
||||
if (_jsPendingRequests.TryRemove(requestId, out var pending))
|
||||
pending.TrySetResult(null!);
|
||||
});
|
||||
return await tcs.Task;
|
||||
}
|
||||
|
||||
return await tcs.Task;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_jsPendingRequests.TryRemove(requestId, out _);
|
||||
_requestWindowMap.TryRemove(requestId, out _);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等待接收来自HTML的一条消息
|
||||
/// </summary>
|
||||
/// <param name="windowId">窗口ID</param>
|
||||
/// <param name="timeoutMs">超时毫秒,0表示无限等待</param>
|
||||
public async Task<string?> Receive(string windowId, int timeoutMs = 0)
|
||||
{
|
||||
if (!_fromHtmlQueues.TryGetValue(windowId, out var queue))
|
||||
return null;
|
||||
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
while (true)
|
||||
{
|
||||
if (queue.TryDequeue(out var message))
|
||||
return JsonSerializer.Serialize(message, _jsonOptions);
|
||||
|
||||
if (_disposed || !_fromHtmlQueues.ContainsKey(windowId) || !HtmlMaskWindow.Exists(windowId))
|
||||
return null;
|
||||
|
||||
if (timeoutMs > 0 && sw.ElapsedMilliseconds > timeoutMs)
|
||||
return null;
|
||||
|
||||
await Task.Delay(50);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮询来自HTML的消息(非阻塞)
|
||||
/// </summary>
|
||||
public string? Poll(string windowId)
|
||||
{
|
||||
if (_fromHtmlQueues.TryGetValue(windowId, out var queue) &&
|
||||
queue.TryDequeue(out var message))
|
||||
{
|
||||
return JsonSerializer.Serialize(message, _jsonOptions);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量获取来自HTML的所有消息
|
||||
/// </summary>
|
||||
public string PollAll(string windowId)
|
||||
{
|
||||
var messages = new List<Message>();
|
||||
if (_fromHtmlQueues.TryGetValue(windowId, out var queue))
|
||||
{
|
||||
while (queue.TryDequeue(out var message))
|
||||
{
|
||||
messages.Add(message);
|
||||
}
|
||||
}
|
||||
return JsonSerializer.Serialize(messages, _jsonOptions);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 内部方法
|
||||
|
||||
/// <summary>
|
||||
/// 将待推送队列中的消息通过回调逐一发出
|
||||
/// </summary>
|
||||
internal static void FlushPendingMessages(string windowId, Action<string> postAction)
|
||||
{
|
||||
if (_toHtmlQueues.TryGetValue(windowId, out var queue))
|
||||
{
|
||||
while (queue.TryDequeue(out var msg))
|
||||
{
|
||||
postAction(JsonSerializer.Serialize(msg, _jsonOptions));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HTML端发来的消息入队,如果是JS请求的响应则直接resolve
|
||||
/// </summary>
|
||||
internal static void SendFromHtml(string windowId, string url, string data, string? requestId = null)
|
||||
{
|
||||
// 匹配JS端pending的request
|
||||
if (requestId != null && _jsPendingRequests.TryRemove(requestId, out var tcs))
|
||||
{
|
||||
var parsed = ParseData(data);
|
||||
tcs.TrySetResult(parsed != null ? parsed.Value.GetRawText() : "null");
|
||||
return;
|
||||
}
|
||||
|
||||
// 普通消息入队
|
||||
if (_fromHtmlQueues.TryGetValue(windowId, out var queue))
|
||||
{
|
||||
queue.Enqueue(new Message
|
||||
{
|
||||
Url = url,
|
||||
Data = ParseData(data),
|
||||
RequestId = requestId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static JsonElement? ParseData(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return null;
|
||||
try
|
||||
{
|
||||
using var doc = JsonDocument.Parse(json);
|
||||
return doc.RootElement.Clone();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 不是合法JSON,作为纯文本包装
|
||||
return JsonSerializer.SerializeToElement(json, _jsonOptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CleanupQueues(string windowId)
|
||||
{
|
||||
_toHtmlQueues.TryRemove(windowId, out _);
|
||||
_fromHtmlQueues.TryRemove(windowId, out _);
|
||||
|
||||
// 取消该窗口关联的待响应请求
|
||||
foreach (var kvp in _requestWindowMap)
|
||||
{
|
||||
if (kvp.Value == windowId && _jsPendingRequests.TryRemove(kvp.Key, out var tcs))
|
||||
{
|
||||
tcs.TrySetCanceled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
CloseAll();
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,9 @@ public class EngineExtend
|
||||
|
||||
engine.AddHostObject("host", new CustomHostFunctions());
|
||||
|
||||
// HTML 遮罩
|
||||
engine.AddHostObject("htmlMask", new HtmlMask(workDir));
|
||||
|
||||
// 导入 JavaScript 模块
|
||||
// https://microsoft.github.io/ClearScript/2023/01/24/module-interop.html
|
||||
// https://github.com/microsoft/ClearScript/blob/master/ClearScriptTest/V8ModuleTest.cs
|
||||
|
||||
@@ -32,7 +32,8 @@ namespace BetterGenshinImpact.Core.Script
|
||||
{
|
||||
string content = await File.ReadAllTextAsync(targetPath);
|
||||
string processedCode = RewriteScriptCode(content, targetPath);
|
||||
return new StringDocument(new DocumentInfo(targetPath) { Category = ModuleCategory.Standard }, processedCode);
|
||||
var documentInfo = new DocumentInfo(new Uri(targetPath)) { Category = ModuleCategory.Standard };
|
||||
return new StringDocument(documentInfo, processedCode);
|
||||
}
|
||||
|
||||
return await Default.LoadDocumentAsync(settings, sourceInfo, specifier, category, contextCallback);
|
||||
|
||||
@@ -10,7 +10,10 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using BetterGenshinImpact.Core.Script.Dependence;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.View;
|
||||
using Microsoft.ClearScript.JavaScript;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Project;
|
||||
|
||||
@@ -31,6 +34,7 @@ public class ScriptProject
|
||||
{
|
||||
throw new DirectoryNotFoundException("脚本文件夹不存在:" + ProjectPath);
|
||||
}
|
||||
|
||||
ManifestFile = Path.GetFullPath(Path.Combine(ProjectPath, "manifest.json"));
|
||||
if (!File.Exists(ManifestFile))
|
||||
{
|
||||
@@ -48,6 +52,7 @@ public class ScriptProject
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var stackPanel = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(0, 0, 20, 0) // 给右侧滚动条留出位置
|
||||
@@ -74,7 +79,7 @@ public class ScriptProject
|
||||
private IScriptEngine BuildScriptEngine(PathingPartyConfig? partyConfig)
|
||||
{
|
||||
V8ScriptEngine engine = new V8ScriptEngine(V8ScriptEngineFlags.UseCaseInsensitiveMemberBinding | V8ScriptEngineFlags.EnableTaskPromiseConversion);
|
||||
|
||||
|
||||
// packages 依赖和资源重载
|
||||
var loader = new PackageDocumentLoader(ProjectPath);
|
||||
engine.DocumentSettings.Loader = loader;
|
||||
@@ -92,14 +97,14 @@ public class ScriptProject
|
||||
return engine;
|
||||
}
|
||||
|
||||
public async Task ExecuteAsync(dynamic? context = null, PathingPartyConfig? partyConfig=null)
|
||||
public async Task ExecuteAsync(dynamic? context = null, PathingPartyConfig? partyConfig = null)
|
||||
{
|
||||
// 默认值
|
||||
GlobalMethod.SetGameMetrics(1920, 1080);
|
||||
// 加载代码
|
||||
var code = await LoadCode();
|
||||
var engine = BuildScriptEngine(partyConfig);
|
||||
|
||||
|
||||
// 使用自定义加载器解析脚本文件
|
||||
var loader = (PackageDocumentLoader)engine.DocumentSettings.Loader;
|
||||
|
||||
@@ -108,10 +113,11 @@ public class ScriptProject
|
||||
// 写入配置的内容
|
||||
engine.AddHostObject("settings", context);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
bool useModule = Manifest.Library.Length != 0 ||
|
||||
code.Contains("import ", StringComparison.Ordinal) ||
|
||||
bool useModule = Manifest.Library.Length != 0 ||
|
||||
code.Contains("import ", StringComparison.Ordinal) ||
|
||||
code.Contains("export ", StringComparison.Ordinal);
|
||||
|
||||
if (useModule)
|
||||
@@ -122,7 +128,8 @@ public class ScriptProject
|
||||
string mainScriptPath = Path.Combine(ProjectPath, Manifest.Main);
|
||||
string runtimeCode = loader.RewriteScriptCode(code, mainScriptPath);
|
||||
|
||||
var evaluation = engine.Evaluate(new DocumentInfo(mainScriptPath) { Category = ModuleCategory.Standard }, runtimeCode);
|
||||
var documentInfo = new DocumentInfo(new Uri(mainScriptPath)) { Category = ModuleCategory.Standard };
|
||||
var evaluation = engine.Evaluate(documentInfo, runtimeCode);
|
||||
if (evaluation is Task task) await task;
|
||||
}
|
||||
else
|
||||
@@ -138,6 +145,16 @@ public class ScriptProject
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 终止代码执行
|
||||
try
|
||||
{
|
||||
engine.Interrupt();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TaskControl.Logger.LogError(e, "中断脚本执行异常:" + e.Message);
|
||||
}
|
||||
|
||||
engine.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -152,4 +169,4 @@ public class ScriptProject
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class FileAccessBridge
|
||||
// if (!string.IsNullOrEmpty(directory))
|
||||
// Directory.CreateDirectory(directory);
|
||||
|
||||
File.WriteAllText(fullPath, content, Encoding.UTF8);
|
||||
File.WriteAllText(fullPath, content, new UTF8Encoding(false));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Policy;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.ViewModel.Message;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.Service;
|
||||
using Serilog.Core;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.WebView;
|
||||
|
||||
@@ -23,4 +21,17 @@ public class MapEditorWebBridge
|
||||
{
|
||||
TaskContext.Instance().Config.DevConfig.RecordMapName = mapName;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RunPathing(string json)
|
||||
{
|
||||
await ScriptService.StartGameTask();
|
||||
SystemControl.ActivateWindow();
|
||||
await new TaskRunner().RunThreadAsync(async () =>
|
||||
{
|
||||
var task = PathingTask.BuildFromJson(json);
|
||||
var pathExecutor = new PathExecutor(CancellationContext.Instance.Cts.Token);
|
||||
pathExecutor.PartyConfig = new PathingPartyConfig { AutoFightEnabled = false };
|
||||
await pathExecutor.Pathing(task);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1271,13 +1271,13 @@ public class AutoDomainTask : ISoloTask
|
||||
Bv.ClickBlackConfirmButton(CaptureToRectArea());
|
||||
}
|
||||
|
||||
public static (bool, int) PressUseResin(ImageRegion ra, string resinName)
|
||||
public static (bool, int) PressUseResin(ImageRegion ra, string resinName, string logPrefix = "自动秘境")
|
||||
{
|
||||
var regionList = ra.FindMulti(RecognitionObject.Ocr(ra.Width * 0.25, ra.Height * 0.2, ra.Width * 0.5, ra.Height * 0.6));
|
||||
return PressUseResin(regionList, resinName);
|
||||
return PressUseResin(regionList, resinName, logPrefix);
|
||||
}
|
||||
|
||||
public static (bool, int) PressUseResin(List<Region> regionList, string resinName)
|
||||
public static (bool, int) PressUseResin(List<Region> regionList, string resinName, string logPrefix = "自动秘境")
|
||||
{
|
||||
if (resinName == "原粹树脂20" || resinName == "原粹树脂40")
|
||||
{
|
||||
@@ -1301,18 +1301,18 @@ public class AutoDomainTask : ISoloTask
|
||||
// 解决水龙王按下左键后没松开,然后后续点击按下就没反应了。使用双击
|
||||
Sleep(60);
|
||||
useKey.Click();
|
||||
var num = GetResinNum(resinKey, resinName);
|
||||
Logger.LogInformation("自动秘境:使用 {ResinName}, 数量:{Num}", resinName, num);
|
||||
var num = GetResinNum(resinKey, resinName, logPrefix);
|
||||
Logger.LogInformation("{LogPrefix}:使用 {ResinName}, 数量:{Num}", logPrefix, resinName, num);
|
||||
return (true, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("自动秘境:未找到 {ResinName} 的使用按键", resinName);
|
||||
Logger.LogWarning("{LogPrefix}:未找到 {ResinName} 的使用按键", logPrefix, resinName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("自动秘境:未找到 {ResinName} 的使用按键", resinName);
|
||||
Logger.LogWarning("{LogPrefix}:未找到 {ResinName} 的使用按键", logPrefix, resinName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1359,7 +1359,7 @@ public class AutoDomainTask : ISoloTask
|
||||
}, TimeSpan.FromMilliseconds(500), 10);
|
||||
}
|
||||
|
||||
private static int GetResinNum(Region region, string resinName)
|
||||
private static int GetResinNum(Region region, string resinName, string logPrefix)
|
||||
{
|
||||
if (resinName == "原粹树脂")
|
||||
{
|
||||
@@ -1373,7 +1373,7 @@ public class AutoDomainTask : ISoloTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("自动秘境:未识别到原粹树脂消耗体力数量,默认按20计算");
|
||||
Logger.LogWarning("{LogPrefix}:未识别到原粹树脂消耗体力数量,默认按20计算", logPrefix);
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
@@ -1415,4 +1415,4 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
await new AutoArtifactSalvageTask(new AutoArtifactSalvageTaskParam(star, javaScript: null, artifactSetFilter: null, maxNumToCheck: null, recognitionFailurePolicy: null)).Start(_ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,12 @@ using BetterGenshinImpact.Service.Notification.Model.Enum;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoEat;
|
||||
|
||||
/// <summary>
|
||||
/// 自动吃药触发器
|
||||
/// 检测红血状态时自动使用Recovery.png,检测到Resurrection.png时按z复活
|
||||
/// 检测红血状态时自动使用Recovery.png,检测到Resurrection.png时按快捷使用小道具键复活
|
||||
/// </summary>
|
||||
public class AutoEatTrigger : ITaskTrigger
|
||||
{
|
||||
@@ -94,8 +93,8 @@ public class AutoEatTrigger : ITaskTrigger
|
||||
// 检查复活CD(2秒)
|
||||
if ((now - _lastResurrectionTime).TotalSeconds >= 2)
|
||||
{
|
||||
// 按z键复活
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_Z);
|
||||
// 走原神动作映射,跟随“快捷使用小道具”键位配置
|
||||
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
|
||||
_lastResurrectionTime = now;
|
||||
_logger.LogInformation("检测到复活图标,自动复活");
|
||||
}
|
||||
@@ -140,4 +139,4 @@ public class AutoEatTrigger : ITaskTrigger
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -1,8 +1,12 @@
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Model;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
@@ -45,6 +49,11 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
|
||||
public RecognitionObject AbnormalIconRa;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值模板识别对象列表,用于检测怪物死亡时掉落的经验值数字图标
|
||||
/// </summary>
|
||||
public IReadOnlyList<RecognitionObject> ExperienceRecognitionObjects { get; private set; } = Array.Empty<RecognitionObject>();
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑添加 "required" 修饰符或声明为可为 null。
|
||||
private AutoFightAssets() : base()
|
||||
{
|
||||
@@ -264,5 +273,56 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
RegionOfInterest = new Rect(0, (int)(CaptureRect.Height * 0.08), (int)(CaptureRect.Width * 0.04), (int)(CaptureRect.Height * 0.07)),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
// 加载经验值模板图片(用于检测精英怪死亡时的经验值数字图标)
|
||||
try
|
||||
{
|
||||
LoadExperienceRecognitionObjects();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 经验值模板加载失败不应阻止 AutoFightAssets 初始化
|
||||
ExperienceRecognitionObjects = Array.Empty<RecognitionObject>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载经验值模板图片,文件缺失时跳过,不影响其他功能
|
||||
/// </summary>
|
||||
private void LoadExperienceRecognitionObjects()
|
||||
{
|
||||
var experienceValues = new[] { 57, 58, 60 };
|
||||
var threshold = CaptureRect.Width > 1920 ? 0.6 : 0.9;
|
||||
var roi = new Rect(
|
||||
(int)(CaptureRect.Width * 0.145),
|
||||
(int)(CaptureRect.Height * 0.5),
|
||||
(int)(CaptureRect.Width * 0.02),
|
||||
(int)(CaptureRect.Height * 0.22));
|
||||
|
||||
var list = new List<RecognitionObject>();
|
||||
foreach (var exp in experienceValues)
|
||||
{
|
||||
var fileName = $"experience_{exp}.png";
|
||||
try
|
||||
{
|
||||
var ro = new RecognitionObject
|
||||
{
|
||||
Name = $"Experience_{exp}",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoFight", fileName, this.systemInfo),
|
||||
RegionOfInterest = roi,
|
||||
UseMask = true,
|
||||
Threshold = threshold,
|
||||
DrawOnWindow = true,
|
||||
}.InitTemplate();
|
||||
list.Add(ro);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 构造阶段 Logger 可能不可用,静默跳过缺失的模板
|
||||
}
|
||||
}
|
||||
|
||||
ExperienceRecognitionObjects = list.AsReadOnly();
|
||||
}
|
||||
}
|
||||
@@ -76,19 +76,19 @@ public partial class AutoFightConfig : ObservableObject
|
||||
/// 检查战斗结束的延时,即角色,默认为1.5秒。也可以指定特定角色之后延时多少时间检查。格式如:2.5;白术,1.5;钟离,1.0;
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _checkEndDelay = "";
|
||||
private string _checkEndDelay = "0.4;钟离,1.4;";
|
||||
|
||||
/// <summary>
|
||||
/// 按下切换队伍后去检查屏幕色块的延迟,默认为0.45秒。若频繁误判可以适当提高这个值。确保这个延迟不会真的把队伍配置界面切出来。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _beforeDetectDelay = "";
|
||||
private string _beforeDetectDelay = "0.4";
|
||||
|
||||
/// <summary>
|
||||
/// 旋转寻找敌人位置的旋转因子,默认为5,越大越快。
|
||||
/// 旋转寻找敌人位置的旋转因子,默认为12(范围1-13),越大越快。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _rotaryFactor = 10;
|
||||
private int _rotaryFactor = 12;
|
||||
|
||||
/// <summary>
|
||||
/// 是否是第一次检查和面敌。
|
||||
@@ -155,7 +155,13 @@ public partial class AutoFightConfig : ObservableObject
|
||||
private string _kazuhaPartyName = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _swimmingEnabled = false;
|
||||
private bool _swimmingEnabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// 基于经验值判断是否执行战后拾取(检测到精英怪经验值图标时才拾取)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _expBasedPickupEnabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗超时,单位秒
|
||||
|
||||
@@ -56,6 +56,7 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
|
||||
RotaryFactor = autoFightConfig.FinishDetectConfig.RotaryFactor;
|
||||
QinDoublePickUp = autoFightConfig.QinDoublePickUp;
|
||||
SwimmingEnabled = autoFightConfig.SwimmingEnabled;
|
||||
ExpBasedPickupEnabled = autoFightConfig.ExpBasedPickupEnabled;
|
||||
}
|
||||
|
||||
public FightFinishDetectConfig FinishDetectConfig { get; set; } = new();
|
||||
@@ -84,6 +85,11 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
|
||||
public bool QinDoublePickUp { get; set; } = false;
|
||||
public static bool SwimmingEnabled { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 基于经验值判断是否执行战后拾取
|
||||
/// </summary>
|
||||
public bool ExpBasedPickupEnabled { get; set; } = false;
|
||||
|
||||
public AutoFightParam(string? strategyName = null) : base(null, null)
|
||||
{
|
||||
SetCombatStrategyPath(strategyName);
|
||||
@@ -140,5 +146,6 @@ public class AutoFightParam : BaseTaskParam<AutoFightTask>
|
||||
GuardianAvatarHold = autoFightConfig.GuardianAvatarHold;
|
||||
SwimmingEnabled = autoFightConfig.SwimmingEnabled;
|
||||
QinDoublePickUp = autoFightConfig.QinDoublePickUp;
|
||||
ExpBasedPickupEnabled = autoFightConfig.ExpBasedPickupEnabled;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
@@ -299,6 +300,16 @@ public class AutoFightTask : ISoloTask
|
||||
|
||||
AutoFightSeek.RotationCount= 0; // 重置旋转次数
|
||||
|
||||
// 基于经验值的战后拾取检测:在战斗过程中异步检测精英怪经验值图标
|
||||
// 仅在万叶拾取总开关开启时才启动经验值检测
|
||||
ExperienceDetector? expDetector = null;
|
||||
if (_taskParam.KazuhaPickupEnabled && _taskParam.ExpBasedPickupEnabled)
|
||||
{
|
||||
var expRos = AutoFightAssets.Instance.ExperienceRecognitionObjects;
|
||||
expDetector = new ExperienceDetector(expRos, cts2.Token);
|
||||
expDetector.Start();
|
||||
}
|
||||
|
||||
// 战斗操作
|
||||
var fightTask = Task.Run(async () =>
|
||||
{
|
||||
@@ -427,7 +438,7 @@ public class AutoFightTask : ISoloTask
|
||||
}
|
||||
|
||||
#region check动作触发战斗结束检测
|
||||
if (command.Method == Method.Check)
|
||||
if (command.Method == Method.Check && _taskParam.FightFinishDetectEnabled)
|
||||
{
|
||||
fightEndFlag = await CheckFightFinish(delayTime, detectDelayTime);
|
||||
}
|
||||
@@ -489,6 +500,50 @@ public class AutoFightTask : ISoloTask
|
||||
}, cts2.Token);
|
||||
|
||||
await fightTask;
|
||||
|
||||
try
|
||||
{
|
||||
// 基于经验值检测结果的拾取判断
|
||||
if (_taskParam.KazuhaPickupEnabled && _taskParam.ExpBasedPickupEnabled && expDetector != null)
|
||||
{
|
||||
// 战斗结束与怪物死亡可能几乎同时发生,检测器可能还没来得及捕获经验值图标
|
||||
// 保持检测器运行,每 100ms 轮询一次结果,最多等待 1.1 秒
|
||||
if (!expDetector.HasDetectedExperience)
|
||||
{
|
||||
Logger.LogInformation("基于经验值判断:等待经验值检测结果");
|
||||
var waitMs = 1100;
|
||||
while (!expDetector.HasDetectedExperience && waitMs > 0)
|
||||
{
|
||||
await Delay(100, ct);
|
||||
waitMs -= 100;
|
||||
}
|
||||
}
|
||||
|
||||
await expDetector.StopAsync();
|
||||
var shouldPickup = expDetector.HasDetectedExperience;
|
||||
Logger.LogInformation("基于经验值判断:{Result} 战后拾取", shouldPickup ? "执行" : "不执行");
|
||||
|
||||
if (!shouldPickup)
|
||||
{
|
||||
// 经验值检测未通过,跳过拾取(但仍执行扫描拾取逻辑)
|
||||
if (_taskParam is { PickDropsAfterFightEnabled: true })
|
||||
{
|
||||
await new ScanPickTask().Start(ct);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 确保检测器在任何路径(异常/取消/正常)都被停止和释放
|
||||
if (expDetector != null)
|
||||
{
|
||||
await expDetector.StopAsync();
|
||||
expDetector.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (_taskParam.BattleThresholdForLoot>=2 && countFight < _taskParam.BattleThresholdForLoot)
|
||||
{
|
||||
Logger.LogInformation($"战斗人次({countFight})低于配置人次({_taskParam.BattleThresholdForLoot}),跳过此次拾取!");
|
||||
@@ -909,4 +964,4 @@ public class AutoFightTask : ISoloTask
|
||||
// // 要大于 gadgetMat 的 1/2
|
||||
// return list.Any(r => r.Width > gadgetMat.Width / 2 && r.Height > gadgetMat.Height / 2);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值检测器:在战斗过程中异步检测屏幕上怪物死亡时掉落的经验值数字图标,
|
||||
/// 用于判断是否有精英怪被击杀,从而决定战后是否执行拾取。
|
||||
/// </summary>
|
||||
public sealed class ExperienceDetector : IDisposable
|
||||
{
|
||||
private static readonly ILogger Logger = TaskControl.Logger;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值图标左侧特征像素的水平偏移量(相对于模板匹配位置)
|
||||
/// </summary>
|
||||
private const int ExpIconPixelOffsetX = -147;
|
||||
|
||||
/// <summary>
|
||||
/// 经验值图标特征颜色 BGR 范围(用于二次验证模板匹配结果)
|
||||
/// </summary>
|
||||
private static readonly Vec3b ExpColorMin = new(200, 200, 150);
|
||||
private static readonly Vec3b ExpColorMax = new(255, 255, 200);
|
||||
|
||||
/// <summary>
|
||||
/// 检测循环间隔(毫秒)
|
||||
/// </summary>
|
||||
private const int DetectionIntervalMs = 100;
|
||||
|
||||
private readonly IReadOnlyList<RecognitionObject> _experienceRos;
|
||||
private readonly CancellationTokenSource _linkedCts;
|
||||
private readonly TaskCompletionSource<bool> _resultTcs;
|
||||
private Task? _detectionTask;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// 获取检测结果:是否检测到经验值图标
|
||||
/// </summary>
|
||||
public bool HasDetectedExperience =>
|
||||
_resultTcs.Task.IsCompletedSuccessfully && _resultTcs.Task.Result;
|
||||
|
||||
public ExperienceDetector(
|
||||
IReadOnlyList<RecognitionObject> experienceRos,
|
||||
CancellationToken externalToken)
|
||||
{
|
||||
_experienceRos = experienceRos ?? throw new ArgumentNullException(nameof(experienceRos));
|
||||
_linkedCts = CancellationTokenSource.CreateLinkedTokenSource(externalToken);
|
||||
_resultTcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动后台经验值检测循环
|
||||
/// </summary>
|
||||
public void
|
||||
Start()
|
||||
{
|
||||
if (_experienceRos.Count == 0)
|
||||
{
|
||||
Logger.LogWarning("经验值检测:无可用模板,跳过检测");
|
||||
return;
|
||||
}
|
||||
|
||||
_detectionTask = Task.Run(() => DetectionLoop(_linkedCts.Token), _linkedCts.Token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止检测并等待后台任务结束
|
||||
/// </summary>
|
||||
public async Task StopAsync()
|
||||
{
|
||||
_linkedCts.Cancel();
|
||||
if (_detectionTask != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _detectionTask.ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// 正常取消,忽略
|
||||
}
|
||||
}
|
||||
|
||||
// 确保结果有值(未检测到时设为 false)
|
||||
_resultTcs.TrySetResult(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 后台检测循环:截屏 → 模板匹配 → 像素颜色验证
|
||||
/// </summary>
|
||||
private void DetectionLoop(CancellationToken ct)
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var capture = TaskControl.CaptureToRectArea();
|
||||
|
||||
foreach (var ro in _experienceRos)
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
|
||||
var matchResult = capture.Find(ro);
|
||||
if (!matchResult.IsExist())
|
||||
continue;
|
||||
|
||||
// 模板匹配成功,执行像素颜色二次验证
|
||||
if (ValidateExpPixelColor(capture, matchResult))
|
||||
{
|
||||
Logger.LogInformation("基于经验值判断:检测到 {Name} 经验值图标,启用战后拾取", ro.Name.Replace("Experience_", ""));
|
||||
_resultTcs.TrySetResult(true);
|
||||
return; // 检测到后退出循环
|
||||
}
|
||||
}
|
||||
|
||||
// 短暂等待后继续下一轮检测
|
||||
Thread.Sleep(DetectionIntervalMs);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "经验值检测循环中发生异常,继续下一轮");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 像素颜色验证:检查匹配位置左侧偏移处的像素是否符合经验值图标特征色
|
||||
/// </summary>
|
||||
private static bool ValidateExpPixelColor(ImageRegion capture, Region matchResult)
|
||||
{
|
||||
var checkX = matchResult.X + ExpIconPixelOffsetX;
|
||||
var checkY = matchResult.Y;
|
||||
|
||||
// 边界检查
|
||||
if (checkX < 0 || checkX >= capture.SrcMat.Cols || checkY < 0 || checkY >= capture.SrcMat.Rows)
|
||||
return false;
|
||||
|
||||
var pixel = capture.SrcMat.At<Vec3b>(checkY, checkX);
|
||||
return pixel[0] >= ExpColorMin[0] && pixel[0] <= ExpColorMax[0] // B
|
||||
&& pixel[1] >= ExpColorMin[1] && pixel[1] <= ExpColorMax[1] // G
|
||||
&& pixel[2] >= ExpColorMin[2] && pixel[2] <= ExpColorMax[2]; // R
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
|
||||
_linkedCts.Cancel();
|
||||
_linkedCts.Dispose();
|
||||
_resultTcs.TrySetResult(false);
|
||||
_detectionTask = null;
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,19 @@ public class Avatar
|
||||
/// 战斗场景
|
||||
/// </summary>
|
||||
public CombatScenes CombatScenes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 脱困方向数组(前/后/左/右)
|
||||
/// </summary>
|
||||
private static readonly GIActions[] UnstuckDirections =
|
||||
{
|
||||
GIActions.MoveForward,
|
||||
GIActions.MoveBackward,
|
||||
GIActions.MoveLeft,
|
||||
GIActions.MoveRight
|
||||
};
|
||||
|
||||
private static readonly Random UnstuckRandom = new();
|
||||
|
||||
|
||||
public Avatar(CombatScenes combatScenes, string name, int index, Rect nameRect, double manualSkillCd = -1)
|
||||
@@ -121,29 +134,44 @@ public class Avatar
|
||||
{
|
||||
if (AutoFightTask.FightWaypoint is not null)
|
||||
{
|
||||
// 二次确认:延迟 800ms 后重新截屏,避免同帧误判
|
||||
Sleep(800, ct);
|
||||
using var ra = CaptureToRectArea();
|
||||
if (!SwimmingConfirm(ra)) //二次确认
|
||||
if (!SwimmingConfirm(ra))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.LogInformation("游泳检测:尝试回到战斗地点");
|
||||
var cts = new CancellationTokenSource();
|
||||
var pathExecutor = new PathExecutor(cts.Token);
|
||||
|
||||
// 保存原始 MoveMode,用于 finally 还原
|
||||
var originalMoveMode = AutoFightTask.FightWaypoint.MoveMode;
|
||||
// 链接外部取消令牌,确保外部取消时能及时响应;using 确保自动 Dispose
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
|
||||
try
|
||||
{
|
||||
pathExecutor.FaceTo(AutoFightTask.FightWaypoint).Wait(2000,cts.Token);
|
||||
AutoFightTask.FightWaypoint.MoveMode = MoveModeEnum.Fly.Code; // 改为跳飞
|
||||
var pathExecutor = new PathExecutor(cts.Token);
|
||||
|
||||
// FaceTo 朝向战斗点,超时 2 秒
|
||||
cts.CancelAfter(2000);
|
||||
pathExecutor.FaceTo(AutoFightTask.FightWaypoint).GetAwaiter().GetResult();
|
||||
|
||||
// 重置超时,MoveTo 超时 15 秒
|
||||
cts.CancelAfter(15000);
|
||||
// 使用 Climb 模式:MoveTo 内部对 Climb 模式跳过卡死脱困检测,避免水中 TrapEscaper 死循环
|
||||
AutoFightTask.FightWaypoint.MoveMode = MoveModeEnum.Climb.Code;
|
||||
Simulation.SendInput.Mouse.RightButtonDown();
|
||||
pathExecutor.MoveTo(AutoFightTask.FightWaypoint).Wait(15000,cts.Token);
|
||||
cts.Cancel();
|
||||
AutoFightTask.FightWaypoint = null;
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
pathExecutor.MoveTo(AutoFightTask.FightWaypoint).GetAwaiter().GetResult();
|
||||
Logger.LogInformation("游泳检测:移动结束");
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
Logger.LogError("游泳检测:回到战斗地点任务被取消");
|
||||
throw;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Logger.LogWarning("游泳检测:回到战斗地点超时");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -151,6 +179,11 @@ public class Avatar
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 确保所有资源和状态在任何路径都被正确清理
|
||||
cts.Cancel(); // 终止 PathExecutor 内部截屏循环
|
||||
AutoFightTask.FightWaypoint.MoveMode = originalMoveMode;
|
||||
AutoFightTask.FightWaypoint = null;
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
Simulation.ReleaseAllKey();
|
||||
}
|
||||
|
||||
@@ -158,7 +191,7 @@ public class Avatar
|
||||
if (!SwimmingConfirm(bitmap2))
|
||||
{
|
||||
Logger.LogInformation("游泳检测:游泳脱困成功");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.LogWarning("游泳检测:回到战斗地点失败");
|
||||
@@ -229,6 +262,13 @@ public class Avatar
|
||||
SimulateSwitchAction(Index);
|
||||
// Debug.WriteLine($"切换到{Index}号位");
|
||||
// Cv2.ImWrite($"log/切换.png", region.SrcMat);
|
||||
|
||||
// 第10次重试时,战斗状态下执行脱困动作
|
||||
if (i == 10 && AutoFightTask.FightStatusFlag)
|
||||
{
|
||||
PerformUnstuckAction(Ct);
|
||||
}
|
||||
|
||||
Sleep(250, Ct);
|
||||
}
|
||||
}
|
||||
@@ -259,14 +299,20 @@ public class Avatar
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == tryTimes - 1)
|
||||
if (i == tryTimes - 1 && tryTimes == 4) //默认状态,没有特意设置重试次数的情况下,最后一次重试失败才输出日志
|
||||
{
|
||||
Logger.LogWarning("切换角色失败,最后一次尝试,当前角色编号:{CurrentIndex},期望角色编号:{ExpectedIndex}", CombatScenes.GetActiveAvatarIndex(region, context), Index);
|
||||
region.SrcMat.SaveImage($"log/{Name}_切换失败.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 特意需要脱困情形下,会设置重试次数激活脱困检测,第10次重试时(2.5秒切换失败,超过角色的大招动画时间),如在盾奶位功能中次数会到第十次。
|
||||
if (i == 9 && AutoFightTask.FightStatusFlag)
|
||||
{
|
||||
PerformUnstuckAction(Ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SimulateSwitchAction(Index);
|
||||
|
||||
Sleep(250, Ct);
|
||||
@@ -302,6 +348,23 @@ public class Avatar
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 战斗中切换角色卡住时的脱困动作:跳跃 → 随机方向移动+切换 → 攻击 → 释放按键
|
||||
/// </summary>
|
||||
private void PerformUnstuckAction(CancellationToken ct)
|
||||
{
|
||||
var direction = UnstuckDirections[UnstuckRandom.Next(4)];
|
||||
Logger.LogWarning("切换角色卡住,执行脱困(方向:{Dir})", direction);
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
Sleep(200, ct);
|
||||
Simulation.SendInput.SimulateAction(direction, KeyType.KeyDown);
|
||||
SimulateSwitchAction(Index);
|
||||
Sleep(1000, ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
Simulation.ReleaseAllKey();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换到本角色
|
||||
/// 切换cd是1秒,如果切换失败,会尝试再次切换,最多尝试5次
|
||||
|
||||
@@ -407,7 +407,8 @@ public class PartyAvatarSideIndexHelper
|
||||
// 方法3:使用更加靠谱的差值识别(-1是未识别),但是不支持非满队
|
||||
if (mats.Length == 4)
|
||||
{
|
||||
return ImageDifferenceDetector.FindMostDifferentImage(mats);
|
||||
var result = ImageDifferenceDetector.FindMostDifferentImage(mats);
|
||||
return result >= 0 ? result + 1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+1540
-1492
File diff suppressed because it is too large.
Load diff
@@ -1715,6 +1715,27 @@
|
||||
"strategy": "蒙德7-达达乌帕谷",
|
||||
"steps": 6,
|
||||
"order": 6
|
||||
},
|
||||
{
|
||||
"x": -155,
|
||||
"y": 3324,
|
||||
"strategy": "蒙德8-风车镇",
|
||||
"steps": 3,
|
||||
"order": 1
|
||||
},
|
||||
{
|
||||
"x": -256,
|
||||
"y": 3295,
|
||||
"strategy": "蒙德8-风车镇",
|
||||
"steps": 3,
|
||||
"order": 2
|
||||
},
|
||||
{
|
||||
"x": -330,
|
||||
"y": 3226,
|
||||
"strategy": "蒙德8-风车镇",
|
||||
"steps": 3,
|
||||
"order": 3
|
||||
}
|
||||
],
|
||||
"须弥": [
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"info": {
|
||||
"authors": [
|
||||
{
|
||||
"links": "",
|
||||
"name": "ddaodan"
|
||||
}
|
||||
],
|
||||
"bgi_version": "0.60.0",
|
||||
"description": "",
|
||||
"enable_monster_loot_split": false,
|
||||
"last_modified_time": 1775792800230,
|
||||
"map_match_method": "SIFT",
|
||||
"map_name": "Teyvat",
|
||||
"name": "蒙德8-风车镇-1",
|
||||
"tags": [],
|
||||
"type": "collect",
|
||||
"version": "1.0"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"id": 1,
|
||||
"x": -155.69140625,
|
||||
"y": 3324.93212890625,
|
||||
"type": "target",
|
||||
"move_mode": "walk"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"info": {
|
||||
"authors": [
|
||||
{
|
||||
"links": "",
|
||||
"name": "ddaodan"
|
||||
}
|
||||
],
|
||||
"bgi_version": "0.60.0",
|
||||
"description": "",
|
||||
"enable_monster_loot_split": false,
|
||||
"last_modified_time": 1775792896742,
|
||||
"map_match_method": "SIFT",
|
||||
"map_name": "Teyvat",
|
||||
"name": "蒙德8-风车镇-2",
|
||||
"tags": [],
|
||||
"type": "collect",
|
||||
"version": "1.0"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"id": 1,
|
||||
"x": -256.87890625,
|
||||
"y": 3295.62060546875,
|
||||
"type": "target",
|
||||
"move_mode": "walk"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"info": {
|
||||
"authors": [
|
||||
{
|
||||
"links": "",
|
||||
"name": "ddaodan"
|
||||
}
|
||||
],
|
||||
"bgi_version": "0.60.0",
|
||||
"description": "",
|
||||
"enable_monster_loot_split": false,
|
||||
"last_modified_time": 1775793214341,
|
||||
"map_match_method": "SIFT",
|
||||
"map_name": "Teyvat",
|
||||
"name": "蒙德8-风车镇-3",
|
||||
"tags": [],
|
||||
"type": "collect",
|
||||
"version": "1.0"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"id": 1,
|
||||
"x": -330.87890625,
|
||||
"y": 3226.130859375,
|
||||
"type": "target",
|
||||
"move_mode": "walk"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"info": {
|
||||
"authors": [
|
||||
{
|
||||
"links": "",
|
||||
"name": "ddaodan"
|
||||
}
|
||||
],
|
||||
"bgi_version": "0.60.0",
|
||||
"description": "",
|
||||
"enable_monster_loot_split": false,
|
||||
"last_modified_time": 1775792800230,
|
||||
"map_match_method": "SIFT",
|
||||
"map_name": "Teyvat",
|
||||
"name": "蒙德8-风车镇-1",
|
||||
"tags": [],
|
||||
"type": "collect",
|
||||
"version": "1.0"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 1,
|
||||
"move_mode": "walk",
|
||||
"type": "teleport",
|
||||
"x": -82.462890625,
|
||||
"y": 3309.48583984375
|
||||
},
|
||||
{
|
||||
"action": "stop_flying",
|
||||
"action_params": "",
|
||||
"id": 2,
|
||||
"locked": false,
|
||||
"move_mode": "fly",
|
||||
"type": "path",
|
||||
"x": -155.69140625,
|
||||
"y": 3324.93212890625
|
||||
},
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 3,
|
||||
"move_mode": "walk",
|
||||
"type": "target",
|
||||
"x": -155.69140625,
|
||||
"y": 3324.93212890625
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"info": {
|
||||
"authors": [
|
||||
{
|
||||
"links": "",
|
||||
"name": "ddaodan"
|
||||
}
|
||||
],
|
||||
"bgi_version": "0.60.0",
|
||||
"description": "",
|
||||
"enable_monster_loot_split": false,
|
||||
"last_modified_time": 1775792896742,
|
||||
"map_match_method": "SIFT",
|
||||
"map_name": "Teyvat",
|
||||
"name": "蒙德8-风车镇-2",
|
||||
"tags": [],
|
||||
"type": "collect",
|
||||
"version": "1.0"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 1,
|
||||
"move_mode": "dash",
|
||||
"type": "path",
|
||||
"x": -193.931640625,
|
||||
"y": 3335.927734375
|
||||
},
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 2,
|
||||
"move_mode": "dash",
|
||||
"type": "target",
|
||||
"x": -256.87890625,
|
||||
"y": 3295.62060546875
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"info": {
|
||||
"authors": [
|
||||
{
|
||||
"links": "",
|
||||
"name": "ddaodan"
|
||||
}
|
||||
],
|
||||
"bgi_version": "0.60.0",
|
||||
"description": "",
|
||||
"enable_monster_loot_split": false,
|
||||
"last_modified_time": 1775793214341,
|
||||
"map_match_method": "SIFT",
|
||||
"map_name": "Teyvat",
|
||||
"name": "蒙德8-风车镇-3",
|
||||
"tags": [],
|
||||
"type": "collect",
|
||||
"version": "1.0"
|
||||
},
|
||||
"positions": [
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 1,
|
||||
"move_mode": "dash",
|
||||
"type": "path",
|
||||
"x": -273.49609375,
|
||||
"y": 3291.94677734375
|
||||
},
|
||||
{
|
||||
"action": "",
|
||||
"action_params": "",
|
||||
"id": 2,
|
||||
"move_mode": "dash",
|
||||
"type": "target",
|
||||
"x": -330.87890625,
|
||||
"y": 3226.130859375
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -48,6 +48,9 @@ public partial class AutoLeyLineOutcropFightConfig : ObservableObject
|
||||
[ObservableProperty] private bool _kazuhaPickupEnabled = true;
|
||||
[ObservableProperty] private bool _qinDoublePickUp = false;
|
||||
[ObservableProperty] private int _timeout = 120;
|
||||
[ObservableProperty] private bool _seekEnemyEnabled = false;
|
||||
[ObservableProperty] private int _seekEnemyIntervalSeconds = 3;
|
||||
[ObservableProperty] private int _seekEnemyRotaryFactor = 6;
|
||||
|
||||
public void CopyFromAutoFightConfig(AutoFightConfig source)
|
||||
{
|
||||
|
||||
@@ -81,6 +81,8 @@ public class AutoLeyLineOutcropTask : ISoloTask
|
||||
private const string OcrFlowOverlayKey = "AutoLeyLineOutcrop.OcrFlow";
|
||||
private const string OcrFightOverlayKey = "AutoLeyLineOutcrop.OcrFight";
|
||||
private const int OcrOverlayRenderLeadMs = 300;
|
||||
private const int KazuhaPickupPostSkillWaitMs = 3000;
|
||||
private static readonly TimeSpan LeyLineFightSeekInitialDelay = TimeSpan.FromSeconds(2);
|
||||
private static readonly Rect HandbookTrackActionButtonRoi = new(ScaleTo1080(1120), ScaleTo1080(680), ScaleTo1080(700), ScaleTo1080(320));
|
||||
private static readonly System.Drawing.Pen OcrOverlayPen = new(System.Drawing.Color.Lime, 2);
|
||||
private static readonly object PickLock = new();
|
||||
@@ -1084,6 +1086,8 @@ public class AutoLeyLineOutcropTask : ISoloTask
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
await Delay(1500, _ct);
|
||||
kazuha.AfterUseSkill();
|
||||
_logger.LogInformation("战后聚集拾取:万叶长E动作完成,等待拾取动作结束");
|
||||
await Delay(KazuhaPickupPostSkillWaitMs, _ct);
|
||||
_logger.LogInformation("战后聚集拾取:万叶长E聚集动作执行完成");
|
||||
}
|
||||
|
||||
@@ -1183,7 +1187,9 @@ public class AutoLeyLineOutcropTask : ISoloTask
|
||||
{
|
||||
var fightCts = CancellationTokenSource.CreateLinkedTokenSource(_ct);
|
||||
using var autoFightConfigScope = UseLeyLineAutoFightConfigScope();
|
||||
// Ley line uses OCR-based finish detection; disable auto-fight finish detect.
|
||||
// 地脉花战斗拆成两条并行链路:
|
||||
// 1. AutoFightTask 持续执行战斗脚本,不负责任何结束判定。
|
||||
// 2. RecognizeTextInRegion 只通过 OCR 判定胜负,并在轮询间隙补一次内部寻敌辅助。
|
||||
var fightTask = StartAutoFightWithoutFinishDetect(fightCts.Token);
|
||||
var fightResult = await RecognizeTextInRegion(timeoutSeconds * 1000);
|
||||
fightCts.Cancel();
|
||||
@@ -1272,19 +1278,26 @@ public class AutoLeyLineOutcropTask : ISoloTask
|
||||
{
|
||||
var start = DateTime.UtcNow;
|
||||
var noTextCount = 0;
|
||||
var fightTextDetectedAt = DateTime.MinValue;
|
||||
var lastSeekAssistAt = DateTime.MinValue;
|
||||
var seekEnemyEnabled = _taskParam.FightConfig.SeekEnemyEnabled;
|
||||
var seekEnemyInterval = TimeSpan.FromSeconds(Math.Clamp(_taskParam.FightConfig.SeekEnemyIntervalSeconds, 1, 60));
|
||||
var seekEnemyRotaryFactor = Math.Clamp(_taskParam.FightConfig.SeekEnemyRotaryFactor, 1, 13);
|
||||
var successKeywords = new[] { "挑战达成", "战斗胜利", "挑战成功" };
|
||||
var failureKeywords = new[] { "挑战失败" };
|
||||
|
||||
while ((DateTime.UtcNow - start).TotalMilliseconds < timeoutMs)
|
||||
{
|
||||
using var capture = CaptureToRectArea();
|
||||
using var ocrOverlayScope = DrawOcrOverlayScope(capture, OcrFightOverlayKey, _ocrRo1!.RegionOfInterest, _ocrRo2!.RegionOfInterest);
|
||||
await WaitOcrOverlayRenderTick();
|
||||
string text;
|
||||
bool foundText;
|
||||
var result = capture.Find(_ocrRo1!);
|
||||
text = result.Text;
|
||||
foundText = RecognizeFightText(capture);
|
||||
using (var capture = CaptureToRectArea())
|
||||
using (var ocrOverlayScope = DrawOcrOverlayScope(capture, OcrFightOverlayKey, _ocrRo1!.RegionOfInterest, _ocrRo2!.RegionOfInterest))
|
||||
{
|
||||
await WaitOcrOverlayRenderTick();
|
||||
var result = capture.Find(_ocrRo1!);
|
||||
text = result.Text;
|
||||
foundText = RecognizeFightText(capture);
|
||||
}
|
||||
|
||||
if (successKeywords.Any(text.Contains))
|
||||
{
|
||||
@@ -1308,7 +1321,18 @@ public class AutoLeyLineOutcropTask : ISoloTask
|
||||
}
|
||||
else
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
if (fightTextDetectedAt == DateTime.MinValue)
|
||||
{
|
||||
fightTextDetectedAt = now;
|
||||
}
|
||||
|
||||
noTextCount = 0;
|
||||
if (ShouldRunLeyLineFightSeek(seekEnemyEnabled, now, fightTextDetectedAt, lastSeekAssistAt, seekEnemyInterval))
|
||||
{
|
||||
lastSeekAssistAt = now;
|
||||
await TrySeekEnemyDuringLeyLineFight(seekEnemyRotaryFactor);
|
||||
}
|
||||
}
|
||||
|
||||
await Delay(1000, _ct);
|
||||
@@ -1317,6 +1341,39 @@ public class AutoLeyLineOutcropTask : ISoloTask
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool ShouldRunLeyLineFightSeek(bool seekEnemyEnabled, DateTime now, DateTime fightTextDetectedAt, DateTime lastSeekAssistAt, TimeSpan seekEnemyInterval)
|
||||
{
|
||||
if (!seekEnemyEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fightTextDetectedAt == DateTime.MinValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (now - fightTextDetectedAt < LeyLineFightSeekInitialDelay)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return lastSeekAssistAt == DateTime.MinValue || now - lastSeekAssistAt >= seekEnemyInterval;
|
||||
}
|
||||
|
||||
private async Task TrySeekEnemyDuringLeyLineFight(int rotaryFactor)
|
||||
{
|
||||
try
|
||||
{
|
||||
// isEndCheck=true prevents AutoFightSeek from falling back to any party-screen finish check.
|
||||
await AutoFightSeek.SeekAndFightAsync(_logger, 0, 0, _ct, true, rotaryFactor);
|
||||
}
|
||||
catch (Exception ex) when (ex is not OperationCanceledException)
|
||||
{
|
||||
_logger.LogDebug(ex, "地脉花战斗中内部寻敌异常");
|
||||
}
|
||||
}
|
||||
|
||||
private bool RecognizeFightText(ImageRegion captureRegion)
|
||||
{
|
||||
var result = captureRegion.Find(_ocrRo2!);
|
||||
@@ -1907,7 +1964,7 @@ public class AutoLeyLineOutcropTask : ISoloTask
|
||||
Simulation.SendInput.Mouse.LeftButtonUp();
|
||||
await Delay(60, _ct);
|
||||
|
||||
var (success, _) = AutoDomainTask.PressUseResin(promptRegions, resinName);
|
||||
var (success, _) = AutoDomainTask.PressUseResin(promptRegions, resinName, Name);
|
||||
if (success)
|
||||
{
|
||||
_logger.LogDebug("奖励页面已尝试使用树脂:{ResinName}", resinName);
|
||||
|
||||
@@ -26,6 +26,7 @@ public class ActionFactory
|
||||
"pyro_collect" => new ElementalCollectHandler(ElementalType.Pyro),
|
||||
"combat_script" => new CombatScriptHandler(),
|
||||
"mining" => new MiningHandler(),
|
||||
"linnea_mining" => new LinneaMiningHandler(),
|
||||
"fishing" => new FishingHandler(),
|
||||
"exit_and_relogin" => new ExitAndReloginHandler(),
|
||||
"wonderland_cycle" => new EnterAndExitWonderlandHandler(),
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.GameTask.Common.Job;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 莉奈娅Yolo挖矿
|
||||
/// 格式: "射箭次数,大循环次数" 或 "射箭次数"
|
||||
/// 例: "3" 或 "3,10" 或 "mines=3,rounds=10"
|
||||
/// </summary>
|
||||
public class LinneaMiningHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
{
|
||||
var (mineCount, scanRounds) = ParseParams(waypointForTrack?.ActionParams);
|
||||
|
||||
var combatScenes = await RunnerContext.Instance.GetCombatScenes(ct);
|
||||
if (combatScenes == null)
|
||||
{
|
||||
Logger.LogError("队伍识别未初始化成功!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 切人
|
||||
var linnea = combatScenes.SelectAvatar("莉奈娅");
|
||||
if (linnea is not null)
|
||||
{
|
||||
linnea.TrySwitch();
|
||||
await Delay(500, ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError("队伍中未找到莉奈娅!");
|
||||
return;
|
||||
}
|
||||
|
||||
await new LinneaMiningTask(scanRounds, mineCount).Start(ct);
|
||||
}
|
||||
|
||||
private static (int mineCount, int scanRounds) ParseParams(string? actionParams)
|
||||
{
|
||||
if (string.IsNullOrEmpty(actionParams)) return (1, 5);
|
||||
|
||||
var parts = actionParams.Split(',');
|
||||
var mineCount = -1;
|
||||
var scanRounds = -1;
|
||||
|
||||
foreach (var part in parts)
|
||||
{
|
||||
var trimmed = part.Trim();
|
||||
if (trimmed.StartsWith("mines=", StringComparison.OrdinalIgnoreCase)
|
||||
&& int.TryParse(trimmed.AsSpan("mines=".Length), out var m))
|
||||
{
|
||||
mineCount = Clamp(m, 1, 999);
|
||||
}
|
||||
else if (trimmed.StartsWith("rounds=", StringComparison.OrdinalIgnoreCase)
|
||||
&& int.TryParse(trimmed.AsSpan("rounds=".Length), out var r))
|
||||
{
|
||||
scanRounds = Clamp(r, 1, 999);
|
||||
}
|
||||
else if (int.TryParse(trimmed, out var num))
|
||||
{
|
||||
if (mineCount == -1)
|
||||
mineCount = Clamp(num, 1, 999);
|
||||
else if (scanRounds == -1)
|
||||
scanRounds = Clamp(num, 1, 999);
|
||||
}
|
||||
}
|
||||
|
||||
if (mineCount == -1) mineCount = 1;
|
||||
if (scanRounds == -1) scanRounds = 5;
|
||||
if (scanRounds < mineCount) scanRounds = mineCount;
|
||||
|
||||
return (mineCount, scanRounds);
|
||||
}
|
||||
|
||||
private static int Clamp(int value, int min, int max) => value <= 0 ? min : value > max ? max : value;
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public class ActionEnum(string code, string msg, ActionUseWaypointTypeEnum useWa
|
||||
public static readonly ActionEnum CombatScript = new("combat_script", "战斗策略脚本", ActionUseWaypointTypeEnum.Custom); // 这个必须要 action_params 里面有脚本
|
||||
|
||||
public static readonly ActionEnum Mining = new("mining", "挖矿", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum LinneaMining = new("linnea_mining", "莉奈娅挖矿", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum LogOutput = new("log_output", "输出日志", ActionUseWaypointTypeEnum.Custom);
|
||||
|
||||
public static readonly ActionEnum Fishing = new("fishing", "钓鱼", ActionUseWaypointTypeEnum.Custom);
|
||||
|
||||
@@ -120,6 +120,6 @@ public class PathingTask
|
||||
public void SaveToFile(string filePath)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(this, PathRecorder.JsonOptions);
|
||||
File.WriteAllText(filePath, json, Encoding.UTF8);
|
||||
File.WriteAllText(filePath, json, new UTF8Encoding(false));
|
||||
}
|
||||
}
|
||||
@@ -1108,6 +1108,7 @@ public class PathExecutor
|
||||
|| waypoint.Action == ActionEnum.PyroCollect.Code
|
||||
|| waypoint.Action == ActionEnum.CombatScript.Code
|
||||
|| waypoint.Action == ActionEnum.Mining.Code
|
||||
|| waypoint.Action == ActionEnum.LinneaMining.Code
|
||||
|| waypoint.Action == ActionEnum.Fishing.Code
|
||||
|| waypoint.Action == ActionEnum.ExitAndRelogin.Code
|
||||
|| waypoint.Action == ActionEnum.EnterAndExitWonderland.Code
|
||||
|
||||
@@ -49,6 +49,8 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
public bool UseBackgroundOperation { get; private set; }
|
||||
|
||||
public bool IsUseInteractionKey { get; set; } = false;
|
||||
|
||||
private const int PlayingFlagDisappearDelaySeconds = 10; // 播放标识消失后继续识别的秒数
|
||||
|
||||
private readonly AutoSkipAssets _autoSkipAssets;
|
||||
|
||||
@@ -188,7 +190,7 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
TryBringToFrontAfterBackgroundDialog();
|
||||
}
|
||||
|
||||
if (!isPlaying && (DateTime.Now - _prevPlayingTime).TotalSeconds <= 5)
|
||||
if (!isPlaying && (DateTime.Now - _prevPlayingTime).TotalSeconds <= PlayingFlagDisappearDelaySeconds)
|
||||
{
|
||||
// 关闭弹出页
|
||||
if (_config.ClosePopupPagedEnabled)
|
||||
@@ -277,8 +279,8 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
return;
|
||||
}
|
||||
|
||||
if ((DateTime.Now - _prevPlayingTime).TotalMilliseconds <= 800
|
||||
|| (DateTime.Now - _prevBringToFrontTime).TotalSeconds <= 2)
|
||||
if ((DateTime.Now - _prevPlayingTime).TotalSeconds <= PlayingFlagDisappearDelaySeconds
|
||||
|| (DateTime.Now - _prevBringToFrontTime).TotalSeconds <= 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -861,6 +863,7 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
}
|
||||
_prevCloseItemTime = DateTime.Now;
|
||||
_logger.LogInformation("自动剧情:{Text} 面积 {Area}", "点击底部三角形",area);
|
||||
_prevPlayingTime = DateTime.Now; // 此时认为还在自动剧情
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -935,6 +938,7 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
}
|
||||
|
||||
_logger.LogInformation("自动剧情:关闭角色弹窗");
|
||||
_prevPlayingTime = DateTime.Now; // 此时认为还在自动剧情
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
|
||||
(StygianState.EventMenu, [StygianState.StygianOnslaughtPage]),
|
||||
(StygianState.StygianOnslaughtPage, [StygianState.TeleportMap, StygianState.DomainEntrance]),
|
||||
(StygianState.TeleportMap, [StygianState.DomainEntrance]),
|
||||
(StygianState.DomainEntrance, [StygianState.DifficultySelect]),
|
||||
(StygianState.DomainEntrance, [StygianState.DomainEntrance, StygianState.DifficultySelect]),
|
||||
(StygianState.DifficultySelect, [StygianState.DomainLobby]),
|
||||
(StygianState.DomainLobby, [StygianState.BossSelect, StygianState.LeylineFlowerPrompt]),
|
||||
|
||||
@@ -369,10 +369,10 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
|
||||
await Delay(500, _ct);
|
||||
|
||||
// 2. 在列表区域内查找"幽境危战"并点击
|
||||
var listItem = page.GetByText("幽境危战").WithRoi(listRegion);
|
||||
if (listItem.IsExist())
|
||||
var target = page.GetByText("幽境危战").WithRoi(listRegion).FindAll().FirstOrDefault();
|
||||
if (target != null)
|
||||
{
|
||||
listItem.FindAll().FirstOrDefault()?.Click();
|
||||
target.Click();
|
||||
await Delay(300, _ct);
|
||||
return StateHandlerResult.Success; // 等待转换到 StygianOnslaughtPage
|
||||
}
|
||||
@@ -382,15 +382,20 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
|
||||
|
||||
// 如果两次都没找到,可能"幽境危战"已经被选中,直接尝试检测下一状态
|
||||
Logger.LogWarning($"{Name}:未找到幽境危战,可能已被选中,尝试检测 StygianOnslaughtPage");
|
||||
page.GetByText("幽境危战").WithRoi(listRegion).FindAll().FirstOrDefault()?.Click();
|
||||
await Delay(300, _ct);
|
||||
return StateHandlerResult.Success; // 等待转换到 StygianOnslaughtPage
|
||||
return StateHandlerResult.Success; // 让状态机继续等待邻接状态出现
|
||||
}
|
||||
|
||||
private async Task<StateHandlerResult> HandleStygianOnslaughtPageState(BvPage page)
|
||||
{
|
||||
Logger.LogInformation($"{Name}:点击前往挑战");
|
||||
page.GetByText("前往挑战").WithRoi(r => r.CutRight(0.5)).FindAll().FirstOrDefault()?.Click();
|
||||
var challengeButton = page.GetByText("前往挑战").WithRoi(r => r.CutRight(0.5)).FindAll().FirstOrDefault();
|
||||
if (challengeButton == null)
|
||||
{
|
||||
Logger.LogWarning($"{Name}:未找到前往挑战按钮");
|
||||
return StateHandlerResult.Retry;
|
||||
}
|
||||
|
||||
challengeButton.Click();
|
||||
await Delay(300, _ct);
|
||||
return StateHandlerResult.Success; // 等待转换到 TeleportMap 或 DomainEntrance
|
||||
}
|
||||
@@ -398,7 +403,14 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
|
||||
private async Task<StateHandlerResult> HandleTeleportMapState(BvPage page)
|
||||
{
|
||||
Logger.LogInformation($"{Name}:点击传送");
|
||||
page.Locator(QuickTeleportAssets.Instance.TeleportButtonRo).FindAll().FirstOrDefault()?.Click();
|
||||
var teleportButton = page.Locator(QuickTeleportAssets.Instance.TeleportButtonRo).FindAll().FirstOrDefault();
|
||||
if (teleportButton == null)
|
||||
{
|
||||
Logger.LogWarning($"{Name}:未找到传送按钮");
|
||||
return StateHandlerResult.Retry;
|
||||
}
|
||||
|
||||
teleportButton.Click();
|
||||
await Delay(300, _ct);
|
||||
return StateHandlerResult.Success; // 等待转换到 DomainEntrance
|
||||
}
|
||||
@@ -421,6 +433,12 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
|
||||
// 点击确认进入
|
||||
using var ra = CaptureToRectArea();
|
||||
var btn = ra.Find(ElementAssets.Instance.BtnWhiteConfirm);
|
||||
if (btn.IsEmpty())
|
||||
{
|
||||
Logger.LogWarning($"{Name}:未找到进入确认按钮");
|
||||
return StateHandlerResult.Retry;
|
||||
}
|
||||
|
||||
btn.Click();
|
||||
await Delay(300, _ct);
|
||||
return StateHandlerResult.Success; // 等待转换到 DomainLobby
|
||||
@@ -686,12 +704,12 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
|
||||
|
||||
if (resinStatus.CondensedResinCount > 0)
|
||||
{
|
||||
AutoDomainTask.PressUseResin(ra, "浓缩树脂");
|
||||
AutoDomainTask.PressUseResin(ra, "浓缩树脂", Name);
|
||||
resinStatus.CondensedResinCount -= 1;
|
||||
}
|
||||
else if (resinStatus.OriginalResinCount >= 20)
|
||||
{
|
||||
var (_, num) = AutoDomainTask.PressUseResin(ra, "原粹树脂");
|
||||
var (_, num) = AutoDomainTask.PressUseResin(ra, "原粹树脂", Name);
|
||||
resinStatus.OriginalResinCount -= num;
|
||||
}
|
||||
|
||||
@@ -706,7 +724,7 @@ public class AutoStygianOnslaughtTask : StateMachineBase<StygianState, BvPage>,
|
||||
{
|
||||
if (record.RemainCount > 0)
|
||||
{
|
||||
var (success, _) = AutoDomainTask.PressUseResin(textList, record.Name);
|
||||
var (success, _) = AutoDomainTask.PressUseResin(textList, record.Name, Name);
|
||||
if (success)
|
||||
{
|
||||
record.RemainCount -= 1;
|
||||
|
||||
@@ -1007,7 +1007,7 @@ public class TpTask
|
||||
if (matchRect == null)
|
||||
{
|
||||
Logger.LogWarning("切换区域失败:{Country}", areaName);
|
||||
if (areaName == MapTypes.TheChasm.GetDescription() || areaName == MapTypes.Enkanomiya.GetDescription() || areaName == MapTypes.SeaOfBygoneEras.GetDescription() || areaName == MapTypes.AncientSacredMountain.GetDescription())
|
||||
if (areaName == MapTypes.TheChasm.GetDescription() || areaName == MapTypes.Enkanomiya.GetDescription() || areaName == MapTypes.SeaOfBygoneEras.GetDescription() || areaName == MapTypes.AncientSacredMountain.GetDescription() || areaName == MapTypes.TempleOfSpace.GetDescription())
|
||||
{
|
||||
throw new Exception($"切换独立地图区域[{areaName}]失败");
|
||||
}
|
||||
|
||||
@@ -11,8 +11,10 @@ using OpenCvSharp;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
@@ -360,6 +362,43 @@ public static partial class Bv
|
||||
using var ra = captureRa.Find(ElementAssets.Instance.PromptDialogLeftBottomStar);
|
||||
return ra.IsExist();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过 OCR 识别当前角色的 UID
|
||||
/// </summary>
|
||||
/// <returns>UID 数字,如果识别失败则返回 0</returns>
|
||||
public static int Uid()
|
||||
{
|
||||
try
|
||||
{
|
||||
var x = 1683;
|
||||
var y = 1051;
|
||||
var width = 234;
|
||||
var height = 28;
|
||||
var scaleTo1080PRatio = TaskContext.Instance().SystemInfo.ScaleTo1080PRatio;
|
||||
|
||||
x = (int)Math.Round(x * scaleTo1080PRatio);
|
||||
y = (int)Math.Round(y * scaleTo1080PRatio);
|
||||
width = (int)Math.Round(width * scaleTo1080PRatio);
|
||||
height = (int)Math.Round(height * scaleTo1080PRatio);
|
||||
|
||||
using var region = TaskControl.CaptureToRectArea();
|
||||
var recognitionObjectOcr = RecognitionObject.Ocr(x, y, width, height);
|
||||
var res = region.Find(recognitionObjectOcr);
|
||||
if (res?.Text == null) return 0;
|
||||
var matches = Regex.Matches(res.Text, @"\d+");
|
||||
if (matches.Count == 0) return 0;
|
||||
var numberStr = string.Join("", matches.Select(m => m.Value));
|
||||
return int.TryParse(numberStr, out var uid) ? uid : 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TaskControl.Logger.LogError(e, "OCR 识别 UID 异常");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum MotionStatus
|
||||
|
||||
@@ -34,8 +34,9 @@ public class BlessingOfTheWelkinMoonTask
|
||||
if (j == 0)
|
||||
{
|
||||
// 双击快速跳过
|
||||
TaskContext.Instance().PostMessageSimulator.LeftButtonClickBackground();
|
||||
TaskContext.Instance().PostMessageSimulator.LeftButtonClickBackground();
|
||||
GameCaptureRegion.GameRegion1080PPosClick(100, 100);
|
||||
await Task.Delay(100, ct);
|
||||
GameCaptureRegion.GameRegion1080PPosClick(100, 100);
|
||||
}
|
||||
await Delay(500, ct);
|
||||
using var ra2 = CaptureToRectArea();
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using Compunet.YoloSharp;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using OpenCvSharp;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.Job;
|
||||
|
||||
/// <summary>
|
||||
/// 莉奈娅挖矿
|
||||
/// </summary>
|
||||
public class LinneaMiningTask
|
||||
{
|
||||
#region 配置参数
|
||||
|
||||
// 聚类距离阈值(基于宽度缩放)
|
||||
private const double BaseClusterDistance = 400;
|
||||
// 聚类面积基准值(1920宽度下的标准矿石面积)
|
||||
private const double BaseClusterArea = 1800;
|
||||
// 对准判定阈值(基于宽度缩放)
|
||||
private const double BaseArrivalThreshold = 50;
|
||||
// 屏幕边缘忽略区域宽度(基于宽度缩放)
|
||||
private const double BaseEdgeIgnore = 200;
|
||||
// 瞄准模式X轴灵敏度补偿系数
|
||||
private const double AimSensitivityFactorX = 0.45;
|
||||
// 瞄准模式Y轴灵敏度补偿系数
|
||||
private const double AimSensitivityFactorY = 0.80;
|
||||
// 检测置信度阈值
|
||||
private const float ConfidenceThreshold = 0.70f;
|
||||
// 聚类面积差异倍率
|
||||
private const double AreaRatioThreshold = 4;
|
||||
// 左转步长
|
||||
private const int LeftTurnStep = -250;
|
||||
// 内层最大检测次数
|
||||
private const int MaxInnerRetry = 7;
|
||||
// 默认大循环次数
|
||||
private const int DefaultScanRounds = 5;
|
||||
// 元素视野刷新间隔
|
||||
private const int ElementSightRefreshMs = 3000;
|
||||
|
||||
#endregion
|
||||
|
||||
private readonly BgiYoloPredictor _predictor;
|
||||
private readonly double _dpi = TaskContext.Instance().DpiScale;
|
||||
private readonly double _widthScale = TaskContext.Instance().SystemInfo.CaptureAreaRect.Width / 1920.0;
|
||||
private readonly double _heightScale = TaskContext.Instance().SystemInfo.CaptureAreaRect.Height / 1080.0;
|
||||
private readonly double ClusterDistanceThreshold;
|
||||
private readonly double ArrivalThreshold;
|
||||
private readonly double EdgeIgnore;
|
||||
|
||||
private readonly int _scanRounds;
|
||||
private readonly int _mineCount;
|
||||
private int _debugIndex;
|
||||
|
||||
public LinneaMiningTask(int scanRounds = DefaultScanRounds, int mineCount = 1)
|
||||
{
|
||||
_scanRounds = scanRounds;
|
||||
_mineCount = mineCount;
|
||||
_predictor = App.ServiceProvider.GetRequiredService<BgiOnnxFactory>()
|
||||
.CreateYoloPredictor(BgiOnnxModel.BgiMine);
|
||||
ClusterDistanceThreshold = BaseClusterDistance * _widthScale;
|
||||
ArrivalThreshold = BaseArrivalThreshold * _widthScale;
|
||||
EdgeIgnore = BaseEdgeIgnore * _widthScale;
|
||||
}
|
||||
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
var aimingModeEntered = false;
|
||||
try
|
||||
{
|
||||
// Logger.LogInformation("开始寻矿");
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_R);
|
||||
aimingModeEntered = true;
|
||||
await Delay(400, ct);
|
||||
|
||||
var minedCount = 0;
|
||||
|
||||
for (var round = 0; round < _scanRounds && !ct.IsCancellationRequested; round++)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MiddleButtonDown();
|
||||
await Delay(1500, ct);
|
||||
_lastRefreshTime = Environment.TickCount64;
|
||||
|
||||
var (cluster, centerX, centerY) = FindNearestMineralCluster();
|
||||
|
||||
if (cluster != null)
|
||||
{
|
||||
var (aligned, counted, compensateDx, compensateDy) = await AlignAndMine(cluster, centerX, centerY, ct);
|
||||
if (aligned)
|
||||
{
|
||||
if (counted) minedCount++;
|
||||
if (minedCount >= _mineCount) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
await Delay(300, ct);
|
||||
|
||||
if (compensateDx != 0 || compensateDy != 0)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MiddleButtonDown();
|
||||
await Delay(1500, ct);
|
||||
_lastRefreshTime = Environment.TickCount64;
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(-compensateDx, -compensateDy);
|
||||
await Delay(800, ct);
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
await Delay(300, ct);
|
||||
}
|
||||
|
||||
if (round < _scanRounds - 1)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy((int)(LeftTurnStep * _dpi * _widthScale), 0);
|
||||
await Delay(800, ct);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
await Delay(300, ct);
|
||||
|
||||
if (round < _scanRounds - 1)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy((int)(LeftTurnStep * _dpi * _widthScale), 0);
|
||||
}
|
||||
await Delay(800, ct);
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_R);
|
||||
aimingModeEntered = false;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Logger.LogInformation("取消挖矿");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError("挖矿异常: {Msg}", e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (aimingModeEntered)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_R);
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
}
|
||||
}
|
||||
|
||||
private long _lastRefreshTime;
|
||||
|
||||
private async Task<(bool aligned, bool counted, int compensateDx, int compensateDy)> AlignAndMine(
|
||||
MineralCluster cluster, double centerX, double centerY, CancellationToken ct)
|
||||
{
|
||||
var totalDx = 0;
|
||||
var totalDy = 0;
|
||||
var hadResult = true;
|
||||
|
||||
for (var retry = 0; retry < MaxInnerRetry && !ct.IsCancellationRequested; retry++)
|
||||
{
|
||||
if (Environment.TickCount64 - _lastRefreshTime >= ElementSightRefreshMs)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
await Delay(100, ct);
|
||||
Simulation.SendInput.Mouse.MiddleButtonDown();
|
||||
await Delay(1500, ct);
|
||||
_lastRefreshTime = Environment.TickCount64;
|
||||
}
|
||||
|
||||
var offsetX = cluster.TargetX - centerX;
|
||||
var offsetY = cluster.TargetY - centerY;
|
||||
var avgArea = cluster.Rects.Average(r => (double)r.Width * r.Height);
|
||||
var refArea = BaseClusterArea * _widthScale * _widthScale;
|
||||
var dynamicThreshold = ArrivalThreshold * Math.Max(1.0, Math.Sqrt(avgArea / refArea));
|
||||
|
||||
var isLast = retry == MaxInnerRetry - 1;
|
||||
var isAligned = Math.Abs(offsetX) <= dynamicThreshold / 2 && Math.Abs(offsetY) <= dynamicThreshold / 2;
|
||||
// 前面所有循环都检测成功时,以不计入总次数的方式兜底射击一次
|
||||
if (isAligned || (isLast && hadResult))
|
||||
{
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
await Delay(300, ct);
|
||||
// Logger.LogInformation("开始挖矿");
|
||||
await Mine(ct, totalDy < 0);
|
||||
return (true, isAligned, 0, 0);
|
||||
}
|
||||
|
||||
var mouseDx = (int)(offsetX * _dpi * AimSensitivityFactorX / _widthScale);
|
||||
var mouseDy = (int)(offsetY * _dpi * AimSensitivityFactorY / _heightScale);
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(mouseDx, mouseDy);
|
||||
totalDx += mouseDx;
|
||||
totalDy += mouseDy;
|
||||
await Delay(150, ct);
|
||||
|
||||
(cluster, centerX, centerY) = FindNearestMineralCluster();
|
||||
if (cluster == null)
|
||||
{
|
||||
hadResult = false;
|
||||
return (false, false, totalDx, totalDy);
|
||||
}
|
||||
}
|
||||
|
||||
return (false, false, totalDx, totalDy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行挖矿操作
|
||||
/// </summary>
|
||||
private static async Task Mine(CancellationToken ct, bool compensateUp)
|
||||
{
|
||||
if (compensateUp)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(0, -25);
|
||||
await Delay(10, ct);
|
||||
}
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
await Delay(2000, ct);
|
||||
}
|
||||
|
||||
private void SaveDebugImage(Mat mat)
|
||||
{
|
||||
var debugDir = Path.Combine(Global.Absolute("log"), "DebugMine");
|
||||
if (!Directory.Exists(debugDir))
|
||||
{
|
||||
Directory.CreateDirectory(debugDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
_debugIndex = Directory.GetFiles(debugDir, "detect_*.png")
|
||||
.Select(f => Path.GetFileNameWithoutExtension(f).Replace("detect_", ""))
|
||||
.Where(n => int.TryParse(n, out _))
|
||||
.Select(int.Parse)
|
||||
.DefaultIfEmpty(-1)
|
||||
.Max() + 1;
|
||||
}
|
||||
Cv2.ImWrite(Path.Combine(debugDir, $"detect_{_debugIndex++:D3}.png"), mat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测矿物,返回距屏幕中心最近的聚堆
|
||||
/// </summary>
|
||||
private (MineralCluster? cluster, double centerX, double centerY) FindNearestMineralCluster()
|
||||
{
|
||||
var systemInfo = TaskContext.Instance().SystemInfo;
|
||||
var image = CaptureGameImage(TaskTriggerDispatcher.GlobalGameCapture);
|
||||
var ra = systemInfo.DesktopRectArea.Derive(image, systemInfo.CaptureAreaRect.X, systemInfo.CaptureAreaRect.Y);
|
||||
|
||||
// SaveDebugImage(ra.SrcMat);
|
||||
|
||||
var rawResult = _predictor.Predictor.Detect(ra.CacheImage);
|
||||
|
||||
var centerX = ra.CacheImage.Width / 2.0;
|
||||
var centerY = ra.CacheImage.Height / 2.0;
|
||||
|
||||
var oreBoxes = rawResult
|
||||
.Where(box => box.Name.Name is "ore" && box.Confidence >= ConfidenceThreshold)
|
||||
.Select(box => new Rect(
|
||||
(int)box.Bounds.X,
|
||||
(int)box.Bounds.Y,
|
||||
(int)box.Bounds.Width,
|
||||
(int)box.Bounds.Height))
|
||||
.ToList();
|
||||
|
||||
// 画框
|
||||
var drawList = oreBoxes.Select(r => ra.ToRectDrawable(r, "ore")).ToList();
|
||||
VisionContext.Instance().DrawContent.PutOrRemoveRectList("BgiMine", drawList);
|
||||
|
||||
if (oreBoxes.Count == 0)
|
||||
{
|
||||
VisionContext.Instance().DrawContent.PutOrRemoveRectList("MiningCluster", null);
|
||||
return (null, centerX, centerY);
|
||||
}
|
||||
|
||||
var clusters = ClusterMinerals(oreBoxes);
|
||||
|
||||
// 画聚类中心标记框
|
||||
var refArea = BaseClusterArea * _widthScale * _widthScale;
|
||||
var clusterDrawList = new List<RectDrawable>();
|
||||
foreach (var cluster in clusters)
|
||||
{
|
||||
var avgArea = cluster.Rects.Average(r => (double)r.Width * r.Height);
|
||||
var markerSize = ArrivalThreshold * Math.Max(1.0, Math.Sqrt(avgArea / refArea));
|
||||
var half = (int)markerSize / 2;
|
||||
var mark = new Rect((int)cluster.TargetX - half, (int)cluster.TargetY - half, (int)markerSize, (int)markerSize);
|
||||
clusterDrawList.Add(ra.ToRectDrawable(mark,
|
||||
$"({(int)cluster.TargetX},{(int)cluster.TargetY})",
|
||||
new Pen(Color.DodgerBlue, 2)
|
||||
));
|
||||
}
|
||||
VisionContext.Instance().DrawContent.PutOrRemoveRectList("MiningCluster", clusterDrawList);
|
||||
|
||||
// 忽略屏幕边缘聚类,仅当中间区域存在聚类时生效
|
||||
var imgW = ra.CacheImage.Width;
|
||||
var imgH = ra.CacheImage.Height;
|
||||
var centerClusters = clusters
|
||||
.Where(c => c.CenterX >= EdgeIgnore && c.CenterX <= imgW - EdgeIgnore
|
||||
&& c.CenterY >= EdgeIgnore && c.CenterY <= imgH - EdgeIgnore)
|
||||
.ToList();
|
||||
var candidates = centerClusters.Count > 0 ? centerClusters : clusters;
|
||||
|
||||
var nearest = candidates
|
||||
.OrderBy(c => Math.Pow(c.CenterX - centerX, 2) + Math.Pow(c.CenterY - centerY, 2))
|
||||
.First();
|
||||
return (nearest, centerX, centerY);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 贪心聚类:距离小于阈值的检测框归入同一簇,阈值根据元素面积动态缩放
|
||||
/// </summary>
|
||||
private List<MineralCluster> ClusterMinerals(List<Rect> rects)
|
||||
{
|
||||
if (rects.Count == 0) return [];
|
||||
|
||||
var refArea = BaseClusterArea * _widthScale * _widthScale;
|
||||
var clusters = new List<MineralCluster>();
|
||||
|
||||
foreach (var rect in rects)
|
||||
{
|
||||
var cx = rect.X + rect.Width / 2.0;
|
||||
var cy = rect.Y + rect.Height / 2.0;
|
||||
|
||||
MineralCluster? nearest = null;
|
||||
double nearestDist = double.MaxValue;
|
||||
|
||||
foreach (var cluster in clusters)
|
||||
{
|
||||
var dist = Math.Sqrt(Math.Pow(cx - cluster.CenterX, 2) + Math.Pow(cy - cluster.CenterY, 2));
|
||||
if (dist < nearestDist)
|
||||
{
|
||||
nearestDist = dist;
|
||||
nearest = cluster;
|
||||
}
|
||||
}
|
||||
|
||||
if (nearest != null)
|
||||
{
|
||||
var clusterAvgArea = nearest.Rects.Average(r => (double)r.Width * r.Height);
|
||||
var rectArea = (double)rect.Width * rect.Height;
|
||||
var combinedAvg = (clusterAvgArea * nearest.Rects.Count + rectArea) / (nearest.Rects.Count + 1);
|
||||
var effectiveThreshold = ClusterDistanceThreshold * Math.Sqrt(combinedAvg / Math.Max(1, refArea));
|
||||
|
||||
if (nearestDist < effectiveThreshold && nearest.TryAddRect(rect))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
clusters.Add(new MineralCluster(rect, AreaRatioThreshold));
|
||||
}
|
||||
|
||||
return clusters;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 矿物聚堆,维护一组相近矿物的检测框及质心
|
||||
/// </summary>
|
||||
public class MineralCluster
|
||||
{
|
||||
public List<Rect> Rects { get; } = new();
|
||||
public double CenterX { get; private set; }
|
||||
public double CenterY { get; private set; }
|
||||
public double TargetX { get; private set; }
|
||||
public double TargetY { get; private set; }
|
||||
|
||||
public MineralCluster(Rect firstRect, double areaRatioThreshold = 5)
|
||||
{
|
||||
AreaRatioThreshold = areaRatioThreshold;
|
||||
Rects.Add(firstRect);
|
||||
RecalculateCenter();
|
||||
}
|
||||
|
||||
private readonly double AreaRatioThreshold;
|
||||
|
||||
public bool TryAddRect(Rect rect)
|
||||
{
|
||||
var avgArea = Rects.Average(r => (double)r.Width * r.Height);
|
||||
var newArea = (double)rect.Width * rect.Height;
|
||||
if (newArea > avgArea * AreaRatioThreshold || newArea < avgArea / AreaRatioThreshold) return false;
|
||||
Rects.Add(rect);
|
||||
RecalculateCenter();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void RecalculateCenter()
|
||||
{
|
||||
CenterX = Rects.Average(r => r.X + r.Width / 2.0);
|
||||
CenterY = Rects.Average(r => r.Y + r.Height / 2.0);
|
||||
|
||||
// 按距离质心排序,取最近2个中靠左的
|
||||
var candidates = Rects
|
||||
.Select(r => (cx: r.X + r.Width / 2.0, cy: r.Y + r.Height / 2.0,
|
||||
dist: Math.Pow(r.X + r.Width / 2.0 - CenterX, 2) + Math.Pow(r.Y + r.Height / 2.0 - CenterY, 2)))
|
||||
.OrderBy(t => t.dist)
|
||||
.Take(2)
|
||||
.OrderBy(t => t.cx)
|
||||
.First();
|
||||
|
||||
TargetX = candidates.cx;
|
||||
TargetY = candidates.cy;
|
||||
}
|
||||
}
|
||||
@@ -19,4 +19,7 @@ public enum DisplayMapTypes
|
||||
|
||||
[Description("远古圣山")]
|
||||
AncientSacredMountain,
|
||||
|
||||
[Description("空之神殿")]
|
||||
TempleOfSpace,
|
||||
}
|
||||
@@ -18,7 +18,10 @@ public enum MapTypes
|
||||
SeaOfBygoneEras,
|
||||
|
||||
[Description("远古圣山")]
|
||||
AncientSacredMountain
|
||||
AncientSacredMountain,
|
||||
|
||||
[Description("空之神殿")]
|
||||
TempleOfSpace,
|
||||
}
|
||||
public static class MapTypesExtensions
|
||||
{
|
||||
|
||||
@@ -58,6 +58,7 @@ public static class MapManager
|
||||
MapTypes.Enkanomiya => new EnkanomiyaMap(),
|
||||
MapTypes.AncientSacredMountain => new AncientSacredMountainMap(),
|
||||
MapTypes.SeaOfBygoneEras => new SeaOfBygoneErasMap(),
|
||||
MapTypes.TempleOfSpace => new TempleOfSpaceMap(),
|
||||
_ => throw new System.ArgumentException($"未知的地图类型: {mapType}", nameof(mapType))
|
||||
};
|
||||
}
|
||||
@@ -70,6 +71,7 @@ public static class MapManager
|
||||
MapTypes.Enkanomiya => new EnkanomiyaMapTest(),
|
||||
MapTypes.AncientSacredMountain => new AncientSacredMountainMap(),
|
||||
MapTypes.SeaOfBygoneEras => new SeaOfBygoneErasMap(),
|
||||
MapTypes.TempleOfSpace => new TempleOfSpaceMap(),
|
||||
_ => throw new System.ArgumentException($"未知的地图类型: {mapType}", nameof(mapType))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.Common.Map.Maps.Base;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.Map.Maps;
|
||||
|
||||
/// <summary>
|
||||
/// 空之神殿
|
||||
/// </summary>
|
||||
public class TempleOfSpaceMap : SceneBaseMap
|
||||
{
|
||||
#region 每次地图扩大都要更新的参数
|
||||
|
||||
static readonly int GameMapRows = 4; // 游戏坐标下地图块的行数
|
||||
static readonly int GameMapCols = 3; // 游戏坐标下地图块的列数
|
||||
static readonly int GameMapUpRows = 1; // 游戏坐标下 左上角离地图原点的行数(注意原点在0_0块的右下角)
|
||||
static readonly int GameMapLeftCols = 1; // 游戏坐标下 左上角离地图原点的列数(注意原点在0_0块的右下角)
|
||||
|
||||
#endregion 每次地图扩大都要更新的参数
|
||||
|
||||
static readonly int TempleOfSpaceMapImageBlockWidth = 1024;
|
||||
|
||||
public TempleOfSpaceMap() : base(type: MapTypes.TempleOfSpace,
|
||||
mapSize: new Size(GameMapCols * TempleOfSpaceMapImageBlockWidth, GameMapRows * TempleOfSpaceMapImageBlockWidth),
|
||||
mapOriginInImageCoordinate: new Point2f((GameMapLeftCols + 1) * TempleOfSpaceMapImageBlockWidth, (GameMapUpRows + 1) * TempleOfSpaceMapImageBlockWidth),
|
||||
mapImageBlockWidth: TempleOfSpaceMapImageBlockWidth,
|
||||
splitRow: 0,
|
||||
splitCol: 0)
|
||||
{
|
||||
ExtractAndSaveFeature(Global.Absolute("Assets/Map/TempleOfSpace/TempleOfSpace_0_1024.png"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask;
|
||||
|
||||
public static class GenshinHdrRegistryHelper
|
||||
{
|
||||
public const string HdrRegistryEntryName = "WINDOWS_HDR_ON_h3132281285";
|
||||
public const string CnHdrRegistrySubKeyPath = @"Software\miHoYo\原神\WINDOWS_HDR_ON_h3132281285";
|
||||
public const string GlobalHdrRegistrySubKeyPath = @"Software\miHoYo\Genshin Impact\WINDOWS_HDR_ON_h3132281285";
|
||||
public const string CnHdrRegistryParentKeyPath = @"Software\miHoYo\原神";
|
||||
public const string GlobalHdrRegistryParentKeyPath = @"Software\miHoYo\Genshin Impact";
|
||||
|
||||
public static readonly IReadOnlyList<string> HdrRegistrySubKeyPaths =
|
||||
[
|
||||
CnHdrRegistrySubKeyPath,
|
||||
GlobalHdrRegistrySubKeyPath
|
||||
];
|
||||
|
||||
public static readonly IReadOnlyList<string> HdrRegistryParentKeyPaths =
|
||||
[
|
||||
CnHdrRegistryParentKeyPath,
|
||||
GlobalHdrRegistryParentKeyPath
|
||||
];
|
||||
|
||||
public static IReadOnlyList<string> HdrRegistryFullKeyPaths =>
|
||||
HdrRegistrySubKeyPaths.Select(static path => $@"HKEY_CURRENT_USER\{path}").ToArray();
|
||||
|
||||
public static bool TryDisableHdr(out IReadOnlyList<string> deletedFullKeyPaths)
|
||||
{
|
||||
var deletedPaths = new List<string>();
|
||||
foreach (var parentKeyPath in HdrRegistryParentKeyPaths)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var key = Registry.CurrentUser.OpenSubKey(parentKeyPath, writable: true);
|
||||
if (key == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.GetValue(HdrRegistryEntryName) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
key.DeleteValue(HdrRegistryEntryName, throwOnMissingValue: false);
|
||||
deletedPaths.Add($@"HKEY_CURRENT_USER\{parentKeyPath}\{HdrRegistryEntryName}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 忽略删除失败,避免影响启动流程
|
||||
}
|
||||
}
|
||||
|
||||
deletedFullKeyPaths = deletedPaths.Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
return deletedFullKeyPaths.Count > 0;
|
||||
}
|
||||
}
|
||||
@@ -63,15 +63,15 @@ public class GameCaptureRegion(Mat mat, int initX, int initY, Region? owner = nu
|
||||
/// <returns></returns>
|
||||
public ImageRegion DeriveTo1080P()
|
||||
{
|
||||
if (Width <= 1920)
|
||||
if (Width <= 1920 || Height <= 1080)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
var scale = Width / 1920d;
|
||||
var scale = SystemInfo.MinZoomOut1080PRatio(Width, Height);
|
||||
|
||||
var newMat = new Mat();
|
||||
Cv2.Resize(SrcMat, newMat, new Size(1920, Height / scale));
|
||||
Cv2.Resize(SrcMat, newMat, new Size(Width / scale, Height / scale));
|
||||
Dispose();
|
||||
return new ImageRegion(newMat, 0, 0, this, new ScaleConverter(scale));
|
||||
// return new ImageRegion(newMat, 0, 0, this, new TranslationConverter(0, 0));
|
||||
|
||||
@@ -81,12 +81,12 @@ namespace BetterGenshinImpact.GameTask.Model
|
||||
}
|
||||
|
||||
// 0.28 改动,素材缩放比例不可以超过 1,也就是图像识别时分辨率大于 1920x1080 的情况下直接进行缩放
|
||||
if (GameScreenSize.Width < 1920)
|
||||
if (GameScreenSize.Width < 1920 || GameScreenSize.Height < 1080)
|
||||
{
|
||||
ZoomOutMax1080PRatio = GameScreenSize.Width / 1920d;
|
||||
ZoomOutMax1080PRatio = MinZoomOut1080PRatio(GameScreenSize.Width, GameScreenSize.Height);
|
||||
AssetScale = ZoomOutMax1080PRatio;
|
||||
}
|
||||
ScaleTo1080PRatio = GameScreenSize.Width / 1920d; // 1080P 为标准
|
||||
ScaleTo1080PRatio = MinZoomOut1080PRatio(GameScreenSize.Width, GameScreenSize.Height); // 1080P 为标准
|
||||
|
||||
CaptureAreaRect = SystemControl.GetCaptureRect(hWnd);
|
||||
if (CaptureAreaRect.Width > 1920)
|
||||
@@ -99,5 +99,10 @@ namespace BetterGenshinImpact.GameTask.Model
|
||||
ScaleMax1080PCaptureRect = new Rect(CaptureAreaRect.X, CaptureAreaRect.Y, CaptureAreaRect.Width, CaptureAreaRect.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public static double MinZoomOut1080PRatio(double width, double height)
|
||||
{
|
||||
return Math.Min(width / 1920d, height / 1080d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
@@ -41,14 +42,20 @@ public class TaskRunner
|
||||
/// 加锁并独立运行任务
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="resetCancellationContext">任务开始时是否重建 CancellationContext。</param>
|
||||
/// <param name="clearCancellationContextOnLockFailure">获取信号量锁失败时是否清理 CancellationContext。</param>
|
||||
/// <returns></returns>
|
||||
public async Task RunCurrentAsync(Func<Task> action)
|
||||
public async Task RunCurrentAsync(Func<Task> action, bool resetCancellationContext = true, bool clearCancellationContextOnLockFailure = false)
|
||||
{
|
||||
// 加锁
|
||||
var hasLock = await TaskSemaphore.WaitAsync(0);
|
||||
if (!hasLock)
|
||||
{
|
||||
_logger.LogError("任务启动失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
if (clearCancellationContextOnLockFailure)
|
||||
{
|
||||
CancellationContext.Instance.Clear();
|
||||
}
|
||||
return;
|
||||
}
|
||||
try
|
||||
@@ -57,8 +64,10 @@ public class TaskRunner
|
||||
|
||||
// 初始化
|
||||
Init();
|
||||
|
||||
CancellationContext.Instance.Set();
|
||||
if (resetCancellationContext)
|
||||
{
|
||||
CancellationContext.Instance.Set();
|
||||
}
|
||||
RunnerContext.Instance.Clear();
|
||||
|
||||
await action();
|
||||
@@ -117,10 +126,24 @@ public class TaskRunner
|
||||
|
||||
public async Task RunSoloTaskAsync(ISoloTask soloTask)
|
||||
{
|
||||
// 启动等待之前先进行取消操作的初始化,便于在任务开始前终止任务.
|
||||
CancellationContext.Instance.Set();
|
||||
|
||||
// 没启动的时候先启动
|
||||
bool waitForMainUi = soloTask.Name != "自动七圣召唤" && !soloTask.Name.Contains("自动音游") && !soloTask.Name.Contains("幽境危战");
|
||||
bool waitForMainUi = soloTask.Name != "自动七圣召唤" && !soloTask.Name.Contains("自动音游") &&
|
||||
!soloTask.Name.Contains("幽境危战");
|
||||
await ScriptService.StartGameTask(waitForMainUi);
|
||||
await Task.Run(() => RunCurrentAsync(async () => await soloTask.Start(CancellationContext.Instance.Cts.Token)));
|
||||
if (CancellationContext.Instance.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogInformation("独立任务在启动阶段被取消: {Name}", soloTask.Name);
|
||||
CancellationContext.Instance.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Run(() => RunCurrentAsync(
|
||||
async () => await soloTask.Start(CancellationContext.Instance.Cts.Token),
|
||||
resetCancellationContext: false,
|
||||
clearCancellationContextOnLockFailure: true));
|
||||
}
|
||||
|
||||
public void Init()
|
||||
@@ -159,7 +182,9 @@ public class TaskRunner
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Simulation.ReleaseAllKey();
|
||||
|
||||
// 还原实时任务触发器
|
||||
TaskTriggerDispatcher.Instance().ClearTriggers();
|
||||
TaskTriggerDispatcher.Instance().SetTriggers(GameTaskManager.LoadInitialTriggers());
|
||||
|
||||
@@ -173,6 +173,7 @@ namespace BetterGenshinImpact.GameTask
|
||||
_gameRect = RECT.Empty;
|
||||
_prevGameActive = false;
|
||||
PictureInPictureService.Hide(resetManual: true);
|
||||
HtmlMaskWindow.CloseAll();
|
||||
if (_winEventHookMoveSize != default)
|
||||
{
|
||||
User32.UnhookWinEvent(_winEventHookMoveSize);
|
||||
@@ -238,6 +239,7 @@ namespace BetterGenshinImpact.GameTask
|
||||
PictureInPictureService.Hide(resetManual: true);
|
||||
UiTaskStopTickEvent?.Invoke(sender, e);
|
||||
maskWindow.Invoke(maskWindow.HideSelf);
|
||||
HtmlMaskWindow.HideAll();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -278,6 +280,7 @@ namespace BetterGenshinImpact.GameTask
|
||||
{
|
||||
// Debug.WriteLine(pName + ":hide mask window");
|
||||
maskWindow.Invoke(() => { maskWindow.HideSelf(); });
|
||||
HtmlMaskWindow.HideAll();
|
||||
}
|
||||
|
||||
_prevGameActive = active;
|
||||
@@ -315,7 +318,7 @@ namespace BetterGenshinImpact.GameTask
|
||||
PictureInPictureService.Hide(resetManual: true);
|
||||
// if (!_prevGameActive)
|
||||
// {
|
||||
maskWindow.Invoke(() =>
|
||||
maskWindow.BeginInvoke(() =>
|
||||
{
|
||||
if (maskWindow.IsExist())
|
||||
{
|
||||
@@ -326,6 +329,7 @@ namespace BetterGenshinImpact.GameTask
|
||||
}
|
||||
}
|
||||
});
|
||||
HtmlMaskWindow.ShowAll();
|
||||
// }
|
||||
|
||||
_prevGameActive = active;
|
||||
@@ -462,6 +466,7 @@ namespace BetterGenshinImpact.GameTask
|
||||
_gameRect = new RECT(currentRect);
|
||||
TaskContext.Instance().SystemInfo.CaptureAreaRect = currentRect;
|
||||
MaskWindow.Instance().RefreshPosition();
|
||||
HtmlMaskWindow.UpdateAllPositions();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,9 @@ public partial class ScriptService : IScriptService
|
||||
{
|
||||
groupName ??= "默认";
|
||||
|
||||
// 启动等待之前先进行取消操作的初始化,便于在任务开始前终止任务.
|
||||
CancellationContext.Instance.Set();
|
||||
|
||||
var list = ReloadScriptProjects(projectList);
|
||||
|
||||
//恢复临时的跳过标志
|
||||
@@ -140,6 +143,11 @@ public partial class ScriptService : IScriptService
|
||||
|
||||
// 没启动时候,启动截图器
|
||||
await StartGameTask();
|
||||
if (CancellationContext.Instance.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogInformation("配置组 {Name} 在启动阶段被取消", groupName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(groupName)&&!RunnerContext.Instance.IsPreExecution)
|
||||
@@ -577,6 +585,12 @@ public partial class ScriptService : IScriptService
|
||||
var loseFocusCount = 0;
|
||||
while (true)
|
||||
{
|
||||
if (CancellationContext.Instance.IsCancellationRequested)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("检测到停止指令,退出启动等待");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!homePageViewModel.TaskDispatcherEnabled || !TaskContext.Instance().IsInitialized)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
// 作者:火山
|
||||
// 描述:万能战斗策略(新手推荐)。内含详细使用说明,请务必打开本文档!!!(内含少部分满命、进阶操作,默认已注释不开启)
|
||||
// 版本:v2.0
|
||||
// 描述:(锄地+副本)请务必打开本文档仔细阅读说明设置!!!【此版本增加Check、ready两种新战斗策略语法的应用,实现自主动精准控制战斗结束检查时间点,有bug或者异常卡顿请及时向管理反馈】(内含少部分满命、进阶操作,默认已注释不开启。本策略作为示范教学,希望大家学习理解bgi战斗逻辑,如有更好的策略,欢迎提交)
|
||||
// 版本:v3.2
|
||||
|
||||
// 战斗配置设置流程
|
||||
// 该设置从调度器入口开始,按以下层级路径操作,核心为开启相关功能并配置关键参数。
|
||||
// 1. 进入战斗配置页面
|
||||
// 路径:调度器 → 配置组 → 设置 → 战斗配置操作:将 “战斗配置” 功能开启
|
||||
// 路径:调度器 → 配置组 → 设置 → 战斗配置操作:将 “战斗配置” 功能开启!(必须开启战斗配置,底下的设置才能生效,每个配置组设置独立的)
|
||||
|
||||
// 2. 战斗结束检测相关设置
|
||||
// 所有子项均需开启,用于快速识别战斗状态,提升效率。
|
||||
// 2. 战斗结束检测相关设置(——————没有的选项为茶包版本设置———————)
|
||||
// 自动检测战斗结束:开启
|
||||
// 更快检查结束战斗:开启,参数设置为 1
|
||||
// 更快检查结束战斗:关闭(一定要关闭!!)
|
||||
// 检查战斗结束的延时:设置为 0.4
|
||||
// 按键触发后检查延时:设置为 0.4
|
||||
// 按键触发后检查延时(快速模式建议配合“不等待旋转结束”使用): 开启(默认值0.15)
|
||||
|
||||
// 3. 敌人定位与面向设置
|
||||
// 3. 敌人定位与面向设置(——————没有的选项为茶包版本设置———————)
|
||||
// 用于自动调整角色朝向,优化战斗操作。
|
||||
// 旋转寻找敌人位置:开启
|
||||
// Q 前检测:开启
|
||||
// 尝试面向敌人:可选开启(根据需求选择)
|
||||
// 旋转寻找敌人位置:关闭(可以把旋转速度条拉到最左);也可选择开启(旋转速度条先拉到最右,再往左一格,过快会导致卡检测和乱转)
|
||||
// Q 前检测:关闭
|
||||
// 尝试面向敌人:关闭(可以选择开启,如果开旋转寻找敌人位置)
|
||||
// 单次接近敌人行走时间(毫秒):500 (设置0则不接近敌人)
|
||||
// 不等待旋转结束:开启
|
||||
|
||||
// 4. 技能释放与角色优先级设置
|
||||
// 核心为盾奶角色技能优先释放,需准确配置角色位置。
|
||||
// 盾奶角色优先释放技能:开启
|
||||
// 关键设置:在队伍栏中,选择盾角色对应的序号(务必准确,不可选错)。
|
||||
// 盾奶角色优先释放技能:开启(非常重要!!!)
|
||||
// 关键设置:在队伍栏中,选择盾角色对应的序号(务必准确,不可选错!!!)。
|
||||
|
||||
// 5. 掉落物拾取设置
|
||||
// 需根据队伍角色情况选择开启,核心注意万叶 / 琴的特殊设置。
|
||||
@@ -34,84 +36,140 @@
|
||||
// 以下是战斗策略正文,注意合理搭配队伍
|
||||
// !!!请严格遵守BGI战斗配队逻辑!!!(以 盾【刚需】+主c【可以是后台输出角色】+副c【可以是后台输出角色】+万叶/琴【如需要捡掉落物的可以带,比如精英怪,小怪、副本可酌情不带换成,奶妈 or 后台输出角色】)
|
||||
|
||||
// 盾(刚需)
|
||||
茜特菈莉 e,attack(0.2),keypress(q),wait(0.2),keypress(q),attack(0.2),keypress(q),attack(0.2),keypress(e)
|
||||
伊涅芙 e,attack(0.22),keypress(q),wait(0.1),keypress(q),attack(0.2),keypress(q),attack(0.2)
|
||||
钟离 s(0.2), e(hold), wait(0.2), w(0.2),keypress(q),wait(0.2),keypress(q),attack(0.1)
|
||||
莱依拉 e,wait(0.2), keypress(q),wait(0.2),keypress(q),attack(0.2),keypress(q),attack(0.2)
|
||||
绮良良 e,attack(0.2), keypress(q),attack(0.2),keypress(q),wait(0.2),keypress(q),attack(0.2)
|
||||
托马 e,attack(0.22),keypress(q),wait(0.1),keypress(q),attack(0.2),keypress(q),attack(0.2)
|
||||
蓝砚 e,wait(0.8),s(0.2),attack(0.33),dash(0.1),attack(0.55),keypress(q),attack(0.1)
|
||||
// 前置防止未拉到怪物仇恨脱战 or 超前爆发【适合自定义需要提前释放技能的角色】(不需要可以注释掉)
|
||||
茜特菈莉 e
|
||||
|
||||
伊涅芙 e
|
||||
|
||||
钟离 s(0.2), e(hold), wait(0.2), w(0.2)
|
||||
|
||||
莱依拉 e
|
||||
|
||||
绮良良 e
|
||||
|
||||
托马 e
|
||||
|
||||
芙宁娜 attack(0.1), keydown(E), wait(0.3), keyup(E)
|
||||
|
||||
玛薇卡 e
|
||||
|
||||
哥伦比娅 attack(0.1), check, keydown(e), wait(0.3), keyup(e), wait(0.1), check, wait(0.3)
|
||||
|
||||
莉奈娅 attack(0.1), keypress(q), wait(0.1), ready, check, attack(0.4), keydown(E), wait(0.05), attack(0.82), keyup(E), wait(1), check
|
||||
|
||||
// 盾(刚需)————强调一下,只需要带一个盾位就够了,盾量不够穿千岩
|
||||
茜特菈莉 e, attack(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), ready, check, wait(0.3), attack(0.3), check, wait(0.3)
|
||||
|
||||
伊涅芙 e, attack(0.1), check, attack(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
钟离 s(0.2), e(hold), wait(0.2), w(0.2), check, wait(0.3), keypress(q), wait(0.1),keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
莱依拉 e, wait(0.3), check, keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), check, wait(0.3)
|
||||
|
||||
绮良良 e, wait(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), check, wait(0.3)
|
||||
|
||||
托马 e, wait(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), check, wait(0.3)
|
||||
|
||||
蓝砚 e, wait(0.8), s(0.2), attack(0.33), dash(0.1), attack(0.55), check, wait(0.3), keypress(q), wait(0.1), check, wait(0.3)
|
||||
|
||||
// 后台、挂元素、副C、先手
|
||||
玛薇卡 attack(0.2),e,wait(0.2),keypress(q),attack(0.15)
|
||||
杜林 attack(0.1), keypress(q), attack(0.2), click(middle), e, wait(0.2), e, keypress(q), wait(0.2), keypress(q), attack(0.2), keypress(q), attack(0.2)
|
||||
迪希雅 e,attack(0.2),e
|
||||
香菱 e,wait(0.3),keypress(q),attack(0.2),keypress(q),wait(0.2),keypress(q),attack(0.2)
|
||||
仆人 attack,e
|
||||
玛薇卡 e, wait(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
迪希雅 e, attack(0.3), e, wait(0.3), check, wait(0.3)
|
||||
香菱 e, wait(0.3),check, keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), check, wait(0.3)
|
||||
仆人 attack(0.3), check, wait(0.3), e, wait(0.3), check, wait(0.3)
|
||||
|
||||
// 夜兰顺时针
|
||||
夜兰 attack(0.5),keydown(VK_W),wait(0.05),keydown(VK_E),wait(0.4),keyup(VK_E),wait(0.1),keydown(VK_D),keyup(VK_W),wait(0.4),keydown(VK_S),keyup(VK_D),wait(0.4),keydown(VK_A),keyup(VK_S),wait(0.4),keydown(VK_W),keyup(VK_A),wait(0.3),keydown(VK_S),keyup(VK_W),wait(0.15),keyup(VK_S),keypress(e), attack(0.2), keypress(Q), attack(0.2), keypress(Q), attack(0.2)
|
||||
哥伦比娅 e,keypress(q),attack(0.2),keypress(q),attack
|
||||
那维莱特 attack(0.05),click(middle),e,wait(0.15),keydown(VK_LBUTTON),wait(0.27),keyup(VK_LBUTTON),wait(0.15),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),keydown(VK_LBUTTON),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),click(middle),j,click(middle),wait(0.05),keyup(VK_LBUTTON)
|
||||
纳西妲 e(hold),click(middle),keypress(q),wait(0.3),keypress(q),attack(0.3),keypress(q),attack(0.2)
|
||||
艾梅莉埃 e,attack(0.2), keypress(q),attack(0.2),keypress(q),wait(0.2),keypress(q),attack(0.2)
|
||||
丝柯克 attack(0.2),click(middle),keypress(q),wait(0.05),keypress(q),attack(0.05),click(middle),keydown(E),wait(0.22),attack(0.08),click(middle),keyup(E),keypress(q),wait(0.08),keypress(q)
|
||||
芙宁娜 e,attack(0.85), keypress(e), keypress(Q), attack(0.2), keydown(S), keypress(e), attack(0.2), keyup(S), keypress(Q), attack(0.2)
|
||||
爱诺 e, wait(0.3), keypress(q), attack(0.22), keypress(q), attack(0.21)
|
||||
夏洛蒂 e, click(middle), attack(0.3), keypress(q), attack(0.22), click(middle), dash(0.1),wait(0.3),keypress(q), attack(0.21)
|
||||
菈乌玛 attack(0.1),keypress(q),attack(0.15),keydown(E),wait(0.4),attack(0.3),keyup(E),attack(0.15),keypress(q),attack(0.15),keydown(E),wait(0.4),attack(0.3),keyup(E),attack(0.2),wait(0.1)
|
||||
夜兰 attack(0.2), check, wait(0.3),keydown(VK_W), wait(0.05), keydown(VK_E), wait(0.4), keyup(VK_E), wait(0.1), keydown(VK_D), keyup(VK_W), wait(0.4), keydown(VK_S), keyup(VK_D), wait(0.4), keydown(VK_A), keyup(VK_S), wait(0.4), keydown(VK_W), keyup(VK_A), wait(0.3), keydown(VK_S), keyup(VK_W), wait(0.15), keyup(VK_S), keypress(e), attack(0.2), check, wait(0.3), keypress(Q), wait(0.1), keypress(Q), wait(0.1), keypress(Q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
// (有奈芙尔就去掉角色名之前的内容,→(//+一个空格 =// ) ←按照我注释的格式给上一行的菈乌玛长e策略注释掉,后面是短e策略,不消耗草露),菈乌玛 e,attack(0.2), keypress(q),attack(0.2),keypress(q),wait(0.2),keypress(q),attack(0.2)
|
||||
哥伦比娅 e, attack(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, attack, e, attack(0.3), check, wait(0.3)
|
||||
|
||||
白术 e,attack(0.2)
|
||||
珊瑚宫心海 e
|
||||
芭芭拉 e,attack(0.2)
|
||||
希格雯 e(hold),wait(0.2),attack(0.21),keypress(q),wait(0.2),keypress(q)
|
||||
爱可菲 e,attack(0.2), keypress(q),attack(0.2),keypress(q),wait(0.2),keypress(q),attack(0.2)
|
||||
菲谢尔 e
|
||||
欧洛伦 e,attack(0.3), keypress(q),wait(0.2),attack(0.3),keypress(q),wait(0.2),attack(0.3),keypress(q),wait(0.3)
|
||||
雷电将军 e,attack(0.22),keypress(q),wait(0.1),keypress(q),attack(0.2),keypress(q),attack(0.2)
|
||||
久岐忍 e,wait(0.2),keypress(q),attack(0.15),keypress(q),e
|
||||
欧洛伦 e,attack(0.3), keypress(q),wait(0.2),attack(0.3),keypress(q),wait(0.2),dash(0.1),attack(0.3),keypress(q),wait(0.3)
|
||||
瓦雷莎 e, attack(1.25),wait(0.45), s(0.4), click(middle), e, attack(1.25), wait(0.3),keypress(q), wait(0.45)
|
||||
那维莱特 attack(0.05), click(middle), check, wait(0.3), e, wait(0.05), keydown(VK_LBUTTON), wait(0.27), keyup(VK_LBUTTON), wait(0.15), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), keydown(VK_LBUTTON), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), click(middle), j, click(middle), wait(0.05), keyup(VK_LBUTTON), wait(0.15), check, wait(0.3)
|
||||
|
||||
纳西妲 click(middle),keydown(e),wait(0.25),moveby(2100,0),wait(0.05),moveby(2100,0),wait(0.05),moveby(2100,-1100),wait(0.05),moveby(1300,-1800),wait(0.05),moveby(1300,-1800),keyup(e),wait(0.12),click(middle), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
艾梅莉埃 e, wait(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
丝柯克 attack(0.2), check, wait(0.3), click(middle), keypress(q), wait(0.05), keypress(q), attack(0.05), click(middle), keydown(E), wait(0.22), attack(0.08), click(middle), keyup(E), keypress(q), wait(0.08), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
芙宁娜 e, attack(0.85), keypress(e), wait(0.1), check, keypress(Q), wait(0.1), ready, check, attack(0.2), keydown(S), keypress(e), attack(0.3), keyup(S), check, keypress(Q), wait(0.1), ready, attack(0.2), check, wait(0.3)
|
||||
|
||||
爱诺 e, wait(0.3),check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), attack, check, wait(0.3)
|
||||
|
||||
夏洛蒂 e, click(middle), attack(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1),keypress(q), attack(0.22), click(middle), dash(0.1), wait(0.3), keypress(q), wait(0.1), check, wait(0.3)
|
||||
|
||||
叶洛亚 e, attack(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), check, wait(0.3)
|
||||
|
||||
莉奈娅 attack(0.05), keydown(E),wait(0.05),attack(0.82),keyup(E), wait(1), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
菈乌玛 attack(0.1), check, wait(0.3), keypress(q), wait(0.1), ready, check, keydown(E), wait(0.4), attack(0.3), keyup(E), wait(0.1), check, keypress(q), wait(0.1), ready, check, keypress(q), wait(0.1), ready, check, keydown(E), wait(0.4), attack(0.3), keyup(E), attack(0.2), check, wait(0.3)
|
||||
|
||||
// (有奈芙尔就去掉角色名之前的内容,→(//+一个空格 =// ) ←按照我注释的格式给上一行的菈乌玛长e策略注释掉,后面是短e策略,不消耗草露),菈乌玛 e, attack(0.2), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
白术 e, wait(0.3),check, wait(0.3)
|
||||
珊瑚宫心海 e, wait(0.3),check, wait(0.3)
|
||||
芭芭拉 e, wait(0.3),check, wait(0.3)
|
||||
希格雯 e(hold), wait(0.2), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
爱可菲 e, attack(0.2), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
菲谢尔 e, wait(0.3), check, wait(0.3)
|
||||
欧洛伦 e, attack(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), check, wait(0.3)
|
||||
雷电将军 e, attack(0.22), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check
|
||||
久岐忍 e, wait(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), e, check
|
||||
瓦雷莎 e, attack(1.25), wait(0.45), check, s(0.4), click(middle), e, attack(1.25), wait(0.3), keypress(q), wait(0.45), check
|
||||
|
||||
|
||||
// 中置位
|
||||
夏沃蕾 attack(0.08),keypress(q),wait(0.2),keypress(q),wait(0.2),attack(0.21),keydown(e),wait(0.15), moveby(0,1300),wait(0.18),keyup(e),attack(0.15)
|
||||
白术 attack(0.2), keypress(q),attack(0.2),keypress(q),wait(0.2),keypress(q),attack(0.2)
|
||||
// 奈芙尔 attack(0.08), keydown(VK_LBUTTON), keydown(E), wait(0.015), keyup(E), wait(0.015), wait(0.95), wait(0.015), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.015), wait(0.015), wait(0.5), keyup(VK_LBUTTON),keypress(q),attack(0.2)
|
||||
雅珂达 attack(0.2),click(middle),attack(0.2), keydown(E), keydown(W), wait(0.4), keyup(W), keydown(S), wait(0.25), keydown(W), wait(0.25), keyup(W), keydown(S), wait(0.25), keyup(S), keydown(W), wait(0.25), keyup(W), keydown(S), wait(0.25), keyup(S), keydown(W), wait(0.25), keyup(W), keydown(S), wait(0.25), keyup(S), keydown(W), wait(0.25), keyup(W), keydown(S), wait(0.25), keyup(S), keydown(W), wait(0.25), keyup(W), keydown(S), wait(0.25), keyup(S), keyup(E), attack(0.2), keypress(q),attack(0.2), keypress(q),attack(0.3)
|
||||
夏沃蕾 attack(0.1), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), attack(0.21), keydown(e), wait(0.15), moveby(0, 1300), wait(0.18), keyup(e), attack(0.15), check, wait(0.3)
|
||||
白术 attack(0.2),check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
// 奈芙尔 attack(0.08), keydown(VK_LBUTTON), keydown(E), wait(0.015), keyup(E), wait(0.015), wait(0.95), wait(0.015), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.015), wait(0.015), wait(0.5), keyup(VK_LBUTTON), keypress(q), attack(0.2), check, wait(0.3)
|
||||
雅珂达 attack(0.2), click(middle), attack(0.2), check, keydown(E), w(0.1), a(0.1), s(0.1), d(0.1), w(0.1), a(0.1), s(0.1), d(0.1), w(0.1), a(0.1), s(0.1), d(0.1), w(0.1), a(0.1), s(0.1), d(0.1), w(0.1), a(0.1), s(0.1), d(0.1), w(0.1), a(0.1), attack(0.2), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
|
||||
|
||||
// 减抗
|
||||
希诺宁 s(0.2),e,w(0.2),attack(0.35),wait(0.1),attack(0.35),keypress(x), wait(0.2), keypress(q), wait(0.3), keypress(q),keypress(x), wait(0.08), keypress(x),attack(0.2)
|
||||
枫原万叶 attack(0.08),keypress(q),wait(0.3),keypress(q),wait(0.3),attack(0.2),keydown(E),wait(0.48),keyup(E),attack(0.3), wait(0.5),attack(0.1)
|
||||
砂糖 e,attack(0.2),keypress(q),attack(0.2),keypress(q),e,attack(0.2)
|
||||
琴 attack(0.21),keydown(e),wait(0.14), moveby(0,1300),wait(0.75),keyup(e),attack(0.12),keypress(q),attack(0.11),keypress(q),attack
|
||||
希诺宁 s(0.2), e, w(0.18), attack(0.7), keypress(x), wait(0.2), check, keypress(q), wait(0.1), keypress(q), wait(0.1), ready, attack, e, wait(0.3), check, wait(0.3)
|
||||
枫原万叶 attack(0.08), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, keydown(E), wait(0.48), keyup(E), attack(0.3), wait(0.5), attack
|
||||
砂糖 e, attack(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), check, wait(0.3), e, attack(0.2)
|
||||
琴 attack(0.21), check, wait(0.3), keydown(e), wait(0.14), moveby(0, 1300), wait(0.75), keyup(e), attack(0.12), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
// 夜兰逆时针
|
||||
夜兰 attack(0.5),keydown(VK_W),wait(0.05),keydown(VK_E),wait(0.4),keyup(VK_E),wait(0.1),keydown(VK_A),keyup(VK_W),wait(0.4),keydown(VK_S),keyup(VK_A),wait(0.4),keydown(VK_D),keyup(VK_S),wait(0.4),keydown(VK_W),keyup(VK_D),wait(0.3),keydown(VK_S),keyup(VK_W),wait(0.15),keyup(VK_S),keypress(e), attack(0.2), keypress(Q), attack(0.2), keypress(Q), attack(0.2)
|
||||
夜兰 attack(0.5), keydown(VK_W), wait(0.05), keydown(VK_E), wait(0.4), keyup(VK_E), wait(0.1), keydown(VK_A), keyup(VK_W), wait(0.4), keydown(VK_S), keyup(VK_A), wait(0.4), keydown(VK_D), keyup(VK_S), wait(0.4), keydown(VK_W), keyup(VK_D), wait(0.3), keydown(VK_S), keyup(VK_W), wait(0.15), keyup(VK_S), keypress(e), attack(0.2), check, wait(0.3), keypress(Q), wait(0.1), keypress(Q), wait(0.1), keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
|
||||
// 爆发
|
||||
玛薇卡 attack(0.08),keydown(E),wait(0.4),attack(0.2),wait(0.01),keyup(E),click(middle),attack(0.08),keypress(Q), wait(0.2), keypress(Q),charge(3.8), keydown(space), wait(0.1), keyup(space), attack(0.2),wait(0.2)
|
||||
玛薇卡 attack(0.08), check, wait(0.3), keydown(E), wait(0.4), attack(0.2), wait(0.01), keyup(E), click(middle), attack(0.08), check, wait(0.3), keypress(Q), wait(0.1), keypress(Q), wait(0.1), ready, check, wait(0.3), charge(3.8), keydown(space), wait(0.1), keyup(space), attack(0.2), wait(0.2), check, wait(0.3)
|
||||
|
||||
|
||||
// 收尾,长轴
|
||||
那维莱特 attack(0.05),keypress(q),wait(0.05),keypress(q),click(middle),e,wait(0.15),keydown(VK_LBUTTON),wait(0.27),keyup(VK_LBUTTON),wait(0.15),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),keydown(VK_LBUTTON),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),click(middle),j,click(middle),keyup(VK_LBUTTON),wait(0.5),attack(0.2), click(middle),wait(0.2),keydown(VK_LBUTTON),wait(0.35),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),keydown(VK_LBUTTON),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),click(middle),j,click(middle),wait(0.05),keyup(VK_LBUTTON)
|
||||
那维莱特 attack(0.05), check, wait(0.3), keypress(q), wait(0.1), keypress(q), wait(0.1), ready, click(middle), e, wait(0.15), keydown(VK_LBUTTON), wait(0.27), keyup(VK_LBUTTON), wait(0.15), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), keydown(VK_LBUTTON), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), click(middle), j, click(middle), keyup(VK_LBUTTON), wait(0.5), check, attack(0.2), click(middle), wait(0.2), keydown(VK_LBUTTON), wait(0.35), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), keydown(VK_LBUTTON), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -2100), wait(0.05), moveby(1800, -1100), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1200), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 1300), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), moveby(1800, 0), wait(0.05), click(middle), j, click(middle), wait(0.05), keyup(VK_LBUTTON), wait(0.15), check, wait(0.3)
|
||||
|
||||
温迪 attack(0.1), keypress(Q), e, click(middle), attack(0.2), keypress(Q), attack(0.22), e, click(middle), dash(0.1), attack(1.2), e, attack(0.5), click(middle), attack(0.2),dash(0.1),attack(1.2)
|
||||
温迪 attack(0.1), check, wait(0.3), keypress(Q), wait(0.1), ready, check, e, click(middle), attack(0.2), keypress(Q), wait(0.1), ready, attack(0.22), e, click(middle), dash(0.1), attack(1.2), e, attack(0.5), click(middle), attack(0.2), dash(0.1), attack(1.2), check, wait(0.3)
|
||||
|
||||
芭芭拉 e,attack(0.6),keypress(q),attack(2),charge(0.5),keypress(q),attack(0.2)
|
||||
丝柯克 attack(0.05),keypress(e),wait(0.05),keypress(e),wait(0.2),attack(2.27),keypress(Q),dash,attack(2.27),keydown(S),keypress(Q),dash,keyup(S),attack(2.27),wait(0.11),charge(0.3),attack(1)
|
||||
迪希雅 keypress(q),attack(0.1),dash(0.2),keypress(q),attack(0.3),keypress(q),attack(0.3),keypress(q),attack(0.3),keydown(S),attack(0.5),keyup(S),keydown(W),attack(0.5),keyup(W),keydown(S),attack(0.5),keyup(S),keydown(W),attack(0.5),keyup(W),keydown(S),attack(0.5),keyup(S),keydown(W),attack(0.5),keyup(W),keydown(S),attack(0.5),keyup(S)
|
||||
娜维娅 keypress(q),attack(0.1),keypress(q),attack(0.1),keypress(q),attack(0.1),keypress(q),keydown(E),wait(0.8),keyup(E),attack(1.6),keydown(E),wait(0.8),keyup(E),attack(0.1),keydown(S),attack(0.33),keyup(S),keydown(W),attack(0.3),keyup(W),keydown(S),attack(0.3),keyup(S),keydown(W),attack(0.3),keyup(W),keydown(S),attack(0.3),keyup(S),keydown(W),attack(0.3),keyup(W),attack(0.2)
|
||||
// (奈芙尔3zs)奈芙尔 attack(0.08), keydown(VK_LBUTTON), keydown(E), wait(0.015), keyup(E), wait(0.015), wait(0.95), wait(0.015), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.015), wait(0.015), wait(0.5), keyup(VK_LBUTTON)
|
||||
// (满命6刀)芙宁娜 attack(0.01),e,attack(0.1),dash(0.1),jump,wait(0.2),keypress(q),keydown(W),attack(0.3),keypress(q),keyup(W),attack(0.3),keypress(q),attack(0.1),keydown(S),attack(0.33),keyup(S),keydown(W),attack(0.3),keyup(W),keydown(S),attack(0.3),keyup(S),keydown(W),attack(0.3),keyup(W),keydown(S),attack(0.3),keyup(S),keydown(W),attack(0.3),keyup(W)
|
||||
// (火神AZS)玛薇卡 q,attack(0.1),e,charge(0.6),dash(0.3),moveby(500,0),moveby(2300,0),attack(0.1),charge(0.7),dash(0.3),moveby(-500,0),moveby(-2300,-0),attack(0.1),charge(0.7),dash(0.3),moveby(500,0),moveby(2600,0),attack(0.1),charge(0.8),dash(0.3),moveby(-500,0),moveby(-2300,-0),attack(0.1),charge(0.8),dash(0.3),moveby(500,0),moveby(2300,0),attack(0.1),charge(0.8),dash(0.3),moveby(-500,0),moveby(-2300,-0)
|
||||
// (火神ZZS)玛薇卡 attack(0.08), keypress(q),attack(0.03),keypress(q),keydown(E),wait(0.35),keyup(E),attack(0.03),wait(0.25), keydown(VK_LBUTTON),wait(0.155),keydown(VK_RBUTTON),wait(0.18),keyup(VK_LBUTTON),wait(0.02),keyup(VK_RBUTTON),wait(0.02),keydown(VK_LBUTTON),wait(0.16),keydown(VK_RBUTTON),wait(0.18),keyup(VK_LBUTTON),wait(0.02),keyup(VK_RBUTTON),wait(0.1),keydown(VK_LBUTTON),wait(0.05),keyup(VK_LBUTTON),wait(0.05),keydown(VK_LBUTTON),wait(0.05),keyup(VK_LBUTTON),wait(1.25), keydown(VK_LBUTTON),wait(0.155),keydown(VK_RBUTTON),wait(0.18),keyup(VK_LBUTTON),wait(0.02),keyup(VK_RBUTTON),wait(0.02),keydown(VK_LBUTTON),wait(0.16),keydown(VK_RBUTTON),wait(0.18),keyup(VK_LBUTTON),wait(0.02),keyup(VK_RBUTTON),wait(0.1),keydown(VK_LBUTTON),wait(0.05),keyup(VK_LBUTTON),wait(0.05),keydown(VK_LBUTTON),wait(0.05),keyup(VK_LBUTTON),wait(0.83)
|
||||
// (回身 QE ZZS)玛薇卡 attack(0.03),keypress(q),keypress(q),keydown(E),wait(0.45),keyup(E),wait(0.2),keydown(VK_LBUTTON),wait(0.155),wait(0.359),keyup(VK_LBUTTON),wait(0.05),wait(0.05), keydown(VK_LBUTTON),wait(0.1),keyup(VK_LBUTTON),wait(0.05),keydown(VK_LBUTTON),wait(0.1),keyup(VK_LBUTTON),click(middle),wait(0.45), moveby(5500,0),wait(0.05),keydown(VK_LBUTTON),wait(0.125),keydown(VK_RBUTTON),wait(0.15),s(0.1),wait(0.1),keyup(VK_LBUTTON),wait(0.01),keyup(VK_RBUTTON),wait(0.08),keydown(VK_LBUTTON),wait(0.125),keydown(VK_RBUTTON),wait(0.1),s(0.1),wait(0.1),keyup(VK_LBUTTON),wait(0.01),keyup(VK_RBUTTON),wait(0.1),keydown(VK_LBUTTON),wait(0.05),keyup(VK_LBUTTON),wait(0.05),keydown(VK_LBUTTON),wait(0.05),keyup(VK_LBUTTON),wait(0.3)
|
||||
瓦雷莎 e, attack(1.25),click(middle),wait(0.45), keydown(s), e, attack(1.25),keyup(s), wait(0.3),keypress(q), click(middle),wait(0.45)
|
||||
仆人 charge(0.35), j, keydown(s),attack(1.17),attack(0.45),keyup(s),keydown(w),attack(0.38),attack(0.6),keyup(w),wait(0.2),keydown(s),attack(1.17),attack(0.45),keyup(s),keydown(w),attack(0.38),attack(0.6),keyup(w),wait(0.2)
|
||||
芭芭拉 e, attack(0.6), check, wait(0.3), keypress(q), wait(0.1), ready, attack(2), charge(0.5), keypress(q), wait(0.1), ready, attack(0.2), check, wait(0.3)
|
||||
|
||||
// (满命转圈喷5.5秒)希格雯 e(hold),keypress(q),wait(0.2),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1),moveby(300,0),wait(0.1)
|
||||
丝柯克 e, wait(0.1), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.15), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), keydown(q), wait(0.05), keyup(q), wait(0.66), mousedown(left), wait(0.05), mouseup(left), check, wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.16), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), wait(0.23), mousedown(left), wait(0.05), mouseup(left), check, wait(0.79), keydown(w), wait(0.05), keyup(w), wait(0.2), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.16), mousedown(left), wait(0.21), mouseup(left), wait(0.66), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), wait(0.23), mousedown(left), wait(0.05), mouseup(left), check, wait(0.79), keydown(w), wait(0.05), keyup(w), wait(0.2), mousedown(left), wait(0.05), mouseup(left), wait(0.13), mousedown(left), wait(0.05), mouseup(left), check, wait(0.19), mousedown(right), wait(0.05), mouseup(right), wait(0.16), mousedown(left), wait(0.05), mouseup(left), wait(0.16), mousedown(left), wait(0.05), mouseup(left), check, wait(0.3)
|
||||
|
||||
迪希雅 attack(0.1), check, wait(0.3), dash(0.2), keypress(q), wait(0.1), ready, attack(0.3), keypress(q), attack(0.3), keypress(q), attack(0.3), keydown(S), attack(0.5), keyup(S), keydown(W), attack(0.5), keyup(W), wait(0.1), check, wait(0.3), keydown(S), attack(0.5), keyup(S), keydown(W), attack(0.5), keyup(W), keydown(S), attack(0.5), keyup(S), keydown(W), attack(0.5), keyup(W), keydown(S), attack(0.5), keyup(S), check, wait(0.3)
|
||||
|
||||
娜维娅 attack(0.1), check, wait(0.3), keypress(q), wait(0.1), ready, attack(0.1), keypress(q), wait(0.1), keypress(q), ready, check, wait(0.3), keydown(E), wait(0.8), keyup(E), attack(1.6), check, wait(0.3), keydown(E), wait(0.8), keyup(E), attack(0.1), keydown(S), attack(0.33), keyup(S), keydown(W), attack(0.3), keyup(W), keydown(S), attack(0.3), keyup(S), keydown(W), attack(0.3), keyup(W), keydown(S), attack(0.3), keyup(S), keydown(W), attack(0.3), keyup(W), attack(0.2), check, wait(0.3)
|
||||
|
||||
// (奈芙尔3zs)奈芙尔 attack(0.08), keydown(VK_LBUTTON), keydown(E), wait(0.015), keyup(E), wait(0.015), wait(0.95), wait(0.015), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), wait(0.015), keyup(W), wait(0.85), keydown(VK_RBUTTON), wait(0.015), keyup(VK_RBUTTON), wait(0.015), keydown(S), wait(0.015), keyup(S), wait(0.25), keydown(W), wait(0.015), keyup(W), wait(0.015), wait(0.015), wait(0.5), keyup(VK_LBUTTON), check, wait(0.3)
|
||||
|
||||
// (满命6刀)芙宁娜 attack(0.01), e, attack(0.1), dash(0.1), jump, wait(0.2), keypress(q), keydown(W), attack(0.3), keypress(q), keyup(W), attack(0.3), keypress(q), attack(0.1), keydown(S), attack(0.33), keyup(S), keydown(W), attack(0.3), keyup(W), keydown(S), attack(0.3), keyup(S), keydown(W), attack(0.3), keyup(W), keydown(S), attack(0.3), keyup(S), keydown(W), attack(0.3), keyup(W), check, wait(0.3)
|
||||
|
||||
// (火神AZS)玛薇卡 q, attack(0.1), e, charge(0.6), dash(0.3), moveby(500, 0), moveby(2300, 0), attack(0.1), charge(0.7), dash(0.3), moveby(-500, 0), moveby(-2300, -0), attack(0.1), charge(0.7), dash(0.3), moveby(500, 0), moveby(2600, 0), attack(0.1), charge(0.8), dash(0.3), moveby(-500, 0), moveby(-2300, -0), attack(0.1), charge(0.8), dash(0.3), moveby(500, 0), moveby(2300, 0), attack(0.1), charge(0.8), dash(0.3), moveby(-500, 0), moveby(-2300, -0), check, wait(0.3)
|
||||
|
||||
// (火神ZZS)玛薇卡 attack(0.08), keypress(q), attack(0.03), keypress(q), keydown(E), wait(0.35), keyup(E), attack(0.03), wait(0.25), keydown(VK_LBUTTON), wait(0.155), keydown(VK_RBUTTON), wait(0.18), keyup(VK_LBUTTON), wait(0.02), keyup(VK_RBUTTON), wait(0.02), keydown(VK_LBUTTON), wait(0.16), keydown(VK_RBUTTON), wait(0.18), keyup(VK_LBUTTON), wait(0.02), keyup(VK_RBUTTON), wait(0.1), keydown(VK_LBUTTON), wait(0.05), keyup(VK_LBUTTON), wait(0.05), keydown(VK_LBUTTON), wait(0.05), keyup(VK_LBUTTON), wait(1.25), keydown(VK_LBUTTON), wait(0.155), keydown(VK_RBUTTON), wait(0.18), keyup(VK_LBUTTON), wait(0.02), keyup(VK_RBUTTON), wait(0.02), keydown(VK_LBUTTON), wait(0.16), keydown(VK_RBUTTON), wait(0.18), keyup(VK_LBUTTON), wait(0.02), keyup(VK_RBUTTON), wait(0.1), keydown(VK_LBUTTON), wait(0.05), keyup(VK_LBUTTON), wait(0.05), keydown(VK_LBUTTON), wait(0.05), keyup(VK_LBUTTON), wait(0.83),check
|
||||
|
||||
// (回身 QE ZZS)玛薇卡 attack(0.03), keypress(q), keypress(q), keydown(E), wait(0.45), keyup(E), wait(0.2), keydown(VK_LBUTTON), wait(0.155), wait(0.359), keyup(VK_LBUTTON), wait(0.05), wait(0.05), keydown(VK_LBUTTON), wait(0.1), keyup(VK_LBUTTON), wait(0.05), keydown(VK_LBUTTON), wait(0.1), keyup(VK_LBUTTON), click(middle), wait(0.45), moveby(5500, 0), wait(0.05), keydown(VK_LBUTTON), wait(0.125), keydown(VK_RBUTTON), wait(0.15), s(0.1), wait(0.1), keyup(VK_LBUTTON), wait(0.01), keyup(VK_RBUTTON), wait(0.08), keydown(VK_LBUTTON), wait(0.125), keydown(VK_RBUTTON), wait(0.1), s(0.1), wait(0.1), keyup(VK_LBUTTON), wait(0.01), keyup(VK_RBUTTON), wait(0.1), keydown(VK_LBUTTON), wait(0.05), keyup(VK_LBUTTON), wait(0.05), keydown(VK_LBUTTON), wait(0.05), keyup(VK_LBUTTON), wait(0.3), check
|
||||
|
||||
瓦雷莎 e, attack(1.25), click(middle), wait(0.45),check, keydown(s), e, attack(1.25), keyup(s), wait(0.3), keypress(q), click(middle), wait(0.45), check, wait(0.3)
|
||||
|
||||
仆人 charge(0.35), j, wait(0.3), check, wait(0.3), keydown(s), attack(1.17), attack(0.45), keyup(s), keydown(w), attack(0.38), attack(0.6), keyup(w), wait(0.2), keydown(s), attack(1.17), attack(0.45), keyup(s), keydown(w), attack(0.38), attack(0.6), keyup(w), wait(0.2), check, wait(0.3)
|
||||
|
||||
// (满命转圈喷5.5秒)希格雯 e(hold),wait(0.3),check, wait(0.3), keypress(q), wait(0.2), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.1), moveby(300, 0), wait(0.2), check, wait(0.3)
|
||||
|
||||
菲谢尔 attack(0.3), check, wait(0.3), keypress(q), wait(0.1), keypress(q), j, attack(0.2), ready, check, wait(0.3)
|
||||
|
||||
菲林斯 attack(0.2), click(middle), check, wait(0.3), keydown(w), e, attack(0.3), keyup(w), keydown(s), e, keypress(q), attack(0.3), keyup(s), keydown(w), attack(0.33), keyup(w), check, wait(0.3), e, keypress(q), attack(0.33), keydown(s), e, attack(0.33), keyup(s), keypress(q), attack(0.2), keydown(w), attack(0.2), keyup(w), keydown(s), e, attack(0.2), keyup(s), keypress(e), attack(0.25), e, keypress(q), ready, keydown(w), e, attack(0.3), keyup(w), check, wait(0.3), keydown(s), e, keypress(q), attack(0.3), keyup(s), keydown(w), attack(0.33), keyup(w), check, wait(0.3), e, keypress(q), attack(0.33), keydown(s), e, attack(0.33), keyup(s), attack(0.2), keypress(q), ready, check, wait(0.3)
|
||||
|
||||
// (6命单喷4s) 那维莱特 attack(0.05),click(middle), check, wait(0.3), e, wait(0.15), keydown(VK_LBUTTON), wait(0.27),keyup(VK_LBUTTON),wait(0.15),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),keydown(VK_LBUTTON),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-2100),wait(0.05),moveby(1800,-1100),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1200),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,0),wait(0.05),moveby(1800,1300),wait(0.05),j,click(middle),click(middle),wait(0.05),keyup(VK_LBUTTON), check, wait(0.3)
|
||||
|
||||
// (大团长满命策略) 法尔伽 attack(0.05), check, wait(0.3), e,attack(0.2),e,attack(0.1),e,attack(0.05),e,keydown(s),attack(1),keyup(s),attack(2.1),keydown(w),e,attack(0.05),e,attack(0.05),e,attack(0.2),e,keyup(w),keydown(s),attack(0.5),e,attack(0.5),e,keyup(s),attack(0.05),e,attack(0.05),e,attack(0.1),e,attack(0.1),e,attack(0.35),keypress(q),wait(0.1),keypress(q), wait(0.1), ready, check, wait(0.3)
|
||||
@@ -1,14 +0,0 @@
|
||||
钟离 q,s(0.2),e(hold),wait(0.1),w(0.2),wait(0.2)
|
||||
雷电将军 e,wait(0.5),
|
||||
纳西妲 e(hold),wait(0.3),q,attack(0.5)
|
||||
芙宁娜 e,wait(0.2),q,wait(0.1)
|
||||
纳西妲 attack(0.5),wait(0.3),charge,wait(0.2)
|
||||
雷电将军 q,wait(0.1),attack(1),charge,wait(0.1),dash,attack(1.5),e
|
||||
钟离 wait(0.3),q,wait(0.2),s(0.2),e(hold),w(0.2),wait(1)
|
||||
纳西妲 e(hold),wait(0.2),q,wait(0.2),attack(1),wait(0.3),charge,wait(0.2)
|
||||
芙宁娜 charge,e,wait(0.3)
|
||||
纳西妲 attack(0.5),wait(0.3),charge,wait(0.2)
|
||||
钟离 s(0.2),e(hold),wait(0.5),w(0.2)
|
||||
雷电将军 wait(0.5),e,wait(0.2)
|
||||
芙宁娜 charge,e,wait(0.2),q
|
||||
纳西妲 e(hold),wait(0.2),attack(0.5),wait(0.3),charge,wait(0.2)
|
||||
@@ -163,7 +163,7 @@
|
||||
},
|
||||
{
|
||||
"name": "胡桃",
|
||||
"scriptContent1": "charge(0.3),wait(0.1),dash,wait(0.1),charge(0.3),wait(0.1),dash,wait(0.1),charge(0.3),wait(0.1),j,wait(0.52)",
|
||||
"scriptContent1": "click,wait(0.25),click,wait(0.05),mousedown,wait(0.265),mouseup,click(right),wait(0.02),keypress(S),wait(0.02),keypress(w),wait(0.35)",
|
||||
"macroPriority": 0
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<Window x:Class="BetterGenshinImpact.View.HtmlMaskWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||
Title="HtmlMaskWindow"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
WindowStartupLocation="Manual"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True">
|
||||
<Grid>
|
||||
<wv2:WebView2 x:Name="WebView" DefaultBackgroundColor="Transparent"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,411 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using Vanara.PInvoke;
|
||||
using static Vanara.PInvoke.User32;
|
||||
using BetterGenshinImpact.Core.Script.Dependence;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
|
||||
namespace BetterGenshinImpact.View;
|
||||
|
||||
/// <summary>
|
||||
/// HTML遮罩窗口 - 仅用于显示,不可交互(点击穿透)
|
||||
/// </summary>
|
||||
public partial class HtmlMaskWindow : Window
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, HtmlMaskWindow> _windows = new();
|
||||
private const int MaxWindows = 5;
|
||||
|
||||
private readonly string _id;
|
||||
private readonly string _workDir;
|
||||
private readonly string _webView2DataPath;
|
||||
private readonly string _pageUrl;
|
||||
private bool _navigationCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// 窗口唯一标识
|
||||
/// </summary>
|
||||
public string MaskId => _id;
|
||||
|
||||
private HtmlMaskWindow(string url, string? id, string workDir)
|
||||
{
|
||||
_id = id ?? Guid.NewGuid().ToString("N");
|
||||
_workDir = workDir;
|
||||
_webView2DataPath = Path.Combine(workDir, "WebView2Data");
|
||||
_pageUrl = url;
|
||||
InitializeComponent();
|
||||
Loaded += OnLoaded;
|
||||
InitializeAsync(url);
|
||||
}
|
||||
|
||||
#region 静态窗口管理
|
||||
|
||||
/// <summary>
|
||||
/// 显示HTML遮罩窗口
|
||||
/// </summary>
|
||||
public static string Show(string url, string? id, string workDir)
|
||||
{
|
||||
return Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 指定ID时先关闭已有窗口
|
||||
if (id != null && _windows.TryGetValue(id, out var existing))
|
||||
{
|
||||
existing.Close();
|
||||
}
|
||||
|
||||
if (_windows.Count >= MaxWindows)
|
||||
{
|
||||
throw new InvalidOperationException($"最多同时打开 {MaxWindows} 个HTML遮罩窗口");
|
||||
}
|
||||
|
||||
var window = new HtmlMaskWindow(url, id, workDir);
|
||||
string wid = window.MaskId;
|
||||
_windows[wid] = window;
|
||||
window.Closed += (_, _) =>
|
||||
{
|
||||
_windows.TryRemove(wid, out _);
|
||||
window.DisposeWebView();
|
||||
};
|
||||
window.Show();
|
||||
return wid;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭指定窗口
|
||||
/// </summary>
|
||||
public static bool Close(string id)
|
||||
{
|
||||
if (_windows.TryGetValue(id, out var window))
|
||||
{
|
||||
window.Dispatcher.Invoke(() => window.Close());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭所有窗口
|
||||
/// </summary>
|
||||
public static void CloseAll()
|
||||
{
|
||||
foreach (var kvp in _windows)
|
||||
{
|
||||
kvp.Value.Dispatcher.Invoke(() => kvp.Value.Close());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏所有窗口(保留生命,不关闭)
|
||||
/// </summary>
|
||||
public static void HideAll()
|
||||
{
|
||||
foreach (var kvp in _windows)
|
||||
{
|
||||
kvp.Value.Dispatcher.Invoke(() => kvp.Value.Hide());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示所有窗口
|
||||
/// </summary>
|
||||
public static void ShowAll()
|
||||
{
|
||||
foreach (var kvp in _windows)
|
||||
{
|
||||
kvp.Value.Dispatcher.Invoke(() =>
|
||||
{
|
||||
kvp.Value.Show();
|
||||
kvp.Value.UpdatePosition();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步所有窗口位置
|
||||
/// </summary>
|
||||
public static void UpdateAllPositions()
|
||||
{
|
||||
foreach (var kvp in _windows)
|
||||
{
|
||||
kvp.Value.UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有窗口ID
|
||||
/// </summary>
|
||||
public static string[] GetWindowIds()
|
||||
{
|
||||
return _windows.Keys.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口是否存在
|
||||
/// </summary>
|
||||
public static bool Exists(string id)
|
||||
{
|
||||
return _windows.ContainsKey(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知窗口刷新待推送的消息
|
||||
/// </summary>
|
||||
internal static void NotifyFlush(string windowId)
|
||||
{
|
||||
if (!_windows.TryGetValue(windowId, out var window)) return;
|
||||
window.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
// 页面还没加载完,消息留在队列中由 NavigationCompleted 统一推送
|
||||
if (!window._navigationCompleted) return;
|
||||
if (window.WebView.CoreWebView2 == null) return;
|
||||
HtmlMask.FlushPendingMessages(windowId, json =>
|
||||
{
|
||||
window.WebView.CoreWebView2.PostWebMessageAsString(json);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetClickThrough();
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
private async void InitializeAsync(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
await WebView.EnsureCoreWebView2Async(
|
||||
await CoreWebView2Environment.CreateAsync(null, _webView2DataPath));
|
||||
|
||||
WebView.DefaultBackgroundColor = System.Drawing.Color.Transparent;
|
||||
WebView.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;
|
||||
WebView.CoreWebView2.Settings.IsScriptEnabled = true;
|
||||
WebView.CoreWebView2.Settings.IsWebMessageEnabled = true;
|
||||
|
||||
// 拦截网络请求,仅允许注册过的域名
|
||||
WebView.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All);
|
||||
WebView.CoreWebView2.WebResourceRequested += OnWebResourceRequested;
|
||||
|
||||
// 注入 helper JS,提供 window.htmlMask.request / onMessage API
|
||||
await WebView.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(@"
|
||||
window.htmlMask = {
|
||||
_callbacks: {},
|
||||
_seq: 0,
|
||||
request: function(url, data) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var id = '__req_' + (++window.htmlMask._seq);
|
||||
window.htmlMask._callbacks[id] = { resolve: resolve, reject: reject };
|
||||
window.chrome.webview.postMessage(JSON.stringify({
|
||||
url: url,
|
||||
data: data || {},
|
||||
requestId: id
|
||||
}));
|
||||
});
|
||||
},
|
||||
onMessage: null,
|
||||
_dispatch: function(raw) {
|
||||
try {
|
||||
var msg = JSON.parse(raw);
|
||||
if (msg.requestId && window.htmlMask._callbacks[msg.requestId]) {
|
||||
window.htmlMask._callbacks[msg.requestId].resolve(msg);
|
||||
delete window.htmlMask._callbacks[msg.requestId];
|
||||
} else if (window.htmlMask.onMessage) {
|
||||
var result = window.htmlMask.onMessage(msg);
|
||||
if (msg.requestId && result !== undefined) {
|
||||
Promise.resolve(result).then(function(data) {
|
||||
window.chrome.webview.postMessage(JSON.stringify({
|
||||
requestId: msg.requestId,
|
||||
url: '/__response__',
|
||||
data: data
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
if (window.htmlMask.onMessage) window.htmlMask.onMessage(raw);
|
||||
}
|
||||
}
|
||||
};
|
||||
window.chrome.webview.addEventListener('message', function(e) {
|
||||
window.htmlMask._dispatch(e.data);
|
||||
});
|
||||
");
|
||||
|
||||
// 监听HTML发来的消息,解析 url + data + requestId
|
||||
WebView.CoreWebView2.WebMessageReceived += (_, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
string raw = e.TryGetWebMessageAsString();
|
||||
string messageUrl = "";
|
||||
string data = raw;
|
||||
string? requestId = null;
|
||||
|
||||
try
|
||||
{
|
||||
using var doc = JsonDocument.Parse(raw);
|
||||
var root = doc.RootElement;
|
||||
if (root.TryGetProperty("url", out var ep))
|
||||
{
|
||||
messageUrl = ep.GetString() ?? "";
|
||||
data = root.TryGetProperty("data", out var d) ? d.GetRawText() : "{}";
|
||||
}
|
||||
if (root.TryGetProperty("requestId", out var rid))
|
||||
{
|
||||
requestId = rid.GetString();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
HtmlMask.SendFromHtml(_id, messageUrl, data, requestId);
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
|
||||
// 页面加载完成后推送队列中待发送的消息
|
||||
WebView.CoreWebView2.NavigationStarting += (_, _) =>
|
||||
{
|
||||
_navigationCompleted = false;
|
||||
};
|
||||
WebView.CoreWebView2.NavigationCompleted += (_, _) =>
|
||||
{
|
||||
_navigationCompleted = true;
|
||||
HtmlMask.FlushPendingMessages(_id, json =>
|
||||
{
|
||||
WebView.CoreWebView2.PostWebMessageAsString(json);
|
||||
});
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
WebView.Source = new Uri(url);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TaskControl.Logger.LogError($"WebView2 初始化失败: {e.Message}");
|
||||
Dispatcher.Invoke(() => Close());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拦截网络请求,仅允许 file://、data:// 和注册过的域名
|
||||
/// </summary>
|
||||
private void OnWebResourceRequested(object? sender, CoreWebView2WebResourceRequestedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var uri = new Uri(e.Request.Uri);
|
||||
|
||||
// 允许数据URI
|
||||
if (uri.Scheme == "data") return;
|
||||
|
||||
// 本地文件:必须在脚本目录内
|
||||
if (uri.Scheme == "file")
|
||||
{
|
||||
var localPath = Uri.UnescapeDataString(uri.AbsolutePath);
|
||||
var fullDir = Path.GetFullPath(_workDir);
|
||||
var fullFile = Path.GetFullPath(localPath);
|
||||
if (fullFile.StartsWith(fullDir, StringComparison.OrdinalIgnoreCase)) return;
|
||||
TaskControl.Logger.LogWarning("拦截HTML遮罩越级文件访问: {Uri}", e.Request.Uri);
|
||||
e.Response = WebView.CoreWebView2.Environment.CreateWebResourceResponse(null, 403, "Blocked", "");
|
||||
return;
|
||||
}
|
||||
|
||||
// 仅允许页面自身的初始导航
|
||||
if (string.Equals(uri.AbsoluteUri, _pageUrl, StringComparison.OrdinalIgnoreCase)) return;
|
||||
|
||||
// HTTP/HTTPS 请求:与 JS 脚本使用完全一致的权限校验
|
||||
var currentProject = TaskContext.Instance().CurrentScriptProject;
|
||||
if (currentProject?.AllowJsHTTP != true)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("未启用JS HTTP权限,拦截HTML遮罩网络请求: {Uri}", e.Request.Uri);
|
||||
e.Response = WebView.CoreWebView2.Environment.CreateWebResourceResponse(null, 403, "Blocked", "");
|
||||
return;
|
||||
}
|
||||
|
||||
var allowedUrls = currentProject?.Project?.Manifest.HttpAllowedUrls ?? [];
|
||||
if (allowedUrls.Length == 0)
|
||||
{
|
||||
TaskControl.Logger.LogWarning("未配置 http_allowed_urls,拦截HTML遮罩网络请求: {Uri}", e.Request.Uri);
|
||||
e.Response = WebView.CoreWebView2.Environment.CreateWebResourceResponse(null, 403, "Blocked", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (allowedUrls.Any(allowedUrl =>
|
||||
{
|
||||
var pattern = "^" + Regex.Escape(allowedUrl).Replace("\\*", ".*") + "$";
|
||||
return Regex.IsMatch(e.Request.Uri, pattern, RegexOptions.IgnoreCase);
|
||||
})) return;
|
||||
|
||||
TaskControl.Logger.LogWarning("URL不在允许列表中,拦截HTML遮罩网络请求: {Uri}", e.Request.Uri);
|
||||
e.Response = WebView.CoreWebView2.Environment.CreateWebResourceResponse(null, 403, "Blocked", "");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogWarning(ex, "HTML遮罩资源请求拦截异常");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新窗口位置
|
||||
/// </summary>
|
||||
public void UpdatePosition()
|
||||
{
|
||||
try
|
||||
{
|
||||
var gameHandle = TaskContext.Instance().GameHandle;
|
||||
if (gameHandle == IntPtr.Zero) return;
|
||||
|
||||
var currentRect = SystemControl.GetCaptureRect(gameHandle);
|
||||
if (currentRect.Width <= 0 || currentRect.Height <= 0) return;
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
Left = currentRect.Left;
|
||||
Top = currentRect.Top;
|
||||
Width = currentRect.Width;
|
||||
Height = currentRect.Height;
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TaskControl.Logger.LogDebug(ex, "HTML遮罩窗口位置更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置点击穿透
|
||||
/// </summary>
|
||||
private void SetClickThrough()
|
||||
{
|
||||
var hwnd = new WindowInteropHelper(this).Handle;
|
||||
var style = (int)GetWindowLong(hwnd, WindowLongFlags.GWL_EXSTYLE);
|
||||
User32.SetWindowLong(hwnd, WindowLongFlags.GWL_EXSTYLE,
|
||||
(IntPtr)(style | (int)User32.WindowStylesEx.WS_EX_TRANSPARENT));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放 WebView2 资源,停止媒体播放
|
||||
/// </summary>
|
||||
private void DisposeWebView()
|
||||
{
|
||||
try
|
||||
{
|
||||
WebView.Dispose();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
@@ -441,6 +441,20 @@ public partial class MaskWindow : Window
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginInvoke(Action action)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispatcher.BeginInvoke(action);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void HideSelf()
|
||||
{
|
||||
|
||||
@@ -436,6 +436,32 @@
|
||||
AcceptsReturn="True" />
|
||||
</Grid>
|
||||
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="启动前自动关闭原神 HDR"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="检测到开启时会自动关闭原神 HDR 注册表设置"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.GenshinStartConfig.AutoDisableGenshinHdrEnabled, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -71,7 +71,54 @@
|
||||
Grid.Row="0"
|
||||
Margin="0,0,10,0"
|
||||
Icon="{ui:SymbolIcon Add24}"
|
||||
Command="{Binding AddTaskGroupCommand}" />
|
||||
x:Name="AddTaskGroupButton"
|
||||
Click="AddTaskGroupButton_Click" />
|
||||
|
||||
<!-- 添加配置组弹窗 -->
|
||||
<Popup x:Name="AddConfigGroupPopup"
|
||||
Placement="Absolute"
|
||||
AllowsTransparency="True"
|
||||
PopupAnimation="Fade"
|
||||
StaysOpen="False">
|
||||
<Border CornerRadius="8"
|
||||
Background="{DynamicResource ApplicationBackgroundBrush}"
|
||||
BorderBrush="{DynamicResource SystemAccentColorPrimaryBrush}"
|
||||
BorderThickness="1"
|
||||
MinWidth="300"
|
||||
MaxHeight="400">
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Text="选择增加的配置组(可多选)"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,0,12"
|
||||
HorizontalAlignment="Center"/>
|
||||
|
||||
<ScrollViewer MaxHeight="250" VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl x:Name="ScriptGroupItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox Content="{Binding Name}"
|
||||
Tag="{Binding}"
|
||||
Margin="0,2"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,12,0,0">
|
||||
<Button Content="确认"
|
||||
Width="70"
|
||||
Margin="0,0,10,0"
|
||||
Click="ConfirmButton_Click"/>
|
||||
<Button Content="取消"
|
||||
Width="70"
|
||||
Click="CancelButton_Click"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Grid>
|
||||
<Grid DockPanel.Dock="Top"
|
||||
Margin="0,0,0,10">
|
||||
|
||||
@@ -6,6 +6,8 @@ using Wpf.Ui.Violeta.Controls;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using BetterGenshinImpact.Core.Script.Group;
|
||||
using System;
|
||||
|
||||
namespace BetterGenshinImpact.View.Pages;
|
||||
|
||||
@@ -34,6 +36,133 @@ public partial class OneDragonFlowPage
|
||||
{ ExpBottleSmallCheckBox, "祝圣油膏" }
|
||||
};
|
||||
|
||||
// 监听ViewModel的属性变化
|
||||
ViewModel.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
|
||||
private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(ViewModel.ShouldShowAddTaskGroupPopup) && ViewModel.ShouldShowAddTaskGroupPopup)
|
||||
{
|
||||
// 重置属性
|
||||
ViewModel.ShouldShowAddTaskGroupPopup = false;
|
||||
|
||||
// 显示弹窗
|
||||
ShowAddTaskGroupPopup();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowAddTaskGroupPopup()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 读取配置组
|
||||
ViewModel.ReadScriptGroup();
|
||||
|
||||
// 检查是否有ScriptGroups
|
||||
if (ViewModel.ScriptGroups == null || !ViewModel.ScriptGroups.Any())
|
||||
{
|
||||
Toast.Warning("没有找到配置组");
|
||||
return;
|
||||
}
|
||||
|
||||
// 过滤已存在的配置组
|
||||
var availableGroups = ViewModel.ScriptGroups
|
||||
.Where(sg => ViewModel.TaskList == null || !ViewModel.TaskList.Any(task => task.Name == sg.Name))
|
||||
.ToList();
|
||||
|
||||
if (!availableGroups.Any())
|
||||
{
|
||||
Toast.Warning("没有可添加的配置组");
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置ItemsControl的数据源
|
||||
ScriptGroupItemsControl.ItemsSource = availableGroups;
|
||||
|
||||
// 获取主窗口
|
||||
var mainWindow = Application.Current.MainWindow;
|
||||
if (mainWindow != null)
|
||||
{
|
||||
// 获取主窗口的位置和大小
|
||||
var windowLeft = mainWindow.Left;
|
||||
var windowTop = mainWindow.Top;
|
||||
var windowWidth = mainWindow.ActualWidth;
|
||||
var windowHeight = mainWindow.ActualHeight;
|
||||
|
||||
// 估算弹窗大小
|
||||
var popupWidth = 350.0;
|
||||
var popupHeight = 300.0;
|
||||
|
||||
// 计算居中位置(相对于主窗口)
|
||||
AddConfigGroupPopup.HorizontalOffset = windowLeft + (windowWidth - popupWidth) / 2;
|
||||
AddConfigGroupPopup.VerticalOffset = windowTop + (windowHeight - popupHeight) / 2;
|
||||
}
|
||||
|
||||
// 显示弹窗
|
||||
AddConfigGroupPopup.IsOpen = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Toast.Error($"添加任务组时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void AddTaskGroupButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowAddTaskGroupPopup();
|
||||
}
|
||||
|
||||
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectedGroups = new List<string>();
|
||||
|
||||
// 遍历所有CheckBox,收集选中的项
|
||||
foreach (var item in ScriptGroupItemsControl.Items)
|
||||
{
|
||||
var container = ScriptGroupItemsControl.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement;
|
||||
if (container != null)
|
||||
{
|
||||
var checkBox = FindVisualChild<CheckBox>(container);
|
||||
if (checkBox?.IsChecked == true && checkBox.Tag is ScriptGroup scriptGroup)
|
||||
{
|
||||
selectedGroups.Add(scriptGroup.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedGroups.Any())
|
||||
{
|
||||
// 调用ViewModel的方法处理选中的配置组
|
||||
ViewModel.ProcessSelectedGroups(selectedGroups);
|
||||
|
||||
// 保存配置并重置选中项
|
||||
ViewModel.SaveConfig();
|
||||
ViewModel.SelectedTask = null;
|
||||
}
|
||||
|
||||
AddConfigGroupPopup.IsOpen = false;
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AddConfigGroupPopup.IsOpen = false;
|
||||
}
|
||||
|
||||
// 辅助方法:查找子控件
|
||||
private static T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject
|
||||
{
|
||||
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++)
|
||||
{
|
||||
var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i);
|
||||
if (child is T result)
|
||||
return result;
|
||||
|
||||
var childOfChild = FindVisualChild<T>(child);
|
||||
if (childOfChild != null)
|
||||
return childOfChild;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private async void SereniteaPotTpType_Clicked(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -1102,6 +1102,36 @@
|
||||
</Grid>
|
||||
<Separator Margin="-18,0"
|
||||
BorderThickness="0,1,0,0" />
|
||||
|
||||
<Grid Margin="16,16,16,16"
|
||||
Visibility="{Binding Config.AutoFightConfig.KazuhaPickupEnabled, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="基于经验值判断拾取(经验值57/58/60,不含传奇120等数字)"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="战斗中检测精英怪死亡经验值图标,未检测到时跳过拾取,避免无价值战斗后浪费时间"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.AutoFightConfig.ExpBasedPickupEnabled, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Separator Margin="-18,0"
|
||||
BorderThickness="0,1,0,0"
|
||||
Visibility="{Binding Config.AutoFightConfig.KazuhaPickupEnabled, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
|
||||
<Grid Margin="16,16,16,16">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -2399,6 +2429,93 @@
|
||||
Text="{Binding Config.AutoLeyLineOutcropConfig.FightConfig.ActionSchedulerByCd, Mode=TwoWay}"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
<Grid Margin="16,0,16,16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="旋转寻找敌人位置"
|
||||
Margin="0,0,0,10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
FontTypography="Body"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
FontSize="9"
|
||||
Text="旋转速度(建议单次360°左右):"
|
||||
Margin="5,8,0,10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
<Slider Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Minimum="1"
|
||||
Maximum="13"
|
||||
Value="{Binding Config.AutoLeyLineOutcropConfig.FightConfig.SeekEnemyRotaryFactor, Mode=TwoWay}"
|
||||
Margin="3,0,5,10"
|
||||
TickFrequency="1"
|
||||
IsSnapToTickEnabled="True"
|
||||
IsEnabled="{Binding Config.AutoLeyLineOutcropConfig.FightConfig.SeekEnemyEnabled}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.RowSpan="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Margin="0,0,5,0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="(实验性功能) 战斗时按下方设置的间隔尝试靠近或旋转寻找敌人。"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.Column="3"
|
||||
Margin="10,0,36,10"
|
||||
IsChecked="{Binding Config.AutoLeyLineOutcropConfig.FightConfig.SeekEnemyEnabled, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid Margin="16,0,16,16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="寻敌间隔(秒)"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="仅在已启用“旋转寻找敌人位置”后生效,最小 1 秒。"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:NumberBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
MinWidth="120"
|
||||
Minimum="1"
|
||||
Maximum="60"
|
||||
SmallChange="1"
|
||||
LargeChange="5"
|
||||
ValidationMode="InvalidInputOverwritten"
|
||||
IsEnabled="{Binding Config.AutoLeyLineOutcropConfig.FightConfig.SeekEnemyEnabled}"
|
||||
Value="{Binding Config.AutoLeyLineOutcropConfig.FightConfig.SeekEnemyIntervalSeconds, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid>
|
||||
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
|
||||
<Grid Margin="16,16,16,13">
|
||||
<Grid.RowDefinitions>
|
||||
|
||||
@@ -992,7 +992,7 @@
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="快速检查战斗结束,在一轮脚本中,可以每隔一定秒数(默认为5)或指定角色操作后,去检查(在每个角色完成该轮脚本时)。"
|
||||
Text="快速检查战斗结束( 默认关闭 ),在一轮脚本中,可以每隔一定秒数(默认为5)或指定角色操作后,去检查(在每个角色完成该轮脚本时)。"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
@@ -1143,7 +1143,7 @@
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="检查战斗结束的延时,不同角色招式结束后的延时不一定相同,默认为1.5秒。也可以指定特定角色之后延时多少秒检查,未指定角色名,则默认为该值。格式如:2.5;白术,1.5;钟离,1.0;"
|
||||
Text="检查战斗结束的延时,不同角色招式结束后的延时不一定相同,默认为1.5秒( 预设0.4秒 )。也可以指定特定角色之后延时多少秒检查,未指定角色名,则默认为该值。格式如:2.5;白术,1.5;钟离,1.0;"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
@@ -1168,7 +1168,7 @@
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="按下切换队伍后去检查屏幕色块的延时,默认为0.45秒。若频繁误判可以适当提高这个值,比如到0.75。确保这个延时不会真的把队伍配置界面切出来。"
|
||||
Text="按下切换队伍后去检查屏幕色块的延时,默认为0.45秒( 预设0.4秒 )。若频繁误判可以适当提高这个值,比如到0.75。确保这个延时不会真的把队伍配置界面切出来。"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
@@ -1482,6 +1482,41 @@
|
||||
Text="二次拾取"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
<Grid Margin="16">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding PathingConfig.AutoFightConfig.KazuhaPickupEnabled}" Value="False">
|
||||
<Setter Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="基于经验值判断拾取(经验值57/58/60,不含传奇120等数字)"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="战斗中检测精英怪死亡经验数字值图标,未检测到时跳过拾取,避免无价值战斗后浪费时间"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding PathingConfig.AutoFightConfig.ExpBasedPickupEnabled, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:behavior="clr-namespace:BetterGenshinImpact.View.Behavior"
|
||||
Width="480"
|
||||
Height="240"
|
||||
MinWidth="400"
|
||||
Width="560"
|
||||
SizeToContent="Height"
|
||||
MinWidth="440"
|
||||
MinHeight="200"
|
||||
MaxHeight="360"
|
||||
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
|
||||
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
@@ -23,7 +24,7 @@
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
@@ -35,7 +36,7 @@
|
||||
ShowMinimize="False" />
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<Grid Grid.Row="1" Margin="24,12,24,12">
|
||||
<Grid Grid.Row="1" Margin="24,16,24,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
@@ -47,25 +48,29 @@
|
||||
Symbol="Info24"
|
||||
FontSize="48"
|
||||
Foreground="{DynamicResource SystemFillColorCautionBrush}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,16,0" />
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,4,16,0" />
|
||||
|
||||
<!-- 消息内容 -->
|
||||
<ui:TextBlock Grid.Column="1"
|
||||
x:Name="MessageTextBlock"
|
||||
TextAlignment="Left"
|
||||
TextWrapping="Wrap"
|
||||
FontSize="14"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||
<ScrollViewer Grid.Column="1"
|
||||
MaxHeight="140"
|
||||
Padding="0,0,8,0"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<ui:TextBlock x:Name="MessageTextBlock"
|
||||
TextAlignment="Left"
|
||||
TextWrapping="Wrap"
|
||||
FontSize="14"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<StackPanel Grid.Row="2"
|
||||
x:Name="ButtonPanel"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="24,0,24,24">
|
||||
HorizontalAlignment="Right"
|
||||
Margin="24,0,24,18">
|
||||
|
||||
<!-- 主按钮 -->
|
||||
<ui:Button x:Name="PrimaryButton"
|
||||
|
||||
@@ -217,6 +217,8 @@ public partial class HomePageViewModel : ViewModel
|
||||
[RelayCommand(CanExecute = nameof(CanStartTrigger))]
|
||||
public async Task OnStartTriggerAsync()
|
||||
{
|
||||
await DisableGenshinHdrIfNeededAsync();
|
||||
|
||||
var hWnd = SystemControl.FindGenshinImpactHandle();
|
||||
if (hWnd == IntPtr.Zero)
|
||||
{
|
||||
@@ -249,6 +251,24 @@ public partial class HomePageViewModel : ViewModel
|
||||
Start(hWnd);
|
||||
}
|
||||
|
||||
private Task DisableGenshinHdrIfNeededAsync()
|
||||
{
|
||||
if (!Config.GenshinStartConfig.AutoDisableGenshinHdrEnabled)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (!GenshinHdrRegistryHelper.TryDisableHdr(out _))
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
// 这行日志可能看不到
|
||||
_logger.LogWarning(
|
||||
"检测到原神 HDR 已开启并已自动关闭。如游戏已在运行,请重启游戏后生效。");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void Start(IntPtr hWnd)
|
||||
{
|
||||
Debug.WriteLine($"原神启动句柄{hWnd}");
|
||||
@@ -634,4 +654,4 @@ public partial class HomePageViewModel : ViewModel
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ using BetterGenshinImpact.Helpers.Extensions;
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.View;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
@@ -39,6 +40,8 @@ using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Vanara.PInvoke;
|
||||
using HotKeySettingModel = BetterGenshinImpact.Model.HotKeySettingModel;
|
||||
|
||||
@@ -48,6 +51,8 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
{
|
||||
private readonly ILogger<HotKeyPageViewModel> _logger;
|
||||
private readonly TaskSettingsPageViewModel _taskSettingsPageViewModel;
|
||||
private readonly Dictionary<string, HotKey> _acceptedHotKeys = [];
|
||||
private readonly HashSet<string> _rollingBackHotKeyProperties = [];
|
||||
public AllConfig Config { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
@@ -66,6 +71,7 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
var list = GetAllNonDirectoryHotkey(HotKeySettingModels);
|
||||
foreach (var hotKeyConfig in list)
|
||||
{
|
||||
_acceptedHotKeys[hotKeyConfig.ConfigPropertyName] = hotKeyConfig.HotKey;
|
||||
hotKeyConfig.RegisterHotKey();
|
||||
hotKeyConfig.PropertyChanged += (sender, e) =>
|
||||
{
|
||||
@@ -77,16 +83,17 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
if (e.PropertyName == "HotKey")
|
||||
{
|
||||
Debug.WriteLine($"{model.FunctionName} 快捷键变更为 {model.HotKey}");
|
||||
var pi = Config.HotKeyConfig.GetType().GetProperty(model.ConfigPropertyName, BindingFlags.Public | BindingFlags.Instance);
|
||||
if (null != pi && pi.CanWrite)
|
||||
if (_rollingBackHotKeyProperties.Remove(model.ConfigPropertyName))
|
||||
{
|
||||
var str = model.HotKey.ToString();
|
||||
if (str == "< None >")
|
||||
{
|
||||
str = "";
|
||||
}
|
||||
|
||||
pi.SetValue(Config.HotKeyConfig, str, null);
|
||||
UpdateHotKeyConfig(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
var newHotKey = model.HotKey;
|
||||
var previousHotKey = _acceptedHotKeys.GetValueOrDefault(model.ConfigPropertyName, HotKey.None);
|
||||
UpdateHotKeyConfig(model);
|
||||
_acceptedHotKeys[model.ConfigPropertyName] = newHotKey;
|
||||
ShowGameKeyBindingConflictWarning(model, newHotKey, previousHotKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +117,145 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowGameKeyBindingConflictWarning(HotKeySettingModel model, HotKey newHotKey, HotKey previousHotKey)
|
||||
{
|
||||
if (!TryConvertToGameKeyId(model.HotKey, out var hotKeyId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var conflictLines = GetGameKeyBindingConflictLines(hotKeyId);
|
||||
if (conflictLines.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = $"{model.FunctionName}使用{hotKeyId.ToName()}键会与原神键位冲突:\n\n"
|
||||
+ string.Join("\n", conflictLines)
|
||||
+ "\n\n会导致游戏内动作和 BetterGI 功能同时触发,建议更换为其他按键。是否继续使用?";
|
||||
Application.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (model.HotKey != newHotKey)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var result = ThemedMessageBox.Warning(message, "快捷键冲突提醒", MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
|
||||
if (result == MessageBoxResult.Cancel && model.HotKey == newHotKey)
|
||||
{
|
||||
_acceptedHotKeys[model.ConfigPropertyName] = previousHotKey;
|
||||
_rollingBackHotKeyProperties.Add(model.ConfigPropertyName);
|
||||
model.HotKey = previousHotKey;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static bool TryConvertToGameKeyId(HotKey hotKey, out KeyId keyId)
|
||||
{
|
||||
keyId = KeyId.Unknown;
|
||||
|
||||
if (hotKey.IsEmpty)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hotKey.MouseButton is MouseButton.XButton1 or MouseButton.XButton2)
|
||||
{
|
||||
keyId = KeyIdConverter.FromMouseButton(hotKey.MouseButton);
|
||||
return keyId is not KeyId.Unknown and not KeyId.None;
|
||||
}
|
||||
|
||||
if (hotKey.Modifiers != ModifierKeys.None || hotKey.Key == Key.None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
keyId = KeyIdConverter.FromInputKey(hotKey.Key);
|
||||
return keyId is not KeyId.Unknown and not KeyId.None;
|
||||
}
|
||||
|
||||
private List<string> GetGameKeyBindingConflictLines(KeyId hotKeyId)
|
||||
{
|
||||
var lines = new List<string>();
|
||||
foreach (var pi in typeof(KeyBindingsConfig).GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
if (pi.PropertyType != typeof(KeyId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pi.GetValue(Config.KeyBindingsConfig) is KeyId gameKeyId && gameKeyId == hotKeyId)
|
||||
{
|
||||
lines.Add($"- {GetGameKeyBindingActionName(pi.Name)}({gameKeyId.ToName()})");
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static string GetGameKeyBindingActionName(string propertyName)
|
||||
{
|
||||
return propertyName switch
|
||||
{
|
||||
nameof(KeyBindingsConfig.MoveForward) => "向前移动",
|
||||
nameof(KeyBindingsConfig.MoveBackward) => "向后移动",
|
||||
nameof(KeyBindingsConfig.MoveLeft) => "向左移动",
|
||||
nameof(KeyBindingsConfig.MoveRight) => "向右移动",
|
||||
nameof(KeyBindingsConfig.SwitchToWalkOrRun) => "切换走/跑;特定操作模式下向下移动",
|
||||
nameof(KeyBindingsConfig.NormalAttack) => "普通攻击",
|
||||
nameof(KeyBindingsConfig.ElementalSkill) => "元素战技",
|
||||
nameof(KeyBindingsConfig.ElementalBurst) => "元素爆发",
|
||||
nameof(KeyBindingsConfig.SprintKeyboard) => "冲刺(键盘)",
|
||||
nameof(KeyBindingsConfig.SprintMouse) => "冲刺(鼠标)",
|
||||
nameof(KeyBindingsConfig.SwitchAimingMode) => "切换瞄准模式",
|
||||
nameof(KeyBindingsConfig.Jump) => "跳跃;特定操作模式下向上移动",
|
||||
nameof(KeyBindingsConfig.Drop) => "落下",
|
||||
nameof(KeyBindingsConfig.PickUpOrInteract) => "拾取/交互(自动拾取由AutoPick模块管理)",
|
||||
nameof(KeyBindingsConfig.QuickUseGadget) => "快捷使用小道具",
|
||||
nameof(KeyBindingsConfig.InteractionInSomeMode) => "特定玩法内交互操作",
|
||||
nameof(KeyBindingsConfig.QuestNavigation) => "开启任务追踪",
|
||||
nameof(KeyBindingsConfig.AbandonChallenge) => "中断挑战",
|
||||
nameof(KeyBindingsConfig.SwitchMember1) => "切换小队角色1",
|
||||
nameof(KeyBindingsConfig.SwitchMember2) => "切换小队角色2",
|
||||
nameof(KeyBindingsConfig.SwitchMember3) => "切换小队角色3",
|
||||
nameof(KeyBindingsConfig.SwitchMember4) => "切换小队角色4",
|
||||
nameof(KeyBindingsConfig.SwitchMember5) => "切换小队角色5",
|
||||
nameof(KeyBindingsConfig.ShortcutWheel) => "呼出快捷轮盘",
|
||||
nameof(KeyBindingsConfig.OpenInventory) => "打开背包",
|
||||
nameof(KeyBindingsConfig.OpenCharacterScreen) => "打开角色界面",
|
||||
nameof(KeyBindingsConfig.OpenMap) => "打开地图",
|
||||
nameof(KeyBindingsConfig.OpenPaimonMenu) => "打开派蒙界面",
|
||||
nameof(KeyBindingsConfig.OpenAdventurerHandbook) => "打开冒险之证界面",
|
||||
nameof(KeyBindingsConfig.OpenCoOpScreen) => "打开多人游戏界面",
|
||||
nameof(KeyBindingsConfig.OpenWishScreen) => "打开祈愿界面",
|
||||
nameof(KeyBindingsConfig.OpenBattlePassScreen) => "打开纪行界面",
|
||||
nameof(KeyBindingsConfig.OpenTheEventsMenu) => "打开活动面板",
|
||||
nameof(KeyBindingsConfig.OpenTheSettingsMenu) => "打开玩法系统界面(尘歌壶内猫尾酒馆内)",
|
||||
nameof(KeyBindingsConfig.OpenTheFurnishingScreen) => "打开摆设界面(尘歌壶内)",
|
||||
nameof(KeyBindingsConfig.OpenStellarReunion) => "打开星之归还(条件符合期间生效)",
|
||||
nameof(KeyBindingsConfig.OpenQuestMenu) => "开关任务菜单",
|
||||
nameof(KeyBindingsConfig.OpenNotificationDetails) => "打开通知详情",
|
||||
nameof(KeyBindingsConfig.OpenChatScreen) => "打开聊天界面",
|
||||
nameof(KeyBindingsConfig.OpenSpecialEnvironmentInformation) => "打开特殊环境说明",
|
||||
nameof(KeyBindingsConfig.CheckTutorialDetails) => "查看教程详情",
|
||||
nameof(KeyBindingsConfig.ElementalSight) => "长按打开元素视野",
|
||||
nameof(KeyBindingsConfig.ShowCursor) => "呼出鼠标",
|
||||
nameof(KeyBindingsConfig.OpenPartySetupScreen) => "打开队伍配置界面",
|
||||
nameof(KeyBindingsConfig.OpenFriendsScreen) => "打开好友界面",
|
||||
nameof(KeyBindingsConfig.HideUI) => "隐藏主界面",
|
||||
_ => propertyName
|
||||
};
|
||||
}
|
||||
|
||||
private void UpdateHotKeyConfig(HotKeySettingModel model)
|
||||
{
|
||||
var pi = Config.HotKeyConfig.GetType().GetProperty(model.ConfigPropertyName, BindingFlags.Public | BindingFlags.Instance);
|
||||
if (null != pi && pi.CanWrite)
|
||||
{
|
||||
pi.SetValue(Config.HotKeyConfig, model.HotKey.IsEmpty ? "" : model.HotKey.ToString(), null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除重复的快捷键配置
|
||||
/// </summary>
|
||||
|
||||
@@ -23,17 +23,10 @@ using BetterGenshinImpact.Service.Notification.Model.Enum;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Newtonsoft.Json;
|
||||
using Wpf.Ui.Controls;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using System.Windows.Controls;
|
||||
using ABI.Windows.UI.UIAutomation;
|
||||
using Wpf.Ui;
|
||||
using StackPanel = Wpf.Ui.Controls.StackPanel;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using TextBlock = Wpf.Ui.Controls.TextBlock;
|
||||
using System.Collections.Specialized;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
|
||||
@@ -93,7 +86,7 @@ public partial class OneDragonFlowViewModel : ViewModel
|
||||
private readonly string _scriptGroupPath = Global.Absolute(@"User\ScriptGroup");
|
||||
private readonly string _basePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
|
||||
private void ReadScriptGroup()
|
||||
public void ReadScriptGroup()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -147,19 +140,26 @@ public partial class OneDragonFlowViewModel : ViewModel
|
||||
|
||||
private async void AddNewTaskGroup()
|
||||
{
|
||||
ReadScriptGroup();
|
||||
var selectedGroupNamePick = await OnStartMultiScriptGroupAsync();
|
||||
if (selectedGroupNamePick == null)
|
||||
// 这个方法现在由XAML中的Popup处理,保留为空或者可以删除
|
||||
// 实际逻辑已经移到ProcessSelectedGroups方法中
|
||||
}
|
||||
|
||||
public void ProcessSelectedGroups(List<string> selectedGroupNames)
|
||||
{
|
||||
if (selectedGroupNames == null || !selectedGroupNames.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pickTaskCount = selectedGroupNamePick.Split(',').Count();
|
||||
foreach (var selectedGroupName in selectedGroupNamePick.Split(','))
|
||||
|
||||
int pickTaskCount = selectedGroupNames.Count;
|
||||
|
||||
foreach (var selectedGroupName in selectedGroupNames)
|
||||
{
|
||||
var taskItem = new OneDragonTaskItem(selectedGroupName)
|
||||
{
|
||||
IsEnabled = true
|
||||
};
|
||||
|
||||
if (TaskList.All(task => task.Name != taskItem.Name))
|
||||
{
|
||||
var names = selectedGroupName.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
@@ -167,6 +167,7 @@ public partial class OneDragonFlowViewModel : ViewModel
|
||||
.ToList();
|
||||
bool containsAnyDefaultGroup =
|
||||
names.Any(name => ScriptGroupsdefault.Any(defaultSg => defaultSg.Name == name));
|
||||
|
||||
if (containsAnyDefaultGroup)
|
||||
{
|
||||
int lastDefaultGroupIndex = -1;
|
||||
@@ -210,70 +211,11 @@ public partial class OneDragonFlowViewModel : ViewModel
|
||||
}
|
||||
if (pickTaskCount > 1)
|
||||
{
|
||||
Toast.Success(pickTaskCount + " 个任务添加成功");
|
||||
Toast.Success(pickTaskCount + " 个任务添加成功");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string?> OnStartMultiScriptGroupAsync()
|
||||
{
|
||||
var stackPanel = new StackPanel();
|
||||
var checkBoxes = new Dictionary<ScriptGroup, CheckBox>();
|
||||
CheckBox selectedCheckBox = null; // 用于保存当前选中的 CheckBox
|
||||
foreach (var scriptGroup in ScriptGroups)
|
||||
{
|
||||
if (TaskList.Any(taskName => scriptGroup.Name == taskName.Name))
|
||||
{
|
||||
continue; // 只有当文件名完全相同时才跳过显示
|
||||
}
|
||||
var checkBox = new CheckBox
|
||||
{
|
||||
Content = scriptGroup.Name,
|
||||
Tag = scriptGroup,
|
||||
IsChecked = false // 初始状态下都未选中
|
||||
};
|
||||
checkBoxes[scriptGroup] = checkBox;
|
||||
stackPanel.Children.Add(checkBox);
|
||||
}
|
||||
var uiMessageBox = new Wpf.Ui.Controls.MessageBox
|
||||
{
|
||||
Title = "选择增加的配置组(可多选)",
|
||||
Content = new ScrollViewer
|
||||
{
|
||||
Content = stackPanel,
|
||||
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
|
||||
},
|
||||
CloseButtonText = "关闭",
|
||||
PrimaryButtonText = "确认",
|
||||
Owner = Application.Current.ShutdownMode == ShutdownMode.OnMainWindowClose ? null : Application.Current.MainWindow,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
SizeToContent = SizeToContent.Width , // 确保弹窗根据内容自动调整大小
|
||||
MaxHeight = 600,
|
||||
};
|
||||
uiMessageBox.SourceInitialized += (s, e) => WindowHelper.TryApplySystemBackdrop(uiMessageBox);
|
||||
var result = await uiMessageBox.ShowDialogAsync();
|
||||
if (result == Wpf.Ui.Controls.MessageBoxResult.Primary)
|
||||
{
|
||||
List<string> selectedItems = new List<string>(); // 用于存储所有选中的项
|
||||
foreach (var checkBox in checkBoxes.Values)
|
||||
{
|
||||
if (checkBox.IsChecked == true)
|
||||
{
|
||||
// 确保 Tag 是 ScriptGroup 类型,并返回其 Name 属性
|
||||
var scriptGroup = checkBox.Tag as ScriptGroup;
|
||||
if (scriptGroup != null)
|
||||
{
|
||||
selectedItems.Add(scriptGroup.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.Error("配置组加载失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
return string.Join(",", selectedItems); // 返回所有选中的项
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// 原来的OnStartMultiScriptGroupAsync方法已被移除,功能已迁移到XAML Popup中
|
||||
|
||||
[ObservableProperty] private ObservableCollection<OneDragonFlowConfig> _configList = [];
|
||||
/// <summary>
|
||||
@@ -471,10 +413,13 @@ public partial class OneDragonFlowViewModel : ViewModel
|
||||
[RelayCommand]
|
||||
private void AddTaskGroup()
|
||||
{
|
||||
AddNewTaskGroup();
|
||||
SaveConfig();
|
||||
SelectedTask = null;
|
||||
// 触发弹窗显示的事件,让View层处理
|
||||
// 我们可以通过一个属性来通知View显示弹窗
|
||||
ShouldShowAddTaskGroupPopup = true;
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _shouldShowAddTaskGroupPopup = false;
|
||||
|
||||
[RelayCommand]
|
||||
private void SaveActionConfig()
|
||||
@@ -577,6 +522,10 @@ public partial class OneDragonFlowViewModel : ViewModel
|
||||
public async Task OnOneKeyExecute()
|
||||
{
|
||||
_logger.LogInformation($"启用一条龙配置:{SelectedConfig.Name}");
|
||||
|
||||
// 启动等待之前先进行取消操作的初始化,便于在任务开始前终止任务.
|
||||
CancellationContext.Instance.Set();
|
||||
|
||||
var taskListCopy = new List<OneDragonTaskItem>(TaskList);//避免执行过程中修改TaskList
|
||||
foreach (var task in taskListCopy)
|
||||
{
|
||||
@@ -610,6 +559,12 @@ public partial class OneDragonFlowViewModel : ViewModel
|
||||
_logger.LogInformation($"启用一条龙任务的数量: {enabledoneTaskCount}");
|
||||
|
||||
await ScriptService.StartGameTask();
|
||||
if (CancellationContext.Instance.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogInformation("一条龙在启动阶段被取消");
|
||||
return;
|
||||
}
|
||||
|
||||
SaveConfig();
|
||||
int enabledTaskCount = SelectedConfig.TaskEnabledList.Count(t =>
|
||||
t.Value && ScriptGroupsdefault.All(defaultTask => defaultTask.Name != t.Key));
|
||||
|
||||
@@ -106,6 +106,10 @@ public partial class MapViewerViewModel : ObservableObject
|
||||
{
|
||||
_mapImage = new Mat(Global.Absolute(@"Assets/Map/AncientSacredMountain/AncientSacredMountain_0_1024.png"));
|
||||
}
|
||||
else if (mapName == MapTypes.TempleOfSpace.ToString())
|
||||
{
|
||||
_mapImage = new Mat(Global.Absolute(@"Assets/Map/TempleOfSpace/TempleOfSpace_0_1024.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("暂时不支持展示路径的地图类型:" + mapName);
|
||||
|
||||
Reference in new issue
Block a user