From 90623c1f0f21b5a149cb430f20e107952cdb6712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Sat, 11 Feb 2023 17:04:13 +0800 Subject: [PATCH] fix: try to remove canattack method. --- .../Actions/BaseAction/BaseAction_Target.cs | 2 +- RotationSolver/Commands/RSCommands_Actions.cs | 2 +- RotationSolver/Data/MarkingController.cs | 2 +- RotationSolver/Helpers/ObjectHelper.cs | 14 +++++++------- .../SigReplacers/PluginAddressResolver.cs | 4 ++-- RotationSolver/Updaters/TargetUpdater_Hostile.cs | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/RotationSolver/Actions/BaseAction/BaseAction_Target.cs b/RotationSolver/Actions/BaseAction/BaseAction_Target.cs index 4818fcd51..4ccb90117 100644 --- a/RotationSolver/Actions/BaseAction/BaseAction_Target.cs +++ b/RotationSolver/Actions/BaseAction/BaseAction_Target.cs @@ -270,7 +270,7 @@ private bool TargetHostile(float range, bool mustUse, int aoeCount, out BattleCh //如果不用自动找目标,那就直接返回。 if (RSCommands.StateType == StateCommandType.Manual) { - if (Service.TargetManager.Target is BattleChara b && b.CanAttack() && b.DistanceToPlayer() <= range) + if (Service.TargetManager.Target is BattleChara b && b.IsNPCEnemy() && b.DistanceToPlayer() <= range) { return TargetHostileManual(b, mustUse, aoeCount, out target); } diff --git a/RotationSolver/Commands/RSCommands_Actions.cs b/RotationSolver/Commands/RSCommands_Actions.cs index c5ee40859..16db40eee 100644 --- a/RotationSolver/Commands/RSCommands_Actions.cs +++ b/RotationSolver/Commands/RSCommands_Actions.cs @@ -43,7 +43,7 @@ internal static unsafe void DoAnAction(bool isGCD) //Service.ChatGui.Print($"{act}, {act.Target.Name}, {ActionUpdater.AbilityRemainCount}, {ActionUpdater.WeaponElapsed}"); #endif //Change Target - if (Service.TargetManager.Target is not PlayerCharacter && (act.Target?.CanAttack() ?? false)) + if (Service.TargetManager.Target is not PlayerCharacter && (act.Target?.IsNPCEnemy() ?? false)) { Service.TargetManager.SetTarget(act.Target); } diff --git a/RotationSolver/Data/MarkingController.cs b/RotationSolver/Data/MarkingController.cs index 1649f20d7..494116bd3 100644 --- a/RotationSolver/Data/MarkingController.cs +++ b/RotationSolver/Data/MarkingController.cs @@ -19,7 +19,7 @@ internal static BattleChara GetAttackMarkChara(IEnumerable charas) for (uint i = 0; i < 5; i++) { var b = GetChara(charas, GetMarker(i)); - if (b?.CanAttack() ?? false) return b; + if (b?.IsNPCEnemy() ?? false) return b; } return null; } diff --git a/RotationSolver/Helpers/ObjectHelper.cs b/RotationSolver/Helpers/ObjectHelper.cs index a8ee05eb6..0ce63413f 100644 --- a/RotationSolver/Helpers/ObjectHelper.cs +++ b/RotationSolver/Helpers/ObjectHelper.cs @@ -139,13 +139,13 @@ internal static EnemyPositional FindEnemyLocation(this GameObject enemy) return EnemyPositional.Flank; } - public unsafe static bool CanAttack(this GameObject actor) - { - if (actor == null) return false; - if (actor is not BattleChara b) return false; - if (b.CurrentHp == 0) return false; - return ((delegate*)Service.Address.CanAttackFunction)(142L, actor.Address) == 1; - } + //public unsafe static bool CanAttack(this GameObject actor) + //{ + // if (actor == null) return false; + // if (actor is not BattleChara b) return false; + // if (b.CurrentHp == 0) return false; + // return ((delegate*)Service.Address.CanAttackFunction)(142L, actor.Address) == 1; + //} #if DEBUG internal static uint GetHealthFromMulty(float mult) diff --git a/RotationSolver/SigReplacers/PluginAddressResolver.cs b/RotationSolver/SigReplacers/PluginAddressResolver.cs index a1dd7d0b3..96e78a6d2 100644 --- a/RotationSolver/SigReplacers/PluginAddressResolver.cs +++ b/RotationSolver/SigReplacers/PluginAddressResolver.cs @@ -7,7 +7,7 @@ namespace RotationSolver.SigReplacers; internal class PluginAddressResolver : BaseAddressResolver { public IntPtr IsActionIdReplaceable { get; private set; } - public IntPtr CanAttackFunction { get; private set; } + //public IntPtr CanAttackFunction { get; private set; } public IntPtr MovingController { get; private set; } public IntPtr ReceiveAbilty { get; private set; } public IntPtr CountdownTimerAdress { get; private set; } @@ -22,7 +22,7 @@ protected override void Setup64Bit(SigScanner scanner) IsActionIdReplaceable = scanner.ScanText("E8 ?? ?? ?? ?? 84 C0 74 4C 8B D3"); //IDK - CanAttackFunction = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8B DA 8B F9 E8 ?? ?? ?? ?? 4C 8B C3 "); + //CanAttackFunction = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8B DA 8B F9 E8 ?? ?? ?? ?? 4C 8B C3 "); MovingController = scanner.ScanText("40 55 53 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 83 79 ?? ??"); ReceiveAbilty = scanner.ScanText("4C 89 44 24 ?? 55 56 41 54 41 55 41 56"); CountdownTimerAdress = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 40 8B 41"); diff --git a/RotationSolver/Updaters/TargetUpdater_Hostile.cs b/RotationSolver/Updaters/TargetUpdater_Hostile.cs index 72a8114a8..cd1f12519 100644 --- a/RotationSolver/Updaters/TargetUpdater_Hostile.cs +++ b/RotationSolver/Updaters/TargetUpdater_Hostile.cs @@ -81,7 +81,7 @@ private unsafe static void UpdateHostileTargets(IEnumerable allTarg if (b.StatusList.Any(StatusHelper.IsInvincible)) return false; - return b.CanAttack(); + return true; }); HostileTargets.Delay(GetHostileTargets(allAttackableTargets));