Example #1
0
        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 );
        }
Example #2
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 );
        }
Example #3
0
        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 );
                    }
                }
            }
        }
Example #4
0
        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 );
        }