muffin v7.4.15
This commit is contained in:
parent
9bf3dbdf69
commit
0b1b2d38c7
14 changed files with 1215 additions and 1057 deletions
|
|
@ -21,9 +21,12 @@ internal static class FateFarming
|
|||
{
|
||||
private DateTime _nextPollAt = DateTime.MinValue;
|
||||
|
||||
private bool _loggedWaitingForFate;
|
||||
|
||||
protected override bool Start()
|
||||
{
|
||||
logger.LogInformation("Waiting for FATE targets to appear ({Count} targets)", base.Task.Targets.Count);
|
||||
_loggedWaitingForFate = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -33,12 +36,24 @@ internal static class FateFarming
|
|||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
ushort currentFateId = gameFunctions.GetCurrentFateId();
|
||||
if (currentFateId == 0)
|
||||
{
|
||||
if (!_loggedWaitingForFate)
|
||||
{
|
||||
logger.LogInformation("No active FATE yet, waiting for FATE to start before checking targets");
|
||||
_loggedWaitingForFate = true;
|
||||
}
|
||||
_nextPollAt = DateTime.Now.AddSeconds(1.0);
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
_loggedWaitingForFate = false;
|
||||
foreach (FateActionTarget target in base.Task.Targets)
|
||||
{
|
||||
IGameObject gameObject = gameFunctions.FindObjectByDataId(target.DataId);
|
||||
IGameObject gameObject = gameFunctions.FindObjectByDataId(target.DataId, null, warnIfMissing: false);
|
||||
if (gameObject != null && gameObject.IsTargetable)
|
||||
{
|
||||
logger.LogInformation("FATE target {DataId} is now targetable", target.DataId);
|
||||
logger.LogInformation("FATE {FateId} active and target {DataId} is targetable", currentFateId, target.DataId);
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +101,7 @@ internal static class FateFarming
|
|||
}
|
||||
}
|
||||
|
||||
internal sealed record FateActionLoop(IReadOnlyList<FateActionTarget> Targets) : ITask
|
||||
internal sealed record FateActionLoop(IReadOnlyList<FateActionTarget> Targets, EStatus? RequiredStatusId = null) : ITask
|
||||
{
|
||||
public bool ShouldRedoOnInterrupt()
|
||||
{
|
||||
|
|
@ -103,12 +118,12 @@ internal static class FateFarming
|
|||
{
|
||||
private DateTime _nextActionAt = DateTime.MinValue;
|
||||
|
||||
private bool _fateWasActive;
|
||||
private ushort _trackedFateId;
|
||||
|
||||
protected override bool Start()
|
||||
{
|
||||
logger.LogInformation("Starting FATE action loop with {Count} targets", base.Task.Targets.Count);
|
||||
_fateWasActive = gameFunctions.GetCurrentFateId() != 0;
|
||||
_trackedFateId = gameFunctions.GetCurrentFateId();
|
||||
logger.LogInformation("Starting FATE action loop with {Count} targets, tracking FATE {FateId}", base.Task.Targets.Count, _trackedFateId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -118,33 +133,31 @@ internal static class FateFarming
|
|||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
bool flag = gameFunctions.GetCurrentFateId() != 0;
|
||||
if (_fateWasActive && !flag)
|
||||
if (base.Task.RequiredStatusId.HasValue && !gameFunctions.HasStatus(base.Task.RequiredStatusId.Value))
|
||||
{
|
||||
bool flag2 = false;
|
||||
foreach (FateActionTarget target in base.Task.Targets)
|
||||
logger.LogInformation("Required status {StatusId} lost during FATE action loop, ending cycle to re-apply", base.Task.RequiredStatusId.Value);
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
if (_trackedFateId == 0)
|
||||
{
|
||||
_trackedFateId = gameFunctions.GetCurrentFateId();
|
||||
if (_trackedFateId != 0)
|
||||
{
|
||||
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;
|
||||
logger.LogInformation("Now tracking FATE {FateId}", _trackedFateId);
|
||||
}
|
||||
}
|
||||
_fateWasActive = flag;
|
||||
foreach (FateActionTarget target2 in base.Task.Targets)
|
||||
if (_trackedFateId != 0 && !gameFunctions.IsFateStillActive(_trackedFateId))
|
||||
{
|
||||
IGameObject gameObject2 = gameFunctions.FindObjectByDataId(target2.DataId);
|
||||
if (gameObject2 != null && gameObject2.IsTargetable)
|
||||
logger.LogInformation("FATE {FateId} is no longer running, cycle complete", _trackedFateId);
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
foreach (FateActionTarget target in base.Task.Targets)
|
||||
{
|
||||
IGameObject gameObject = gameFunctions.FindObjectByDataId(target.DataId, null, warnIfMissing: false);
|
||||
if (gameObject != null && gameObject.IsTargetable)
|
||||
{
|
||||
bool flag3 = gameFunctions.UseAction(gameObject2, target2.Action);
|
||||
_nextActionAt = (flag3 ? DateTime.Now.AddSeconds(2.5) : DateTime.Now.AddSeconds(0.5));
|
||||
bool flag = gameFunctions.UseAction(gameObject, target.Action);
|
||||
_nextActionAt = (flag ? DateTime.Now.AddSeconds(2.5) : DateTime.Now.AddSeconds(0.5));
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue