コード例 #1
0
            protected override void OnTick()
            {
                count++;
                // Face toward the Rocks
                player.Direction = player.GetDirectionTo(rocks.Location);

                if (rocks == null || !rocks.OrePresent || pick == null || !player.InRange(rocks.Location, 1))
                {
                    player.SendMessage("You stop mining.");
                    Stop();
                }

                // Do Mining animation
                player.Animate(Utility.RandomBool() ? 11 : 12, 4, 2, true, true, 1);

                // Chance to find a Gem
                BaseRunescapeGem gem = Utilities.FindGem(player, rocks.OreType, pick);

                if (gem != null)
                {
                    //give player a gem
                    if (player.AddToBackpack(gem))
                    {
                        player.SendMessage("You have found an {0}!", gem.Name);
                    }

                    return;
                }

                // Keep doing it until successful
                successful = Utility.Random(100) - (40 - count) > Utilities.MiningLevelNeeded(rocks.OreType); // This will be replaced once Levels are implemented.

                // Better picks mine faster
                // Higher level rocks mine slower

                if (successful)
                {
                    rocks.GiveOreTo(player);
                    rocks.ResetOreSpawn();
                    player.Animate(4, 1, 1, true, false, 0);
                    player.InvalidateProperties();
                    Stop();
                }
            }
コード例 #2
0
        public static BaseRunescapeGem FindGem(Mobile from, Ores oreType, RunescapePickaxe pick)
        {
            BaseRunescapeGem gem      = null;
            double           chance   = 0.005; // Half of 1%
            Item             necklace = from.FindItemOnLayer(Layer.Neck);

            if (necklace != null && necklace is AmuletOfGlory)
            {
                chance = 0.015;                                                           // Increased to 1.5% chance if wearing Glory Ammy
            }
            chance = oreType >= Ores.Mithril ? chance + 0.005 : chance;                   // increased by another half percent if Mith rock and above
            chance = pick.WeaponType >= RuneWeaponType.Mithril ? chance + 0.005 : chance; // increased by another half percent if Mith pick and above

            if (chance > Utility.RandomDouble())
            {
                int select = Utility.Random(100);

                if (select > 97)
                {
                    gem = new DiamondGem();
                }
                else if (select > 90)
                {
                    gem = new RubyGem();
                }
                else if (select > 60)
                {
                    gem = new EmeraldGem();
                }
                else
                {
                    gem = new SapphhireGem();
                }
            }

            return(gem);
        }