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

Commit

Permalink
fix: changed the drawing of melee target.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 7, 2023
1 parent ddafea6 commit 91c3c9e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 70 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/Actions/BaseAction/BaseAction_BasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public bool IsEnabled

public unsafe float CastTime => ActionManager.GetAdjustedCastTime(ActionType.Spell, AdjustedID) / 1000f;

internal virtual EnemyPositional EnermyPositonal
public virtual EnemyPositional EnermyPositonal
{
get
{
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal interface IBaseAction : IAction

float Range { get; }

EnemyPositional EnermyPositonal { get; }

/// <summary>
/// If combo id is on this list, this aciton will not used.
/// </summary>
Expand Down
5 changes: 2 additions & 3 deletions RotationSolver/Helpers/IActionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ private static ActionID[] GetIDFromActions(bool isAdjust, params IAction[] actio
return actions.Select(a => isAdjust ? (ActionID)a.AdjustedID : (ActionID)a.ID).ToArray();
}

internal static bool IsMeleeAction(this IAction act)
internal static bool IsMeleeAction(this IBaseAction act)
{
if (act is not IBaseAction baseAct) return false;
return baseAct.Range == 3;
return act.Range == 3;
}
}
2 changes: 1 addition & 1 deletion RotationSolver/Rotations/Basic/RPR_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal abstract class RPR_Base : CustomRotation.CustomRotation

public class PRPAction : BaseAction
{
internal override EnemyPositional EnermyPositonal => Player.HasStatus(true, StatusID.Enshrouded)
public override EnemyPositional EnermyPositonal => Player.HasStatus(true, StatusID.Enshrouded)
? EnemyPositional.None : base.EnermyPositonal;
internal PRPAction(ActionID actionID, bool isFriendly = false, bool shouldEndSpecial = false)
: base(actionID, isFriendly, shouldEndSpecial)
Expand Down
36 changes: 15 additions & 21 deletions RotationSolver/Rotations/CustomRotation/CustomRotation_Invoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,27 @@ private IAction Invoke()

IAction act = GCD(abilityRemain, helpDefenseAOE, helpDefenseSingle);

if (act != null && act is BaseAction GcdAction)
OverlayWindow.MeleeAction = null;
if (act != null && act is IBaseAction GcdAction)
{
//Sayout!
if (GcdAction.EnermyPositonal != EnemyPositional.None && GcdAction.Target.HasPositional()
&& !Player.HasStatus(true, StatusID.TrueNorth))
if (GcdAction.IsMeleeAction())
{
if (CheckAction(GcdAction.ID))
OverlayWindow.MeleeAction = GcdAction;
//Sayout!
if (GcdAction.EnermyPositonal != EnemyPositional.None && GcdAction.Target.HasPositional()
&& !Player.HasStatus(true, StatusID.TrueNorth))
{
string positional = GcdAction.EnermyPositonal.ToName();
if (Service.Configuration.SayPotional) Watcher.Speak(positional);
if (Service.Configuration.FlytextPositional) Service.ToastGui.ShowQuest(" " + positional, new Dalamud.Game.Gui.Toast.QuestToastOptions()
if (CheckAction(GcdAction.ID))
{
IconId = GcdAction.IconID,
});
OverlayWindow.EnemyLocationTarget = GcdAction.Target;
OverlayWindow.ShouldPositional = GcdAction.EnermyPositonal;
string positional = GcdAction.EnermyPositonal.ToName();
if (Service.Configuration.SayPotional) Watcher.Speak(positional);
if (Service.Configuration.FlytextPositional) Service.ToastGui.ShowQuest(" " + positional, new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = GcdAction.IconID,
});
}
}
}
else
{
OverlayWindow.ShouldPositional = EnemyPositional.None;
}

if (abilityRemain == 0 || ActionUpdater.WeaponTotal < ActionUpdater._lastCastingTotal) return GcdAction;

Expand All @@ -84,14 +83,9 @@ private IAction Invoke()
}
else if (act == null)
{
OverlayWindow.ShouldPositional = EnemyPositional.None;
if (Ability(abilityRemain, Addle, out IAction ability, helpDefenseAOE, helpDefenseSingle)) return ability;
return null;
}
else
{
OverlayWindow.ShouldPositional = EnemyPositional.None;
}
return act;
}

Expand Down
81 changes: 37 additions & 44 deletions RotationSolver/Windows/OverlayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace RotationSolver.Windows;

internal static class OverlayWindow
{
internal static BattleChara EnemyLocationTarget { get; set; }
internal static EnemyPositional ShouldPositional { get; set; } = EnemyPositional.None;
internal static IBaseAction MeleeAction { get; set; }
public static void Draw()
{
if (Service.GameGui == null || Service.ClientState.LocalPlayer == null || !Service.Configuration.UseOverlayWindow) return;
Expand All @@ -40,8 +39,7 @@ public static void Draw()

ImGui.SetWindowSize(ImGui.GetIO().DisplaySize);

if (!DrawPositional())
DrawMeleeRange();
DrawPositional();
DrawTarget();
DrawMoveTarget();
DrawHealthRatio();
Expand Down Expand Up @@ -135,53 +133,48 @@ private static void DrawTarget(BattleChara tar, uint color, float radius, out Ve
}

const int COUNT = 20;
private static bool DrawPositional()
private static void DrawPositional()
{
if (EnemyLocationTarget == null || !Service.Configuration.DrawPositional) return false;
if (Service.ClientState.LocalPlayer.HasStatus(true, StatusID.TrueNorth)) return false;
if (ShouldPositional is EnemyPositional.None or EnemyPositional.Front) return false;
if (MeleeAction == null) return;

float radius = EnemyLocationTarget.HitboxRadius + Service.ClientState.LocalPlayer.HitboxRadius + 3;
float rotation = EnemyLocationTarget.Rotation;

Vector3 pPosition = EnemyLocationTarget.Position;
if (!Service.GameGui.WorldToScreen(pPosition, out var scrPos)) return false;

List<Vector2> pts = new List<Vector2>(2 * COUNT + 2) { scrPos };
switch (ShouldPositional)
{
case EnemyPositional.Flank:
SectorPlots(ref pts, pPosition, radius, Math.PI * 0.25 + rotation, COUNT);
pts.Add(scrPos);
SectorPlots(ref pts, pPosition, radius, Math.PI * 1.25 + rotation, COUNT);
break;
case EnemyPositional.Rear:
SectorPlots(ref pts, pPosition, radius, Math.PI * 0.75 + rotation, COUNT);
break;
default:
return false;
}
pts.Add(scrPos);

bool wrong = ShouldPositional != EnemyLocationTarget.FindEnemyPositional() || EnemyLocationTarget.DistanceToPlayer() > 3;
DrawRange(pts, wrong);
return true;
}

private static void DrawMeleeRange()
{
if (!Service.Configuration.DrawMeleeRange ||
!Service.ClientState.LocalPlayer.IsJobCategory(JobRole.Melee)) return;
if (ActionUpdater.NextAction is not IBaseAction act) return;
if (!act.IsMeleeAction()) return;
Vector3 pPosition = MeleeAction.Target.Position;
Service.GameGui.WorldToScreen(pPosition, out var scrPos);

float radius = MeleeAction.Target.HitboxRadius + Service.ClientState.LocalPlayer.HitboxRadius + 3;
float rotation = MeleeAction.Target.Rotation;
bool wrong = MeleeAction.Target.DistanceToPlayer() > 3;
List<Vector2> pts = new List<Vector2>(4 * COUNT);

float radius = act.Target.HitboxRadius + Service.ClientState.LocalPlayer.HitboxRadius + 3;
if(Service.Configuration.DrawPositional && !Service.ClientState.LocalPlayer.HasStatus(true, StatusID.TrueNorth))
{
var shouldPos = MeleeAction.EnermyPositonal;

SectorPlots(ref pts, act.Target.Position, radius, 0, 4 * COUNT, 2 * Math.PI);
switch (shouldPos)
{
case EnemyPositional.Flank:
pts.Add(scrPos);
SectorPlots(ref pts, pPosition, radius, Math.PI * 0.25 + rotation, COUNT);
pts.Add(scrPos);
SectorPlots(ref pts, pPosition, radius, Math.PI * 1.25 + rotation, COUNT);
pts.Add(scrPos);
break;
case EnemyPositional.Rear:
pts.Add(scrPos);
SectorPlots(ref pts, pPosition, radius, Math.PI * 0.75 + rotation, COUNT);
pts.Add(scrPos);
break;
}
if (!wrong && pts.Count > 0)
{
wrong = shouldPos != MeleeAction.Target.FindEnemyPositional();
}
}
if(pts.Count == 0 && Service.Configuration.DrawMeleeRange)
{
SectorPlots(ref pts, pPosition, radius, 0, 4 * COUNT, 2 * Math.PI);
}

DrawRange(pts, act.Target.DistanceToPlayer() > 3);
if(pts.Count > 0) DrawRange(pts, wrong);
}

static void DrawRange(List<Vector2> pts, bool wrong)
Expand Down

0 comments on commit 91c3c9e

Please sign in to comment.