Mobile step 6: client-side auto hunt with AUTO button

Engine-free AutoHunt state machine (search/engage/loot/return/paused) driven
from the game loop through the existing manual paths: move target, target
packet, normal attack, quickslot skills, item pick-up and belt potions.
player.SetAutoHunt/GetAutoHuntState/SetAutoHuntOption with autohunt.cfg;
AUTO button on the combat wheel (tap toggles, long press opens settings).
Tests: ava2.auto_hunt, extended ava2.touch_game; 54/54.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-12 22:05:15 +09:00
co-authored by Claude Opus 5.5
parent ed2c185135
commit 64d25e3571
13 changed files with 1085 additions and 2 deletions
+2 -2
View File
@@ -122,7 +122,7 @@ Python 更新(原版脚本 + mobile HUD)
| 攻击键外圈 / 底部 | 技能圈、药水栏、翻页 | 原版快捷栏(4 页) | 技能圈对应技能格,底部栏对应道具格 |
| 攻击键附近 | 骑乘、拾取、锁定目标 | `player.PickCloseItem`;骑乘/锁定接口待核对 | 小按钮 |
| 屏幕空白处 | 转镜头、双指缩放 | `app.RotateCamera`;镜头距离接口待核对 | C++ 手势识别 |
| 可选 | 自动战斗 | 原版没有 | 客户端新功能,最后做 |
| 技能圈旁 | 自动狩猎(AUTO 键) | 原版没有 | 客户端新功能:轻点开关、长按设置;已完成(第 6 步) |
注意事项:
@@ -144,6 +144,6 @@ Python 更新(原版脚本 + mobile HUD)
3. `input/`:触摸分流、虚拟摇杆、攻击键、镜头手势——可在手机上移动和战斗。
4. `mobile/`:手机 HUD(状态面板、技能圈和快捷栏、右上角入口、小地图、左侧按钮)。
5. 界面缩放和安全区域收尾。
6. 自动战斗等新增功能;iOS 打包与 `app_loop` 拆分。
6. 自动战斗等新增功能(自动狩猎已完成,见 PORT-PLAN);iOS 打包与 `app_loop` 拆分。
第 3、4 步大部分可在 macOS 上开发(鼠标模拟单指,触控板测双指);多指同时操作和性能需要真机验证。
+41
View File
@@ -1337,3 +1337,44 @@ real cutout insets); a window size change at runtime (split screen,
foldable) keeps the logical size chosen at start; no in-game UI size option
yet (only `--ui-height` / env); original PC windows (inventory etc.) are
not rearranged for 600 px height.
### 2026-10-12 Mobile step 6 — auto hunt
Client-only feature (the original client has none; not taken from 40250).
It only drives paths that manual play already uses: walk-to (move target),
target packet, the normal attack, quickslot skills, item pick-up and
quickslot potions. Nothing new goes on the wire.
- `src/game/auto_hunt.{h,cpp}`: engine-free state machine
(off / search / engage / loot / return / paused). Hunts the nearest living
mob within `radius` of an anchor point (metin stones optional), loots own
or unowned drops before the next mob, walks back to the anchor when the
area is empty, and gives up on a target whose distance stops shrinking for
8 s (ignored for 30 s). Joystick / attack key / mouse movement pause it;
it resumes 3 s after the last input and re-anchors where the player
stopped. HP / SP potions (belt slots 1 / 2, quickslot 24 / 25) are checked
in every state with a 1 s gap. Death turns it off.
- `ProcessAutoHunt()` (python_gameplay_modules.cpp, called from the game loop
before `ProcessPlayerAttack`) builds the input from NetworkActorManager
(mobs bType 0/2), `CPythonItem::GetGroundItems()` (new read accessor) and
the combat wheel's current skill page, skipping skills on cooldown, active
toggles, 121-123 and guild skills.
- Python: `player.SetAutoHunt / IsAutoHunt / GetAutoHuntState /
SetAutoHuntOption / GetAutoHuntOption`; options (radius, skills, pickup,
stones, hp_percent, sp_percent, hp_slot, sp_slot) persist in
`autohunt.cfg` next to metin2.cfg.
- `ui_mobile_autohunt.py`: AUTO button on the combat wheel (tap toggles,
green while on with the state under it; 0.6 s long press opens the settings
board with range / skills / pick-up / stones / potion thresholds).
Verified: `ava2.auto_hunt` (targeting, range stop, skill gap, busy, loot
before next mob, area and stone filter, return, chase watchdog, pause /
resume / re-anchor, potions, death), `ava2.touch_game` (AUTO is UI under the
finger, tap on/off, engage + target VID + move target, stop in reach,
joystick pauses, long press opens settings, option persistence), 54/54
desktop tests, HUD screenshot shows AUTO above Ride.
Outstanding: not run on a device or against the server (ownership timing,
pick-up refusals, attack speed); straight-line walking only, the stuck
watchdog is the only obstacle handling; party loot rules ignored (only own /
unowned drops); no desktop hotkey (F9 is taken by the preview mode);
English labels, no locale strings; does not run in `--preview-data`.