From 688e6e7d71d7b0893cacb4ea7a613cd71f9d3ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Wed, 5 Apr 2023 11:42:39 +0800 Subject: [PATCH] fix: add a feature to draw melee's offset. --- .../Configuration/PluginConfiguration.cs | 1 + RotationSolver.Basic/Helpers/IActionHelper.cs | 5 --- RotationSolver/Localization/Strings.cs | 2 + RotationSolver/UI/OverlayWindow.cs | 44 ++++++++++++++++--- .../UI/RotationConfigWindow_Param.cs | 3 ++ 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/RotationSolver.Basic/Configuration/PluginConfiguration.cs b/RotationSolver.Basic/Configuration/PluginConfiguration.cs index e32d9e981..2e4f9243a 100644 --- a/RotationSolver.Basic/Configuration/PluginConfiguration.cs +++ b/RotationSolver.Basic/Configuration/PluginConfiguration.cs @@ -59,6 +59,7 @@ public class PluginConfiguration : IPluginConfiguration public bool PositionalFeedback = true; public bool DrawPositional = true; public bool DrawMeleeRange = true; + public bool DrawMeleeOffset = true; public bool ShowMoveTarget = true; public bool ShowHealthRatio = false; public bool ShowTarget = true; diff --git a/RotationSolver.Basic/Helpers/IActionHelper.cs b/RotationSolver.Basic/Helpers/IActionHelper.cs index 05da3c8a0..3e2696b32 100644 --- a/RotationSolver.Basic/Helpers/IActionHelper.cs +++ b/RotationSolver.Basic/Helpers/IActionHelper.cs @@ -64,9 +64,4 @@ private static ActionID[] GetIDFromActions(bool isAdjust, params IAction[] actio { return actions.Select(a => isAdjust ? (ActionID)a.AdjustedID : (ActionID)a.ID).ToArray(); } - - public static bool IsMeleeAction(this IBaseAction act) - { - return act.Range == 3; - } } diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index 04d6981b0..3a30ebd4d 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -153,6 +153,8 @@ internal partial class Strings public string ConfigWindow_Param_PositionalFeedback { get; set; } = "Positional error feedback"; public string ConfigWindow_Param_DrawPositional { get; set; } = "Draw Positional on the screen"; public string ConfigWindow_Param_DrawMeleeRange { get; set; } = "Draw the range of melee on the screen"; + + public string ConfigWindow_Param_DrawMeleeOffset { get; set; } = "Draw the offset of melee on the screen"; public string ConfigWindow_Param_ShowMoveTarget { get; set; } = "Show the pointing target of the move skill"; public string ConfigWindow_Param_ShowTarget { get; set; } = "Show Target"; public string ConfigWindow_Param_PositionalFeedbackDesc { get; set; } = "Attention: Positional anticipation is experimental, just for reference only."; diff --git a/RotationSolver/UI/OverlayWindow.cs b/RotationSolver/UI/OverlayWindow.cs index f52fa8425..b100ba09d 100644 --- a/RotationSolver/UI/OverlayWindow.cs +++ b/RotationSolver/UI/OverlayWindow.cs @@ -121,16 +121,34 @@ private static void DrawTarget(BattleChara tar, uint color, float radius, out Ve const int COUNT = 20; private static void DrawPositional() { - if (ActionUpdater.NextGCDAction == null || !ActionUpdater.NextGCDAction.IsMeleeAction()) return; + if (ActionUpdater.NextGCDAction == null ||  + !Service.Player.IsJobCategory(JobRole.Tank) + && !Service.Player.IsJobCategory(JobRole.Melee)) return; Vector3 pPosition = ActionUpdater.NextGCDAction.Target.Position; Service.WorldToScreen(pPosition, out var scrPos); float radius = ActionUpdater.NextGCDAction.Target.HitboxRadius + Service.Player.HitboxRadius + 3; float rotation = ActionUpdater.NextGCDAction.Target.Rotation; - bool wrong = ActionUpdater.NextGCDAction.Target.DistanceToPlayer() > 3; - List pts = new List(4 * COUNT); + if (Service.Config.DrawMeleeOffset) + { + var offsetColor = new Vector3(0.8f, 0.3f, 0.2f); + List pts1 = new List(4 * COUNT); + SectorPlots(ref pts1, pPosition, radius, 0, 4 * COUNT, 2 * Math.PI); + + List pts2 = new List(4 * COUNT); + SectorPlots(ref pts2, pPosition, radius + Service.Config.MeleeRangeOffset, 0, 4 * COUNT, 2 * Math.PI); + pts2.Reverse(); + + DrawFill(pts1.Union(pts2), offsetColor); + + DrawBoundary(pts1 , offsetColor); + DrawBoundary(pts2, offsetColor); + } + + List pts = new List(4 * COUNT); + bool wrong = ActionUpdater.NextGCDAction.Target.DistanceToPlayer() > 3; if (Service.Config.DrawPositional && !Service.Player.HasStatus(true, StatusID.TrueNorth)) { var shouldPos = ActionUpdater.NextGCDAction.EnemyPositional; @@ -163,14 +181,28 @@ private static void DrawPositional() if (pts.Count > 0) DrawRange(pts, wrong); } - static void DrawRange(List pts, bool wrong) + static void DrawRange(IEnumerable pts, bool wrong) { var color = wrong ? new Vector3(0.3f, 0.8f, 0.2f) : new Vector3(1, 1, 1); + DrawFill(pts, color); + DrawBoundary(pts, color); + } - pts.ForEach(pt => ImGui.GetWindowDrawList().PathLineTo(pt)); + static void DrawFill(IEnumerable pts, Vector3 color) + { + foreach (var pt in pts) + { + ImGui.GetWindowDrawList().PathLineTo(pt); + } ImGui.GetWindowDrawList().PathFillConvex(ImGui.GetColorU32(new Vector4(color.X, color.Y, color.Z, 0.15f))); + } - pts.ForEach(pt => ImGui.GetWindowDrawList().PathLineTo(pt)); + static void DrawBoundary(IEnumerable pts, Vector3 color) + { + foreach (var pt in pts) + { + ImGui.GetWindowDrawList().PathLineTo(pt); + } ImGui.GetWindowDrawList().PathStroke(ImGui.GetColorU32(new Vector4(color.X, color.Y, color.Z, 1f)), ImDrawFlags.None, 2); } diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs index 16dc98095..3031928bf 100644 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ b/RotationSolver/UI/RotationConfigWindow_Param.cs @@ -269,6 +269,9 @@ private void DrawParamDisplay() DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_DrawMeleeRange, ref Service.Config.DrawMeleeRange); + + DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_DrawMeleeOffset, + ref Service.Config.DrawMeleeOffset); } }