private static int Scale(int min, int max, int low, int high) { int percent; if (m_PlayerMade) { percent = Utility.RandomMinMax(min, max); } else { int v = Utility.RandomMinMax(0, 10000); v = (int)Math.Sqrt(v); v = 100 - v; if (LootPack.CheckLuck(m_LuckChance)) { v += 10; } percent = Math.Min(max, min + AOS.Scale((max - min), v)); } int scaledBy = Math.Abs(high - low) + 1; if (scaledBy != 0) { scaledBy = 10000 / scaledBy; } percent *= (10000 + scaledBy); return(low + (((high - low) * percent) / 1000001)); }
private static int Scale(int min, int max, int low, int high) { int percent; if (m_IsRunicTool) { percent = Utility.RandomMinMax(min, max); } else { // Behold, the worst system ever! int v = Utility.RandomMinMax(0, 10000); v = (int)Math.Sqrt(v); v = 100 - v; if (LootPack.CheckLuck(m_LuckChance)) { v += 10; } if (v < min) { v = min; } else if (v > max) { v = max; } percent = v; } int scaledBy = Math.Abs(high - low) + 1; if (scaledBy != 0) { scaledBy = 10000 / scaledBy; } percent *= (10000 + scaledBy); return(low + (((high - low) * percent) / 1000001)); }
public Item Mutate(Mobile from, int luckChance, Item item) { if (item != null) { if (item is BaseWeapon && Utility.Random(100) < 1) { item.Delete(); item = new FireHorn(); return(item); } if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat) { if (Core.AOS) { var bonusProps = GetBonusProperties(); var min = MinIntensity; var max = MaxIntensity; if (bonusProps < MaxProps && LootPack.CheckLuck(luckChance)) { ++bonusProps; } var props = 1 + bonusProps; // Make sure we're not spawning items with 6 properties. if (props > MaxProps) { props = MaxProps; } if (item is BaseWeapon weapon) { BaseRunicTool.ApplyAttributesTo(weapon, false, luckChance, props, MinIntensity, MaxIntensity); } else if (item is BaseArmor armor) { BaseRunicTool.ApplyAttributesTo(armor, false, luckChance, props, MinIntensity, MaxIntensity); } else if (item is BaseJewel jewel) { BaseRunicTool.ApplyAttributesTo(jewel, false, luckChance, props, MinIntensity, MaxIntensity); } else { BaseRunicTool.ApplyAttributesTo( (BaseHat)item, false, luckChance, props, MinIntensity, MaxIntensity ); } } else // not aos { if (item is BaseWeapon weapon) { if (Utility.Random(100) < 80) { weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus(); } if (Utility.Random(100) < 60) { weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus(); } if (Utility.Random(100) < 40) { weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus(); } if (Utility.Random(100) < 5) { weapon.Slayer = SlayerName.Silver; } if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 && weapon.Slayer == SlayerName.None && Utility.Random(100) < 5) { weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType()); } } else if (item is BaseArmor armor) { if (Utility.Random(100) < 80) { armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus(); } if (Utility.Random(100) < 40) { armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus(); } } } } else if (item is BaseInstrument instr) { SlayerName slayer; if (Core.AOS) { slayer = BaseRunicTool.GetRandomSlayer(); } else { slayer = SlayerGroup.GetLootSlayerType(from.GetType()); } if (slayer == SlayerName.None) { instr.Delete(); return(null); } instr.Quality = InstrumentQuality.Regular; instr.Slayer = slayer; } if (item.Stackable) { item.Amount = Quantity.Roll(); } } return(item); }
public static void ApplyAttributesTo(BaseQuiver quiver, bool isRunicTool, int luckChance, int attributeCount, int min, int max) { m_IsRunicTool = isRunicTool; m_LuckChance = luckChance; AosAttributes primary = quiver.Attributes; m_Props.SetAll(false); int dmgIncrease = 0; if (LootPack.CheckLuck(m_LuckChance) || max >= Utility.RandomMinMax(1, 50)) { dmgIncrease = 5 + Utility.RandomMinMax(min, max); } if (dmgIncrease > 50) { dmgIncrease = 50; } int lowAmmo = 0; if (LootPack.CheckLuck(m_LuckChance) || max >= Utility.RandomMinMax(1, 50)) { lowAmmo = 5 + Utility.RandomMinMax(min, max); } if (lowAmmo > 75) { lowAmmo = 75; } int weightReduce = 50; if (LootPack.CheckLuck(m_LuckChance) || max >= Utility.RandomMinMax(1, 50)) { weightReduce = weightReduce + Utility.RandomMinMax(min, max); } if (weightReduce > 100) { weightReduce = 100; } quiver.DamageIncrease = dmgIncrease; quiver.LowerAmmoCost = lowAmmo; quiver.WeightReduction = weightReduce; for (int i = 0; i < attributeCount; ++i) { int random = GetUniqueRandom(22); if (random == -1) { break; } switch (random) { case 0: ApplyAttribute(primary, min, max, AosAttribute.WeaponDamage, 1, 25); break; case 1: ApplyAttribute(primary, min, max, AosAttribute.DefendChance, 1, 15); break; case 2: ApplyAttribute(primary, min, max, AosAttribute.AttackChance, 1, 15); break; case 3: ApplyAttribute(primary, min, max, AosAttribute.BonusStr, 1, 8); break; case 4: ApplyAttribute(primary, min, max, AosAttribute.BonusDex, 1, 8); break; case 5: ApplyAttribute(primary, min, max, AosAttribute.BonusInt, 1, 8); break; case 6: ApplyAttribute(primary, min, max, AosAttribute.EnhancePotions, 5, 25, 5); break; case 7: ApplyAttribute(primary, min, max, AosAttribute.CastSpeed, 1, 1); break; case 8: ApplyAttribute(primary, min, max, AosAttribute.CastRecovery, 1, 3); break; case 9: ApplyAttribute(primary, min, max, AosAttribute.LowerManaCost, 1, 8); break; case 10: ApplyAttribute(primary, min, max, AosAttribute.LowerRegCost, 1, 20); break; case 11: ApplyAttribute(primary, min, max, AosAttribute.Luck, 1, 100); break; case 12: ApplyAttribute(primary, min, max, AosAttribute.SpellDamage, 1, 12); break; case 13: ApplyAttribute(primary, min, max, AosAttribute.NightSight, 1, 1); break; case 14: ApplyAttribute(primary, min, max, AosAttribute.BonusHits, 5, 20); break; case 15: ApplyAttribute(primary, min, max, AosAttribute.BonusStam, 5, 20); break; case 16: ApplyAttribute(primary, min, max, AosAttribute.BonusMana, 5, 20); break; case 17: ApplyAttribute(primary, min, max, AosAttribute.ReflectPhysical, 5, 15); break; case 18: ApplyAttribute(primary, min, max, AosAttribute.RegenHits, 1, 5); break; case 19: ApplyAttribute(primary, min, max, AosAttribute.RegenStam, 1, 5); break; case 20: ApplyAttribute(primary, min, max, AosAttribute.RegenMana, 1, 5); break; case 21: ApplyAttribute(primary, min, max, AosAttribute.WeaponSpeed, 1, 2); break; } } }
public override void OnDoubleClick(Mobile from) { if (!this.IsChildOf(from.Backpack) && m_Owner == null) //you could set ownership while in a playervendor's backpack without this. { from.SendMessage("That needs to be in your backpack" + from.Name.ToString() + "."); } else if (m_Owner == null) //if no-one has opened it yet { m_Owner = from; this.Name = m_Owner.Name.ToString() + "'s loot."; DoFill(from); from.PlaySound(0x548); base.OnDoubleClick(from); from.SendMessage("NOO! Release me! I was happy when i was forgotten!"); } else if (m_Owner != from) //if it has an owner other than the person trying to open it { from.SendMessage("It is trying to get away!!"); from.PlaySound(0x549); this.ItemID = Utility.RandomList(m_ItemIDs); return; } else if (m_Owner == from) //if it is yours and you want to open it { if (!LootPack.CheckLuck((from.Luck * 5) / 2)) { this.ItemID = Utility.RandomList(m_ItemIDs); from.PlaySound(Utility.RandomList(m_Sounds)); switch (Utility.Random(20)) { case 0: from.SendAsciiMessage(0x53, m_Owner.Name.ToString() + " you touched me! How dare you! "); break; case 1: from.SendAsciiMessage(0x52, "Your not very lucky " + m_Owner.Name.ToString() + "!"); break; case 2: from.SendAsciiMessage(0x51, "Release me before you get gobbled by a monster " + m_Owner.Name.ToString() + "!"); break; case 3: from.SendAsciiMessage(0x50, "I was happier when everyone forgot about me."); break; case 4: from.SendAsciiMessage(0x4F, "Release me " + m_Owner.Name.ToString() + "!"); break; case 5: from.SendAsciiMessage(0x4E, "I wish i was home, the dust was just right there."); break; case 6: from.SendAsciiMessage(0x4D, "When in doubt, pout and SHOUT!"); break; case 7: from.SendAsciiMessage(0x4C, "It isn't me! Look, I'm different now!"); break; case 8: from.SendAsciiMessage(0x4B, "Quit grabbing me there " + m_Owner.Name.ToString() + "!"); break; case 9: from.SendAsciiMessage(0x4A, "Wouldn't you be cranky if you had to carry all this around " + m_Owner.Name.ToString() + "?"); break; case 10: from.SendAsciiMessage(0x49, "Hey! I let you in before didn't I?"); break; case 11: from.SendAsciiMessage(0x48, "Dang your ugly " + m_Owner.Name.ToString() + "!"); break; case 12: from.SendAsciiMessage(0x47, "My mother was a container and my dad was a shapeshifter, so..."); break; case 13: from.SendAsciiMessage(0x46, "Zzz Zzz Zz-wha? Let me rest! I plan to run away in the morning."); break; case 14: from.SendAsciiMessage(0x45, "Dat's noice."); break; case 15: from.SendAsciiMessage(0x44, "I do too know how to keep my trap shut! You aren't getting in, are you?"); break; case 16: from.SendAsciiMessage(0x43, m_Owner.Name.ToString() + ", you can always send me away you know..."); break; case 17: from.SendAsciiMessage(0x42, "Out of my head at the moment, be back later."); break; case 18: from.SendAsciiMessage(0x41, "Do you mind " + m_Owner.Name.ToString() + "? I have a date in here! Or is it a plum?"); break; case 19: from.SendAsciiMessage(0x40, "I wonder what that release thingy does...hmm?"); break; } } else { from.PlaySound(Utility.RandomList(m_Sounds)); switch (Utility.Random(7)) { case 0: from.SendAsciiMessage(0x3F, "I reject your reality and substitute my own."); break; case 1: from.SendAsciiMessage(0x3E, "Like the new look? I changed it just to bug you " + m_Owner.Name.ToString() + "."); break; case 2: from.SendAsciiMessage(0x3D, "Hey! You opened me when i wasn't looking!"); break; case 3: from.SendAsciiMessage(0x3C, "You sure know how to get inside a person don't you " + m_Owner.Name.ToString() + "?"); break; case 4: from.SendAsciiMessage(0x3B, "Hey! Close me! I'm not a flasher!"); break; case 5: from.SendAsciiMessage(0x3A, "Quit poking me " + m_Owner.Name.ToString() + "!"); break; case 6: from.SendAsciiMessage(0x39, "This isn't a peep show you, you ...Peeper!"); break; } base.OnDoubleClick(from); } } }