mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
fix bug
This commit is contained in:
@@ -7,6 +7,8 @@ using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
@@ -38,7 +40,12 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
continue;
|
||||
}
|
||||
|
||||
var condition = PartyConditions.FirstOrDefault(c => c.Subject == "动作" && c.Object != null && c.Object.Contains(action));
|
||||
if (!ConditionDefinitions.ActionCnDic.TryGetValue(action, out var actionCn))
|
||||
{
|
||||
continue; // 不校验
|
||||
}
|
||||
|
||||
var condition = PartyConditions.FirstOrDefault(c => c.Subject == "动作" && c.Object.Contains(actionCn));
|
||||
if (condition is { Result: not null })
|
||||
{
|
||||
return condition.Result;
|
||||
@@ -47,14 +54,14 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
}
|
||||
|
||||
// 采集物匹配队伍名
|
||||
var materialCondition = PartyConditions.FirstOrDefault(c => c.Subject == "采集物" && c.Object != null && c.Object.Contains(materialName));
|
||||
var materialCondition = PartyConditions.FirstOrDefault(c => c.Subject == "采集物" && c.Object.Contains(materialName));
|
||||
if (materialCondition is { Result: not null })
|
||||
{
|
||||
return materialCondition.Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
materialCondition = PartyConditions.FirstOrDefault(c => c.Subject == "采集物" && c.Object != null && c.Object.Contains("全部"));
|
||||
materialCondition = PartyConditions.FirstOrDefault(c => c.Subject == "采集物" && c.Object.Contains("全部"));
|
||||
if (materialCondition is { Result: not null })
|
||||
{
|
||||
return materialCondition.Result;
|
||||
@@ -81,11 +88,20 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
if (avatarCondition is { Object: not null } && avatarCondition.Object.Contains(avatar.Name))
|
||||
{
|
||||
partyConfig.GuardianAvatarIndex = avatar.Index.ToString();
|
||||
partyConfig.GuardianElementalSkillSecondInterval = avatar.SkillCd.ToString(CultureInfo.CurrentCulture);
|
||||
partyConfig.GuardianElementalSkillLongPress = avatarCondition.Result == "循环长E";
|
||||
if (avatarCondition.Result == "循环长E")
|
||||
{
|
||||
partyConfig.GuardianElementalSkillLongPress = true;
|
||||
partyConfig.GuardianElementalSkillSecondInterval = avatar.SkillHoldCd.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
partyConfig.GuardianElementalSkillLongPress = false;
|
||||
partyConfig.GuardianElementalSkillSecondInterval = avatar.SkillCd.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(partyConfig.GuardianAvatarIndex))
|
||||
{
|
||||
break;
|
||||
@@ -105,6 +121,7 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(partyConfig.MainAvatarIndex))
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ElementalCollectAvatarConfigs
|
||||
// 风
|
||||
new ElementalCollectAvatar("砂糖", ElementalType.Anemo, true, true),
|
||||
new ElementalCollectAvatar("鹿野院平藏", ElementalType.Anemo, true, true),
|
||||
new ElementalCollectAvatar("散兵", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("流浪者", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("闲云", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("万叶", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("珐露珊", ElementalType.Anemo, false, true),
|
||||
|
||||
@@ -9,10 +9,12 @@ public class ActionEnum(string code, string msg)
|
||||
public static readonly ActionEnum NahidaCollect = new("nahida_collect", "纳西妲长按E收集");
|
||||
public static readonly ActionEnum PickAround = new("pick_around", "尝试在周围拾取");
|
||||
public static readonly ActionEnum Fight = new("fight", "战斗");
|
||||
public static readonly ActionEnum NormalAttack = new("normal_attack", "普通攻击");
|
||||
public static readonly ActionEnum ElementalSkill = new("elemental_skill", "元素战技");
|
||||
public static readonly ActionEnum UpDownGrabLeaf = new("up_down_grab_leaf", "四叶印");
|
||||
|
||||
public static readonly ActionEnum HydroCollect = new("hydro_collect", "水元素力采集");
|
||||
public static readonly ActionEnum ElectroCollect = new("electro_collect", "雷元素力采集");
|
||||
public static readonly ActionEnum AnemoCollect = new("anemo_collect", "风元素力采集");
|
||||
|
||||
// 还有要加入的其他动作
|
||||
// 滚轮F
|
||||
// 触发自动战斗任务
|
||||
|
||||
@@ -139,7 +139,7 @@ public class PathExecutor(CancellationToken ct)
|
||||
/// <summary>
|
||||
/// 切换队伍
|
||||
/// </summary>
|
||||
/// <param name="task"></param>
|
||||
/// <param name="partyName"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> SwitchParty(string? partyName)
|
||||
{
|
||||
@@ -150,6 +150,12 @@ public class PathExecutor(CancellationToken ct)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(RunnerContext.Instance.PartyName))
|
||||
{
|
||||
// 非空的情况下,先tp到安全位置(回血的七天神像)
|
||||
await new TpTask(ct).Tp(TpTask.ReviveStatueOfTheSevenPointX, TpTask.ReviveStatueOfTheSevenPointY, true);
|
||||
}
|
||||
|
||||
var success = await new SwitchPartyTask().Start(partyName, ct);
|
||||
if (success)
|
||||
{
|
||||
@@ -214,9 +220,9 @@ public class PathExecutor(CancellationToken ct)
|
||||
// 把所有需要切换的角色编号记录下来
|
||||
Dictionary<string, ElementalType> map = new()
|
||||
{
|
||||
{ "hydro_collect", ElementalType.Hydro },
|
||||
{ "electro_collect", ElementalType.Electro },
|
||||
{ "anemo_collect", ElementalType.Anemo }
|
||||
{ ActionEnum.HydroCollect.Code, ElementalType.Hydro },
|
||||
{ ActionEnum.ElectroCollect.Code, ElementalType.Electro },
|
||||
{ ActionEnum.AnemoCollect.Code, ElementalType.Anemo }
|
||||
};
|
||||
|
||||
foreach (var (action, el) in map)
|
||||
@@ -241,11 +247,14 @@ public class PathExecutor(CancellationToken ct)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.LogError("此路径存在 {action} 收集动作,队伍中没有对应元素角色:{},无法执行此路径!", action, string.Join(",", ElementalCollectAvatarConfigs.GetAvatarNameList(el)));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Logger.LogError("此路径存在 {action} 收集动作,队伍中没有对应元素角色:{},无法执行此路径!", action, string.Join(",", ElementalCollectAvatarConfigs.GetAvatarNameList(el)));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<WaypointForTrack> ConvertWaypointsForTrack(List<Waypoint> positions)
|
||||
@@ -433,7 +442,7 @@ public class PathExecutor(CancellationToken ct)
|
||||
|
||||
var ms = s * 1000;
|
||||
Debug.WriteLine($"元素战技释放间隔:{(now - _elementalSkillLastUseTime).TotalMilliseconds}ms");
|
||||
if ((now - _elementalSkillLastUseTime).TotalMilliseconds > ms)
|
||||
if ((DateTime.UtcNow - _elementalSkillLastUseTime).TotalMilliseconds > ms)
|
||||
{
|
||||
// 可能刚切过人在冷却时间内
|
||||
if (num <= 5 && (!string.IsNullOrEmpty(PartyConfig.MainAvatarIndex) && PartyConfig.GuardianAvatarIndex != PartyConfig.MainAvatarIndex))
|
||||
@@ -442,7 +451,7 @@ public class PathExecutor(CancellationToken ct)
|
||||
}
|
||||
|
||||
await UseElementalSkill();
|
||||
_elementalSkillLastUseTime = now;
|
||||
_elementalSkillLastUseTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,7 +528,7 @@ public class PathExecutor(CancellationToken ct)
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
stepsTaken++;
|
||||
if (stepsTaken > 20)
|
||||
if (stepsTaken > 30)
|
||||
{
|
||||
Logger.LogWarning("精确接近超时");
|
||||
break;
|
||||
@@ -537,7 +546,7 @@ public class PathExecutor(CancellationToken ct)
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 2);
|
||||
// 小碎步接近
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W).Sleep(60).KeyUp(User32.VK.VK_W);
|
||||
await Delay(50, ct);
|
||||
await Delay(20, ct);
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
@@ -561,8 +570,9 @@ public class PathExecutor(CancellationToken ct)
|
||||
if (waypoint.Action == ActionEnum.NahidaCollect.Code
|
||||
|| waypoint.Action == ActionEnum.PickAround.Code
|
||||
|| waypoint.Action == ActionEnum.Fight.Code
|
||||
|| waypoint.Action == ActionEnum.NormalAttack.Code
|
||||
|| waypoint.Action == ActionEnum.ElementalSkill.Code)
|
||||
|| waypoint.Action == ActionEnum.HydroCollect.Code
|
||||
|| waypoint.Action == ActionEnum.ElectroCollect.Code
|
||||
|| waypoint.Action == ActionEnum.AnemoCollect.Code)
|
||||
{
|
||||
var handler = ActionFactory.GetAfterHandler(waypoint.Action);
|
||||
await handler.RunAsync(ct);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SwitchPartyTask
|
||||
});
|
||||
|
||||
var currTeamName = string.Join("", currTeamNameRaList.Select(x => x.Text).Where(x => !string.IsNullOrWhiteSpace(x)));
|
||||
Logger.LogInformation("切换队伍,当前队伍名称: {Text}", currTeamName);
|
||||
// Logger.LogInformation("切换队伍,当前队伍名称: {Text}", currTeamName);
|
||||
if (currTeamName == partyName)
|
||||
{
|
||||
Logger.LogInformation("切换队伍,当前队伍[{Name}]即为目标队伍,无需切换", partyName);
|
||||
@@ -138,7 +138,7 @@ public class SwitchPartyTask
|
||||
{
|
||||
page.ClickTo(textRegion.Right, textRegion.Bottom + textRegion.Height * 2);
|
||||
await Delay(200, ct);
|
||||
Logger.LogInformation("切换到队伍: {Text}", textRegion.Text);
|
||||
Logger.LogInformation("切换队伍成功: {Text}", textRegion.Text);
|
||||
await ConfirmParty(page, ct);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -138,4 +138,12 @@ public class ConditionDefinitions
|
||||
public static List<string> AvatarSubjects { get; } = ["队伍中角色"];
|
||||
|
||||
public static List<string> AvatarResultList { get; } = ["循环短E", "循环长E", "主要行走角色"];
|
||||
|
||||
public static Dictionary<string, string> ActionCnDic { get; } = new()
|
||||
{
|
||||
{ "nahida_collect", "纳西妲采集" },
|
||||
{ "hydro_collect", "水元素采集" },
|
||||
{ "electro_collect", "雷元素采集" },
|
||||
{ "anemo_collect", "风元素采集" },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
|
||||
<ui:TextBlock Margin="0,0,0,8"
|
||||
FontTypography="BodyStrong"
|
||||
Text="角色设置" />
|
||||
Text="角色设置(存在多个符合条件的角色情况下,优先使用游戏内编队编号更小的)" />
|
||||
<!-- 使用ItemsControl来动态显示筛选条件 -->
|
||||
<ItemsControl ItemsSource="{Binding Config.PathingConditionConfig.AvatarConditions, Mode=TwoWay}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -241,7 +241,8 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
if (!fileInfo.Attributes.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
SelectedScriptGroup?.AddProject(ScriptGroupProject.BuildPathingProject(fileInfo.Name, fileInfo.Directory!.Name));
|
||||
var relativePath = Path.GetRelativePath(MapPathingViewModel.PathJsonPath, fileInfo.Directory!.FullName);
|
||||
SelectedScriptGroup?.AddProject(ScriptGroupProject.BuildPathingProject(fileInfo.Name, relativePath));
|
||||
}
|
||||
}
|
||||
else if (child is StackPanel childStackPanel)
|
||||
@@ -251,21 +252,21 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, List<FileInfo>> LoadAllPathingScripts()
|
||||
{
|
||||
var folder = Global.Absolute(@"User\AutoPathing");
|
||||
var directories = Directory.GetDirectories(folder);
|
||||
var result = new Dictionary<string, List<FileInfo>>();
|
||||
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
var dirInfo = new DirectoryInfo(directory);
|
||||
var files = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
|
||||
result.Add(dirInfo.Name, files);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
// private Dictionary<string, List<FileInfo>> LoadAllPathingScripts()
|
||||
// {
|
||||
// var folder = Global.Absolute(@"User\AutoPathing");
|
||||
// var directories = Directory.GetDirectories(folder);
|
||||
// var result = new Dictionary<string, List<FileInfo>>();
|
||||
//
|
||||
// foreach (var directory in directories)
|
||||
// {
|
||||
// var dirInfo = new DirectoryInfo(directory);
|
||||
// var files = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
|
||||
// result.Add(dirInfo.Name, files);
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private List<ScriptProject> LoadAllJsScriptProjects()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user