If I wanted to make monsters drop randomly one of 50 items, would there be an easier way than doing


{
base.OnDeath( c );

if ( Utility.RandomDouble() < 0.95 )
c.DropItem( new EmberStaff() );

if ( Utility.RandomDouble() < 0.55 )
c.DropItem( new DeathsHead() );

}


etc..
?
 
You can do something like this.

First add
C#:
        private static readonly Type[] rewards = new Type[]
        {
            typeof(EmberStaff), typeof(DeathsHead), typeof(StaffOfTheMagi)
        };

inside your code.

Then where you want to drop the item, you can simply do.
C#:
            c.DropItem(Activator.CreateInstance(rewards[Utility.Random(rewards.Length)]) as Item);
This way you will get 1 random Item of the types you defined in the rewards array
 
Exactly what I was looking for, thanks alot (again lol)
I was trying to do something similar in the loot codes but couldnt find exactly how :)
 
Back