Skip to content

Commit d437e3c

Browse files
authored
Fix P3 Earthquake Black Hole anchor ordering (#492)
1 parent 2382cd5 commit d437e3c

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

SplatoonScripts/Duties/Dawntrail/Dancing Mad/P3_Earthquake.cs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public unsafe class P3_Earthquake : SplatoonScript<P3_Earthquake.Config>
253253
private string _instruction = "";
254254

255255
public override HashSet<uint>? ValidTerritories { get; } = [TerritoryDancingMadUltimate];
256-
public override Metadata Metadata => new(40, "Garume");
256+
public override Metadata Metadata => new(41, "Garume");
257257

258258
public override void OnSetup()
259259
{
@@ -743,7 +743,7 @@ private void DrawDebugStatus()
743743

744744
ImGui.Indent();
745745
ImGui.TextUnformatted($"State={_state} Window={_currentWindow} Slot={_selfSlot} Source={_quality} Guide={_guideKind}");
746-
ImGui.TextUnformatted($"BlackHoleOrder={C.BlackHoleSourceOrder} Anchor={OrderAnchorDebugText()}");
746+
ImGui.TextUnformatted($"BlackHoleOrder={C.BlackHoleSourceOrder} Anchor={BlackHoleOrderAnchorDebugText()}");
747747
ImGui.TextWrapped($"BlackHoleExpected={BlackHoleExpectedDebugText("settings")}");
748748
ImGui.TextWrapped($"BlackHoleActors={BlackHoleActorDebugText()}");
749749
ImGui.TextWrapped($"TetherHolders={TetherHolderDebugText()}");
@@ -1218,7 +1218,7 @@ private bool TryGetFinalInitialBaitGuide(out Vector3 destination, out string tex
12181218
? FinalStackRole.Support
12191219
: FinalStackRole.Dps;
12201220
var goNorth = ownStackRole == northRole;
1221-
var angle = NormalizeAngle(OrderAnchorAngle() + (goNorth ? 0.0f : MathF.PI));
1221+
var angle = NormalizeAngle(KefkaAnchorAngle() + (goNorth ? 0.0f : MathF.PI));
12221222
destination = PositionFromDirectionAngle(angle, FinalInitialSplitRadius);
12231223
text = TextOrEmpty(C.ShowFinalRoleSplitText, C.FinalRoleSplitText, ownStackRole == FinalStackRole.Support ? "Support" : "DPS");
12241224
return true;
@@ -1636,20 +1636,37 @@ private static bool TryGetKefkaAnchorOffset(uint actionId, out float offset)
16361636
return !float.IsNaN(offset);
16371637
}
16381638

1639-
private float OrderAnchorAngle() =>
1639+
private float BlackHoleOrderAnchorAngle() => C.BlackHoleOrderAnchor switch
1640+
{
1641+
BlackHoleOrderAnchor.KefkaPosition when TryGetKefkaPosition(out var kefka) => DirectionAngle(kefka),
1642+
_ => 0.0f
1643+
};
1644+
1645+
private float KefkaAnchorAngle() =>
16401646
TryGetKefkaPosition(out var kefka) ? DirectionAngle(kefka) : 0.0f;
16411647

16421648
private float SourceAngle(int bucket) =>
16431649
_tetherSources.TryGetValue(bucket, out var source) ? DirectionAngle(source) : BucketAngle(bucket);
16441650

1645-
private float OrderedAngleDistance(float sourceAngle, float anchorAngle) =>
1646-
C.BlackHoleSourceOrder == BlackHoleSourceOrder.ClockwiseFromNorth
1651+
private float OrderedAngleDistance(float sourceAngle, float anchorAngle)
1652+
{
1653+
var delta = C.BlackHoleSourceOrder == BlackHoleSourceOrder.ClockwiseFromNorth
16471654
? NormalizeAngle(sourceAngle - anchorAngle)
16481655
: NormalizeAngle(anchorAngle - sourceAngle);
1656+
return Math.Min(delta, MathF.PI * 2.0f - delta) <= MathF.PI / 36.0f ? 0.0f : delta;
1657+
}
1658+
1659+
private string BlackHoleOrderAnchorDebugText() => C.BlackHoleOrderAnchor switch
1660+
{
1661+
BlackHoleOrderAnchor.KefkaPosition when TryGetKefkaPosition(out var pos) => KefkaAnchorDebugText(pos),
1662+
BlackHoleOrderAnchor.KefkaPosition => "Kefka missing -> N",
1663+
_ => "Arena north"
1664+
};
1665+
1666+
private string KefkaAnchorDebugText() => TryGetKefkaPosition(out var pos) ? KefkaAnchorDebugText(pos) : "Kefka missing -> N";
16491667

1650-
private string OrderAnchorDebugText() => TryGetKefkaPosition(out var pos)
1651-
? $"{(string.IsNullOrWhiteSpace(_kefkaAnchorDebug) ? "Kefka" : _kefkaAnchorDebug)}({pos.X:F1},{pos.Z:F1})"
1652-
: "N";
1668+
private string KefkaAnchorDebugText(Vector3 pos) =>
1669+
$"{(string.IsNullOrWhiteSpace(_kefkaAnchorDebug) ? "Kefka" : _kefkaAnchorDebug)}({pos.X:F1},{pos.Z:F1})";
16531670

16541671
private static Vector3 FlatPosition(Vector3 position) => new(position.X, 0.0f, position.Z);
16551672

@@ -2125,7 +2142,7 @@ private List<int> OrderedActiveBuckets()
21252142

21262143
private List<int> OrderedBuckets()
21272144
{
2128-
var anchor = OrderAnchorAngle();
2145+
var anchor = BlackHoleOrderAnchorAngle();
21292146
return Enumerable.Range(0, 4)
21302147
.OrderBy(bucket => OrderedAngleDistance(SourceAngle(bucket), anchor))
21312148
.ThenBy(bucket => bucket)
@@ -2254,9 +2271,9 @@ private Vector3 FinalTowerPosition(RolePosition role)
22542271
: _finalTowerPositions.OrderBy(position => AngleDistance(DirectionAngle(position), angle)).First();
22552272
}
22562273

2257-
private float FinalPairAnchorAngle() => OrderAnchorAngle();
2274+
private float FinalPairAnchorAngle() => KefkaAnchorAngle();
22582275

2259-
private string FinalPairAnchorDebugText() => $"blackhole-order {OrderAnchorDebugText()}";
2276+
private string FinalPairAnchorDebugText() => $"kefka {KefkaAnchorDebugText()}";
22602277

22612278
private string FinalTowerDebugText() => _finalTowerPositions.Count == 0
22622279
? "none"

0 commit comments

Comments
 (0)