Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add an option for auto heal.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 17, 2023
1 parent fbd71e8 commit bc4a603
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"3573": 0.6,
"3574": 0.6,
"3576": 0.1,
"3577": 0.1,
"3577": 0.6,
"3578": 0.6,
"3579": 0.1,
"3582": 0.6,
Expand Down
10 changes: 5 additions & 5 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private bool TargetAreaMove(float range, bool mustUse)

private bool TargetAreaFriend(float range, bool mustUse, PlayerCharacter player)
{
if (!Configuration.PluginConfiguration.GetValue(SettingsCommand.UseGroundBeneficialAbility)) return false;
if (!Service.Config.GetValue(SettingsCommand.UseGroundBeneficialAbility)) return false;

if (Service.Config.BeneficialAreaOnTarget && Svc.Targets.Target != null)
{
Expand Down Expand Up @@ -330,8 +330,8 @@ private bool TargetHostileManual(BattleChara b, bool mustUse, int aoeCount, out
return true;
}

if (Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAOEAction)
&& Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAOEWhenManual) || mustUse)
if (Service.Config.GetValue(SettingsCommand.UseAOEAction)
&& Service.Config.GetValue(SettingsCommand.UseAOEWhenManual) || mustUse)
{
if (GetMostObjects(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), aoeCount).Contains(b))
{
Expand All @@ -355,7 +355,7 @@ private bool TargetSelf(bool mustUse, int aoeCount)
//not use when aoe.
if (DataCenter.StateType == StateCommandType.Manual)
{
if (!Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAOEWhenManual) && !mustUse) return false;
if (!Service.Config.GetValue(SettingsCommand.UseAOEWhenManual) && !mustUse) return false;
}

var tars = TargetFilter.GetObjectInRadius(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), EffectRange);
Expand Down Expand Up @@ -520,7 +520,7 @@ private static bool NoAOE
{
get
{
if (!Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAOEAction)) return true;
if (!Service.Config.GetValue(SettingsCommand.UseAOEAction)) return true;

return Service.Config.ChooseAttackMark
&& !Service.Config.CanAttackMarkAOE
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver.Basic/Configuration/MacroInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FFXIVClientStructs.FFXIV.Client.UI.Misc;

namespace RotationSolver.Basic.Configuration;

#pragma warning disable CS1591 // Missing XML comment for publicly visible
public class MacroInfo
{
public int MacroIndex;
Expand All @@ -24,3 +24,4 @@ public unsafe bool AddMacro(GameObject tar = null)
return true;
}
}
#pragma warning restore CS1591 // Missing XML comment for publicly visible
10 changes: 6 additions & 4 deletions RotationSolver.Basic/Configuration/OtherConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace RotationSolver.Basic.Configuration;

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public class InputConfiguration
{
public Dictionary<StateCommandType, KeyRecord> KeyState { get; set; } = new Dictionary<StateCommandType, KeyRecord>();
Expand Down Expand Up @@ -39,16 +40,16 @@ public class InputConfiguration
public class OtherConfiguration
{
public static InputConfiguration InputConfig = new();
public static SortedSet<uint> HostileCastingArea = new();
public static SortedSet<uint> HostileCastingTank = new();
public static HashSet<uint> HostileCastingArea = new();
public static HashSet<uint> HostileCastingTank = new();

public static SortedList<uint, float> AnimationLockTime = new();

public static Dictionary<uint, string[]> NoHostileNames = new();

public static SortedSet<uint> DangerousStatus = new();
public static HashSet<uint> DangerousStatus = new();

public static SortedSet<uint> InvincibleStatus = new();
public static HashSet<uint> InvincibleStatus = new();

public static void Init()
{
Expand Down Expand Up @@ -170,3 +171,4 @@ private static void InitOne<T>(ref T value, string name)
}
}
}
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class PluginConfiguration : IPluginConfiguration

[JsonProperty]
private Dictionary<SettingsCommand, bool> SettingsBools { get; set; } = new Dictionary<SettingsCommand, bool>();
public static bool GetValue(SettingsCommand command) => Service.Config.SettingsBools.TryGetValue(command, out var value) ? value : command.GetDefault();
public static void SetValue(SettingsCommand command, bool value) => Service.Config.SettingsBools[command] = value;
public bool GetValue(SettingsCommand command) => SettingsBools.TryGetValue(command, out var value) ? value : command.GetDefault();
public void SetValue(SettingsCommand command, bool value) => SettingsBools[command] = value;

public int AddDotGCDCount = 2;

Expand Down
2 changes: 2 additions & 0 deletions RotationSolver.Basic/Data/RSCommandType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public enum OtherCommandType : byte
public enum SettingsCommand : byte
{
AutoBurst,
AutoHeal,
UseAbility,
UseDefenseAbility,
AutoTankStance,
Expand All @@ -58,6 +59,7 @@ public static class SettingsCommandExtension
public static bool GetDefault(this SettingsCommand command) => command switch
{
SettingsCommand.AutoBurst => true,
SettingsCommand.AutoHeal => true,
SettingsCommand.UseAbility => true,
SettingsCommand.UseDefenseAbility => true,
SettingsCommand.AutoTankStance => true,
Expand Down
12 changes: 6 additions & 6 deletions RotationSolver.Basic/Rotations/CustomRotation_Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private bool Ability(IAction nextGCD, out IAction act, bool helpDefenseAOE, bool

if(act is IBaseItem i && i.CanUse(out _)) return true;

if (!Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAbility)
if (!Service.Config.GetValue(SettingsCommand.UseAbility)
|| Player.TotalCastTime > 0)
{
act = null;
Expand Down Expand Up @@ -57,7 +57,7 @@ private bool Ability(IAction nextGCD, out IAction act, bool helpDefenseAOE, bool
if (GeneralAbility(out act)) return true;

//Run!
if (IsMoving && NotInCombatDelay && PluginConfiguration.GetValue(SettingsCommand.AutoSpeedOutOfCombat)
if (IsMoving && NotInCombatDelay && Service.Config.GetValue(SettingsCommand.AutoSpeedOutOfCombat)
&& SpeedAbility(out act)) return true;

return false;
Expand Down Expand Up @@ -106,7 +106,7 @@ private bool ShirkOrShield(JobRole role, SpecialCommandType specialType, out IAc
break;
}

if (DataCenter.SetAutoStatus(AutoStatus.TankStance, Configuration.PluginConfiguration.GetValue(SettingsCommand.AutoTankStance)
if (DataCenter.SetAutoStatus(AutoStatus.TankStance, Service.Config.GetValue(SettingsCommand.AutoTankStance)
&& !DataCenter.AllianceTanks.Any(t => t.CurrentHp != 0 && t.HasStatus(false, StatusHelper.TankStanceStatus))
&& !HasTankStance && TankStance.CanUse(out act, CanUseOption.IgnoreClippingCheck)))
{
Expand Down Expand Up @@ -185,15 +185,15 @@ private bool AutoDefense(JobRole role, bool helpDefenseAOE, bool helpDefenseSing

//Auto Provoke
if (DataCenter.SetAutoStatus(AutoStatus.Provoke, role == JobRole.Tank
&& (Configuration.PluginConfiguration.GetValue(SettingsCommand.AutoProvokeForTank) || DataCenter.AllianceTanks.Count() < 2)
&& (Service.Config.GetValue(SettingsCommand.AutoProvokeForTank) || DataCenter.AllianceTanks.Count() < 2)
&& TargetFilter.ProvokeTarget(DataCenter.HostileTargets, true).Count() != DataCenter.HostileTargets.Count()))
{
if (!HasTankStance && TankStance.CanUse(out act)) return true;
if (Provoke.CanUse(out act, CanUseOption.MustUse)) return true;
}

//No using defense abilities.
if (!Configuration.PluginConfiguration.GetValue(SettingsCommand.UseDefenseAbility)) return false;
if (!Service.Config.GetValue(SettingsCommand.UseDefenseAbility)) return false;

if (helpDefenseAOE)
{
Expand Down Expand Up @@ -283,7 +283,7 @@ protected virtual bool EmergencyAbility(IAction nextGCD, out IAction act)
if (ClassJob.GetJobRole() is JobRole.Healer or JobRole.RangedMagical &&
action.CastTime >= 5 && Swiftcast.CanUse(out act, CanUseOption.EmptyOrSkipCombo)) return true;

if (Configuration.PluginConfiguration.GetValue(SettingsCommand.AutoUseTrueNorth)
if (Service.Config.GetValue(SettingsCommand.AutoUseTrueNorth)
&& action.EnemyPositional != EnemyPositional.None && action.Target != null)
{
if (action.EnemyPositional != action.Target.FindEnemyPositional() && action.Target.HasPositional())
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_GCD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private bool RaiseSpell(SpecialCommandType specialType, out IAction act, bool mu
return DataCenter.SetAutoStatus(AutoStatus.Raise, true);
}
}
else if (Configuration.PluginConfiguration.GetValue(SettingsCommand.RaisePlayerBySwift) && !Swiftcast.IsCoolingDown
else if (Service.Config.GetValue(SettingsCommand.RaisePlayerBySwift) && !Swiftcast.IsCoolingDown
&& DataCenter.NextAbilityToNextGCD > DataCenter.MinAnimationLock + DataCenter.Ping)
{
return DataCenter.SetAutoStatus(AutoStatus.Raise, true);
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private IAction Invoke(out IAction gcdAction)
return CountDownAction(countDown);
}

var helpDefenseAOE = Configuration.PluginConfiguration.GetValue(SettingsCommand.UseDefenseAbility) && DataCenter.IsHostileCastingAOE;
var helpDefenseAOE = Service.Config.GetValue(SettingsCommand.UseDefenseAbility) && DataCenter.IsHostileCastingAOE;

bool helpDefenseSingle = false;
if (ClassJob.GetJobRole() == JobRole.Healer || ClassJob.RowId == (uint)ECommons.ExcelServices.Job.PLD)
Expand Down
13 changes: 7 additions & 6 deletions RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.DalamudServices;
using RotationSolver.Basic.Configuration;
using RotationSolver.Basic.Helpers;

namespace RotationSolver.Basic.Rotations;
Expand Down Expand Up @@ -120,17 +121,17 @@ public abstract partial class CustomRotation
/// <summary>
/// Is in burst right now? Usually it used with team support actions.
/// </summary>
protected static bool InBurst => DataCenter.SpecialType == SpecialCommandType.Burst || Configuration.PluginConfiguration.GetValue(SettingsCommand.AutoBurst);
protected static bool InBurst => DataCenter.SpecialType == SpecialCommandType.Burst || Service.Config.GetValue(SettingsCommand.AutoBurst);

bool CanUseHealAction => ClassJob.GetJobRole() == JobRole.Healer || Service.Config.UseHealWhenNotAHealer;
bool _canUseHealAction => (ClassJob.GetJobRole() == JobRole.Healer || Service.Config.UseHealWhenNotAHealer) && Service.Config.GetValue(SettingsCommand.AutoHeal);

protected virtual bool CanHealAreaAbility => DataCenter.CanHealAreaAbility && CanUseHealAction;
protected virtual bool CanHealAreaAbility => DataCenter.CanHealAreaAbility && _canUseHealAction;

protected virtual bool CanHealAreaSpell => DataCenter.CanHealAreaSpell && CanUseHealAction;
protected virtual bool CanHealAreaSpell => DataCenter.CanHealAreaSpell && _canUseHealAction;

protected virtual bool CanHealSingleAbility => DataCenter.CanHealSingleAbility && CanUseHealAction;
protected virtual bool CanHealSingleAbility => DataCenter.CanHealSingleAbility && _canUseHealAction;

protected virtual bool CanHealSingleSpell => DataCenter.CanHealSingleSpell && CanUseHealAction;
protected virtual bool CanHealSingleSpell => DataCenter.CanHealSingleSpell && _canUseHealAction;

protected static SpecialCommandType SpecialType => DataCenter.SpecialType;
protected static StateCommandType StateType => DataCenter.StateType;
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ private static void DoSettingCommand(string str)
return;
}

Basic.Configuration.PluginConfiguration.SetValue(type, !Basic.Configuration.PluginConfiguration.GetValue(type));
Service.Config.SetValue(type, !Service.Config.GetValue(type));

//Say out.
Svc.Chat.Print(string.Format(LocalizationManager.RightLang.Commands_ChangeSettingsValue,
type.ToString(), Basic.Configuration.PluginConfiguration.GetValue(type)));
type.ToString(), Service.Config.GetValue(type)));
}

private static void ToggleActionCommand(string str)
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ internal partial class Strings

public string ConfigWindow_Param_UseAOEWhenManual { get; set; } = "Use AOE actions in manual mode";
public string ConfigWindow_Param_AutoBurst { get; set; } = "Automatic burst";

public string ConfigWindow_Param_AutoHeal { get; set; } = "Automatic Heal";
public string ConfigWindow_Param_UseAbility { get; set; } = "Auto-use abilities";
public string ConfigWindow_Param_NoNewHostiles { get; set; } = "Don't attack new mobs by aoe";
public string ConfigWindow_Params_NoNewHostilesDesc { get; set; } = "Never use any AOE action when this action may attack the mobs that not is a hostile target.";
Expand Down
8 changes: 4 additions & 4 deletions RotationSolver/UI/NextActionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ public override void Draw()
ControlWindow.DrawIAction(ActionUpdater.NextAction, width, 1);

var strs = new List<string>(3);
if(PluginConfiguration.GetValue(SettingsCommand.UseAOEAction)
if(Service.Config.GetValue(SettingsCommand.UseAOEAction)
&& (DataCenter.StateType != StateCommandType.Manual
|| PluginConfiguration.GetValue(SettingsCommand.UseAOEWhenManual)))
|| Service.Config.GetValue(SettingsCommand.UseAOEWhenManual)))
{
strs.Add("AOE");
}
if (PluginConfiguration.GetValue(SettingsCommand.PreventActions))
if (Service.Config.GetValue(SettingsCommand.PreventActions))
{
strs.Add("Prevent");
}
if (PluginConfiguration.GetValue(SettingsCommand.AutoBurst))
if (Service.Config.GetValue(SettingsCommand.AutoBurst))
{
strs.Add("Burst");
}
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public override unsafe void Draw()

internal static void DrawCheckBox(string name, SettingsCommand command, string description = "", Action otherThing = null)
{
var value = Basic.Configuration.PluginConfiguration.GetValue(command);
var value = Service.Config.GetValue(command);
DrawCheckBox(name, ref value, command.GetDefault(), description, () =>
{
Basic.Configuration.PluginConfiguration.SetValue(command, value);
Service.Config.SetValue(command, value);
otherThing?.Invoke();
});

Expand Down
12 changes: 7 additions & 5 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private void DrawParamAction()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseAOEAction,
SettingsCommand.UseAOEAction);

if(Basic.Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAOEAction))
if(Service.Config.GetValue(SettingsCommand.UseAOEAction))
{
ImGui.Indent();
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseAOEWhenManual,
Expand All @@ -318,7 +318,7 @@ private void DrawParamAction()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_PreventActionsIfOutOfCombat,
SettingsCommand.PreventActions);

if (Basic.Configuration.PluginConfiguration.GetValue(SettingsCommand.PreventActions))
if (Service.Config.GetValue(SettingsCommand.PreventActions))
{
ImGui.Indent();
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_PreventActionsIfDutyRing,
Expand All @@ -330,6 +330,8 @@ private void DrawParamAction()

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoBurst, SettingsCommand.AutoBurst);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoHeal, SettingsCommand.AutoHeal);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseTinctures,
ref Service.Config.UseTinctures, Service.Default.UseTinctures);

Expand All @@ -339,7 +341,7 @@ private void DrawParamAction()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseAbility,
SettingsCommand.UseAbility);

if (Basic.Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAbility))
if (Service.Config.GetValue(SettingsCommand.UseAbility))
{
ImGui.Indent();

Expand Down Expand Up @@ -398,7 +400,7 @@ private void DrawParamCondition()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_OnlyHotOnTanks,
ref Service.Config.OnlyHotOnTanks, Service.Default.OnlyHotOnTanks);

if (Basic.Configuration.PluginConfiguration.GetValue(SettingsCommand.UseGroundBeneficialAbility))
if (Service.Config.GetValue(SettingsCommand.UseGroundBeneficialAbility))
{
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_BeneficialAreaOnTarget,
ref Service.Config.BeneficialAreaOnTarget, Service.Default.BeneficialAreaOnTarget);
Expand Down Expand Up @@ -504,7 +506,7 @@ private void DrawParamTarget()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ChooseAttackMark,
ref Service.Config.ChooseAttackMark, Service.Default.ChooseAttackMark);

if (Service.Config.ChooseAttackMark && Basic.Configuration.PluginConfiguration.GetValue(SettingsCommand.UseAOEAction))
if (Service.Config.ChooseAttackMark && Service.Config.GetValue(SettingsCommand.UseAOEAction))
{
ImGui.Indent();

Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ internal static class MajorUpdater
&& !Svc.Condition[ConditionFlag.BetweenAreas51]
&& Player.Available && !SocialUpdater.InPvp;

public static bool ShouldPreventActions => Basic.Configuration.PluginConfiguration.GetValue(SettingsCommand.PreventActions)
&& (Basic.Configuration.PluginConfiguration.GetValue(SettingsCommand.PreventActionsDuty)
public static bool ShouldPreventActions => Service.Config.GetValue(SettingsCommand.PreventActions)
&& (Service.Config.GetValue(SettingsCommand.PreventActionsDuty)
&& Svc.Condition[ConditionFlag.BoundByDuty]
&& !Svc.DutyState.IsDutyStarted
|| !DataCenter.HasHostilesInMaxRange);
Expand Down

0 comments on commit bc4a603

Please sign in to comment.