From b2f15dd0685e1b25f8cd8b0b323593e795dde7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Fri, 25 Aug 2023 11:24:36 +0800 Subject: [PATCH] fix: add mobs time. --- .../Actions/BaseAction_Target.cs | 13 +----------- RotationSolver.Basic/Actions/IBaseAction.cs | 2 +- RotationSolver.Basic/DataCenter.cs | 1 + RotationSolver.Basic/Helpers/ObjectHelper.cs | 20 +++++++++++++++++++ .../Rotations/Basic/WAR_Base.cs | 11 ++++++++-- .../Rotations/CustomRotation_OtherInfo.cs | 6 ++++++ RotationSolver/Localization/Strings.cs | 1 + RotationSolver/UI/RotationConfigWindow.cs | 3 --- RotationSolver/Updaters/TargetUpdater.cs | 4 +++- 9 files changed, 42 insertions(+), 19 deletions(-) diff --git a/RotationSolver.Basic/Actions/BaseAction_Target.cs b/RotationSolver.Basic/Actions/BaseAction_Target.cs index b5c4c7836..958005cf4 100644 --- a/RotationSolver.Basic/Actions/BaseAction_Target.cs +++ b/RotationSolver.Basic/Actions/BaseAction_Target.cs @@ -575,18 +575,7 @@ internal unsafe bool CanUseTo(GameObject tar) if (!IsTargetArea && (ActionID)ID != ActionID.AethericMimicry && !ActionManager.CanUseActionOnTarget(AdjustedID, tarAddress)) return false; - var point = Player.Object.Position + Vector3.UnitY * Player.GameObject->Height; - var tarPt = tar.Position + Vector3.UnitY * tar.Struct()->Height; - var direction = tarPt - point; - - int* unknown = stackalloc int[] { 0x4000, 0, 0x4000, 0 }; - - RaycastHit hit = default; - - if( FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->BGCollisionModule - ->RaycastEx(&hit, point, direction, direction.Length(), 1, unknown)) return false; - - return true; + return tar.CanSee(); } private static bool NoAOE diff --git a/RotationSolver.Basic/Actions/IBaseAction.cs b/RotationSolver.Basic/Actions/IBaseAction.cs index 48a4c54b8..807010885 100644 --- a/RotationSolver.Basic/Actions/IBaseAction.cs +++ b/RotationSolver.Basic/Actions/IBaseAction.cs @@ -94,7 +94,7 @@ public interface IBaseAction : IAction /// /// Options about using this method. /// How many targets do you want this skill to affect - /// The count of gcd for ability to delay. Only used in BLM right now + /// The count of gcd for ability to delay. Make it use it earlier when max stack. /// Should I use. bool CanUse(out IAction act, CanUseOption option = CanUseOption.None, byte aoeCount = 0, byte gcdCountForAbility = 0); diff --git a/RotationSolver.Basic/DataCenter.cs b/RotationSolver.Basic/DataCenter.cs index b47642cb1..d4818e9a4 100644 --- a/RotationSolver.Basic/DataCenter.cs +++ b/RotationSolver.Basic/DataCenter.cs @@ -242,6 +242,7 @@ 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 bool MobsTime { get; internal set; } public static float AverageDeadTime { get; internal set; } public static bool IsHostileCastingAOE { get; internal set; } diff --git a/RotationSolver.Basic/Helpers/ObjectHelper.cs b/RotationSolver.Basic/Helpers/ObjectHelper.cs index f26d95e83..093a67361 100644 --- a/RotationSolver.Basic/Helpers/ObjectHelper.cs +++ b/RotationSolver.Basic/Helpers/ObjectHelper.cs @@ -4,6 +4,7 @@ using ECommons.GameHelpers; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Event; +using FFXIVClientStructs.FFXIV.Common.Component.BGCollision; using Lumina.Excel.GeneratedSheets; namespace RotationSolver.Basic.Helpers; @@ -221,6 +222,25 @@ public static bool IsAttacked(this BattleChara b) return false; } + /// + /// Can the player see the object. + /// + /// + /// + public static unsafe bool CanSee(this GameObject b) + { + var point = Player.Object.Position + Vector3.UnitY * Player.GameObject->Height; + var tarPt = b.Position + Vector3.UnitY * b.Struct()->Height; + var direction = tarPt - point; + + int* unknown = stackalloc int[] { 0x4000, 0, 0x4000, 0 }; + + RaycastHit hit = default; + + return !FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->BGCollisionModule + ->RaycastEx(&hit, point, direction, direction.Length(), 1, unknown); + } + /// /// Get the 's current HP percentage. /// diff --git a/RotationSolver.Basic/Rotations/Basic/WAR_Base.cs b/RotationSolver.Basic/Rotations/Basic/WAR_Base.cs index 49582acd5..4262b2523 100644 --- a/RotationSolver.Basic/Rotations/Basic/WAR_Base.cs +++ b/RotationSolver.Basic/Rotations/Basic/WAR_Base.cs @@ -89,12 +89,18 @@ public abstract class WAR_Base : CustomRotation /// /// 1 /// - public static IBaseAction Overpower { get; } = new BaseAction(ActionID.Overpower); + public static IBaseAction Overpower { get; } = new BaseAction(ActionID.Overpower) + { + AOECount = 2, + }; /// /// 2 /// - public static IBaseAction MythrilTempest { get; } = new BaseAction(ActionID.MythrilTempest); + public static IBaseAction MythrilTempest { get; } = new BaseAction(ActionID.MythrilTempest) + { + AOECount = 2, + }; /// /// @@ -102,6 +108,7 @@ public abstract class WAR_Base : CustomRotation public static IBaseAction SteelCyclone { get; } = new BaseAction(ActionID.SteelCyclone) { ActionCheck = InnerBeast.ActionCheck, + AOECount = 2, }; /// diff --git a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs index c63bc9d55..be4a91bed 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs @@ -2,6 +2,7 @@ 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 @@ -173,6 +174,11 @@ public static bool IsLongerThan(float time) if (IsInHighEndDuty) return true; return AverageDeadTime > time; } + + /// + /// Now, it is attacking the mobs! + /// + public static bool MobsTime => DataCenter.MobsTime; #endregion #region Command diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index a2d2613d8..75decd4b8 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -451,6 +451,7 @@ internal partial class Strings { nameof(CustomRotation.ShowStatus), "Show the status"}, { nameof(CustomRotation.AverageDeadTime), "Average dead time"}, + { nameof(CustomRotation.MobsTime), "Mobs Time"}, #endregion #region AST diff --git a/RotationSolver/UI/RotationConfigWindow.cs b/RotationSolver/UI/RotationConfigWindow.cs index 275910419..a7a078942 100644 --- a/RotationSolver/UI/RotationConfigWindow.cs +++ b/RotationSolver/UI/RotationConfigWindow.cs @@ -20,9 +20,6 @@ using RotationSolver.UI.SearchableSettings; using RotationSolver.Updaters; using System.Diagnostics; -using System.Drawing; -using System.Security.Policy; -using System.Windows.Forms; using GAction = Lumina.Excel.GeneratedSheets.Action; namespace RotationSolver.UI; diff --git a/RotationSolver/Updaters/TargetUpdater.cs b/RotationSolver/Updaters/TargetUpdater.cs index aab8be5f1..2470acbea 100644 --- a/RotationSolver/Updaters/TargetUpdater.cs +++ b/RotationSolver/Updaters/TargetUpdater.cs @@ -110,7 +110,6 @@ private unsafe static void UpdateHostileTargets(IEnumerable allTarg { if (!Svc.GameGui.WorldToScreen(b.Position, out _)) return false; } - return true; }))); @@ -125,6 +124,9 @@ private unsafe static void UpdateHostileTargets(IEnumerable allTarg DataCenter.NumberOfHostilesInMaxRange = DataCenter.HostileTargets.Count(o => o.DistanceToPlayer() <= 25); + DataCenter.MobsTime = DataCenter.HostileTargets.Count(o => o.DistanceToPlayer() <= JobRange && o.CanSee()) + >= Service.Config.GetValue(PluginConfigInt.AutoDefenseNumber); + if (DataCenter.HostileTargets.Count() == 1) { var tar = DataCenter.HostileTargets.FirstOrDefault();