Пример #1
0
        public void CallGuards(Point3D p)
        {
            if (IsDisabled())
            {
                return;
            }

            IPooledEnumerable eable = Map.GetMobilesInRange(p, 14);

            foreach (Mobile m in eable)
            {
                if (IsGuardCandidate(m) && ((!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this)) || m_GuardCandidates.ContainsKey(m)))
                {
                    GuardTimer timer = null;
                    m_GuardCandidates.TryGetValue(m, out timer);

                    if (timer != null)
                    {
                        timer.Stop();
                        m_GuardCandidates.Remove(m);
                    }

                    MakeGuard(m);
                    m.SendLocalizedMessage(502276);                       // Guards can no longer be called on you.
                    break;
                }
            }

            eable.Free();
        }
Пример #2
0
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsDisabled())
            {
                return;
            }

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue(m, out timer);

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio     = 0.0;

                        foreach (Mobile v in m.GetMobilesInRange(8))
                        {
                            if (!v.Player && v.Body.IsHuman && v != m && !IsGuardCandidate(v))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio     = dist;
                                }
                            }
                        }

                        if (fakeCall != null)
                        {
                            if (fakeCall is BaseVendor && !(fakeCall is BaseGuard))
                            {
                                fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));
                            }

                            MakeGuard(m);
                            timer.Stop();
                            m_GuardCandidates.Remove(m);
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
Пример #3
0
        public void CallGuards(Point3D p)
        {
            if (IsDisabled())
            {
                return;
            }

            IPooledEnumerable eable = Map.GetMobilesInRange(p, 14);

            foreach (Mobile m in eable)
            {
                if (IsGuardCandidate(m) && (((m is PlayerMobile) && (m.Karma <= -110) && m.Region.IsPartOf(this)) || m_GuardCandidates.ContainsKey(m)))
                {
                    GuardTimer timer = null;
                    m_GuardCandidates.TryGetValue(m, out timer);

                    if (timer != null)
                    {
                        timer.Stop();
                        m_GuardCandidates.Remove(m);
                    }

                    MakeGuard(m);
                    m.SendAsciiMessage("Guards can no longer be called on you.");
                    break;
                }
            }

            eable.Free();
        }
Пример #4
0
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsDisabled())
            {
                return;
            }

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue(m, out timer);

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendLocalizedMessage(502275);                     // Guards can now be called on you!

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio     = 0.0;

                        foreach (Mobile v in m.GetMobilesInRange(8))
                        {
                            if (!v.Player && v != m && !IsGuardCandidate(v) &&
                                ((v is BaseCreature) ? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf(this))))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio     = dist;
                                }
                            }
                        }

                        if (fakeCall != null)
                        {
                            fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));
                            MakeGuard(m);
                            timer.Stop();
                            m_GuardCandidates.Remove(m);
                            m.SendLocalizedMessage(502276);                             // Guards can no longer be called on you.
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
Пример #5
0
        public void RemoveGuardCandidate(Mobile m)
        {
            GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

            if (timer != null)
            {
                timer.Stop();
                m_GuardCandidates.Remove(m);
                m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
            }
        }
Пример #6
0
        public bool AddGuardCandidate(Mobile m)
        {
            GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

            if (timer == null)
            {
                timer = new GuardTimer(m, m_GuardCandidates);
                timer.Start();

                m_GuardCandidates[m] = timer;
                m.SendLocalizedMessage(502275); // Guards can now be called on you!

                return(true);
            }
            else
            {
                timer.Stop();
                timer.Start();

                return(false);
            }
        }
        public void CallGuards(Point3D p)
        {
            if (IsDisabled())
            {
                return;
            }

            IPooledEnumerable eable   = Map.GetMobilesInRange(p, 14);
            Queue             mobiles = new Queue();

            foreach (Mobile m in eable)
            {
                mobiles.Enqueue(m);
            }

            while (mobiles.Count > 0)
            {
                Mobile m = mobiles.Dequeue() as Mobile;

                if (IsGuardCandidate(m) && ((!AllowReds && m.MurderCounts >= Mobile.MurderCountsRequiredForMurderer && m.Region.IsPartOf(this)) || m_GuardCandidates.ContainsKey(m)))
                {
                    GuardTimer timer = null;
                    m_GuardCandidates.TryGetValue(m, out timer);

                    if (timer != null)
                    {
                        timer.Stop();
                        m_GuardCandidates.Remove(m);
                    }

                    MakeGuard(m);
                    m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
                }
            }

            eable.Free();
        }
        public void CheckGuardCandidate( Mobile m )
        {
            if ( IsDisabled() )
                return;

            if ( IsGuardCandidate( m ) )
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue( m, out timer );

                if ( timer == null )
                {
                    timer = new GuardTimer( m, m_GuardCandidates );
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendLocalizedMessage( 502275 ); // Guards can now be called on you!

                    Map map = m.Map;

                    if ( map != null )
                    {
                        Mobile fakeCall = null;
                        double prio = 0.0;

                        foreach ( Mobile v in m.GetMobilesInRange( 8 ) )
                        {
                            if( !v.Player && v != m  && !IsGuardCandidate( v ) && !(v is CharacterStatue) && ((v is BaseCreature)? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf( this ))) )
                            {
                                double dist = m.GetDistanceToSqrt( v );

                                if ( fakeCall == null || dist < prio )
                                {
                                    fakeCall = v;
                                    prio = dist;
                                }
                            }
                        }

                        if ( fakeCall != null )
                        {
                            fakeCall.Say( Utility.RandomList( 1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052 ) );
                            MakeGuard( m );
                            timer.Stop();
                            m_GuardCandidates.Remove( m );
                            m.SendLocalizedMessage( 502276 ); // Guards can no longer be called on you.
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsDisabled())
                return;

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendLocalizedMessage(502275); // Guards can now be called on you!

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio = 0.0;

                        foreach (Mobile v in m.GetMobilesInRange(8))
                        {
                            if (!v.Player && v != m && !IsGuardCandidate(v) && IsInTownNPC(v))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio = dist;
                                }
                            }
                        }

                        if (fakeCall != null)
                        {
                            fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));
                            MakeGuard(m);
                            m_GuardCandidates.Remove(m);
                            m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
Пример #10
0
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsDisabled())
                return;

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue(m, out timer);

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio = 0.0;

                        foreach (Mobile v in m.GetMobilesInRange(8))
                        {
                            if (!v.Player && v.Body.IsHuman && v != m && !IsGuardCandidate(v))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio = dist;
                                }
                            }
                        }

                        if (fakeCall != null)
                        {
                            if (fakeCall is BaseVendor && !(fakeCall is BaseGuard))
                                fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));

                            MakeGuard(m);
                            timer.Stop();
                            m_GuardCandidates.Remove(m);
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
Пример #11
0
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsGuarded == false)
            {
                return;
            }

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendLocalizedMessage(502275);                       // Guards can now be called on you!

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio     = 0.0;

                        IPooledEnumerable eable = m.GetMobilesInRange(8);
                        foreach (Mobile v in eable)
                        {
                            if (!v.Player &&
                                v.Body.IsHuman &&
                                v != m &&
                                !IsGuardCandidate(v))
                            {
                                //Pixie 10/28/04: checking whether v is in the region fixes the problem
                                // where player1 recalls to a guardzone before player2's explosion hits ...
                                if (this.Contains(v.Location))
                                {
                                    double dist = m.GetDistanceToSqrt(v);

                                    if (fakeCall == null || dist < prio)
                                    {
                                        fakeCall = v;
                                        prio     = dist;
                                    }
                                }
                                else
                                {
                                    //System.Console.WriteLine( "Mobile ({0}) isn't in this region, so skip him!", v.Name );
                                }
                            }
                        }
                        eable.Free();

                        if (fakeCall != null)
                        {
                            fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));
                            MakeGuard(m);
                            m_GuardCandidates.Remove(m);
                            m.SendLocalizedMessage(502276);                               // Guards can no longer be called on you.
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
Пример #12
0
		public void CheckGuardCandidate( Mobile m )
		{
			if ( IsGuarded == false )
				return;

			if ( IsGuardCandidate( m ) )
			{
				GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

				if ( timer == null )
				{
					timer = new GuardTimer( m, m_GuardCandidates );
					timer.Start();

					m_GuardCandidates[m] = timer;
					m.SendLocalizedMessage( 502275 ); // Guards can now be called on you!

					Map map = m.Map;

					if ( map != null )
					{
						Mobile fakeCall = null;
						double prio = 0.0;

						IPooledEnumerable eable = m.GetMobilesInRange( 8 );
						foreach ( Mobile v in eable)
						{
							if ( !v.Player &&
								  v.Body.IsHuman && 
								  v != m && 
								 !IsGuardCandidate( v ) )
							{
								//Pixie 10/28/04: checking whether v is in the region fixes the problem
								// where player1 recalls to a guardzone before player2's explosion hits ...
								if( this.Contains( v.Location ) )
								{
									double dist = m.GetDistanceToSqrt( v );

									if ( fakeCall == null || dist < prio )
									{
										fakeCall = v;
										prio = dist;
									}
								}
								else
								{
									//System.Console.WriteLine( "Mobile ({0}) isn't in this region, so skip him!", v.Name );
								}
							}
						}
						eable.Free();

						if ( fakeCall != null )
						{
							fakeCall.Say( Utility.RandomList( 1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052 ) );
							MakeGuard( m );
							m_GuardCandidates.Remove( m );
							m.SendLocalizedMessage( 502276 ); // Guards can no longer be called on you.
						}
					}
				}
				else
				{
					timer.Stop();
					timer.Start();
				}
			}
		}
Пример #13
0
        public void CheckGuardCandidate(Mobile m)
        {
            if (IsDisabled())
            {
                return;
            }

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue(m, out timer);

                if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendAsciiMessage("Guards can now be called on you!");

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio     = 0.0;

                        foreach (Mobile v in m.GetMobilesInRange(8))
                        {
                            if (!v.Player && v != m && !IsGuardCandidate(v) && ((v is BaseCreature) ? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf(this))))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (v is BaseGuard && ((BaseGuard)v).Focus != null && ((BaseGuard)v).Focus == m)
                                {
                                    return;
                                }

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio     = dist;
                                }
                            }
                        }

                        if (fakeCall is BaseGuard && ((BaseGuard)fakeCall).Focus == null)
                        {
                            ((BaseGuard)fakeCall).Focus = m;
                            return;
                        }

                        if (fakeCall != null)
                        {
                            switch (Utility.Random(9))
                            {
                            case 0: fakeCall.Say(true, "I hope the guards catch thee, scum!"); break;

                            case 1: fakeCall.Say(true, "Guards! Help!"); break;

                            case 2: fakeCall.Say(true, "Thou'rt scum! Guards!"); break;

                            case 3: fakeCall.Say(true, "Guards! A villain!"); break;

                            case 4: fakeCall.Say(true, "Tis a villain! Guards!"); break;

                            case 5: fakeCall.Say(true, "Help! Guards! Flood, fire, famine!"); break;

                            case 6: fakeCall.Say(true, "Aaaah! They will kill me! Guards!"); break;

                            case 7: fakeCall.Say(true, "Arrest this scum!"); break;

                            case 8: fakeCall.Say(true, "Guards! Guards!"); break;
                            }

                            MakeGuard(m);
                            //timer.Stop();
                            //m_GuardCandidates.Remove( m );
                            //m.SendAsciiMessage("Guards can no longer be called on you.");
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
Пример #14
0
        public void CheckGuardCandidate( Mobile m )
        {
            if ( IsDisabled() )
                return;

            if (m.Combatant != null && m_GuardCandidates.ContainsKey(m.Combatant))
                return;

            if ( IsGuardCandidate( m ) )
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue( m, out timer );

                if ( timer == null )
                {
                    timer = new GuardTimer( m, m_GuardCandidates );
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    //m.SendLocalizedMessage( 502275 ); // Guards can now be called on you!
                    m.SendAsciiMessage("Guards can now be called on you!");

                    Map map = m.Map;

                    if ( map != null )
                    {
                        Mobile fakeCall = null;
                        double prio = 0.0;

                        foreach ( Mobile v in m.GetMobilesInRange( 8 ) )
                        {
                            if( !v.Player && v != m  && !IsGuardCandidate( v ) && ((v is BaseCreature)? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf( this ))) )
                            {
                                double dist = m.GetDistanceToSqrt( v );

                                if ( fakeCall == null || dist < prio )
                                {
                                    fakeCall = v;
                                    prio = dist;
                                }
                            }
                        }

                        if ( fakeCall != null )
                        {
                            //fakeCall.Say( Utility.RandomList( 1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052 ) );
                            switch (Utility.Random(9))
                            {
                                case 0: fakeCall.Say(true, "I hope the guards catch thee, scum!"); break;
                                case 1: fakeCall.Say(true, "Guards! Help!"); break;
                                case 2: fakeCall.Say(true, "Thou'rt scum! Guards!"); break;
                                case 3: fakeCall.Say(true, "Guards! A villain!"); break;
                                case 4: fakeCall.Say(true, "Tis a villain! Guards!"); break;
                                case 5: fakeCall.Say(true, "Help! Guards! Flood, fire, famine!"); break;
                                case 6: fakeCall.Say(true, "Aaaah! They will kill me! Guards!"); break;
                                case 7: fakeCall.Say(true, "Arrest this scum!"); break;
                                case 8: fakeCall.Say(true, "Guards! Guards!"); break;
                            }

                            MakeGuard( m );
                            timer.Stop();
                            m_GuardCandidates.Remove( m );
                            //m.SendLocalizedMessage( 502276 ); // Guards can no longer be called on you.
                            m.SendAsciiMessage("Guards can no longer be called on you.");
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
Пример #15
0
        public bool AddGuardCandidate(Mobile m)
        {
            GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

            if (timer == null)
            {
                timer = new GuardTimer(m, m_GuardCandidates);
                timer.Start();

                m_GuardCandidates[m] = timer;
                m.SendLocalizedMessage(502275); // Guards can now be called on you!

                return true;
            }
            else
            {
                timer.Stop();
                timer.Start();

                return false;
            }
        }