Skip to content

Commit

Permalink
1.7.2
Browse files Browse the repository at this point in the history
-Modified Ability rando on crystarium to guarantee all full ATB abilities
-Modified Ability rando on crystarium to not allow normal and -ra buffs on the same character (was simple to change, hard to add as an option. makes the AI less confused anyways)
-Modified HP nodes to be at 90% value compared to before (probably still high HP, but taking steps in the right direction)
-Fixed shop location flag not working on mission shop rewards
  • Loading branch information
bartz24games@gmail.com committed Aug 26, 2020
1 parent a7cb1f0 commit 2653594
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 55 deletions.
32 changes: 14 additions & 18 deletions Data/Abilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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", "");
}
Expand Down
5 changes: 4 additions & 1 deletion Data/Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public bool HasCharacter(string character)
/// <param name="role"></param>
/// <param name="id"></param>
/// <param name="characters"></param>
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);
Expand All @@ -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--)
Expand Down
8 changes: 6 additions & 2 deletions Data/Tiered.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,22 @@ public int GetRandomCount(int rankBoost, int max)
return lower >= upper ? lower : RandomNum.RandInt(lower, upper - 1);
}

public List<Tuple<T, int>> Get(int rank, int count, Func<T, bool> meetsReq = null)
public List<Tuple<T, int>> Get(int rank, int count, Func<T, bool> meetsReq = null, bool anyRandom = false)
{
if (meetsReq == null)
meetsReq = t => true;
if (anyRandom)
{
return new List<Tuple<T, int>>() { new Tuple<T, int>(list[RandomNum.RandInt(0, list.Count - 1)].Item2, count) };
}
if (rank < LowBound || rank > HighBound)
return new List<Tuple<T, int>>();
List<int> validIndexes = new List<int>();
for (int i = 0; i < list.Count; i++)
{
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<T, int>(list[i].Item2, GetRandomCount(rank - list[i].Item1,count))).ToList();
Expand Down
28 changes: 10 additions & 18 deletions Data/TieredAbilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,32 +232,24 @@ public class TieredAbilities
(0, Abilities.Enwater)
.Register(manager);

public static TieredDependent<Ability> Bravery = new TieredDependent<Ability>
public static TieredDependent<Ability> Bravery = (TieredDependent<Ability>)new TieredDependent<Ability>
(0, Abilities.Bravery)
.Register(manager);
public static TieredDependent<Ability> Bravera = new TieredDependent<Ability>
(0, Abilities.Bravera)
.Add(1,Abilities.Bravera)
.Register(manager);

public static TieredDependent<Ability> Faith = new TieredDependent<Ability>
public static TieredDependent<Ability> Faith = (TieredDependent<Ability>)new TieredDependent<Ability>
(0, Abilities.Faith)
.Register(manager);
public static TieredDependent<Ability> Faithra = new TieredDependent<Ability>
(0, Abilities.Faithra)
.Add(1, Abilities.Faithra)
.Register(manager);

public static TieredDependent<Ability> Protect = new TieredDependent<Ability>
public static TieredDependent<Ability> Protect = (TieredDependent<Ability>)new TieredDependent<Ability>
(0, Abilities.Protect)
.Register(manager);
public static TieredDependent<Ability> Protectra = new TieredDependent<Ability>
(0, Abilities.Protectra)
.Add(1, Abilities.Protectra)
.Register(manager);

public static TieredDependent<Ability> Shell = new TieredDependent<Ability>
public static TieredDependent<Ability> Shell = (TieredDependent<Ability>)new TieredDependent<Ability>
(0, Abilities.Shell)
.Register(manager);
public static TieredDependent<Ability> Shellra = new TieredDependent<Ability>
(0, Abilities.Shellra)
.Add(1, Abilities.Shellra)
.Register(manager);

public static TieredDependent<Ability> Haste = new TieredDependent<Ability>
Expand Down Expand Up @@ -422,12 +414,12 @@ static TieredAbilities()

public static Ability Get(Tiered<Ability> tiered, List<Ability> obtained)
{
return manager.Get(0, 1, tiered, a => ((TieredDependent<Ability>)tiered).MeetsRequirement(a, obtained)).Item1;
return manager.Get(0, 1, tiered, a => ((TieredDependent<Ability>)tiered).MeetsRequirement(a, obtained), true).Item1;
}

public static Ability GetNoDep(Tiered<Ability> tiered)
{
return manager.Get(0, 1, tiered, a => true).Item1;
return manager.Get(0, 1, tiered, a => true, true).Item1;
}
}
}
4 changes: 2 additions & 2 deletions Data/TieredManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public List<Tiered<T>> GetTiered(int rank, int count)
return Get(rank,maxCount, tiered);
}

public Tuple<T, int> Get(int rank, int maxCount, Tiered<T> tiered, Func<T, bool> meetsReq = null)
public Tuple<T, int> Get(int rank, int maxCount, Tiered<T> tiered, Func<T, bool> meetsReq = null, bool anyRandom = false)
{
List<Tuple<T, int>> possible = tiered == null ? new List<Tuple<T, int>>() : tiered.Get(rank,maxCount,meetsReq);
List<Tuple<T, int>> possible = tiered == null ? new List<Tuple<T, int>>() : tiered.Get(rank, maxCount, meetsReq, anyRandom);
if (possible.Count == 0)
return new Tuple<T, int>(default(T), 0);
return possible[RandomNum.RandInt(0, possible.Count - 1)];
Expand Down
2 changes: 1 addition & 1 deletion FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 22 additions & 6 deletions Randomizers/RandoCrystarium.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ public void RandomizeStats(Dictionary<int, Dictionary<CrystariumType, List<int>>

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)
Expand Down Expand Up @@ -299,6 +301,19 @@ public void ShuffleTechniques(string name, DataStoreWDB<DataStoreCrystarium> cry
}
}

public void ShuffleAnyRole(string name, DataStoreWDB<DataStoreCrystarium> 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)
Expand Down Expand Up @@ -327,7 +342,7 @@ public void RandomizeAbilities()
abilityNodes.Sort((a, b) => crystarium.DataList[a].Stage.CompareTo(crystarium.DataList[b].Stage));

List<Tiered<Ability>> 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++)
Expand All @@ -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))
Expand Down Expand Up @@ -380,7 +395,7 @@ public void RandomizeAbilities()
abilityNodes.Sort((a, b) => crystarium.DataList[a].Stage.CompareTo(crystarium.DataList[b].Stage));

List<Tiered<Ability>> 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]];
Expand All @@ -390,7 +405,7 @@ public void RandomizeAbilities()

Ability orig = GetAbility(name, crystarium, cryst);

if (orig.Role == Role.None)
if (orig.Special)
continue;

int newI;
Expand Down Expand Up @@ -425,7 +440,7 @@ public void RandomizeAbilities()
abilityNodes.Sort((a, b) => crystarium.DataList[a].Stage.CompareTo(crystarium.DataList[b].Stage));

List<Tiered<Ability>> 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]];
Expand All @@ -435,7 +450,7 @@ public void RandomizeAbilities()

Ability orig = GetAbility(name, crystarium, cryst);

if (orig.Role == Role.None)
if (orig.Special)
continue;

int newI;
Expand All @@ -453,6 +468,7 @@ public void RandomizeAbilities()
RandomNum.ClearRand();
}
}
ShuffleAnyRole(name, crystarium);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Randomizers/RandoEnemies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> list = scene.IndexesOf(Encoding.UTF8.GetBytes("key_shop_"));

List<string> shops = list.Select(i => Encoding.UTF8.GetString(scene.SubArray(i, 11))).ToList();
Expand Down
10 changes: 5 additions & 5 deletions Randomizers/RandoTreasure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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);
}
});
Expand Down

0 comments on commit 2653594

Please sign in to comment.