Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Apr 6, 2024
1 parent 195d373 commit 9c94ab2
Show file tree
Hide file tree
Showing 40 changed files with 152 additions and 162 deletions.
112 changes: 57 additions & 55 deletions BossMod/BossModule/AOEShapes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,59 +231,61 @@ private IEnumerable<WPos> ContourPoints(WPos origin, Angle rotation, float offse
yield return origin + dx1 + dy2;
}
}

// TODO: revise and reconsider, not convinced it needs to be here, and it's not well implemented
public class AOEShapeTriangle : AOEShape
{
public float SideLength;
public Angle DirectionOffset;

public AOEShapeTriangle(float sideLength, Angle directionOffset = new())
{
SideLength = sideLength;
DirectionOffset = directionOffset;
}

public override bool Check(WPos position, WPos origin, Angle rotation)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset);
return position.InTri(vertices.p1, vertices.p2, vertices.p3);
}

public override void Draw(MiniArena arena, WPos origin, Angle rotation, uint color = ArenaColor.AOE)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset);
arena.AddTriangleFilled(vertices.p1, vertices.p2, vertices.p3, color);
}

public override void Outline(MiniArena arena, WPos origin, Angle rotation, uint color = ArenaColor.Danger)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset);
arena.AddTriangle(vertices.p1, vertices.p2, vertices.p3, color);
}

public override IEnumerable<IEnumerable<WPos>> Contour(WPos origin, Angle rotation, float offset = 0, float maxError = 1)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset, offset);
return new List<IEnumerable<WPos>> { new[] { vertices.p1, vertices.p2, vertices.p3 } };
}

public override Func<WPos, float> Distance(WPos origin, Angle rotation)
{
// Implementing an exact distance calculation for a triangle shape might be complex and is beyond the scope of this basic implementation.
return p => (p - origin).Length(); // Simplified placeholder
}

private (WPos p1, WPos p2, WPos p3) CalculateVertices(WPos origin, Angle rotation, float offset = 0)
{
// Calculate vertex positions for an equilateral triangle with origin as one vertex
var sideOffset = (SideLength + offset) / 2;
var height = MathF.Sqrt(3) / 2 * (SideLength + offset);
var direction = rotation.ToDirection();
var ortho = direction.OrthoR();

var p1 = origin; // The origin is one of the vertices
var p2 = origin + direction * height - ortho * sideOffset;
var p3 = origin + direction * height + ortho * sideOffset;

return (p1, p2, p3);
}
}
{
public float SideLength;
public Angle DirectionOffset;

public AOEShapeTriangle(float sideLength, Angle directionOffset = new())
{
SideLength = sideLength;
DirectionOffset = directionOffset;
}

public override bool Check(WPos position, WPos origin, Angle rotation)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset);
return position.InTri(vertices.p1, vertices.p2, vertices.p3);
}

public override void Draw(MiniArena arena, WPos origin, Angle rotation, uint color = ArenaColor.AOE)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset);
arena.AddTriangleFilled(vertices.p1, vertices.p2, vertices.p3, color);
}

public override void Outline(MiniArena arena, WPos origin, Angle rotation, uint color = ArenaColor.Danger)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset);
arena.AddTriangle(vertices.p1, vertices.p2, vertices.p3, color);
}

public override IEnumerable<IEnumerable<WPos>> Contour(WPos origin, Angle rotation, float offset = 0, float maxError = 1)
{
var vertices = CalculateVertices(origin, rotation + DirectionOffset, offset);
return new List<IEnumerable<WPos>> { new[] { vertices.p1, vertices.p2, vertices.p3 } };
}

public override Func<WPos, float> Distance(WPos origin, Angle rotation)
{
// Implementing an exact distance calculation for a triangle shape might be complex and is beyond the scope of this basic implementation.
return p => (p - origin).Length(); // Simplified placeholder
}

private (WPos p1, WPos p2, WPos p3) CalculateVertices(WPos origin, Angle rotation, float offset = 0)
{
// Calculate vertex positions for an equilateral triangle with origin as one vertex
var sideOffset = (SideLength + offset) / 2;
var height = MathF.Sqrt(3) / 2 * (SideLength + offset);
var direction = rotation.ToDirection();
var ortho = direction.OrthoR();

var p1 = origin; // The origin is one of the vertices
var p2 = origin + direction * height - ortho * sideOffset;
var p3 = origin + direction * height + ortho * sideOffset;

return (p1, p2, p3);
}
}
10 changes: 5 additions & 5 deletions BossMod/BossModule/ArenaBounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ protected ArenaBounds(WPos center, float halfSize)
var points = (donut, fullCircle) switch
{
(false, false) => CurveApprox.CircleSector(center, outerRadius, centerDirection - halfAngle, centerDirection + halfAngle, MaxApproxError),
(false, true) => CurveApprox.Circle(center, outerRadius, MaxApproxError),
( true, false) => CurveApprox.DonutSector(center, innerRadius, outerRadius, centerDirection - halfAngle, centerDirection + halfAngle, MaxApproxError),
( true, true) => CurveApprox.Donut(center, innerRadius, outerRadius, MaxApproxError),
(false, true) => CurveApprox.Circle(center, outerRadius, MaxApproxError),
(true, false) => CurveApprox.DonutSector(center, innerRadius, outerRadius, centerDirection - halfAngle, centerDirection + halfAngle, MaxApproxError),
(true, true) => CurveApprox.Donut(center, innerRadius, outerRadius, MaxApproxError),
};
return ClipAndTriangulate(points);
}
Expand Down Expand Up @@ -207,6 +207,7 @@ public override WDir ClampToBounds(WDir offset, float scale)
}
}

// TODO: revise and reconsider, not convinced it needs to be here, and it's not well implemented
public class ArenaBoundsTri : ArenaBounds
{
private static readonly float sqrt3 = MathF.Sqrt(3);
Expand Down Expand Up @@ -248,7 +249,6 @@ private float Sign(WPos p1, WPos p2, WPos p3)
return (p1.X - p3.X) * (p2.Z - p3.Z) - (p2.X - p3.X) * (p1.Z - p3.Z);
}


public override float IntersectRay(WPos origin, WDir dir)
{
// Define triangle vertices
Expand All @@ -268,4 +268,4 @@ public override WDir ClampToBounds(WDir offset, float scale = 1)
// This method needs a detailed implementation based on specific requirements
return new WDir(0, 0); // Placeholder to indicate that clamping logic is needed
}
}
}
5 changes: 2 additions & 3 deletions BossMod/Components/Exaflare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public class Line
{
public WPos Next;
public WDir Advance;
public Angle Rotation;
public DateTime NextExplosion;
public float TimeToMove;
public int ExplosionsLeft;
public int MaxShownExplosions;
public Angle Rotation;
}

public AOEShape Shape { get; private init; }
Expand Down Expand Up @@ -41,15 +41,14 @@ public override IEnumerable<AOEInstance> ActiveAOEs(BossModule module, int slot,
{
foreach (var l in Lines)
{
Angle angle = l.Rotation;
int num = Math.Min(l.ExplosionsLeft, l.MaxShownExplosions);
var pos = l.Next;
var time = l.NextExplosion > currentTime ? l.NextExplosion : currentTime;
for (int i = 1; i < num; ++i)
{
pos += l.Advance;
time = time.AddSeconds(l.TimeToMove);
yield return (pos, time, angle);
yield return (pos, time, l.Rotation);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public A30TrashPack1States(BossModule module) : base(module)
.ActivateOnEnter<PelagicCleaver2Hint>()
.ActivateOnEnter<WaterFlood>()
.ActivateOnEnter<DivineFlood>()
.Raw.Update = () => module.Enemies(OID.Boss).All(e => e.IsDestroyed) && module.Enemies(OID.Triton).All(e => e.IsDead) && module.Enemies(OID.WaterSprite).All(e => e.IsDead) && module.Enemies(OID.WaterSprite).All(e => e.IsDead);
.Raw.Update = () => module.Enemies(OID.Boss).All(e => e.IsDestroyed) && module.Enemies(OID.Triton).All(e => e.IsDead) && module.Enemies(OID.WaterSprite).All(e => e.IsDead) && module.Enemies(OID.WaterSprite).All(e => e.IsDead);
}
}

Expand All @@ -67,4 +67,4 @@ protected override void DrawEnemies(int pcSlot, Actor pc)
foreach (var e in Enemies(OID.WaterSprite))
Arena.Actor(e, ArenaColor.Enemy);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public enum OID : uint
Triton = 0x4011, // R1.950, x2
DivineSprite = 0x4012, // R1.600, x3
WaterSprite = 0x4085, // R0.800, x5
};
}

public enum AID : uint
{
Expand All @@ -19,4 +19,4 @@ public enum AID : uint
WaterBurst = 35443, // Water Sprite->self, no cast, range 40 circle, raidwide when Water Sprite dies
DivineFlood = 35440, // Divine Sprite->self, 3.0s cast, range 6 circle
DivineBurst = 35441, // Divine Sprite->self, no cast, range 40 circle, raidwide when Divine Sprite dies
};
}
52 changes: 26 additions & 26 deletions BossMod/Modules/Endwalker/Alliance/A31Thaliak/A31Thaliak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,62 @@ public Katarraktes() : base(ActionID.MakeSpell(AID.KatarraktesAOE), "Raidwide +

class Thlipsis : Components.StackWithCastTargets
{
public Thlipsis() : base(ActionID.MakeSpell(AID.ThlipsisStack), 6) { }
public Thlipsis() : base(ActionID.MakeSpell(AID.ThlipsisStack), 6) { }
}

class Hydroptosis : Components.SpreadFromCastTargets
{
public Hydroptosis() : base(ActionID.MakeSpell(AID.HydroptosisSpread), 6) { }
public Hydroptosis() : base(ActionID.MakeSpell(AID.HydroptosisSpread), 6) { }
}

class Rhyton : Components.GenericBaitAway
{
private static readonly AOEShapeRect _shape = new(70, 3);
private static readonly AOEShapeRect _shape = new(70, 3);

public override void OnEventIcon(BossModule module, Actor actor, uint iconID)
{
if (iconID == (uint)IconID.RhytonBuster)
CurrentBaits.Add(new(module.PrimaryActor, actor, _shape));
}
public override void OnEventIcon(BossModule module, Actor actor, uint iconID)
{
if (iconID == (uint)IconID.RhytonBuster)
CurrentBaits.Add(new(module.PrimaryActor, actor, _shape));
}

public override void OnEventCast(BossModule module, Actor caster, ActorCastEvent spell)
public override void OnEventCast(BossModule module, Actor caster, ActorCastEvent spell)
{
if ((AID)spell.Action.ID == AID.RhytonHelper)
{
++NumCasts;
CurrentBaits.Clear();
}
if ((AID)spell.Action.ID == AID.RhytonHelper)
{
++NumCasts;
CurrentBaits.Clear();
}
}

public override void AddGlobalHints(BossModule module, GlobalHints hints)
{
if (CurrentBaits.Count > 0)
hints.Add("Tankbuster cleave");
}
public override void AddGlobalHints(BossModule module, GlobalHints hints)
{
if (CurrentBaits.Count > 0)
hints.Add("Tankbuster cleave");
}
}

class LeftBank : Components.SelfTargetedAOEs
{
public LeftBank() : base(ActionID.MakeSpell(AID.LeftBank), new AOEShapeCone(60, 90.Degrees())) { }
public LeftBank() : base(ActionID.MakeSpell(AID.LeftBank), new AOEShapeCone(60, 90.Degrees())) { }
}

class LeftBank2 : Components.SelfTargetedAOEs
{
public LeftBank2() : base(ActionID.MakeSpell(AID.LeftBank2), new AOEShapeCone(60, 90.Degrees())) { }
public LeftBank2() : base(ActionID.MakeSpell(AID.LeftBank2), new AOEShapeCone(60, 90.Degrees())) { }
}

class RightBank : Components.SelfTargetedAOEs
{
public RightBank() : base(ActionID.MakeSpell(AID.RightBank), new AOEShapeCone(60, 90.Degrees())) { }
public RightBank() : base(ActionID.MakeSpell(AID.RightBank), new AOEShapeCone(60, 90.Degrees())) { }
}

class RightBank2 : Components.SelfTargetedAOEs
{
public RightBank2() : base(ActionID.MakeSpell(AID.RightBank2), new AOEShapeCone(60, 90.Degrees())) { }
public RightBank2() : base(ActionID.MakeSpell(AID.RightBank2), new AOEShapeCone(60, 90.Degrees())) { }
}

[ModuleInfo(BossModuleInfo.Maturity.Contributed, Contributors = "Malediktus, LTS", GroupType = BossModuleInfo.GroupType.CFC, GroupID = 962, NameID = 11298)]
public class A31Thaliak : BossModule
{
public A31Thaliak(WorldState ws, Actor primary) : base(ws, primary, new ArenaBoundsSquare(new(-945, 945), 24)) { }
}
public A31Thaliak(WorldState ws, Actor primary) : base(ws, primary, new ArenaBoundsSquare(new(-945, 945), 24)) { }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace BossMod.Endwalker.Alliance.A31Thaliak;

public enum OID : uint
{
Boss = 0x404C, // R9.496, x1
Expand Down Expand Up @@ -63,4 +64,4 @@ public enum IconID : uint
RhytonBuster = 471, // player
ClockwiseHieroglyphika = 487, // HieroglyphikaIndicator
CounterClockwiseHieroglyphika = 490, // HieroglyphikaIndicator
};
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace BossMod.Endwalker.Alliance.A31Thaliak;

class A31ThaliakStates : StateMachineBuilder
{
{
public A31ThaliakStates(BossModule module) : base(module)
{
TrivialPhase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Hieroglyphika : Components.GenericAOEs
private static readonly AOEShapeRect rect = new(6, 6, 6);
private readonly List<AOEInstance> _aoes = [];
private const float RadianConversion = MathF.PI / 180;
private static readonly WPos[] StartingCoords = [new(-963, 939), new(-963, 963), new(-939, 927), new (-951, 939), new(-951, 927), new(-939, 963), new(-927, 939), new(-939, 951), new(-939, 939), new(-927, 963), new(-963, 951), new(-927, 951), new(-951, 951), new(-963, 927)];
private static readonly WPos[] StartingCoords = [new(-963, 939), new(-963, 963), new(-939, 927), new(-951, 939), new(-951, 927), new(-939, 963), new(-927, 939), new(-939, 951), new(-939, 939), new(-927, 963), new(-963, 951), new(-927, 951), new(-951, 951), new(-963, 927)];
private byte currentIndex;

public override IEnumerable<AOEInstance> ActiveAOEs(BossModule module, int slot, Actor actor) => _aoes.Take(14);
Expand All @@ -16,13 +16,14 @@ class Hieroglyphika : Components.GenericAOEs
float z = MathF.Sin(rotatebydegrees * RadianConversion) * (caster.X - origin.X) + MathF.Cos(rotatebydegrees * RadianConversion) * (caster.Z - origin.Z);
return new WPos(origin.X + x, origin.Z + z);
}

public override void OnEventEnvControl(BossModule module, byte index, uint state)
{
if (state == 0x00020001)
{
if (index == 0x17)
if (index == 0x17)
currentIndex = 0x17;
if (index == 0x4A)
if (index == 0x4A)
currentIndex = 0x4A;
}
}
Expand All @@ -38,13 +39,13 @@ public override void OnEventIcon(BossModule module, Actor actor, uint iconID)
_aoes.Add(new(rect, RotateAroundOrigin(0, origin, r), default, _activation));
if (currentIndex == 0x4A)
foreach (var r in StartingCoords)
_aoes.Add(new(rect, RotateAroundOrigin(-90, origin, r), default, _activation));
_aoes.Add(new(rect, RotateAroundOrigin(-90, origin, r), default, _activation));
}
if (iconID == (uint)IconID.CounterClockwiseHieroglyphika)
{
if (currentIndex == 0x4A)
foreach (var r in StartingCoords)
_aoes.Add(new(rect, RotateAroundOrigin(90, origin, r), default, _activation));
_aoes.Add(new(rect, RotateAroundOrigin(90, origin, r), default, _activation));
if (currentIndex == 0x17)
foreach (var r in StartingCoords)
_aoes.Add(new(rect, RotateAroundOrigin(180, origin, r), default, _activation));
Expand All @@ -56,4 +57,4 @@ public override void OnEventCast(BossModule module, Actor caster, ActorCastEvent
if (_aoes.Count > 0 && (AID)spell.Action.ID is AID.HieroglyphikaRect)
_aoes.Clear();
}
}
}
Loading

0 comments on commit 9c94ab2

Please sign in to comment.