public MessageLocalized( Serial serial, int graphic, MessageType type, int hue, int font, int number, string name, string args )
            : base(0xC1)
        {
            if (Core.Config.Features["delocalize"]) {
                string format = StringList.Localization[number];
                if (format != null) {
                    string text = StringList.CombineArguments( format, args );

                    /* this hack replaces the packet data generated by
                       this class with an AsciiMessage packet */
                    Packet p = new AsciiMessage(serial, graphic, type, hue, font, name, text);
                    EnsureCapacity(3);
                    m_Stream = p.UnderlyingStream;
                    return;
                }
            }

            if ( name == null ) name = "";
            if ( args == null ) args = "";

            if ( hue == 0 )
                hue = 0x3B2;

            this.EnsureCapacity( 50 + (args.Length * 2) );

            m_Stream.Write( (int) serial );
            m_Stream.Write( (short) graphic );
            m_Stream.Write( (byte) type );
            m_Stream.Write( (short) hue );
            m_Stream.Write( (short) font );
            m_Stream.Write( (int) number );
            m_Stream.WriteAsciiFixed( name, 30 );
            m_Stream.WriteLittleUniNull( args );
        }
        public override void DoSpeech( string text, int[] keywords, MessageType type, int hue )
        {
            if ( Deleted || Commands.CommandSystem.Handle( this, text ) )
                return;

            int range = 15;

            switch ( type )
            {
                case MessageType.Regular: SpeechHue = hue; break;
                case MessageType.Emote: EmoteHue = hue; break;
                case MessageType.Whisper: WhisperHue = hue; range = 1; break;
                case MessageType.Yell: YellHue = hue; range = 18; break;
                default: type = MessageType.Regular; break;
            }

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

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

            if ( regArgs.Blocked )
                return;

            text = regArgs.Speech;

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

            List<Mobile> hears = new List<Mobile>();
            ArrayList onSpeech = new ArrayList();

            bool needSpeechItem = Alive && Hidden && AccessLevel == AccessLevel.Player;

            if ( Map != null )
            {
                IPooledEnumerable eable = Map.GetObjectsInRange( Location, range );

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

                        if ( ( needSpeechItem || heard.CanSee( this ) ) && (NoSpeechLOS || !heard.Player || heard.InLOS( this )) )
                        {
                            if ( heard.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();

                SpeechItem si = null;

                Packet regp = null, regpSI = null;
                Packet mutp = null, mutpSI = 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 ( needSpeechItem && !heard.CanSee( this ) && this != heard )
                            {
                                if ( regpSI == null )
                                {
                                    if ( si == null )
                                        si = SpeechItem.Get( this );
                                    regpSI = new AsciiMessage( si.Serial, si.ItemID, type, hue, 3, "(hidden)", text );
                                    regpSI.SetStatic();
                                }
                                ns.Send( regpSI );
                            }
                            else
                            {
                                if ( regp == null )
                                {
                                    regp = new AsciiMessage( Serial, Body, type, hue, 3, Name, text );
                                    regp.SetStatic();
                                }
                                ns.Send( regp );
                            }
                        }
                    }
                    else
                    {
                        heard.OnSpeech( mutatedArgs );

                        NetState ns = heard.NetState;

                        if ( ns != null )
                        {
                            if ( needSpeechItem && !heard.CanSee( this ) && this != heard )
                            {
                                if ( mutpSI == null )
                                {
                                    if ( si == null )
                                        si = SpeechItem.Get( this );

                                    mutpSI = new AsciiMessage( si.Serial, si.ItemID, type, hue, 3, "(hidden)", mutatedText );
                                    mutpSI.SetStatic();
                                }
                                ns.Send( mutpSI );
                            }
                            else
                            {
                                if ( mutp == null )
                                {
                                    mutp = new AsciiMessage( Serial, Body, type, hue, 3, Name, mutatedText );
                                    mutp.SetStatic();
                                }
                                ns.Send( mutp );
                            }
                        }
                    }
                }

                Packet.Release( ref regp );
                Packet.Release( ref regpSI );
                Packet.Release( ref mutp );
                Packet.Release( ref mutpSI );

                if ( onSpeech.Count > 1 )
                    onSpeech.Sort( new LocationComparer( 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 );
                    }
                }
            }
        }
        public override void OnHarmfulAction( Mobile target, bool isCriminal )
        {
            if ( target != this && !PlayerMobile.CheckAggressors( this, target ) && !PlayerMobile.CheckAggressors( target, this ) )
            {
                IPooledEnumerable eable = GetClientsInRange( 13 );
                Packet p = null;
                foreach ( NetState ns in eable )
                {
                    Mobile m = ns.Mobile;
                    if ( m != null && m.CanSee( this ) && m != target && m != this )
                    {
                        if ( p == null )
                        {
                            p = new AsciiMessage( Serial.MinusOne, -1, MessageType.Regular, 0x3b2, 3, "System", String.Format( "You see {0} attacking {1}!", this.Name, target.Name ) );
                            p.SetStatic();
                        }
                        ns.Send( p );
                    }
                    //if ( Notoriety.Compute( this, target ) == Notoriety.Innocent )
                    //	Titles.AlterNotoriety( this, -1, NotoCap.Dastardly );
                }
                Packet.Release( p );
                eable.Free();

                if ( SkillHandlers.Stealing.AttackOK( this, target ) )
                    AggressiveAction( target, false );
            }

            base.OnHarmfulAction( target, isCriminal );
        }
        public override void OnHarmfulAction(Mobile target, bool isCriminal)
        {
            if ( target != this && !(this is BaseGuard) && !PlayerMobile.CheckAggressors( this, target ) && !PlayerMobile.CheckAggressors( target, this ) )
            {
                IPooledEnumerable eable = GetClientsInRange( 13 );
                Packet p = null;
                foreach ( NetState ns in eable )
                {
                    Mobile m = ns.Mobile;
                    if ( m != null && m.CanSee( this ) && m != target && m != this )
                    {
                        if ( p == null )
                        {
                            p = new AsciiMessage( Serial.MinusOne, -1, MessageType.Regular, 0x3b2, 3, "System", String.Format( "You see {0} attacking {1}!", this.Name, target.Name ) );
                            p.SetStatic();
                        }
                        ns.Send( p );
                    }
                }
                eable.Free();
                Packet.Release( ref p );
            }

            base.OnHarmfulAction( target, isCriminal );
        }
Exemple #5
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();
            }
        }
Exemple #6
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();
        }
        public static void PublicOverheadItemMessage(Item item, MessageType type, int hue, int font, string text)
        {
            if (item != null && item.Map != null)
            {
                Packet p = null;
                Point3D worldLoc = item.GetWorldLocation();

                IPooledEnumerable eable = item.Map.GetClientsInRange(worldLoc, item.GetMaxUpdateRange());

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

                    if (m.CanSee(item) && m.InRange(worldLoc, item.GetUpdateRange(m)))
                    {
                        if (p == null)
                        {
                            p = new AsciiMessage(item.Serial, item.ItemID, type, hue, font, item.Name, text);

                            p.Acquire();
                        }

                        state.Send(p);
                    }
                }

                Packet.Release(p);

                eable.Free();
            }
        }
Exemple #8
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();
        }
Exemple #9
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 BeginMRCapture(CommandEventArgs e)
        {
            m_Capturing = true;
            m_Table = new Dictionary<PlayerMobile,MemoryStream>();
            m_Started = DateTime.Now;
            m_Count = 0;

            Packet p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, 0, 3, "System", "Beginning MovementReq capture. Halting after 30 minutes or 1,000,000 hits.");
            foreach (NetState n in NetState.Instances)
            {
                if (n.Mobile != null && n.Mobile.AccessLevel >= AccessLevel.GameMaster)
                    n.Send(p);
            }
        }
        // Adam: may be called with CommandEventArgs == null
        public static void StopMRCapture(CommandEventArgs e)
        {
            try
            {
                using (FileStream fs = new FileStream("MRCapture.dat", FileMode.Create, FileAccess.Write))
                {
                    using (BinaryWriter writer = new BinaryWriter(fs))
                    {
                        foreach (PlayerMobile pm in m_Table.Keys)
                        {
                            writer.Write((string)pm.Name);
                            writer.Write((int)pm.Serial);
                            writer.Write((string)(((Account)pm.Account).Username));
                            writer.Write((long)m_Table[pm].Length);
                            writer.Write((byte[])m_Table[pm].ToArray());
                        }

                        writer.Close();
                    }

                    fs.Close();
                }

                if (e != null && e.Mobile != null)
                    e.Mobile.SendMessage("Capture data written to MRCapture.dat in the main directory.");
            }
            catch (Exception ex)
            {
                if (e != null && e.Mobile != null)
                    e.Mobile.SendMessage(ex.Message);
            }

            m_Capturing = false;
            m_Table = null;
            m_Started = DateTime.MinValue;
            m_Count = 0;

            Packet p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, 0, 3, "System", "Ended MovementReq capture.");
            foreach (NetState n in NetState.Instances)
            {
                if (n.Mobile != null && n.Mobile.AccessLevel >= AccessLevel.GameMaster)
                    n.Send(p);
            }
        }
Exemple #12
0
        public static void SystemMessage( string from, string message )
        {
            Packet msg = null;
            for (int i=0;i<NetState.Instances.Count;i++)
            {
                NetState state = (NetState)NetState.Instances[i];
                if ( state.Mobile != null )
                {
                    if ( msg == null )
                    {
                        msg = new AsciiMessage( Serial.MinusOne, -1, MessageType.Regular, 0x34, 0, from, String.Format( "{0}: {1}", from, message ) );
                        msg.SetStatic();
                    }
                    state.Send( msg );
                }
            }

            Packet.Release( ref msg );
        }
Exemple #13
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();
		}
        public override void DoSpeech( string text, int[] keywords, MessageType type, int hue )
        {
            if( type != MessageType.Emote )
                hue = GetLanguageHue( this );

            if( Guilds.Guild.NewGuildSystem && (type == MessageType.Guild || type == MessageType.Alliance) )
            {
                Guilds.Guild g = this.Guild as Guilds.Guild;
                if( g == null )
                {
                    SendLocalizedMessage( 1063142 ); // You are not in a guild!
                }
                else if( type == MessageType.Alliance )
                {
                    if( g.Alliance != null && g.Alliance.IsMember( g ) )
                    {
                        //g.Alliance.AllianceTextMessage( hue, "[Alliance][{0}]: {1}", this.Name, text );
                        g.Alliance.AllianceChat( this, text );
                        SendToStaffMessage( this, "[Alliance]: {0}", this.Name, text );

                        m_AllianceMessageHue = hue;
                    }
                    else
                    {
                        SendLocalizedMessage( 1071020 ); // You are not in an alliance!
                    }
                }
                else	//Type == MessageType.Guild
                {
                    m_GuildMessageHue = hue;

                    g.GuildChat( this, text );
                    SendToStaffMessage( this, "[Guild]: {0}", text );
                }
            }
            else
            {
                if( Deleted || CommandSystem.Handle( this, text, type ) )
                    return;

                int range = 15;

                switch( type )
                {
                    case MessageType.Regular:
                        SpeechHue = hue;
                        break;
                    case MessageType.Emote:
                        EmoteHue = hue;
                        break;
                    case MessageType.Whisper:
                        WhisperHue = hue;
                        range = 1;
                        break;
                    case MessageType.Yell:
                        YellHue = hue;
                        range = 18;
                        break;
                    default:
                        type = MessageType.Regular;
                        break;
                }

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

                EventSink.InvokeSpeech( regArgs );
                this.Region.OnSpeech( regArgs );

                if( Squelched && type == MessageType.Emote )
                    regArgs.Blocked = true;

                    OnSaid( regArgs );

                if( regArgs.Blocked )
                    if ( type != MessageType.Emote )
                    return;

                text = regArgs.Speech;

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

                if( m_Hears == null )
                    m_Hears = new List<Mobile>();
                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();

                List<Mobile> hears = m_Hears;
                ArrayList onSpeech = m_OnSpeech;

                string newtext = text.ToLower();
                bool ignore = false;

                if( newtext == "all come" || newtext == "all kill" ||
                   newtext == "all report" || newtext == "all attack" ||
                   newtext == "all stay" || newtext == "all follow me" ||
                   newtext == "all guard me" || newtext == "all stop" ||
                   newtext == "all guard" || newtext == "all follow" ||
                   newtext == "all release" || newtext == "all obey" ||
                   newtext == "i wish to release this" || newtext == "i wish to release this." ||
                   newtext == "i wish to lock this down" || newtext == "i wish to lock this down." || newtext == "bank" )
                {
                    ignore = true;
                }

                if( Map != null )
                {
                    IPooledEnumerable eable = Map.GetObjectsInRange( Location, range );

                    string teaching = "";

                    if( this.m_Teaching )
                        teaching = "[Teaching]";

                    if( !ignore || teaching != "" )
                    {
                        if( newtext != "turn left" && newtext != "turn right" && newtext != "turn about" && newtext != "forward" && newtext != "back" &&
                            newtext != "come about" && newtext != "forward left" && newtext != "forward right" && newtext != "back left" && newtext != "drop anchor" &&
                            newtext != "raise anchor" && newtext != "stop" && newtext != "back right" && newtext != "right" && newtext != "left" )
                        {
                            foreach( NetState state in NetState.Instances )
                            {
                                Mobile staffer = state.Mobile;

                                if( staffer != null && staffer.AccessLevel > AccessLevel.Player && staffer is PlayerMobile && ( ( (PlayerMobile)staffer ).HearAll == 1 || ( (PlayerMobile)staffer ).HearAll == 3 ) )
                                    staffer.SendMessage( hue, "" + teaching + this.Name + ": " + text );
                            }
                        }
                    }

                    this.m_Teaching = false;

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

                            if( heard.CanSee( this ) && ( NoSpeechLOS || !heard.Player || heard.InLOS( this ) ) )
                            {
                                if( heard is PlayerMobile )
                                {
                                    if( ignore )
                                        continue;

                                    if( this.SpokenLanguage == KnownLanguage.Shorthand && type != MessageType.Emote )
                                    {
                                        if( !this.InRange( heard.Location, ( this.Feats.GetFeatLevel(FeatList.Shorthand) * 4 ) ) || ( (PlayerMobile)heard ).Feats.GetFeatLevel(FeatList.Shorthand) < 1 )
                                            continue;

                                        else
                                        {
                                            heard.SendMessage( hue, "[Shorthand]" + this.Name + ": " + text );
                                            continue;
                                        }
                                    }

                                    if( ( (PlayerMobile)heard ).DeafnessTimer != null && type != MessageType.Emote )
                                    {
                                        continue;
                                    }

                                    if( ( (PlayerMobile)heard ).GetBackgroundLevel(BackgroundList.Deaf) > 0 && type != MessageType.Emote && heard.Serial != this.Serial )
                                    {
                                        continue;
                                    }

                                    if( type != MessageType.Emote && (this.GetBackgroundLevel(BackgroundList.Mute) > 0 || this.CannotSpeak) )
                                    {
                                        continue;
                                    }

                                    if( this.SpokenLanguage != KnownLanguage.Shorthand && !KnowsLanguage( ( (PlayerMobile)heard ), this.SpokenLanguage ) && heard.Serial != this.Serial && type != MessageType.Emote )
                                    {
                                        Packet p = null;

                  						if (p == null)
                                        {
                  							p = new AsciiMessage( this.Serial, this.Body, type, hue, 8, this.Name, RandomString( text.Length, true ) );
                                 	    	p.Acquire();

                      						if( heard.NetState != null )
                      						{
                                                heard.NetState.Send(p);
                                                Packet.Release(p);
                      						}
                  						}
                                    }

                                    else
                                    {
                                        if( heard.NetState != null )
                                        {
                                            PlayerMobile student = heard as PlayerMobile;

                                            if( this.m_Students != null && this.m_Students.Contains( student ) && student.m_WantsTeaching && DateTime.Compare( DateTime.Now, ( student.m_LastTeaching + TimeSpan.FromSeconds( 30 ) ) ) > 0 )
                                            {
                                                if( !CanTeach(student) )
                                                {
                                                    student.SendMessage( 60, "You cannot learn anything else from your teacher." );
                                                    this.SendMessage( 60, "You cannot teach anything else to your student." );
                                                    this.m_Students.Remove( student );
                                                    student.m_WantsTeaching = false;
                                                }

                                                else
                                                {
                                                    student.m_LastTeaching = DateTime.Now;
                                                    this.m_LastTeaching = DateTime.Now;

                                                    int exp = 200;

                                                    if( student.Level > 4 )
                                                        exp = 225;

                                                    if( student.Level > 9 )
                                                        exp = 250;

                                                    if( student.Level > 14 )
                                                        exp = 275;

                                                    if( student.Level > 19 )
                                                        exp = 300;

                                                    if( student.Level > 24 )
                                                        exp = 325;

                                                    if( student.Level > 29 )
                                                        exp = 350;

                                                    student.XPFromLearning = true;
                                                    this.XPFromLearning = true;
                                                    LevelSystem.AwardExp( student, exp );
                                                    LevelSystem.AwardCP( student, exp / 4 );
                                                    LevelSystem.AwardExp( this, exp / 2 );
                                                    LevelSystem.AwardCP( this, exp / 8 );
                                                    student.XPFromLearning = false;
                                                    this.XPFromLearning = false;
                                                    this.m_Teaching = true;
                                                }
                                            }

                                            hears.Add( heard );
                                        }

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

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

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

                                            if( item is Container )
                                                base.AddSpeechItemsFrom( onSpeech, (Container)item );
                                        }
                                    }
                                }

                                else
                                {
                                    if( heard.NetState != null )
                                        hears.Add( heard );

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

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

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

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

                            if( o is Container )
                                base.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 = hears[i];

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

                            NetState ns = heard.NetState;

                            if( ns != null )
                            {
                                if( regp == null )
                                    regp = Packet.Acquire( new UnicodeMessage( Serial, Body, type, hue, 3, Language, Name, text ) );

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

                            NetState ns = heard.NetState;

                            if( ns != null )
                            {
                                if( mutp == null )
                                    mutp = Packet.Acquire( new UnicodeMessage( Serial, Body, type, hue, 3, Language, Name, mutatedText ) );

                                ns.Send( mutp );
                            }
                        }
                    }

                    Packet.Release( regp );
                    Packet.Release( 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 );
                        }
                    }
                }
            }
        }
Exemple #15
0
        public MessageLocalizedAffix( Serial serial, int graphic, MessageType messageType, int hue, int font, int number, string name, AffixType affixType, string affix, string args )
            : base(0xCC)
        {
            if (Core.Config.Features["delocalize"]) {
                string text = StringList.Localization[number];
                if (text != null) {
                    if ( (affixType & AffixType.Prepend) == AffixType.Prepend )
                        text = affix + text;
                    else
                        text += affix;

                    /* this hack replaces the packet data generated by
                       this class with an AsciiMessage packet */
                    Packet p = new AsciiMessage(serial, graphic, messageType,
                                                hue, font, name, text);
                    EnsureCapacity(3);
                    m_Stream = p.UnderlyingStream;
                    return;
                }
            }

            if ( name == null ) name = "";
            if ( affix == null ) affix = "";
            if ( args == null ) args = "";

            if ( hue == 0 )
                hue = 0x3B2;

            this.EnsureCapacity( 52 + affix.Length + (args.Length * 2) );

            m_Stream.Write( (int) serial );
            m_Stream.Write( (short) graphic );
            m_Stream.Write( (byte) messageType );
            m_Stream.Write( (short) hue );
            m_Stream.Write( (short) font );
            m_Stream.Write( (int) number );
            m_Stream.Write( (byte) affixType );
            m_Stream.WriteAsciiFixed( name, 30 );
            m_Stream.WriteAsciiNull( affix );
            m_Stream.WriteBigUniNull( args );
        }
Exemple #16
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 );
            }
        }
Exemple #17
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();
            }
        }
			/* I cant find any better way to send "speech" using fonts other than default */
		public static void POHMessage( Mobile from, int index ) 
		{
			Packet p = new AsciiMessage( from.Serial, from.Body, MessageType.Regular, MsgParams[index][0], MsgParams[index][1], from.Name, Msgs[index] );
			p.Acquire();
			foreach( NetState state in from.Map.GetClientsInRange( from.Location ) )
				state.Send( p );

			Packet.Release( p );
		}
Exemple #19
0
		public virtual void WorldBroadcast(string message, params object[] args)
		{
			switch (Options.Broadcasts.World.Mode)
			{
				case PvPBattleWorldBroadcastMode.Notify:
					{
						string text = String.Format(message, args);

						foreach (PlayerMobile pm in GetWorldBroadcastList())
						{
							pm.SendNotification(text, true, 0.5, 10.0);
						}
					}
					break;

				case PvPBattleWorldBroadcastMode.Broadcast:
					{
						string text = String.Format(message, args);
						Packet p = new AsciiMessage(
							Server.Serial.MinusOne, -1, MessageType.Regular, Options.Broadcasts.World.MessageHue, 3, "System", text);

						p.Acquire();

						foreach (PlayerMobile pm in GetWorldBroadcastList())
						{
							pm.Send(p);
						}

						p.Release();
						NetState.FlushAll();
					}
					break;

				case PvPBattleWorldBroadcastMode.TownCrier:
					{
						foreach (TownCrier tc in TownCrier.Instances)
						{
							tc.PublicOverheadMessage(
								MessageType.Yell, Options.Broadcasts.World.MessageHue, true, String.Format(message, args));
						}
					}
					break;
			}
		}
Exemple #20
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();
            }
        }
        public static void PublicOverheadMobileMessage(Mobile mob, MessageType type, int hue, int font, string text, bool noLineOfSight)
        {
            if (mob != null && mob.Map != null)
            {
                Packet p = null;

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

                foreach (NetState state in eable)
                {
                    if (state.Mobile.CanSee(mob) && (noLineOfSight || state.Mobile.InLOS(mob)))
                    {
                        if (p == null)
                        {
                            p = new AsciiMessage(mob.Serial, mob.Body, type, hue, font, mob.Name, text);

                            p.Acquire();

                        }

                        state.Send(p);
                    }
                }

                Packet.Release(p);

                eable.Free();
            }
        }
Exemple #22
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();
			}
		}