Server.Loot.Construct C# (CSharp) Méthode

Construct() public static méthode

public static Construct ( ) : Item
Résultat Item
		public static Item Construct( params Type[][] types )
		{
			int totalLength = 0;

			for ( int i = 0; i < types.Length; ++i )
				totalLength += types[i].Length;

			if ( totalLength > 0 )
			{
				int index = Utility.Random( totalLength );

				for ( int i = 0; i < types.Length; ++i )
				{
					if ( index >= 0 && index < types[i].Length )
						return Construct( types[i][index] );

					index -= types[i].Length;
				}
			}

			return null;
		}
		#endregion

Same methods

Loot::Construct ( Type type ) : Item
Loot::Construct ( Type types, int index ) : Item

Usage Example

Exemple #1
0
        public static void CheckRecipeDrop(CreatureDeathEventArgs e)
        {
            BaseCreature bc     = e.Creature as BaseCreature;
            Container    c      = e.Corpse;
            Mobile       killer = e.Killer;

            if (SpellHelper.IsEodon(c.Map, c.Location))
            {
                double chance = (double)bc.Fame / 1000000;
                int    luck   = 0;

                if (killer != null)
                {
                    luck = Math.Min(1800, killer is PlayerMobile ? ((PlayerMobile)killer).RealLuck : killer.Luck);
                }

                if (luck > 0)
                {
                    chance += (double)luck / 152000;
                }

                if (chance > Utility.RandomDouble())
                {
                    if (0.33 > Utility.RandomDouble())
                    {
                        Item item = Loot.Construct(_ArmorDropTypes[Utility.Random(_ArmorDropTypes.Length)]);

                        if (item != null)
                        {
                            c.DropItem(item);
                        }
                    }
                    else
                    {
                        Item scroll = new RecipeScroll(_RecipeTypes[Utility.Random(_RecipeTypes.Length)]);

                        if (scroll != null)
                        {
                            c.DropItem(scroll);
                        }
                    }
                }
            }
        }
All Usage Examples Of Server.Loot::Construct