Skip to content

Commit e75933b

Browse files
authored
Merge pull request #807 from FFXIV-CombatReborn/movecastcheckFix
Experimental solution to cast cancelling with BMR movement AI
2 parents 4b85024 + 7099e73 commit e75933b

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

BasicRotations/Ranged/BRD_Default.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ protected override bool AttackAbility(IAction nextGCD, out IAction? act)
255255
return true;
256256
}
257257

258-
if (PitchPerfectPvE.CanUse(out act, skipCastingCheck: true, skipAoeCheck: true, skipComboCheck: true))
258+
if (PitchPerfectPvE.CanUse(out act, skipAoeCheck: true, skipComboCheck: true))
259259
{
260260
if (SongEndAfter(3) && Repertoire > 0)
261261
{

RotationSolver.Basic/Actions/ActionBasicInfo.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ internal readonly bool BasicCheck(bool skipStatusProvideCheck, bool skipComboChe
177177
return false;
178178
}
179179

180+
if (NeedsCasting(!skipCastingCheck) && DataCenter.IsMoving && Service.Config.BmrLock)
181+
{
182+
return false;
183+
}
184+
180185
if (!IsActionEnabled() || !IsOnSlot)
181186
{
182187
return false;
@@ -264,9 +269,25 @@ private bool IsRotationCheckValid()
264269

265270
private bool NeedsCasting(bool skipCastingCheck)
266271
{
267-
return CastTime > 0 && !Player.Object.HasStatus(true, [StatusID.Swiftcast, StatusID.Triplecast, StatusID.Dualcast]) && !ActionsNoNeedCasting.Contains(ID) &&
268-
(DataCenter.SpecialType == SpecialCommandType.NoCasting || (DateTime.Now > DataCenter.KnockbackStart && DateTime.Now < DataCenter.KnockbackFinished) ||
269-
(DataCenter.NoPoslock && DataCenter.IsMoving && !skipCastingCheck));
272+
// Must have a cast time
273+
if (CastTime <= 0)
274+
return false;
275+
276+
// Must not have a instant cast status
277+
if (!Player.Object.WillStatusEnd(0, true, StatusHelper.SwiftcastStatus))
278+
return false;
279+
280+
// Must not be in the no-cast list
281+
if (ActionsNoNeedCasting.Contains(ID))
282+
return false;
283+
284+
// Must be in a state where casting is not possible
285+
if (DataCenter.SpecialType == SpecialCommandType.NoCasting ||
286+
(DateTime.Now > DataCenter.KnockbackStart && DateTime.Now < DataCenter.KnockbackFinished) ||
287+
(DataCenter.NoPoslock && DataCenter.IsMoving && !skipCastingCheck))
288+
return true;
289+
290+
return false;
270291
}
271292

272293
private bool IsStatusProvidedDuringGCD()

RotationSolver.Basic/Configuration/Configs.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public const string
103103
Filter = Extra)]
104104
private static readonly bool _poslockCasting = false;
105105

106+
[ConditionBool, UI("(Experimental) Attempt to mitigate cast cancelling with movement tech in BMR).",
107+
Filter = Extra)]
108+
private static readonly bool _bmrLock = false;
109+
106110
[UI("", Action = ActionID.PassageOfArmsPvE, Parent = nameof(PoslockCasting))]
107111
public bool PosPassageOfArms { get; set; } = false;
108112

RotationSolver.Basic/DataCenter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public static TargetingType TargetingType
267267
}
268268
}
269269

270-
public static bool IsMoving { get; internal set; }
270+
public static bool IsMoving => Player.IsMoving;
271271

272272
internal static float StopMovingRaw { get; set; }
273273

RotationSolver/Updaters/ActionUpdater.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,16 @@ private static unsafe void UpdateSlots()
134134
}
135135
}
136136

137+
private static bool _lastIsMoving = false;
137138
private static DateTime _startMovingTime = DateTime.MinValue;
138139
private static DateTime _stopMovingTime = DateTime.MinValue;
139140
private static void UpdateMoving(DateTime now)
140141
{
141-
bool last = DataCenter.IsMoving;
142-
DataCenter.IsMoving = Player.IsMoving;
143-
if (last && !DataCenter.IsMoving)
142+
if (_lastIsMoving && !DataCenter.IsMoving)
144143
{
145144
_stopMovingTime = now;
146145
}
147-
else if (DataCenter.IsMoving && !last)
146+
else if (DataCenter.IsMoving && !_lastIsMoving)
148147
{
149148
_startMovingTime = now;
150149
}
@@ -156,6 +155,8 @@ private static void UpdateMoving(DateTime now)
156155
DataCenter.MovingRaw = DataCenter.IsMoving
157156
? Math.Min(10, (float)(now - _startMovingTime).TotalSeconds)
158157
: 0;
158+
159+
_lastIsMoving = DataCenter.IsMoving;
159160
}
160161

161162
private static DateTime _startDeadTime = DateTime.MinValue;

0 commit comments

Comments
 (0)