muffin v7.4.12
This commit is contained in:
parent
e3e5a401c3
commit
0f9f445830
38 changed files with 13646 additions and 10442 deletions
|
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Questionable.Controller.Steps.Common;
|
||||
using Questionable.Functions;
|
||||
using Questionable.Model;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.Controller.Steps.Interactions;
|
||||
|
||||
internal static class FateAction
|
||||
{
|
||||
internal sealed class Factory : ITaskFactory
|
||||
{
|
||||
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
|
||||
{
|
||||
if (step.InteractionType != EInteractionType.FateAction)
|
||||
{
|
||||
return Array.Empty<ITask>();
|
||||
}
|
||||
if (step.FateActionTargets.Count == 0)
|
||||
{
|
||||
throw new InvalidOperationException("FateAction step requires FateActionTargets");
|
||||
}
|
||||
return new global::_003C_003Ez__ReadOnlyArray<ITask>(new ITask[2]
|
||||
{
|
||||
new Mount.UnmountTask(),
|
||||
new UseOnTargets(step.FateActionTargets)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record UseOnTargets(IList<FateActionTarget> Targets) : ITask
|
||||
{
|
||||
public bool ShouldRedoOnInterrupt()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"FateAction({Targets.Count} targets)";
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class UseOnTargetsExecutor(GameFunctions gameFunctions, ILogger<UseOnTargets> logger) : TaskExecutor<UseOnTargets>()
|
||||
{
|
||||
private DateTime _nextActionAt = DateTime.MinValue;
|
||||
|
||||
protected override bool Start()
|
||||
{
|
||||
logger.LogInformation("Starting FateAction: {Count} targets [{Targets}]", base.Task.Targets.Count, string.Join(", ", base.Task.Targets.Select((FateActionTarget t) => $"{t.DataId}→{t.Action}")));
|
||||
return true;
|
||||
}
|
||||
|
||||
public override ETaskResult Update()
|
||||
{
|
||||
if (DateTime.Now < _nextActionAt)
|
||||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
foreach (FateActionTarget target in base.Task.Targets)
|
||||
{
|
||||
IGameObject gameObject = gameFunctions.FindObjectByDataId(target.DataId);
|
||||
if (gameObject != null && gameObject.IsTargetable)
|
||||
{
|
||||
bool flag = gameFunctions.UseAction(gameObject, target.Action);
|
||||
_nextActionAt = (flag ? DateTime.Now.AddSeconds(2.5) : DateTime.Now.AddSeconds(0.5));
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
}
|
||||
_nextActionAt = DateTime.Now.AddSeconds(0.25);
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Questionable.Functions;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.Controller.Steps.Interactions;
|
||||
|
||||
internal static class FateFarming
|
||||
{
|
||||
internal sealed record WaitForFateTargets(IReadOnlyList<FateActionTarget> Targets) : ITask
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return $"WaitForFateTargets({Targets.Count} targets)";
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class WaitForFateTargetsExecutor(GameFunctions gameFunctions, ILogger<WaitForFateTargetsExecutor> logger) : TaskExecutor<WaitForFateTargets>()
|
||||
{
|
||||
private DateTime _nextPollAt = DateTime.MinValue;
|
||||
|
||||
protected override bool Start()
|
||||
{
|
||||
logger.LogInformation("Waiting for FATE targets to appear ({Count} targets)", base.Task.Targets.Count);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override ETaskResult Update()
|
||||
{
|
||||
if (DateTime.Now < _nextPollAt)
|
||||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
foreach (FateActionTarget target in base.Task.Targets)
|
||||
{
|
||||
IGameObject gameObject = gameFunctions.FindObjectByDataId(target.DataId);
|
||||
if (gameObject != null && gameObject.IsTargetable)
|
||||
{
|
||||
logger.LogInformation("FATE target {DataId} is now targetable", target.DataId);
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
}
|
||||
_nextPollAt = DateTime.Now.AddSeconds(1.0);
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record SyncFateLevel : ITask
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return "SyncFateLevel";
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class SyncFateLevelExecutor(GameFunctions gameFunctions, ILogger<SyncFateLevelExecutor> logger) : TaskExecutor<SyncFateLevel>()
|
||||
{
|
||||
protected override bool Start()
|
||||
{
|
||||
logger.LogInformation("Syncing to FATE level");
|
||||
return true;
|
||||
}
|
||||
|
||||
public override ETaskResult Update()
|
||||
{
|
||||
ushort currentFateId = gameFunctions.GetCurrentFateId();
|
||||
if (currentFateId == 0)
|
||||
{
|
||||
logger.LogDebug("No active FATE to sync to, skipping");
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
gameFunctions.SyncToFate(currentFateId);
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record FateActionLoop(IReadOnlyList<FateActionTarget> Targets) : ITask
|
||||
{
|
||||
public bool ShouldRedoOnInterrupt()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"FateActionLoop({Targets.Count} targets)";
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class FateActionLoopExecutor(GameFunctions gameFunctions, ILogger<FateActionLoopExecutor> logger) : TaskExecutor<FateActionLoop>()
|
||||
{
|
||||
private DateTime _nextActionAt = DateTime.MinValue;
|
||||
|
||||
private bool _fateWasActive;
|
||||
|
||||
protected override bool Start()
|
||||
{
|
||||
logger.LogInformation("Starting FATE action loop with {Count} targets", base.Task.Targets.Count);
|
||||
_fateWasActive = gameFunctions.GetCurrentFateId() != 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override ETaskResult Update()
|
||||
{
|
||||
if (DateTime.Now < _nextActionAt)
|
||||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
bool flag = gameFunctions.GetCurrentFateId() != 0;
|
||||
if (_fateWasActive && !flag)
|
||||
{
|
||||
bool flag2 = false;
|
||||
foreach (FateActionTarget target in base.Task.Targets)
|
||||
{
|
||||
IGameObject gameObject = gameFunctions.FindObjectByDataId(target.DataId);
|
||||
if (gameObject != null && gameObject.IsTargetable)
|
||||
{
|
||||
flag2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
logger.LogInformation("FATE completed (was active, now inactive, no targetable NPCs)");
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
}
|
||||
_fateWasActive = flag;
|
||||
foreach (FateActionTarget target2 in base.Task.Targets)
|
||||
{
|
||||
IGameObject gameObject2 = gameFunctions.FindObjectByDataId(target2.DataId);
|
||||
if (gameObject2 != null && gameObject2.IsTargetable)
|
||||
{
|
||||
bool flag3 = gameFunctions.UseAction(gameObject2, target2.Action);
|
||||
_nextActionAt = (flag3 ? DateTime.Now.AddSeconds(2.5) : DateTime.Now.AddSeconds(0.5));
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
}
|
||||
_nextActionAt = DateTime.Now.AddSeconds(0.25);
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ internal static class Interact
|
|||
uint value = step.DataId.Value;
|
||||
EInteractionType interactionType2 = step.InteractionType;
|
||||
int skipMarkerCheck;
|
||||
if (!step.TargetTerritoryId.HasValue && !(quest.Id is SatisfactionSupplyNpcId))
|
||||
if (!step.IgnoreQuestMarker && !step.TargetTerritoryId.HasValue && !(quest.Id is SatisfactionSupplyNpcId))
|
||||
{
|
||||
SkipConditions skipConditions = step.SkipConditions;
|
||||
if (skipConditions != null)
|
||||
|
|
@ -72,21 +72,22 @@ internal static class Interact
|
|||
SkipStepConditions stepIf = skipConditions.StepIf;
|
||||
if (stepIf != null && stepIf.Never)
|
||||
{
|
||||
goto IL_024f;
|
||||
goto IL_025f;
|
||||
}
|
||||
}
|
||||
if (step.InteractionType != EInteractionType.PurchaseItem)
|
||||
{
|
||||
skipMarkerCheck = ((step.DataId == 1052475) ? 1 : 0);
|
||||
goto IL_0250;
|
||||
goto IL_0260;
|
||||
}
|
||||
}
|
||||
goto IL_024f;
|
||||
IL_024f:
|
||||
skipMarkerCheck = 1;
|
||||
goto IL_0250;
|
||||
IL_0250:
|
||||
goto IL_025f;
|
||||
IL_0260:
|
||||
yield return new Task(value, quest, interactionType2, (byte)skipMarkerCheck != 0, step.PickUpItemId ?? step.GCPurchase?.ItemId, step.TaxiStandId, step.SkipConditions?.StepIf, step.CompletionQuestVariablesFlags);
|
||||
yield break;
|
||||
IL_025f:
|
||||
skipMarkerCheck = 1;
|
||||
goto IL_0260;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue