Skip to content

Commit

Permalink
Merge pull request #634 from erdelf/vbmModuleRange
Browse files Browse the repository at this point in the history
Vbm module range
  • Loading branch information
erdelf authored Nov 12, 2024
2 parents a05fa1c + 3046984 commit fb3e83b
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 19 deletions.
48 changes: 31 additions & 17 deletions AutoDuty/AutoDuty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

namespace AutoDuty;

using System.Globalization;

// TODO:
// Scrapped interable list, going to implement an internal list that when a interactable step end in fail, the Dataid gets add to the list and is scanned for from there on out, if found we goto it and get it, then remove from list.
// Need to expand AutoRepair to include check for level and stuff to see if you are eligible for self repair. and check for dark matter
Expand Down Expand Up @@ -1167,38 +1169,45 @@ internal void SetGeneralSettings(bool on)

internal void SetRotationPluginSettings(bool on, bool ignoreConfig = false)
{
if (!Configuration.AutoManageRotationPluginState && !ignoreConfig) return;
if(!ignoreConfig && !this.Configuration.AutoManageRotationPluginState)
return;
bool bmEnabled = BossMod_IPCSubscriber.IsEnabled;

if (ReflectionHelper.RotationSolver_Reflection.RotationSolverEnabled)
{
if (on)
{
if (ReflectionHelper.RotationSolver_Reflection.GetStateType != ReflectionHelper.RotationSolver_Reflection.StateTypeEnum.Auto)
ReflectionHelper.RotationSolver_Reflection.RotationAuto();

if (bmEnabled && this.Configuration.AutoManageBossModAISettings)
{
BossMod_IPCSubscriber.AddPreset("AutoDuty Passive", Resources.AutoDutyPassivePreset);
BossMod_IPCSubscriber.SetPreset("AutoDuty Passive");
}
}
else
{
if (bmEnabled && this.Configuration.AutoManageBossModAISettings)
BossMod_IPCSubscriber.DisablePresets();

if (ReflectionHelper.RotationSolver_Reflection.GetStateType != ReflectionHelper.RotationSolver_Reflection.StateTypeEnum.Off)
{
ReflectionHelper.RotationSolver_Reflection.RotationStop();
}
}
else if (ReflectionHelper.RotationSolver_Reflection.GetStateType != ReflectionHelper.RotationSolver_Reflection.StateTypeEnum.Off)
ReflectionHelper.RotationSolver_Reflection.RotationStop();
}
else if (BossMod_IPCSubscriber.IsEnabled)
else if (bmEnabled)
{
if (on)
{
//check if our preset does not exist
if (BossMod_IPCSubscriber.Presets_Get("AutoDuty") == null)
{
//load it
Svc.Log.Debug($"AutoDuty Preset Loaded: {BossMod_IPCSubscriber.Presets_Create(Resources.AutoDutyPreset, true)}");
}

//set it as the active preset for both
if (BossMod_IPCSubscriber.Presets_GetActive() != "AutoDuty")
BossMod_IPCSubscriber.Presets_SetActive("AutoDuty");
BossMod_IPCSubscriber.AddPreset("AutoDuty", Resources.AutoDutyPreset);
BossMod_IPCSubscriber.SetPreset("AutoDuty");
}
else
{
//set disabled as preset
if (!BossMod_IPCSubscriber.Presets_GetForceDisabled())
BossMod_IPCSubscriber.Presets_SetForceDisabled();
BossMod_IPCSubscriber.DisablePresets();
}
}
}
Expand Down Expand Up @@ -1231,11 +1240,12 @@ internal void SetBMSettings(bool defaults = false)
Chat.ExecuteCommand($"/vbm cfg AIConfig FollowDuringActiveBossModule {Configuration.FollowDuringActiveBossModule}");
Chat.ExecuteCommand($"/vbm cfg AIConfig FollowOutOfCombat {Configuration.FollowOutOfCombat}");
Chat.ExecuteCommand($"/vbm cfg AIConfig FollowTarget {Configuration.FollowTarget}");
Chat.ExecuteCommand($"/vbm cfg AIConfig MaxDistanceToTarget {Configuration.MaxDistanceToTargetFloat}");
Chat.ExecuteCommand($"/vbm cfg AIConfig MaxDistanceToSlot {Configuration.MaxDistanceToSlotFloat}");
Chat.ExecuteCommand($"/vbm cfg AIConfig DesiredPositional {Configuration.PositionalEnum}");
}

BossMod_IPCSubscriber.SetRange(Plugin.Configuration.MaxDistanceToTargetFloat);

Chat.ExecuteCommand($"/vbmai follow {(Configuration.FollowSelf ? Player.Name : ((Configuration.FollowRole && !ConfigTab.FollowName.IsNullOrEmpty()) ? ConfigTab.FollowName : (Configuration.FollowSlot ? $"Slot{Configuration.FollowSlotInt}" : Player.Name)))}");

if (!bmr && false)
Expand Down Expand Up @@ -1688,6 +1698,10 @@ private unsafe void OnCommand(string command, string args)
Svc.Log.Info($"{tt?.RowId}");
ImGui.SetClipboardText($"{tt?.RowId}");
break;
case "range":
if (float.TryParse(argsArray[1], out float newRange))
BossMod_IPCSubscriber.SetRange(Math.Clamp(newRange, 1, 30));
break;
case "spew":
IGameObject? spewObj = null;
if (argsArray.Length == 2)
Expand Down
41 changes: 40 additions & 1 deletion AutoDuty/IPC/IPCSubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
using ECommons.DalamudServices;
using AutoDuty.Properties;
using ECommons.Automation;
using ECommons.DalamudServices;
using ECommons.EzIpcManager;
using ECommons.Reflection;
using FFXIVClientStructs.FFXIV.Client.Game;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Numerics;
using System.Threading;
using System.Threading.Tasks;
#nullable disable

namespace AutoDuty.IPC
{

internal static class AutoRetainer_IPCSubscriber
{
private static EzIPCDisposalToken[] _disposalTokens = EzIPC.Init(typeof(AutoRetainer_IPCSubscriber), "AutoRetainer.PluginState", SafeWrapper.IPCException);
Expand Down Expand Up @@ -78,8 +82,43 @@ internal static class BossMod_IPCSubscriber
[EzIPC("Presets.ClearActive", true)] internal static readonly Func<bool> Presets_ClearActive;
[EzIPC("Presets.GetForceDisabled", true)] internal static readonly Func<bool> Presets_GetForceDisabled;
[EzIPC("Presets.SetForceDisabled", true)] internal static readonly Func<bool> Presets_SetForceDisabled;
/** string presetName, string moduleTypeName, string trackName, string value*/
[EzIPC("Presets.AddTransientStrategy")] internal static readonly Func<string, string, string, string, bool> Presets_AddTransientStrategy;

internal static void Dispose() => IPCSubscriber_Common.DisposeAll(_disposalTokens);

public static void AddPreset(string name, string preset)
{
//check if our preset does not exist
if (Presets_Get(name) == null)
//load it
Svc.Log.Debug($"AutoDuty Preset Loaded: {Presets_Create(preset, true)}");
}

public static void SetPreset(string name)
{
if (Presets_GetActive() != name)
Presets_SetActive(name);
}

public static void DisablePresets()
{
if (!Presets_GetForceDisabled())
Presets_SetForceDisabled();
}

public static void SetRange(float range)
{
if(IPCSubscriber_Common.IsReady("BossModReborn"))
{
Plugin.Chat.ExecuteCommand($"/vbm cfg AIConfig MaxDistanceToTarget {range}");
}
else
{
Presets_AddTransientStrategy("AutoDuty", "BossMod.Autorotation.MiscAI.StayCloseToTarget", "range", MathF.Round(range, 1).ToString(CultureInfo.InvariantCulture));
Presets_AddTransientStrategy("AutoDuty Passive", "BossMod.Autorotation.MiscAI.StayCloseToTarget", "range", MathF.Round(range, 1).ToString(CultureInfo.InvariantCulture));
}
}
}

/* Seem's YesAlready is not Initializing this
Expand Down
14 changes: 14 additions & 0 deletions AutoDuty/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions AutoDuty/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@
<data name="AutoDutyPreset" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\AutoDuty.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AutoDutyPassivePreset" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\AutoDuty_Passive.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
3 changes: 2 additions & 1 deletion AutoDuty/Resources/AutoDuty.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
"Track": "LShot",
"Option": "Opener"
}
]
],
"BossMod.Autorotation.MiscAI.StayCloseToTarget": []
}
}
6 changes: 6 additions & 0 deletions AutoDuty/Resources/AutoDuty_Passive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Name": "AutoDuty Passive",
"Modules": {
"BossMod.Autorotation.MiscAI.StayCloseToTarget": []
}
}

0 comments on commit fb3e83b

Please sign in to comment.