Skip to content

Commit

Permalink
DUD cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xanunderscore committed Feb 24, 2025
1 parent 0c09afa commit 9760ddb
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 22 deletions.
7 changes: 4 additions & 3 deletions BossMod/ActionTweaks/OutOfCombatActionsTweak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ class OutOfCombatActionsConfig : ConfigNode
[PropertyDisplay("Enable the feature")]
public bool Enabled = false;

[PropertyDisplay("Auto use Peloton when moving out of combat")]
public bool AutoPeloton = true;
// changed name so that it's treated as a new option (that's set to false) since everyone hates this feature and it's extremely hard to find in the settings
[PropertyDisplay("Auto use Peloton when moving out of combat", since: "0.0.0.294")]
public bool AutoPeloton2 = false;
}

// Tweak to automatically use out-of-combat convenience actions (peloton, pet summoning, etc).
Expand Down Expand Up @@ -38,7 +39,7 @@ public void FillActions(Actor player, AIHints hints)
if (!_config.Enabled || player.InCombat || _ws.Client.CountdownRemaining != null || player.MountId != 0 || player.Statuses.Any(s => s.ID is 418 or 2648)) // note: in overworld content, you leave combat on death...
return;

if (_config.AutoPeloton && player.ClassCategory == ClassCategory.PhysRanged && _ws.CurrentTime >= _nextAutoPeloton)
if (_config.AutoPeloton2 && player.ClassCategory == ClassCategory.PhysRanged && _ws.CurrentTime >= _nextAutoPeloton)
{
var movementThreshold = 5 * _ws.Frame.Duration;
if (player.LastFrameMovement.LengthSq() >= movementThreshold * movementThreshold)
Expand Down
41 changes: 39 additions & 2 deletions BossMod/Components/DirectionalParry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,52 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
_ => forbiddenSides.HasFlag(attackDir.Dot(facing.OrthoL()) > 0 ? Side.Left : Side.Right)
};
if (attackingFromForbidden)
{
hints.Add("Attack target from unshielded side!");
}
}

public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
foreach (var (id, targetState) in _actorStates)
{
var target = WorldState.Actors.Find(id);
if (target == null)
continue;

void forbidDirection(Angle offset) => hints.AddForbiddenZone(new AOEShapeCone(100, 45.Degrees()), target.Position, target.Rotation + offset, DateTime.MaxValue, target.InstanceID);

var forbiddenSides = ActiveSides(targetState);
var attackDir = (actor.Position - target.Position).Normalized();
var facing = target.Rotation.ToDirection();
bool attackingFromForbidden = attackDir.Dot(facing) switch
{
> 0.7071067f => forbiddenSides.HasFlag(Side.Front),
< -0.7071067f => forbiddenSides.HasFlag(Side.Back),
_ => forbiddenSides.HasFlag(attackDir.Dot(facing.OrthoL()) > 0 ? Side.Left : Side.Right)
};

if (attackingFromForbidden)
{
hints.SetPriority(target, AIHints.Enemy.PriorityForbidden);

// make AI move to an area where it can attack target safely
if (actor.TargetID == id)
{
if (forbiddenSides.HasFlag(Side.Front))
forbidDirection(default);
if (forbiddenSides.HasFlag(Side.Left))
forbidDirection(90.Degrees());
if (forbiddenSides.HasFlag(Side.Back))
forbidDirection(180.Degrees());
if (forbiddenSides.HasFlag(Side.Right))
forbidDirection(270.Degrees());
}
}
}
}

public override void DrawArenaForeground(int pcSlot, Actor pc)
{
base.DrawArenaForeground(pcSlot, pc);
foreach (var a in ActiveActors)
{
if (_actorStates.TryGetValue(a.InstanceID, out var aState))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Zantetsuken(BossModule module) : Components.GenericAOEs(module)
{
private readonly List<Actor> Casters = [];

public override IEnumerable<AOEInstance> ActiveAOEs(int slot, Actor actor) => Casters.Select(c => new AOEInstance(new AOEShapeRect(70, 19.5f), actor.CastInfo!.LocXZ, actor.CastInfo!.Rotation, Module.CastFinishAt(actor.CastInfo)));
public override IEnumerable<AOEInstance> ActiveAOEs(int slot, Actor actor) => Casters.Select(c => new AOEInstance(new AOEShapeRect(70, 19.5f), c.CastInfo!.LocXZ, c.CastInfo!.Rotation, Module.CastFinishAt(c.CastInfo)));

public override void OnCastStarted(Actor caster, ActorCastInfo spell)
{
Expand Down Expand Up @@ -107,4 +107,7 @@ public LunarOdinStates(BossModule module) : base(module)
}

[ModuleInfo(BossModuleInfo.Maturity.Contributed, GroupType = BossModuleInfo.GroupType.Quest, GroupID = 69602, NameID = 10034)]
public class LunarOdin(WorldState ws, Actor primary) : BossModule(ws, primary, new(146.5f, 84.5f), new ArenaBoundsCircle(20));
public class LunarOdin(WorldState ws, Actor primary) : BossModule(ws, primary, new(146.5f, 84.5f), new ArenaBoundsCircle(20))
{
protected override bool CheckPull() => true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,7 @@ protected override void Exec(Actor? primaryTarget)
}

class AutoGraha(BossModule module) : RotationModule<GrahaAI>(module);
class DirectionalParry(BossModule module) : Components.DirectionalParry(module, 0x3201)
{
public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
if (Module.PrimaryActor.FindStatus(680) != null)
{
hints.AddForbiddenZone(new AOEShapeCone(100, 45.Degrees()), Module.PrimaryActor.Position, Module.PrimaryActor.Rotation, WorldState.FutureTime(10));
}
}
}
class DirectionalParry(BossModule module) : Components.DirectionalParry(module, 0x3201);
class Explosion(BossModule module) : Components.SelfTargetedAOEs(module, ActionID.MakeSpell(AID.Explosion), new AOEShapeCross(80, 5), maxCasts: 2);

class LunarRavanaStates : StateMachineBuilder
Expand All @@ -104,6 +95,9 @@ protected override void CalculateModuleAIHints(int slot, Actor actor, PartyRoles
{
base.CalculateModuleAIHints(slot, actor, assignment, hints);
foreach (var h in hints.PotentialTargets)
h.Priority = h.Actor.FindStatus(SID.Invincibility) == null ? 1 : 0;
if (h.Actor.FindStatus(SID.Invincibility) != null)
h.Priority = AIHints.Enemy.PriorityInvincible;
}

protected override bool CheckPull() => true;
}
Binary file modified BossMod/Pathfinding/ObstacleMaps/938.777.1.bmp
Binary file not shown.
8 changes: 7 additions & 1 deletion BossMod/QuestBattle/QuestBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ protected override void Dispose(bool disposing)

public override void Update()
{
if (!_config.EnableQuestBattles)
return;

if (!_playerLoaded)
{
var player = World.Party.Player();
Expand All @@ -343,6 +346,9 @@ public override void Update()

public override void CalculateAIHints(int playerSlot, Actor player, AIHints hints)
{
if (!_config.EnableQuestBattles)
return;

var restartPathfind = false;

// update combat flag (TODO: the name is not great...)
Expand Down Expand Up @@ -390,7 +396,7 @@ public override void CalculateAIHints(int playerSlot, Actor player, AIHints hint
TryPathfind(player.PosRot.XYZ(), curObjective.Connections[CurrentObjectiveNavigationProgress..]);
}

if (_config.EnableQuestBattles && !Paused && !World.Party.Members[playerSlot].InCutscene)
if (!Paused && !World.Party.Members[playerSlot].InCutscene)
{
MoveNext(player, curObjective, hints);
}
Expand Down
5 changes: 2 additions & 3 deletions BossMod/QuestBattle/Shadowbringers/MSQ/DeathUntoDawn.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BossMod.Autorotation;
using RID = BossMod.Roleplay.AID;
using RID = BossMod.Roleplay.AID;

namespace BossMod.QuestBattle.Shadowbringers.MSQ;

Expand Down Expand Up @@ -86,7 +85,7 @@ public override List<QuestObjective> DefineObjectives(WorldState ws) => [
hints.PathfindMapCenter = new(0, -180);
hints.PathfindMapBounds = new ArenaBoundsCircle(20);
if (!player.InCombat)
hints.PrioritizeAll();
hints.ForcedTarget = hints.PotentialTargets.MinBy(t => player.DistanceToPoint(t.Actor.Position))?.Actor;
_ai.Execute(player, hints);
};
})
Expand Down

0 comments on commit 9760ddb

Please sign in to comment.