Skip to content

Commit 9b420d8

Browse files
committed
fix: 修复钓鱼异常退出,修改agent出口为钓上鱼/鱼溜走/在钓鱼界面
1 parent bf88a54 commit 9b420d8

7 files changed

Lines changed: 28 additions & 11 deletions

File tree

agent/custom/action/AutoFish/auto_fish_withoutCV.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def run(
2020
self, context: Context, argv: CustomAction.RunArg
2121
) -> CustomAction.RunResult:
2222
deadzone = 15 # 光标与绿条中心的距离在 deadzone(像素)以内时不操作,避免过度频繁地轻微调整导致的抖动
23-
max_try_item = 5 # 识别不完整(绿条或光标未命中)的最大尝试次数,超过后放弃本次钓鱼,重新抛竿(执行 FishHook)
2423
factor = 1.5 # 控条时长的调整因子,实际时长 = 基础时长 * factor,基础时长 = (光标与绿条中心的像素偏移 / CURSOR_PX_PER_SEC) * 1000ms,增加 factor 可以适当补偿识别误差和按键响应延迟
2524
cap_ms = (
2625
1500 # 控条时长的上限(毫秒),避免因识别到较大偏移时按键过久,导致过度补偿
@@ -32,7 +31,6 @@ def run(
3231
try:
3332
params = json.loads(argv.custom_action_param)
3433
deadzone = params.get("deadzone", deadzone)
35-
max_try_item = params.get("max_try", max_try_item)
3634
factor = params.get("factor", factor)
3735
cap_ms = params.get("cap_ms", cap_ms)
3836
floor_ms = params.get("floor_ms", floor_ms)
@@ -48,7 +46,7 @@ def run(
4846
green_bar = context.run_recognition("FishGreenBar", image)
4947
cursor = context.run_recognition("FishCursor", image)
5048

51-
if not (
49+
while not (
5250
green_bar
5351
and green_bar.hit
5452
and green_bar.box
@@ -62,17 +60,20 @@ def run(
6260
click_blank = context.run_recognition("SceneClickBlankToExit", image)
6361
if click_blank and click_blank.hit:
6462
PrintT(context, "autofish.fish_caught")
63+
logger.debug("识别到钓上鱼, 钓鱼退出")
6564
return CustomAction.RunResult(success=True)
6665

67-
max_try_item -= 1
68-
logger.debug(
69-
f"识别不完整(绿条或光标未命中),剩余尝试次数: {max_try_item}"
70-
)
71-
72-
if max_try_item <= 0:
73-
logger.debug("尝试次数用尽,控条失败")
66+
fish_escape = context.run_recognition("FishEscape", image)
67+
if fish_escape and fish_escape.hit:
68+
PrintT(context, "autofish.fish_escape")
69+
logger.debug("识别到鱼溜走,钓鱼退出")
70+
return CustomAction.RunResult(success=True)
71+
fish_on_gaming = context.run_recognition("FishSceneOnFishGame", image)
72+
if fish_on_gaming and fish_on_gaming.hit:
73+
Print(
74+
"钓鱼异常结束(可能是鱼溜走),继续钓鱼"
75+
) # 通常不会执行这一步
7476
return CustomAction.RunResult(success=True)
75-
# 看来就是通过识别失败几次直接通用适配成功/失败的情况的,不用管,根本没有去识别有没有钓到
7677
continue
7778

7879
green_bar_x, green_bar_y, green_bar_w, green_bar_h = green_bar.box

assets/resource/base/pipeline/Fish/FishStatus.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@
5757
}
5858
}
5959
},
60+
"FishEscape": {
61+
"desc": "鱼逃走",
62+
"recognition": "OCR",
63+
"expected": [
64+
"鱼儿溜走了",
65+
"The fish got away!"
66+
],
67+
"pre_delay": 0,
68+
"post_delay": 0,
69+
"rate_limit": 0
70+
},
6071
"FishTest": {
6172
"post_delay": 0,
6273
"pre_delay": 0,

assets/resource/locales/agent/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"autofish.fish_caught": "Fish hooked!",
3+
"autofish.fish_escape": "Fish escaped!",
34
"autofish.task_end": "Fishing task ended",
45
"autofish.started": "=== Auto Fishing Started ===",
56
"autofish.progress": "=== Fishing %d/%d ===",

assets/resource/locales/agent/ja_jp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"autofish.fish_caught": "魚がかかりました!",
3+
"autofish.fish_escape": "魚が逃げました!",
34
"autofish.task_end": "釣りタスク終了",
45
"autofish.started": "=== 自動釣り開始 ===",
56
"autofish.progress": "=== 釣り %d/%d ===",

assets/resource/locales/agent/ko_kr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"autofish.fish_caught": "물고기가 걸렸습니다!",
3+
"autofish.fish_escape": "물고기가 도망갔습니다!",
34
"autofish.task_end": "낚시 작업 종료",
45
"autofish.started": "=== 자동 낚시 시작 ===",
56
"autofish.progress": "=== 낚시 %d/%d ===",

assets/resource/locales/agent/zh_cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"autofish.fish_caught": "钓上鱼了!",
3+
"autofish.fish_escape": "鱼逃走了!",
34
"autofish.task_end": "钓鱼任务结束",
45
"autofish.started": "=== 自动钓鱼已启动 ===",
56
"autofish.progress": "=== 钓鱼 %d/%d ===",

assets/resource/locales/agent/zh_tw.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"autofish.fish_caught": "釣上魚了!",
3+
"autofish.fish_escape": "魚逃走了!",
34
"autofish.task_end": "釣魚任務結束",
45
"autofish.started": "=== 自動釣魚已啟動 ===",
56
"autofish.progress": "=== 釣魚 %d/%d ===",

0 commit comments

Comments
 (0)