From 325d5368a50b3f8089168232eaccb51b17f051ae Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 21 Jan 2025 21:44:08 +0100 Subject: [PATCH] Interrupts: Add a special case for certain movement tasks --- .../Controller/Steps/Shared/MoveTo.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Questionable/Controller/Steps/Shared/MoveTo.cs b/Questionable/Controller/Steps/Shared/MoveTo.cs index 65689108..60d83aed 100644 --- a/Questionable/Controller/Steps/Shared/MoveTo.cs +++ b/Questionable/Controller/Steps/Shared/MoveTo.cs @@ -228,6 +228,17 @@ internal static class MoveTo } } } + else if (!ShouldResolveCombatBeforeNextInteraction() && + _movementController is { IsPathfinding: false, IsPathRunning: false } && + mountExecutor.EvaluateMountState() == Mount.MountResult.DontMount) + { + // except for e.g. jumping which would maybe break if combat navigates us away, if we don't + // need a mount anymore we can just skip combat and assume that the interruption is handled + // later. + // + // without this, the character would just stand around while getting hit + _nestedExecutor = (new NoOpTaskExecutor(), new NoOpTask(), true); + } } else if (nestedExecutor.Executor.Update() == ETaskResult.TaskComplete) { @@ -286,7 +297,16 @@ internal static class MoveTo return base.WasInterrupted(); } - public override bool ShouldInterruptOnDamage() => false; + public override bool ShouldInterruptOnDamage() + { + // have we stopped moving, and are we + // (a) waiting for a mount to complete, or + // (b) want combat to be done before any other interaction? + return _movementController is { IsPathfinding: false, IsPathRunning: false } && + (_nestedExecutor is { Triggered: false, Executor: Mount.MountExecutor } || ShouldResolveCombatBeforeNextInteraction()); + } + + private bool ShouldResolveCombatBeforeNextInteraction() => Task.InteractionType is EInteractionType.Jump; public bool OnErrorToast(SeString message) {