예제 #1
0
        public void FillWith(Mobile from, IronIngot ironingot)
        {
            int need = RequiredIngots - CurrentIngots;

            int toAdd = Math.Min(need, ironingot.Amount);

            CurrentIngots += toAdd;

            ironingot.Amount -= need;

            if (ironingot.Amount <= 0)
            {
                ironingot.Delete();
            }

            if (CurrentIngots < RequiredIngots || CurrentBoards < RequiredBoards)
            {
                from.SendMessage("You have added {0} ingots to the plan.", toAdd);
            }
            else
            {
                from.SendMessage("The filled plans have been added to your backpack.");
                from.AddToBackpack(FilledPlans);
                Delete();
            }
        }
예제 #2
0
        public override void OnComponentUsed(AddonComponent c, Mobile from)
        {
            BaseHouse house = BaseHouse.FindHouseAt(this);

            /*
             * Unique problems have unique solutions.  OSI does not have a problem with 1000s of mining carts
             * due to the fact that they have only a miniscule fraction of the number of 10 year vets that a
             * typical RunUO shard will have (RunUO's scaled down account aging system makes this a unique problem),
             * and the "freeness" of free accounts. We also dont have mitigating factors like inactive (unpaid)
             * accounts not gaining veteran time.
             *
             * The lack of high end vets and vet rewards on OSI has made testing the *exact* ranging/stacking
             * behavior of these things all but impossible, so either way its just an estimation.
             *
             * If youd like your shard's carts/stumps to work the way they did before, simply replace the check
             * below with this line of code:
             *
             * if (!from.InRange(GetWorldLocation(), 2)
             *
             * However, I am sure these checks are more accurate to OSI than the former version was.
             *
             */

            if (!from.InRange(GetWorldLocation(), 2) || !from.InLOS(this) || !((from.Z - Z) > -3 && (from.Z - Z) < 3))
            {
                from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045);                 // I can't reach that.
            }
            else if (house != null && house.HasSecureAccess(from, SecureLevel.Friends))
            {
                switch (m_CartType)
                {
                case MiningCartType.OreSouth:
                case MiningCartType.OreEast:
                    if (m_Ore > 0)
                    {
                        Item ingots = null;

                        switch (Utility.Random(0))
                        {
                        case 0: ingots = new IronIngot(); break;
                            //case 1: ingots = new DullCopperIngot(); break;
                            //case 2: ingots = new ShadowIronIngot(); break;
                            //case 3: ingots = new CopperIngot(); break;
                            //case 4: ingots = new BronzeIngot(); break;
                            //case 5: ingots = new GoldIngot(); break;
                            //case 6: ingots = new AgapiteIngot(); break;
                            //case 7: ingots = new VeriteIngot(); break;
                            //case 8: ingots = new ValoriteIngot(); break;
                        }

                        int amount = Math.Min(10, m_Ore);
                        ingots.Amount = amount;

                        if (!from.PlaceInBackpack(ingots))
                        {
                            ingots.Delete();
                            from.SendLocalizedMessage(1078837);                                       // Your backpack is full! Please make room and try again.
                        }
                        else
                        {
                            PublicOverheadMessage(MessageType.Regular, 0, 1094724, amount.ToString());                                      // Ore: ~1_COUNT~
                            m_Ore -= amount;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1094725);                                   // There are no more resources available at this time.
                    }
                    break;

                case MiningCartType.GemSouth:
                case MiningCartType.GemEast:
                    if (m_Gems > 0)
                    {
                        Item gems = null;

                        switch (Utility.Random(9))
                        {
                        case 0: gems = new Amber(); break;

                        case 1: gems = new Amethyst(); break;

                        case 2: gems = new Citrine(); break;

                        case 3: gems = new Diamond(); break;

                        case 4: gems = new Emerald(); break;

                        case 5: gems = new Ruby(); break;

                        case 6: gems = new Sapphire(); break;

                        case 7: gems = new StarSapphire(); break;

                        case 8: gems = new Tourmaline(); break;

                            // Mondain's Legacy gems
                            //case 9: gems = new PerfectEmerald(); break;
                            //case 10: gems = new DarkSapphire(); break;
                            //case 11: gems = new Turquoise(); break;
                            //case 12: gems = new EcruCitrine(); break;
                            //case 13: gems = new FireRuby(); break;
                            //case 14: gems = new BlueDiamond(); break;
                        }

                        int amount = Math.Min(5, m_Gems);
                        gems.Amount = amount;

                        if (!from.PlaceInBackpack(gems))
                        {
                            gems.Delete();
                            from.SendLocalizedMessage(1078837);                                       // Your backpack is full! Please make room and try again.
                        }
                        else
                        {
                            PublicOverheadMessage(MessageType.Regular, 0, 1094723, amount.ToString());                                       // Gems: ~1_COUNT~
                            m_Gems -= amount;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1094725);                                   // There are no more resources available at this time.
                    }
                    break;
                }
            }
            else
            {
                from.SendLocalizedMessage(1061637);                   // You are not allowed to access this.
            }
        }
        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;
            }
            }
        }