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

Commit

Permalink
fix: add a animationLock Dictionary.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 19, 2023
1 parent 31d09b8 commit 121c98b
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"31": 0.6,
"37": 0.6,
"45": 0.6,
"52": 0.6,
"3549": 0.6,
"7386": 0.6,
"7387": 0.6,
"7389": 0.6,
"16465": 0.6,
"25753": 1.15
}
1 change: 1 addition & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class PluginConfiguration : IPluginConfiguration
public float SpecialDuration = 3;
public float AbilitiesInterval = 0.67f;
public float ActionAhead = 0.08f;
public float ActionAheadForLast0GCD = 0.06f;

public float WeaponDelayMin = 0;
public float WeaponDelayMax = 0;
Expand Down
34 changes: 33 additions & 1 deletion RotationSolver.Basic/Helpers/IActionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
namespace RotationSolver.Basic.Helpers;
using Dalamud.Logging;
using System.IO;

namespace RotationSolver.Basic.Helpers;

public static class IActionHelper
{
public static SortedList<uint, float> AnimationLockTime = new SortedList<uint, float>();

public static async void GetAnimationLockTimeAsync(string directory)
{
var filename = $"{nameof(AnimationLockTime)}.json";
var filePath = Path.Combine(directory, filename);
if (File.Exists(filePath))
{
var str = File.ReadAllText(filePath);
AnimationLockTime = JsonConvert.DeserializeObject<SortedList<uint, float>>(str);
}
else
{
try
{
var client = new HttpClient();
var str = await client.GetStringAsync($"https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Resources/{nameof(AnimationLockTime)}.json");
File.WriteAllText(filePath, str);

AnimationLockTime = JsonConvert.DeserializeObject<SortedList<uint, float>>(str);
}
catch (Exception ex)
{
PluginLog.Warning(ex, "Failed to download the animation lock time.");
}
}

}

public static ActionID[] MovingActions = new ActionID[]
{
ActionID.EnAvant,
Expand Down
3 changes: 1 addition & 2 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ internal static unsafe void DoAnAction(bool isGCD)
}
_lastState = DataCenter.StateType;

var localPlayer = Service.Player;
if (localPlayer == null) return;
if (Service.Player == null) return;

//Do not click the button in random time.
if (DateTime.Now - _fastClickStopwatch < TimeSpan.FromMilliseconds(new Random().Next(
Expand Down
12 changes: 12 additions & 0 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface)

MajorUpdater.Enable();
TimeLineUpdater.Enable(pluginInterface.ConfigDirectory.FullName);
IActionHelper.GetAnimationLockTimeAsync(pluginInterface.ConfigDirectory.FullName);
SocialUpdater.Enable();
_dis.Add(new Watcher());
_dis.Add(new MovingController());
Expand Down Expand Up @@ -107,6 +108,17 @@ public void Dispose()
SocialUpdater.Disable();

IconSet.Dispose();

#if DEBUG
var directory = @"E:\OneDrive - stu.zafu.edu.cn\PartTime\FFXIV\RotationSolver\Resources";
#else
var directory = Service.Interface.ConfigDirectory.FullName;
#endif
if (!Directory.Exists(directory)) return;

//Default values.
var path = Path.Combine(directory, $"{nameof(IActionHelper.AnimationLockTime)}.json");
File.WriteAllText(path, JsonConvert.SerializeObject(IActionHelper.AnimationLockTime, Formatting.Indented));
}

private void OnOpenConfigUi()
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ internal unsafe static void DoAction()
if (_GCDDelay.Delay(canUseGCD)) RSCommands.DoAnAction(true);
if (canUseGCD) return;

var ping = 0.06f;

//More then gcd.
if (DataCenter.WeaponRemain < Service.Config.AbilitiesInterval
|| DataCenter.WeaponElapsed < Service.Config.AbilitiesInterval)
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private static void ActionFromSelf(uint sourceId, ActionEffectSet set)
//Record
DataCenter.AddActionRec(set.Action);
DataCenter.NextActionMinTime = DateTime.Now.AddSeconds(set.AnimationLock);
IActionHelper.AnimationLockTime[set.Action.RowId] = set.AnimationLock;
ShowStrSelf = set.ToString();

//Macro
Expand Down

0 comments on commit 121c98b

Please sign in to comment.