diff --git a/Addons/DataToColor/DataToColor.lua b/Addons/DataToColor/DataToColor.lua index 0c0c5643..f530a1d8 100644 --- a/Addons/DataToColor/DataToColor.lua +++ b/Addons/DataToColor/DataToColor.lua @@ -153,6 +153,7 @@ DataToColor.CastNum = 0 DataToColor.targetChanged = true DataToColor.autoFollow = false +DataToColor.moving = false DataToColor.playerGUID = UnitGUID(DataToColor.C.unitPlayer) DataToColor.petGUID = UnitGUID(DataToColor.C.unitPet) diff --git a/Addons/DataToColor/DataToColor.toc b/Addons/DataToColor/DataToColor.toc index 5327cad0..4de9497d 100644 --- a/Addons/DataToColor/DataToColor.toc +++ b/Addons/DataToColor/DataToColor.toc @@ -3,7 +3,7 @@ ## Title: DataToColor ## Author: FreeHongKongMMO ## Notes: Displays data as colors -## Version: 1.7.49 +## Version: 1.7.50 ## RequiredDeps: ## OptionalDeps: Ace3, LibRangeCheck, LibClassicCasterino ## SavedVariables: diff --git a/Addons/DataToColor/EventHandlers.lua b/Addons/DataToColor/EventHandlers.lua index e000b8b8..eb38fccf 100644 --- a/Addons/DataToColor/EventHandlers.lua +++ b/Addons/DataToColor/EventHandlers.lua @@ -125,6 +125,9 @@ function DataToColor:RegisterEvents() DataToColor:RegisterEvent('AUTOFOLLOW_BEGIN', 'AutoFollowBegin') DataToColor:RegisterEvent('AUTOFOLLOW_END', 'AutoFollowEnd') + DataToColor:RegisterEvent('PLAYER_STARTED_MOVING', 'PlayerStartedMoving') + DataToColor:RegisterEvent('PLAYER_STOPPED_MOVING', 'PlayerStoppedMoving') + DataToColor:RegisterEvent('CHAT_MSG_WHISPER', 'OnMessageWhisper') DataToColor:RegisterEvent('CHAT_MSG_SAY', 'OnMessageSay') DataToColor:RegisterEvent('CHAT_MSG_YELL', 'OnMessageYell') @@ -607,6 +610,14 @@ function DataToColor:AutoFollowEnd() DataToColor.autoFollow = false end +function DataToColor:PlayerStartedMoving() + DataToColor.moving = true +end + +function DataToColor:PlayerStoppedMoving() + DataToColor.moving = false +end + function DataToColor:OnMessageWhisper(event, msg, author) AddMessageToQueue(0, msg, author) end diff --git a/Addons/DataToColor/Query.lua b/Addons/DataToColor/Query.lua index 7ccfe80e..5758000b 100644 --- a/Addons/DataToColor/Query.lua +++ b/Addons/DataToColor/Query.lua @@ -163,7 +163,8 @@ function DataToColor:Bits2() (UnitPlayerControlled(DataToColor.C.unitTarget) and 2 or 0) ^ 18 + ((DataToColor.autoFollow) and 2 or 0) ^ 19 + ((GameMenuFrame:IsShown() and 2 or 0)) ^ 20 + - ((IsFlying() and 2 or 0)) ^ 21 + ((IsFlying() and 2 or 0)) ^ 21 + + ((DataToColor.moving and 2 or 0)) ^ 22 end function DataToColor:CustomTrigger(t) diff --git a/Core/AddonComponent/AddonBits.cs b/Core/AddonComponent/AddonBits.cs index c011b246..edaf94df 100644 --- a/Core/AddonComponent/AddonBits.cs +++ b/Core/AddonComponent/AddonBits.cs @@ -72,7 +72,8 @@ public void Update(IAddonDataProvider reader) public bool AutoFollow() => v2[Mask._19]; public bool GameMenuWindowShown() => v2[Mask._20]; public bool Flying() => v2[Mask._21]; - + public bool Moving() => v2[Mask._22]; + public bool NotMoving() => !Moving(); // Combined diff --git a/Core/Goals/LootGoal.cs b/Core/Goals/LootGoal.cs index 60d0ec0e..63497399 100644 --- a/Core/Goals/LootGoal.cs +++ b/Core/Goals/LootGoal.cs @@ -194,9 +194,9 @@ private bool FoundByCursor() if (!playerReader.MinRangeZero()) { - elapsedMs = - wait.AfterEquals(MAX_TIME_TO_REACH_MELEE, 2, playerReader._MapPosNoZ, - input.PressApproachOnCooldown); + elapsedMs = wait.Until(MAX_TIME_TO_REACH_MELEE, + bits.NotMoving, input.PressApproachOnCooldown); + LogReachedCorpse(logger, elapsedMs); return playerReader.MinRangeZero(); @@ -313,9 +313,9 @@ private bool LootKeyboard() if (!playerReader.MinRangeZero()) { - float elapsedMs = - wait.AfterEquals(MAX_TIME_TO_REACH_MELEE, 2, playerReader._MapPosNoZ, - input.PressApproachOnCooldown); + float elapsedMs = wait.Until(MAX_TIME_TO_REACH_MELEE, + bits.NotMoving, input.PressApproachOnCooldown); + LogReachedCorpse(logger, elapsedMs); return playerReader.MinRangeZero(); diff --git a/Core/Goals/SkinningGoal.cs b/Core/Goals/SkinningGoal.cs index e68243c9..192b3c09 100644 --- a/Core/Goals/SkinningGoal.cs +++ b/Core/Goals/SkinningGoal.cs @@ -166,8 +166,8 @@ public override void OnEnter() if (!playerReader.MinRangeZero()) { - e = wait.AfterEquals(MAX_TIME_TO_REACH_MELEE, 2, playerReader._MapPosNoZ, - input.PressApproachOnCooldown); + e = wait.Until(MAX_TIME_TO_REACH_MELEE, + bits.NotMoving, input.PressApproachOnCooldown); LogReachedCorpse(logger, e); interact = !playerReader.MinRangeZero(); diff --git a/Core/GoalsComponent/StopMoving.cs b/Core/GoalsComponent/StopMoving.cs index 8bf04d05..e4c5949d 100644 --- a/Core/GoalsComponent/StopMoving.cs +++ b/Core/GoalsComponent/StopMoving.cs @@ -1,7 +1,5 @@ using System; using System.Threading; -using System.Numerics; -using SharedLib.Extensions; using Game; using Core.GOAP; using SharedLib; @@ -12,20 +10,20 @@ public sealed class StopMoving { private readonly WowProcessInput input; private readonly PlayerReader playerReader; + private readonly AddonBits bits; private readonly CancellationToken ct; - private const float MinDist = 0.001f; - - private Vector3 mapPos; private float direction; public StopMoving(WowProcessInput input, PlayerReader playerReader, - CancellationTokenSource cts) + CancellationTokenSource cts, + AddonBits bits) { this.input = input; this.playerReader = playerReader; ct = cts.Token; + this.bits = bits; } public void Stop() @@ -36,35 +34,21 @@ public void Stop() public void StopForward() { - if (mapPos != playerReader.MapPos) - { - bool pressedAny = false; - - if (!input.IsKeyDown(input.BackwardKey) && - !input.IsKeyDown(input.ForwardKey) && - mapPos.MapDistanceXYTo(playerReader.MapPos) >= MinDist) - { - input.PressFixed(input.ForwardKey, Random.Shared.Next(2, 5), ct); - pressedAny = true; - } - - if (input.IsKeyDown(input.ForwardKey)) - { - input.SetKeyState(input.ForwardKey, false, true); - pressedAny = true; - } + if (!bits.Moving()) + return; - if (input.IsKeyDown(input.BackwardKey)) - { - input.SetKeyState(input.BackwardKey, false, true); - pressedAny = true; - } - - if (pressedAny) - ct.WaitHandle.WaitOne(Random.Shared.Next(25, 30)); + if (input.IsKeyDown(input.ForwardKey)) + { + input.SetKeyState(input.ForwardKey, false, true); + } + else if (input.IsKeyDown(input.BackwardKey)) + { + input.SetKeyState(input.BackwardKey, false, true); + } + else // moving by interact key + { + input.PressFixed(input.ForwardKey, Random.Shared.Next(2, 5), ct); } - - mapPos = playerReader.MapPos; } public void StopTurn() @@ -78,8 +62,7 @@ public void StopTurn() input.SetKeyState(input.TurnLeftKey, false, true); pressedAny = true; } - - if (input.IsKeyDown(input.TurnRightKey)) + else if (input.IsKeyDown(input.TurnRightKey)) { input.SetKeyState(input.TurnRightKey, false, true); pressedAny = true;