Server.Items.TreasureMapChest.Fill C# (CSharp) Method

Fill() public static method

public static Fill ( Server.Items.LockableContainer cont, int level ) : void
cont Server.Items.LockableContainer
level int
return void
        public static void Fill( LockableContainer cont, int level )
		{
			cont.Movable = false;
			cont.Locked = true;
			int numberItems;
			
			if ( level == 0 )
			{
				cont.LockLevel = 0; // Can't be unlocked

				cont.DropItem( new Gold( Utility.RandomMinMax( 50, 100 ) ) );

				if ( Utility.RandomDouble() < 0.75 )
					cont.DropItem( new TreasureMap( 0, Map.Felucca ) );
			}
			else
			{
				cont.TrapType = TrapType.ExplosionTrap;
				cont.TrapPower = level * 25;
				cont.TrapLevel = level;

				switch ( level )
				{
					case 1: cont.RequiredSkill = 36; break;
					case 2: cont.RequiredSkill = 76; break;
					case 3: cont.RequiredSkill = 84; break;
					case 4: cont.RequiredSkill = 92; break;
					case 5: cont.RequiredSkill = 100; break;
					case 6: cont.RequiredSkill = 100; break;
				}

				cont.LockLevel = cont.RequiredSkill - 10;
				cont.MaxLockLevel = cont.RequiredSkill + 40;
				
				//Publish 67 gold change
				//if ( Core.SA )
				//	cont.DropItem( new Gold( level * 5000 ) );
				//else					
					cont.DropItem( new Gold( level * 1000 ) );

				for ( int i = 0; i < level * 5; ++i )
					cont.DropItem( Loot.RandomScroll( 0, 63, SpellbookType.Regular ) );

				numberItems = level * 6;
				
				for ( int i = 0; i < numberItems; ++i )
				{
					Item item = Loot.RandomArmorOrShieldOrWeapon();

					if ( item is BaseWeapon )
					{
						BaseWeapon weapon = (BaseWeapon)item;

						weapon.DamageLevel = (WeaponDamageLevel)Utility.Random( 6 );
						weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random( 6 );
						weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );

						cont.DropItem( item );
					}
					else if ( item is BaseArmor )
					{
						BaseArmor armor = (BaseArmor)item;

                        armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
						armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );

						cont.DropItem( item );
					}
					else if( item is BaseHat )
					{
						BaseHat hat = (BaseHat)item;

						cont.DropItem( item );
					}
					else if( item is BaseJewel )
					{
						int attributeCount;
						int min, max;

						GetRandomAOSStats( out attributeCount, out min, out max );

						BaseRunicTool.ApplyAttributesTo( attributeCount );

						cont.DropItem( item );
					}
				}
			}

			int reagents;
			if ( level == 0 )
				reagents = 12;
			else
				reagents = level * 3;

			for ( int i = 0; i < reagents; i++ )
			{
				Item item = Loot.RandomPossibleReagent();
				item.Amount = Utility.RandomMinMax( 40, 60 );
				cont.DropItem( item );
			}

			int gems;
			if ( level == 0 )
				gems = 2;
			else
				gems = level * 3;

			for ( int i = 0; i < gems; i++ )
			{
				Item item = Loot.RandomGem();
				cont.DropItem( item );
			}
		}

Usage Example

Ejemplo n.º 1
0
        protected virtual void FinishEffect(Point3D p, Map map, Mobile from)
        {
            from.RevealingAction();

            int spawncount = GetSpawnCount();
            int z          = p.Z;
            //Ghost ship Z, should be 10 lower than the spawn Z
            int gsZ = z - 30; //Set to -30 so it spawns under the sea and then emerges up
            //Spawn Z, needs to be 10 higher than ghost ship Z so they get on top of the boat
            int spawnZ = z - 20;

            //Create the ghost ship here
            GhostShip gs = new GhostShip();

            //Add treasure
            MetalChest tc = new MetalChest {
                ItemID = 0xE7C, LiftOverride = true
            };

            TreasureMapChest.Fill(tc, 5);

            //Now declare an area the same size as the ship, to look for items that might block
            Point2D     start = new Point2D(p.X - 10, p.Y - 7); //Starting location of the area
            Point2D     end   = new Point2D(p.X + 10, p.Y + 7); //Ending location of the area
            Rectangle2D rect  = new Rectangle2D(start, end);    //Declaring the entire area as a rectangle

            //Create a new list that will contain all items in the rectangle
            List <Item> list = new List <Item>();

            IPooledEnumerable eable = map.GetItemsInBounds(rect); //Get all items in the rectangle

            foreach (Item item in eable)                          //Add all items in the rectangle to the list
            {
                list.Add(item);
            }

            eable.Free();

            //While an item exists in the rectangle, move the spawnlocation of the boat/monsters
            while (list.Count > 0)
            {
                if (Utility.RandomDouble() < 0.5)
                {
                    p.X += 1;
                }
                else
                {
                    p.X -= 1;
                }

                if (Utility.RandomDouble() < 0.5)
                {
                    p.Y += 1;
                }
                else
                {
                    p.Y -= 1;
                }

                start = new Point2D(p.X - 10, p.Y - 7);
                end   = new Point2D(p.X + 10, p.Y + 7);
                rect  = new Rectangle2D(start, end);

                eable = map.GetItemsInBounds(rect);

                //Clear the list as we need to create a new one with the new location of the ship
                list.Clear();

                foreach (Item item in eable)
                {
                    list.Add(item); //Add the items (if any) in the new spawnlocation to the list
                }
                eable.Free();
            }

            //No items blocking, move the ship to the world
            p.Z = gsZ;
            gs.MoveToWorld(p, map);

            //Move the treasure chest to the world
            p.Z  = spawnZ + 2;
            p.X -= 9;
            tc.MoveToWorld(p, map);

            //Add the boat and all items inside the boat here
            gs.Itemlist.Add(gs);
            gs.Itemlist.Add(tc);

            //Add as many spawns as spawncount allows
            for (int i = 0; i < spawncount; ++i)
            {
                BaseCreature spawn;

                switch (Utility.Random(4))
                {
                default:
                    spawn = new LichLord();
                    break;

                case 1:
                    spawn = new AncientLich();
                    break;

                case 2:
                    spawn = new Lich();
                    break;

                case 3:
                    spawn = new SkeletalCaptain();
                    break;
                }

                p.Z = spawnZ;
                Spawn(p, map, spawn);

                spawn.Combatant = from;

                //Add the spawn to the list "spawns", needed for the boat decay timer and emerge timer
                gs.Spawnlist.Add(spawn);
            }

            //Start the emerge timer, so the boat doesn't just appear instantly on top of the water
            new EmergeTimer(gs.Itemlist, gs.Spawnlist).Start();

            Delete();
        }