Ejemplo n.º 1
0
        public void DoMining()
        {
            if (Map == null || Map == Map.Internal)
            {
                return;
            }

            // We may not mine while we are fighting
            if (Combatant != null)
            {
                return;
            }

            HarvestSystem     system = Mining.System;
            HarvestDefinition def    = Mining.System.OreAndStone;

            // Our target is the land tile under us
            Map     map = Map;
            Point3D loc = Location;
            int     x = 0, y = 0;

            GetMiningOffset(Direction, ref x, ref y);
            loc.X += x;
            loc.Y += y;
            int tileId = map.Tiles.GetLandTile(loc.X, loc.Y).ID & 0x3FFF;

            if (!def.Validate(tileId))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null || bank.Current < def.ConsumedPerHarvest)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = def.Resources[0];

            HarvestResource resource = system.MutateResource(this, null, def, map, loc, vein, primary, fallback);

            double skillBase = Skills[def.Skill].Base;

            Type type = null;

            if (skillBase >= resource.ReqSkill && CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
            {
                type = system.GetResourceType(this, null, def, map, loc, resource);

                if (type != null)
                {
                    type = system.MutateType(type, this, null, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = system.Construct(type, this, null);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        if (item.Stackable)
                        {
                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerFeluccaHarvest;

                            bool inFelucca = map == Map.Felucca;

                            if (inFelucca)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }
                        }

                        bank.Consume(item.Amount, this);

                        item.MoveToWorld(loc, map);

                        system.DoHarvestingEffect(this, def, loc);
                        system.DoHarvestingSound(this, def, null);

                        // Mine for gems
                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = system.Construct(bonus.Type, this, null);

                            bonusItem.MoveToWorld(loc, map);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Prospect(Mobile from, object toProspect)
        {
            if (!IsChildOf(from.Backpack) && Parent != from)
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
                return;
            }

            HarvestSystem system = Mining.System;

            int     tileID;
            Map     map;
            Point3D loc;

            if (!system.GetHarvestDetails(from, this, toProspect, out tileID, out map, out loc))
            {
                from.SendLocalizedMessage(1049048);                   // You cannot use your prospector tool on that.
                return;
            }

            HarvestDefinition def = system.GetDefinition(tileID);

            if (def == null || def.Veins.Length <= 1)
            {
                from.SendLocalizedMessage(1049048);                   // You cannot use your prospector tool on that.
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                from.SendLocalizedMessage(1049048);                   // You cannot use your prospector tool on that.
                return;
            }

            HarvestVein vein = bank.Vein, defaultVein = bank.DefaultVein;

            if (vein == null || defaultVein == null)
            {
                from.SendLocalizedMessage(1049048);                   // You cannot use your prospector tool on that.
                return;
            }
            else if (vein != defaultVein)
            {
                from.SendMessage("That ore has been prospected already.");                   // 1049049 - That ore looks to be prospected already.
                return;
            }

            int veinIndex = Array.IndexOf(def.Veins, vein);

            if (veinIndex < 0)
            {
                from.SendLocalizedMessage(1049048);                   // You cannot use your prospector tool on that.
            }
            else if (veinIndex >= (def.Veins.Length - 1))
            {
                from.SendLocalizedMessage(1049061);                   // You cannot improve valorite ore through prospecting.
            }
            else
            {
                bank.Vein = def.Veins[veinIndex + 1];
                from.SendLocalizedMessage(1049050 + veinIndex);

                --UsesRemaining;

                if (UsesRemaining <= 0)
                {
                    from.SendLocalizedMessage(1049062);                       // You have used up your prospector's tool.
                    Delete();
                }
            }
        }
Ejemplo n.º 3
0
        public bool DoDisposeOre(int x, int y, int z, Map map, Mobile from)
        {
            if (!IsMiningTile(x, y, map))
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            HarvestBank bank = Mining.System.OreAndStone.GetBank(map, x, y);

            if (bank == null)
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            if (bank.Current <= 0)
            {
                this.Say("No Ore remains !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            HarvestVein vein = bank.DefaultVein;

            if (vein == null)
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            HarvestDefinition def = Mining.System.OreAndStone;
            HarvestResource   res = vein.PrimaryResource;
            BaseOre           ore = Mining.System.Construct(res.Types[0], null) as BaseOre;

            if (ore == null)
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            if (ore.Resource > CraftResource.Iron)
            {
                double minskill  = 0.0;
                double minskill2 = 0.0;
                double maxskill  = 0.0;
                double skillbase = this.Skills.Mining.Base;

                switch (ore.Resource)
                {
                case CraftResource.Iron: { minskill = 00.0; minskill2 = 00.0; maxskill = 100.0; } break;

                case CraftResource.DullCopper: { minskill = 60.0; minskill2 = 25.0; maxskill = 105.0; } break;

                case CraftResource.ShadowIron: { minskill = 65.0; minskill2 = 30.0; maxskill = 110.0; } break;

                case CraftResource.Copper: { minskill = 70.0; minskill2 = 35.0; maxskill = 115.0; } break;

                case CraftResource.Gold: { minskill = 75.0; minskill2 = 40.0; maxskill = 120.0; } break;

                case CraftResource.Agapite: { minskill = 80.0; minskill2 = 45.0; maxskill = 120.0; } break;

                case CraftResource.Verite: { minskill = 85.0; minskill2 = 50.0; maxskill = 120.0; } break;

                case CraftResource.Valorite: { minskill = 90.0; minskill2 = 55.0; maxskill = 120.0; } break;
                }

                if (Utility.RandomDouble() <= 0.30 || skillbase < minskill)
                {
                    ore = new IronOre(); minskill = 00.0; minskill2 = 00.0; maxskill = 100.0;
                }
                if (!(from.CheckSkill(SkillName.Mining, minskill2, maxskill)))
                {
                    ore.Delete();
                    return(false);
                }
            }

            ore.Amount = (map == Map.Felucca ? 2 : 1);
            if (from != null)
            {
                from.AddToBackpack(ore);
            }
            else
            {
                ore.Delete();
            }
            bank.Consume(ore.Amount, this);
            this.Hue = ore.Hue;
            return(true);
        }
Ejemplo n.º 4
0
        public void Prospect(Mobile from, object toProspect)
        {
            if (!IsChildOf(from.Backpack) && Parent != from)
            {
                from.SendAsciiMessage("That must be in your pack for you to use it.");
                return;
            }

            HarvestSystem system = Mining.System;

            int     tileID;
            Map     map;
            Point3D loc;

            if (!system.GetHarvestDetails(from, this, toProspect, out tileID, out map, out loc))
            {
                from.SendAsciiMessage("You cannot use your prospector tool on that.");                   //
                return;
            }

            HarvestDefinition def = system.GetDefinition(tileID);

            if (def == null || def.Veins.Length <= 1)
            {
                from.SendAsciiMessage("You cannot use your prospector tool on that.");                   //
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                from.SendAsciiMessage("You cannot use your prospector tool on that.");                   //
                return;
            }

            HarvestVein vein = bank.Vein, defaultVein = bank.DefaultVein;

            if (vein == null || defaultVein == null)
            {
                from.SendAsciiMessage("You cannot use your prospector tool on that.");                   //
                return;
            }
            else if (vein != defaultVein)
            {
                from.SendAsciiMessage("That ore looks to be prospected already.");                   //
                return;
            }

            int veinIndex = Array.IndexOf(def.Veins, vein);

            if (veinIndex < 0)
            {
                from.SendAsciiMessage("You cannot use your prospector tool on that.");                   //
            }
            else if (veinIndex >= (def.Veins.Length - 1))
            {
                from.SendAsciiMessage("You cannot improve valorite ore through prospecting.");                   //
            }
            else
            {
                bank.Vein = def.Veins[veinIndex + 1];
                if (veinIndex == 0)
                {
                    from.SendAsciiMessage("You sift through the ore and find dull copper can be mined there.");
                }
                else if (veinIndex == 1)
                {
                    from.SendAsciiMessage("You sift through the ore and find shadow iron can be mined there.");
                }
                else if (veinIndex == 2)
                {
                    from.SendAsciiMessage("You sift through the ore and find copper ore can be mined there.");
                }
                else if (veinIndex == 3)
                {
                    from.SendAsciiMessage("You sift through the ore and find bronze can be mined there.");
                }
                else if (veinIndex == 4)
                {
                    from.SendAsciiMessage("You sift through the ore and find gold ore can be mined there.");
                }
                else if (veinIndex == 5)
                {
                    from.SendAsciiMessage("You sift through the ore and find agapite can be mined there.");
                }
                else if (veinIndex == 6)
                {
                    from.SendAsciiMessage("You sift through the ore and find verite can be mined there.");
                }
                else if (veinIndex == 7)
                {
                    from.SendAsciiMessage("You sift through the ore and find valorite can be mined there.");
                }
                else
                {
                    from.SendAsciiMessage("bug");
                }

                --UsesRemaining;

                if (UsesRemaining <= 0)
                {
                    from.SendAsciiMessage("You have used up your prospector's tool.");                       //
                    Delete();
                }
            }
        }