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 target finding method of sector action.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 6, 2023
1 parent f6ea5f4 commit 105759c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions RotationSolver/Actions/BaseAction/BaseAction_Target.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.Game;
using RotationSolver.Commands;
using RotationSolver.Data;
using RotationSolver.Helpers;
Expand Down Expand Up @@ -393,6 +394,8 @@ private int CanGetTargetCount(BattleChara target, IEnumerable<BattleChara> canAt
return count;
}

const double _alpha = Math.PI / 3;

internal bool CanGetTarget(BattleChara target, BattleChara subTarget)
{
if (target == null) return false;
Expand All @@ -412,13 +415,14 @@ internal bool CanGetTarget(BattleChara target, BattleChara subTarget)
case 2: // 圆形范围攻击
return Vector3.Distance(target.Position, subTarget.Position) - subTarget.HitboxRadius <= _action.EffectRange;

case 3: // 扇形范围攻击
double cos = Vector3.Dot(dir, tdir) / (dir.Length() * tdir.Length());
return subTarget.DistanceToPlayer() <= _action.EffectRange && cos >= 0.5;
case 3: // Sector
if(subTarget.DistanceToPlayer() > _action.EffectRange) return false;
tdir += dir / dir.Length() * target.HitboxRadius / (float)Math.Sin(_alpha);
return Vector3.Dot(dir, tdir) / (dir.Length() * tdir.Length()) >= Math.Cos(_alpha);

case 4: //直线范围攻击
double distance = Vector3.Cross(dir, tdir).Length() / dir.Length();
return subTarget.DistanceToPlayer() <= _action.EffectRange && distance <= 2;
if (subTarget.DistanceToPlayer() > _action.EffectRange) return false;
return Vector3.Cross(dir, tdir).Length() / dir.Length() <= 2 + target.HitboxRadius;
}

PluginLog.LogDebug(Name + "'s CastType is not valid! The value is " + _action.CastType.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ internal RoleAction(ActionID actionID, JobRole[] roles, bool isFriendly = false,
/// </summary>
public static IBaseAction Peloton { get; } = new RoleAction(ActionID.Peloton, new JobRole[] { JobRole.RangedPhysical }, true)
{
ActionCheck = b => !InCombat && TargetUpdater.PartyMembers.GetObjectInRadius(20).Any(p => !p.HasStatus(false, StatusID.Peloton)),
ActionCheck = b => !InCombat && TargetUpdater.PartyMembers.GetObjectInRadius(20).Any(p =>
p.WillStatusEnd(2, false, StatusID.Peloton)),
};

private protected virtual IBaseAction Raise => null;
Expand Down
3 changes: 1 addition & 2 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ private static void FrameworkUpdate(Framework framework)
ActionUpdater.DoAction();
MacroUpdater.UpdateMacro();


ActionUpdater.UpdateActionInfo();
MovingUpdater.UpdateLocation();
}

Expand Down Expand Up @@ -101,6 +99,7 @@ private static void CalculateFPS()

private static void UpdateWork()
{
ActionUpdater.UpdateActionInfo();
PreviewUpdater.UpdateCastBarState();
TargetUpdater.UpdateTarget();

Expand Down

0 comments on commit 105759c

Please sign in to comment.