Beispiel #1
0
        private static void ClosestMonsterTarget(params int[] noto)
        {
            if (!Client.Instance.AllowBit(FeatureBit.ClosestTargets))
            {
                return;
            }

            var list = new List <Mobile>();

            foreach (var m in World.MobilesInRange(12))
            {
                if (!m.IsMonster)
                {
                    continue;
                }

                if ((!FriendsManager.IsFriend(m.Serial) || noto.Length > 0 && noto[0] == 0) &&
                    !m.Blessed && !m.IsGhost && m.Serial != World.Player.Serial &&
                    !TargetFilterManager.IsFilteredTarget(m.Serial) &&
                    Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange")))
                {
                    for (var i = 0; i < noto.Length; i++)
                    {
                        if (noto[i] == m.Notoriety)
                        {
                            list.Add(m);
                            break;
                        }
                    }

                    if (noto.Length == 0)
                    {
                        list.Add(m);
                    }
                }
            }

            Mobile closest     = null;
            var    closestDist = double.MaxValue;

            foreach (var m in list)
            {
                var dist = Utility.DistanceSqrt(m.Position, World.Player.Position);

                if (dist < closestDist || closest == null)
                {
                    closestDist = dist;
                    closest     = m;
                }
            }

            if (closest != null)
            {
                SetLastTargetTo(closest);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne);
            }
        }
Beispiel #2
0
        public static void ClosestHumanoidTarget(params int[] noto)
        {
            if (!ClientCommunication.AllowBit(FeatureBit.ClosestTargets))
            {
                return;
            }

            ArrayList list = new ArrayList();

            foreach (Mobile m in World.MobilesInRange(12))
            {
                if (m.Body != 0x0190 && m.Body != 0x0191 && m.Body != 0x025D && m.Body != 0x025E)
                {
                    continue;
                }

                if ((!FriendsAgent.IsFriend(m) || (noto.Length > 0 && noto[0] == 0)) &&
                    !m.Blessed && !m.IsGhost && m.Serial != World.Player.Serial &&
                    Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange")))
                {
                    for (int i = 0; i < noto.Length; i++)
                    {
                        if (noto[i] == m.Notoriety)
                        {
                            list.Add(m);
                            break;
                        }
                    }

                    if (noto.Length == 0)
                    {
                        list.Add(m);
                    }
                }
            }

            Mobile closest     = null;
            double closestDist = double.MaxValue;

            foreach (Mobile m in list)
            {
                double dist = Utility.DistanceSqrt(m.Position, World.Player.Position);

                if (dist < closestDist || closest == null)
                {
                    closestDist = dist;
                    closest     = m;
                }
            }

            if (closest != null)
            {
                SetLastTargetTo(closest);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne);
            }
        }
Beispiel #3
0
        public static void ClosestMonsterTarget(params int[] noto)
        {
            List <Mobile> list = new List <Mobile>();

            foreach (Mobile m in World.MobilesInRange(12))
            {
                if (!m.IsMonster)
                {
                    continue;
                }

                if (((noto.Length > 0 && noto[0] == 0)) &&
                    !m.Blessed && !m.IsGhost && m.Serial != World.Player.Serial &&
                    Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange")))
                {
                    for (int i = 0; i < noto.Length; i++)
                    {
                        if (noto[i] == m.Notoriety)
                        {
                            list.Add(m);
                            break;
                        }
                    }

                    if (noto.Length == 0)
                    {
                        list.Add(m);
                    }
                }
            }

            Mobile closest     = null;
            double closestDist = double.MaxValue;

            foreach (Mobile m in list)
            {
                double dist = Utility.DistanceSqrt(m.Position, World.Player.Position);

                if (dist < closestDist || closest == null)
                {
                    closestDist = dist;
                    closest     = m;
                }
            }

            if (closest != null)
            {
                SetLastTargetTo(closest);
            }
        }
Beispiel #4
0
        public static void ClosestFriendTarget()
        {
            if (!Client.Instance.AllowBit(FeatureBit.ClosestTargets))
            {
                return;
            }

            var list = new List <Mobile>();

            foreach (var m in World.MobilesInRange(12))
            {
                if (FriendsManager.IsFriend(m.Serial) && !m.Blessed && !m.IsGhost && m.Serial != World.Player.Serial &&
                    !TargetFilterManager.IsFilteredTarget(m.Serial) &&
                    Utility.InRange(World.Player.Position, m.Position, Config.GetInt("LTRange")))
                {
                    list.Add(m);
                }
            }

            Mobile closest     = null;
            var    closestDist = double.MaxValue;

            foreach (var m in list)
            {
                var dist = Utility.DistanceSqrt(m.Position, World.Player.Position);

                if (dist < closestDist || closest == null)
                {
                    closestDist = dist;
                    closest     = m;
                }
            }

            if (closest != null)
            {
                SetLastTargetTo(closest);
                ScriptManager.TargetFound = true;
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne);
            }
        }