/// <summary> /// Randomizes monster stats/drops/etc. /// - Skips coin range randomization - not sure what it's for /// - Skips whether a monster is a glider, as flying monster spawns are hard-coded... don't want to /// accidently spawn a non-flying monster somewhere it can't move /// </summary> /// <returns /> public static Dictionary <string, string> Randomize() { Dictionary <string, string> replacements = new Dictionary <string, string>(); List <Monster> allMonsters = MonsterData.GetAllMonsters(); Dictionary <int, int> monsterItemSwaps = GetMonsterDropReplacements(allMonsters); Dictionary <string, ItemDrop> extraItemDrops = new Dictionary <string, ItemDrop>(); foreach (Monster monster in allMonsters) { monster.HP = Math.Max(Globals.RNGGetIntWithinPercentage(monster.HP, HPVariance), 1); monster.Damage = Math.Max(Globals.RNGGetIntWithinPercentage(monster.Damage, DamageVariance), 1); monster.RandomMovementDuration = Globals.RNGGetNextBoolean(35) ? 0 : Range.GetRandomValue(1, 3000); RandomizeMonsterDrops(monster, monsterItemSwaps, extraItemDrops); RandomizeResilience(monster); monster.Jitteriness = Range.GetRandomValue(0, 2) / 100d; RandomizeMoveTowardPlayerThreshold(monster); monster.Speed = Range.GetRandomValue(1, 4); monster.MissChance = Range.GetRandomValue(0, 5) / 100d; monster.Experience = Math.Max(Globals.RNGGetIntWithinPercentage(monster.Experience, ExperienceVariance), 1); replacements.Add(monster.Name, monster.ToString()); } WriteToSpoilerLog(allMonsters, monsterItemSwaps, extraItemDrops); return(replacements); }
/// <summary> /// Randomizes weapon damage based on the original max damage /// - if the max damage is under 10 - has a 50% variance /// - if the max damage is under 50 - has a 30% variance /// - if the max damage is over 50,- has a 20% variance /// </summary> /// <param name="weapon">The weapon to randomize</param> private static void RandomizeWeaponDamage(WeaponItem weapon) { const int percentageUnder10 = 50; const int percentageUnder50 = 30; const int percentageOver50 = 20; int minDamage = weapon.Damage.MinValue; int maxDamage = weapon.Damage.MaxValue; int percentage = 0; if (maxDamage < 10) { percentage = percentageUnder10; } else if (maxDamage < 50) { percentage = percentageUnder50; } else { percentage = percentageOver50; } int minValueToUse = Globals.RNGGetIntWithinPercentage(minDamage, percentage); int maxValueToUse = Globals.RNGGetIntWithinPercentage(maxDamage, percentage); weapon.Damage = new Range(minValueToUse, maxValueToUse); }
/// <summary> /// Randomizes boots - currently only changes defense and immunity /// </summary> /// <returns /> public static Dictionary <int, string> Randomize() { Boots.Clear(); WeaponAndArmorNameRandomizer nameRandomizer = new WeaponAndArmorNameRandomizer(); Dictionary <int, string> bootReplacements = new Dictionary <int, string>(); List <BootItem> bootsToUse = new List <BootItem>(); foreach (BootItem originalBoot in BootData.AllBoots) { int statPool = Globals.RNGGetIntWithinPercentage(originalBoot.Defense + originalBoot.Immunity, 30); int defense = Range.GetRandomValue(0, statPool); int immunity = statPool - defense; BootItem newBootItem = new BootItem( originalBoot.Id, nameRandomizer.GenerateRandomBootName(), originalBoot.NotActuallyPrice, defense, immunity, originalBoot.ColorSheetIndex ); bootsToUse.Add(newBootItem); Boots.Add(newBootItem.Id, newBootItem); } foreach (BootItem bootToAdd in bootsToUse) { bootReplacements.Add(bootToAdd.Id, bootToAdd.ToString()); } WriteToSpoilerLog(bootsToUse); return(bootReplacements); }
/// <summary> /// Randomizes the resilience of a monster /// </summary> /// <param name="monster"></param> private static void RandomizeResilience(Monster monster) { if (monster.Resilience == 0) { monster.Resilience = Globals.RNGGetNextBoolean(ResilienceVariance) ? 1 : 0; } else { monster.Resilience = Globals.RNGGetIntWithinPercentage(monster.Resilience, ResilienceVariance); } }
/// <summary> /// Randomizes boots - currently only changes defense and immunity /// </summary> /// <returns /> public static Dictionary <int, string> Randomize() { Boots.Clear(); WeaponAndArmorNameRandomizer nameRandomizer = new WeaponAndArmorNameRandomizer(); List <string> descriptions = NameAndDescriptionRandomizer.GenerateBootDescriptions(BootData.AllBoots.Count); Dictionary <int, string> bootReplacements = new Dictionary <int, string>(); List <BootItem> bootsToUse = new List <BootItem>(); for (int i = 0; i < BootData.AllBoots.Count; i++) { BootItem originalBoot = BootData.AllBoots[i]; int statPool = Globals.RNGGetIntWithinPercentage(originalBoot.Defense + originalBoot.Immunity, 30); int defense = Range.GetRandomValue(0, statPool); int immunity = statPool - defense; if ((defense + immunity) == 0) { if (Globals.RNGGetNextBoolean()) { defense = 1; } else { immunity = 1; } } BootItem newBootItem = new BootItem( originalBoot.Id, nameRandomizer.GenerateRandomBootName(), descriptions[i], originalBoot.NotActuallyPrice, defense, immunity, originalBoot.ColorSheetIndex ); bootsToUse.Add(newBootItem); Boots.Add(newBootItem.Id, newBootItem); } foreach (BootItem bootToAdd in bootsToUse) { bootReplacements.Add(bootToAdd.Id, bootToAdd.ToString()); } WriteToSpoilerLog(bootsToUse); return(bootReplacements); }