Skip to content

Commit

Permalink
Merge pull request #108 from FFXIV-CombatReborn/aoe-rework
Browse files Browse the repository at this point in the history
Reworked AoE into a three way system: On/Full/Cleave
  • Loading branch information
LTS-FFXIV authored Apr 18, 2024
2 parents 9d424c1 + e1145f4 commit b7bfd36
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 122 deletions.
22 changes: 3 additions & 19 deletions RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using RotationSolver.Basic.Configuration;
using static RotationSolver.Basic.Configuration.ConfigTypes;

namespace RotationSolver.Basic.Actions;

Expand Down Expand Up @@ -39,23 +40,6 @@ public struct ActionTargetInfo(IBaseAction action)
/// </summary>
public readonly bool IsTargetFriendly => action.Setting.IsFriendly;

private static bool NoAOE
{
get
{
if (!Service.Config.UseAoeAction) return true;

if (DataCenter.IsManual)
{
if (!Service.Config.UseAoeWhenManual) return true;
}

return Service.Config.ChooseAttackMark
&& !Service.Config.CanAttackMarkAoe
&& MarkingHelper.HaveAttackChara;
}
}

#region Target Finder.
private readonly IEnumerable<BattleChara> GetCanTargets(bool skipStatusProvideCheck, TargetType type)
{
Expand Down Expand Up @@ -409,8 +393,8 @@ private readonly IEnumerable<BattleChara> GetAffects(BattleChara tar, IEnumerabl
private readonly IEnumerable<BattleChara> GetMostCanTargetObjects(IEnumerable<BattleChara> canTargets, IEnumerable<BattleChara> canAffects, int aoeCount)
{
if (IsSingleTarget || EffectRange <= 0) return canTargets;
if (!action.Setting.IsFriendly && NoAOE) return [];
if (aoeCount > 1 && DataCenter.IsManual) return [];
if (!action.Setting.IsFriendly && Service.Config.AoEType == AoEType.Off) return [];
if (aoeCount > 1 && Service.Config.AoEType == AoEType.Cleave) return [];

List<BattleChara> objectMax = new(canTargets.Count());

Expand Down
35 changes: 35 additions & 0 deletions RotationSolver.Basic/Configuration/ConfigTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.Basic.Configuration
{
/// <summary>
/// Various types used in the configuration.
/// </summary>
public class ConfigTypes
{
/// <summary>
/// The type of AoE actions to use.
/// </summary>
public enum AoEType
{
/// <summary>
/// No AoE.
/// </summary>
Off = 0,

/// <summary>
/// Only single-target AoE.
/// </summary>
Cleave = 1,

/// <summary>
/// Full AoE.
/// </summary>
Full = 2,
}
}
}
11 changes: 4 additions & 7 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using ECommons.ExcelServices;
using Newtonsoft.Json.Linq;
using RotationSolver.Basic.Configuration.Timeline;
using static RotationSolver.Basic.Configuration.ConfigTypes;

namespace RotationSolver.Basic.Configuration;

Expand Down Expand Up @@ -40,6 +41,8 @@ public const string
public MacroInfo DutyStart { get; set; } = new MacroInfo();
public MacroInfo DutyEnd { get; set; } = new MacroInfo();

public AoEType AoEType { get; set; } = AoEType.Full;

[ConditionBool, UI("Show RSR logo animation",
Filter = UiWindows)]
private static readonly bool _drawIconAnimation = false;
Expand Down Expand Up @@ -205,7 +208,7 @@ public const string
private static readonly bool _startOnAttackedBySomeone = false;

[ConditionBool, UI("Don't attack new mobs by AoE. (Dangerous)", Description = "Never use any AoE action when this may attack the mobs that are not hostile targets.",
Parent =nameof(UseAoeAction))]
Filter = BasicAutoSwitch)]
private static readonly bool _noNewHostiles = false;

[ConditionBool, UI("Use healing abilities when playing a non-healer role.",
Expand Down Expand Up @@ -327,12 +330,6 @@ public const string
Filter =UiInformation)]
private static readonly bool _showToastsAboutDoAction = false;

[ConditionBool, UI("Use AoE actions", Filter = AutoActionUsage)]
private static readonly bool _useAOEAction = true;

[ConditionBool, UI("Use single target AoE actions in manual mode.", Parent = nameof(UseAoeAction))]
private static readonly bool _useAOEWhenManual = false;

[ConditionBool, UI("Automatically trigger dps burst phase.", Filter = AutoActionCondition)]
private static readonly bool _autoBurst = true;

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Data/RSCommandType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public enum StateCommandType : byte
///
/// </summary>
[Description("Stop the addon. Always remember to turn it off when it is not in use!")]
Cancel,
Off,

/// <summary>
///
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void IncrementState()
if (!DataCenter.State) { DoStateCommandType(StateCommandType.Auto); return; }
if (DataCenter.State && !DataCenter.IsManual && DataCenter.TargetingType == TargetingType.Big) { DoStateCommandType(StateCommandType.Auto); return; }
if (DataCenter.State && !DataCenter.IsManual) { DoStateCommandType(StateCommandType.Manual); return; }
if (DataCenter.State && DataCenter.IsManual) { DoStateCommandType(StateCommandType.Cancel); return; }
if (DataCenter.State && DataCenter.IsManual) { DoStateCommandType(StateCommandType.Off); return; }
}

internal static unsafe bool CanDoAnAction(bool isGCD)
Expand Down Expand Up @@ -170,7 +170,7 @@ internal static void ResetSpecial()
}
internal static void CancelState()
{
if (DataCenter.State) DoStateCommandType(StateCommandType.Cancel);
if (DataCenter.State) DoStateCommandType(StateCommandType.Off);
}

static float _lastCountdownTime = 0;
Expand Down
64 changes: 36 additions & 28 deletions RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,58 +40,66 @@ private static void DoOtherCommand(OtherCommandType otherType, string str)
private static void DoSettingCommand(string str)
{
var strs = str.Split(' ');
var settingName = strs[0];
var value = strs.LastOrDefault();


foreach (var property in typeof(Configs).GetRuntimeProperties()
.Where(p => p.GetMethod?.IsPublic ?? false))
foreach (var property in typeof(Configs).GetRuntimeProperties().Where(p => p.GetMethod?.IsPublic ?? false))
{
if (!str.StartsWith(property.Name, StringComparison.OrdinalIgnoreCase)) continue;
if (!settingName.Equals(property.Name, StringComparison.OrdinalIgnoreCase))
continue;

var type = property.PropertyType;

if (type == typeof(ConditionBoolean))
{
type = typeof(bool);
}

object v;
try { v = Convert.ChangeType(value, type); }
catch { v = null; }

if (v == null && type == typeof(bool))
object convertedValue = null;
try
{
var config = property.GetValue(Service.Config);
if (config is ConditionBoolean relay)
if (type.IsEnum)
{
relay.Value = !relay.Value;
v = relay.Value;
convertedValue = Enum.Parse(type, value, ignoreCase: true);
}
else
{
convertedValue = Convert.ChangeType(value, type);
}
}

if (property.PropertyType == typeof(ConditionBoolean))
catch
{
var relay = (ConditionBoolean)property.GetValue(Service.Config)!;
relay.Value = (bool)v!;
v = relay;
if (type == typeof(bool))
{
// Toggle the boolean value if no value is specified
var config = property.GetValue(Service.Config) as ConditionBoolean;
if (config != null)
{
config.Value = !config.Value;
convertedValue = config.Value;
}
}
}

if (v == null)
if (convertedValue == null)
{
#if DEBUG
Svc.Chat.Print("Failed to get the value.");
Svc.Chat.Print("Failed to parse the value.");
#endif
continue;
}

property.SetValue(Service.Config, v);
value = v.ToString();
// If it's a ConditionBoolean, handle it specifically
if (property.PropertyType == typeof(ConditionBoolean))
{
var relay = (ConditionBoolean)property.GetValue(Service.Config)!;
relay.Value = (bool)convertedValue;
convertedValue = relay;
}

//Say out.
Svc.Chat.Print(string.Format(UiString.CommandsChangeSettingsValue.Local(), property.Name, value));
property.SetValue(Service.Config, convertedValue);
value = convertedValue.ToString();

// Notify the user of the change
Svc.Chat.Print(string.Format(UiString.CommandsChangeSettingsValue.Local(), property.Name, value));
return;

}

Svc.Chat.PrintError(UiString.CommandsCannotFindConfig.Local());
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ private static unsafe void DoStateCommandType(StateCommandType stateType, int in
if (DataCenter.IsManual && stateType == StateCommandType.Manual
&& Service.Config.ToggleManual)
{
stateType = StateCommandType.Cancel;
stateType = StateCommandType.Off;
}
else if (stateType == StateCommandType.Auto)
{
if (Service.Config.ToggleAuto)
{
stateType = StateCommandType.Cancel;
stateType = StateCommandType.Off;
}
else
{
Expand All @@ -51,7 +51,7 @@ private static unsafe void DoStateCommandType(StateCommandType stateType, int in

switch (stateType)
{
case StateCommandType.Cancel:
case StateCommandType.Off:
DataCenter.State = false;
break;

Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Localization/EnumTranslations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class EnumTranslations

internal static string ToSayout(this StateCommandType type, JobRole role) => type switch
{
StateCommandType.Cancel => UiString.SpecialCommandType_Cancel.Local(),
StateCommandType.Off => UiString.SpecialCommandType_Cancel.Local(),
_ => type.ToStateString(role),
};

Expand Down Expand Up @@ -50,7 +50,7 @@ internal static class EnumTranslations
{
StateCommandType.Auto => UiString.SpecialCommandType_Smart.Local() + DataCenter.TargetingType.Local(),
StateCommandType.Manual => UiString.SpecialCommandType_Manual.Local(),
StateCommandType.Cancel => UiString.SpecialCommandType_Off.Local(),
StateCommandType.Off => UiString.SpecialCommandType_Off.Local(),
_ => string.Empty,
};
}
Loading

0 comments on commit b7bfd36

Please sign in to comment.