Skip to content

feat(GiftOperator): 新增赠送干员礼物功能#985

Merged
MistEO merged 17 commits intoMaaEnd:mainfrom
KrAu2k:feat/gift-operator
Mar 7, 2026
Merged

feat(GiftOperator): 新增赠送干员礼物功能#985
MistEO merged 17 commits intoMaaEnd:mainfrom
KrAu2k:feat/gift-operator

Conversation

@KrAu2k
Copy link
Contributor

@KrAu2k KrAu2k commented Mar 4, 2026

新增
任务 GiftOperator(赠送干员礼物):从帝江号舰桥前往干员联络台,自动与干员交互、赠送/领取礼物
任务选项 GiftOperatorMoveMode:支持「预制操作」和「识别寻路(MapTracker)」两种移动方式
Pipeline 流程:assets/resource/pipeline/GiftOperator.json,包含寻路、交互、送礼/领礼、重试等节点
任务配置:assets/tasks/GiftOperator.json,定义任务入口和选项
修改
agent/go-service/register.go:删除 input-replay 相关导入与注册
assets/misc/locales/*.json:补充 GiftOperator 任务和 GiftOperatorMoveMode 选项的本地化
删除
agent/go-service/input-replay/:整个 input-replay 包移除,改为用 Pipeline 的 LongPressKey + post_delay 实现录制逻辑
技术说明
两种移动路线前都会按 Shift 恢复跑步模式并等待约 500ms
部分节点配置 on_error -> GiftOperatorRetryCleanupAlt,失败时自动清理 Alt 并重试
GiftOperator 需要 Win32-Front 控制器,建议优先使用「预制操作」模式

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些高层次的反馈:

  • 考虑在 parseParam 中对 Steps 输入做更严格的校验(例如:t 值非负且单调递增、Action/Key 值必须在允许范围内),这样可以在发送任意按键事件之前就让格式错误的录制尽早失败。
  • 目前回放循环在调用 PostKeyDown/PostKeyUp().Wait() 时没有检查错误或超时;如果控制器调用失败或卡住,这可能会阻塞任务,所以建议在这些等待操作外层增加错误处理或超时机制,以提升回放的健壮性。
  • 由于 releaseAll 目前是把 W/A 写死在代码里,可能更安全的做法是要么从 keyNameToCode 中动态推导需要释放的按键,要么强制只允许这两个键,以避免将来增加更多键时出现不一致。
给 AI Agents 的提示
Please address the comments from this code review:

## Overall Comments
- Consider validating the `Steps` input more strictly in `parseParam` (e.g., non-negative and monotonically increasing `t` values, allowed `Action`/`Key` values) so that malformed recordings fail fast before any key events are sent.
- Right now the replay loop calls `PostKeyDown`/`PostKeyUp().Wait()` without checking for errors or timeouts; if the controller call fails or hangs, this could block the task, so adding error handling or a timeout around these waits would make the replay more robust.
- Since `releaseAll` is hardcoded to W/A, it might be safer to either derive the keys to release dynamically from `keyNameToCode` or to enforce that only those keys are allowed, to avoid inconsistencies if more keys are added later.

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • Consider validating the Steps input more strictly in parseParam (e.g., non-negative and monotonically increasing t values, allowed Action/Key values) so that malformed recordings fail fast before any key events are sent.
  • Right now the replay loop calls PostKeyDown/PostKeyUp().Wait() without checking for errors or timeouts; if the controller call fails or hangs, this could block the task, so adding error handling or a timeout around these waits would make the replay more robust.
  • Since releaseAll is hardcoded to W/A, it might be safer to either derive the keys to release dynamically from keyNameToCode or to enforce that only those keys are allowed, to avoid inconsistencies if more keys are added later.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider validating the `Steps` input more strictly in `parseParam` (e.g., non-negative and monotonically increasing `t` values, allowed `Action`/`Key` values) so that malformed recordings fail fast before any key events are sent.
- Right now the replay loop calls `PostKeyDown`/`PostKeyUp().Wait()` without checking for errors or timeouts; if the controller call fails or hangs, this could block the task, so adding error handling or a timeout around these waits would make the replay more robust.
- Since `releaseAll` is hardcoded to W/A, it might be safer to either derive the keys to release dynamically from `keyNameToCode` or to enforce that only those keys are allowed, to avoid inconsistencies if more keys are added later.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@MistEO MistEO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pipeline 里 mpe 的配置请删一下(设置里选择分离导出或者不导出)

然后 submodule 要更新一下

git submodule update --init

@KrAu2k
Copy link
Contributor Author

KrAu2k commented Mar 7, 2026

@MistEO
整个 input-replay 包移除,改为用 Pipeline 的 LongPressKey + post_delay 实现录制逻辑
支持「预制操作」和「识别寻路(MapTracker)」两种移动方式

@MistEO
Copy link
Contributor

MistEO commented Mar 7, 2026

预制操作 在各不相同的用户电脑上一定是更不稳定的,我几乎可以打包票。

不过我们也可以先合进去看看用户反馈,万一呢()

"type": "OCR"
}
},
"GiftOperatorShiftToRunMapTracker": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前无需在调用 MapTrackerMove 之前手动恢复跑步:MapTrackerMove 会自动处理走-跑切换。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那这个要改吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那这个要改吗

不用吧,我预制跑步得用这个,后面可以把MapTracker的去了

@MistEO MistEO merged commit dc881d2 into MaaEnd:main Mar 7, 2026
17 checks passed
MistEO pushed a commit that referenced this pull request Mar 9, 2026
MistEO pushed a commit that referenced this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants