forked from aly/qstbak
muffin v7.4.9
This commit is contained in:
parent
a9e1cdc5f1
commit
2df81c5d15
5 changed files with 5320 additions and 4932 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -263,18 +263,25 @@ internal static class Duty
|
||||||
|
|
||||||
internal sealed class StartLevelingModeExecutor(AutoDutyIpc autoDutyIpc, ICondition condition, ILogger<StartLevelingModeExecutor> logger) : TaskExecutor<StartLevelingModeTask>(), IStoppableTaskExecutor, ITaskExecutor
|
internal sealed class StartLevelingModeExecutor(AutoDutyIpc autoDutyIpc, ICondition condition, ILogger<StartLevelingModeExecutor> logger) : TaskExecutor<StartLevelingModeTask>(), IStoppableTaskExecutor, ITaskExecutor
|
||||||
{
|
{
|
||||||
private bool _started;
|
|
||||||
|
|
||||||
private DateTime _startTime;
|
private DateTime _startTime;
|
||||||
|
|
||||||
private DateTime _lastRetryTime = DateTime.MinValue;
|
|
||||||
|
|
||||||
protected override bool Start()
|
protected override bool Start()
|
||||||
{
|
{
|
||||||
logger.LogInformation("Starting AutoDuty Leveling mode to reach level {RequiredLevel} for quest '{QuestName}'", base.Task.RequiredLevel, base.Task.QuestName);
|
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;
|
_startTime = DateTime.Now;
|
||||||
return _started;
|
return true;
|
||||||
|
}
|
||||||
|
autoDutyIpc.StartLevelingMode();
|
||||||
|
_startTime = DateTime.Now;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ETaskResult Update()
|
public override ETaskResult Update()
|
||||||
|
|
@ -290,19 +297,13 @@ internal static class Duty
|
||||||
{
|
{
|
||||||
return ETaskResult.StillRunning;
|
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;
|
|
||||||
}
|
|
||||||
if (DateTime.Now - _startTime > TimeSpan.FromSeconds(60L))
|
|
||||||
{
|
|
||||||
logger.LogError("AutoDuty failed to start after 60 seconds");
|
|
||||||
return ETaskResult.TaskComplete;
|
|
||||||
}
|
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
}
|
}
|
||||||
|
logger.LogError("AutoDuty failed to start leveling mode after 10 seconds");
|
||||||
|
return ETaskResult.TaskComplete;
|
||||||
|
}
|
||||||
|
|
||||||
public void StopNow()
|
public void StopNow()
|
||||||
{
|
{
|
||||||
|
|
@ -329,12 +330,9 @@ internal static class Duty
|
||||||
|
|
||||||
private DateTime _lastStatusMessage = DateTime.MinValue;
|
private DateTime _lastStatusMessage = DateTime.MinValue;
|
||||||
|
|
||||||
private DateTime _idleStartTime = DateTime.MinValue;
|
|
||||||
|
|
||||||
protected override bool Start()
|
protected override bool Start()
|
||||||
{
|
{
|
||||||
_wasInDuty = false;
|
_wasInDuty = false;
|
||||||
_idleStartTime = DateTime.MinValue;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -346,11 +344,6 @@ internal static class Duty
|
||||||
{
|
{
|
||||||
logger.LogInformation("Entered duty for leveling");
|
logger.LogInformation("Entered duty for leveling");
|
||||||
_wasInDuty = true;
|
_wasInDuty = true;
|
||||||
_idleStartTime = DateTime.MinValue;
|
|
||||||
}
|
|
||||||
if (flag || flag2)
|
|
||||||
{
|
|
||||||
_idleStartTime = DateTime.MinValue;
|
|
||||||
}
|
}
|
||||||
byte b = objectTable.LocalPlayer?.Level ?? 0;
|
byte b = objectTable.LocalPlayer?.Level ?? 0;
|
||||||
if (b >= base.Task.RequiredLevel)
|
if (b >= base.Task.RequiredLevel)
|
||||||
|
|
@ -360,21 +353,11 @@ internal static class Duty
|
||||||
autoDutyIpc.DisableLevelingMode();
|
autoDutyIpc.DisableLevelingMode();
|
||||||
return ETaskResult.TaskComplete;
|
return ETaskResult.TaskComplete;
|
||||||
}
|
}
|
||||||
if (autoDutyIpc.IsStopped() && !flag && !flag2)
|
if (autoDutyIpc.IsStopped() && !flag && !flag2 && _wasInDuty && DateTime.Now - _lastStatusMessage > TimeSpan.FromSeconds(30L))
|
||||||
{
|
{
|
||||||
if (_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);
|
||||||
_idleStartTime = DateTime.Now;
|
|
||||||
}
|
|
||||||
if (_wasInDuty && DateTime.Now - _idleStartTime > TimeSpan.FromSeconds(3L))
|
|
||||||
{
|
|
||||||
_ = base.Task.RequiredLevel;
|
|
||||||
_lastStatusMessage = DateTime.Now;
|
_lastStatusMessage = DateTime.Now;
|
||||||
logger.LogInformation("Starting another leveling run (current: {CurrentLevel}, need: {RequiredLevel})", b, base.Task.RequiredLevel);
|
|
||||||
autoDutyIpc.StartLevelingMode();
|
|
||||||
_wasInDuty = false;
|
|
||||||
_idleStartTime = DateTime.MinValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -322,13 +322,19 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
{
|
{
|
||||||
StopAllDueToConditionFailed("Logged out");
|
StopAllDueToConditionFailed("Logged out");
|
||||||
}
|
}
|
||||||
|
bool flag;
|
||||||
if (_condition[ConditionFlag.Unconscious])
|
if (_condition[ConditionFlag.Unconscious])
|
||||||
{
|
{
|
||||||
if ((!_condition[ConditionFlag.Unconscious] || !_condition[ConditionFlag.SufferingStatusAffliction63] || _clientState.TerritoryType != 1052) && !(_taskQueue.CurrentTaskExecutor is Duty.WaitAutoDutyExecutor) && !_taskQueue.AllTasksComplete)
|
if (!_condition[ConditionFlag.Unconscious] || !_condition[ConditionFlag.SufferingStatusAffliction63] || _clientState.TerritoryType != 1052)
|
||||||
|
{
|
||||||
|
ITaskExecutor currentTaskExecutor = _taskQueue.CurrentTaskExecutor;
|
||||||
|
flag = ((currentTaskExecutor is Duty.WaitAutoDutyExecutor || currentTaskExecutor is Duty.WaitLevelingModeExecutor) ? true : false);
|
||||||
|
if (!flag && !_taskQueue.AllTasksComplete)
|
||||||
{
|
{
|
||||||
StopAllDueToConditionFailed("HP = 0");
|
StopAllDueToConditionFailed("HP = 0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (_configuration.General.UseEscToCancelQuesting)
|
else if (_configuration.General.UseEscToCancelQuesting)
|
||||||
{
|
{
|
||||||
if (_keyState[VirtualKey.ESCAPE] && !_lastEscDown)
|
if (_keyState[VirtualKey.ESCAPE] && !_lastEscDown)
|
||||||
|
|
@ -410,7 +416,7 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool flag = AutomationType == EAutomationType.Automatic && (_taskQueue.AllTasksComplete || _taskQueue.CurrentTaskExecutor?.CurrentTask is WaitAtEnd.WaitQuestAccepted);
|
flag = AutomationType == EAutomationType.Automatic && (_taskQueue.AllTasksComplete || _taskQueue.CurrentTaskExecutor?.CurrentTask is WaitAtEnd.WaitQuestAccepted);
|
||||||
bool flag2;
|
bool flag2;
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
|
|
@ -421,14 +427,14 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
if (step == 0 || step == 255)
|
if (step == 0 || step == 255)
|
||||||
{
|
{
|
||||||
flag2 = true;
|
flag2 = true;
|
||||||
goto IL_07e7;
|
goto IL_0800;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flag2 = false;
|
flag2 = false;
|
||||||
goto IL_07e7;
|
goto IL_0800;
|
||||||
}
|
}
|
||||||
goto IL_07eb;
|
goto IL_0804;
|
||||||
IL_07eb:
|
IL_0804:
|
||||||
if (flag && DateTime.Now >= CurrentQuest.StepProgress.StartedAt.AddSeconds(15.0))
|
if (flag && DateTime.Now >= CurrentQuest.StepProgress.StartedAt.AddSeconds(15.0))
|
||||||
{
|
{
|
||||||
lock (_progressLock)
|
lock (_progressLock)
|
||||||
|
|
@ -444,9 +450,9 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
UpdateCurrentTask();
|
UpdateCurrentTask();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
IL_07e7:
|
IL_0800:
|
||||||
flag = flag2;
|
flag = flag2;
|
||||||
goto IL_07eb;
|
goto IL_0804;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckAutoRefreshCondition()
|
private void CheckAutoRefreshCondition()
|
||||||
|
|
@ -527,7 +533,7 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
private bool HasWaitingTasks()
|
private bool HasWaitingTasks()
|
||||||
{
|
{
|
||||||
ITask task = _taskQueue.CurrentTaskExecutor?.CurrentTask;
|
ITask task = _taskQueue.CurrentTaskExecutor?.CurrentTask;
|
||||||
if (task is WaitAtEnd.WaitObjectAtPosition || task is WaitAtEnd.WaitForCompletionFlags)
|
if (task is WaitAtEnd.WaitObjectAtPosition || task is WaitAtEnd.WaitForCompletionFlags || task is Duty.StartLevelingModeTask || task is Duty.WaitLevelingModeTask)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -551,7 +557,7 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
|
|
||||||
private bool HasSystemConditionsPreventingRefresh()
|
private bool HasSystemConditionsPreventingRefresh()
|
||||||
{
|
{
|
||||||
if (_movementController.IsNavmeshReady && !_condition[ConditionFlag.InCombat] && !_condition[ConditionFlag.Unconscious] && !_condition[ConditionFlag.BoundByDuty] && !_condition[ConditionFlag.InDeepDungeon] && !_condition[ConditionFlag.WatchingCutscene] && !_condition[ConditionFlag.WatchingCutscene78] && !_condition[ConditionFlag.BetweenAreas] && !_condition[ConditionFlag.BetweenAreas51] && !_gameFunctions.IsOccupied() && !_movementController.IsPathfinding && !_movementController.IsPathRunning)
|
if (_movementController.IsNavmeshReady && !_condition[ConditionFlag.InCombat] && !_condition[ConditionFlag.Unconscious] && !_condition[ConditionFlag.BoundByDuty] && !_condition[ConditionFlag.InDutyQueue] && !_condition[ConditionFlag.InDeepDungeon] && !_condition[ConditionFlag.WatchingCutscene] && !_condition[ConditionFlag.WatchingCutscene78] && !_condition[ConditionFlag.BetweenAreas] && !_condition[ConditionFlag.BetweenAreas51] && !_gameFunctions.IsOccupied() && !_movementController.IsPathfinding && !_movementController.IsPathRunning)
|
||||||
{
|
{
|
||||||
return DateTime.Now < _safeAnimationEnd;
|
return DateTime.Now < _safeAnimationEnd;
|
||||||
}
|
}
|
||||||
|
|
@ -652,13 +658,20 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
}
|
}
|
||||||
if (elementId == null || elementId.Value == 0)
|
if (elementId == null || elementId.Value == 0)
|
||||||
{
|
{
|
||||||
|
ITask task = _taskQueue.CurrentTaskExecutor?.CurrentTask;
|
||||||
|
bool flag = ((task is Duty.StartLevelingModeTask || task is Duty.WaitLevelingModeTask) ? true : false);
|
||||||
|
if (flag || _taskQueue.RemainingTasks.Any((ITask t) => (t is Duty.StartLevelingModeTask || t is Duty.WaitLevelingModeTask) ? true : false))
|
||||||
|
{
|
||||||
|
DebugState = "Leveling mode active";
|
||||||
|
return;
|
||||||
|
}
|
||||||
(bool isLevelLocked, int levelsNeeded, int requiredLevel, string? questName) msqLevelLockInfo = _questFunctions.GetMsqLevelLockInfo();
|
(bool isLevelLocked, int levelsNeeded, int requiredLevel, string? questName) msqLevelLockInfo = _questFunctions.GetMsqLevelLockInfo();
|
||||||
bool item = msqLevelLockInfo.isLevelLocked;
|
bool item = msqLevelLockInfo.isLevelLocked;
|
||||||
int item2 = msqLevelLockInfo.levelsNeeded;
|
int item2 = msqLevelLockInfo.levelsNeeded;
|
||||||
int item3 = msqLevelLockInfo.requiredLevel;
|
int item3 = msqLevelLockInfo.requiredLevel;
|
||||||
string item4 = msqLevelLockInfo.questName;
|
string item4 = msqLevelLockInfo.questName;
|
||||||
int currentPlayerLevel = (_objectTable[0] as IPlayerCharacter)?.Level ?? 0;
|
int currentPlayerLevel = (_objectTable[0] as IPlayerCharacter)?.Level ?? 0;
|
||||||
if (item && _autoDutyIpc.IsConfiguredToRunLevelingMode(currentPlayerLevel) && AutomationType == EAutomationType.Automatic && !_condition[ConditionFlag.BoundByDuty] && _taskQueue.AllTasksComplete)
|
if (item && _autoDutyIpc.IsConfiguredToRunLevelingMode(currentPlayerLevel) && AutomationType == EAutomationType.Automatic && !_condition[ConditionFlag.BoundByDuty] && !_condition[ConditionFlag.InDutyQueue] && _taskQueue.AllTasksComplete)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("MSQ '{QuestName}' requires level {RequiredLevel}, current level is {CurrentLevel} ({LevelsNeeded} levels needed). Starting AutoDuty Leveling mode.", item4, item3, item3 - item2, item2);
|
_logger.LogInformation("MSQ '{QuestName}' requires level {RequiredLevel}, current level is {CurrentLevel} ({LevelsNeeded} levels needed). Starting AutoDuty Leveling mode.", item4, item3, item3 - item2, item2);
|
||||||
_taskQueue.Enqueue(new Duty.StartLevelingModeTask(item3, item4));
|
_taskQueue.Enqueue(new Duty.StartLevelingModeTask(item3, item4));
|
||||||
|
|
@ -748,6 +761,13 @@ internal sealed class QuestController : MiniTaskController<QuestController>
|
||||||
}
|
}
|
||||||
if (questProgress == null)
|
if (questProgress == null)
|
||||||
{
|
{
|
||||||
|
ITask task = _taskQueue.CurrentTaskExecutor?.CurrentTask;
|
||||||
|
bool flag = ((task is Duty.StartLevelingModeTask || task is Duty.WaitLevelingModeTask) ? true : false);
|
||||||
|
if (flag || _taskQueue.RemainingTasks.Any((ITask t) => (t is Duty.StartLevelingModeTask || t is Duty.WaitLevelingModeTask) ? true : false))
|
||||||
|
{
|
||||||
|
DebugState = "Leveling mode active";
|
||||||
|
return;
|
||||||
|
}
|
||||||
DebugState = "No quest active";
|
DebugState = "No quest active";
|
||||||
Stop("No quest active");
|
Stop("No quest active");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -146,6 +146,11 @@ internal sealed class AutoDutyIpc
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!IsStopped())
|
||||||
|
{
|
||||||
|
_logger.LogDebug("AutoDuty is already running, not starting leveling mode again");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
_logger.LogInformation("Starting AutoDuty Leveling mode (Support) - AutoDuty will select the best dungeon");
|
_logger.LogInformation("Starting AutoDuty Leveling mode (Support) - AutoDuty will select the best dungeon");
|
||||||
_setConfig.InvokeAction("leveling", "Support");
|
_setConfig.InvokeAction("leveling", "Support");
|
||||||
_run.InvokeAction(0u, 1, !_configuration.Advanced.DisableAutoDutyBareMode);
|
_run.InvokeAction(0u, 1, !_configuration.Advanced.DisableAutoDutyBareMode);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue