Fix teleport

This commit is contained in:
Liza 2024-08-14 13:41:53 +02:00
parent 348fb06542
commit 55238da348
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 12 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>2.7</Version> <Version>2.8</Version>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -145,6 +145,8 @@ internal static class AetheryteShortcut
if (!aetheryteFunctions.IsTeleportUnlocked()) if (!aetheryteFunctions.IsTeleportUnlocked())
throw new TaskException("Teleport is not unlocked, attune to any aetheryte first."); throw new TaskException("Teleport is not unlocked, attune to any aetheryte first.");
_continueAt = DateTime.Now.AddSeconds(1);
logger.LogTrace("Waiting for teleport cooldown...");
return false; return false;
} }

View File

@ -8,13 +8,14 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Questionable.Model.Common; using Questionable.Model.Common;
using Questionable.Model.Questing; using Questionable.Model.Questing;
using Action = Lumina.Excel.GeneratedSheets.Action;
namespace Questionable.Functions; namespace Questionable.Functions;
internal sealed unsafe class AetheryteFunctions internal sealed unsafe class AetheryteFunctions
{ {
private const uint TeleportAction = 5; private const uint TeleportAction = 5;
private const uint ReturnAction = 8; private const uint ReturnAction = 6;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly ILogger<AetheryteFunctions> _logger; private readonly ILogger<AetheryteFunctions> _logger;
@ -48,16 +49,16 @@ internal sealed unsafe class AetheryteFunctions
public bool CanTeleport(EAetheryteLocation aetheryteLocation) public bool CanTeleport(EAetheryteLocation aetheryteLocation)
{ {
if ((ushort)aetheryteLocation == PlayerState.Instance()->HomeAetheryteId && if ((ushort)aetheryteLocation == PlayerState.Instance()->HomeAetheryteId &&
ActionManager.Instance()->GetActionStatus(ActionType.GeneralAction, ReturnAction) == 0) ActionManager.Instance()->GetActionStatus(ActionType.Action, ReturnAction) == 0)
return true; return true;
return ActionManager.Instance()->GetActionStatus(ActionType.GeneralAction, TeleportAction) == 0; return ActionManager.Instance()->GetActionStatus(ActionType.Action, TeleportAction) == 0;
} }
public bool IsTeleportUnlocked() public bool IsTeleportUnlocked()
{ {
ushort unlockLink = _dataManager.GetExcelSheet<GeneralAction>()! uint unlockLink = _dataManager.GetExcelSheet<Action>()!
.Single(x => x.Action.Row == 5) .GetRow(5)!
.UnlockLink; .UnlockLink;
return UIState.Instance()->IsUnlockLinkUnlocked(unlockLink); return UIState.Instance()->IsUnlockLinkUnlocked(unlockLink);
} }
@ -68,17 +69,17 @@ internal sealed unsafe class AetheryteFunctions
if (IsAetheryteUnlocked(aetheryteId, out var subIndex)) if (IsAetheryteUnlocked(aetheryteId, out var subIndex))
{ {
if (aetheryteId == PlayerState.Instance()->HomeAetheryteId && if (aetheryteId == PlayerState.Instance()->HomeAetheryteId &&
ActionManager.Instance()->GetActionStatus(ActionType.GeneralAction, ReturnAction) == 0) ActionManager.Instance()->GetActionStatus(ActionType.Action, ReturnAction) == 0)
{ {
ReturnRequestedAt = DateTime.Now; ReturnRequestedAt = DateTime.Now;
if (ActionManager.Instance()->UseAction(ActionType.GeneralAction, ReturnAction)) if (ActionManager.Instance()->UseAction(ActionType.Action, ReturnAction))
{ {
_logger.LogInformation("Using 'return' for home aetheryte"); _logger.LogInformation("Using 'return' for home aetheryte");
return true; return true;
} }
} }
if (ActionManager.Instance()->GetActionStatus(ActionType.GeneralAction, TeleportAction) == 0) if (ActionManager.Instance()->GetActionStatus(ActionType.Action, TeleportAction) == 0)
{ {
// fallback if return isn't available or (more likely) on a different aetheryte // fallback if return isn't available or (more likely) on a different aetheryte
_logger.LogInformation("Teleporting to aetheryte {AetheryteId}", aetheryteId); _logger.LogInformation("Teleporting to aetheryte {AetheryteId}", aetheryteId);