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 feature to draw melee's offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 5, 2023
1 parent 8139b49 commit 688e6e7
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
1 change: 1 addition & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions RotationSolver.Basic/Helpers/IActionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down
44 changes: 38 additions & 6 deletions RotationSolver/UI/OverlayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vector2> pts = new List<Vector2>(4 * COUNT);

if (Service.Config.DrawMeleeOffset)
{
var offsetColor = new Vector3(0.8f, 0.3f, 0.2f);
List<Vector2> pts1 = new List<Vector2>(4 * COUNT);
SectorPlots(ref pts1, pPosition, radius, 0, 4 * COUNT, 2 * Math.PI);

List<Vector2> pts2 = new List<Vector2>(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<Vector2> pts = new List<Vector2>(4 * COUNT);
bool wrong = ActionUpdater.NextGCDAction.Target.DistanceToPlayer() > 3;
if (Service.Config.DrawPositional && !Service.Player.HasStatus(true, StatusID.TrueNorth))
{
var shouldPos = ActionUpdater.NextGCDAction.EnemyPositional;
Expand Down Expand Up @@ -163,14 +181,28 @@ private static void DrawPositional()
if (pts.Count > 0) DrawRange(pts, wrong);
}

static void DrawRange(List<Vector2> pts, bool wrong)
static void DrawRange(IEnumerable<Vector2> 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<Vector2> 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<Vector2> 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);
}

Expand Down
3 changes: 3 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 688e6e7

Please sign in to comment.