qstcompanion v1.0.5
This commit is contained in:
parent
52daefcfd7
commit
5e1e1decc5
9 changed files with 304 additions and 200 deletions
|
|
@ -48,6 +48,8 @@ public class QuestRotationExecutionService : IDisposable
|
|||
|
||||
private StepsOfFaithHandler? stepsOfFaithHandler;
|
||||
|
||||
private ErrorRecoveryService? errorRecoveryService;
|
||||
|
||||
private readonly List<StopPoint> stopPoints = new List<StopPoint>();
|
||||
|
||||
private RotationState currentState = new RotationState();
|
||||
|
|
@ -64,10 +66,6 @@ public class QuestRotationExecutionService : IDisposable
|
|||
|
||||
private bool waitingForQuestAcceptForSubmarines;
|
||||
|
||||
private uint? lastDungeonQuestId;
|
||||
|
||||
private int? lastDungeonSequence;
|
||||
|
||||
private uint? lastSoloDutyQuestId;
|
||||
|
||||
private const double CharacterLoginTimeoutSeconds = 60.0;
|
||||
|
|
@ -480,6 +478,12 @@ public class QuestRotationExecutionService : IDisposable
|
|||
log.Information("[QuestRotation] Steps of Faith Handler service linked");
|
||||
}
|
||||
|
||||
public void SetErrorRecoveryService(ErrorRecoveryService service)
|
||||
{
|
||||
errorRecoveryService = service;
|
||||
log.Information("[QuestRotation] Error Recovery service linked");
|
||||
}
|
||||
|
||||
private void MarkQuestCompleted(uint questId, string characterName)
|
||||
{
|
||||
if (!questCompletionByCharacter.ContainsKey(questId))
|
||||
|
|
@ -626,6 +630,24 @@ public class QuestRotationExecutionService : IDisposable
|
|||
return;
|
||||
}
|
||||
lastCheckTime = now;
|
||||
if (isRotationActive && errorRecoveryService != null && errorRecoveryService.IsErrorDisconnect)
|
||||
{
|
||||
string charToRelog = errorRecoveryService.LastDisconnectedCharacter ?? currentState.CurrentCharacter;
|
||||
if (!string.IsNullOrEmpty(charToRelog))
|
||||
{
|
||||
log.Warning("[ErrorRecovery] Disconnect detected for " + charToRelog);
|
||||
log.Information("[ErrorRecovery] Automatically relogging to " + charToRelog + "...");
|
||||
errorRecoveryService.Reset();
|
||||
currentState.Phase = RotationPhase.WaitingForCharacterLogin;
|
||||
currentState.CurrentCharacter = charToRelog;
|
||||
currentState.PhaseStartTime = DateTime.Now;
|
||||
autoRetainerIpc.SwitchCharacter(charToRelog);
|
||||
log.Information("[ErrorRecovery] Relog initiated for " + charToRelog);
|
||||
return;
|
||||
}
|
||||
log.Warning("[ErrorRecovery] Disconnect detected but no character to relog to");
|
||||
errorRecoveryService.Reset();
|
||||
}
|
||||
if (deathHandler != null && combatDutyDetection != null && !combatDutyDetection.IsInDuty)
|
||||
{
|
||||
deathHandler.Update();
|
||||
|
|
@ -1037,7 +1059,19 @@ public class QuestRotationExecutionService : IDisposable
|
|||
private unsafe void HandleQuestMonitoring()
|
||||
{
|
||||
uint questId = currentState.CurrentStopQuestId;
|
||||
if (!submarineManager.IsSubmarinePaused && !submarineManager.IsSubmarineCooldownActive())
|
||||
bool hasReachedStopSequence = false;
|
||||
StopPoint stopPointForSubmarine = stopPoints.FirstOrDefault((StopPoint sp) => sp.QuestId == questId && sp.IsActive);
|
||||
if (stopPointForSubmarine != null && stopPointForSubmarine.Sequence.HasValue)
|
||||
{
|
||||
string currentQuestIdStr = questionableIPC.GetCurrentQuestId();
|
||||
byte? currentSequence = questionableIPC.GetCurrentSequence();
|
||||
if (!string.IsNullOrEmpty(currentQuestIdStr) && currentSequence.HasValue && uint.TryParse(currentQuestIdStr, out var currentQuestId) && currentQuestId == questId && currentSequence.Value >= stopPointForSubmarine.Sequence.Value)
|
||||
{
|
||||
hasReachedStopSequence = true;
|
||||
log.Debug($"[QuestRotation] Stop sequence reached (Quest {questId} Seq {currentSequence.Value} >= {stopPointForSubmarine.Sequence.Value}) - skipping submarine check");
|
||||
}
|
||||
}
|
||||
if (!hasReachedStopSequence && !submarineManager.IsSubmarinePaused && !submarineManager.IsSubmarineCooldownActive())
|
||||
{
|
||||
TimeSpan submarineCheckInterval = TimeSpan.FromSeconds(configuration.SubmarineCheckInterval);
|
||||
if (DateTime.Now - lastSubmarineCheckTime >= submarineCheckInterval)
|
||||
|
|
@ -1128,16 +1162,16 @@ public class QuestRotationExecutionService : IDisposable
|
|||
bool shouldRotate = false;
|
||||
if (activeStopPoint != null && activeStopPoint.Sequence.HasValue)
|
||||
{
|
||||
string currentQuestIdStr = questionableIPC.GetCurrentQuestId();
|
||||
byte? currentSequence = questionableIPC.GetCurrentSequence();
|
||||
if (!string.IsNullOrEmpty(currentQuestIdStr) && currentSequence.HasValue && uint.TryParse(currentQuestIdStr, out var currentQuestId))
|
||||
string currentQuestIdStr2 = questionableIPC.GetCurrentQuestId();
|
||||
byte? currentSequence2 = questionableIPC.GetCurrentSequence();
|
||||
if (!string.IsNullOrEmpty(currentQuestIdStr2) && currentSequence2.HasValue && uint.TryParse(currentQuestIdStr2, out var currentQuestId2))
|
||||
{
|
||||
if (currentQuestId == questId)
|
||||
if (currentQuestId2 == questId)
|
||||
{
|
||||
if (currentSequence.Value >= activeStopPoint.Sequence.Value)
|
||||
if (currentSequence2.Value >= activeStopPoint.Sequence.Value)
|
||||
{
|
||||
log.Information($"[QuestRotation] ✓ Quest {questId} Sequence {activeStopPoint.Sequence.Value} reached by {currentState.CurrentCharacter}!");
|
||||
log.Information($"[QuestRotation] Current Sequence: {currentSequence.Value} (reached {activeStopPoint.Sequence.Value})");
|
||||
log.Information($"[QuestRotation] Current Sequence: {currentSequence2.Value} (reached {activeStopPoint.Sequence.Value})");
|
||||
shouldRotate = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue