Example #1
0
        public static int GetArmorRating( Mobile m )
        {
            int ar = 0;

            foreach ( var armor in m.GetEquippedItems().OfType<BaseArmor>() )
            {
                if ( armor.ArmorAttributes.MageArmor == 0 )
                    ar += m_ArmorTable[(int) armor.MaterialType, (int) armor.BodyPosition];
            }

            return ar;
        }
Example #2
0
 public override void OnDoubleClick( Mobile from )
 {
     if ( from.GetEquippedItems().Contains( this ) )
     {
         InternalTarget t = new InternalTarget( this );
         from.Target = t;
     }
     else
     {
         from.SendMessage( "You must be holding that weapon to use it." );
     }
 }
Example #3
0
        public static bool ConsumeCharges( Mobile from, int amount )
        {
            var arcaneEquipment = from.GetEquippedItems().OfType<IArcaneEquip>().Where( eq => eq.IsArcane );

            if ( arcaneEquipment.Sum( eq => eq.CurArcaneCharges ) < amount )
                return false;

            foreach ( var eq in arcaneEquipment )
            {
                if ( eq.CurArcaneCharges > amount )
                {
                    eq.CurArcaneCharges -= amount;
                    break;
                }
                else
                {
                    amount -= eq.CurArcaneCharges;
                    eq.CurArcaneCharges = 0;
                }
            }

            return true;
        }
Example #4
0
        public static bool IsUnburdened( Mobile m )
        {
            int count = m.GetEquippedItems().Count() - 1;

            if ( m.Backpack != null )
                count -= 1;

            return count > 0;
        }
Example #5
0
            protected override void OnTarget( Mobile from, object targeted )
            {
                if ( m_Dagger.Deleted )
                {
                    return;
                }
                else if ( !from.GetEquippedItems().Contains( m_Dagger ) )
                {
                    from.SendMessage( "You must be holding that weapon to use it." );
                }
                else if ( targeted is Mobile )
                {
                    Mobile m = (Mobile) targeted;

                    if ( m != from && from.HarmfulCheck( m ) )
                    {
                        Direction to = from.GetDirectionTo( m );

                        from.Direction = to;

                        from.Animate( from.Mounted ? 26 : 9, 7, 1, true, false, 0 );

                        if ( Utility.RandomDouble() >= ( Math.Sqrt( m.Dex / 100.0 ) * 0.8 ) )
                        {
                            from.MovingEffect( m, 0x1BFE, 7, 1, false, false, 0x481, 0 );

                            AOS.Damage( m, from, Utility.Random( 5, from.Str / 10 ), 100, 0, 0, 0, 0 );

                            m_Dagger.MoveToWorld( m.Location, m.Map );
                        }
                        else
                        {
                            int x = 0, y = 0;

                            switch ( to & Direction.Mask )
                            {
                                case Direction.North:
                                    --y;
                                    break;
                                case Direction.South:
                                    ++y;
                                    break;
                                case Direction.West:
                                    --x;
                                    break;
                                case Direction.East:
                                    ++x;
                                    break;
                                case Direction.Up:
                                    --x;
                                    --y;
                                    break;
                                case Direction.Down:
                                    ++x;
                                    ++y;
                                    break;
                                case Direction.Left:
                                    --x;
                                    ++y;
                                    break;
                                case Direction.Right:
                                    ++x;
                                    --y;
                                    break;
                            }

                            x += Utility.Random( -1, 3 );
                            y += Utility.Random( -1, 3 );

                            x += m.X;
                            y += m.Y;

                            m_Dagger.MoveToWorld( new Point3D( x, y, m.Z ), m.Map );

                            from.MovingEffect( m_Dagger, 0x1BFE, 7, 1, false, false, 0x481, 0 );

                            from.SendMessage( "You miss." );
                        }
                    }
                }
            }
Example #6
0
        public void CloneClothes( Mobile from )
        {
            this.GetEquippedItems().Each( item => item.Delete() );

            foreach ( var item in from.GetEquippedItems().Where( item => !m_InvalidLayers.Contains( item.Layer ) ) )
            {
                AddItem( CloneItem( item ) );
            }
        }
Example #7
0
        public static void ValidateMobile( Mobile m )
        {
            if ( m.AccessLevel >= AccessLevel.GameMaster )
                return;

            foreach ( var clothing in m.GetEquippedItems().OfType<BaseClothing>() )
            {
                if ( !clothing.AllowMaleWearer && m.Body.IsMale )
                {
                    if ( clothing.AllowFemaleWearer )
                        m.SendLocalizedMessage( 1010388 ); // Only females can wear this.
                    else
                        m.SendMessage( "You may not wear this." );

                    m.AddToBackpack( clothing );
                }
                else if ( !clothing.AllowFemaleWearer && m.Body.IsFemale )
                {
                    if ( clothing.AllowMaleWearer )
                        m.SendMessage( "Only males can wear this." );
                    else
                        m.SendMessage( "You may not wear this." );

                    m.AddToBackpack( clothing );
                }
            }
        }
Example #8
0
        public MobileIncoming( Mobile beholder, Mobile beheld )
            : base(0x78)
        {
            bool isPrior7033 = ( beholder.Client != null && beholder.Client.Version < ClientVersion.Client70330 );

            m_Beheld = beheld;
            ++m_Version;

            var eq = beheld.GetEquippedItems();
            int count = eq.Count();

            if ( beheld.HairItemID > 0 )
                count++;
            if ( beheld.FacialHairItemID > 0 )
                count++;

            this.EnsureCapacity( 23 + ( count * 9 ) );

            int hue = beheld.Hue;

            if ( beheld.SolidHueOverride >= 0 )
                hue = beheld.SolidHueOverride;

            m_Stream.Write( (int) beheld.Serial );
            m_Stream.Write( (short) ( (int) beheld.Body ) );
            m_Stream.Write( (short) beheld.X );
            m_Stream.Write( (short) beheld.Y );
            m_Stream.Write( (sbyte) beheld.Z );
            m_Stream.Write( (byte) beheld.Direction );
            m_Stream.Write( (short) hue );
            m_Stream.Write( (byte) beheld.GetPacketFlags() );
            m_Stream.Write( (byte) Notoriety.Compute( beholder, beheld ) );

            foreach ( var item in eq )
            {
                byte layer = (byte) item.Layer;

                if ( !item.Deleted && beholder.CanSee( item ) && m_DupedLayers[layer] != m_Version )
                {
                    m_DupedLayers[layer] = m_Version;

                    hue = item.Hue;

                    if ( beheld.SolidHueOverride >= 0 )
                        hue = beheld.SolidHueOverride;

                    int itemID = item.ItemID;

                    if ( isPrior7033 )
                        itemID = itemID | 0x8000;

                    m_Stream.Write( (int) item.Serial );
                    m_Stream.Write( (short) itemID );
                    m_Stream.Write( (byte) layer );
                    m_Stream.Write( (short) hue );
                }
            }

            if ( beheld.HairItemID > 0 )
            {
                if ( m_DupedLayers[(int) Layer.Hair] != m_Version )
                {
                    m_DupedLayers[(int) Layer.Hair] = m_Version;
                    hue = beheld.HairHue;

                    if ( beheld.SolidHueOverride >= 0 )
                        hue = beheld.SolidHueOverride;

                    int itemID = beheld.HairItemID;

                    if ( isPrior7033 )
                        itemID = itemID | 0x8000;

                    m_Stream.Write( (int) HairInfo.FakeSerial( beheld ) );
                    m_Stream.Write( (short) itemID );
                    m_Stream.Write( (byte) Layer.Hair );
                    m_Stream.Write( (short) hue );
                }
            }

            if ( beheld.FacialHairItemID > 0 )
            {
                if ( m_DupedLayers[(int) Layer.FacialHair] != m_Version )
                {
                    m_DupedLayers[(int) Layer.FacialHair] = m_Version;
                    hue = beheld.FacialHairHue;

                    if ( beheld.SolidHueOverride >= 0 )
                        hue = beheld.SolidHueOverride;

                    int itemID = beheld.FacialHairItemID;

                    if ( isPrior7033 )
                        itemID = itemID | 0x8000;

                    m_Stream.Write( (int) FacialHairInfo.FakeSerial( beheld ) );
                    m_Stream.Write( (short) itemID );
                    m_Stream.Write( (byte) Layer.FacialHair );
                    m_Stream.Write( (short) hue );
                }
            }

            m_Stream.Write( (int) 0 ); // terminate
        }
Example #9
0
            protected override void OnTarget( Mobile from, object targeted )
            {
                if ( from is PlayerMobile && targeted is Mobile )
                {
                    PlayerMobile pm = (PlayerMobile) from;
                    Mobile targ = (Mobile) targeted;

                    if ( targ.AccessLevel <= from.AccessLevel )
                    {
                        ArrayList list = pm.VisibilityList;

                        if ( list.Contains( targ ) )
                        {
                            list.Remove( targ );
                            from.SendMessage( "{0} has been removed from your visibility list.", targ.Name );
                        }
                        else
                        {
                            list.Add( targeted );
                            from.SendMessage( "{0} has been added to your visibility list.", targ.Name );
                        }

                        if ( targ.InUpdateRange( from ) )
                        {
                            if ( targ.CanSee( from ) )
                            {
                                targ.Send( new Network.MobileIncoming( targ, from ) );

                                if ( ObjectPropertyListPacket.Enabled )
                                {
                                    targ.Send( from.OPLPacket );

                                    foreach ( var item in from.GetEquippedItems() )
                                    {
                                        targ.Send( item.OPLPacket );
                                    }
                                }
                            }
                            else
                            {
                                targ.Send( from.RemovePacket );
                            }
                        }
                    }
                    else
                    {
                        from.SendMessage( "They can already see you!" );
                    }
                }
                else
                {
                    from.SendMessage( "Add only mobiles to your visibility list." );
                }
            }