mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-25 22:29:47 +08:00
add log & pathing opt
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
@@ -16,6 +18,7 @@ internal class AutoFightHandler : IActionHandler
|
||||
|
||||
private async Task StartFight(CancellationTokenSource cts)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("执行 {Text}", "自动战斗");
|
||||
// 爷们要战斗
|
||||
var taskParams = new AutoFightParam(GetFightStrategy())
|
||||
{
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
@@ -13,6 +15,7 @@ public class ElementalSkillHandler : IActionHandler
|
||||
{
|
||||
public Task RunAsync(CancellationTokenSource cts)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("执行 {Text}", "释放元素战技");
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_E);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
@@ -16,6 +17,7 @@ public class NahidaCollectHandler : IActionHandler
|
||||
|
||||
public async Task RunAsync(CancellationTokenSource cts)
|
||||
{
|
||||
Logger.LogInformation("执行 {Nhd} 长按E转圈拾取", "纳西妲");
|
||||
var cd = DateTime.Now - lastETime;
|
||||
if (cd < TimeSpan.FromSeconds(10))
|
||||
{
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 触发元素战技
|
||||
/// 触发普通攻击
|
||||
/// </summary>
|
||||
public class NormalAttackHandler : IActionHandler
|
||||
{
|
||||
public Task RunAsync(CancellationTokenSource cts)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("执行 {Text}", "普通攻击");
|
||||
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -261,12 +261,11 @@ public class PathExecutor(CancellationTokenSource cts)
|
||||
}
|
||||
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 2);
|
||||
var wPressed = false;
|
||||
var stepsTaken = 0;
|
||||
while (!cts.IsCancellationRequested)
|
||||
{
|
||||
stepsTaken++;
|
||||
if (stepsTaken > 12)
|
||||
if (stepsTaken > 20)
|
||||
{
|
||||
Logger.LogWarning("精确接近超时");
|
||||
break;
|
||||
@@ -280,27 +279,16 @@ public class PathExecutor(CancellationTokenSource cts)
|
||||
break;
|
||||
}
|
||||
|
||||
_rotateTask.RotateToApproach(targetOrientation, screen); //不再改变视角
|
||||
if (waypoint.MoveMode == MoveModeEnum.Walk.Code)
|
||||
{
|
||||
// 小碎步接近
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W).Sleep(60).KeyUp(User32.VK.VK_W);
|
||||
await Delay(200, cts);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!wPressed)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
}
|
||||
|
||||
await Delay(100, cts);
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 2);
|
||||
// 小碎步接近
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W).Sleep(60).KeyUp(User32.VK.VK_W);
|
||||
await Delay(50, cts);
|
||||
}
|
||||
|
||||
if (wPressed)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
}
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
|
||||
// 到达目的地后停顿一秒
|
||||
await Delay(1000, cts);
|
||||
}
|
||||
|
||||
private async Task AfterMoveToTarget(Waypoint waypoint)
|
||||
@@ -311,6 +299,7 @@ public class PathExecutor(CancellationTokenSource cts)
|
||||
{
|
||||
var handler = ActionFactory.GetHandler(waypoint.Action);
|
||||
await handler.RunAsync(cts);
|
||||
await Delay(800, cts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user