muffin v7.5.13
This commit is contained in:
parent
911ed68baa
commit
acf3e3cb18
69 changed files with 2731 additions and 1425 deletions
|
|
@ -130,10 +130,10 @@ internal sealed class MoveExecutor : TaskExecutor<MoveTask>, IToastAware, ITaskE
|
|||
};
|
||||
}
|
||||
}
|
||||
float num2 = base.Task.StopDistance ?? 3f;
|
||||
float stopDistance = base.Task.StopDistance ?? 3f;
|
||||
Vector3? vector = _objectTable.LocalPlayer?.Position;
|
||||
float num3 = ((!vector.HasValue) ? float.MaxValue : Vector3.Distance(vector.Value, _destination));
|
||||
if (num3 > num2)
|
||||
float num2 = ((!vector.HasValue) ? float.MaxValue : Vector3.Distance(vector.Value, _destination));
|
||||
if (!vector.HasValue || !IsWithinInteractionRange(vector.Value, _destination, stopDistance, GetVerticalStopDistance()))
|
||||
{
|
||||
PrepareMovementIfNeeded();
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ internal sealed class MoveExecutor : TaskExecutor<MoveTask>, IToastAware, ITaskE
|
|||
else if (!base.Task.DisableNavmesh)
|
||||
{
|
||||
bool flag = _gameFunctions.IsFlyingUnlocked(base.Task.TerritoryId);
|
||||
if (!base.Task.SmartNavRouted && !base.Task.Fly && flag && num3 > _configuration.Navigation.MountFlyDistance)
|
||||
if (!base.Task.SmartNavRouted && !base.Task.Fly && flag && num2 > _configuration.Navigation.MountFlyDistance)
|
||||
{
|
||||
base.Task = base.Task with
|
||||
{
|
||||
|
|
@ -184,8 +184,8 @@ internal sealed class MoveExecutor : TaskExecutor<MoveTask>, IToastAware, ITaskE
|
|||
Land = true
|
||||
};
|
||||
}
|
||||
float num4 = (base.Task.Fly ? _configuration.Navigation.MountFlyDistance : _configuration.Navigation.MountGroundDistance);
|
||||
Questionable.Controller.Steps.Common.Mount.EMountIf mountIf = ((!(num3 > num4)) ? Questionable.Controller.Steps.Common.Mount.EMountIf.AwayFromPosition : Questionable.Controller.Steps.Common.Mount.EMountIf.Always);
|
||||
float num3 = (base.Task.Fly ? _configuration.Navigation.MountFlyDistance : _configuration.Navigation.MountGroundDistance);
|
||||
Questionable.Controller.Steps.Common.Mount.EMountIf mountIf = ((!(num2 > num3)) ? Questionable.Controller.Steps.Common.Mount.EMountIf.AwayFromPosition : Questionable.Controller.Steps.Common.Mount.EMountIf.Always);
|
||||
Questionable.Controller.Steps.Common.Mount.MountTask mountTask3 = new Questionable.Controller.Steps.Common.Mount.MountTask(base.Task.TerritoryId, mountIf, _destination);
|
||||
long retryAtMs = 0L;
|
||||
(Questionable.Controller.Steps.Common.Mount.MountExecutor, Questionable.Controller.Steps.Common.Mount.MountTask)? tuple;
|
||||
|
|
@ -244,7 +244,7 @@ internal sealed class MoveExecutor : TaskExecutor<MoveTask>, IToastAware, ITaskE
|
|||
}
|
||||
IPlayerCharacter localPlayer = _objectTable.LocalPlayer;
|
||||
float num = base.Task.StopDistance ?? 3f;
|
||||
if (base.Task.Fly && base.Task.Land && _canRestart && localPlayer != null && _clientState.TerritoryType == base.Task.TerritoryId && Vector3.Distance(localPlayer.Position, _destination) > num)
|
||||
if (base.Task.Fly && base.Task.Land && _canRestart && localPlayer != null && _clientState.TerritoryType == base.Task.TerritoryId && (_condition[ConditionFlag.InFlight] || Vector3.Distance(localPlayer.Position, _destination) > num))
|
||||
{
|
||||
if (_condition[ConditionFlag.InFlight])
|
||||
{
|
||||
|
|
@ -255,20 +255,25 @@ internal sealed class MoveExecutor : TaskExecutor<MoveTask>, IToastAware, ITaskE
|
|||
}
|
||||
if (!_movementController.IsNavmeshReady)
|
||||
{
|
||||
_logger.LogDebug("Airborne outside stop distance, waiting for navmesh to descend");
|
||||
_logger.LogDebug("Still airborne after fly-and-land movement, waiting for navmesh to descend");
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
Vector3 position = localPlayer.Position;
|
||||
position.Y = localPlayer.Position.Y - 100f;
|
||||
Vector3 vector = position;
|
||||
Vector3 destination = _destination;
|
||||
destination.Y = localPlayer.Position.Y;
|
||||
Vector3 vector = destination;
|
||||
destination = _destination;
|
||||
destination.Y = _destination.Y - 100f;
|
||||
Vector3 vector2 = destination;
|
||||
_descendAttempted = true;
|
||||
_logger.LogDebug("Outside stop distance but still airborne, descending to {Target}", vector.ToString("G", CultureInfo.InvariantCulture));
|
||||
_logger.LogDebug("Still airborne, moving above {LandingTarget} and descending to {DescendTarget}", _destination.ToString("G", CultureInfo.InvariantCulture), vector2.ToString("G", CultureInfo.InvariantCulture));
|
||||
MovementController movementController = _movementController;
|
||||
uint? dataId = base.Task.DataId;
|
||||
int num2 = 1;
|
||||
int num2 = 2;
|
||||
List<Vector3> list = new List<Vector3>(num2);
|
||||
CollectionsMarshal.SetCount(list, num2);
|
||||
CollectionsMarshal.AsSpan(list)[0] = vector;
|
||||
Span<Vector3> span = CollectionsMarshal.AsSpan(list);
|
||||
span[0] = vector;
|
||||
span[1] = vector2;
|
||||
movementController.NavigateTo(EMovementType.Landing, dataId, list, fly: true, sprint: false, null);
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
|
|
@ -276,22 +281,29 @@ internal sealed class MoveExecutor : TaskExecutor<MoveTask>, IToastAware, ITaskE
|
|||
_logger.LogDebug("Landed outside stop distance, closing gap on foot");
|
||||
MovementController movementController2 = _movementController;
|
||||
uint? dataId2 = base.Task.DataId;
|
||||
Vector3 destination = _destination;
|
||||
Vector3 destination2 = _destination;
|
||||
float? stopDistance = base.Task.StopDistance;
|
||||
bool smartNavRouted = base.Task.SmartNavRouted;
|
||||
movementController2.NavigateTo(EMovementType.Quest, dataId2, destination, fly: false, sprint: false, stopDistance, null, land: false, smartNavRouted);
|
||||
movementController2.NavigateTo(EMovementType.Quest, dataId2, destination2, fly: false, sprint: false, stopDistance, null, land: false, smartNavRouted);
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
if (base.Task.DataId.HasValue && !_adjustedToObject && localPlayer != null && !_condition[ConditionFlag.InFlight] && _clientState.TerritoryType == base.Task.TerritoryId)
|
||||
if (base.Task.DataId.HasValue && localPlayer != null && !_condition[ConditionFlag.InFlight] && _clientState.TerritoryType == base.Task.TerritoryId)
|
||||
{
|
||||
IGameObject gameObject = _gameFunctions.FindObjectByDataId(base.Task.DataId.Value, null, warnIfMissing: false);
|
||||
if (gameObject != null)
|
||||
{
|
||||
float num3 = Vector3.Distance(localPlayer.Position, gameObject.Position);
|
||||
if (num3 > num)
|
||||
float num4 = Math.Abs(localPlayer.Position.Y - gameObject.Position.Y);
|
||||
if (!IsWithinInteractionRange(localPlayer.Position, gameObject.Position, num, GetVerticalStopDistance()))
|
||||
{
|
||||
if (_adjustedToObject)
|
||||
{
|
||||
_logger.LogWarning("Movement to actual object position ended out of interaction range ({Distance:F1}y away, vertical difference {VerticalDistance:F1}y), treating as unreachable", num3, num4);
|
||||
throw new MovementController.PathfindingFailedException($"Movement to object ended {num3:F1}y away with a {num4:F1}y vertical difference");
|
||||
}
|
||||
_adjustedToObject = true;
|
||||
_logger.LogDebug("Adjusting to actual object position ({Distance:F1}y away)", num3);
|
||||
_canRestart = false;
|
||||
_logger.LogDebug("Adjusting to actual object position ({Distance:F1}y away, vertical difference {VerticalDistance:F1}y)", num3, num4);
|
||||
_movementController.NavigateTo(EMovementType.Quest, base.Task.DataId, gameObject.Position, fly: false, sprint: false, base.Task.StopDistance);
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
|
|
@ -316,13 +328,31 @@ internal sealed class MoveExecutor : TaskExecutor<MoveTask>, IToastAware, ITaskE
|
|||
}
|
||||
if (base.Task.SmartNavRouted && !_adjustedToObject && localPlayer != null && _clientState.TerritoryType == base.Task.TerritoryId && Vector3.Distance(localPlayer.Position, _destination) > num + 5f)
|
||||
{
|
||||
float num4 = Vector3.Distance(localPlayer.Position, _destination);
|
||||
_logger.LogWarning("SmartNav movement ended {Distance:F1}y from target (stop distance {StopDistance:F1}y), treating as unreachable", num4, num);
|
||||
throw new MovementController.PathfindingFailedException($"SmartNav movement ended {num4:F1}y from target (stop distance {num:F1}y)");
|
||||
float num5 = Vector3.Distance(localPlayer.Position, _destination);
|
||||
_logger.LogWarning("SmartNav movement ended {Distance:F1}y from target (stop distance {StopDistance:F1}y), treating as unreachable", num5, num);
|
||||
throw new MovementController.PathfindingFailedException($"SmartNav movement ended {num5:F1}y from target (stop distance {num:F1}y)");
|
||||
}
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
|
||||
private float GetVerticalStopDistance()
|
||||
{
|
||||
if (!base.Task.IgnoreDistanceToObject)
|
||||
{
|
||||
return 1.95f;
|
||||
}
|
||||
return float.MaxValue;
|
||||
}
|
||||
|
||||
internal static bool IsWithinInteractionRange(Vector3 playerPosition, Vector3 targetPosition, float stopDistance, float verticalStopDistance)
|
||||
{
|
||||
if (Vector3.Distance(playerPosition, targetPosition) <= stopDistance)
|
||||
{
|
||||
return Math.Abs(playerPosition.Y - targetPosition.Y) <= verticalStopDistance;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ETaskResult? UpdateMountState()
|
||||
{
|
||||
(Questionable.Controller.Steps.Common.Mount.MountExecutor, Questionable.Controller.Steps.Common.Mount.MountTask)? mountBeforeMovement = _mountBeforeMovement;
|
||||
|
|
|
|||
|
|
@ -7,10 +7,64 @@ namespace Questionable.Controller.Steps.Movement;
|
|||
internal sealed record MoveTask(ushort TerritoryId, Vector3 Destination, bool? Mount = null, bool MountRequired = false, bool DismountRequired = false, float? StopDistance = null, uint? DataId = null, bool DisableNavmesh = false, bool? Sprint = null, bool Fly = false, bool Land = false, bool IgnoreDistanceToObject = false, bool RestartNavigation = true, EInteractionType InteractionType = EInteractionType.None, bool SmartNavRouted = false, bool AllowZoneTransition = false, string? RouteTargetNodeId = null, string? RouteApproachNodeId = null) : ITask
|
||||
{
|
||||
public MoveTask(QuestStep step, Vector3 destination)
|
||||
: this(step.TerritoryId, destination, step.Mount, step.MountRequired, step.DismountRequired, step.CalculateActualStopDistance(), step.DataId, step.DisableNavmesh, step.Sprint, step.Fly == true, step.Land == true, step.IgnoreDistanceToObject == true, step.RestartNavigationIfCancelled != false, step.InteractionType)
|
||||
: this(step.TerritoryId, destination, ResolveMount(step), step.MountRequired, step.DismountRequired, step.CalculateActualStopDistance(), step.DataId, step.DisableNavmesh, step.Sprint, ResolveFly(step), ResolveLand(step), step.IgnoreDistanceToObject == true, step.RestartNavigationIfCancelled != false, step.InteractionType)
|
||||
{
|
||||
}
|
||||
|
||||
private static bool? ResolveMount(QuestStep step)
|
||||
{
|
||||
if (step.MountRequired)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (step.DismountRequired)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (step.TravelMode)
|
||||
{
|
||||
case ETravelMode.OnFoot:
|
||||
return false;
|
||||
case ETravelMode.GroundMount:
|
||||
case ETravelMode.Flying:
|
||||
return true;
|
||||
default:
|
||||
return step.Mount;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ResolveFly(QuestStep step)
|
||||
{
|
||||
if (step.DismountRequired)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (step.TravelMode)
|
||||
{
|
||||
case ETravelMode.OnFoot:
|
||||
case ETravelMode.GroundMount:
|
||||
return false;
|
||||
case ETravelMode.Flying:
|
||||
return true;
|
||||
default:
|
||||
return step.Fly == true;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ResolveLand(QuestStep step)
|
||||
{
|
||||
ETravelMode travelMode = step.TravelMode;
|
||||
bool flag = (uint)(travelMode - 1) <= 1u;
|
||||
bool flag2 = !flag;
|
||||
if (flag2)
|
||||
{
|
||||
EArrivalMode arrivalMode = step.ArrivalMode;
|
||||
bool flag3 = (uint)(arrivalMode - 2) <= 1u;
|
||||
flag2 = flag3 || step.Land == true;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
public bool ShouldRedoOnInterrupt()
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -109,6 +109,14 @@ internal static class MoveTo
|
|||
yield return new LandTask();
|
||||
}
|
||||
}
|
||||
if (step.ArrivalMode == EArrivalMode.StayMounted && !step.DismountRequired)
|
||||
{
|
||||
yield return new Mount.MountTask(step.TerritoryId, Mount.EMountIf.Always);
|
||||
}
|
||||
else if (step.ArrivalMode == EArrivalMode.Dismount && !step.MountRequired)
|
||||
{
|
||||
yield return new Mount.UnmountTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue