muffin v7.38.2
This commit is contained in:
parent
0336b9c9e9
commit
bbc394c386
10 changed files with 737 additions and 437 deletions
|
|
@ -3,7 +3,9 @@ using System.Collections.Generic;
|
|||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Group;
|
||||
using LLib.Gear;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Questionable.Controller.Steps.Common;
|
||||
using Questionable.Controller.Steps.Shared;
|
||||
using Questionable.Controller.Utils;
|
||||
|
|
@ -17,7 +19,7 @@ namespace Questionable.Controller.Steps.Interactions;
|
|||
|
||||
internal static class Duty
|
||||
{
|
||||
internal sealed class Factory(AutoDutyIpc autoDutyIpc) : ITaskFactory
|
||||
internal sealed class Factory(AutoDutyIpc autoDutyIpc, Configuration configuration) : ITaskFactory
|
||||
{
|
||||
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
|
||||
{
|
||||
|
|
@ -26,36 +28,94 @@ internal static class Duty
|
|||
yield break;
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(step.DutyOptions, "step.DutyOptions");
|
||||
uint contentFinderConditionId;
|
||||
int dutyMode;
|
||||
if (autoDutyIpc.IsConfiguredToRunContent(step.DutyOptions))
|
||||
{
|
||||
contentFinderConditionId = step.DutyOptions.ContentFinderConditionId;
|
||||
ElementId id = quest.Id;
|
||||
if (id is QuestId)
|
||||
AutoDutyIpc.DutyMode dutyMode = GetDutyMode(step.DutyOptions.ContentFinderConditionId, step.DutyOptions.DutyMode);
|
||||
if (dutyMode == AutoDutyIpc.DutyMode.UnsyncRegular && (step.DutyOptions.DutyMode == EDutyMode.UnsyncParty || (!step.DutyOptions.DutyMode.HasValue && configuration.Duties.DutyModeOverrides.TryGetValue(step.DutyOptions.ContentFinderConditionId, out var value) && value == EDutyMode.UnsyncParty) || (!step.DutyOptions.DutyMode.HasValue && !configuration.Duties.DutyModeOverrides.ContainsKey(step.DutyOptions.ContentFinderConditionId) && configuration.Duties.DefaultDutyMode == EDutyMode.UnsyncParty)))
|
||||
{
|
||||
ushort value = id.Value;
|
||||
if (value >= 357 && value <= 360)
|
||||
{
|
||||
dutyMode = 2;
|
||||
goto IL_00b2;
|
||||
}
|
||||
yield return new WaitForPartyTask();
|
||||
}
|
||||
yield return new StartAutoDutyTask(step.DutyOptions.ContentFinderConditionId, dutyMode);
|
||||
yield return new WaitAutoDutyTask(step.DutyOptions.ContentFinderConditionId);
|
||||
if (!QuestWorkUtils.HasCompletionFlags(step.CompletionQuestVariablesFlags))
|
||||
{
|
||||
yield return new WaitAtEnd.WaitNextStepOrSequence();
|
||||
}
|
||||
dutyMode = 1;
|
||||
goto IL_00b2;
|
||||
}
|
||||
if (!step.DutyOptions.LowPriority)
|
||||
else if (!step.DutyOptions.LowPriority)
|
||||
{
|
||||
yield return new OpenDutyFinderTask(step.DutyOptions.ContentFinderConditionId);
|
||||
}
|
||||
yield break;
|
||||
IL_00b2:
|
||||
yield return new StartAutoDutyTask(contentFinderConditionId, (AutoDutyIpc.DutyMode)dutyMode);
|
||||
yield return new WaitAutoDutyTask(step.DutyOptions.ContentFinderConditionId);
|
||||
if (!QuestWorkUtils.HasCompletionFlags(step.CompletionQuestVariablesFlags))
|
||||
}
|
||||
|
||||
private AutoDutyIpc.DutyMode GetDutyMode(uint cfcId, EDutyMode? stepDutyMode)
|
||||
{
|
||||
if (stepDutyMode.HasValue)
|
||||
{
|
||||
yield return new WaitAtEnd.WaitNextStepOrSequence();
|
||||
return ConvertToAutoDutyMode(stepDutyMode.Value);
|
||||
}
|
||||
if (configuration.Duties.DutyModeOverrides.TryGetValue(cfcId, out var value))
|
||||
{
|
||||
return ConvertToAutoDutyMode(value);
|
||||
}
|
||||
return ConvertToAutoDutyMode(configuration.Duties.DefaultDutyMode);
|
||||
}
|
||||
|
||||
private static AutoDutyIpc.DutyMode ConvertToAutoDutyMode(EDutyMode mode)
|
||||
{
|
||||
return mode switch
|
||||
{
|
||||
EDutyMode.Support => AutoDutyIpc.DutyMode.Support,
|
||||
EDutyMode.UnsyncSolo => AutoDutyIpc.DutyMode.UnsyncRegular,
|
||||
EDutyMode.UnsyncParty => AutoDutyIpc.DutyMode.UnsyncRegular,
|
||||
_ => AutoDutyIpc.DutyMode.Support,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record WaitForPartyTask : ITask
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return "WaitForParty";
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class WaitForPartyExecutor(IChatGui chatGui, ILogger<WaitForPartyExecutor> logger) : TaskExecutor<WaitForPartyTask>()
|
||||
{
|
||||
private DateTime _lastWarningTime = DateTime.MinValue;
|
||||
|
||||
protected override bool Start()
|
||||
{
|
||||
logger.LogInformation("Waiting for party members before starting duty...");
|
||||
return true;
|
||||
}
|
||||
|
||||
public unsafe override ETaskResult Update()
|
||||
{
|
||||
GroupManager* ptr = GroupManager.Instance();
|
||||
if (ptr == null)
|
||||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
byte memberCount = ptr->MainGroup.MemberCount;
|
||||
bool isAlliance = ptr->MainGroup.IsAlliance;
|
||||
if (memberCount > 1 || isAlliance)
|
||||
{
|
||||
logger.LogInformation("Party detected with {MemberCount} members, proceeding with duty", memberCount);
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
if (DateTime.Now - _lastWarningTime > TimeSpan.FromSeconds(10L))
|
||||
{
|
||||
chatGui.Print("[Questionable] Waiting for party members before starting duty (Unsync Party mode)...", "Questionable", 576);
|
||||
_lastWarningTime = DateTime.Now;
|
||||
}
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue