public override void AddContents(BaseContainer cont, Mobile creature, out int contentValue) { base.AddContents(cont, creature, out contentValue); if (m_RuneChance > Utility.RandomDouble()) { cont.DropItem(new RecallRune()); } int scrollcount = Utility.RandomMinMax(MinAmount / 25, MaxAmount / 8); for (int i = 0; i < scrollcount; i++) { if ((m_RuneChance / 3.0) > Utility.RandomDouble()) { Item item = null; switch (Utility.Random(5)) { default: case 0: case 1: case 2: item = new RecallScroll(); break; case 3: item = new MarkScroll(); break; case 4: item = new GateTravelScroll(); break; } cont.DropItem(item); } } }
public override void AddContents(BaseContainer cont, Mobile creature, out int contentValue) { base.AddContents(cont, creature, out contentValue); if (m_BookChance > Utility.RandomDouble()) { BaseSpellbookLootSet spellbookloot = MagicSpellbookLootSets.LootSet(m_SpellbookGrade); if (spellbookloot != null) //sanity check { Tuple <Item[], int> spelltuple = spellbookloot.GenerateLootItem(creature); if (spelltuple.Item1 != null) // another sanity check { for (int i = 0; i < spelltuple.Item1.Length; i++) { if (spelltuple.Item1[i] != null) // more sanity checks { cont.DropItem(spelltuple.Item1[i]); } } } contentValue += spelltuple.Item2; } } }
public override void AddContents(BaseContainer cont, Mobile creature, out int contentValue) { base.AddContents(cont, creature, out contentValue); if (m_HealChance > Utility.RandomDouble()) { cont.DropItem(new Bandage(Utility.RandomMinMax(MinAmount / 2, MaxAmount))); } int potioncount = Utility.RandomMinMax(MinAmount / 25, MaxAmount / 10); for (int i = 0; i < potioncount; i++) { if ((m_HealChance / 2.0) > Utility.RandomDouble()) { cont.DropItem(Utility.RandomBool() ? (Item) new LesserHealPotion() : (Item) new HealPotion()); } } int scrollcount = Utility.RandomMinMax(MinAmount / 12, MaxAmount / 5); for (int i = 0; i < scrollcount; i++) { if ((m_HealChance / 3.0) > Utility.RandomDouble()) { Item item = null; switch (Utility.Random(4)) { default: case 0: item = new HealScroll(); break; case 1: item = new GreaterHealScroll(); break; case 2: item = new CureScroll(); break; case 3: item = new ArchCureScroll(); break; } cont.DropItem(item); } } }
public override void AddContents(BaseContainer cont, Mobile creature, out int contentValue) { contentValue = 0; int count = Utility.RandomMinMax(m_MinCount, m_MaxCount); for (int i = 0; i < count; i++) { Type type = null; if (m_Random) { type = m_CommodityTypes[Utility.Random(m_CommodityTypes.Length)]; } else { type = m_CommodityTypes[i % m_CommodityTypes.Length]; } Item com = Activator.CreateInstance(m_CommodityTypes[i]) as Item; if (com == null) { throw new NullReferenceException(String.Format("Type {0} is not an Item or could not be instantiated.", type.ToString())); } else { if (com.Stackable) { com.Amount = Utility.RandomMinMax(m_MinAmount, m_MaxAmount); } cont.DropItem(com); } } }
private static void MakeCopy(Item toCopy, ref List <Item> itemList, BaseContainer parentCont) { Item newItem = null; try { newItem = (Item)Activator.CreateInstance(toCopy.GetType()); } catch { Console.WriteLine("SupplySystem error, cannot create {0}, no parameterless constructor defined?", toCopy.GetType()); } if (newItem == null) { return; } //Copy all the "item" related properties CopyBaseProperties(toCopy, newItem); if (newItem is Container) { Container newContainer = ((Container)newItem); // If a container gets duplicated it needs to get emptied. // ("BagOfReagents" problem, items which create content in the constructors have unwanted // contents after duping under certain circumstances.) Item[] found; //Delete all the items from the constructor found = newContainer.FindItemsByType(typeof(Item), false); for (int j = 0; j < found.Length; j++) { found[j].Delete(); } //Add the items from the orginal bag. found = ((Container)toCopy).FindItemsByType(typeof(Item), false); for (int i = 0; i < found.Length; i++) { MakeCopy(found[i], ref itemList, (BaseContainer)newItem); } } else if (newItem is BaseWeapon) { CopyProperties((BaseWeapon)toCopy, (BaseWeapon)newItem); } else if (newItem is BaseArmor) { CopyProperties((BaseArmor)toCopy, (BaseArmor)newItem); } else if (newItem is BaseClothing) { CopyProperties((BaseClothing)toCopy, (BaseClothing)newItem); } else if (toCopy is Spellbook && newItem is Spellbook) { Spellbook bookToCopy = toCopy as Spellbook; Spellbook newBook = newItem as Spellbook; newBook.Content = bookToCopy.Content; } if (parentCont != null) { parentCont.DropItem(newItem); } itemList.Add(newItem); }
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); } } } }