Beispiel #1
0
        public void PublicOverheadMessage( MessageType type, int hue, bool ascii, string text )
        {
            if ( m_Map != null )
            {
                Packet p = null;
                Point3D worldLoc = GetWorldLocation();

                IPooledEnumerable eable = m_Map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );

                foreach ( NetState state in eable )
                {
                    Mobile m = state.Mobile;

                    if ( m.CanSee( this ) && m.InRange( worldLoc, GetUpdateRange( m ) ) )
                    {
                        if ( p == null )
                        {
                            if ( ascii )
                                p = new AsciiMessage( m_Serial, m_ItemID, type, hue, 3, m_Name, text );
                            else
                                p = new UnicodeMessage( m_Serial, m_ItemID, type, hue, 3, "ENU", m_Name, text );
                        }

                        state.Send( p );
                    }
                }

                eable.Free();
            }
        }
Beispiel #2
0
        public static void Broadcast( int hue, bool ascii, string text )
        {
            Packet p;

            if ( ascii )
                p = new AsciiMessage( Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text );
            else
                p = new UnicodeMessage( Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text );

            ArrayList list = NetState.Instances;

            for ( int i = 0; i < list.Count; ++i )
            {
                if ( ((NetState)list[i]).Mobile != null )
                    ((NetState)list[i]).Send( p );
            }

            NetState.FlushAll();
        }
Beispiel #3
0
        public void NonlocalOverheadMessage( MessageType type, int hue, bool ascii, string text )
        {
            if ( m_Map != null )
            {
                Packet p = null;

                IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );

                foreach ( NetState state in eable )
                {
                    if ( state != m_NetState && state.Mobile.CanSee( this ) )
                    {
                        if ( p == null )
                        {
                            if ( ascii )
                                p = new AsciiMessage( m_Serial, Body, type, hue, 3, Name, text  );
                            else
                                p = new UnicodeMessage( m_Serial, Body, type, hue, 3, Language, Name, text );
                        }

                        state.Send( p );
                    }
                }

                eable.Free();
            }
        }
Beispiel #4
0
        public void PublicOverheadMessage( MessageType type, int hue, bool ascii, string text, bool noLineOfSight )
        {
            if ( m_Map != null )
            {
                Packet p = null;

                IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );

                foreach ( NetState state in eable )
                {
                    if ( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) )
                    {
                        if ( p == null )
                        {
                            if ( ascii || (!this.Player && PreferAscii ) )
                                p = new AsciiMessage( m_Serial, Body, type, hue, 3, Name, text );
                            else
                                p = new UnicodeMessage( m_Serial, Body, type, hue, 3, m_Language, Name, text );
                        }

                        state.Send( p );
                    }
                }

                eable.Free();
            }
        }
Beispiel #5
0
        public void PublicOverheadMessage( MessageType type, int hue, bool ascii, string text, bool noLineOfSight = true )
        {
            if ( m_Map != null )
            {
                Packet p = null;

                foreach ( GameClient state in m_Map.GetClientsInRange( m_Location ) )
                {
                    if ( state.Mobile.CanSee( this ) && ( noLineOfSight || state.Mobile.InLOS( this ) ) )
                    {
                        if ( p == null )
                        {
                            if ( ascii )
                                p = new AsciiMessage( this.Serial, Body, type, hue, 3, Name, text );
                            else
                                p = new UnicodeMessage( this.Serial, Body, type, hue, 3, m_Language, Name, text );

                            p.Acquire();
                        }

                        state.Send( p );
                    }
                }

                Packet.Release( p );
            }
        }
Beispiel #6
0
        public virtual void DoSpeech( string text, int[] keywords, MessageType type, int hue )
        {
            if ( m_Deleted || Commands.Handle( this, text ) )
                return;

            int range = 15;

            switch ( type )
            {
                case MessageType.Regular: m_SpeechHue = hue; break;
                case MessageType.Emote: m_EmoteHue = hue; break;
                case MessageType.Whisper: m_WhisperHue = hue; range = 1; break;
                case MessageType.Yell: m_YellHue = hue; range = 18; break;
                default: type = MessageType.Regular; break;
            }

            SpeechEventArgs regArgs = new SpeechEventArgs( this, text, type, hue, keywords );

            EventSink.InvokeSpeech( regArgs );
            m_Region.OnSpeech( regArgs );
            OnSaid( regArgs );

            if ( regArgs.Blocked )
                return;

            text = regArgs.Speech;

            if ( text == null || text.Length == 0 )
                return;

            if ( m_Hears == null )
                m_Hears = new ArrayList();
            else if ( m_Hears.Count > 0 )
                m_Hears.Clear();

            if ( m_OnSpeech == null )
                m_OnSpeech = new ArrayList();
            else if ( m_OnSpeech.Count > 0 )
                m_OnSpeech.Clear();

            ArrayList hears = m_Hears;
            ArrayList onSpeech = m_OnSpeech;

            if ( m_Map != null )
            {
                IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, range );

                foreach ( object o in eable )
                {
                    if ( o is Mobile )
                    {
                        Mobile heard = (Mobile)o;

                        if ( heard.CanSee( this ) && (m_NoSpeechLOS || !heard.Player || heard.InLOS( this )) )
                        {
                            if ( heard.m_NetState != null )
                                hears.Add( heard );

                            if ( heard.HandlesOnSpeech( this ) )
                                onSpeech.Add( heard );

                            for ( int i = 0; i < heard.Items.Count; ++i )
                            {
                                Item item = (Item)heard.Items[i];

                                if ( item.HandlesOnSpeech )
                                    onSpeech.Add( item );

                                if ( item is Container )
                                    AddSpeechItemsFrom( onSpeech, (Container)item );
                            }
                        }
                    }
                    else if ( o is Item )
                    {
                        if ( ((Item)o).HandlesOnSpeech )
                            onSpeech.Add( o );

                        if ( o is Container )
                            AddSpeechItemsFrom( onSpeech, (Container)o );
                    }
                }

                //eable.Free();

                object mutateContext = null;
                string mutatedText = text;
                SpeechEventArgs mutatedArgs = null;

                if ( MutateSpeech( hears, ref mutatedText, ref mutateContext ) )
                    mutatedArgs = new SpeechEventArgs( this, mutatedText, type, hue, new int[0] );

                CheckSpeechManifest();

                ProcessDelta();

                Packet regp = null;
                Packet mutp = null;

                for ( int i = 0; i < hears.Count; ++i )
                {
                    Mobile heard = (Mobile)hears[i];

                    if ( mutatedArgs == null || !CheckHearsMutatedSpeech( heard, mutateContext ) )
                    {
                        heard.OnSpeech( regArgs );

                        NetState ns = heard.NetState;

                        if ( ns != null )
                        {
                            if ( regp == null )
                                regp = new UnicodeMessage( m_Serial, Body, type, hue, 3, m_Language, Name, text );

                            ns.Send( regp );
                        }
                    }
                    else
                    {
                        heard.OnSpeech( mutatedArgs );

                        NetState ns = heard.NetState;

                        if ( ns != null )
                        {
                            if ( mutp == null )
                                mutp = new UnicodeMessage( m_Serial, Body, type, hue, 3, m_Language, Name, mutatedText );

                            ns.Send( mutp );
                        }
                    }
                }

                if ( onSpeech.Count > 1 )
                    onSpeech.Sort( LocationComparer.GetInstance( this ) );

                for ( int i = 0; i < onSpeech.Count; ++i )
                {
                    object obj = onSpeech[i];

                    if ( obj is Mobile )
                    {
                        Mobile heard = (Mobile)obj;

                        if ( mutatedArgs == null || !CheckHearsMutatedSpeech( heard, mutateContext ) )
                            heard.OnSpeech( regArgs );
                        else
                            heard.OnSpeech( mutatedArgs );
                    }
                    else
                    {
                        Item item = (Item)obj;

                        item.OnSpeech( regArgs );
                    }
                }
            }
        }
Beispiel #7
0
        public void PublicLOSMessage( MessageType type, int hue, bool ascii, string text )
        {
            Packet p = null;
            Point3D worldLoc = GetWorldLocation();

            IPooledEnumerable eable = GetClientsInRange( GetMaxUpdateRange() );
            foreach ( NetState state in eable )
            {
                Mobile m = state.Mobile;

                if ( m.CanSee( this ) && m.InRange( worldLoc, GetUpdateRange( m ) ) && this.Map.LineOfSight( this.Map.GetPoint( m, true ), worldLoc ) )
                {
                    if ( p == null )
                    {
                        if ( ascii )
                            p = new AsciiMessage( Serial, ItemID, type, hue, 3, Name, text );
                        else
                            p = new UnicodeMessage( Serial, ItemID, type, hue, 3, "ENU", Name, text );
                        p.SetStatic();
                    }
                    state.Send( p );
                }
                Packet.Release( ref p );
            }
            eable.Free();
        }
Beispiel #8
0
        public void NonlocalOverheadMessage( MessageType type, int hue, bool ascii, string text )
        {
            if ( m_Map != null )
            {
                Packet p = null;

                foreach ( GameClient state in m_Map.GetClientsInRange( m_Location ) )
                {
                    if ( state != m_Client && state.Mobile.CanSee( this ) )
                    {
                        if ( p == null )
                        {
                            if ( ascii )
                                p = new AsciiMessage( this.Serial, Body, type, hue, 3, Name, text );
                            else
                                p = new UnicodeMessage( this.Serial, Body, type, hue, 3, Language, Name, text );

                            p.Acquire();
                        }

                        state.Send( p );
                    }
                }

                Packet.Release( p );
            }
        }
        public static void PublicOverheadMessage( Mobile m, MessageType type, int hue, string text )
        {
            if( m.Map != null )
            {
                Packet p = null;

                IPooledEnumerable eable = m.Map.GetClientsInRange( m.Location );

                foreach( NetState state in eable )
                {
                    if( state.Mobile != null && state.Mobile.CanSee( m ) && state.Mobile.AccessLevel >= AccessLevel.GameMaster )
                    {
                        if( p == null )
                        {
                            p = new UnicodeMessage( m.Serial, m.Body, type, hue, 3, m.Language, m.Name, text );

                            p.Acquire();
                        }

                        state.Send( p );
                    }
                }

                Packet.Release( p );

                eable.Free();
            }
        }
Beispiel #10
0
		public static void Broadcast(int hue, bool ascii, string text)
		{
			Packet p;

			if (ascii)
				p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
			else
				p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);

			List<NetState> list = NetState.Instances;

			p.Acquire();

			for (int i = 0; i < list.Count; ++i)
			{
				if (list[i].Mobile != null)
					list[i].Send(p);
			}

			p.Release();

			NetState.FlushAll();
		}
Beispiel #11
0
        public void SendPublicMessage( Mobile from, string text )
        {
            SendToAll( new PartyTextMessage( true, from, text ) );

            for ( int i = 0; i < m_Listeners.Count; ++i )
            {
                Mobile mob = (Mobile)m_Listeners[i];

                if ( mob.Party != this )
                    ((Mobile)m_Listeners[i]).SendMessage( "[{0}]: {1}", from.Name, text );
            }

            Packet p = null;

            foreach ( NetState ns in from.GetClientsInRange( 8 ) )
            {
                Mobile mob = ns.Mobile;

                if ( mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel && mob.Party != this && !m_Listeners.Contains( mob ) )
                {
                    if ( p == null )
                        p = new UnicodeMessage( from.Serial, from.Body, MessageType.Regular, from.SpeechHue, 3, from.Language, from.Name, String.Format( "[Party]: {0}", text ) );

                    ns.Send( p );
                }
            }
        }
Beispiel #12
0
		public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text, bool noLineOfSight)
		{
			if (m_Map != null)
			{
				Packet p = null;

				IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location);

				foreach (NetState state in eable)
				{
					// wea: changed to a check to see if target is audible to the speaker 
					// if ( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) )
					if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.IsAudibleTo(this)))
					{
						if (p == null)
						{
							if (ascii)
								p = new AsciiMessage(m_Serial, Body, type, hue, 3, Name, text);
							else
								p = new UnicodeMessage(m_Serial, Body, type, hue, 3, m_Language, Name, text);

							p.Acquire();
						}

						state.Send(p);
					}
				}

				Packet.Release(p);

				eable.Free();
			}
		}
      private static void Msg( CommandEventArgs e  )
      {
         Mobile from = e.Mobile;

         Guild GuildC = from.Guild as Guild;
         if ( GuildC == null )
         {
            from.SendMessage( "You are not in a guild!" );
         }
         else
         {
            foreach ( NetState state in NetState.Instances )
            {
               Mobile m = state.Mobile;
               if ( m != null && GuildC.IsMember( m ) )
               {
                  m.SendMessage( 0x2C, String.Format( "Guild[{0}]: {1}", from.Name, e.ArgString ) );
               }
            }
			Packet p = null;
			foreach (NetState ns in from.GetClientsInRange(8))
			{
				Mobile mob = ns.Mobile;
				if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel)
				{
					if (p == null)
						p = new UnicodeMessage(from.Serial, from.Body, MessageType.Regular, from.SpeechHue, 3, from.Language, from.Name, String.Format("[Guild]: {0}", e.ArgString));
					ns.Send(p);
				}
			}
         }
      }