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

Commit

Permalink
fix: add integer value into the action sequencer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 28, 2023
1 parent e1009e9 commit 4654e4c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 9 deletions.
2 changes: 2 additions & 0 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ public static void SetSpecialType(SpecialCommandType specialType)
public static bool HasHostilesInMaxRange => NumberOfHostilesInMaxRange > 0;
public static int NumberOfHostilesInRange { get; internal set; }
public static int NumberOfHostilesInMaxRange { get; internal set; }
public static int NumberOfAllHostilesInRange { get; internal set; }
public static int NumberOfAllHostilesInMaxRange { get; internal set; }
public static bool MobsTime { get; internal set; }
public static float AverageDeadTime { get; internal set; }

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.
public PropertyInfo[] AllBools => _allBools ??= GetType().GetStaticProperties<bool>();

PropertyInfo[] _allBytes;
public PropertyInfo[] AllBytes => _allBytes ??= GetType().GetStaticProperties<byte>();
public PropertyInfo[] AllBytesOrInt => _allBytes ??= GetType().GetStaticProperties<byte>().Union(GetType().GetStaticProperties<byte>()).ToArray();

PropertyInfo[] _allFloats;
public PropertyInfo[] AllFloats => _allFloats ??= GetType().GetStaticProperties<float>();
Expand Down
16 changes: 15 additions & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.DalamudServices;
using RotationSolver.Basic.Configuration;

namespace RotationSolver.Basic.Rotations;
public abstract partial class CustomRotation
Expand Down Expand Up @@ -159,6 +158,21 @@ public abstract partial class CustomRotation
/// </summary>
protected static IEnumerable<BattleChara> HostileTargets => DataCenter.HostileTargets;

/// <summary>
/// How many hostile targets in range? 25 for ranged jobs and healer, 3 for melee and tank. This is all can attack.
/// </summary>
public static int NumberOfAllHostilesInRange => DataCenter.NumberOfAllHostilesInRange;

/// <summary>
/// How many hostile targets in max range (25 yalms) regardless of job. This is all can attack.
/// </summary>
public static int NumberOfAllHostilesInMaxRange => DataCenter.NumberOfAllHostilesInMaxRange;

/// <summary>
/// All hostile Targets. This is all can attack.
/// </summary>
protected static IEnumerable<BattleChara> AllHostileTargets => DataCenter.AllHostileTargets;

/// <summary>
/// Average dead time of hostiles.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/ICustomRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public interface ICustomRotation : ITexture
/// <summary>
/// All byte properties.
/// </summary>
PropertyInfo[] AllBytes { get; }
PropertyInfo[] AllBytesOrInt { get; }

/// <summary>
/// All time methods.
Expand Down
24 changes: 19 additions & 5 deletions RotationSolver/ActionSequencer/RotationCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ public override bool IsTrueInside(ICustomRotation rotation)
}
return false;

case ComboConditionType.Byte:
case ComboConditionType.Integer:
if (_prop == null) return false;
if (_prop.GetValue(rotation) is byte by)

var value = _prop.GetValue(rotation);
if (value is byte by)
{
switch (Condition)
{
Expand All @@ -58,6 +60,18 @@ public override bool IsTrueInside(ICustomRotation rotation)
return by == Param1;
}
}
else if (value is int i)
{
switch (Condition)
{
case 0:
return i > Param1;
case 1:
return i < Param1;
case 2:
return i == Param1;
}
}
return false;

case ComboConditionType.Float:
Expand Down Expand Up @@ -125,9 +139,9 @@ public override void DrawInside(ICustomRotation rotation)

break;

case ComboConditionType.Byte:
case ComboConditionType.Integer:
ImGui.SameLine();
ConditionHelper.SearchItemsReflection($"##ByteChoice{GetHashCode()}", _prop?.GetMemberName(), ref searchTxt, rotation.AllBytes, i =>
ConditionHelper.SearchItemsReflection($"##ByteChoice{GetHashCode()}", _prop?.GetMemberName(), ref searchTxt, rotation.AllBytesOrInt, i =>
{
_prop = i;
PropertyName = i.Name;
Expand Down Expand Up @@ -216,7 +230,7 @@ public override void DrawInside(ICustomRotation rotation)
public enum ComboConditionType : byte
{
Bool,
Byte,
Integer,
Float,
Last,
}
3 changes: 2 additions & 1 deletion RotationSolver/Localization/EnumTranslations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal static class EnumTranslations
TargetConditionType.HasStatus => LocalizationManager.RightLang.TargetConditionType_HasStatus,
TargetConditionType.IsDying => LocalizationManager.RightLang.TargetConditionType_IsDying,
TargetConditionType.IsBoss => LocalizationManager.RightLang.TargetConditionType_IsBoss,
TargetConditionType.InCombat => LocalizationManager.RightLang.TargetConditionType_InCombat,
TargetConditionType.Distance => LocalizationManager.RightLang.TargetConditionType_Distance,
TargetConditionType.StatusEnd => LocalizationManager.RightLang.TargetConditionType_StatusEnd,
TargetConditionType.StatusEndGCD => LocalizationManager.RightLang.TargetConditionType_StatusEndGCD,
Expand All @@ -22,7 +23,7 @@ internal static class EnumTranslations
internal static string ToName(this ComboConditionType type) => type switch
{
ComboConditionType.Bool => LocalizationManager.RightLang.ComboConditionType_Bool,
ComboConditionType.Byte => LocalizationManager.RightLang.ComboConditionType_Byte,
ComboConditionType.Integer => LocalizationManager.RightLang.ComboConditionType_Byte,
ComboConditionType.Float => LocalizationManager.RightLang.ComboConditionType_Float,
ComboConditionType.Last => LocalizationManager.RightLang.ComboConditionType_Last,
_ => string.Empty,
Expand Down
3 changes: 3 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ internal partial class Strings
public string TargetConditionType_HasStatus { get; set; } = "Has Status";
public string TargetConditionType_IsDying { get; set; } = "Is Dying";
public string TargetConditionType_IsBoss { get; set; } = "Is Boss";
public string TargetConditionType_InCombat { get; set; } = "In Combat";
public string TargetConditionType_Distance { get; set; } = "Distance";
public string TargetConditionType_StatusEnd { get; set; } = "Status End";
public string TargetConditionType_DeadTime { get; set; } = "Dead Time";
Expand Down Expand Up @@ -417,6 +418,8 @@ internal partial class Strings
{ nameof(CustomRotation.HasHostilesInRange), "Has hostiles in Range"},
{ nameof(CustomRotation.NumberOfHostilesInRange), "The number of hostiles in Range"},
{ nameof(CustomRotation.NumberOfHostilesInMaxRange), "The number of hostiles in max Range"},
{ nameof(CustomRotation.NumberOfAllHostilesInRange), "The number of all hostiles in Range"},
{ nameof(CustomRotation.NumberOfAllHostilesInMaxRange), "The number of all hostiles in max Range"},
{ nameof(CustomRotation.InBurst), "In burst."},

{ nameof(CustomRotation.CanHealAreaAbility), "Can heal area ability"},
Expand Down
4 changes: 4 additions & 0 deletions RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ private unsafe static void UpdateHostileTargets(IEnumerable<BattleChara> allTarg

DataCenter.NumberOfHostilesInMaxRange = DataCenter.HostileTargets.Count(o => o.DistanceToPlayer() <= 25);

DataCenter.NumberOfAllHostilesInRange = DataCenter.AllHostileTargets.Count(o => o.DistanceToPlayer() <= JobRange);

DataCenter.NumberOfAllHostilesInMaxRange = DataCenter.AllHostileTargets.Count(o => o.DistanceToPlayer() <= 25);

DataCenter.MobsTime = DataCenter.HostileTargets.Count(o => o.DistanceToPlayer() <= JobRange && o.CanSee())
>= Service.Config.GetValue(PluginConfigInt.AutoDefenseNumber);

Expand Down

0 comments on commit 4654e4c

Please sign in to comment.