mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-22 21:59:55 +08:00
* 在路径追踪重构了部分冷却处理逻辑,战斗脚本e增加wait参数可等待技能冷却而不是跳过。采矿e增加等待。尝试修复路径追踪 UseElementalSkill 与采矿脚本冲突的问题。 * 给CombatCommand加入快速跳过e的选项 * 优化技能冷却处理逻辑,增加OcrSkillCd属性以支持OCR识别的技能冷却时间,并调整相关技能CD计算和等待逻辑,尝试修复纳西妲采集终止时按键未弹起的问题 * 优化战斗任务中的技能冷却处理逻辑 * 更新纳西妲技能冷却时间记录,改为使用UTC时间并增加日志输出以便调试 * 增加最大技能CD检查,以排除系统时间/日期同步导致无限卡死。修复跑图路切人。(ps:主板电池没电应该去修主板) * 修复CheckAvatarAvailable * fix AutoFightTask skill cooldown logic and improve comments * 尝试修复脚本在"当前角色"下的小问题 * 尝试修复脚本在"当前角色"下的小问题,Avatar类结构调整,重新做了"根据技能cd优化出招"部分。 * Refactor avatar retrieval in PathingConditionConfig to use GetAvatars method and update skill cooldown references * Fix variable naming for clarity in CombatScenes * 在自动战斗执行前预先过滤不可执行的脚本。 --------- Co-authored-by: 辉鸭蛋 <huiyadanli@gmail.com>
96 lines
2.9 KiB
C#
96 lines
2.9 KiB
C#
using System;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using BetterGenshinImpact.Core.Simulator;
|
||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||
using Microsoft.Extensions.Logging;
|
||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||
|
||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||
|
||
/// <summary>
|
||
/// 使用纳西妲长按E技能进行收集,360°球形无死角扫码,`type = target`的情况才有效
|
||
/// </summary>
|
||
public class NahidaCollectHandler : IActionHandler
|
||
{
|
||
private DateTime lastETime = DateTime.MinValue;
|
||
|
||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||
{
|
||
Logger.LogInformation("执行 {Nhd} 长按E转圈拾取", "纳西妲");
|
||
|
||
var combatScenes = await RunnerContext.Instance.GetCombatScenes(ct);
|
||
if (combatScenes == null)
|
||
{
|
||
Logger.LogError("队伍识别未初始化成功!");
|
||
return;
|
||
}
|
||
|
||
// 切人
|
||
var nahida = combatScenes.SelectAvatar("纳西妲");
|
||
if (nahida is not null)
|
||
{
|
||
nahida.TrySwitch();
|
||
}
|
||
else
|
||
{
|
||
Logger.LogError("队伍中未找到纳西妲角色!");
|
||
return;
|
||
}
|
||
|
||
await nahida.WaitSkillCd(ct);
|
||
|
||
var dpi = TaskContext.Instance().DpiScale;
|
||
|
||
int x = (int)(400 * dpi), y = (int)(-30 * dpi);
|
||
int i = 60;
|
||
// 视角拉到最下面
|
||
Simulation.SendInput.Mouse.MoveMouseBy(0, 10000);
|
||
await Delay(200, ct);
|
||
|
||
// 按住E技能 无死角扫码
|
||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyDown);
|
||
try
|
||
{
|
||
await Delay(200, ct);
|
||
|
||
// 先地面来一圈
|
||
for (int j = 0; j < 15; j++)
|
||
{
|
||
Simulation.SendInput.Mouse.MoveMouseBy(x, 500);
|
||
await Delay(30, ct);
|
||
}
|
||
|
||
// 然后抬斜向转圈
|
||
while (!ct.IsCancellationRequested && i > 0)
|
||
{
|
||
i--;
|
||
if (i == 40)
|
||
{
|
||
y -= (int)(20 * dpi);
|
||
}
|
||
|
||
Simulation.SendInput.Mouse.MoveMouseBy(x, y);
|
||
await Delay(30, ct);
|
||
}
|
||
}
|
||
finally
|
||
{
|
||
// 就算被终止也要让按键弹回
|
||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyUp);
|
||
// 更新纳西妲CD
|
||
if (!ct.IsCancellationRequested)
|
||
{
|
||
await Delay(200, ct);
|
||
var cd = nahida.AfterUseSkill();
|
||
Logger.LogInformation("{Nhd} 长按E转圈,cd:{Cd}", "纳西妲", Math.Round(cd, 2));
|
||
}
|
||
}
|
||
|
||
await Delay(800, ct);
|
||
// 恢复视角
|
||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||
await Delay(1000, ct);
|
||
}
|
||
} |