diff --git a/Resources/RotationSolverRecord.json b/Resources/RotationSolverRecord.json index a85abebc2..eb93efaaf 100644 --- a/Resources/RotationSolverRecord.json +++ b/Resources/RotationSolverRecord.json @@ -1,5 +1,5 @@ { - "ClickingCount": 56901, + "ClickingCount": 56909, "SayingHelloCount": 0, "SaidUsers": [ "Ig4lHXUohMZNIeheUtAtRg==" diff --git a/RotationSolver.Basic/Actions/BaseAction_Target.cs b/RotationSolver.Basic/Actions/BaseAction_Target.cs index 5a23481db..11ad1f2ce 100644 --- a/RotationSolver.Basic/Actions/BaseAction_Target.cs +++ b/RotationSolver.Basic/Actions/BaseAction_Target.cs @@ -45,16 +45,6 @@ public float TimeToKill } } - /// - /// Is this action's target dead? - /// - public bool IsTargetDying => Target?.IsDying() ?? false; - - /// - /// Is this action's target is a boss? - /// - public bool IsTargetBoss => Target?.IsBoss() ?? false; - /// /// Is this action single target? /// @@ -281,7 +271,7 @@ private bool TargetAreaFriend(float range, bool mustUse, PlayerCharacter player) } if (Svc.Targets.Target is BattleChara b && b.DistanceToPlayer() < range && - b.IsBoss() && b.HasPositional() && b.HitboxRadius <= 8) + b.IsBossFromIcon() && b.HasPositional() && b.HitboxRadius <= 8) { Position = b.Position; } diff --git a/RotationSolver.Basic/Actions/IBaseAction.cs b/RotationSolver.Basic/Actions/IBaseAction.cs index f51e6b88b..025c12438 100644 --- a/RotationSolver.Basic/Actions/IBaseAction.cs +++ b/RotationSolver.Basic/Actions/IBaseAction.cs @@ -179,16 +179,6 @@ public interface IBaseAction : IAction /// BattleChara Target { get; } - /// - /// Is target a boss. - /// - bool IsTargetBoss { get; } - - /// - /// Is target will die immediately. - /// - bool IsTargetDying { get; } - /// /// Is this action's target type is target only one. /// diff --git a/RotationSolver.Basic/Configuration/Conditions/TargetCondition.cs b/RotationSolver.Basic/Configuration/Conditions/TargetCondition.cs index d3b4a3df9..9de6ca2db 100644 --- a/RotationSolver.Basic/Configuration/Conditions/TargetCondition.cs +++ b/RotationSolver.Basic/Configuration/Conditions/TargetCondition.cs @@ -56,8 +56,12 @@ protected override bool IsTrueInside(ICustomRotation rotation) result = tar.HasStatus(FromSelf, StatusId); break; - case TargetConditionType.IsBoss: - result = tar.IsBoss(); + case TargetConditionType.IsBossFromTTK: + result = tar.IsBossFromTTK(); + break; + + case TargetConditionType.IsBossFromIcon: + result = tar.IsBossFromIcon(); break; case TargetConditionType.IsDying: @@ -246,7 +250,8 @@ internal enum TargetConditionType : byte IsNull, HasStatus, IsDying, - IsBoss, + IsBossFromTTK, + IsBossFromIcon, InCombat, Distance, StatusEnd, @@ -260,4 +265,7 @@ internal enum TargetConditionType : byte TargetName, ObjectEffect, Vfx, + + [Obsolete("Please use Target type instead.")] + IsBoss = IsBossFromTTK, } \ No newline at end of file diff --git a/RotationSolver.Basic/Helpers/ObjectHelper.cs b/RotationSolver.Basic/Helpers/ObjectHelper.cs index 613c2a6d7..b8b7a7e81 100644 --- a/RotationSolver.Basic/Helpers/ObjectHelper.cs +++ b/RotationSolver.Basic/Helpers/ObjectHelper.cs @@ -52,14 +52,6 @@ public static unsafe bool IsOthersPlayers(this GameObject obj) return false; } - /// - /// Is this target an enemy (can be attacked). - /// - /// - /// - [Obsolete("Please use IsEnemy instead", true)] - public static bool IsNPCEnemy(this GameObject obj) => obj.IsEnemy(); - /// /// Is this target an enemy (can be attacked). /// @@ -113,7 +105,6 @@ or 71344 //Major Quest } internal static unsafe uint GetNamePlateIcon(this GameObject obj) => obj.Struct()->NamePlateIconId; - internal static unsafe void SetNamePlateIcon(this GameObject obj, uint id) => obj.Struct()->NamePlateIconId = id; internal static unsafe EventHandlerType GetEventType(this GameObject obj) => obj.Struct()->EventId.Type; /// @@ -155,18 +146,43 @@ internal static bool CanInterrupt(this BattleChara b) /// /// /// + [Obsolete("Please use IsBossFromTTK or IsBossFromIcon instead", true)] public static bool IsBoss(this BattleChara obj) + { + return IsBossFromTTK(obj); + } + + /// + /// Is character a boss? Calculate from ttk. + /// + /// + /// + public static bool IsBossFromTTK(this BattleChara obj) + { + if (obj == null) return false; + + if (obj.IsDummy() && !Service.Config.GetValue(Configuration.PluginConfigBool.ShowTargetTimeToKill)) return true; + + //Fate + if (obj.GetTimeToKill(true) >= Service.Config.GetValue(Configuration.PluginConfigFloat.BossTimeToKill)) return true; + + return false; + } + + /// + /// Is character a boss? Calculated from the icon. + /// + /// + /// + public static bool IsBossFromIcon(this BattleChara obj) { if (obj == null) return false; - if (obj is PlayerCharacter) return false; if (obj.IsDummy() && !Service.Config.GetValue(Configuration.PluginConfigBool.ShowTargetTimeToKill)) return true; //Icon if (obj.GetObjectNPC()?.Rank is 1 or 2 /*or 4*/ or 6) return true; - //Fate - if (obj.FateId() != 0 && obj.GetTimeToKill(true) >= Service.Config.GetValue(Configuration.PluginConfigFloat.BossTimeToKill)) return true; return false; } @@ -237,11 +253,11 @@ public static float GetTimeToKill(this BattleChara b, bool wholeTime = false) /// public static bool IsAttacked(this BattleChara b) { - foreach (var item in DataCenter.AttackedTargets) + foreach (var (id, time) in DataCenter.AttackedTargets) { - if (item.id == b.ObjectId) + if (id == b.ObjectId) { - return DateTime.Now - item.time > TimeSpan.FromSeconds(1); + return DateTime.Now - time > TimeSpan.FromSeconds(1); } } return false; diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs b/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs index 22403b7d5..b5887dc8b 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Actions.cs @@ -169,7 +169,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption. { FilterForHostiles = bs => bs.Where((Func)(b => { - if (b.IsBoss() || CustomRotation.IsMoving || b.CastActionId == 0) return false; + if (b.IsBossFromIcon() || IsMoving || b.CastActionId == 0) return false; if (!b.IsCastInterruptible || Interject.IsCoolingDown) return true; return false; diff --git a/RotationSolver/Localization/EnumTranslations.cs b/RotationSolver/Localization/EnumTranslations.cs index ec043d5d4..979cbdb8c 100644 --- a/RotationSolver/Localization/EnumTranslations.cs +++ b/RotationSolver/Localization/EnumTranslations.cs @@ -8,7 +8,8 @@ internal static class EnumTranslations { TargetConditionType.HasStatus => LocalizationManager.RightLang.TargetConditionType_HasStatus, TargetConditionType.IsDying => LocalizationManager.RightLang.TargetConditionType_IsDying, - TargetConditionType.IsBoss => LocalizationManager.RightLang.TargetConditionType_IsBoss, + TargetConditionType.IsBossFromTTK => LocalizationManager.RightLang.TargetConditionType_IsBossFromTTK, + TargetConditionType.IsBossFromIcon => LocalizationManager.RightLang.TargetConditionType_IsBossFromIcon, TargetConditionType.InCombat => LocalizationManager.RightLang.TargetConditionType_InCombat, TargetConditionType.Distance => LocalizationManager.RightLang.TargetConditionType_Distance, TargetConditionType.StatusEnd => LocalizationManager.RightLang.TargetConditionType_StatusEnd, @@ -131,7 +132,7 @@ internal static class EnumTranslations _ => string.Empty, }; - internal static string ToStateString(this StateCommandType type, JobRole role) => type switch + internal static string ToStateString(this StateCommandType type, JobRole _) => type switch { StateCommandType.Auto => LocalizationManager.RightLang.SpecialCommandType_Smart + DataCenter.TargetingType.ToName(), StateCommandType.Manual => LocalizationManager.RightLang.SpecialCommandType_Manual, diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index cd56e729c..7b54499a7 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -377,7 +377,8 @@ internal class Strings #region TargetConditionType 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_IsBossFromTTK { get; set; } = "Is Boss From TTK"; + public string TargetConditionType_IsBossFromIcon { get; set; } = "Is Boss From Icon"; public string TargetConditionType_InCombat { get; set; } = "In Combat"; public string TargetConditionType_Distance { get; set; } = "Distance"; public string TargetConditionType_StatusEnd { get; set; } = "Status End";