Example #1
0
        public bool Scissor( Mobile from, Scissors scissors )
        {
            if ( Deleted || !from.CanSee( this ) ) return false;

            Cloth c = new Cloth();
            c.Hue = this.Hue;
            base.ScissorHelper( from, c, 50 );

            return true;
        }
Example #2
0
        public bool Scissor(Mobile from, Scissors scissors)
        {
            if (Deleted || !from.CanSee(this))
            {
                return(false);
            }

            Cloth c = new Cloth();

            c.Hue = this.Hue;
            base.ScissorHelper(from, c, 50);

            return(true);
        }
        public void Combine(Mobile from, Item[] items)
        {
            Container backpack = from.Backpack;

            int[] hues    = new int[backpack.Items.Count];
            int[] amounts = new int[backpack.Items.Count];

            for (int i = 0; i < items.Length; i++)
            {
                Cloth c = items[i] as Cloth;

                if (c != null)
                {
                    int count;

                    if (CheckHue(c.Hue, hues, out count))
                    {
                        hues[i]    = c.Hue;
                        amounts[i] = c.Amount;
                    }
                    else
                    {
                        amounts[count] += c.Amount;
                    }

                    c.Delete();
                }
            }

            for (int i = 0; i < hues.Length; i++)
            {
                Cloth cloth = new Cloth();
                cloth.Hue    = hues[i];
                cloth.Amount = amounts[i];

                if (cloth.Amount > 0)
                {
                    backpack.DropItem(cloth);
                }
                else
                {
                    cloth.Delete();
                }
            }
        }
        public override bool Scissor(Mobile from, Scissors scissors)
        {
            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(502437); // Items you wish to cut must be in your backpack.
                return(false);
            }

            Cloth cloth = new Cloth();

            cloth.Amount = 1;
            cloth.Hue    = Hue;

            Delete();

            from.AddToBackpack(cloth);
            from.SendMessage("You cut the item into cloth.");

            return(false);
        }
Example #5
0
        public static bool CutCloth(Item item, Mobile from)
        {
            if (!item.IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(502437); // Items you wish to cut must be in your backpack.
                return(false);
            }

            Cloth cloth = new Cloth();

            cloth.Amount = 1;
            cloth.Hue    = item.Hue;

            item.Delete();

            from.AddToBackpack(cloth);
            from.SendMessage("You cut the item into cloth.");

            return(false);
        }
Example #6
0
        public void Combine( Mobile from, Item[] items )
        {
            Container backpack = from.Backpack;

            int[] hues = new int[backpack.Items.Count];
            int[] amounts = new int[backpack.Items.Count];

            for ( int i = 0; i < items.Length; i++ )
            {
                Cloth c = items[i] as Cloth;

                if ( c != null )
                {
                    int count;

                    if ( CheckHue( c.Hue, hues, out count ) )
                    {
                        hues[i] = c.Hue;
                        amounts[i] = c.Amount;
                    }
                    else
                    {
                        amounts[count] += c.Amount;
                    }

                    c.Delete();
                }
            }

            for ( int i = 0; i < hues.Length; i++ )
            {
                Cloth cloth = new Cloth();
                cloth.Hue = hues[i];
                cloth.Amount = amounts[i];

                if ( cloth.Amount > 0 )
                    backpack.DropItem( cloth );
                else
                    cloth.Delete();
            }
        }
Example #7
0
        protected override bool ConsumeResources( int count, Type toMake )
        {
            if ( m_Resource.Deleted || !m_Resource.IsChildOf( m_Mobile ) || !m_Mobile.Alive )
                return false;

            if ( m_Resource is BoltOfCloth )
            {
                if ( count > 50 )
                    return false;

                int left = 50 - count;
                if ( left > 0 )
                {
                    Item cloth = new Cloth( left );
                    cloth.Hue = m_Resource.Hue;
                    m_Mobile.AddToBackpack( cloth );
                }

                m_Resource.Consume();
                return true;
            }
            else if ( count <= m_Resource.Amount )
            {
                m_Resource.Consume( count );
                return true;
            }
            else
            {
                return false;
            }
        }
        public void UseRepairMaterials(BaseShip ship, Mobile from, DamageType damageType)
        {
            switch (damageType)
            {
            case DamageType.Hull:
            {
                int boardsUsed          = 0;
                int boardsNeeded        = 0;
                int repairAmount        = ship.MaxHitPoints - ship.HitPoints;
                int maximumRepairAmount = (int)((double)ship.MaxHitPoints * BaseShip.HullRepairPercent);

                if (repairAmount > maximumRepairAmount)
                {
                    repairAmount = maximumRepairAmount;
                }

                boardsNeeded = (int)((double)repairAmount * BaseShip.RepairMaterialFactor);

                if (boardsNeeded < 0)
                {
                    boardsNeeded = 1;
                }

                Item[] playerBoards = from.Backpack.FindItemsByType(typeof(BaseResourceBoard));
                Item[] holdBoards   = ship.Hold.FindItemsByType(typeof(BaseResourceBoard));

                foreach (Item item in playerBoards)
                {
                    if (boardsNeeded <= 0)
                    {
                        return;
                    }

                    BaseResourceBoard board = item as BaseResourceBoard;

                    if (board.Amount > boardsNeeded)
                    {
                        board.Amount -= boardsNeeded;
                        boardsNeeded  = 0;
                    }

                    else
                    {
                        boardsNeeded -= board.Amount;
                        board.Delete();
                    }
                }

                foreach (Item item in holdBoards)
                {
                    if (boardsNeeded <= 0)
                    {
                        return;
                    }

                    BaseResourceBoard board = item as BaseResourceBoard;

                    if (board.Amount > boardsNeeded)
                    {
                        board.Amount -= boardsNeeded;
                        boardsNeeded  = 0;
                    }

                    else
                    {
                        boardsNeeded -= board.Amount;
                        board.Delete();
                    }
                }

                break;
            }

            case DamageType.Sails:
            {
                int clothUsed           = 0;
                int clothNeeded         = 0;
                int repairAmount        = ship.MaxSailPoints - ship.SailPoints;
                int maximumRepairAmount = (int)((double)ship.MaxSailPoints * BaseShip.HullRepairPercent);

                if (repairAmount > maximumRepairAmount)
                {
                    repairAmount = maximumRepairAmount;
                }

                clothNeeded = (int)((double)repairAmount * BaseShip.RepairMaterialFactor);

                if (clothNeeded < 0)
                {
                    clothNeeded = 1;
                }

                Item[] playerCloth = from.Backpack.FindItemsByType(typeof(Cloth));
                Item[] holdCloth   = ship.Hold.FindItemsByType(typeof(Cloth));

                foreach (Item item in playerCloth)
                {
                    if (clothNeeded <= 0)
                    {
                        return;
                    }

                    Cloth cloth = item as Cloth;

                    if (cloth.Amount > clothNeeded)
                    {
                        cloth.Amount -= clothNeeded;
                        clothNeeded   = 0;
                    }

                    else
                    {
                        clothNeeded -= cloth.Amount;
                        cloth.Delete();
                    }
                }

                foreach (Item item in holdCloth)
                {
                    if (clothNeeded <= 0)
                    {
                        return;
                    }

                    Cloth cloth = item as Cloth;

                    if (cloth.Amount > clothNeeded)
                    {
                        cloth.Amount -= clothNeeded;
                        clothNeeded   = 0;
                    }

                    else
                    {
                        clothNeeded -= cloth.Amount;
                        cloth.Delete();
                    }
                }

                break;
            }


            case DamageType.Guns:
            {
                int ironIngotsUsed      = 0;
                int ironIngotsNeeded    = 0;
                int repairAmount        = ship.MaxGunPoints - ship.GunPoints;
                int maximumRepairAmount = (int)((double)ship.MaxGunPoints * BaseShip.HullRepairPercent);

                if (repairAmount > maximumRepairAmount)
                {
                    repairAmount = maximumRepairAmount;
                }

                ironIngotsNeeded = (int)((double)repairAmount * BaseShip.RepairMaterialFactor);

                if (ironIngotsNeeded < 0)
                {
                    ironIngotsNeeded = 1;
                }

                Item[] playerIronIngots = from.Backpack.FindItemsByType(typeof(IronIngot));
                Item[] holdIronIngots   = ship.Hold.FindItemsByType(typeof(IronIngot));

                foreach (Item item in playerIronIngots)
                {
                    if (ironIngotsNeeded <= 0)
                    {
                        return;
                    }

                    IronIngot ironIngot = item as IronIngot;

                    if (ironIngot.Amount > ironIngotsNeeded)
                    {
                        ironIngot.Amount -= ironIngotsNeeded;
                        ironIngotsNeeded  = 0;
                    }

                    else
                    {
                        ironIngotsNeeded -= ironIngot.Amount;
                        ironIngot.Delete();
                    }
                }

                foreach (Item item in holdIronIngots)
                {
                    if (ironIngotsNeeded <= 0)
                    {
                        return;
                    }

                    IronIngot ironIngot = item as IronIngot;

                    if (ironIngot.Amount > ironIngotsNeeded)
                    {
                        ironIngot.Amount -= ironIngotsNeeded;
                        ironIngotsNeeded  = 0;
                    }

                    else
                    {
                        ironIngotsNeeded -= ironIngot.Amount;
                        ironIngot.Delete();
                    }
                }

                break;
            }
            }
        }
        public bool CheckRepairMaterials(BaseShip ship, Mobile from, DamageType damageType)
        {
            if (ship == null)
            {
                return(false);
            }

            if (from == null)
            {
                return(false);
            }

            if (damageType == null)
            {
                return(false);
            }

            switch (damageType)
            {
            case DamageType.Hull:
            {
                int totalBoards  = 0;
                int boardsNeeded = (int)((double)ship.MaxHitPoints * BaseShip.HullRepairPercent * BaseShip.RepairMaterialFactor);

                Item[] playerBoards = from.Backpack.FindItemsByType(typeof(BaseResourceBoard));
                Item[] holdBoards   = ship.Hold.FindItemsByType(typeof(BaseResourceBoard));

                foreach (Item item in playerBoards)
                {
                    BaseResourceBoard board = item as BaseResourceBoard;
                    totalBoards += board.Amount;
                }

                foreach (Item item in holdBoards)
                {
                    BaseResourceBoard board = item as BaseResourceBoard;
                    totalBoards += board.Amount;
                }

                if (totalBoards > boardsNeeded)
                {
                    return(true);
                }

                break;
            }

            case DamageType.Sails:
            {
                int totalCloth  = 0;
                int clothNeeded = (int)((double)ship.MaxHitPoints * BaseShip.SailRepairPercent * BaseShip.RepairMaterialFactor);

                Item[] playerCloth = from.Backpack.FindItemsByType(typeof(Cloth));
                Item[] holdCloth   = ship.Hold.FindItemsByType(typeof(Cloth));

                foreach (Item item in playerCloth)
                {
                    Cloth cloth = item as Cloth;
                    totalCloth += cloth.Amount;
                }

                foreach (Item item in holdCloth)
                {
                    Cloth cloth = item as Cloth;
                    totalCloth += cloth.Amount;
                }

                if (totalCloth > clothNeeded)
                {
                    return(true);
                }

                break;
            }

            case DamageType.Guns:
            {
                int totalIronIngots  = 0;
                int ironIngotsNeeded = (int)((double)ship.MaxHitPoints * BaseShip.GunRepairPercent * BaseShip.RepairMaterialFactor);

                Item[] playerIronIngots = from.Backpack.FindItemsByType(typeof(IronIngot));
                Item[] holdIronIngots   = ship.Hold.FindItemsByType(typeof(IronIngot));

                foreach (Item item in playerIronIngots)
                {
                    IronIngot ironIngot = item as IronIngot;
                    totalIronIngots += ironIngot.Amount;
                }

                foreach (Item item in holdIronIngots)
                {
                    IronIngot ironIngot = item as IronIngot;
                    totalIronIngots += ironIngot.Amount;
                }

                if (totalIronIngots > ironIngotsNeeded)
                {
                    return(true);
                }

                break;
            }
            }

            return(false);
        }