From ef42c91bc119535f37506a2baa5ff63c8dd5f8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Tue, 2 May 2023 10:24:42 +0800 Subject: [PATCH] fix: fixed the heal potion usage. --- Resources/AnimationLockTime.json | 93 ++++++++++++++++++- RotationSolver.Basic/Actions/BaseItem.cs | 7 +- .../Rotations/Basic/BRD_Base.cs | 2 +- .../Rotations/CustomRotation_Ability.cs | 3 +- .../Rotations/CustomRotation_Medicine.cs | 6 +- RotationSolver/Localization/Localization.json | 4 +- .../UI/RotationConfigWindow_Debug.cs | 13 +-- RotationSolver/Updaters/ActionUpdater.cs | 5 +- RotationSolver/Watcher.cs | 3 +- 9 files changed, 108 insertions(+), 28 deletions(-) diff --git a/Resources/AnimationLockTime.json b/Resources/AnimationLockTime.json index d28050b25..4789a6f6c 100644 --- a/Resources/AnimationLockTime.json +++ b/Resources/AnimationLockTime.json @@ -9,22 +9,66 @@ "46": 0.6, "48": 0.6, "52": 0.6, + "53": 0.6, + "54": 0.6, + "56": 0.6, + "61": 0.6, + "62": 0.6, + "65": 0.6, + "66": 0.6, + "69": 0.6, + "70": 0.6, + "74": 0.6, + "97": 0.6, + "98": 0.6, + "100": 0.6, + "101": 0.6, + "106": 0.6, + "107": 0.6, + "110": 0.6, + "113": 0.6, + "114": 0.6, + "116": 0.6, + "117": 0.6, + "118": 0.6, + "127": 0.1, + "132": 0.6, + "133": 0.1, + "135": 0.1, + "136": 0.6, + "137": 0.6, + "139": 0.1, + "140": 0.6, "141": 0.1, + "147": 0.1, "149": 0.6, - "152": 0.1, - "153": 0.1, + "152": 0.6, + "153": 0.6, "154": 0.1, + "156": 0.6, "158": 0.6, + "159": 0.1, + "162": 0.1, "167": 0.6, + "181": 0.6, "185": 0.1, "190": 0.1, + "3545": 0.6, + "3546": 0.6, "3549": 0.6, "3550": 0.6, "3552": 0.6, + "3558": 0.6, + "3559": 0.6, + "3560": 0.6, + "3562": 0.6, "3573": 0.6, "3574": 0.6, "3576": 0.1, "3577": 0.1, + "3578": 0.6, + "3579": 0.1, + "3582": 0.6, "3587": 0.6, "3590": 0.6, "3593": 0.6, @@ -43,6 +87,7 @@ "3613": 0.6, "3614": 0.6, "3615": 0.6, + "4262": 0.6, "4401": 0.6, "4402": 0.6, "4403": 0.6, @@ -54,7 +99,19 @@ "7387": 0.6, "7388": 0.6, "7389": 0.6, + "7395": 0.6, + "7396": 0.6, + "7404": 0.6, + "7406": 0.6, + "7407": 0.6, + "7409": 0.6, "7421": 0.6, + "7426": 0.6, + "7427": 0.6, + "7429": 0.6, + "7431": 0.1, + "7432": 0.6, + "7447": 0.1, "7503": 0.1, "7505": 0.6, "7506": 0.6, @@ -70,12 +127,17 @@ "7533": 0.6, "7535": 0.6, "7540": 0.6, + "7541": 0.6, + "7542": 0.6, + "7546": 0.6, "7548": 0.6, + "7557": 0.6, "7559": 0.6, "7560": 0.6, "7561": 0.6, "7562": 0.6, "7568": 0.1, + "7863": 0.6, "9793": 0.1, "10083": 0.1, "12260": 0.1, @@ -98,8 +160,14 @@ "16165": 0.6, "16462": 0.6, "16464": 0.6, + "16473": 0.6, + "16495": 0.6, + "16496": 0.6, "16505": 0.1, "16507": 0.6, + "16508": 0.6, + "16510": 0.6, + "16514": 0.6, "16524": 0.1, "16525": 0.1, "16527": 0.6, @@ -139,9 +207,30 @@ "25753": 1.15, "25759": 0.6, "25760": 0.6, + "25761": 0.6, + "25762": 0.6, + "25763": 0.6, + "25766": 0.6, + "25768": 0.6, + "25784": 0.6, + "25785": 0.6, + "25793": 0.1, "25796": 0.6, "25797": 0.6, + "25798": 0.1, + "25799": 0.6, + "25801": 0.6, + "25820": 0.6, + "25826": 0.1, + "25830": 0.6, + "25835": 0.75, + "25836": 0.6, + "25837": 0.1, + "25838": 0.6, + "25839": 0.6, + "25840": 0.6, "25865": 0.1, "25870": 0.6, + "25885": 0.6, "31323": 2.1 } \ No newline at end of file diff --git a/RotationSolver.Basic/Actions/BaseItem.cs b/RotationSolver.Basic/Actions/BaseItem.cs index c84c249d0..5bda33e44 100644 --- a/RotationSolver.Basic/Actions/BaseItem.cs +++ b/RotationSolver.Basic/Actions/BaseItem.cs @@ -91,9 +91,12 @@ public virtual unsafe bool CanUse(out IAction item) var remain = RecastTimeOneCharge - RecastTimeElapsed; - if (DataCenter.NextAbilityToNextGCD > AnimationLockTime + DataCenter.Ping + DataCenter.MinAnimationLock) return false; + if(DataCenter.WeaponRemain > 0) + { + if (DataCenter.NextAbilityToNextGCD > AnimationLockTime + DataCenter.Ping + DataCenter.MinAnimationLock) return false; - if (CooldownHelper.RecastAfter(DataCenter.ActionRemain, remain, false)) return false; + if (CooldownHelper.RecastAfter(DataCenter.ActionRemain, remain, false)) return false; + } if (OtherCheck != null && !OtherCheck()) return false; diff --git a/RotationSolver.Basic/Rotations/Basic/BRD_Base.cs b/RotationSolver.Basic/Rotations/Basic/BRD_Base.cs index 3afd534ae..1cfca2a4b 100644 --- a/RotationSolver.Basic/Rotations/Basic/BRD_Base.cs +++ b/RotationSolver.Basic/Rotations/Basic/BRD_Base.cs @@ -144,6 +144,6 @@ protected sealed override bool DefenseAreaAbility(out IAction act) protected sealed override bool HealSingleAbility(out IAction act) { if (NaturesMinne.CanUse(out act)) return true; - return false; + return base.HealSingleAbility(out act); } } diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs b/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs index 7116d849e..ee5087f71 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Ability.cs @@ -147,7 +147,6 @@ private bool GeneralHealAbility(SpecialCommandType specialType, out IAction act) if (DataCenter.SpecialType == SpecialCommandType.HealSingle || CanHealSingleAbility) { if (HealSingleAbility(out act)) return true; - if (UseHealPotion(out act)) return true; } } @@ -286,7 +285,7 @@ protected virtual bool MoveBackAbility(out IAction act) [RotationDesc(DescType.HealSingleAbility)] protected virtual bool HealSingleAbility(out IAction act) { - act = null; return false; + return UseHealPotion(out act); } [RotationDesc(DescType.HealAreaAbility)] diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Medicine.cs b/RotationSolver.Basic/Rotations/CustomRotation_Medicine.cs index f80e28f92..47fa2f65d 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Medicine.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Medicine.cs @@ -74,9 +74,9 @@ protected bool UseBurstMedicine(out IAction act) private bool UseHealPotion(out IAction act) { - var acts = from prop in GetType().GetProperties() - where typeof(HealPotionItem).IsAssignableFrom(prop.PropertyType) && !(prop.GetMethod?.IsPrivate ?? true) - select (HealPotionItem)prop.GetValue(this) into a + var acts = from prop in typeof(CustomRotation).GetProperties() + where !(prop.GetMethod?.IsPrivate ?? true) && typeof(IBaseItem).IsAssignableFrom(prop.PropertyType) + select prop.GetValue(this) as HealPotionItem into a where a != null && a.CanUse(out _) orderby a.MaxHealHp select a; diff --git a/RotationSolver/Localization/Localization.json b/RotationSolver/Localization/Localization.json index a2dbc1ed1..375b307ae 100644 --- a/RotationSolver/Localization/Localization.json +++ b/RotationSolver/Localization/Localization.json @@ -266,8 +266,8 @@ "SpecialCommandType_AntiKnockback": "Anti-Knockback", "SpecialCommandType_Burst": "Burst", "SpecialCommandType_EndSpecial": "End Special", - "SpecialCommandType_Smart": "Smart ", - "SpecialCommandType_Manual": "Manual", + "SpecialCommandType_Smart": "Auto Target ", + "SpecialCommandType_Manual": "Manual Target", "SpecialCommandType_Cancel": "Cancel", "SpecialCommandType_Off": "Off", "ActionConditionType_Elapsed": "Elapsed", diff --git a/RotationSolver/UI/RotationConfigWindow_Debug.cs b/RotationSolver/UI/RotationConfigWindow_Debug.cs index 10387d84d..b39cebd8a 100644 --- a/RotationSolver/UI/RotationConfigWindow_Debug.cs +++ b/RotationSolver/UI/RotationConfigWindow_Debug.cs @@ -26,7 +26,6 @@ private void DrawDebugTab() DrawParamTabItem("Target Data", DrawTargetData); DrawParamTabItem("Next Action", DrawNextAction); DrawParamTabItem("Last Action", DrawLastAction); - DrawParamTabItem("CD, EX", DrawCDEX); DrawParamTabItem("Icon", DrawIcon); DrawParamTabItem("Effect", () => { @@ -58,6 +57,7 @@ private unsafe void DrawStatus() ImGui.Text("Have Companion: " + DataCenter.HasCompanion.ToString()); ImGui.Text("Ping: " + DataCenter.Ping.ToString()); ImGui.Text("MP: " + DataCenter.CurrentMp.ToString()); + ImGui.Text("Count Down: " + Service.CountDownTime.ToString()); foreach (var status in Service.Player.StatusList) { @@ -159,17 +159,6 @@ private void DrawLastAction() DrawAction(DataCenter.LastComboAction, nameof(DataCenter.LastComboAction)); } - private void DrawCDEX() - { - ImGui.Text("Count Down: " + Service.CountDownTime.ToString()); - - if (ActionUpdater.exception != null) - { - ImGui.Text(ActionUpdater.exception.Message); - ImGui.Text(ActionUpdater.exception.StackTrace); - } - } - private unsafe void DrawIcon() { //var pointer = (AddonActionCross*) Service.GetAddon(); diff --git a/RotationSolver/Updaters/ActionUpdater.cs b/RotationSolver/Updaters/ActionUpdater.cs index 90f2bfd41..b79710fbf 100644 --- a/RotationSolver/Updaters/ActionUpdater.cs +++ b/RotationSolver/Updaters/ActionUpdater.cs @@ -1,5 +1,6 @@ using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Objects.SubKinds; +using Dalamud.Logging; using FFXIVClientStructs.FFXIV.Client.Game; using RotationSolver.Commands; using RotationSolver.Localization; @@ -15,8 +16,6 @@ internal static class ActionUpdater internal static IAction NextAction { get; private set; } internal static IBaseAction NextGCDAction { get; private set; } - internal static Exception exception; - internal static void UpdateNextAction() { PlayerCharacter localPlayer = Service.Player; @@ -58,7 +57,7 @@ internal static void UpdateNextAction() } catch (Exception ex) { - exception = ex; + PluginLog.Error(ex, "Failed to update next action."); } NextAction = NextGCDAction = null; diff --git a/RotationSolver/Watcher.cs b/RotationSolver/Watcher.cs index 5283583c2..b5ad67674 100644 --- a/RotationSolver/Watcher.cs +++ b/RotationSolver/Watcher.cs @@ -108,7 +108,8 @@ private static void ActionFromSelf(uint sourceId, ActionEffectSet set, uint id) { if (sourceId != Service.Player.ObjectId) return; if (set.Type != ActionType.Spell && set.Type != ActionType.Item) return; - if ((ActionCate)set.Action?.ActionCategory.Value.RowId == ActionCate.AutoAttack) return; + if (set.Action == null) return; + if ((ActionCate)set.Action.ActionCategory.Value.RowId == ActionCate.AutoAttack) return; if(set.Action.ClassJob.Row > 0 || Enum.IsDefined((ActionID)id)) {