Skip to content

Commit

Permalink
More conservative rasterization for circle bounds + fixed affected FR…
Browse files Browse the repository at this point in the history
…U AI
  • Loading branch information
awgil committed Jan 23, 2025
1 parent 658339b commit 0fdf9ad
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
5 changes: 3 additions & 2 deletions BossMod/BossModule/ArenaBounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ public override WDir ClampToBounds(WDir offset)

private Pathfinding.Map BuildMap()
{
// circle is convex, and pathfinding always aims to cell centers, so we can only block pixels which centers are out of bounds
var map = new Pathfinding.Map(MapResolution, default, Radius, Radius);
int iCell = 0;
var threshold = Radius * Radius / (MapResolution * MapResolution); // square of bounds radius, in grid coordinates
var dy = -map.Height / 2 + 0.5f;
for (int y = 0; y < map.Height; ++y, ++dy)
{
var cy = Math.Abs(dy) + 0.5f; // farthest corner
var dx = -map.Width / 2 + 0.5f;
for (int x = 0; x < map.Width; ++x, ++dx)
{
if (dx * dx + dy * dy > threshold)
var cx = Math.Abs(dx) + 0.5f;
if (cx * cx + cy * cy > threshold)
{
map.PixelMaxG[iCell] = -1000;
}
Expand Down
2 changes: 2 additions & 0 deletions BossMod/Modules/Dawntrail/Ultimate/FRU/FRU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class P5ParadiseLost(BossModule module) : Components.CastCounter(module, ActionI
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.BossP1, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 1006, NameID = 9707, PlanLevel = 100)]
public class FRU(WorldState ws, Actor primary) : BossModule(ws, primary, new(100, 100), new ArenaBoundsCircle(20))
{
public static readonly ArenaBoundsSquare PathfindHugBorderBounds = new(20); // this is a hack to allow precise positioning near border by some mechanics, TODO reconsider

private Actor? _bossP2;
private Actor? _iceVeil;
private Actor? _bossP3;
Expand Down
1 change: 1 addition & 0 deletions BossMod/Modules/Dawntrail/Ultimate/FRU/P1UtopianSky.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
_ => default
};
var range = spreadSpot == 0 ? 13 : 19;
hints.PathfindMapBounds = FRU.PathfindHugBorderBounds;
hints.AddForbiddenZone(ShapeDistance.PrecisePosition(Module.Center + range * direction.ToDirection(), new(0, 1), Module.Bounds.MapResolution, actor.Position, 0.1f), _aoes.Activation);
}
}
Expand Down
5 changes: 4 additions & 1 deletion BossMod/Modules/Dawntrail/Ultimate/FRU/P2DiamondDust.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ class P2DiamondDustSafespots(BossModule module) : BossComponent(module)
public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
if (_safeOffs[slot] != default)
{
hints.PathfindMapBounds = FRU.PathfindHugBorderBounds;
hints.AddForbiddenZone(ShapeDistance.PrecisePosition(Module.Center + _safeOffs[slot], new WDir(0, 1), Module.Bounds.MapResolution, actor.Position, 0.1f));
}
}

public override void DrawArenaForeground(int pcSlot, Actor pc)
Expand Down Expand Up @@ -299,7 +302,7 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
// non-healers should just stack with whatever closest healer is
// before first cast, ignore master's movements
var moveDir = NumCasts > 0 ? master.LastFrameMovement.Normalized() : default;
var capsule = ShapeDistance.Capsule(master.Position + 2 * moveDir, moveDir, 4, 1);
var capsule = ShapeDistance.Capsule(master.Position + 2 * moveDir, moveDir, 4, 1.5f);
hints.AddForbiddenZone(p => -capsule(p), DateTime.MaxValue);
}

Expand Down
12 changes: 6 additions & 6 deletions BossMod/Modules/Dawntrail/Ultimate/FRU/P2MirrorMirror.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
{
0 => -135.Degrees(),
1 => 135.Degrees(),
2 => -90.Degrees(),
3 => 90.Degrees(),
2 => -95.Degrees(),
3 => 95.Degrees(),
_ => default
};
}
else
{
dir = Angle.FromDirection(origin.Actor.Position - Module.Center) + group switch
{
0 => (RedRangedLeftOfMelee ? -90 : 90).Degrees(),
1 => (RedRangedLeftOfMelee ? 90 : -90).Degrees(),
0 => (RedRangedLeftOfMelee ? -95 : 95).Degrees(),
1 => (RedRangedLeftOfMelee ? 95 : -95).Degrees(),
2 => 180.Degrees(),
3 => (RedRangedLeftOfMelee ? -135 : 135).Degrees(),
4 => -90.Degrees(),
5 => 90.Degrees(),
4 => -95.Degrees(),
5 => 95.Degrees(),
6 => (RedRangedLeftOfMelee ? 180 : -135).Degrees(),
7 => (RedRangedLeftOfMelee ? 135 : 180).Degrees(),
_ => default
Expand Down
7 changes: 4 additions & 3 deletions BossMod/Modules/Dawntrail/Ultimate/FRU/P3Apocalypse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.ComponentModel;

namespace BossMod.Dawntrail.Ultimate.FRU;
namespace BossMod.Dawntrail.Ultimate.FRU;

class P3Apocalypse(BossModule module) : Components.GenericAOEs(module)
{
Expand Down Expand Up @@ -268,7 +266,10 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
{
var safeSpot = SafeOffset(slot, out _);
if (safeSpot != default)
{
hints.PathfindMapBounds = FRU.PathfindHugBorderBounds;
hints.AddForbiddenZone(ShapeDistance.PrecisePosition(Module.Center + safeSpot, new(0, 1), Module.Bounds.MapResolution, actor.Position, 0.1f), Spreads.Count > 0 ? Spreads[0].Activation : DateTime.MaxValue);
}
}

public override void DrawArenaForeground(int pcSlot, Actor pc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
}
if (hint.hint.HasFlag(Hint.SafespotPrecise))
{
hints.PathfindMapBounds = FRU.PathfindHugBorderBounds;
hints.AddForbiddenZone(ShapeDistance.PrecisePosition(Module.Center + hint.offset, new(0, 1), Module.Bounds.MapResolution, actor.Position, 0.1f));
}
if (hint.hint.HasFlag(Hint.Maelstrom) && _hourglass != null)
Expand Down
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
immediate plans
- proper circle bounds -> revise everything in fru
- ai refactoring
-- high-level ai modules
--- ordered before standard rotation modules
Expand Down

0 comments on commit 0fdf9ad

Please sign in to comment.