private BehaviorTreeStatus MoveToPosition(Vector3 position, double minDistance = 2.5) { double distance = WowInterface.ObjectManager.Player.Position.GetDistance(position); if (distance > minDistance) { double zDiff = position.Z - WowInterface.ObjectManager.Player.Position.Z; if (LosCheckEvent.Run()) { if (WowInterface.HookManager.WowIsInLineOfSight(WowInterface.ObjectManager.Player.Position, position, 2f)) { InLos = true; } else { InLos = false; } } if (zDiff < -4.0 && InLos) // target is below us and in line of sight, just run down { WowInterface.MovementEngine.SetMovementAction(MovementAction.DirectMove, position); } else { WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, position); } return(BehaviorTreeStatus.Ongoing); } else { return(BehaviorTreeStatus.Success); } }
public override void Execute() { // dont follow when casting, or player is dead/ghost if (WowInterface.ObjectManager.Player.IsCasting || (PlayerToFollow != null && (PlayerToFollow.IsDead || PlayerToFollow.Health == 1))) { return; } if (PlayerToFollow == null) { // handle nearby portals, if our groupleader enters a portal, we follow WowGameobject nearestPortal = WowInterface.ObjectManager.WowObjects .OfType <WowGameobject>() .Where(e => e.DisplayId == (int)GameobjectDisplayId.UtgardeKeepDungeonPortalNormal || e.DisplayId == (int)GameobjectDisplayId.UtgardeKeepDungeonPortalHeroic) .FirstOrDefault(e => e.Position.GetDistance(WowInterface.ObjectManager.Player.Position) < 12.0); if (nearestPortal != null) { WowInterface.MovementEngine.SetMovementAction(MovementAction.DirectMove, BotUtils.MoveAhead(WowInterface.ObjectManager.Player.Position, nearestPortal.Position, 6f)); } else { StateMachine.SetState(BotState.Idle); } return; } Vector3 posToGoTo; if (Config.FollowPositionDynamic) { posToGoTo = PlayerToFollow.Position + Offset; } else { posToGoTo = PlayerToFollow.Position; } double distance = WowInterface.ObjectManager.Player.Position.GetDistance(posToGoTo); if (distance < Config.MinFollowDistance || distance > Config.MaxFollowDistance) { StateMachine.SetState(BotState.Idle); return; } if (Config.UseMountsInParty && WowInterface.CharacterManager.Mounts?.Count > 0 && PlayerToFollow != null && PlayerToFollow.IsMounted && !WowInterface.ObjectManager.Player.IsMounted) { if (CastMountEvent.Run()) { List <WowMount> filteredMounts; if (Config.UseOnlySpecificMounts) { filteredMounts = WowInterface.CharacterManager.Mounts.Where(e => Config.Mounts.Split(",", StringSplitOptions.RemoveEmptyEntries).Contains(e.Name)).ToList(); } else { filteredMounts = WowInterface.CharacterManager.Mounts; } if (filteredMounts != null && filteredMounts.Count >= 0) { WowMount mount = filteredMounts[new Random().Next(0, filteredMounts.Count)]; WowInterface.MovementEngine.StopMovement(); WowInterface.HookManager.LuaCallCompanion(mount.Index); } } return; } double zDiff = posToGoTo.Z - WowInterface.ObjectManager.Player.Position.Z; if (LosCheckEvent.Run()) { if (WowInterface.HookManager.WowIsInLineOfSight(WowInterface.ObjectManager.Player.Position, posToGoTo, 2f)) { InLos = true; } else { InLos = false; } } if (zDiff < -4.0 && InLos) // target is below us and in line of sight, just run down { WowInterface.MovementEngine.SetMovementAction(MovementAction.DirectMove, posToGoTo); } else { WowInterface.MovementEngine.SetMovementAction(MovementAction.Following, posToGoTo); } }