From 2119b39338b577b5cb3c48463089c2ffbc8b0e00 Mon Sep 17 00:00:00 2001 From: NostraThomas99 <34015422+NostraThomas99@users.noreply.github.com> Date: Thu, 28 Mar 2024 03:16:49 -0500 Subject: [PATCH 1/2] Biiig changes --- .../Actions/ActionBasicInfo.cs | 3 +- .../Actions/ActionCooldownInfo.cs | 4 +- RotationSolver.Basic/Actions/BaseAction.cs | 2 +- RotationSolver.Basic/Configuration/Configs.cs | 2 +- RotationSolver.Basic/DataCenter.cs | 2 + .../Helpers/ActionManagerHelper.cs | 21 ++++++ RotationSolver.Basic/Service.cs | 2 +- RotationSolver/Data/UiString.cs | 3 - RotationSolver/UI/ControlWindow.cs | 4 ++ RotationSolver/UI/RotationConfigWindow.cs | 43 ++---------- .../UI/RotationConfigWindow_Config.cs | 23 ------- RotationSolver/Updaters/MajorUpdater.cs | 12 ++-- RotationSolver/Updaters/RotationUpdater.cs | 6 +- RotationSolver/Updaters/SocialUpdater.cs | 67 ------------------- manifest.json | 10 ++- 15 files changed, 58 insertions(+), 146 deletions(-) create mode 100644 RotationSolver.Basic/Helpers/ActionManagerHelper.cs diff --git a/RotationSolver.Basic/Actions/ActionBasicInfo.cs b/RotationSolver.Basic/Actions/ActionBasicInfo.cs index 353e02c5e..a04086f12 100644 --- a/RotationSolver.Basic/Actions/ActionBasicInfo.cs +++ b/RotationSolver.Basic/Actions/ActionBasicInfo.cs @@ -52,7 +52,8 @@ public readonly struct ActionBasicInfo /// /// The animation lock time of this action. /// - public readonly float AnimationLockTime => OtherConfiguration.AnimationLockTime?.TryGetValue(AdjustedID, out var time) ?? false ? time : 0.6f; + [Obsolete("Use ActionManagerHelper.GetCurrentAnimationLock()")] + public readonly float AnimationLockTime => ActionManagerHelper.GetCurrentAnimationLock(); /// /// The level of this action. diff --git a/RotationSolver.Basic/Actions/ActionCooldownInfo.cs b/RotationSolver.Basic/Actions/ActionCooldownInfo.cs index c02811132..980024358 100644 --- a/RotationSolver.Basic/Actions/ActionCooldownInfo.cs +++ b/RotationSolver.Basic/Actions/ActionCooldownInfo.cs @@ -168,11 +168,11 @@ internal bool CooldownCheck(bool isEmpty, bool onLastAbility, bool ignoreClippin { if (onLastAbility) { - if (DataCenter.NextAbilityToNextGCD > _action.Info.AnimationLockTime + DataCenter.Ping + DataCenter.MinAnimationLock) return false; + if (DataCenter.NextAbilityToNextGCD > ActionManagerHelper.GetCurrentAnimationLock() + DataCenter.Ping + DataCenter.MinAnimationLock) return false; } else if (!ignoreClippingCheck) { - if (DataCenter.NextAbilityToNextGCD < _action.Info.AnimationLockTime) return false; + if (DataCenter.NextAbilityToNextGCD < ActionManagerHelper.GetCurrentAnimationLock()) return false; } } diff --git a/RotationSolver.Basic/Actions/BaseAction.cs b/RotationSolver.Basic/Actions/BaseAction.cs index 9dad2e351..98414310a 100644 --- a/RotationSolver.Basic/Actions/BaseAction.cs +++ b/RotationSolver.Basic/Actions/BaseAction.cs @@ -37,7 +37,7 @@ public class BaseAction : IBaseAction public uint AdjustedID => Info.AdjustedID; /// - public float AnimationLockTime => Info.AnimationLockTime; + public float AnimationLockTime => ActionManagerHelper.GetCurrentAnimationLock(); /// public uint SortKey => Cooldown.CoolDownGroup; diff --git a/RotationSolver.Basic/Configuration/Configs.cs b/RotationSolver.Basic/Configuration/Configs.cs index 67573bd0f..646befed1 100644 --- a/RotationSolver.Basic/Configuration/Configs.cs +++ b/RotationSolver.Basic/Configuration/Configs.cs @@ -39,7 +39,7 @@ public const string [ConditionBool, UI("Show RS logo animation", Filter = UiWindows)] - private static readonly bool _drawIconAnimation = False; + private static readonly bool _drawIconAnimation = false; [ConditionBool, UI("Auto turn off when player is moving between areas.", Filter =BasicAutoSwitch)] diff --git a/RotationSolver.Basic/DataCenter.cs b/RotationSolver.Basic/DataCenter.cs index 332f26542..5d181416b 100644 --- a/RotationSolver.Basic/DataCenter.cs +++ b/RotationSolver.Basic/DataCenter.cs @@ -15,6 +15,8 @@ namespace RotationSolver.Basic; internal static class DataCenter { private static uint _hostileTargetId = GameObject.InvalidGameObjectId; + + public static bool IsActivated() => State || IsManual || Service.Config.TeachingMode; internal static BattleChara? HostileTarget { get diff --git a/RotationSolver.Basic/Helpers/ActionManagerHelper.cs b/RotationSolver.Basic/Helpers/ActionManagerHelper.cs new file mode 100644 index 000000000..2baef0af0 --- /dev/null +++ b/RotationSolver.Basic/Helpers/ActionManagerHelper.cs @@ -0,0 +1,21 @@ +using FFXIVClientStructs.FFXIV.Client.Game; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RotationSolver.Basic.Helpers +{ + internal static class ActionManagerHelper + { + public static unsafe float GetCurrentAnimationLock() + { + var actionManager = ActionManager.Instance(); + if (actionManager == null) return 0.6f; + + var animationLockRaw = ((IntPtr)actionManager + 8); + return *(float*)animationLockRaw; + } + } +} diff --git a/RotationSolver.Basic/Service.cs b/RotationSolver.Basic/Service.cs index dc7f2a16d..596aa5310 100644 --- a/RotationSolver.Basic/Service.cs +++ b/RotationSolver.Basic/Service.cs @@ -9,7 +9,7 @@ namespace RotationSolver.Basic; internal class Service : IDisposable { - public const string COMMAND = "/rotation", USERNAME = "ArchiDog1998", REPO = "RotationSolver"; + public const string COMMAND = "/rotation", USERNAME = "FFXIV-CombatReborn", REPO = "RotationSolverReborn"; // 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)] diff --git a/RotationSolver/Data/UiString.cs b/RotationSolver/Data/UiString.cs index 856d9dcc3..5c556db1c 100644 --- a/RotationSolver/Data/UiString.cs +++ b/RotationSolver/Data/UiString.cs @@ -48,9 +48,6 @@ internal enum UiString [Description("Rotation Solver helped you by clicking actions {0:N0} times.")] ConfigWindow_About_ClickingCount, - [Description("You have said hello to other users {0:N0} times!")] - ConfigWindow_About_SayHelloCount, - [Description("Macro")] ConfigWindow_About_Macros, diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index 08eb7a0a0..16ff892b7 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -225,6 +225,10 @@ static void DrawCommandAction(IAction? gcd, IAction? ability, SpecialCommandType ImGui.TextColored(color, str); var help = command.Local(); + if (ability != null) + { + help = help + "\n" + $"({ability.Name})"; + } string baseId = "ImgButton" + command.ToString(); ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, strWidth / 2 - width / 2)); diff --git a/RotationSolver/UI/RotationConfigWindow.cs b/RotationSolver/UI/RotationConfigWindow.cs index b297b07cb..f74b3e53f 100644 --- a/RotationSolver/UI/RotationConfigWindow.cs +++ b/RotationSolver/UI/RotationConfigWindow.cs @@ -308,26 +308,6 @@ private void DrawSideBar() } } } - - if (wholeWidth <= 60 * Scale - ? IconSet.GetTexture("https://storage.ko-fi.com/cdn/brandasset/kofi_s_logo_nolabel.png", out var texture) - : IconSet.GetTexture("https://storage.ko-fi.com/cdn/brandasset/kofi_bg_tag_dark.png", out texture)) - { - var width = Math.Min(150 * Scale, Math.Max(Scale * MIN_COLUMN_WIDTH, Math.Min(wholeWidth, texture.Width))); - var size = new Vector2(width, width * texture.Height / texture.Width); - size *= MathF.Max(Scale * MIN_COLUMN_WIDTH / size.Y, 1); - var result = false; - ImGuiHelper.DrawItemMiddle(() => - { - ImGui.SetCursorPosY(ImGui.GetWindowSize().Y + ImGui.GetScrollY() - size.Y); - result = ImGuiHelper.NoPaddingNoColorImageButton(texture.ImGuiHandle, size, "Donate Plugin"); - }, wholeWidth, size.X); - - if (result) - { - Util.OpenLink("https://ko-fi.com/B0B0IN5DX"); - } - } } } @@ -542,12 +522,13 @@ private static void DrawRotationCombo(float comboSize, Type[] rotations, ICustom { if( DataCenter.IsPvP) { - Service.Config.PvPRotationChoice = r.GetType().FullName; + Service.Config.PvPRotationChoice = r.FullName; } else { - Service.Config.RotationChoice = r.GetType().FullName; + Service.Config.RotationChoice = r.FullName; } + Service.Config.Save(); } ImguiTooltips.HoveredTooltip(rAttr.Description); ImGui.PopStyleColor(); @@ -698,19 +679,6 @@ private static void DrawAbout() } } } - - var sayHelloCount = OtherConfiguration.RotationSolverRecord.SayingHelloCount; - if (sayHelloCount > 0) - { - using var color = ImRaii.PushColor(ImGuiCol.Text, new Vector4(0.2f, 0.8f, 0.95f, 1)); - var countStr = string.Format(UiString.ConfigWindow_About_SayHelloCount.Local(), sayHelloCount); - - ImGuiHelper.DrawItemMiddle(() => - { - ImGui.TextWrapped(countStr); - }, width, ImGui.CalcTextSize(countStr).X); - } - _aboutHeaders.Draw(); } @@ -1724,7 +1692,9 @@ private static void DrawRotationsLoaded() if (IconSet.GetTexture(IconSet.GetJobIcon(jobs.Key, IconType.Framed), out var texture, 62574)) ImGui.Image(texture.ImGuiHandle, Vector2.One * 30 * Scale); - ImguiTooltips.HoveredTooltip(string.Join('\n', jobs.Select(t => t.GetCustomAttribute()?.Name ?? t.Name))); + ImguiTooltips.HoveredTooltip(string.Join('\n', jobs.Select(t => t.GetCustomAttribute()?.Name ?? t.Name)) + + Environment.NewLine + + string.Join('\n', jobs.Select(t => t.GetCustomAttribute()?.Type ?? CombatType.None))); } ImGui.TableNextColumn(); @@ -2562,6 +2532,7 @@ private static void DrawNextAction() ImGui.Text("Ability Remain: " + DataCenter.AbilityRemain.ToString()); ImGui.Text("Action Remain: " + DataCenter.AnimationLocktime.ToString()); ImGui.Text("Weapon Remain: " + DataCenter.WeaponRemain.ToString()); + ImGui.Text("Animation Lock Delay: " + ActionManagerHelper.GetCurrentAnimationLock().ToString()); } private static void DrawLastAction() diff --git a/RotationSolver/UI/RotationConfigWindow_Config.cs b/RotationSolver/UI/RotationConfigWindow_Config.cs index 1581c1cee..b501911ba 100644 --- a/RotationSolver/UI/RotationConfigWindow_Config.cs +++ b/RotationSolver/UI/RotationConfigWindow_Config.cs @@ -268,29 +268,6 @@ private static void DrawBasicNamedConditions() private static void DrawBasicOthers() { _allSearchable.DrawItems(Configs.BasicParams); - - if (Service.Config.SayHelloToAll) - { - var str = Player.Object.EncryptString(); - ImGui.SetNextItemWidth(ImGui.CalcTextSize(str).X + 10); - ImGui.InputText("That is your HASH:", ref str, 100); - - if (!DataCenter.ContributorsHash.Contains(str) - && !DownloadHelper.UsersHash.Contains(str) - && !DataCenter.AuthorHashes.ContainsKey(str)) - { - if (ImGui.Button("DM your Hash to ArchiTed for being greeted.")) - { - ImGui.SetClipboardText(str); - Notify.Success($"Your hash \"{str}\" copied to clipboard."); - Util.OpenLink("https://discord.com/users/1007293294100877322"); - } - } - } - else - { - ImGui.TextColored(ImGuiColors.DalamudRed, "The author of RS loves being greeted by you!"); - } } #endregion diff --git a/RotationSolver/Updaters/MajorUpdater.cs b/RotationSolver/Updaters/MajorUpdater.cs index cbd71bfd8..44cc7ffb6 100644 --- a/RotationSolver/Updaters/MajorUpdater.cs +++ b/RotationSolver/Updaters/MajorUpdater.cs @@ -171,7 +171,6 @@ private static void UpdateWork() try { - TargetUpdater.UpdateTarget(); StateUpdater.UpdateState(); if (Service.Config.AutoLoadCustomRotations) @@ -180,10 +179,13 @@ private static void UpdateWork() } RotationUpdater.UpdateRotation(); - - RaidTimeUpdater.UpdateTimeline(); - ActionSequencerUpdater.UpdateActionSequencerAction(); - ActionUpdater.UpdateNextAction(); + if (DataCenter.IsActivated()) + { + TargetUpdater.UpdateTarget(); + RaidTimeUpdater.UpdateTimeline(); + ActionSequencerUpdater.UpdateActionSequencerAction(); + ActionUpdater.UpdateNextAction(); + } RSCommands.UpdateRotationState(); PainterManager.UpdateSettings(); diff --git a/RotationSolver/Updaters/RotationUpdater.cs b/RotationSolver/Updaters/RotationUpdater.cs index 7f833461c..224f568da 100644 --- a/RotationSolver/Updaters/RotationUpdater.cs +++ b/RotationSolver/Updaters/RotationUpdater.cs @@ -553,11 +553,11 @@ private static void UpdateCustomRotation() private static Type? GetChosenType(IEnumerable types, string name) { - var rotation = types.FirstOrDefault(r => r.GetType().FullName == name); + var rotation = types.FirstOrDefault(r => r.FullName == name); - rotation ??= types.FirstOrDefault(r => r.GetType().Assembly.FullName!.Contains("SupportersRotations", StringComparison.OrdinalIgnoreCase)); + rotation ??= types.FirstOrDefault(r => r.Assembly.FullName!.Contains("SupportersRotations", StringComparison.OrdinalIgnoreCase)); - rotation ??= types.FirstOrDefault(r => r.GetType().Assembly.FullName!.Contains("DefaultRotations", StringComparison.OrdinalIgnoreCase)); + rotation ??= types.FirstOrDefault(r => r.Assembly.FullName!.Contains("DefaultRotations", StringComparison.OrdinalIgnoreCase)); rotation ??= types.FirstOrDefault(); diff --git a/RotationSolver/Updaters/SocialUpdater.cs b/RotationSolver/Updaters/SocialUpdater.cs index f30d0aa89..b91f1f22c 100644 --- a/RotationSolver/Updaters/SocialUpdater.cs +++ b/RotationSolver/Updaters/SocialUpdater.cs @@ -139,73 +139,10 @@ internal static async void UpdateSocial() _canSaying = false; Service.Config.DutyStart.AddMacro(); await Task.Delay(new Random().Next(1000, 1500)); - - SayHelloToUsers(); } } private static readonly ChatEntityComparer _comparer = new(); - private static async void SayHelloToUsers() - { - if (!Service.Config.SayHelloToAll) - { - return; - } - - var players = DataCenter.AllianceMembers.OfType() -#if DEBUG -#else - .Where(c => c.ObjectId != Player.Object.ObjectId) -#endif - .Select(player => (player, player.EncryptString())) - .Where(pair => !saidAuthors.Contains(pair.Item2) - && !OtherConfiguration.RotationSolverRecord.SaidUsers.Contains(pair.Item2)); - - IEnumerable entities = players - .Select(c => - { - if (!DataCenter.AuthorHashes.TryGetValue(c.Item2, out var nameDesc)) nameDesc = string.Empty; - return (c.player, nameDesc); - }) - .Where(p => !string.IsNullOrEmpty(p.nameDesc)) - .Select(p => new RotationAuthorChatEntity(p.player, p.nameDesc)); - - entities = entities.Union(players - .Where(p => DataCenter.ContributorsHash.Contains(p.Item2)) - .Select(p => new ContributorChatEntity(p.player)), _comparer); - - if (Service.Config.SayHelloToUsers) - { - entities = entities.Union(players - .Where(p => DownloadHelper.UsersHash.Contains(p.Item2)) - .Select(p => new UserChatEntity(p.player)), _comparer); - } - - foreach (var entity in entities) - { - while (!entity.CanTarget && !DataCenter.InCombat) - { - await Task.Delay(100); - } - -#if DEBUG -#else - Svc.Targets.Target = entity.player; - ECommons.Automation.Chat.Instance.SendMessage($"/{_macroToAuthor[new Random().Next(_macroToAuthor.Count)]} "); -#endif - Svc.Chat.Print(new Dalamud.Game.Text.XivChatEntry() - { - Message = entity.GetMessage(), - Type = Dalamud.Game.Text.XivChatType.Notice, - }); - UIModule.PlaySound(20, 0, 0, 0); - entity.Dispose(); - - await Task.Delay(new Random().Next(800, 1200)); - Svc.Targets.Target = null; - await Task.Delay(new Random().Next(800, 1200)); - } - } internal abstract class ChatEntity(PlayerCharacter character) : IDisposable { @@ -247,10 +184,6 @@ public void Dispose() OtherConfiguration.RotationSolverRecord.SayingHelloCount++; var hash = player.EncryptString(); saidAuthors.Add(hash); - if (Service.Config.JustSayHelloOnce) - { - OtherConfiguration.RotationSolverRecord.SaidUsers.Add(hash); - } } } diff --git a/manifest.json b/manifest.json index beb418707..02efab928 100644 --- a/manifest.json +++ b/manifest.json @@ -1,12 +1,16 @@ { - "Author": "ArchiTed", + "Author": "The FFXIV-CombatReborn Team", "Name": "Rotation Solver", "InternalName": "RotationSolver", "Description": "Analyses combat information every frame and finds the best action.\n\nThis means almost all the information available in one frame in combat, including the status of all players in the party, the status of any hostile targets, skill cooldowns, the MP and HP of characters, the location of characters, casting status of the hostile target, combo, combat duration, player level, etc.\nThen, it will highlight the best action on the hot bar, or help you to click on it.\nIt is designed for `general combat`, not for savage or ultimate. Use it carefully.", "ApplicableVersion": "any", "Tags": [ "combat", - "rotation" + "rotation", + "auto", + "solver", + "pve", + "pvp" ], "CategoryTags": [ "jobs" @@ -17,7 +21,7 @@ "CanUnloadAsync": false, "LoadPriority": 0, "IsTestingExclusive": false, - "IconUrl": "https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Images/Logo.png", + "IconUrl": "https://raw.githubusercontent.com/FFXIV-CombatReborn/RotationSolverReborn/main/Images/Logo.png", "Punchline": "Analyses combat information every frame and finds the best action.", "AcceptsFeedback": true } \ No newline at end of file From fb6758bde58eb878b0962297d5f20bff13e43a8e Mon Sep 17 00:00:00 2001 From: NostraThomas99 <34015422+NostraThomas99@users.noreply.github.com> Date: Thu, 28 Mar 2024 03:28:28 -0500 Subject: [PATCH 2/2] Added back Server Bar clicking --- RotationSolver/Commands/RSCommands_Actions.cs | 8 ++++++++ RotationSolver/Updaters/PreviewUpdater.cs | 1 + 2 files changed, 9 insertions(+) diff --git a/RotationSolver/Commands/RSCommands_Actions.cs b/RotationSolver/Commands/RSCommands_Actions.cs index a55faa7fb..82a71e2dd 100644 --- a/RotationSolver/Commands/RSCommands_Actions.cs +++ b/RotationSolver/Commands/RSCommands_Actions.cs @@ -15,6 +15,14 @@ public static partial class RSCommands static DateTime _lastClickTime = DateTime.MinValue; static bool _lastState; + public static void IncrementState() + { + if (!DataCenter.State) { DoStateCommandType(StateCommandType.Auto); return; } + if (DataCenter.State && !DataCenter.IsManual && DataCenter.TargetingType == TargetingType.Big) { DoStateCommandType(StateCommandType.Auto); return; } + if (DataCenter.State && !DataCenter.IsManual) { DoStateCommandType(StateCommandType.Manual); return; } + if (DataCenter.State && DataCenter.IsManual) { DoStateCommandType(StateCommandType.Cancel); return; } + } + internal static unsafe bool CanDoAnAction(bool isGCD) { if (!_lastState || !DataCenter.State) diff --git a/RotationSolver/Updaters/PreviewUpdater.cs b/RotationSolver/Updaters/PreviewUpdater.cs index 123996b1d..e658ebd4b 100644 --- a/RotationSolver/Updaters/PreviewUpdater.cs +++ b/RotationSolver/Updaters/PreviewUpdater.cs @@ -42,6 +42,7 @@ private static void UpdateEntry() new IconPayload(BitmapFontIcon.DPS), new TextPayload(showStr) ); + _dtrEntry.OnClick = RSCommands.IncrementState; } else if (_dtrEntry != null && _dtrEntry.Shown) {