public Item Construct(Mobile from, int luckChance, bool spawning) { if (m_AtSpawnTime != spawning) { return(null); } int totalChance = 0; for (int i = 0; i < m_Items.Length; ++i) { totalChance += m_Items[i].Chance; } int rnd = Utility.Random(totalChance); for (int i = 0; i < m_Items.Length; ++i) { LootPackItem item = m_Items[i]; if (rnd < item.Chance) { return(Mutate(from, luckChance, item.Construct(IsInTokuno(from), IsMondain(from), IsStygian(from)))); } rnd -= item.Chance; } return(null); }
public Item Construct(Mobile from, bool spawning) { if (m_AtSpawnTime != spawning) { return(null); } int totalChance = 0; for (int i = 0; i < m_Items.Length; ++i) { totalChance += m_Items[i].Chance; } int rnd = Utility.Random(totalChance); for (int i = 0; i < m_Items.Length; ++i) { LootPackItem item = m_Items[i]; if (rnd < item.Chance) { return(Mutate(from, item.Construct(false, false))); } rnd -= item.Chance; } return(null); }
public Item Construct(Mobile from, int luckChance, bool spawning) { if (m_AtSpawnTime != spawning) { return(null); } int totalChance = 0; for (int i = 0; i < m_Items.Length; ++i) { totalChance += m_Items[i].Chance; } var inTokuno = Core.SE && IsInTokuno(from); var isMondain = Core.ML && (IsMondain(from) || (from.LastKiller != null ? from.LastKiller.Race : null) == Race.Elf); var isStygian = Core.SA && (IsStygian(from) || (from.LastKiller != null ? from.LastKiller.Race : null) == Race.Gargoyle); int rnd = Utility.Random(totalChance); for (int i = 0; i < m_Items.Length; ++i) { LootPackItem item = m_Items[i]; if (rnd < item.Chance) { return(Mutate(from, luckChance, item.Construct(inTokuno, isMondain, isStygian))); } rnd -= item.Chance; } return(null); }
public static LootPack RandomLootItem(Type[] types, double chance, int amount, bool onSpawn, bool onSteal) { var items = new LootPackItem[types.Length]; for (int i = 0; i < items.Length; i++) { items[i] = new LootPackItem(types[i], 1); } return(new LootPack(new[] { new LootPackEntry(onSpawn, onSteal, items, chance, amount) })); }
public Item Construct() { int rnd = Utility.Random(m_TotalChance); for (int i = 0; i < m_Items.Length; ++i) { LootPackItem item = m_Items[i]; if (rnd < item.Chance) { return(Mutate(item.Construct())); } rnd -= item.Chance; } return(null); }
public Item Construct(IEntity from, int luckChance, LootStage stage, bool hasBeenStolenFrom) { int totalChance = 0; for (int i = 0; i < Items.Length; ++i) { totalChance += Items[i].Chance; } int rnd = Utility.Random(totalChance); for (int i = 0; i < Items.Length; ++i) { LootPackItem item = Items[i]; if (rnd < item.Chance) { Item loot = null; if (item.ConstructCallback != null) { loot = item.ConstructCallback(from); } else { loot = item.Construct(IsInTokuno(from), IsMondain(from), IsStygian(from)); } if (loot != null) { return(Mutate(from, luckChance, loot)); } } rnd -= item.Chance; } return(null); }
public Item Construct(Mobile from, int luckChance, bool spawning) { if (m_AtSpawnTime != spawning) return null; int totalChance = 0; for (int i = 0; i < m_Items.Length; ++i) totalChance += m_Items[i].Chance; int rnd = Utility.Random(totalChance); for (int i = 0; i < m_Items.Length; ++i) { LootPackItem item = m_Items[i]; if (rnd < item.Chance) return Mutate(from, luckChance, item.Construct()); rnd -= item.Chance; } return null; }
public LootPackEntry( bool atSpawnTime, LootPackItem[] items, double chance, LootPackDice quantity, int maxProps, int minIntensity, int maxIntensity) { m_AtSpawnTime = atSpawnTime; m_Items = items; Chance = (int)(100 * chance); m_Quantity = quantity; m_MaxProps = maxProps; m_MinIntensity = minIntensity; m_MaxIntensity = maxIntensity; }
public LootPackEntry( bool atSpawnTime, LootPackItem[] items, double chance, int quantity, int maxProps, int minIntensity, int maxIntensity) : this(atSpawnTime, items, chance, new LootPackDice(0, 0, quantity), maxProps, minIntensity, maxIntensity) { }
public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, int quantity) : this(atSpawnTime, items, chance, new LootPackDice(0, 0, quantity), 0, 0, 0) { }
public void Generate(Mobile m, Container cont, bool spawning, int luck) { int index = 0; foreach (LootPackEntry entry in m_Entries) { if (!entry.AtSpawnTime && spawning) { index++; continue; } int itemIndex = Utility.Random(entry.Types.Count); bool drop = false; if (entry.DropChance >= 100) { drop = true; } else { if (entry.DropChance >= Utility.Random(100)) { //Console.WriteLine("Create: DropChance >= Creation Chance... "); drop = true; } } if (!drop) { index++; continue; } //Console.WriteLine("Create: Drop Test Passed"); /* * Item check = (Item)Activator.CreateInstance(entry.Types[itemIndex]); * * int loop = 1; * if (!check.Stackable) * loop = entry.DropAmount; */ for (int a = 0; a < ((entry.Types[itemIndex] == typeof(Gold)) ? 1 : entry.DropAmount); a++) { Item looted = null; if (entry.Types[itemIndex] == typeof(BasePotion)) { int t = Utility.Random(LootPack.LowPotions.Count); Server.LootPackItem lpi = new Server.LootPackItem(Custom.LootPack.LowPotions[t], 1); looted = lpi.Construct(true, true, true); } else if (entry.Types[itemIndex] == typeof(TreasureMap)) { looted = new TreasureMap(Utility.Random(5), Map.Felucca); ((TreasureMap)looted).Decoder = m; } else if (entry.Types[itemIndex] == typeof(BaseRunicTool)) { switch (Utility.Random(2)) { case 0: looted = new RunicSewingKit(GetRandomLeather()); break; case 1: looted = new RunicHammer(GetRandomMetal()); break; // case 2: looted = new RunicSaw(GetRandomWood()); break; // case 3: looted = new RunicFletcherTools(GetRandomWood()); break; case 2: looted = new RunicSewingKit(GetRandomLeather()); break; //J.I.C } } else { Server.LootPackItem lpi = new Server.LootPackItem(entry.Types[itemIndex], 1); looted = lpi.Construct(true, true, true); } if (looted == null) { index++; continue; } //Console.WriteLine("Create: Construct Test Passed"); //Console.WriteLine("Mutate: # of Possible Attributes = " + entry.AttributeAmount); int chance = 0; for (int b = 0; b < entry.AttributeAmount; b++) { chance = Utility.Random(100); //Console.WriteLine("Mutate: Attach Chance " + chance); int propCount = ItemProps.BonusCount(looted); if (propCount < entry.AttributeAmount && entry.AttributeChance >= chance) { //Console.WriteLine("Mutate: Prop Chance >= Attach Chance"); looted = Mutate(m, luck, looted, index, itemIndex); } } if (looted == null) { index++; continue; } // if (looted is BaseRanged/*.GetType().IsSubclassOf(typeof(BaseRanged))*/ && 1 >= Utility.Random(200)) /* { * ((BaseRanged)looted).EnergyBow = true; * ((BaseRanged)looted).EnergyCost = Utility.RandomMinMax(3, 10); * }*/ //if (looted.GetType() == typeof(ScrollofCombatSecrets) || 1 >= Utility.Random(1000)) //looted.LootType = LootType.Blessed; if (looted.Stackable) { looted.Amount = entry.DropAmount; } //Skill Bonus Bug Fix Custom.ItemProps.FixSkillBonuses(looted); if (!cont.TryDropItem(m, looted, false)) { cont.DropItem(looted); } if (entry.Types.Count > 1) { itemIndex = Utility.Random(entry.Types.Count); } if (looted.Stackable) { break; } } index++; } }
public LootPackEntry( LootPackItem[] items, double chance, RandMinMax quantity, int minIntensity, int maxIntensity ) { m_Items = items; m_Quantity = quantity; m_Chance = (int)(100 * chance); m_MinIntensity = minIntensity; m_MaxIntensity = maxIntensity; m_TotalChance = 0; for ( int i = 0; i < m_Items.Length; ++i ) m_TotalChance += m_Items[i].Chance; }
public LootPackEntry( LootPackItem[] items, double chance, int quantity, int minIntensity, int maxIntensity ) : this(items, chance, new RandMinMax( quantity ), minIntensity, maxIntensity) { }
public LootPackEntry( LootPackItem[] items, double chance, RandMinMax quantity ) : this(items, chance, quantity, 0, 0) { }
public LootPackEntry( LootPackItem[] items, double chance, int quantity ) : this(items, chance, new RandMinMax( quantity ), 0, 0) { }