mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
修复移动地图时概率持续点击标记。
This commit is contained in:
@@ -19,7 +19,6 @@ using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Common.Exceptions;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
|
||||
@@ -152,7 +151,7 @@ public class TpTask(CancellationToken ct)
|
||||
return (clickX, clickY);
|
||||
}
|
||||
|
||||
private async Task checkInBigMapUi()
|
||||
public async Task<(double, double)> Tp(double tpX, double tpY, bool force = false)
|
||||
{
|
||||
// M 打开地图识别当前位置,中心点为当前位置
|
||||
var ra1 = CaptureToRectArea();
|
||||
@@ -164,7 +163,7 @@ public class TpTask(CancellationToken ct)
|
||||
await Delay(1000, ct);
|
||||
ra1 = CaptureToRectArea();
|
||||
}
|
||||
Simulation.SendInput.SimulateAction(GIActions.OpenMap);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_M);
|
||||
await Delay(1000, ct);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
@@ -174,14 +173,8 @@ 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
|
||||
@@ -198,7 +191,6 @@ public class TpTask(CancellationToken ct)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await checkInBigMapUi();
|
||||
Logger.LogError("传送失败,重试 {I} 次", i + 1);
|
||||
Logger.LogDebug(e, "传送失败,重试 {I} 次", i + 1);
|
||||
}
|
||||
@@ -259,34 +251,33 @@ 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("移动 {I} 次鼠标后,已经接近目标点,不再进一步调整。", iteration + 1);
|
||||
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 && currentZoomLevel < 2.5)
|
||||
{
|
||||
Logger.LogInformation("移动 {I} 次鼠标后,已经接近目标点,不再进一步调整。", iteration + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 非常接近目标点,不再进一步调整
|
||||
if (mouseDistance < tolerance)
|
||||
{
|
||||
Logger.LogInformation("移动 {I} 次鼠标后,已经接近目标点,不再移动地图。", iteration + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
// 单次移动最大距离为 maxMouseMove
|
||||
@@ -302,7 +293,6 @@ public class TpTask(CancellationToken ct)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 调整地图缩放级别以加速移动
|
||||
/// </summary>
|
||||
@@ -478,8 +468,6 @@ public class TpTask(CancellationToken ct)
|
||||
country = tpPosition.Country;
|
||||
}
|
||||
}
|
||||
|
||||
// todo: 识别当前国家
|
||||
return (recentX, recentY, country);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user