Skip to content

Commit 7ae736e

Browse files
authored
Merge pull request #772 from FFXIV-CombatReborn/tankhotfix
hotfix i hate floats
2 parents bcda68a + e3215d1 commit 7ae736e

File tree

6 files changed

+37
-20
lines changed

6 files changed

+37
-20
lines changed

BasicRotations/Tank/PLD_Default.cs

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

307-
if (CircleOfScornPvE.CanUse(out act, skipAoeCheck: true) && FightOrFlightPvE.Cooldown.IsCoolingDown && (ImperatorPvE.EnoughLevel && ImperatorPvE.IsInCooldown || !ImperatorPvE.EnoughLevel))
307+
if (CircleOfScornPvE.CanUse(out act, skipAoeCheck: true, skipTTKCheck: true) && FightOrFlightPvE.Cooldown.IsCoolingDown && (ImperatorPvE.EnoughLevel && ImperatorPvE.IsInCooldown || !ImperatorPvE.EnoughLevel))
308308
{
309309
return true;
310310
}

RotationSolver.Basic/Actions/ActionBasicInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private bool IsRotationCheckValid()
247247

248248
private bool NeedsCasting(bool skipCastingCheck)
249249
{
250-
return CastTime > 0 && !Player.Object.HasStatus(true, new[] { StatusID.Swiftcast, StatusID.Triplecast, StatusID.Dualcast }) && !ActionsNoNeedCasting.Contains(ID) &&
250+
return CastTime > 0 && !Player.Object.HasStatus(true, [StatusID.Swiftcast, StatusID.Triplecast, StatusID.Dualcast]) && !ActionsNoNeedCasting.Contains(ID) &&
251251
(DataCenter.SpecialType == SpecialCommandType.NoCasting || (DateTime.Now > DataCenter.KnockbackStart && DateTime.Now < DataCenter.KnockbackFinished) ||
252252
(DataCenter.NoPoslock && DataCenter.IsMoving && !skipCastingCheck));
253253
}

RotationSolver.Basic/Actions/ActionTargetInfo.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,9 @@ private readonly bool CanGetTarget(IBattleChara target, IBattleChara subTarget)
985985
Vector3 dir = target.Position - pPos;
986986
Vector3 tdir = subTarget.Position - pPos;
987987

988+
float dirLen = dir.Length();
989+
_ = tdir.Length();
990+
988991
switch (action.Action.CastType)
989992
{
990993
case 2: // Circle
@@ -995,17 +998,23 @@ private readonly bool CanGetTarget(IBattleChara target, IBattleChara subTarget)
995998
{
996999
return false;
9971000
}
998-
999-
tdir += dir / dir.Length() * target.HitboxRadius / (float)Math.Sin(_alpha);
1000-
return Vector3.Dot(dir, tdir) / (dir.Length() * tdir.Length()) >= Math.Cos(_alpha);
1001+
if (dirLen == 0)
1002+
return false;
1003+
tdir += dir / dirLen * target.HitboxRadius / (float)Math.Sin(_alpha);
1004+
dirLen = dir.Length();
1005+
float tdirLen = tdir.Length();
1006+
if (dirLen == 0 || tdirLen == 0)
1007+
return false;
1008+
return Vector3.Dot(dir, tdir) / (dirLen * tdirLen) >= Math.Cos(_alpha);
10011009

10021010
case 4: // Line
10031011
if (subTarget.DistanceToPlayer() > EffectRange)
10041012
{
10051013
return false;
10061014
}
1007-
1008-
return Vector3.Cross(dir, tdir).Length() / dir.Length() <= 2 + target.HitboxRadius
1015+
if (dirLen == 0)
1016+
return false;
1017+
return Vector3.Cross(dir, tdir).Length() / dirLen <= 2 + target.HitboxRadius
10091018
&& Vector3.Dot(dir, tdir) >= 0;
10101019

10111020
case 10: // Donut

RotationSolver.Basic/DataCenter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ public static TargetingType TargetingType
250250

251251
public static bool IsMoving { get; internal set; }
252252

253-
internal static int StopMovingRaw { get; set; }
253+
internal static float StopMovingRaw { get; set; }
254254

255-
internal static int MovingRaw { get; set; }
256-
internal static int DeadTimeRaw { get; set; }
257-
internal static int AliveTimeRaw { get; set; }
255+
internal static float MovingRaw { get; set; }
256+
internal static float DeadTimeRaw { get; set; }
257+
internal static float AliveTimeRaw { get; set; }
258258

259259
public static unsafe ushort PlayerFateId
260260
{
@@ -355,7 +355,7 @@ internal static SpecialCommandType SpecialType
355355
/// </summary>
356356
public static bool NotInCombatDelay => _notInCombatDelay.Delay(!InCombat);
357357

358-
internal static int CombatTimeRaw { get; set; }
358+
internal static float CombatTimeRaw { get; set; }
359359
private static DateTime _startRaidTime = DateTime.MinValue;
360360

361361
internal static int RaidTimeRaw

RotationSolver/Updaters/ActionUpdater.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static void UpdateCombatTime(DateTime now)
118118

119119
DataCenter.CombatTimeRaw = _startCombatTime == DateTime.MinValue
120120
? 0
121-
: (int)(now - _startCombatTime).TotalSeconds;
121+
: (float)(now - _startCombatTime).TotalSeconds;
122122
}
123123

124124
private static unsafe void UpdateSlots()
@@ -151,10 +151,10 @@ private static void UpdateMoving(DateTime now)
151151

152152
DataCenter.StopMovingRaw = DataCenter.IsMoving
153153
? 0
154-
: Math.Min(10, (int)(now - _stopMovingTime).TotalSeconds);
154+
: Math.Min(10, (float)(now - _stopMovingTime).TotalSeconds);
155155

156156
DataCenter.MovingRaw = DataCenter.IsMoving
157-
? Math.Min(10, (int)(now - _startMovingTime).TotalSeconds)
157+
? Math.Min(10, (float)(now - _startMovingTime).TotalSeconds)
158158
: 0;
159159
}
160160

@@ -181,18 +181,18 @@ public static void UpdateLifetime(DateTime now)
181181
}
182182

183183
DataCenter.DeadTimeRaw = Player.Object.IsDead
184-
? Math.Min(10, (int)(now - _startDeadTime).TotalSeconds)
184+
? Math.Min(10, (float)(now - _startDeadTime).TotalSeconds)
185185
: 0;
186186

187187
DataCenter.AliveTimeRaw = Player.Object.IsDead
188188
? 0
189-
: Math.Min(10, (int)(now - _startAliveTime).TotalSeconds);
189+
: Math.Min(10, (float)(now - _startAliveTime).TotalSeconds);
190190
}
191191

192192
private static uint _lastMP = 0;
193193
private static DateTime _lastMPUpdate = DateTime.Now;
194194

195-
internal static int MPUpdateElapsed => (int)((DateTime.Now - _lastMPUpdate).TotalSeconds % 3);
195+
internal static float MPUpdateElapsed => (float)((DateTime.Now - _lastMPUpdate).TotalSeconds % 3);
196196

197197
private static void UpdateMPTimer(DateTime now)
198198
{

RotationSolver/Updaters/StateUpdater.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ private static bool ShouldAddDefenseSingle()
269269

270270
if (DataCenter.Role == JobRole.Tank)
271271
{
272-
bool movingHere = DataCenter.NumberOfHostilesInRange / DataCenter.NumberOfHostilesInMaxRange > 0.3f;
272+
bool movingHere = false;
273+
if (DataCenter.NumberOfHostilesInMaxRange != 0)
274+
{
275+
movingHere = DataCenter.NumberOfHostilesInRange / DataCenter.NumberOfHostilesInMaxRange > 0.3f;
276+
}
273277

274278
int tarOnMeCount = 0;
275279
int attackedCount = 0;
@@ -285,7 +289,11 @@ private static bool ShouldAddDefenseSingle()
285289
}
286290
}
287291

288-
bool attacked = attackedCount / tarOnMeCount > 0.7f;
292+
bool attacked = false;
293+
if (tarOnMeCount != 0)
294+
{
295+
attacked = attackedCount / tarOnMeCount > 0.7f;
296+
}
289297

290298
if (tarOnMeCount >= Service.Config.AutoDefenseNumber
291299
&& Player.Object.GetHealthRatio() <= Service.Config.HealthForAutoDefense

0 commit comments

Comments
 (0)