diff --git a/Data/Abilities.cs b/Data/Abilities.cs index a2d2023..288a938 100644 --- a/Data/Abilities.cs +++ b/Data/Abilities.cs @@ -16,7 +16,7 @@ public class Abilities public static Ability Deathblow = new Ability("Deathblow", Role.Commando, "ade710_00"); public static Ability Faultsiphon = new Ability("Faultsiphon", Role.Commando, "ade730_00"); public static Ability Jeopardize = new Ability("Jeopardize", Role.Commando, "ade700_00"); - public static Ability Launch = new Ability("Launch", Role.Commando, "aat500_00","lsf"); + public static Ability Launch = new Ability("Launch", Role.Commando, "aat500_00", "lsf"); public static Ability Lifesiphon = new Ability("Lifesiphon", Role.Commando, "ade720_00"); public static Ability Powerchain = new Ability("Powerchain", Role.Commando, "aat550_00", "lszf"); public static Ability Ravage = new Ability("Ravage", Role.Commando, "aat530_00", "lsf") @@ -32,7 +32,7 @@ public class Abilities .Add("at200_rv", "") // some Attack? Fang/Snow .Add("at010_99", "") // Ch1/2 Snow .Add("at020_99", "") // Ch1/2 Snow - .Add("c000_at010_00","l") + .Add("c000_at010_00", "l") .Add("c000_at020_00", "") // mid Attacks Lightning .Add("c000_at200_00", "") // some Attack? Lightning .Add("c002_at010_00", "z") @@ -48,10 +48,6 @@ public class Abilities .Add("c004_at010_00", "v") .Add("c004_at010_99", "") // Ch1/2 Vanille .Add("c004_at020_00", "") // mid Attacks Vanille - //.Add("c004_at540_00", "") - //.Add("c004_at550_00", "") - //.Add("c004_at570_00", "") - //.Add("c004_at570_10", "") .SetStarting(); public static Ability Blitz = new Ability("Blitz", Role.Commando, "at520_00", "lsf") .Add("c002_at520_00", "z") @@ -144,7 +140,7 @@ public class Abilities public static Ability Faith = new Ability("Faith", Role.Synergist, "me010_00").SetStarting(); public static Ability Faithra = new Ability("Faithra", Role.Synergist, "me210_00").SetStarting(); - + public static Ability Protect = new Ability("Protect", Role.Synergist, "me500_00").SetStarting(); public static Ability Protectra = new Ability("Protectra", Role.Synergist, "me700_00").SetStarting(); @@ -203,22 +199,22 @@ public class Abilities // Techniques - public static Ability Dispelga = new Ability("Dispelga", Role.None, "tp300_00"); - public static Ability Libra = new Ability("Libra", Role.None, "tp100_00"); - public static Ability Quake = new Ability("Quake", Role.None, "tp400_00"); - public static Ability Renew = new Ability("Renew", Role.None, "tp000_00"); - public static Ability Stopga = new Ability("Stopga", Role.None, "tp200_00"); + public static Ability Dispelga = new Ability("Dispelga", Role.None, "tp300_00", "lsvzhf", true); + public static Ability Libra = new Ability("Libra", Role.None, "tp100_00", "lsvzhf", true); + public static Ability Quake = new Ability("Quake", Role.None, "tp400_00", "lsvzhf", true); + public static Ability Renew = new Ability("Renew", Role.None, "tp000_00", "lsvzhf", true); + public static Ability Stopga = new Ability("Stopga", Role.None, "tp200_00", "lsvzhf", true); public static Ability Summon = new Ability("Summon", Role.None, "sm000", ""); // Special - public static Ability ArmyOfOne = new Ability("ArmyOfOne", Role.Ravager, "c000_at900_00", "l"); - public static Ability ColdBlood = new Ability("ColdBlood", Role.Ravager, "c002_at900_00", "z"); - public static Ability Death = new Ability("Death", Role.Saboteur, "ms400_00", "v"); - public static Ability Highwind = new Ability("Highwind", Role.Commando, "c005_at900_00", "f"); - public static Ability LastResort = new Ability("LastResort", Role.Ravager, "ms200_00", "h"); - public static Ability SovereignFist = new Ability("SovereignFist", Role.Commando, "c001_at900_00", "s"); + public static Ability ArmyOfOne = new Ability("ArmyOfOne", Role.Ravager, "c000_at900_00", "l", true); + public static Ability ColdBlood = new Ability("ColdBlood", Role.Ravager, "c002_at900_00", "z", true); + public static Ability Death = new Ability("Death", Role.Saboteur, "ms400_00", "v", true); + public static Ability Highwind = new Ability("Highwind", Role.Commando, "c005_at900_00", "f", true); + public static Ability LastResort = new Ability("LastResort", Role.Ravager, "ms200_00", "h", true); + public static Ability SovereignFist = new Ability("SovereignFist", Role.Commando, "c001_at900_00", "s", true); public static Ability HandGrenade = new Ability("Hand Grenade", Role.Commando, "def100_00", ""); } diff --git a/Data/Ability.cs b/Data/Ability.cs index 154e44b..0714d88 100644 --- a/Data/Ability.cs +++ b/Data/Ability.cs @@ -35,9 +35,10 @@ public bool HasCharacter(string character) /// /// /// - public Ability(String name, Role role, string id, string characters = "lsvzhf") + public Ability(String name, Role role, string id, string characters = "lsvzhf", bool special = false) { this.Name = name; + this.Special = special; Role = role; Add(id, characters); Abilities.abilities.Add(this); @@ -49,6 +50,8 @@ public Ability Add(string id, string characters = "lsvzhf") return this; } + public bool Special { get; set; } + public bool HasCharacter(string character) { for (int i = list.Count - 1; i >= 0; i--) diff --git a/Data/Tiered.cs b/Data/Tiered.cs index 756f9fb..535770c 100644 --- a/Data/Tiered.cs +++ b/Data/Tiered.cs @@ -106,10 +106,14 @@ public int GetRandomCount(int rankBoost, int max) return lower >= upper ? lower : RandomNum.RandInt(lower, upper - 1); } - public List> Get(int rank, int count, Func meetsReq = null) + public List> Get(int rank, int count, Func meetsReq = null, bool anyRandom = false) { if (meetsReq == null) meetsReq = t => true; + if (anyRandom) + { + return new List>() { new Tuple(list[RandomNum.RandInt(0, list.Count - 1)].Item2, count) }; + } if (rank < LowBound || rank > HighBound) return new List>(); List validIndexes = new List(); @@ -117,7 +121,7 @@ public int GetRandomCount(int rankBoost, int max) { int upperBound = i == list.Count - 1 ? HighBound : list[i + 1].Item1; upperBound = Math.Max(upperBound, list[i].Item1 + GetCountBoost(maxCount)); - if (rank >= list[i].Item1 && rank <= upperBound && meetsReq.Invoke(list[i].Item2)) + if (anyRandom || (rank >= list[i].Item1 && rank <= upperBound && meetsReq.Invoke(list[i].Item2))) validIndexes.Add(i); } return validIndexes.Select(i => new Tuple(list[i].Item2, GetRandomCount(rank - list[i].Item1,count))).ToList(); diff --git a/Data/TieredAbilities.cs b/Data/TieredAbilities.cs index 208a55d..ddf1dd1 100644 --- a/Data/TieredAbilities.cs +++ b/Data/TieredAbilities.cs @@ -232,32 +232,24 @@ public class TieredAbilities (0, Abilities.Enwater) .Register(manager); - public static TieredDependent Bravery = new TieredDependent + public static TieredDependent Bravery = (TieredDependent)new TieredDependent (0, Abilities.Bravery) - .Register(manager); - public static TieredDependent Bravera = new TieredDependent - (0, Abilities.Bravera) + .Add(1,Abilities.Bravera) .Register(manager); - public static TieredDependent Faith = new TieredDependent + public static TieredDependent Faith = (TieredDependent)new TieredDependent (0, Abilities.Faith) - .Register(manager); - public static TieredDependent Faithra = new TieredDependent - (0, Abilities.Faithra) + .Add(1, Abilities.Faithra) .Register(manager); - public static TieredDependent Protect = new TieredDependent + public static TieredDependent Protect = (TieredDependent)new TieredDependent (0, Abilities.Protect) - .Register(manager); - public static TieredDependent Protectra = new TieredDependent - (0, Abilities.Protectra) + .Add(1, Abilities.Protectra) .Register(manager); - public static TieredDependent Shell = new TieredDependent + public static TieredDependent Shell = (TieredDependent)new TieredDependent (0, Abilities.Shell) - .Register(manager); - public static TieredDependent Shellra = new TieredDependent - (0, Abilities.Shellra) + .Add(1, Abilities.Shellra) .Register(manager); public static TieredDependent Haste = new TieredDependent @@ -422,12 +414,12 @@ static TieredAbilities() public static Ability Get(Tiered tiered, List obtained) { - return manager.Get(0, 1, tiered, a => ((TieredDependent)tiered).MeetsRequirement(a, obtained)).Item1; + return manager.Get(0, 1, tiered, a => ((TieredDependent)tiered).MeetsRequirement(a, obtained), true).Item1; } public static Ability GetNoDep(Tiered tiered) { - return manager.Get(0, 1, tiered, a => true).Item1; + return manager.Get(0, 1, tiered, a => true, true).Item1; } } } diff --git a/Data/TieredManager.cs b/Data/TieredManager.cs index cbe076c..424583b 100644 --- a/Data/TieredManager.cs +++ b/Data/TieredManager.cs @@ -24,9 +24,9 @@ public List> GetTiered(int rank, int count) return Get(rank,maxCount, tiered); } - public Tuple Get(int rank, int maxCount, Tiered tiered, Func meetsReq = null) + public Tuple Get(int rank, int maxCount, Tiered tiered, Func meetsReq = null, bool anyRandom = false) { - List> possible = tiered == null ? new List>() : tiered.Get(rank,maxCount,meetsReq); + List> possible = tiered == null ? new List>() : tiered.Get(rank, maxCount, meetsReq, anyRandom); if (possible.Count == 0) return new Tuple(default(T), 0); return possible[RandomNum.RandInt(0, possible.Count - 1)]; diff --git a/FormMain.cs b/FormMain.cs index a17b6bd..6493e02 100644 --- a/FormMain.cs +++ b/FormMain.cs @@ -18,7 +18,7 @@ namespace FF13Randomizer { public partial class FormMain : Form { - public static string version = "1.7.1"; + public static string version = "1.7.2"; public string[] fileNamesModified = new string[] { "db/crystal/crystal_lightning.wdb", diff --git a/Randomizers/RandoCrystarium.cs b/Randomizers/RandoCrystarium.cs index c4b0431..4c33335 100644 --- a/Randomizers/RandoCrystarium.cs +++ b/Randomizers/RandoCrystarium.cs @@ -219,6 +219,8 @@ public void RandomizeStats(Dictionary> if (name != "fang" && c.CPCost == 0) avgValue = (int)Math.Floor(avgValue * 2.8d); + if (c.Type == CrystariumType.HP) + avgValue = (int)Math.Ceiling(avgValue * 0.9); if (c.Type == CrystariumType.HP) @@ -299,6 +301,19 @@ public void ShuffleTechniques(string name, DataStoreWDB cry } } + public void ShuffleAnyRole(string name, DataStoreWDB crystarium) + { + if (Flags.CrystariumFlags.NewAbilities && Flags.CrystariumFlags.NewAbilities.ExtraSelected) + { + Flags.CrystariumFlags.NewAbilities.SetRand(); + crystarium.DataList.ToList() + .Where(c => c.Type == CrystariumType.Ability + && c.CPCost > 0 && (primaryRoles[name].Contains(c.Role) || c.Stage > 1)) + .ToList().Shuffle((a, b) => a.SwapStatsAbilities(b)); + RandomNum.ClearRand(); + } + } + public void RandomizeAbilities() { foreach (string name in names) @@ -327,7 +342,7 @@ public void RandomizeAbilities() abilityNodes.Sort((a, b) => crystarium.DataList[a].Stage.CompareTo(crystarium.DataList[b].Stage)); List> starting = TieredAbilities.manager.list.Where( - t => t.Items.Where(a => a.Role == role && a.Starting && a.HasCharacter(getCharID(name))).Count() > 0 && !added.Contains(t)).ToList(); + t => t.Items.Where(a => a.Role == role && !a.Special && a.Starting && a.HasCharacter(getCharID(name))).Count() > 0 && !added.Contains(t)).ToList(); int maxStage = 1; for (int i = 0; i < abilityNodes.Count; i++) @@ -338,7 +353,7 @@ public void RandomizeAbilities() maxStage = cryst.Stage; Ability orig = GetAbility(name, crystarium, cryst); - if (orig.Role == Role.None) + if (orig.Special) continue; if (cryst.CPCost == 0 || (!primaryRoles[name].Contains(role) && cryst.Stage == 1)) @@ -380,7 +395,7 @@ public void RandomizeAbilities() abilityNodes.Sort((a, b) => crystarium.DataList[a].Stage.CompareTo(crystarium.DataList[b].Stage)); List> rest = TieredAbilities.manager.list.Where( - t => t.Items.Where(a => a.Role == role && a.HasCharacter(getCharID(name))).Count() > 0 && !added.Contains(t)).ToList(); + t => t.Items.Where(a => a.Role == role && !a.Special && a.HasCharacter(getCharID(name))).Count() > 0 && !added.Contains(t)).ToList(); for (int i = 0; i < abilityNodes.Count; i++) { DataStoreCrystarium cryst = crystarium.DataList[abilityNodes[i]]; @@ -390,7 +405,7 @@ public void RandomizeAbilities() Ability orig = GetAbility(name, crystarium, cryst); - if (orig.Role == Role.None) + if (orig.Special) continue; int newI; @@ -425,7 +440,7 @@ public void RandomizeAbilities() abilityNodes.Sort((a, b) => crystarium.DataList[a].Stage.CompareTo(crystarium.DataList[b].Stage)); List> rest = TieredAbilities.manager.list.Where( - t => t.Items.Where(a => (a.Role == role || Flags.CrystariumFlags.NewAbilities.ExtraSelected) && a.Role != Role.None && a.HasCharacter(getCharID(name))).Count() > 0 && !added.Contains(t)).ToList(); + t => t.Items.Where(a => (a.Role == role || Flags.CrystariumFlags.NewAbilities.ExtraSelected) && !a.Special && a.HasCharacter(getCharID(name))).Count() > 0 && !added.Contains(t)).ToList(); for (int i = 0; i < abilityNodes.Count; i++) { DataStoreCrystarium cryst = crystarium.DataList[abilityNodes[i]]; @@ -435,7 +450,7 @@ public void RandomizeAbilities() Ability orig = GetAbility(name, crystarium, cryst); - if (orig.Role == Role.None) + if (orig.Special) continue; int newI; @@ -453,6 +468,7 @@ public void RandomizeAbilities() RandomNum.ClearRand(); } } + ShuffleAnyRole(name, crystarium); } } diff --git a/Randomizers/RandoEnemies.cs b/Randomizers/RandoEnemies.cs index a99f8ea..c15ca8a 100644 --- a/Randomizers/RandoEnemies.cs +++ b/Randomizers/RandoEnemies.cs @@ -208,9 +208,9 @@ public override void Randomize(BackgroundWorker backgroundWorker) }); - if (Flags.ItemFlags.Shops) + if (Flags.ItemFlags.ShopLocations) { - Flags.ItemFlags.Shops.SetRand(); + Flags.ItemFlags.ShopLocations.SetRand(); List list = scene.IndexesOf(Encoding.UTF8.GetBytes("key_shop_")); List shops = list.Select(i => Encoding.UTF8.GetString(scene.SubArray(i, 11))).ToList(); diff --git a/Randomizers/RandoTreasure.cs b/Randomizers/RandoTreasure.cs index ceefce6..c121413 100644 --- a/Randomizers/RandoTreasure.cs +++ b/Randomizers/RandoTreasure.cs @@ -86,9 +86,9 @@ public override void Randomize(BackgroundWorker backgroundWorker) }); RandomNum.ClearRand(); - if (Flags.ItemFlags.Shops) + if (Flags.ItemFlags.ShopLocations) { - Flags.ItemFlags.Shops.SetRand(); + Flags.ItemFlags.ShopLocations.SetRand(); shopsRemaining.Clear(); for (int i = 1; i <= 13; i++) { @@ -97,11 +97,11 @@ public override void Randomize(BackgroundWorker backgroundWorker) shopsRemaining.Add("key_shop_" + i.ToString("00")); } shopsRemaining.Shuffle(); - treasures.StringList.ToList().ForEach(str => + treasures.DataList.ToList().ForEach(treasure => { - if (str.Value.StartsWith("key_shop_")) + if (treasure.ItemID.StartsWith("key_shop_")) { - str.Value = shopsRemaining[0]; + treasure.ItemID = shopsRemaining[0]; shopsRemaining.RemoveAt(0); } });