예제 #1
0
        public bool Get(out Vector3 position, out MovementAction type)
        {
            if (!Bot.Player.IsDead &&
                !Bot.Player.IsInCombat &&
                !Config.Autopilot &&
                !Bot.Player.IsGhost)
            {
                if (IsUnitToFollowThere(out IWowUnit player))
                {
                    Vector3 pos      = Config.FollowPositionDynamic ? player.Position + FollowOffset : player.Position;
                    float   distance = Bot.Player.DistanceTo(pos);

                    if (distance > Config.MinFollowDistance && distance <= Config.MaxFollowDistance)
                    {
                        if (Config.FollowPositionDynamic && OffsetCheckEvent.Run())
                        {
                            float factor = Bot.Player.IsOutdoors ? 2.0f : 1.0f;

                            FollowOffset = new()
                            {
                                X = ((float)Random.NextDouble() * ((float)Config.MinFollowDistance * factor) - ((float)Config.MinFollowDistance * (0.5f * factor))) * 0.7071f,
                                Y = ((float)Random.NextDouble() * ((float)Config.MinFollowDistance * factor) - ((float)Config.MinFollowDistance * (0.5f * factor))) * 0.7071f,
                                Z = 0.0f
                            };
                        }

                        type     = MovementAction.Move;
                        position = pos;
                        return(true);
                    }
                }
            }

            type     = MovementAction.None;
            position = Vector3.Zero;
            return(false);
        }
예제 #2
0
        public override void Enter()
        {
            PlayerToFollowGuid = 0;

            // TODO: make this crap less redundant
            // check the specific character
            List <WowPlayer> wowPlayers = WowInterface.ObjectManager.WowObjects.OfType <WowPlayer>().ToList();

            if (wowPlayers.Count > 0)
            {
                if (Config.FollowSpecificCharacter)
                {
                    WowPlayer player = SkipIfOutOfRange(wowPlayers.FirstOrDefault(p => p.Name == Config.SpecificCharacterToFollow));

                    if (player != null)
                    {
                        PlayerToFollowGuid = player.Guid;
                    }
                }

                // check the group/raid leader
                if (PlayerToFollow == null && Config.FollowGroupLeader)
                {
                    WowPlayer player = SkipIfOutOfRange(wowPlayers.FirstOrDefault(p => p.Guid == WowInterface.ObjectManager.PartyleaderGuid));

                    if (player != null)
                    {
                        PlayerToFollowGuid = player.Guid;
                    }
                }

                // check the group members
                if (PlayerToFollow == null && Config.FollowGroupMembers)
                {
                    WowPlayer player = SkipIfOutOfRange(wowPlayers.FirstOrDefault(p => WowInterface.ObjectManager.PartymemberGuids.Contains(p.Guid)));

                    if (player != null)
                    {
                        PlayerToFollowGuid = player.Guid;
                    }
                }
            }

            if (PlayerToFollow == null)
            {
                StateMachine.SetState(BotState.Idle);
                return;
            }
            else if (Config.FollowPositionDynamic && OffsetCheckEvent.Run())
            {
                // Vector3 rndPos = WowInterface.PathfindingHandler.GetRandomPointAround((int)WowInterface.ObjectManager.MapId, PlayerToFollow.Position, Config.MinFollowDistance * 0.2f);
                // Offset = PlayerToFollow.Position - rndPos;

                Random rnd = new Random();

                Offset = new Vector3
                {
                    X = ((float)rnd.NextDouble() * (float)(Config.MinFollowDistance * 2)) - (float)(Config.MinFollowDistance),
                    Y = ((float)rnd.NextDouble() * (float)(Config.MinFollowDistance * 2)) - (float)(Config.MinFollowDistance),
                    Z = 0f
                };
            }
        }