Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/awgil/ffxiv_bossmod into wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xanunderscore committed Sep 30, 2024
2 parents 38daead + a56c450 commit 4fe2a15
Show file tree
Hide file tree
Showing 35 changed files with 671 additions and 124 deletions.
4 changes: 3 additions & 1 deletion BossMod/Autorotation/Standard/StandardWAR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,9 @@ private GCDPriority FellCleavePriorityBerserk()
}
}
var nextAction = wantAOEAction ? NextComboAOE(comboStepsRemaining == 0) : NextComboSingleTarget(wantSERoute, comboStepsRemaining == 0);
var riskOvercappingGauge = Gauge + GaugeGainedFromAction(nextAction) > 100;

var needInfuriateSoon = Unlocked(WAR.AID.Infuriate) && !CanFitGCD(InfuriateCD - InfuriateCDReduction - InfuriateCDLeeway, 1);
var riskOvercappingGauge = Gauge + GaugeGainedFromAction(nextAction) > (needInfuriateSoon ? 50 : 100);

// first deal with forced combo; for ST extension, we generally want to minimize overcap by using combo finisher as late as possible
// TODO: reconsider what to do if we can't fit in combo - do we still want to do partial combo? especially if it would cause gauge overcap
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Autorotation/Utility/ClassDRKUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa

var dashStrategy = strategy.Option(Track.Shadowstride).As<DashStrategy>();
if (ShouldUseDash(dashStrategy, primaryTarget))
Hints.ActionsToExecute.Push(ActionID.MakeSpell(DRK.AID.Shadowstride), Player, obl.Priority());
Hints.ActionsToExecute.Push(ActionID.MakeSpell(DRK.AID.Shadowstride), primaryTarget, obl.Priority());
}
private bool ShouldUseDash(DashStrategy strategy, Actor? primaryTarget) => strategy switch
{
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Autorotation/Utility/ClassGNBUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa

var dashStrategy = strategy.Option(Track.Trajectory).As<DashStrategy>();
if (ShouldUseDash(dashStrategy, primaryTarget))
Hints.ActionsToExecute.Push(ActionID.MakeSpell(GNB.AID.Trajectory), Player, hoc.Priority());
Hints.ActionsToExecute.Push(ActionID.MakeSpell(GNB.AID.Trajectory), primaryTarget, hoc.Priority());
}
private bool ShouldUseDash(DashStrategy strategy, Actor? primaryTarget) => strategy switch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,48 @@
using ImGuiNET;
using System.Reflection;

namespace BossMod.Config;
namespace BossMod;

public sealed class ChangelogProperties : ConfigNode
public sealed record class VersionedField(ConfigNode Node, FieldInfo FieldInfo, Version AddedVersion)
{
public Version BossModVersion { get; set; } = new(0, 0, 0, 0);
public string FieldKey => $"{Node}.{FieldInfo.Name}";
}

public class ChangelogWindow(Version old, List<VersionedField> fields) : UIWindow("VBM Changelog", false, new(400, 300))
public class ConfigChangelogWindow : UIWindow
{
private readonly List<string> ProcessedFields = [];
private readonly Version PreviousVersion;
private readonly List<VersionedField> Fields;

private void SetOption(VersionedField field, bool value)
public ConfigChangelogWindow() : base("VBM Changelog", true, new(400, 300))
{
field.FieldInfo.SetValue(field.Node, value);
ProcessedFields.Add(field.FieldKey);
if (ProcessedFields.Count >= fields.Count)
PreviousVersion = GetPreviousPluginVersion();
Service.Config.AssemblyVersion = GetCurrentPluginVersion();
if (Service.Config.AssemblyVersion != PreviousVersion)
{
IsOpen = false;
Service.Config.Modified.Fire();
Fields = GetAllFields().Where(f => f.AddedVersion > PreviousVersion).ToList();
}
else
{
Fields = [];
}

if (Fields.Count == 0)
{
// nothing interesting to show...
IsOpen = false;
Dispose();
}
}

public override void Draw()
{
ImGui.TextUnformatted($"The following config options have been added since version {old}:");
ImGui.TextUnformatted($"The following config options have been added since version {PreviousVersion}:");

ImGui.Separator();

foreach (var group in fields.Where(f => !ProcessedFields.Contains(f.FieldKey)).GroupBy(f => f.Node.GetType()))
Action? postIteration = null;
foreach (var group in Fields.GroupBy(f => f.Node.GetType()))
{
ImGui.TextUnformatted(group.Key.GetCustomAttribute<ConfigDisplayAttribute>()?.Name ?? "");
foreach (var f in group)
Expand All @@ -46,44 +59,23 @@ public override void Draw()
ImGui.TextUnformatted(disp?.Label ?? "unknown");
ImGui.SameLine();
if (ImGui.Button("Enable"))
{
SetOption(f, true);
return;
}
postIteration += () => SetOption(f, true);
ImGui.SameLine();
if (ImGui.Button("Disable"))
{
SetOption(f, false);
return;
}
postIteration += () => SetOption(f, false);
}
}
postIteration?.Invoke();
}
}

public record VersionedField(ConfigNode Node, FieldInfo FieldInfo, Version AddedVersion)
{
public string FieldKey => $"{Node}.{FieldInfo.Name}";
}

public static class ChangelogDisplay
{
private static Version GetCurrentPluginVersion()
private void SetOption(VersionedField field, bool value)
{
#if DEBUG
// version is always 0.0.0.0 in debug, making it useless for testing
return new(0, 0, 0, 999);
#endif
return Assembly.GetExecutingAssembly().GetName().Version!;
}
field.FieldInfo.SetValue(field.Node, value);
Service.Config.Modified.Fire();

private static Version GetPreviousPluginVersion(ChangelogProperties props)
{
#if DEBUG
// change value to something sensible if you want to test the changelog stuff
return new(0, 0, 0, 999);
#endif
return props.BossModVersion;
Fields.Remove(field);
if (Fields.Count == 0)
IsOpen = false;
}

private static IEnumerable<VersionedField> GetAllFields()
Expand All @@ -100,28 +92,30 @@ private static IEnumerable<VersionedField> GetAllFields()

if (sinceNode != null)
yield return new(n, f, Version.Parse(sinceNode));

else if (f.GetCustomAttribute<PropertyDisplayAttribute>()?.Since is string sinceVersion)
yield return new(n, f, Version.Parse(sinceVersion));
}
}
}

public static void UpdateAndNotifyUser()
private static Version GetCurrentPluginVersion()
{
var props = Service.Config.Get<ChangelogProperties>();
var previousVersion = GetPreviousPluginVersion(props);
var currentVersion = GetCurrentPluginVersion();

props.BossModVersion = currentVersion;
#if DEBUG
// version is always 0.0.0.0 in debug, making it useless for testing
return new(0, 0, 0, 999);
#else
return Assembly.GetExecutingAssembly().GetName().Version!;
#endif
}

var fields = GetAllFields().Where(f => f.AddedVersion > previousVersion).ToList();
if (fields.Count > 0)
{
var win = new ChangelogWindow(previousVersion, fields)
{
IsOpen = true
};
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1024:Use properties where appropriate")]
private static Version GetPreviousPluginVersion()
{
#if DEBUG
// change value to something sensible if you want to test the changelog stuff
return new(0, 0, 0, 999);
#else
return Service.Config.AssemblyVersion;
#endif
}
}
3 changes: 3 additions & 0 deletions BossMod/Config/ConfigRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class ConfigRoot
private const int _version = 10;

public Event Modified = new();
public Version AssemblyVersion = new(); // we use this to show newly added config options
private readonly Dictionary<Type, ConfigNode> _nodes = [];

public IEnumerable<ConfigNode> Nodes => _nodes.Values;
Expand Down Expand Up @@ -45,6 +46,7 @@ public void LoadFromFile(FileInfo file)
var node = type != null ? _nodes.GetValueOrDefault(type) : null;
node?.Deserialize(jconfig.Value, ser);
}
AssemblyVersion = json.RootElement.TryGetProperty(nameof(AssemblyVersion), out var jver) ? new(jver.GetString() ?? "") : new();
}
catch (Exception e)
{
Expand Down Expand Up @@ -75,6 +77,7 @@ public void SaveToFile(FileInfo file)
n.Serialize(jwriter, ser);
}
jwriter.WriteEndObject();
jwriter.WriteString(nameof(AssemblyVersion), AssemblyVersion.ToString());
});
}
catch (Exception e)
Expand Down
3 changes: 1 addition & 2 deletions BossMod/Framework/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BossMod.Autorotation;
using BossMod.QuestBattle;
using BossMod.Config;
using Dalamud.Common;
using Dalamud.Game;
using Dalamud.Game.ClientState.Conditions;
Expand Down Expand Up @@ -104,7 +103,7 @@ public unsafe Plugin(IDalamudPluginInterface dalamud, ICommandManager commandMan
dalamud.UiBuilder.Draw += DrawUI;
dalamud.UiBuilder.OpenConfigUi += () => OpenConfigUI();

ChangelogDisplay.UpdateAndNotifyUser();
_ = new ConfigChangelogWindow();
}

public void Dispose()
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Modules/Dawntrail/Hunt/RankA/Heshuala.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public override void OnCastStarted(Actor caster, ActorCastInfo spell)
if (offset != default)
{
for (int i = 0; i < _numCharges; ++i)
_aoes.Add(new(_shapeSpinshock, caster.Position, spell.Rotation + i * 90.Degrees(), Module.CastFinishAt(spell, i * 2.7f)));
_aoes.Add(new(_shapeSpinshock, caster.Position, spell.Rotation + i * offset, Module.CastFinishAt(spell, i * 2.7f)));
_aoes.Add(new(_shapeCross, caster.Position, spell.Rotation + _crossOffset, Module.CastFinishAt(spell, _numCharges * 2.7f + 3.7f)));
}
}
Expand Down
4 changes: 3 additions & 1 deletion BossMod/Modules/Dawntrail/Hunt/RankA/SallyTheSweeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ExecutionModel(BossModule module) : Components.GenericAOEs(module)
private readonly List<AOEShape> _shapes = [];
private bool _reverse;
private DateTime _activation;
private Angle _rotation;

private static readonly AOEShapeCircle _shapeCircle = new(10);
private static readonly AOEShapeDonut _shapeDonut = new(10, 40);
Expand All @@ -35,7 +36,7 @@ class ExecutionModel(BossModule module) : Components.GenericAOEs(module)
public override IEnumerable<AOEInstance> ActiveAOEs(int slot, Actor actor)
{
if (_activation != default && _shapes.Count > 0)
yield return new(_shapes[_reverse ? ^1 : 0], Module.PrimaryActor.Position, Module.PrimaryActor.Rotation, _activation);
yield return new(_shapes[_reverse ? ^1 : 0], Module.PrimaryActor.Position, _rotation, _activation);
}

public override void OnCastStarted(Actor caster, ActorCastInfo spell)
Expand All @@ -50,6 +51,7 @@ public override void OnCastStarted(Actor caster, ActorCastInfo spell)
break;
case AID.ExecutionModelCross:
_shapes.Add(_shapeCross);
_rotation = spell.Rotation;
break;
case AID.CodeExecutionFirstCircle:
case AID.CodeExecutionFirstDonut:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class SFizzlingDusterPuff(BossModule module) : FizzlingDusterPuff(module, AID.SF
public static readonly AOEShapeCone ShapeYellow = new(60, 22.5f.Degrees());
}

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 878, NameID = 11369, SortOrder = 5)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 878, NameID = 11369, SortOrder = 5, PlanLevel = 90)]
public class C011NSilkie(WorldState ws, Actor primary) : C011Silkie(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 879, NameID = 11369, SortOrder = 5)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 879, NameID = 11369, SortOrder = 5, PlanLevel = 90)]
public class C011SSilkie(WorldState ws, Actor primary) : C011Silkie(ws, primary);
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class SRushOfMightBack(BossModule module) : RushOfMightBack(module, AID.SRushOfM

public abstract class C012Gladiator(WorldState ws, Actor primary) : BossModule(ws, primary, new(-35, -271), new ArenaBoundsSquare(20));

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 878, NameID = 11387, SortOrder = 8)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 878, NameID = 11387, SortOrder = 8, PlanLevel = 90)]
public class C012NGladiator(WorldState ws, Actor primary) : C012Gladiator(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 879, NameID = 11387, SortOrder = 8)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 879, NameID = 11387, SortOrder = 8, PlanLevel = 90)]
public class C012SGladiator(WorldState ws, Actor primary) : C012Gladiator(ws, primary);
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class SPureFire(BossModule module) : PureFire(module, AID.SPureFireAOE);

public abstract class C013Shadowcaster(WorldState ws, Actor primary) : BossModule(ws, primary, new(289, -105), new ArenaBoundsRect(15, 20));

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 878, NameID = 11393, SortOrder = 9)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 878, NameID = 11393, SortOrder = 9, PlanLevel = 90)]
public class C013NShadowcaster(WorldState ws, Actor primary) : C013Shadowcaster(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 879, NameID = 11393, SortOrder = 9)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 879, NameID = 11393, SortOrder = 9, PlanLevel = 90)]
public class C013SShadowcaster(WorldState ws, Actor primary) : C013Shadowcaster(ws, primary);
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class SThunderVortex(BossModule module) : ThunderVortex(module, AID.SThunderVort

public abstract class C021Shishio(WorldState ws, Actor primary) : BossModule(ws, primary, new(0, -100), new ArenaBoundsSquare(20));

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 946, NameID = 12428, SortOrder = 4)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 946, NameID = 12428, SortOrder = 4, PlanLevel = 90)]
public class C021NShishio(WorldState ws, Actor primary) : C021Shishio(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 947, NameID = 12428, SortOrder = 4)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 947, NameID = 12428, SortOrder = 4, PlanLevel = 90)]
public class C021SShishio(WorldState ws, Actor primary) : C021Shishio(ws, primary);
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class SUnenlightenment(BossModule module) : Unenlightenment(module, AID.SUnenlig

public abstract class C022Gorai(WorldState ws, Actor primary) : BossModule(ws, primary, new(300, -120), new ArenaBoundsSquare(20));

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 946, NameID = 12373, SortOrder = 7)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 946, NameID = 12373, SortOrder = 7, PlanLevel = 90)]
public class C022NGorai(WorldState ws, Actor primary) : C022Gorai(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 947, NameID = 12373, SortOrder = 7)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 947, NameID = 12373, SortOrder = 7, PlanLevel = 90)]
public class C022SGorai(WorldState ws, Actor primary) : C022Gorai(ws, primary);
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class SLateralSlice(BossModule module) : LateralSlice(module, AID.SLateralSlice)

public abstract class C023Moko(WorldState ws, Actor primary) : BossModule(ws, primary, new(-200, 0), new ArenaBoundsSquare(20));

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 946, NameID = 12357, SortOrder = 8)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 946, NameID = 12357, SortOrder = 8, PlanLevel = 90)]
public class C023NMoko(WorldState ws, Actor primary) : C023Moko(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 947, NameID = 12357, SortOrder = 8)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 947, NameID = 12357, SortOrder = 8, PlanLevel = 90)]
public class C023SMoko(WorldState ws, Actor primary) : C023Moko(ws, primary);
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class SHydrobomb(BossModule module) : Hydrobomb(module, AID.SHydrobombAOE);

public abstract class C031Ketuduke(WorldState ws, Actor primary) : BossModule(ws, primary, new(0, 0), new ArenaBoundsSquare(20));

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 979, NameID = 12605, SortOrder = 5)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 979, NameID = 12605, SortOrder = 5, PlanLevel = 90)]
public class C031NKetuduke(WorldState ws, Actor primary) : C031Ketuduke(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 980, NameID = 12605, SortOrder = 5)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 980, NameID = 12605, SortOrder = 5, PlanLevel = 90)]
public class C031SKetuduke(WorldState ws, Actor primary) : C031Ketuduke(ws, primary);
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class SArcaneBlight(BossModule module) : ArcaneBlight(module, AID.SArcaneBlightA

public abstract class C032Lala(WorldState ws, Actor primary) : BossModule(ws, primary, new(200, 0), new ArenaBoundsSquare(20));

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 979, NameID = 12639, SortOrder = 8)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.NBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 979, NameID = 12639, SortOrder = 8, PlanLevel = 90)]
public class C032NLala(WorldState ws, Actor primary) : C032Lala(ws, primary);

[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 980, NameID = 12639, SortOrder = 8)]
[ModuleInfo(BossModuleInfo.Maturity.Verified, PrimaryActorOID = (uint)OID.SBoss, GroupType = BossModuleInfo.GroupType.CFC, GroupID = 980, NameID = 12639, SortOrder = 8, PlanLevel = 90)]
public class C032SLala(WorldState ws, Actor primary) : C032Lala(ws, primary);
Loading

0 comments on commit 4fe2a15

Please sign in to comment.