Skip to content

Commit

Permalink
Merge pull request #129 from FFXIV-CombatReborn/mergeWIP2
Browse files Browse the repository at this point in the history
codeanalyzer fixes
  • Loading branch information
CarnifexOptimus authored Jun 10, 2024
2 parents fc6ff4a + 404fd82 commit b3f9acb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
31 changes: 16 additions & 15 deletions BossMod/AI/AIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void Dispose()
{
SwitchToIdle();
_dtrBarEntry.Dispose();
_wndAI.Dispose();
Service.ChatGui.ChatMessage -= OnChatMessage;
Service.CommandManager.RemoveHandler("/bmrai");
Service.CommandManager.RemoveHandler("/vbmai");
Expand Down Expand Up @@ -148,45 +149,45 @@ private void OnCommand(string cmd, string message)

var configModified = false;

switch (messageData[0].ToLowerInvariant())
switch (messageData[0].ToUpperInvariant())
{
case "on":
case "ON":
configModified = EnableConfig(true);
break;
case "off":
case "OFF":
configModified = EnableConfig(false);
break;
case "toggle":
case "TOGGLE":
configModified = ToggleConfig();
break;
case "targetmaster":
case "TARGETMASTER":
configModified = ToggleFocusTargetLeader();
break;
case "follow":
case "FOLLOW":
configModified = HandleFollowCommand(messageData);
break;
case "debug":
case "UI":
configModified = ToggleDebugMenu();
break;
case "forbidactions":
case "FORBIDACTIONS":
configModified = ToggleForbidActions();
break;
case "forbidmovement":
case "FORDBIDMOVEMENT":
configModified = ToggleForbidMovement();
break;
case "followoutofcombat":
case "FOLLOWOUTOFCOMBAT":
configModified = ToggleFollowOutOfCombat();
break;
case "followcombat":
case "FOLLOWCOMBAT":
configModified = ToggleFollowCombat();
break;
case "followmodule":
case "FOLLOWMODULE":
configModified = ToggleFollowModule();
break;
case "followtarget":
case "FOLLOWTARGET":
configModified = ToggleFollowTarget();
break;
case "positional":
case "POSITIONAL":
configModified = HandlePositionalCommand(messageData);
break;
default:
Expand Down Expand Up @@ -258,7 +259,7 @@ private bool HandleFollowCommand(string[] messageData)
private bool ToggleDebugMenu()
{
_config.DrawUI = !_config.DrawUI;
Service.Log($"[AI] Debug menu is now {(_config.DrawUI ? "enabled" : "disabled")}");
Service.Log($"[AI] AI menu is now {(_config.DrawUI ? "enabled" : "disabled")}");
return true;
}

Expand Down
25 changes: 21 additions & 4 deletions BossMod/Config/ConfigUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public void Draw()
}
}

private readonly Dictionary<string, string> _availableCommands = new()
private readonly Dictionary<string, string> _availableAICommands = new()
{
{ "on", "Enables the AI." },
{ "off", "Disables the AI." },
{ "toggle", "Toggles the AI on/off." },
{ "targetmaster", "Toggles the focus on target leader." },
{ "follow slotX", "Follows the specified slot, eg. Slot1." },
{ "follow name", "Follows the specified party member by name." },
{ "debug", "Toggles the debug menu." },
{ "ui", "Toggles the AI menu." },
{ "forbidactions", "Toggles the forbidding of actions. (only for autorotation)" },
{ "forbidmovement", "Toggles the forbidding of movement." },
{ "followcombat", "Toggles following during combat." },
Expand All @@ -93,16 +93,33 @@ public void Draw()
{ "positional X", "Switch to positional when following targets. (any, rear, flank, front)" }
};

private readonly Dictionary<string, string> _availableOtherCommands = new()
{
{ "a", "Toggles autorotation." },
{ "d", "Opens the debug menu." },
{ "r", "Opens the replay menu." },
{ "gc", "Triggers the garbage collection." },
{ "cfg", "Lists all configs." }
};

private void DrawAvailableCommands()
{
ImGui.Text("Available Commands:");
ImGui.Separator();
foreach (var command in _availableCommands)
ImGui.Text("AI:");
ImGui.Separator();
foreach (var command in _availableAICommands)
{
ImGui.Text($"/bmrai {command.Key}: {command.Value}");
}
ImGui.Separator();
ImGui.Text("To ensure plugin compatibility: /vbmai can be used instead of /bmrai");
ImGui.Text("Other commands:");
ImGui.Separator();
foreach (var command in _availableOtherCommands)
{
ImGui.Text($"/bmr {command.Key}: {command.Value}");
}
ImGui.Text("/vbm can be used instead of /bmr and /vbmai can be used instead of /bmrai");
}

private void DrawReadMe()
Expand Down
5 changes: 5 additions & 0 deletions BossMod/Framework/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void Dispose()

private void OnCommand(string cmd, string args)
{
var autorotConfig = Service.Config.Get<AutorotationConfig>();
Service.Log($"OnCommand: {cmd} {args}");
var split = args.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (split.Length == 0)
Expand Down Expand Up @@ -131,6 +132,10 @@ private void OnCommand(string cmd, string args)
case "r":
_wndReplay.SetVisible(!_wndReplay.IsOpen);
break;
case "a":
autorotConfig.Enabled = !autorotConfig.Enabled;
autorotConfig.Modified.Fire();
break;
}
}

Expand Down
13 changes: 7 additions & 6 deletions BossMod/Modules/Endwalker/Dungeon/D03Vanaspati/D033Svarbhanu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public override void OnEventCast(Actor caster, ActorCastEvent spell)
_aoes.RemoveAt(0);
}
}

class CosmicKissRaidwide(BossModule module) : Components.RaidwideCast(module, ActionID.MakeSpell(AID.CosmicKiss));

class CosmicKissKnockback(BossModule module) : Components.KnockbackFromCastTarget(module, ActionID.MakeSpell(AID.CosmicKiss), 13)
Expand All @@ -178,22 +179,22 @@ public override void OnCastStarted(Actor caster, ActorCastInfo spell)
public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
var forbidden = new List<Func<WPos, float>>();
var component = Module.FindComponent<ChaoticUndercurrent>()!.ActiveAOEs(slot, actor);
if (component.Any() && Sources(slot, actor).Any() || activation > Module.WorldState.CurrentTime) // 0.8s delay to wait for action effect
var component = Module.FindComponent<ChaoticUndercurrent>()?.ActiveAOEs(slot, actor)?.ToList();
if (component != null && component.Count != 0 && Sources(slot, actor).Any() || activation > Module.WorldState.CurrentTime) // 0.8s delay to wait for action effect
{
if (component.Any(x => x.Origin.Z == -152) && component.Any(x => x.Origin.Z == -162))
if (component!.Any(x => x.Origin.Z == -152) && component!.Any(x => x.Origin.Z == -162))
{
forbidden.Add(ShapeDistance.InvertedCone(Module.Center, 7, Degrees0, Degrees45));
forbidden.Add(ShapeDistance.InvertedCone(Module.Center, 7, Degrees180, Degrees45));
}
else if (component.Any(x => x.Origin.Z == -142) && component.Any(x => x.Origin.Z == -172))
else if (component!.Any(x => x.Origin.Z == -142) && component!.Any(x => x.Origin.Z == -172))
{
forbidden.Add(ShapeDistance.InvertedCone(Module.Center, 7, Degrees90, Degrees45));
forbidden.Add(ShapeDistance.InvertedCone(Module.Center, 7, -Degrees90, Degrees45));
}
else if (component.Any(x => x.Origin.Z == -142) && component.Any(x => x.Origin.Z == -152))
else if (component!.Any(x => x.Origin.Z == -142) && component!.Any(x => x.Origin.Z == -152))
forbidden.Add(ShapeDistance.InvertedCone(Module.Center, 7, Degrees180, Degrees90));
else if (component.Any(x => x.Origin.Z == -162) && component.Any(x => x.Origin.Z == -172))
else if (component!.Any(x => x.Origin.Z == -162) && component!.Any(x => x.Origin.Z == -172))
forbidden.Add(ShapeDistance.InvertedCone(Module.Center, 7, Degrees0, Degrees90));
if (forbidden.Count > 0)
hints.AddForbiddenZone(p => forbidden.Select(f => f(p)).Max(), activation);
Expand Down

0 comments on commit b3f9acb

Please sign in to comment.