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

Construct() public static méthode

public static Construct ( Type type ) : Item
type System.Type
Résultat Item
		public static Item Construct( Type type )
		{
			try
			{
				return Activator.CreateInstance( type ) as Item;
			}
			catch
			{
				return null;
			}
		}

Same methods

Loot::Construct ( ) : 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