diff --git a/BetterGenshinImpact/GameTask/AutoPathing/PathExecutor.cs b/BetterGenshinImpact/GameTask/AutoPathing/PathExecutor.cs
index 688c1790..245ef7ee 100644
--- a/BetterGenshinImpact/GameTask/AutoPathing/PathExecutor.cs
+++ b/BetterGenshinImpact/GameTask/AutoPathing/PathExecutor.cs
@@ -44,6 +44,11 @@ public class PathExecutor(CancellationToken ct)
set => _partyConfig = value;
}
+ ///
+ /// 判断是否中止路径追踪的条件
+ ///
+ public Func? EndAction { get; set; }
+
private CombatScenes? _combatScenes;
// private readonly Dictionary _actionAvatarIndexMap = new();
@@ -97,6 +102,7 @@ public class PathExecutor(CancellationToken ct)
{
try
{
+ await ResolveAnomalies(); // 异常场景处理
foreach (var waypoint in waypoints)
{
await RecoverWhenLowHp(); // 低血量恢复
@@ -122,6 +128,11 @@ public class PathExecutor(CancellationToken ct)
break;
}
+ catch (NormalEndException normalEndException)
+ {
+ Logger.LogInformation(normalEndException.Message);
+ break;
+ }
catch (RetryException retryException)
{
Logger.LogWarning(retryException.Message);
@@ -131,7 +142,6 @@ public class PathExecutor(CancellationToken ct)
// 不管咋样,松开所有按键
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
Simulation.SendInput.Mouse.RightButtonUp();
- await ResolveAnomalies(); // 异常场景处理
}
}
}
@@ -150,6 +160,7 @@ public class PathExecutor(CancellationToken ct)
{
Logger.LogError("游戏窗口分辨率不是 16:9 !当前分辨率为 {Width}x{Height} , 非 16:9 分辨率的游戏无法正常使用路径追踪功能!", gameScreenSize.Width, gameScreenSize.Height);
}
+
if (gameScreenSize.Width < 1920 || gameScreenSize.Height < 1080)
{
Logger.LogError("游戏窗口分辨率小于 1920x1080 !当前分辨率为 {Width}x{Height} , 小于 1920x1080 的分辨率的游戏路径追踪的效果非常差!", gameScreenSize.Width, gameScreenSize.Height);
@@ -351,6 +362,9 @@ public class PathExecutor(CancellationToken ct)
}
screen = CaptureToRectArea();
+
+ EndJudgment(screen);
+
position = await GetPosition(screen);
var distance = Navigation.GetDistance(waypoint, position);
Debug.WriteLine($"接近目标点中,距离为{distance}");
@@ -555,6 +569,9 @@ public class PathExecutor(CancellationToken ct)
}
screen = CaptureToRectArea();
+
+ EndJudgment(screen);
+
position = await GetPosition(screen);
if (Navigation.GetDistance(waypoint, position) < 2)
{
@@ -695,4 +712,12 @@ public class PathExecutor(CancellationToken ct)
}
}
}
+
+ private void EndJudgment(ImageRegion ra)
+ {
+ if (EndAction != null && EndAction(ra))
+ {
+ throw new NormalEndException("达成结束条件,结束路径追踪");
+ }
+ }
}
diff --git a/BetterGenshinImpact/GameTask/Common/Element/Assets/Json/冒险家协会_枫丹.json b/BetterGenshinImpact/GameTask/Common/Element/Assets/Json/冒险家协会_枫丹.json
index d9b4b5fd..ec1d9eba 100644
--- a/BetterGenshinImpact/GameTask/Common/Element/Assets/Json/冒险家协会_枫丹.json
+++ b/BetterGenshinImpact/GameTask/Common/Element/Assets/Json/冒险家协会_枫丹.json
@@ -20,7 +20,7 @@
"id": 2,
"x": 4495.0,
"y": 3638.0,
- "type": "path",
+ "type": "target",
"move_mode": "walk",
"action": ""
}
diff --git a/BetterGenshinImpact/GameTask/Common/Job/GoToAdventurersGuildTask.cs b/BetterGenshinImpact/GameTask/Common/Job/GoToAdventurersGuildTask.cs
index 6257a6ed..e30d6450 100644
--- a/BetterGenshinImpact/GameTask/Common/Job/GoToAdventurersGuildTask.cs
+++ b/BetterGenshinImpact/GameTask/Common/Job/GoToAdventurersGuildTask.cs
@@ -46,24 +46,15 @@ public class GoToAdventurersGuildTask
}
}
}
+
Logger.LogInformation("→ {Name} 结束", Name);
}
public async Task DoOnce(string country, CancellationToken ct)
{
- // 1. 走到冒险家协会
+ // 1. 走到冒险家协会并对话
await GoToAdventurersGuild(country, ct);
- // 2. 交互
- var ra = CaptureToRectArea();
- if (!Bv.FindFAndPress(ra, "凯瑟琳"))
- {
- throw new Exception("未找与凯瑟琳对话交互按钮");
- }
-
- // 3. 等待对话界面
- await Delay(200, ct);
-
// 每日
var res = await _chooseTalkOptionTask.SingleSelectText("每日", ct, 10, true);
if (res == TalkOptionRes.FoundAndClick)
@@ -76,7 +67,7 @@ public class GoToAdventurersGuildTask
// 结束后重新打开
await Delay(200, ct);
- ra = CaptureToRectArea();
+ var ra = CaptureToRectArea();
if (!Bv.FindFAndPress(ra, "凯瑟琳"))
{
throw new Exception("未找与凯瑟琳对话交互按钮");
@@ -130,10 +121,17 @@ public class GoToAdventurersGuildTask
{
Enabled = true,
AutoSkipEnabled = true
- }
+ },
+ EndAction = region => Bv.FindFAndPress(region, "凯瑟琳")
};
await pathingTask.Pathing(task);
- await Delay(500, ct);
+ await Delay(300, ct);
+
+ using var ra = CaptureToRectArea();
+ if (!Bv.IsInTalkUi(ra))
+ {
+ throw new Exception("未找与凯瑟琳对话交互按钮");
+ }
}
}
diff --git a/BetterGenshinImpact/GameTask/Common/Job/GoToCraftingBenchTask.cs b/BetterGenshinImpact/GameTask/Common/Job/GoToCraftingBenchTask.cs
index e548833b..c1844f3f 100644
--- a/BetterGenshinImpact/GameTask/Common/Job/GoToCraftingBenchTask.cs
+++ b/BetterGenshinImpact/GameTask/Common/Job/GoToCraftingBenchTask.cs
@@ -52,18 +52,10 @@ public class GoToCraftingBenchTask
public async Task DoOnce(string country, CancellationToken ct)
{
- // 1. 走到合成台
+ // 1. 走到合成台并交互
await GoToCraftingBench(country, ct);
- // 2. 交互
- var ra = CaptureToRectArea();
- if (!Bv.FindFAndPress(ra, "合成"))
- {
- throw new Exception("未找与合成台交互按钮");
- }
-
- // 3. 等待合成界面
- await Delay(100, ct);
+ // 2. 等待合成界面
await _chooseTalkOptionTask.SelectLastOptionUntilEnd(ct,
region => region.Find(ElementAssets.Instance.BtnWhiteConfirm).IsExist()
);
@@ -71,7 +63,7 @@ public class GoToCraftingBenchTask
// 判断浓缩树脂是否存在
// TODO 满的情况是怎么样子的
- ra = CaptureToRectArea();
+ var ra = CaptureToRectArea();
var resin = ra.Find(ElementAssets.Instance.CraftCondensedResin);
if (resin.IsExist())
{
@@ -100,16 +92,24 @@ public class GoToCraftingBenchTask
public async Task GoToCraftingBench(string country, CancellationToken ct)
{
var task = PathingTask.BuildFromFilePath(Global.Absolute(@$"GameTask\Common\Element\Assets\Json\合成台_{country}.json"));
+
var pathingTask = new PathExecutor(ct)
{
PartyConfig = new PathingPartyConfig
{
Enabled = true,
AutoSkipEnabled = true
- }
+ },
+ EndAction = region => Bv.FindFAndPress(region, "合成")
};
await pathingTask.Pathing(task);
- await Delay(500, ct);
+ await Delay(300, ct);
+
+ using var ra = CaptureToRectArea();
+ if (!Bv.IsInTalkUi(ra))
+ {
+ throw new Exception("未找与合成台交互按钮");
+ }
}
}