Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some fixes #593

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions BossMod/AI/AIBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public async Task Execute(Actor player, Actor master)
autorot.Preset = target.Target != null ? AIPreset : null;
}
UpdateMovement(player, master, target, gazeImminent || pyreticImminent, misdirectionMode ? autorot.Hints.MisdirectionThreshold : default, !forbidTargeting ? autorot.Hints.ActionsToExecute : null);

}
finally
{
Expand Down Expand Up @@ -236,10 +235,34 @@ private void UpdateMovement(Actor player, Actor master, Targeting target, bool g
}
else if (misdirectionAngle != default && _naviDecision.Destination != null)
{
var turn = (_naviDecision.Destination.Value - player.Position).OrthoL().Dot((_naviDecision.NextWaypoint ?? _naviDecision.Destination).Value - _naviDecision.Destination.Value);
ctrl.NaviTargetPos = turn == 0f ? _naviDecision.Destination
: player.Position + (_naviDecision.Destination.Value - player.Position).Rotate(turn > 0f ? -misdirectionAngle : misdirectionAngle);
ctrl.AllowInterruptingCastByMovement = true;
var dir = _naviDecision.Destination.Value - player.Position;
var distSq = dir.LengthSq();
var threshold = 30f.Degrees();
var forceddir = WorldState.Client.ForcedMovementDirection;
var allowMovement = forceddir.AlmostEqual(Angle.FromDirection(dir), threshold.Rad);
if (allowMovement)
allowMovement = CalculateUnobstructedPathLength(forceddir) >= Math.Min(4f, distSq);
ctrl.NaviTargetPos = allowMovement && distSq >= 0.01f ? _naviDecision.Destination.Value : null;

float CalculateUnobstructedPathLength(Angle dir)
{
var start = _naviCtx.Map.WorldToGrid(player.Position);
if (!_naviCtx.Map.InBounds(start.x, start.y))
return 0;

var end = _naviCtx.Map.WorldToGrid(player.Position + 100f * dir.ToDirection());
var startG = _naviCtx.Map.PixelMaxG[_naviCtx.Map.GridToIndex(start.x, start.y)];
foreach (var p in _naviCtx.Map.EnumeratePixelsInLine(start.x, start.y, end.x, end.y))
{
if (!_naviCtx.Map.InBounds(p.x, p.y) || _naviCtx.Map.PixelMaxG[_naviCtx.Map.GridToIndex(p.x, p.y)] < startG)
{
var dest = _naviCtx.Map.GridToWorld(p.x, p.y, 0.5f, 0.5f);
return (dest - player.Position).LengthSq();
}
}
return float.MaxValue;
}

// debug
//void drawLine(WPos from, WPos to, uint color) => Camera.Instance!.DrawWorldLine(new(from.X, player.PosRot.Y, from.Z), new(to.X, player.PosRot.Y, to.Z), color);
Expand Down
4 changes: 2 additions & 2 deletions BossMod/Autorotation/MiscAI/NormalMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa
// this means that cos(threshold) = speed * dt / 2 / distance
// assuming we wanna move at least for a second, speed is standard 6, threshold of 60 degrees would be fine for distances >= 6
// for micro adjusts, if we move for 1 frame (1/60s), threshold of 60 degrees would be fine for distance 0.1, which is our typical threshold
var threshold = 30.Degrees();
var threshold = 30f.Degrees();
var allowMovement = World.Client.ForcedMovementDirection.AlmostEqual(Angle.FromDirection(dir), threshold.Rad);
if (allowMovement && destinationStrategy == DestinationStrategy.Pathfind)
{
Expand Down Expand Up @@ -190,7 +190,7 @@ private float CalculateUnobstructedPathLength(Angle dir)
if (!_navCtx.Map.InBounds(start.x, start.y))
return 0;

var end = _navCtx.Map.WorldToGrid(Player.Position + 100 * dir.ToDirection());
var end = _navCtx.Map.WorldToGrid(Player.Position + 100f * dir.ToDirection());
var startG = _navCtx.Map.PixelMaxG[_navCtx.Map.GridToIndex(start.x, start.y)];
foreach (var p in _navCtx.Map.EnumeratePixelsInLine(start.x, start.y, end.x, end.y))
{
Expand Down
2 changes: 1 addition & 1 deletion BossMod/BossModule/AIHints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void Clear()
RecommendedPositional = default;
ForbiddenDirections.Clear();
ImminentSpecialMode = default;
MisdirectionThreshold = 15.Degrees();
MisdirectionThreshold = 15f.Degrees();
PredictedDamage.Clear();
MaxCastTime = float.MaxValue;
ForceCancelCast = false;
Expand Down
8 changes: 4 additions & 4 deletions BossMod/BossModule/BossModuleHintsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class BossModuleHintsWindow : UIWindow

public override void PreOpenCheck()
{
IsOpen = _mgr.Config.HintsInSeparateWindow && (_mgr.ActiveModule != null || ShowZoneModule());
IsOpen = BossModuleManager.Config.HintsInSeparateWindow && (_mgr.ActiveModule != null || ShowZoneModule());
Flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse;
if (_mgr.Config.Lock)
if (BossModuleManager.Config.Lock)
Flags |= ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoInputs;
if (_mgr.Config.HintsInSeparateWindowTransparent)
if (BossModuleManager.Config.HintsInSeparateWindowTransparent)
Flags |= ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoBackground;
ForceMainWindow = _mgr.Config.HintsInSeparateWindowTransparent; // NoBackground flag without ForceMainWindow works incorrectly for whatever reason
ForceMainWindow = BossModuleManager.Config.HintsInSeparateWindowTransparent; // NoBackground flag without ForceMainWindow works incorrectly for whatever reason
}

public override void Draw()
Expand Down
14 changes: 7 additions & 7 deletions BossMod/BossModule/BossModuleMainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ public class BossModuleMainWindow : UIWindow
public override void PreOpenCheck()
{
var showZoneModule = ShowZoneModule();
IsOpen = _mgr.Config.Enable && (_mgr.LoadedModules.Count > 0 || showZoneModule);
IsOpen = BossModuleManager.Config.Enable && (_mgr.LoadedModules.Count > 0 || showZoneModule);
ShowCloseButton = _mgr.ActiveModule != null && !showZoneModule;
WindowName = (showZoneModule ? $"Zone module ({_zmm.ActiveModule?.GetType().Name})" : _mgr.ActiveModule != null ? $"Boss module ({_mgr.ActiveModule.GetType().Name})" : "Loaded boss modules") + _windowID;
Flags = ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse;
if (_mgr.Config.TrishaMode)
if (BossModuleManager.Config.TrishaMode)
Flags |= ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoBackground;
if (_mgr.Config.Lock)
if (BossModuleManager.Config.Lock)
Flags |= ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoInputs;
ForceMainWindow = _mgr.Config.TrishaMode; // NoBackground flag without ForceMainWindow works incorrectly for whatever reason
ForceMainWindow = BossModuleManager.Config.TrishaMode; // NoBackground flag without ForceMainWindow works incorrectly for whatever reason

if (_mgr.Config.ShowWorldArrows && _mgr.ActiveModule != null && _mgr.WorldState.Party[PartyState.PlayerSlot] is var pc && pc != null)
if (BossModuleManager.Config.ShowWorldArrows && _mgr.ActiveModule != null && _mgr.WorldState.Party[PartyState.PlayerSlot] is var pc && pc != null)
DrawMovementHints(_mgr.ActiveModule.CalculateMovementHintsForRaidMember(PartyState.PlayerSlot, ref pc), pc.PosRot.Y);
}

Expand Down Expand Up @@ -68,7 +68,7 @@ public override void Draw()
{
try
{
_mgr.ActiveModule.Draw(_mgr.Config.RotateArena ? _mgr.WorldState.Client.CameraAzimuth : _mgr.Config.FlipArena ? 180.Degrees() : default, PartyState.PlayerSlot, !_mgr.Config.HintsInSeparateWindow, true);
_mgr.ActiveModule.Draw(BossModuleManager.Config.RotateArena ? _mgr.WorldState.Client.CameraAzimuth : BossModuleManager.Config.FlipArena ? 180f.Degrees() : default, PartyState.PlayerSlot, !BossModuleManager.Config.HintsInSeparateWindow, true);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -113,5 +113,5 @@ private void OpenModuleConfig()
_ = new BossModuleConfigWindow(_mgr.ActiveModule.Info, _mgr.WorldState);
}

private bool ShowZoneModule() => _mgr.Config.ShowGlobalHints && !_mgr.Config.HintsInSeparateWindow && _mgr.ActiveModule?.StateMachine.ActivePhase == null && (_zmm.ActiveModule?.WantToBeDrawn() ?? false);
private bool ShowZoneModule() => BossModuleManager.Config.ShowGlobalHints && !BossModuleManager.Config.HintsInSeparateWindow && _mgr.ActiveModule?.StateMachine.ActivePhase == null && (_zmm.ActiveModule?.WantToBeDrawn() ?? false);
}
2 changes: 1 addition & 1 deletion BossMod/BossModule/BossModuleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public sealed class BossModuleManager : IDisposable
{
public readonly WorldState WorldState;
public readonly RaidCooldowns RaidCooldowns;
public readonly BossModuleConfig Config = Service.Config.Get<BossModuleConfig>();
public static readonly BossModuleConfig Config = Service.Config.Get<BossModuleConfig>();
private readonly EventSubscriptions _subsciptions;

public List<BossModule> LoadedModules { get; } = [];
Expand Down
4 changes: 2 additions & 2 deletions BossMod/Framework/MovementOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void RMIWalkDetour(void* self, float* sumLeft, float* sumForward, float*
if (misdirectionMode)
{
var thresholdDeg = UserMove != default ? _tweaksConfig.MisdirectionThreshold : MisdirectionThreshold.Deg;
if (thresholdDeg < 180)
if (thresholdDeg < 180f)
{
// note: if we are already moving, it doesn't matter what we do here, only whether 'is input active' function returns true or false
_forcedControlState = ActualMove != default && (Angle.FromDirection(ActualMove) + ForwardMovementDirection() - ForcedMovementDirection->Radians()).Normalized().Abs().Deg <= thresholdDeg;
Expand Down Expand Up @@ -184,7 +184,7 @@ private byte MCIsInputActiveDetour(void* self, byte inputSourceFlags)
return (dirH - ForwardMovementDirection(), dirV);
}

private Angle ForwardMovementDirection() => _legacyMode ? Camera.Instance!.CameraAzimuth.Radians() + 180.Degrees() : GameObjectManager.Instance()->Objects.IndexSorted[0].Value->Rotation.Radians();
private Angle ForwardMovementDirection() => _legacyMode ? Camera.Instance!.CameraAzimuth.Radians() + 180f.Degrees() : GameObjectManager.Instance()->Objects.IndexSorted[0].Value->Rotation.Radians();

private bool PlayerHasMisdirection()
{
Expand Down
32 changes: 23 additions & 9 deletions BossMod/Modules/Dawntrail/Alliance/A10Trash/A10Aquarius.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public enum AID : uint
Agaricus = 41661 // DeathCap->self, 3.0s cast, range 5 circle
}

class CursedSphere(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.CursedSphere), 3);
class WaterIII(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.WaterIII), 7);
class BubbleShower(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.BubbleShower), new AOEShapeCone(6, 30.Degrees()));
class Scoop(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.Scoop), new AOEShapeCone(15, 60.Degrees()));
class Agaricus(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.Agaricus), 5);
class Beatdown(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.Beatdown), new AOEShapeRect(9, 1.5f));
class SpiderWeb(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.SpiderWeb), 6);
class CursedSphere(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.CursedSphere), 3f);
class WaterIII(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.WaterIII), 7f);
class BubbleShower(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.BubbleShower), new AOEShapeCone(6f, 30f.Degrees()));
class Scoop(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.Scoop), new AOEShapeCone(15f, 60f.Degrees()));
class Agaricus(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.Agaricus), 5f);
class Beatdown(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.Beatdown), new AOEShapeRect(9f, 1.5f));
class SpiderWeb(BossModule module) : Components.SimpleAOEs(module, ActionID.MakeSpell(AID.SpiderWeb), 6f);
class HundredFists(BossModule module) : Components.CastInterruptHint(module, ActionID.MakeSpell(AID.HundredFists), showNameInHint: true);

public class A10AquariusStates : StateMachineBuilder
Expand All @@ -51,7 +51,21 @@ public A10AquariusStates(BossModule module) : base(module)
.ActivateOnEnter<SpiderWeb>()
.ActivateOnEnter<HundredFists>()
.ActivateOnEnter<Agaricus>()
.Raw.Update = () => Module.Enemies(A10Aquarius.Trash).All(x => x.IsDeadOrDestroyed);
.Raw.Update = () =>
{
var allDeadOrDestroyed = true;
var enemies = module.Enemies(A10Aquarius.Trash);
var count = enemies.Count;
for (var i = 0; i < count; ++i)
{
if (!enemies[i].IsDeadOrDestroyed)
{
allDeadOrDestroyed = false;
break;
}
}
return allDeadOrDestroyed;
};
}
}

Expand Down Expand Up @@ -80,7 +94,7 @@ public class A10Aquarius(WorldState ws, Actor primary) : BossModule(ws, primary,
new(-410.14f, 755.88f), new(-409.01f, 756.23f), new(-409.3f, 759.38f), new(-409.32f, 760.07f), new(-407.32f, 764.18f),
new(-407.06f, 764.83f), new(-405.69f, 770.83f), new(-402.62f, 778.61f), new(-402.54f, 779.34f), new(-404.95f, 792.13f),
new(-404.88f, 792.77f), new(-403.92f, 794.71f), new(-404.14f, 810.99f), new(-403.93f, 815.01f), new(-412.73f, 817.93f),
new(-413.45f, 818), new(-427.66f, 817.49f), new(-428.17f, 817.69f), new(-429.68f, 822.64f), new(-429.97f, 823.22f),
new(-413.45f, 818f), new(-427.66f, 817.49f), new(-428.17f, 817.69f), new(-429.68f, 822.64f), new(-429.97f, 823.22f),
new(-431.56f, 825.26f), new(-432.02f, 825.68f), new(-432.24f, 825.13f), new(-439.69f, 821.71f), new(-440.34f, 821.33f),
new(-440.26f, 820.77f), new(-440.05f, 820.31f), new(-439.57f, 819.75f), new(-438.55f, 818.8f), new(-436.36f, 816.11f),
new(-436.1f, 815.58f), new(-437.12f, 802.89f), new(-443.22f, 794.68f), new(-443.57f, 786.54f), new(-441.28f, 772.63f),
Expand Down
Loading