muffin v7.4.9

This commit is contained in:
alydev 2026-01-01 09:34:51 +10:00
parent a9e1cdc5f1
commit 2df81c5d15
5 changed files with 5320 additions and 4932 deletions

View file

@ -263,18 +263,25 @@ internal static class Duty
internal sealed class StartLevelingModeExecutor(AutoDutyIpc autoDutyIpc, ICondition condition, ILogger<StartLevelingModeExecutor> logger) : TaskExecutor<StartLevelingModeTask>(), IStoppableTaskExecutor, ITaskExecutor
{
private bool _started;
private DateTime _startTime;
private DateTime _lastRetryTime = DateTime.MinValue;
protected override bool Start()
{
logger.LogInformation("Starting AutoDuty Leveling mode to reach level {RequiredLevel} for quest '{QuestName}'", base.Task.RequiredLevel, base.Task.QuestName);
_started = autoDutyIpc.StartLevelingMode();
if (condition[ConditionFlag.BoundByDuty] || condition[ConditionFlag.InDutyQueue])
{
logger.LogInformation("Already in duty or queue, skipping start");
return true;
}
if (!autoDutyIpc.IsStopped())
{
logger.LogInformation("AutoDuty is already running, waiting for it");
_startTime = DateTime.Now;
return true;
}
autoDutyIpc.StartLevelingMode();
_startTime = DateTime.Now;
return _started;
return true;
}
public override ETaskResult Update()
@ -290,18 +297,12 @@ internal static class Duty
{
return ETaskResult.StillRunning;
}
if (DateTime.Now - _lastRetryTime > TimeSpan.FromSeconds(5L))
if (DateTime.Now - _startTime < TimeSpan.FromSeconds(10L))
{
logger.LogWarning("AutoDuty stopped before entering duty, retrying...");
_started = autoDutyIpc.StartLevelingMode();
_lastRetryTime = DateTime.Now;
return ETaskResult.StillRunning;
}
if (DateTime.Now - _startTime > TimeSpan.FromSeconds(60L))
{
logger.LogError("AutoDuty failed to start after 60 seconds");
return ETaskResult.TaskComplete;
}
return ETaskResult.StillRunning;
logger.LogError("AutoDuty failed to start leveling mode after 10 seconds");
return ETaskResult.TaskComplete;
}
public void StopNow()
@ -329,12 +330,9 @@ internal static class Duty
private DateTime _lastStatusMessage = DateTime.MinValue;
private DateTime _idleStartTime = DateTime.MinValue;
protected override bool Start()
{
_wasInDuty = false;
_idleStartTime = DateTime.MinValue;
return true;
}
@ -346,11 +344,6 @@ internal static class Duty
{
logger.LogInformation("Entered duty for leveling");
_wasInDuty = true;
_idleStartTime = DateTime.MinValue;
}
if (flag || flag2)
{
_idleStartTime = DateTime.MinValue;
}
byte b = objectTable.LocalPlayer?.Level ?? 0;
if (b >= base.Task.RequiredLevel)
@ -360,21 +353,11 @@ internal static class Duty
autoDutyIpc.DisableLevelingMode();
return ETaskResult.TaskComplete;
}
if (autoDutyIpc.IsStopped() && !flag && !flag2)
if (autoDutyIpc.IsStopped() && !flag && !flag2 && _wasInDuty && DateTime.Now - _lastStatusMessage > TimeSpan.FromSeconds(30L))
{
if (_idleStartTime == DateTime.MinValue)
{
_idleStartTime = DateTime.Now;
}
if (_wasInDuty && DateTime.Now - _idleStartTime > TimeSpan.FromSeconds(3L))
{
_ = base.Task.RequiredLevel;
_lastStatusMessage = DateTime.Now;
logger.LogInformation("Starting another leveling run (current: {CurrentLevel}, need: {RequiredLevel})", b, base.Task.RequiredLevel);
autoDutyIpc.StartLevelingMode();
_wasInDuty = false;
_idleStartTime = DateTime.MinValue;
}
int num = base.Task.RequiredLevel - b;
logger.LogInformation("Waiting for leveling mode to continue (current: {CurrentLevel}, need: {RequiredLevel}, {LevelsNeeded} more levels needed)", b, base.Task.RequiredLevel, num);
_lastStatusMessage = DateTime.Now;
}
return ETaskResult.StillRunning;
}