Beispiel #1
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 #2
0
        private static void OnAttack(PacketReader p, PacketHandlerEventArgs args)
        {
            Mobile mobile = World.FindMobile(p.ReadUInt32());

            if (mobile != null && (FriendsAgent.IsFriend(mobile) || mobile.Notoriety == 1 || mobile.Notoriety == 2 || mobile.Renamable))
            {
                WorldEx.SendMessage("Attack blocked.");
                args.Block = true;
            }
        }
Beispiel #3
0
 public static void AttackLast()
 {
     if (Targeting.m_LastTarget != null && Targeting.m_LastTarget.Serial != lastOath)
     {
         Mobile mobile = World.FindMobile(Targeting.m_LastTarget.Serial);
         if (mobile != null && !FriendsAgent.IsFriend(mobile) && mobile.Notoriety != 1 && mobile.Notoriety != 2 && !mobile.Renamable)
         {
             ClientCommunication.SendToServer(new AttackReq(Targeting.m_LastTarget.Serial));
         }
     }
 }
Beispiel #4
0
        public static Mobile GetClosest(params byte[] notoriety)
        {
            Mobile result = null;

            foreach (Mobile mobile in World.MobilesInRange(Config.GetInt("LTRange")))
            {
                if (FriendsAgent.IsFriend(mobile) || PacketHandlers.Party.Contains(mobile.Serial) || mobile.Serial == World.Player.Serial || Array.IndexOf(notoriety, mobile.Notoriety) == -1 || mobile.Renamable)
                {
                    continue;
                }
                if (mobile.Notoriety == 6)
                {
                    if (mobile.Body == 0x0009 && mobile.Hue == 0x0000) // daemon
                    {
                        continue;
                    }

                    if (mobile.Body == 0x02F4) // picovina golema
                    {
                        continue;
                    }

                    if (mobile.Body == 0x0033 && mobile.Hue == 0x4001 &&
                        (mobile.Name.StartsWith("a nature's fury") ||
                         (mobile.Name.StartsWith("a fire fury") && !PositionCheck.InFire)))
                    {
                        continue;
                    }

                    if (mobile.Body == 0x02EC && mobile.Hue == 0x4001) // wraith form
                    {
                        continue;
                    }

                    if (mobile.Body == 0x000E && mobile.Hue == 0x0000) // mental z krumpu
                    {
                        continue;
                    }

                    if (mobile.Body == 0x008A && mobile.Hue == 0x4001) // ork z talismanu
                    {
                        continue;
                    }
                }

                if (result == null || Utility.DistanceSqrt(World.Player.Position, mobile.Position) < Utility.DistanceSqrt(World.Player.Position, result.Position))
                {
                    result = mobile;
                }
            }
            return(result);
        }
Beispiel #5
0
        public static void RandomHumanoidTarget(params int[] noto)
        {
            if (!ClientCommunication.AllowBit(FeatureBit.RandomTargets))
            {
                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);
                    }
                }
            }

            if (list.Count > 0)
            {
                SetLastTargetTo((Mobile)list[Utility.Random(list.Count)]);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.TargNoOne);
            }
        }