diff --git a/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs b/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs index 82b4e36f..bf6f7bb2 100644 --- a/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs +++ b/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs @@ -329,7 +329,7 @@ public class AutoDomainTask : ISoloTask await Delay(1000, _ct); } - await Delay(1500, _ct); + await Delay(2000, _ct); } private List FindCombatScriptAndSwitchAvatar(CombatScenes combatScenes) @@ -354,7 +354,7 @@ public class AutoDomainTask : ISoloTask await Task.Run((Action)(() => { _simulator.SimulateAction(GIActions.MoveForward, KeyType.KeyDown); - Sleep(20); + Sleep(30, _ct); // 组合键好像不能直接用 postmessage if (!_config.WalkToF) { diff --git a/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs b/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs index c1a19717..4056d694 100644 --- a/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs +++ b/BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs @@ -174,14 +174,11 @@ public class TpTask(CancellationToken ct) await Delay(500, ct); } } - } + } } - public async Task<(double, double)> Tp(double tpX, double tpY, bool force = false) { - await checkInBigMapUi(); - for (var i = 0; i < 3; i++) { try @@ -259,30 +256,34 @@ public class TpTask(CancellationToken ct) double mouseDistance = Math.Sqrt(totalMoveMouseX * totalMoveMouseX + totalMoveMouseY * totalMoveMouseY); // 调整地图缩放 // mapZoomLevel<5 才显示传送锚点和秘境; - // mapZoomLevel<3 是为了避免部分锚点过于接近导致选错锚点; + // mapZoomLevel<2.5 是为了避免部分锚点过于接近导致选错锚点; // 风龙废墟无法避免,但是目前没有风龙废墟的脚本吧。:) // https://github.com/babalae/better-genshin-impact/issues/318 - if (mouseDistance < tolerance && currentZoomLevel < 2.5) - { - Logger.LogInformation($"移动 {iteration} 次鼠标后,已经接近目标点,不再进一步调整。"); - break; - } + + // 距离过远,缩小地图 while (mouseDistance > 5 * tolerance && currentZoomLevel < 4) - { // 缩小地图 + { await AdjustMapZoomLevel(false); totalMoveMouseX *= (currentZoomLevel) / (currentZoomLevel + 1); totalMoveMouseY *= (currentZoomLevel) / (currentZoomLevel + 1); mouseDistance *= (currentZoomLevel) / (currentZoomLevel + 1); currentZoomLevel++; } - while (mouseDistance < 2 * tolerance && currentZoomLevel > 2) - { // 放大地图 + // 距离过近,放大地图 + while (mouseDistance < 2 * tolerance && currentZoomLevel > 2.5) + { await AdjustMapZoomLevel(true); totalMoveMouseX *= (currentZoomLevel) / (currentZoomLevel - 1); totalMoveMouseY *= (currentZoomLevel) / (currentZoomLevel - 1); mouseDistance *= (currentZoomLevel) / (currentZoomLevel - 1); currentZoomLevel--; } + // 非常接近目标点,不再进一步调整 + if (mouseDistance < tolerance) + { + Logger.LogInformation("移动 {I} 次鼠标后,已经接近目标点,不再移动地图。", iteration + 1); + break; + } // 单次移动最大距离为 maxMouseMove moveMouseX = (int)Math.Min(totalMoveMouseX, maxMouseMove * totalMoveMouseX / mouseDistance) * Math.Sign(xOffset); @@ -297,7 +298,6 @@ public class TpTask(CancellationToken ct) } } - /// /// 调整地图缩放级别以加速移动 /// @@ -473,8 +473,6 @@ public class TpTask(CancellationToken ct) country = tpPosition.Country; } } - - // todo: 识别当前国家 return (recentX, recentY, country); } diff --git a/BetterGenshinImpact/GameTask/LogParse/LogParse.cs b/BetterGenshinImpact/GameTask/LogParse/LogParse.cs index 68053393..9ec4517b 100644 --- a/BetterGenshinImpact/GameTask/LogParse/LogParse.cs +++ b/BetterGenshinImpact/GameTask/LogParse/LogParse.cs @@ -213,7 +213,7 @@ namespace LogParse } // 定义文件名匹配的正则表达式 - string pattern = @"^better-genshin-impact(\d{8})\.log$"; + string pattern = @"^better-genshin-impact(\d{8})(_\d{3})*\.log$"; Regex regex = new Regex(pattern); // 遍历文件夹中的所有文件 diff --git a/BetterGenshinImpact/Genshin/Paths/UnityLogGameLocator.cs b/BetterGenshinImpact/Genshin/Paths/UnityLogGameLocator.cs index 55939921..c8ba86c0 100644 --- a/BetterGenshinImpact/Genshin/Paths/UnityLogGameLocator.cs +++ b/BetterGenshinImpact/Genshin/Paths/UnityLogGameLocator.cs @@ -12,7 +12,7 @@ namespace BetterGenshinImpact.Genshin.Paths; /// public partial class UnityLogGameLocator { - [GeneratedRegex(@".:/.+(?:GenshinImpact|YuanShen)(?=_Data)", RegexOptions.IgnoreCase)] + [GeneratedRegex(@".:(?:\\|/).+(?:GenshinImpact|YuanShen)(?=_Data)", RegexOptions.IgnoreCase)] private static partial Regex WarmupFileLine(); public static async ValueTask LocateSingleGamePathAsync() @@ -23,28 +23,19 @@ public partial class UnityLogGameLocator string logFilePathOversea = Path.Combine(appDataPath, @"..\LocalLow\miHoYo\Genshin Impact\output_log.txt"); string logFilePathChinese = Path.Combine(appDataPath, @"..\LocalLow\miHoYo\原神\output_log.txt"); - if (File.Exists(logFilePathChinese)) + var p1 = await LocateGamePathAsync(logFilePathChinese).ConfigureAwait(false); + if (p1 is not null) { - var p1 = await LocateGamePathAsync(logFilePathChinese).ConfigureAwait(false); - if (p1 is not null && File.Exists(p1)) - { - return p1; - } - } - - if (File.Exists(logFilePathOversea)) - { - var p2 = await LocateGamePathAsync(logFilePathOversea).ConfigureAwait(false); - if (p2 is not null && File.Exists(p2)) - { - return p2; - } + return p1; } + + return await LocateGamePathAsync(logFilePathOversea).ConfigureAwait(false); } catch (Exception e) { TaskControl.Logger.LogDebug(e, "Failed to locate game path."); } + return null; } @@ -73,8 +64,12 @@ public partial class UnityLogGameLocator return null; } - string entryName = $"{matchResult.Value}.exe"; - string fullPath = Path.GetFullPath(Path.Combine(matchResult.Value, "..", entryName)); + string fullPath = Path.GetFullPath($"{matchResult.Value}.exe"); + if (!File.Exists(fullPath)) + { + return null; + } + return fullPath; } } \ No newline at end of file diff --git a/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml b/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml index 28b98bf8..41a55e68 100644 --- a/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml +++ b/BetterGenshinImpact/View/Pages/TaskSettingsPage.xaml @@ -702,35 +702,6 @@ MinWidth="120" Text="{Binding Config.AutoFightConfig.Timeout}" /> - - - - - - - - - - - - - - @@ -1020,34 +991,6 @@ Margin="0,0,36,0" Text="{Binding Config.AutoDomainConfig.LeftRightMoveTimes, Mode=TwoWay}" /> - - - - - - - - - - - - - diff --git a/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml b/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml index 920e541f..7bc0760d 100644 --- a/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml +++ b/BetterGenshinImpact/View/Pages/View/ScriptGroupConfigView.xaml @@ -322,34 +322,6 @@ - - - - - - - - - - - - -