public void Generate(IEntity from, BaseContainer cont, LootStage stage, int luckChance, bool hasBeenStolenFrom) { if (cont == null) { return; } bool checkLuck = true; for (int i = 0; i < m_Entries.Length; ++i) { LootPackEntry entry = m_Entries[i]; if (!entry.CanGenerate(stage, hasBeenStolenFrom)) { continue; } bool shouldAdd = entry.Chance > Utility.Random(10000); if (!shouldAdd && checkLuck) { checkLuck = false; if (CheckLuck(luckChance)) { shouldAdd = entry.Chance > Utility.Random(10000); } } if (!shouldAdd) { continue; } Item item = entry.Construct(from, luckChance, stage, hasBeenStolenFrom); if (item != null) { if (from is BaseCreature && item.LootType == LootType.Blessed) { Timer.DelayCall(TimeSpan.FromMilliseconds(25), () => { var corpse = ((BaseCreature)from).Corpse; if (corpse != null) { if (!corpse.TryDropItem((BaseCreature)from, item, false)) { corpse.DropItem(item); } } else { item.Delete(); } }); } else if (item.Stackable) { cont.DropItemStacked(item); } else { cont.DropItem(item); } } } }