mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-09 00:34:14 +08:00
自动吃药相关问题修正,配置调整
This commit is contained in:
@@ -32,7 +32,7 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
|
||||
// 启用自动吃药功能
|
||||
[ObservableProperty]
|
||||
private bool _autoEatEnabled = true;
|
||||
private bool _autoEatEnabled = false;
|
||||
|
||||
public static PathingConditionConfig Default => new()
|
||||
{
|
||||
|
||||
@@ -214,6 +214,11 @@ public class AutoDomainTask : ISoloTask
|
||||
private void Init()
|
||||
{
|
||||
LogScreenResolution();
|
||||
if (_config.AutoEat)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().AddTrigger("AutoEat", null);
|
||||
}
|
||||
|
||||
if (_config.SpecifyResinUse)
|
||||
{
|
||||
Logger.LogInformation("→ {Text} 指定使用树脂", "自动秘境,");
|
||||
@@ -749,7 +754,7 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
if (!IsTakeFood())
|
||||
{
|
||||
Logger.LogInformation("未装备 “{Tool}”,不启用红血自动吃药功能", "便携营养袋");
|
||||
Logger.LogInformation("未装备 “{Tool}”,不启用红血自动吃药功能", "便携营养袋");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ public partial class AutoEatConfig : ObservableObject
|
||||
/// 检测间隔时间(毫秒)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _checkInterval = 500;
|
||||
private int _checkInterval = 150;
|
||||
|
||||
/// <summary>
|
||||
/// 吃药间隔时间(毫秒)
|
||||
/// 防止频繁吃药
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _eatInterval = 2000;
|
||||
private int _eatInterval = 1000;
|
||||
|
||||
/// <summary>
|
||||
/// 测试食物名称
|
||||
|
||||
@@ -31,6 +31,8 @@ public class AutoEatTrigger : ITaskTrigger
|
||||
private DateTime _lastResurrectionTime = DateTime.MinValue;
|
||||
private DateTime _lastEatTime = DateTime.MinValue;
|
||||
private bool _recoveryDetected = false;
|
||||
|
||||
private DateTime _prevExecute = DateTime.MinValue;
|
||||
|
||||
public AutoEatTrigger()
|
||||
{
|
||||
@@ -44,28 +46,17 @@ public class AutoEatTrigger : ITaskTrigger
|
||||
|
||||
public void OnCapture(CaptureContent content)
|
||||
{
|
||||
if (!IsEnabled)
|
||||
if ((DateTime.Now - _prevExecute).TotalMilliseconds <= _config.CheckInterval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_prevExecute = DateTime.Now;
|
||||
|
||||
try
|
||||
{
|
||||
using var ra = TaskControl.CaptureToRectArea();
|
||||
var ra = content.CaptureRectArea;
|
||||
var now = DateTime.Now;
|
||||
|
||||
// 优先检测复活图标,添加2秒CD
|
||||
if (CheckResurrection(ra))
|
||||
{
|
||||
// 检查复活CD(2秒)
|
||||
if ((now - _lastResurrectionTime).TotalSeconds >= 2)
|
||||
{
|
||||
// 按z键复活
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_Z);
|
||||
_lastResurrectionTime = now;
|
||||
_logger.LogInformation("检测到复活图标,自动复活");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 检测角色是否红血
|
||||
if (Bv.CurrentAvatarIsLowHp(ra))
|
||||
{
|
||||
@@ -92,10 +83,23 @@ public class AutoEatTrigger : ITaskTrigger
|
||||
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
|
||||
_lastEatTime = now;
|
||||
|
||||
_logger.LogInformation("检测到红血且Recovery可用,自动吃药");
|
||||
_logger.LogInformation("检测到红血且不在CD,自动吃药");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检测复活图标,添加2秒CD
|
||||
if (CheckResurrection(ra))
|
||||
{
|
||||
// 检查复活CD(2秒)
|
||||
if ((now - _lastResurrectionTime).TotalSeconds >= 2)
|
||||
{
|
||||
// 按z键复活
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_Z);
|
||||
_lastResurrectionTime = now;
|
||||
_logger.LogInformation("检测到复活图标,自动复活");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -147,6 +147,7 @@ public class TaskRunner
|
||||
}
|
||||
|
||||
// 还原实时任务触发器
|
||||
TaskTriggerDispatcher.Instance().ClearTriggers();
|
||||
TaskTriggerDispatcher.Instance().SetTriggers(GameTaskManager.LoadInitialTriggers());
|
||||
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
|
||||
@@ -689,18 +689,43 @@
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="显示通知"
|
||||
Text="触发时间间隔(毫秒)"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="是否在吃药时显示通知消息"
|
||||
Text="多少时间检查一次是否红血或需要复活"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
<ui:TextBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
Text="{Binding Config.AutoEatConfig.CheckInterval, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="吃药时间间隔(毫秒)"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="防止频繁吃药"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.AutoEatConfig.ShowNotification, Mode=TwoWay}" />
|
||||
Text="{Binding Config.AutoEatConfig.EatInterval, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
|
||||
Reference in New Issue
Block a user