1
0
Fork 0
forked from aly/qstbak

qstcompanion v1.0.6

This commit is contained in:
alydev 2025-12-07 10:54:53 +10:00
parent 5e1e1decc5
commit ada27cf05b
30 changed files with 3403 additions and 426 deletions

View file

@ -29,6 +29,10 @@ public class DungeonAutomationService : IDisposable
private readonly QuestionableIPC questionableIPC;
private readonly CrossProcessIPC crossProcessIPC;
private readonly MultiClientIPC multiClientIPC;
private bool isWaitingForParty;
private DateTime partyInviteTime = DateTime.MinValue;
@ -55,6 +59,10 @@ public class DungeonAutomationService : IDisposable
private bool isAutomationActive;
private int originalDutyMode;
private Func<bool>? isRotationActiveChecker;
private bool hasSentAtY;
public bool IsWaitingForParty => isWaitingForParty;
@ -63,7 +71,30 @@ public class DungeonAutomationService : IDisposable
public bool IsInAutoDutyDungeon => isAutomationActive;
public DungeonAutomationService(ICondition condition, IPluginLog log, IClientState clientState, ICommandManager commandManager, IFramework framework, IGameGui gameGui, Configuration config, HelperManager helperManager, MemoryHelper memoryHelper, QuestionableIPC questionableIPC)
public void SetRotationActiveChecker(Func<bool> checker)
{
isRotationActiveChecker = checker;
}
private bool CanExecuteAutomation()
{
if (config.IsHighLevelHelper)
{
return true;
}
if (config.IsQuester)
{
Func<bool>? func = isRotationActiveChecker;
if (func == null || !func())
{
return false;
}
return true;
}
return false;
}
public DungeonAutomationService(ICondition condition, IPluginLog log, IClientState clientState, ICommandManager commandManager, IFramework framework, IGameGui gameGui, Configuration config, HelperManager helperManager, MemoryHelper memoryHelper, QuestionableIPC questionableIPC, CrossProcessIPC crossProcessIPC, MultiClientIPC multiClientIPC)
{
this.condition = condition;
this.log = log;
@ -75,6 +106,8 @@ public class DungeonAutomationService : IDisposable
this.helperManager = helperManager;
this.memoryHelper = memoryHelper;
this.questionableIPC = questionableIPC;
this.crossProcessIPC = crossProcessIPC;
this.multiClientIPC = multiClientIPC;
condition.ConditionChange += OnConditionChanged;
log.Information("[DungeonAutomation] Service initialized with ConditionChange event");
log.Information($"[DungeonAutomation] Config - Required Party Size: {config.AutoDutyPartySize}");
@ -87,6 +120,11 @@ public class DungeonAutomationService : IDisposable
{
if (!isAutomationActive)
{
if (!CanExecuteAutomation())
{
log.Information("[DungeonAutomation] Start request ignored - validation failed (Check Role/Rotation)");
return;
}
log.Information("[DungeonAutomation] ========================================");
log.Information("[DungeonAutomation] === STARTING DUNGEON AUTOMATION ===");
log.Information("[DungeonAutomation] ========================================");
@ -148,6 +186,10 @@ public class DungeonAutomationService : IDisposable
public void Update()
{
if (!CanExecuteAutomation() && !isAutomationActive)
{
return;
}
if (config.EnableAutoDutyUnsynced && !isAutomationActive)
{
CheckWaitForPartyTask();
@ -268,8 +310,12 @@ public class DungeonAutomationService : IDisposable
return;
}
lastDutyEntryTime = DateTime.Now;
log.Information("[DungeonAutomation] Entered duty");
if (expectingDutyEntry)
log.Debug("[DungeonAutomation] Entered duty");
if (!CanExecuteAutomation())
{
log.Debug("[DungeonAutomation] OnDutyEntered ignored - validation failed");
}
else if (expectingDutyEntry)
{
log.Information("[DungeonAutomation] Duty started by DungeonAutomation - enabling automation commands");
expectingDutyEntry = false;
@ -297,7 +343,11 @@ public class DungeonAutomationService : IDisposable
}
lastDutyExitTime = DateTime.Now;
log.Information("[DungeonAutomation] Exited duty");
if (isAutomationActive)
if (!CanExecuteAutomation() && !isAutomationActive)
{
log.Information("[DungeonAutomation] OnDutyExited ignored - validation failed");
}
else if (isAutomationActive)
{
commandManager.ProcessCommand("/at n");
log.Information("[DungeonAutomation] Sent /at n (duty exited)");
@ -343,6 +393,11 @@ public class DungeonAutomationService : IDisposable
{
try
{
if (!CanExecuteAutomation())
{
log.Information("[DungeonAutomation] DisbandParty ignored - validation failed");
return;
}
log.Information("[DungeonAutomation] Disbanding party");
framework.RunOnFrameworkThread(delegate
{