private bool HandleAutoQuestMode(WowUnit wowPlayer) { WowUnit possibleQuestgiver = WowInterface.ObjectManager.GetWowObjectByGuid <WowUnit>(wowPlayer.TargetGuid); if (possibleQuestgiver != null && (possibleQuestgiver.IsQuestgiver || possibleQuestgiver.IsGossip)) { double distance = WowInterface.ObjectManager.Player.Position.GetDistance(possibleQuestgiver.Position); if (distance > 32.0) { return(false); } if (distance > 4.0) { WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, possibleQuestgiver.Position); return(true); } else { if (QuestgiverRightClickEvent.Run()) { if (!BotMath.IsFacing(WowInterface.ObjectManager.Player.Position, WowInterface.ObjectManager.Player.Rotation, possibleQuestgiver.Position)) { WowInterface.HookManager.WowFacePosition(WowInterface.ObjectManager.Player, possibleQuestgiver.Position); } WowInterface.HookManager.WowUnitRightClick(possibleQuestgiver); return(true); } } } return(false); }
private BtStatus OpenTrainer() { if (Bot == null || trainer == null) { return(BtStatus.Failed); } if (Bot.Wow.TargetGuid != trainer.Guid) { Bot.Wow.ChangeTarget(trainer.Guid); } if (!BotMath.IsFacing(Bot.Objects.Player.Position, Bot.Objects.Player.Rotation, trainer.Position, 0.5f)) { Bot.Wow.FacePosition(Bot.Objects.Player.BaseAddress, Bot.Player.Position, trainer.Position); } if (Bot.Wow.UiIsVisible("GossipFrame")) { return(BtStatus.Success); } Bot.Wow.InteractWithUnit(trainer); return(BtStatus.Success); }
public void FaceUnit(WowPlayer player, WowPosition positionToFace) { float angle = BotMath.GetFacingAngle(player.Position, positionToFace); TrashMem.Write(player.BaseAddress + OffsetList.OffsetPlayerRotation, angle); SendKey(new IntPtr(0x41), 0, 0); // the "S" key to go a bit backwards TODO: find better method 0x53 }
public override void Execute() { if (WowInterface.ObjectManager.Player.Health > 1) { StateMachine.SetState(BotState.Idle); } if (StateMachine.IsBattlegroundMap(WowInterface.ObjectManager.MapId)) { // just wait for the mass ress return; } if (WowInterface.ObjectManager.Player.Position.GetDistance(CorpsePosition) > 8) { WowInterface.MovementEngine.SetState(MovementEngineState.Moving, CorpsePosition); WowInterface.MovementEngine.Execute(); } else { if (NeedToEnterPortal) { // move into portal CorpsePosition = BotUtils.MoveAhead(BotMath.GetFacingAngle(WowInterface.ObjectManager.Player.Position, CorpsePosition), CorpsePosition, 4); WowInterface.MovementEngine.SetState(MovementEngineState.Moving, CorpsePosition); WowInterface.MovementEngine.Execute(); } else { WowInterface.HookManager.RetrieveCorpse(); } } }
public void Execute() { if (Bot.Target != null) { Bot.Wow.FacePosition(Bot.Player.BaseAddress, Bot.Player.Position, BotMath.CalculatePositionAround(Bot.Target.Position, 0.0f, (float)Rnd.NextDouble() * (MathF.PI * 2), (float)Rnd.NextDouble()), true); } }
private void HandleMovement(WowUnit target) { if (target == null) { return; } if (hasTargetMoved || (distanceToTarget < 6.0 && !BotMath.IsFacing(LastPlayerPosition, ObjectManager.Player.Rotation, LastTargetPosition, 0.75, 1.25))) { CharacterManager.MoveToPosition(LastTargetPosition); } else if (distanceToTarget >= 6.0) { if (computeNewRoute || MovementEngine.CurrentPath?.Count == 0) { List <Vector3> path = PathfindingHandler.GetPath((int)ObjectManager.MapId, LastPlayerPosition, LastTargetPosition); MovementEngine.LoadPath(path); MovementEngine.PostProcessPath(); } else { if (MovementEngine.GetNextStep(LastPlayerPosition, out Vector3 positionToGoTo, out bool needToJump)) { CharacterManager.MoveToPosition(positionToGoTo); if (needToJump) { CharacterManager.Jump(); } } } } }
public void ClampAnglesTest() { float clampedA = BotMath.ClampAngles(9.0f); float clampedB = BotMath.ClampAngles(-3.0f); Assert.IsTrue(clampedA >= 0.0f && clampedA <= MathF.PI * 2.0f); Assert.IsTrue(clampedB >= 0.0f && clampedB <= MathF.PI * 2.0f); }
public void ClampAnglesTest() { float clampedA = BotMath.ClampAngles(9f); float clampedB = BotMath.ClampAngles(-3f); Assert.IsTrue(clampedA >= 0 && clampedA <= Math.PI * 2); Assert.IsTrue(clampedB >= 0 && clampedB <= Math.PI * 2); }
public void FacePosition(WowPlayer player, Vector3 positionToFace) { float angle = BotMath.GetFacingAngle(player.Position, positionToFace); SetFacing(player, angle); // buggy atm // SendMovementPacket(player, 0xDA); }
public void Execute() { IWowUnit randomPartymember = NpcsNearMe.ElementAt(Rnd.Next(0, NpcsNearMe.Count())); if (randomPartymember != null) { Bot.Wow.FacePosition(Bot.Player.BaseAddress, Bot.Player.Position, BotMath.CalculatePositionAround(randomPartymember.Position, 0.0f, (float)Rnd.NextDouble() * (MathF.PI * 2), (float)Rnd.NextDouble()), true); } }
public void Execute() { computeNewRoute = false; WowUnit target = WowInterface.ObjectManager.Target; if ((WowInterface.ObjectManager.TargetGuid != 0 && target != null && !(target.IsDead || target.Health < 1)) || SearchNewTarget(ref target, false)) { Dancing = false; bool targetDistanceChanged = false; if (!LastPlayerPosition.Equals(WowInterface.ObjectManager.Player.Position)) { distanceTraveled = WowInterface.ObjectManager.Player.Position.GetDistance(LastPlayerPosition); LastPlayerPosition = new Vector3(WowInterface.ObjectManager.Player.Position.X, WowInterface.ObjectManager.Player.Position.Y, WowInterface.ObjectManager.Player.Position.Z); targetDistanceChanged = true; } if (LastTargetRotation != target.Rotation) { computeNewRoute = true; LastTargetRotation = target.Rotation; } if (!LastTargetPosition.Equals(target.Position)) { computeNewRoute = true; LastTargetPosition = new Vector3(target.Position.X, target.Position.Y, target.Position.Z); LastBehindTargetPosition = BotMath.CalculatePositionBehind(target.Position, target.Rotation, 3f); targetDistanceChanged = true; } if (targetDistanceChanged) { distanceToTarget = LastPlayerPosition.GetDistance(LastTargetPosition); distanceToBehindTarget = LastPlayerPosition.GetDistance(LastBehindTargetPosition); } HandleMovement(target); HandleAttacking(target); } else if (!Dancing) { if (distanceTraveled < 0.001) { WowInterface.HookManager.WowClearTarget(); WowInterface.HookManager.LuaSendChatMessage(standingEmotes[new Random().Next(standingEmotes.Length)]); Dancing = true; WowInterface.Globals.ForceCombat = false; } else { WowInterface.HookManager.WowClearTarget(); Dancing = true; } } }
public void OutOfCombatExecute() { computeNewRoute = false; List <string> buffs = WowInterface.ObjectManager.Player.Auras.Select(e => e.Name).ToList(); if (!buffs.Any(e => e.Contains("tealth"))) { WowInterface.HookManager.LuaCastSpell("Stealth"); spells.ResetAfterTargetDeath(); } if (!LastPlayerPosition.Equals(WowInterface.ObjectManager.Player.Position)) { distanceTraveled = WowInterface.ObjectManager.Player.Position.GetDistance(LastPlayerPosition); LastPlayerPosition = new Vector3(WowInterface.ObjectManager.Player.Position.X, WowInterface.ObjectManager.Player.Position.Y, WowInterface.ObjectManager.Player.Position.Z); } if (distanceTraveled < 0.001) { ulong leaderGuid = WowInterface.ObjectManager.PartyleaderGuid; WowUnit target = WowInterface.ObjectManager.Target; if ((WowInterface.ObjectManager.TargetGuid != 0 && target != null && !(target.IsDead || target.Health < 1)) || SearchNewTarget(ref target, true)) { if (!LastTargetPosition.Equals(target.Position)) { computeNewRoute = true; LastTargetPosition = new Vector3(target.Position.X, target.Position.Y, target.Position.Z); LastBehindTargetPosition = BotMath.CalculatePositionBehind(target.Position, target.Rotation, 5f); distanceToTarget = LastPlayerPosition.GetDistance(LastTargetPosition); distanceToBehindTarget = LastPlayerPosition.GetDistance(LastBehindTargetPosition); } Dancing = false; HandleMovement(target); WowInterface.Globals.ForceCombat = true; HandleAttacking(target); } else if (!Dancing || standing) { standing = false; WowInterface.HookManager.WowClearTarget(); WowInterface.HookManager.LuaSendChatMessage(standingEmotes[new Random().Next(standingEmotes.Length)]); Dancing = true; } } else { if (!Dancing || !standing) { standing = true; WowInterface.HookManager.WowClearTarget(); Dancing = true; } } }
private bool HandleMovement(WowUnit target) { // check if we are facing the unit if ((WowInterface.CombatClass == null || !WowInterface.CombatClass.HandlesFacing) && target != null && target.Guid != WowInterface.PlayerGuid && FacingCheck.Run() && !WowInterface.HookManager.WowIsClickToMoveActive() && !BotMath.IsFacing(WowInterface.Player.Position, WowInterface.Player.Rotation, target.Position)) { WowInterface.HookManager.WowFacePosition(WowInterface.Player, target.Position); } // do we need to move if (target == null) { // just move to our group return(WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, WowInterface.ObjectManager.MeanGroupPosition)); } else if (WowInterface.CombatClass != null) { Vector3 targetPosition = BotUtils.MoveAhead(target.Position, target.Rotation, 0.5f); float distance = WowInterface.Player.Position.GetDistance(target.Position); if (distance > DistanceToKeep || !WowInterface.ObjectManager.IsTargetInLineOfSight) { switch (WowInterface.CombatClass.Role) { case WowRole.Dps: return(WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, target.Position)); // return HandleDpsMovement(target, targetPosition); case WowRole.Tank: return(WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, target.Position)); // return HandleTankMovement(target, targetPosition); case WowRole.Heal: return(HandleHealMovement(target, targetPosition)); } } if (distance < DistanceToKeep * 0.08f) { // no need to move WowInterface.MovementEngine.StopMovement(); } return(false); } WowInterface.MovementEngine.StopMovement(); return(false); }
public void CalculatePositionBehindTest() { Vector3 topPos = new Vector3(0, 4, 0); Vector3 middlePos = new Vector3(0, 0, 0); float facingAngle = BotMath.GetFacingAngle2D(topPos, middlePos); Vector3 calculatedPos = BotMath.CalculatePositionBehind(topPos, facingAngle, 2.0); Vector3 expectedPos = new Vector3(0, 6, 0); Assert.AreEqual(expectedPos, calculatedPos); }
public static bool Run(WowInterface wowInterface, WowUnit selectedUnit) { if (wowInterface == null || selectedUnit == null) { return(false); } if (wowInterface.ObjectManager.TargetGuid != selectedUnit.Guid) { wowInterface.HookManager.WowTargetGuid(selectedUnit.Guid); return(false); } if (wowInterface.HookManager.WowIsClickToMoveActive()) { wowInterface.MovementEngine.StopMovement(); } if (!BotMath.IsFacing(wowInterface.ObjectManager.Player.Position, wowInterface.ObjectManager.Player.Rotation, selectedUnit.Position)) { wowInterface.HookManager.WowFacePosition(wowInterface.ObjectManager.Player, selectedUnit.Position); } if (!wowInterface.HookManager.LuaUiIsVisible("GossipFrame", "MerchantFrame")) { wowInterface.HookManager.WowUnitRightClick(selectedUnit); return(false); } if (selectedUnit.IsGossip) { if (wowInterface.HookManager.LuaUiIsVisible("GossipFrame")) { string[] gossipTypes = wowInterface.HookManager.LuaGetGossipTypes(); for (int i = 0; i < gossipTypes.Length; ++i) { if (gossipTypes[i].Equals("vendor", StringComparison.OrdinalIgnoreCase) || gossipTypes[i].Equals("repair", StringComparison.OrdinalIgnoreCase)) { wowInterface.HookManager.LuaSelectGossipOption(i + 1); } } } if (!wowInterface.HookManager.LuaUiIsVisible("MerchantFrame")) { return(false); } } return(true); }
private void HandleMovement(WowUnit target) { if (target == null) { return; } if (WowInterface.ObjectManager.Player.Auras.Any(e => e.Name.Contains("tealth"))) { if (!wasInStealth || hasTargetMoved) { isSneaky = true; } wasInStealth = true; } else { isSneaky = false; wasInStealth = false; } if (isAttackingFromBehind) { if (WowInterface.MovementEngine.Status != Movement.Enums.MovementAction.None && distanceToTarget < 0.75f * (WowInterface.ObjectManager.Player.CombatReach + target.CombatReach)) { WowInterface.MovementEngine.StopMovement(); } if (WowInterface.ObjectManager.Player.IsInCombat) { isAttackingFromBehind = false; } } if (computeNewRoute) { if (!isAttackingFromBehind && isSneaky && distanceToBehindTarget > 0.75f * (WowInterface.ObjectManager.Player.CombatReach + target.CombatReach)) { WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Move, LastBehindTargetPosition); } else { isAttackingFromBehind = true; if (!BotMath.IsFacing(LastPlayerPosition, WowInterface.ObjectManager.Player.Rotation, LastTargetPosition, 0.5f)) { WowInterface.HookManager.WowFacePosition(WowInterface.ObjectManager.Player, target.Position); } WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Move, LastTargetPosition, LastTargetRotation); } } }
public void IsFacingTest() { WowPosition a = new WowPosition() { x = 0, y = 0, z = 0, r = 1 }; WowPosition b = new WowPosition() { x = 10, y = 10, z = 10, r = 1 }; Assert.IsTrue(BotMath.IsFacing(a, b)); }
public void GetDistanceTest() { WowPosition a = new WowPosition() { x = 0, y = 0, z = 0 }; WowPosition b = new WowPosition() { x = 1, y = 0, z = 0 }; Assert.AreEqual(1, BotMath.GetDistance(a, b)); }
public bool IsUnitInFollowRange(WowUnit unitToFollow) { WowUnit wowPlayer = (WowUnit)ObjectManager.GetWowObjectByGuid(WowDataAdapter.PlayerGuid); if (wowPlayer != null && unitToFollow != null) { WowPosition myPosition = wowPlayer.Position; return(BotMath.GetDistance(myPosition, unitToFollow.Position) >= UnitFollowThreshold); } else { return(false); } }
public void GetFacingAngleTest() { WowPosition a = new WowPosition() { x = 0, y = 0, z = 0, r = 2 }; WowPosition b = new WowPosition() { x = 10, y = 10, z = 10, r = 1 }; double angle = BotMath.GetFacingAngle(a, b); Assert.AreEqual(0.79, Math.Round(angle, 2)); }
public static bool Run(AmeisenBotInterfaces bot, IWowUnit selectedUnit) { if (bot == null || selectedUnit == null) { return(false); } if (bot.Wow.TargetGuid != selectedUnit.Guid) { bot.Wow.ChangeTarget(selectedUnit.Guid); return(false); } if (!BotMath.IsFacing(bot.Objects.Player.Position, bot.Objects.Player.Rotation, selectedUnit.Position, 0.5f)) { bot.Wow.FacePosition(bot.Objects.Player.BaseAddress, bot.Player.Position, selectedUnit.Position); } if (!bot.Wow.UiIsVisible("GossipFrame", "MerchantFrame")) { bot.Wow.InteractWithUnit(selectedUnit.BaseAddress); return(false); } if (selectedUnit.IsGossip) { if (bot.Wow.UiIsVisible("GossipFrame")) { string[] gossipTypes = bot.Wow.GetGossipTypes(); for (int i = 0; i < gossipTypes.Length; ++i) { if (gossipTypes[i].Equals("vendor", StringComparison.OrdinalIgnoreCase) || gossipTypes[i].Equals("repair", StringComparison.OrdinalIgnoreCase)) { bot.Wow.SelectGossipOption(i + 1); } } } if (!bot.Wow.UiIsVisible("MerchantFrame")) { return(false); } } return(true); }
public static bool Run(AmeisenBotInterfaces bot, IWowUnit selectedUnit) { if (bot == null || selectedUnit == null) { return(false); } if (bot.Wow.TargetGuid != selectedUnit.Guid) { bot.Wow.ChangeTarget(selectedUnit.Guid); } if (!BotMath.IsFacing(bot.Objects.Player.Position, bot.Objects.Player.Rotation, selectedUnit.Position, 0.5f)) { bot.Wow.FacePosition(bot.Objects.Player.BaseAddress, bot.Player.Position, selectedUnit.Position); } if (!bot.Wow.UiIsVisible("GossipFrame")) { bot.Wow.InteractWithUnit(selectedUnit.BaseAddress); } if (!selectedUnit.IsGossip) { return(false); } // gossip 1 train skills // gossip 2 unlearn talents // quest gossip from trainer?? string[] gossipTypes = bot.Wow.GetGossipTypes(); for (int i = 0; i < gossipTypes.Length; ++i) { if (!gossipTypes[i].Equals("trainer", StringComparison.OrdinalIgnoreCase)) { continue; } // +1 is due to implicit conversion between lua array (indexed at 1 not 0) and c# array bot.Wow.SelectGossipOptionSimple(i + 1); return(true); } return(false); }
public bool ExecuteTactic(CombatClassRole role, bool isMelee, out bool preventMovement, out bool allowAttacking) { preventMovement = false; allowAttacking = true; WowUnit wowUnit = WowInterface.I.ObjectManager.GetClosestWowUnitByDisplayId(DevourerOfSoulsDisplayId, false); if (wowUnit != null) { if (wowUnit.DisplayId == 30150) { // make sure we avoid the lazer // we only care about being on the reight side of him because the lazer spins clockwise float angleDiff = BotMath.GetAngleDiff(wowUnit.Position, wowUnit.Rotation, WowInterface.I.ObjectManager.Player.Position); if (angleDiff < 0.5f) { WowInterface.I.MovementEngine.SetMovementAction(MovementAction.Move, BotMath.CalculatePositionAround(wowUnit.Position, wowUnit.Rotation, MathF.PI, isMelee ? 5.0f : 22.0f)); preventMovement = true; allowAttacking = false; return(true); } } if (role == CombatClassRole.Tank) { Vector3 modifiedCenterPosition = BotUtils.MoveAhead(MidPosition, BotMath.GetFacingAngle(WowInterface.I.ObjectManager.MeanGroupPosition, MidPosition), 8.0f); float distanceToMid = WowInterface.I.ObjectManager.Player.Position.GetDistance(modifiedCenterPosition); if (wowUnit.TargetGuid == WowInterface.I.ObjectManager.PlayerGuid) { if (distanceToMid > 5.0f && WowInterface.I.ObjectManager.Player.Position.GetDistance(wowUnit.Position) < 3.5) { // move the boss to mid WowInterface.I.MovementEngine.SetMovementAction(MovementAction.Move, modifiedCenterPosition); preventMovement = true; allowAttacking = false; return(true); } } } } return(false); }
private bool HandleDpsMovement(WowUnit target, Vector3 targetPosition) { // handle special movement needs if (WowInterface.CombatClass.WalkBehindEnemy && WowInterface.ObjectManager.Target.TargetGuid != WowInterface.ObjectManager.PlayerGuid || WowInterface.ObjectManager.Target.Type == WowObjectType.Player) // prevent spinning { // walk behind enemy Vector3 positionToGoTo = BotMath.CalculatePositionBehind(target.Position, target.Rotation); return(WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, positionToGoTo)); } else { // just move to the enemies return(WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, targetPosition)); } }
public void IsFacingTest() { Vector3 middlePos = new(0, 0, 0); Vector3 topPos = new(0, 4, 0); Vector3 leftPos = new(-4, 0, 0); Vector3 bottomPos = new(0, -4, 0); Vector3 rightPos = new(4, 0, 0); float rotation = MathF.PI / 2.0f; Assert.IsTrue(BotMath.IsFacing(middlePos, rotation, topPos)); Assert.IsFalse(BotMath.IsFacing(middlePos, rotation, rightPos)); Assert.IsFalse(BotMath.IsFacing(middlePos, rotation, bottomPos)); Assert.IsFalse(BotMath.IsFacing(middlePos, rotation, leftPos)); }
public override void Execute() { WowInterface.ObjectManager.UpdateObject(PlayerToFollow); Vector3 posToGoTo = default; // handle nearby portals, if our groupleader enters a portal, we follow WowGameobject nearestPortal = WowInterface.ObjectManager.WowObjects .OfType <WowGameobject>() .Where(e => e.DisplayId == (int)GameobjectDisplayId.DungeonPortalNormal || e.DisplayId == (int)GameobjectDisplayId.DungeonPortalHeroic) .FirstOrDefault(e => e.Position.GetDistance(WowInterface.ObjectManager.Player.Position) < Config.GhostPortalScanThreshold); if (nearestPortal != null) { double distanceToPortal = PlayerToFollow.Position.GetDistance(nearestPortal.Position); if (distanceToPortal < 4.0) { // move into portal, MoveAhead is used to go beyond the portals entry point to make sure enter it posToGoTo = BotUtils.MoveAhead(BotMath.GetFacingAngle2D(WowInterface.ObjectManager.Player.Position, nearestPortal.Position), nearestPortal.Position, 6); } } // if no portal position was found, follow the player if (posToGoTo == default) { posToGoTo = PlayerToFollow.Position; } double distance = PlayerToFollow.Position.GetDistance(posToGoTo); if (distance < Config.MinFollowDistance || distance > Config.MaxFollowDistance) { StateMachine.SetState(BotState.Idle); } if (WowInterface.ObjectManager.Player.IsCasting) { return; } WowInterface.MovementEngine.SetState(MovementEngineState.Following, posToGoTo); WowInterface.MovementEngine.Execute(); }
public void Execute() { if (Finished || Bot.Player.IsCasting) { return; } if (!SearchAreas.IsPlayerNearSearchArea(Bot) && Bot.Target == null) // if i have target, go nearby don't clear it { Bot.Wow.ClearTarget(); IWowUnit = null; } if (!Bot.Player.IsInCombat && Bot.Target == null) // if pulling with ranged we have target and yet not in combat { IWowUnit = Bot.Objects.All .OfType <IWowUnit>() .Where(e => !e.IsDead && !e.IsNotAttackable && Bot.Db.GetReaction(Bot.Player, e) != WowUnitReaction.Friendly && e.Health > 10 && // workaround to filter some critters, would be nice e.CreatureType != WoWCreatureType.Critter BotMath.SlopeGradientAngle(Bot.Player.Position, e.Position) <= 39.0f) // check if not too steep .OrderBy(e => e.Position.GetDistance(Bot.Player.Position)) .FirstOrDefault(); if (IWowUnit != null) { Bot.Wow.ChangeTarget(IWowUnit.Guid); } } if (IWowUnit != null) { SearchAreas.NotifyDetour(); Bot.CombatClass.AttackTarget(); } else if (Bot.Player.Position.GetDistance(CurrentNode) < 3.5f || SearchAreas.HasAbortedPath()) { CurrentNode = SearchAreas.GetNextPosition(Bot); Bot.Movement.SetMovementAction(MovementAction.Move, CurrentNode); } }
private void HandleMovement(WowUnit target) { if (target == null) { return; } if (WowInterface.MovementEngine.MovementAction != Movement.Enums.MovementAction.None && distanceToTarget < 0.75f * (WowInterface.ObjectManager.Player.CombatReach + target.CombatReach)) { WowInterface.MovementEngine.StopMovement(); } if (computeNewRoute) { if (!BotMath.IsFacing(LastPlayerPosition, WowInterface.ObjectManager.Player.Rotation, LastTargetPosition, 0.5f)) { WowInterface.HookManager.FacePosition(WowInterface.ObjectManager.Player, target.Position); } WowInterface.MovementEngine.SetMovementAction(Movement.Enums.MovementAction.Moving, target.Position, target.Rotation); } }
public void AngleCalculationTest() { Vector3 middlePos = new(0, 0, 0); Vector3 topPos = new(0, 4, 0); Vector3 bottomPos = new(0, -4, 0); Vector3 leftPos = new(-4, 0, 0); Vector3 rightPos = new(4, 0, 0); float facingAngle = BotMath.GetFacingAngle(middlePos, rightPos); Assert.AreEqual(0f, MathF.Round(facingAngle, 4)); facingAngle = BotMath.GetFacingAngle(middlePos, topPos); Assert.AreEqual(MathF.Round(MathF.PI * 0.5f, 4), MathF.Round(facingAngle, 4)); facingAngle = BotMath.GetFacingAngle(middlePos, bottomPos); Assert.AreEqual(MathF.Round(MathF.PI * 1.5f, 4), MathF.Round(facingAngle, 4)); facingAngle = BotMath.GetFacingAngle(middlePos, leftPos); Assert.AreEqual(MathF.Round(MathF.PI, 4), MathF.Round(facingAngle, 4)); }
private void HandleMovement(WowUnit target) { // we cant move to a null target if (target == null) { return; } // perform a facing check every 250ms, should be enough if (target.Guid != ObjectManager.PlayerGuid && !BotMath.IsFacing(ObjectManager.Player.Position, ObjectManager.Player.Rotation, target.Position) && DateTime.Now - LastRotationCheck > TimeSpan.FromMilliseconds(250)) { HookManager.FacePosition(ObjectManager.Player, target.Position); CharacterManager.Face(target.Position, target.Guid); LastRotationCheck = DateTime.Now; } // we don't want to move when we are casting or channeling something if (ObjectManager.Player.CurrentlyCastingSpellId > 0 || ObjectManager.Player.CurrentlyChannelingSpellId > 0) { return; } // if we are close enough, stop movement and start attacking double distance = ObjectManager.Player.Position.GetDistance2D(target.Position); if (distance <= DistanceToTarget) { // do we need to stop movement HookManager.StopClickToMove(ObjectManager.Player); } else { MovementEngine.SetState(MovementEngineState.Chasing, target.Position); MovementEngine.Execute(); } }