Skip to content

Commit

Permalink
Merge pull request #549 from FFXIV-CombatReborn/mergeWIP
Browse files Browse the repository at this point in the history
BA Raiden module, Chaotic tile setting, other random changes
  • Loading branch information
CarnifexOptimus authored Jan 11, 2025
2 parents b2f135c + 3a54b9e commit c4d355f
Show file tree
Hide file tree
Showing 61 changed files with 1,202 additions and 430 deletions.
2 changes: 1 addition & 1 deletion BossMod/BossModule/AOEShapes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public override Func<WPos, float> Distance(WPos origin, Angle rotation)
public sealed record class AOEShapeCross(float Length, float HalfWidth, Angle DirectionOffset = default, bool InvertForbiddenZone = false) : AOEShape
{
public override string ToString() => $"Cross: l={Length:f3}, w={HalfWidth * 2}, off={DirectionOffset}, ifz={InvertForbiddenZone}";
public override bool Check(WPos position, WPos origin, Angle rotation) => position.InRect(origin, rotation + DirectionOffset, Length, Length, HalfWidth) || position.InRect(origin, rotation + DirectionOffset, HalfWidth, HalfWidth, Length);
public override bool Check(WPos position, WPos origin, Angle rotation) => position.InCross(origin, rotation + DirectionOffset, Length, HalfWidth);
public override void Draw(MiniArena arena, WPos origin, Angle rotation, uint color = 0) => arena.ZonePoly((GetType(), origin, rotation + DirectionOffset, Length, HalfWidth), ContourPoints(origin, rotation), color);
public override void Outline(MiniArena arena, WPos origin, Angle rotation, uint color = 0)
{
Expand Down
2 changes: 2 additions & 0 deletions BossMod/BossModule/ArenaBounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ private Pathfinding.Map BuildMap()
public sealed record class ArenaBoundsComplex : ArenaBoundsCustom
{
public readonly WPos Center;
public bool IsCircle; // can be used by gaze component for gazes outside of the arena

public ArenaBoundsComplex(Shape[] UnionShapes, Shape[]? DifferenceShapes = null, Shape[]? AdditionalShapes = null, float MapResolution = Half, float Offset = 0, float ScaleFactor = 1)
: base(BuildBounds(UnionShapes, DifferenceShapes, AdditionalShapes, MapResolution, Offset, ScaleFactor, out var center, out var halfWidth, out var halfHeight))
{
Expand Down
1 change: 1 addition & 0 deletions BossMod/BossModule/BossModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public enum GroupType
CFC, // group id is ContentFinderCondition row
MaskedCarnivale, // group id is ContentFinderCondition row
RemovedUnreal, // group id is ContentFinderCondition row
BaldesionArsenal, // group id is ContentFinderCondition row
Quest, // group id is Quest row
Fate, // group id is Fate row
Hunt, // group id is HuntRank
Expand Down
48 changes: 23 additions & 25 deletions BossMod/BossModule/Shapes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,49 @@ public override List<WDir> Contour(WPos center)
result.Add(Points[i] + offset);
return result;
}

public override string ToString() => $"Circle:{Center.X},{Center.Z},{Radius}";
}

// for custom polygons defined by an IEnumerable of vertices
public sealed record class PolygonCustom(IEnumerable<WPos> Vertices) : Shape
// for custom polygons defined by an IReadOnlyList of vertices
public sealed record class PolygonCustom(IReadOnlyList<WPos> Vertices) : Shape
{
private readonly WPos[] points = [.. Vertices];
public override List<WDir> Contour(WPos center)
{
var len = points.Length;
var result = new List<WDir>(len);
for (var i = 0; i < len; ++i)
result.Add(points[i] - center);
var count = Vertices.Count;
var result = new List<WDir>(count);
for (var i = 0; i < count; ++i)
result.Add(Vertices[i] - center);
return result;
}

public override string ToString()
{
var len = points.Length;
var sb = new StringBuilder($"PolygonCustom:");
for (var i = 0; i < len; ++i)
var count = Vertices.Count;
var sb = new StringBuilder("PolygonCustom:", 14 + count * 15);
for (var i = 0; i < count; ++i)
{
sb.Append(points[i].X).Append(',').Append(points[i].Z);
if (i < len - 1)
sb.Append(',');
var vertex = Vertices[i];
sb.Append(vertex.X).Append(',').Append(vertex.Z).Append(';');
}
--sb.Length;
return sb.ToString();
}
}

// for custom polygons defined by an IEnumerable of vertices with an offset, eg to account for hitbox radius
public sealed record class PolygonCustomO(IEnumerable<WPos> Vertices, float Offset) : Shape
// for custom polygons defined by an IReadOnlyList of vertices with an offset, eg to account for hitbox radius
public sealed record class PolygonCustomO(IReadOnlyList<WPos> Vertices, float Offset) : Shape
{
private readonly WPos[] points = [.. Vertices];
private Path64? path;

public override List<WDir> Contour(WPos center)
{
if (path == null)
{
var originalPath = new Path64();
for (var i = 0; i < points.Length; ++i)
for (var i = 0; i < Vertices.Count; ++i)
{
var v = points[i];
var v = Vertices[i];
originalPath.Add(new Point64((long)(v.X * PolygonClipper.Scale), (long)(v.Z * PolygonClipper.Scale)));
}

Expand All @@ -93,15 +92,14 @@ public override List<WDir> Contour(WPos center)

public override string ToString()
{
var len = points.Length;
var sb = new StringBuilder($"PolygonCustomO:");
for (var i = 0; i < len; ++i)
var count = Vertices.Count;
var sb = new StringBuilder("PolygonCustomO:", 15 + count * 15);
for (var i = 0; i < count; ++i)
{
sb.Append(points[i].X).Append(',').Append(points[i].Z);
if (i < len - 1)
sb.Append(',');
var vertex = Vertices[i];
sb.Append(vertex.X).Append(',').Append(vertex.Z).Append(';');
}
sb.Append(',').Append(Offset);
sb.Append("Offset:").Append(Offset);
return sb.ToString();
}
}
Expand Down
2 changes: 1 addition & 1 deletion BossMod/BossModule/ZoneModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public virtual void DrawExtra() { }

public void DrawGlobalHints()
{
using var color = ImRaii.PushColor(ImGuiCol.Text, 0xffffff00);
using var color = ImRaii.PushColor(ImGuiCol.Text, Colors.TextColor11);
foreach (var hint in CalculateGlobalHints())
{
ImGui.TextUnformatted(hint);
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Components/Exaflare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Line
public readonly AOEShape Shape = shape;
public uint ImminentColor = Colors.Danger;
public uint FutureColor = Colors.AOE;
protected readonly List<Line> Lines = [];
public readonly List<Line> Lines = [];

public bool Active => Lines.Count > 0;

Expand Down
6 changes: 1 addition & 5 deletions BossMod/Components/Gaze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,10 @@ public static void DrawEye(Vector2 eyeCenter, bool danger)

private Vector2 IndicatorScreenPos(WPos eye)
{
if (Arena.InBounds(eye) || Arena.Bounds is not ArenaBoundsCircle and not ArenaBoundsSquare)
if (Arena.InBounds(eye) || Arena.Bounds is not ArenaBoundsCircle && Arena.Bounds is ArenaBoundsComplex circle && !circle.IsCircle)
{
return Arena.WorldPositionToScreenPosition(eye);
}
else if (Arena.Bounds is ArenaBoundsRect)
{
return Arena.WorldPositionToScreenPosition(Arena.ClampToBounds(eye) + 2 * (eye - Arena.Center).Normalized());
}
else
{
var dir = (eye - Arena.Center).Normalized();
Expand Down
30 changes: 23 additions & 7 deletions BossMod/Components/GenericAOEs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// generic component that shows arbitrary shapes representing avoidable aoes
public abstract class GenericAOEs(BossModule module, ActionID aid = default, string warningText = "GTFO from aoe!") : CastCounter(module, aid)
{
public record struct AOEInstance(AOEShape Shape, WPos Origin, Angle Rotation = default, DateTime Activation = default, uint Color = 0, bool Risky = true)
public record struct AOEInstance(AOEShape Shape, WPos Origin, Angle Rotation = default, DateTime Activation = default, uint Color = 0, bool Risky = true, ulong? ActorID = null)
{
public readonly bool Check(WPos pos) => Shape.Check(pos, Origin, Rotation);
}
Expand All @@ -14,8 +14,14 @@ public record struct AOEInstance(AOEShape Shape, WPos Origin, Angle Rotation = d

public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (ActiveAOEs(slot, actor).Any(c => c.Risky && c.Check(actor.Position)))
hints.Add(WarningText);
foreach (var aoe in ActiveAOEs(slot, actor))
{
if (aoe.Risky && aoe.Check(actor.Position))
{
hints.Add(WarningText);
break;
}
}
}

public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
Expand Down Expand Up @@ -106,7 +112,7 @@ public class LocationTargetedAOEs(BossModule module, ActionID aid, AOEShape shap
public uint Color; // can be customized if needed
public bool Risky = true; // can be customized if needed
public readonly bool TargetIsLocation = targetIsLocation; // can be customized if needed
public float RiskyWithSecondsLeft = riskyWithSecondsLeft; // can be used to delay risky status of AOEs, so AI waits longer to dodge, if 0 it will just use the bool Risky
public readonly float RiskyWithSecondsLeft = riskyWithSecondsLeft; // can be used to delay risky status of AOEs, so AI waits longer to dodge, if 0 it will just use the bool Risky

public readonly List<AOEInstance> Casters = [];
public IEnumerable<AOEInstance> ActiveCasters => Casters.Take(MaxCasts);
Expand All @@ -127,13 +133,23 @@ public override IEnumerable<AOEInstance> ActiveAOEs(int slot, Actor actor)
public override void OnCastStarted(Actor caster, ActorCastInfo spell)
{
if (spell.Action == WatchedAction)
Casters.Add(new(Shape, (TargetIsLocation ? WorldState.Actors.Find(caster.CastInfo!.TargetID)?.Position : spell.LocXZ) ?? default, spell.Rotation, Module.CastFinishAt(spell), Color, Risky));
Casters.Add(new(Shape, (TargetIsLocation ? WorldState.Actors.Find(caster.CastInfo!.TargetID)?.Position : spell.LocXZ) ?? default, spell.Rotation, Module.CastFinishAt(spell), Color, Risky, caster.InstanceID));
}

public override void OnCastFinished(Actor caster, ActorCastInfo spell)
{
if (Casters.Count != 0 && spell.Action == WatchedAction)
Casters.RemoveAt(0);
if (spell.Action == WatchedAction)
{
for (var i = 0; i < Casters.Count; ++i)
{
var aoe = Casters[i];
if (aoe.ActorID == caster.InstanceID)
{
Casters.Remove(aoe);
break;
}
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions BossMod/Config/ModuleViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ private void DrawModules(UITree tree, WorldState ws)
return (new(mcName, groupId, mcSort), new(module, BNpcName(module.NameID), module.SortOrder));
case BossModuleInfo.GroupType.RemovedUnreal:
return (new("Removed Content", groupId, groupId), new(module, BNpcName(module.NameID), module.SortOrder));
case BossModuleInfo.GroupType.BaldesionArsenal:
return (new("Baldesion Arsenal", groupId, groupId), new(module, BNpcName(module.NameID), module.SortOrder));
case BossModuleInfo.GroupType.Quest:
var questRow = Service.LuminaRow<Quest>(module.GroupID)!.Value;
groupId |= questRow.JournalGenre.RowId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override void OnCastStarted(Actor caster, ActorCastInfo spell)

public override void OnEventCast(Actor caster, ActorCastEvent spell)
{
if ((AID)spell.Action.ID == AID.ActivePivotParticleBeamAOE && Sequences.Count > 0)
if ((AID)spell.Action.ID == AID.ActivePivotParticleBeamAOE)
AdvanceSequence(0, WorldState.CurrentTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Break(BossModule module) : Components.GenericGaze(module)
{
public readonly List<Eye> Eyes = [];
public readonly List<Eye> Eyes = new(3);

public override IEnumerable<Eye> ActiveEyes(int slot, Actor actor) => Eyes;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BossMod.Dawntrail.Chaotic.Ch01CloudOfDarkness;

[ConfigDisplay(Order = 0x020, Parent = typeof(DawntrailConfig))]
class Ch01CloudOfDarknessConfig() : ConfigNode()
{
[PropertyDisplay("Show occupied tiles on radar", tooltip: "Required for AI to not step on occupied tiles.")]
public bool ShowOccupiedTiles = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public enum OID : uint
{
Boss = 0x461E, // R23.000, x1
Helper = 0x233C, // R0.500, x24, Helper type
StygianShadow = 0x461F, // R4.000, x0 (spawn during fight), big add
Atomos = 0x4620, // R2.800, x0 (spawn during fight), small add
DeathsHand = 0x4621, // R2.000, x6, grim embrace hand
Expand All @@ -14,6 +13,7 @@ public enum OID : uint
SinisterEye = 0x4626, // R2.800, x2, break gaze source
AtomosSpawnPoint = 0x1EBD7B, // R0.500, x0 (spawn during fight), EventObj type
EvilSeed = 0x1E9B3B, // R0.500, x0 (spawn during fight), EventObj type
Helper = 0x233C
}

public enum AID : uint
Expand Down Expand Up @@ -132,7 +132,7 @@ public enum AID : uint
Evaporation = 40454, // StygianShadow->Boss, 2.0s cast, single-target, destroy add and transfer damage done to boss
FloodOfDarkness2 = 40455, // Boss->location, 7.0s cast, range 60 circle, raidwide + arena transition to normal

Enrage = 40533, // Boss->location, 12.0s cast, range 100 circle, enrage
Enrage = 40533 // Boss->location, 12.0s cast, range 100 circle, enrage
}

public enum SID : uint
Expand Down
Loading

0 comments on commit c4d355f

Please sign in to comment.