Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add button control for movement lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 10, 2023
1 parent 7b42b45 commit 7ce40ee
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"3603": 0.6,
"3606": 0.6,
"3608": 0.6,
"3610": 0.6,
"3610": 0.1,
"3612": 0.6,
"3613": 0.6,
"3614": 0.6,
Expand Down Expand Up @@ -246,7 +246,7 @@
"7560": 0.6,
"7561": 0.6,
"7562": 0.6,
"7568": 0.1,
"7568": 0.6,
"7863": 0.6,
"8570": 0.1,
"9483": 0.6,
Expand Down
10 changes: 10 additions & 0 deletions Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,19 @@
15593,
15596,
15601,
15764,
15772,
15780,
15783,
15813,
15824,
15832,
15982,
16332,
16339,
16630,
16631,
17382,
18245,
18261,
18437,
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Helpers/ConfigurationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static class ConfigurationHelper
573, //没学会 ?
};

public static readonly VirtualKey[] Keys = new VirtualKey[] { VirtualKey.CONTROL, VirtualKey.SHIFT, VirtualKey.MENU };
public static readonly VirtualKey[] Keys = new VirtualKey[] { VirtualKey.CONTROL, VirtualKey.SHIFT, VirtualKey.MENU, VirtualKey.LBUTTON, VirtualKey.MBUTTON, VirtualKey.RBUTTON };

public static float GetHealthAreaAbility(this Job job)
=> Service.Config.HealthAreaAbilities.TryGetValue(job, out var value) ? value : Service.Config.HealthAreaAbility;
Expand Down
17 changes: 16 additions & 1 deletion RotationSolver.Basic/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,30 @@

namespace RotationSolver.Basic;

public static class Service
internal class Service
{
public const string Command = "/rotation";

// From https://github.com/PunishXIV/Orbwalker/blame/master/Orbwalker/Memory.cs#L85-L87
[Signature("F3 0F 10 05 ?? ?? ?? ?? 0F 2E C6 0F 8A", ScanType = ScanType.StaticAddress, Fallibility = Fallibility.Infallible)]
static IntPtr forceDisableMovementPtr;
private static unsafe ref int ForceDisableMovement => ref *(int*)(forceDisableMovementPtr + 4);
internal static unsafe bool CanMove
{
get => ForceDisableMovement == 0;
set => ForceDisableMovement = value || DataCenter.NoPoslock ? 0 : 1;
}

public static float CountDownTime => Countdown.TimeRemaining;

public static PluginConfiguration Config { get; set; }
public static PluginConfiguration Default { get; } = new PluginConfiguration();


public Service()
{
SignatureHelper.Initialise(this);
}
public static ActionID GetAdjustedActionId(ActionID id)
=> (ActionID)GetAdjustedActionId((uint)id);

Expand Down
3 changes: 3 additions & 0 deletions RotationSolver/Localization/EnumTranslations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ internal static class EnumTranslations
VirtualKey.SHIFT => "SHIFT",
VirtualKey.CONTROL => "CTRL",
VirtualKey.MENU => "ALT",
VirtualKey.LBUTTON => "Left Mouse",
VirtualKey.MBUTTON => "Middle Mouse",
VirtualKey.RBUTTON => "Right Mouse",
_ => k.ToString(),
};

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"ConfigWindow_Param_Display": "Display",
"ConfigWindow_Param_Advanced": "Advanced",
"ConfigWindow_Param_PoslockCasting": "Lock the movement when casting or some actions.",
"ConfigWindow_Param_UseStopCasting": "Use stopping casting when target is dead.",
"ConfigWindow_Param_UseStopCasting": "Stops casting when target is dead.",
"ConfigWindow_Param_ShowTooltips": "Show tooltips",
"ConfigWindow_Param_InDebug": "Debug Mode",
"ConfigWindow_Param_ShowHealthRatio": "Show the health ratio for the check of Boss, Dying, Dot.",
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ internal partial class Strings
public string ConfigWindow_Param_Display { get; set; } = "Display";
public string ConfigWindow_Param_Advanced { get; set; } = "Advanced";
public string ConfigWindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting or some actions.";
public string ConfigWindow_Param_UseStopCasting { get; set; } = "Use stopping casting when target is dead.";
public string ConfigWindow_Param_UseStopCasting { get; set; } = "Stops casting when target is dead.";
public string ConfigWindow_Param_ShowTooltips { get; set; } = "Show tooltips";
public string ConfigWindow_Param_InDebug { get; set; } = "Debug Mode";

Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)

//Init!
Clipper.InflatePaths(new PathsD(new PathD[] { Clipper.MakePath(new double[] {0, 0, 1, 1 }) }), 0, JoinType.Round, EndType.Joined);

new Service();
try
{
Service.Config = JsonConvert.DeserializeObject<PluginConfiguration>(
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public static void Enable()
{
ActionSequencerUpdater.Enable(Svc.PluginInterface.ConfigDirectory.FullName + "\\Conditions");
SocialUpdater.Enable();
new MovingUpdater();

Svc.Framework.Update += FrameworkUpdate;
}
Expand Down
21 changes: 2 additions & 19 deletions RotationSolver/Updaters/MovingUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Utility.Signatures;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;
using RotationSolver.Commands;

namespace RotationSolver.Updaters;

internal class MovingUpdater
internal static class MovingUpdater
{
// From https://github.com/PunishXIV/Orbwalker/blame/master/Orbwalker/Memory.cs#L85-L87
[Signature("F3 0F 10 05 ?? ?? ?? ?? 0F 2E C6 0F 8A", ScanType = ScanType.StaticAddress, Fallibility = Fallibility.Infallible)]
static IntPtr forceDisableMovementPtr;
private static unsafe ref int ForceDisableMovement => ref *(int*)(forceDisableMovementPtr + 4);

internal static unsafe bool CanMove
{
get => ForceDisableMovement == 0;
set => ForceDisableMovement = value || DataCenter.NoPoslock ? 0 : 1;
}

public MovingUpdater()
{
SignatureHelper.Initialise(this);
}

internal unsafe static void UpdateCanMove(bool doNextAction)
{
bool canMove = !Svc.Condition[ConditionFlag.OccupiedInEvent]
Expand Down Expand Up @@ -64,6 +47,6 @@ internal unsafe static void UpdateCanMove(bool doNextAction)
//Status
var specialStatus = Player.Object.HasStatus(true, statusList.ToArray());

CanMove = !specialStatus && !specialActions && canMove;
Service.CanMove = !specialStatus && !specialActions && canMove;
}
}
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static unsafe void UpdateCastBar()
UIState.Instance()->Hotbar.CancelCast();
}

var nowMove = MovingUpdater.CanMove && Service.Config.CastingDisplay;
var nowMove = Service.CanMove && Service.Config.CastingDisplay;
if (nowMove == _showCanMove) return;
_showCanMove = nowMove;

Expand Down

0 comments on commit 7ce40ee

Please sign in to comment.