Add AllowRandomFusions to Trainer Randomizer Settings

Move BattleExclusiveForms outside of Tables7 since it'll be used for every Generation, and update it with Gen 8 species.
Also fix FormRandomizer allowing Zen/Galarian Zen Darmanitan.
This commit is contained in:
sora10pls
2020-07-01 15:16:03 -04:00
parent cd29f974e7
commit caf9e635b4
10 changed files with 66 additions and 71 deletions

View File

@@ -47,7 +47,7 @@ private void Randomize(EvolutionSet evos, int species)
if (evo.Method != 0)
{
evo.Species = RandSpec.GetRandomSpecies(evo.Species, species);
evo.Form = RandForm.GetRandomForme(evo.Species, false, true, Game.SWSH, Personal.Table);
evo.Form = RandForm.GetRandomForme(evo.Species, false, false, true, Game.SWSH, Personal.Table);
}
}
}

View File

@@ -14,7 +14,7 @@ public FormRandomizer(PersonalTable t)
Personal = t;
}
public int GetRandomForme(int species, bool mega, bool alola, bool galar, PersonalInfo[] stats = null)
public int GetRandomForme(int species, bool mega, bool fused, bool alola, bool galar, PersonalInfo[] stats = null)
{
if (stats == null)
stats = Personal.Table;
@@ -28,7 +28,6 @@ public int GetRandomForme(int species, bool mega, bool alola, bool galar, Person
case Sawsbuck:
return 31; // Random
case Greninja when !mega:
case Eternatus:
return 0;
case Scatterbug:
case Spewpa:
@@ -37,15 +36,13 @@ public int GetRandomForme(int species, bool mega, bool alola, bool galar, Person
case Minior:
return Util.Random.Next(7); // keep the core color a surprise
// Galarian Forms
case Meowth when galar: // Kanto, Alola, Galar
return Util.Random.Next(3);
case Darmanitan when galar: // Standard, Zen, Galar Standard, Galar Zen
return Util.Random.Next(4);
case Meowth when galar:
return Util.Random.Next(3); // Kanto, Alola, Galar
// some species have 1 invalid form among several other valid forms, handle them here
case Pikachu when Personal.TableLength == 1181:
case Slowbro when galar:
case Darmanitan:
{
int form = Util.Random.Next(stats[species].FormeCount - 1);
int banned = GetInvalidForm(species, galar, Personal);
@@ -61,7 +58,7 @@ public int GetRandomForme(int species, bool mega, bool alola, bool galar, Person
return Util.Random.Next(2);
if (galar && Legal.EvolveToGalarForms.Contains(species))
return Util.Random.Next(2);
if (!Legal.BattleExclusiveForms.Contains(species) || mega)
if (!Legal.BattleExclusiveForms.Contains(species) || mega || fused && Legal.BattleFusions.Contains(species))
return Util.Random.Next(stats[species].FormeCount); // Slot-Random
return 0;
}
@@ -72,6 +69,7 @@ public int GetInvalidForm(int species, bool galar, PersonalTable stats)
{
(int)Pikachu when stats.TableLength == 1181 => 8, // LGPE Partner Pikachu
(int)Slowbro when galar => 1, // Mega Slowbro
(int)Darmanitan => 1, // Zen Mode
_ => throw new ArgumentOutOfRangeException(nameof(species))
};
}

View File

@@ -50,6 +50,9 @@ public class TrainerRandSettings
[Category(PKM), Description("Allows random Mega Forms when randomizing species.")]
public bool AllowRandomMegaForms { get; set; } = false;
[Category(PKM), Description("Allows random Fused PKM when randomizing species.")]
public bool AllowRandomFusions { get; set; } = false;
[Category(PKM), Description("Allows random Held Items when randomizing species.")]
public bool AllowRandomHeldItems { get; set; } = false;

View File

@@ -162,7 +162,7 @@ private void RandomizeSpecFormItem(IPokeData pk, int Type)
else // every other pkm
{
pk.Species = RandSpec.GetRandomSpeciesType(pk.Species, Type);
pk.Form = RandForm.GetRandomForme(pk.Species, Settings.AllowRandomMegaForms, true, true, Personal.Table);
pk.Form = RandForm.GetRandomForme(pk.Species, Settings.AllowRandomMegaForms, Settings.AllowRandomFusions, true, true, Personal.Table);
}
}
@@ -181,7 +181,7 @@ private void RandomizeSpecForm(TrainerPoke7b pk, int type)
else
{
pk.Species = RandSpec.GetRandomSpeciesType(pk.Species, type);
pk.Form = RandForm.GetRandomForme(pk.Species, Settings.AllowRandomMegaForms, true, false, Personal.Table);
pk.Form = RandForm.GetRandomForme(pk.Species, Settings.AllowRandomMegaForms, Settings.AllowRandomFusions, true, false, Personal.Table);
}
}
@@ -255,7 +255,7 @@ private void UpdatePKMFromSettings(TrainerPoke pk)
return;
c.Species = AllowedGigantamaxes[Util.Random.Next(AllowedGigantamaxes.Length)];
c.Form = c.Species == (int)Species.Pikachu || c.Species == (int)Species.Meowth ? 0 : RandForm.GetRandomForme(c.Species, false, false, false, Personal.Table); // Pikachu & Meowth altforms can't gmax
c.Form = c.Species == (int)Species.Pikachu || c.Species == (int)Species.Meowth ? 0 : RandForm.GetRandomForme(c.Species, false, false, false, false, Personal.Table); // Pikachu & Meowth altforms can't gmax
}
if (Settings.MaxDynamaxLevel && c.CanDynamax)
c.DynamaxLevel = 10;

View File

@@ -191,5 +191,44 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount)
406, 417, 420, 430, 438, 446, 453, 483, 492, 499,
503, 504, 525, 529, 583, 585, 605, 742
};
public static readonly HashSet<int> BattleForms = new HashSet<int>
{
(int)Species.Castform,
(int)Species.Cherrim,
(int)Species.Meloetta,
(int)Species.Aegislash,
(int)Species.Xerneas,
(int)Species.Wishiwashi,
(int)Species.Mimikyu,
(int)Species.Cramorant,
(int)Species.Eiscue,
(int)Species.Morpeko,
(int)Species.Zacian,
(int)Species.Zamazenta,
(int)Species.Eternatus,
};
public static readonly HashSet<int> BattleMegas = new HashSet<int>
{
// XY
(int)Species.Venusaur, (int)Species.Charizard, (int)Species.Blastoise, (int)Species.Alakazam, (int)Species.Gengar,
(int)Species.Kangaskhan, (int)Species.Pinsir, (int)Species.Gyarados, (int)Species.Aerodactyl, (int)Species.Mewtwo,
(int)Species.Ampharos, (int)Species.Scizor, (int)Species.Heracross, (int)Species.Houndoom, (int)Species.Tyranitar,
(int)Species.Blaziken, (int)Species.Gardevoir, (int)Species.Mawile, (int)Species.Aggron, (int)Species.Medicham,
(int)Species.Manectric, (int)Species.Banette, (int)Species.Absol, (int)Species.Latias, (int)Species.Latios,
(int)Species.Garchomp, (int)Species.Lucario, (int)Species.Abomasnow,
// AO
(int)Species.Beedrill, (int)Species.Pidgeot, (int)Species.Slowbro, (int)Species.Steelix,
(int)Species.Sceptile, (int)Species.Swampert, (int)Species.Sableye, (int)Species.Sharpedo, (int)Species.Camerupt,
(int)Species.Altaria, (int)Species.Glalie, (int)Species.Salamence, (int)Species.Metagross, (int)Species.Rayquaza,
(int)Species.Lopunny, (int)Species.Gallade,
(int)Species.Audino, (int)Species.Diancie,
};
public static readonly HashSet<int> BattlePrimals = new HashSet<int> { 382, 383 }; // Kyogre and Groudon
public static readonly HashSet<int> BattleFusions = new HashSet<int> { 646, 800 }; // Kyurem and Necrozma
public static HashSet<int> BattleExclusiveForms = new HashSet<int>(BattleForms.Concat(BattleMegas.Concat(BattlePrimals).Concat(BattleFusions)));
}
}

View File

@@ -233,41 +233,5 @@ public static partial class Legal
};
public static readonly ushort[] HeldItemsBuy_SM = new ushort[1].Concat(Pouch_Items_SM).Concat(Pouch_Medicine_SM).ToArray();
public static readonly HashSet<int> BattleForms = new HashSet<int>
{
(int)Species.Castform,
(int)Species.Cherrim,
(int)Species.Darmanitan,
(int)Species.Meloetta,
(int)Species.Aegislash,
(int)Species.Xerneas,
(int)Species.Wishiwashi,
(int)Species.Mimikyu,
};
public static readonly HashSet<int> BattleMegas = new HashSet<int>
{
// XY
(int)Species.Venusaur, (int)Species.Charizard, (int)Species.Blastoise, (int)Species.Alakazam, (int)Species.Gengar,
(int)Species.Kangaskhan, (int)Species.Pinsir, (int)Species.Gyarados, (int)Species.Aerodactyl, (int)Species.Mewtwo,
(int)Species.Ampharos, (int)Species.Scizor, (int)Species.Heracross, (int)Species.Houndoom, (int)Species.Tyranitar,
(int)Species.Blaziken, (int)Species.Gardevoir, (int)Species.Mawile, (int)Species.Aggron, (int)Species.Medicham,
(int)Species.Manectric, (int)Species.Banette, (int)Species.Absol, (int)Species.Latias, (int)Species.Latios,
(int)Species.Garchomp, (int)Species.Lucario, (int)Species.Abomasnow,
// AO
(int)Species.Beedrill, (int)Species.Pidgeot, (int)Species.Slowbro, (int)Species.Steelix,
(int)Species.Sceptile, (int)Species.Swampert, (int)Species.Sableye, (int)Species.Sharpedo, (int)Species.Camerupt,
(int)Species.Altaria, (int)Species.Glalie, (int)Species.Salamence, (int)Species.Metagross, (int)Species.Rayquaza,
(int)Species.Lopunny, (int)Species.Gallade,
(int)Species.Audino, (int)Species.Diancie,
// USUM
(int)Species.Necrozma, // Ultra
};
public static readonly HashSet<int> BattlePrimals = new HashSet<int> { 382, 383 };
public static HashSet<int> BattleExclusiveForms = new HashSet<int>(BattleForms.Concat(BattleMegas.Concat(BattlePrimals)));
}
}

View File

@@ -125,7 +125,7 @@ void Randomize()
foreach (var t in objs)
{
t.Species = (Species)srand.GetRandomSpecies((int)t.Species);
t.Form = frand.GetRandomForme((int)t.Species, false, true, false, ROM.Data.PersonalData.Table);
t.Form = frand.GetRandomForme((int)t.Species, false, false, true, false, ROM.Data.PersonalData.Table);
t.Nature = Nature.Random25;
t.Gender = FixedGender.Random;
t.Shiny = Shiny.Random;
@@ -162,7 +162,7 @@ void Randomize()
{
t.Species = (Species)srand.GetRandomSpecies((int)t.Species);
t.RequiredSpecies = (Species)srand.GetRandomSpecies((int)t.Species);
t.Form = frand.GetRandomForme((int)t.Species, false, true, false, ROM.Data.PersonalData.Table);
t.Form = frand.GetRandomForme((int)t.Species, false, false, true, false, ROM.Data.PersonalData.Table);
t.RequiredForm = 0; // can't catch wild alolan forms
t.Nature = Nature.Random - 1;
t.Gender = FixedGender.Random;
@@ -200,7 +200,7 @@ void Randomize()
{
var t = objs[i];
t.Species = (Species)srand.GetRandomSpecies((int)t.Species);
t.Form = frand.GetRandomForme((int)t.Species, false, true, false, ROM.Data.PersonalData.Table);
t.Form = frand.GetRandomForme((int)t.Species, false, false, true, false, ROM.Data.PersonalData.Table);
t.Nature = Nature.Random25;
t.Gender = FixedGender.Random;
t.Shiny = Shiny.Random;

View File

@@ -244,7 +244,7 @@ void Randomize()
foreach (var p in t.Entries)
{
p.Species = srand.GetRandomSpecies(p.Species);
p.AltForm = frand.GetRandomForme(p.Species, false, true, true, ROM.Data.PersonalData.Table);
p.AltForm = frand.GetRandomForme(p.Species, false, false, true, true, ROM.Data.PersonalData.Table);
p.Ability = 4; // "A4" -- 1, 2, or H
p.Gender = 0; // random
p.IsGigantamax = false; // don't allow gmax flag on non-gmax species
@@ -349,7 +349,7 @@ void Randomize()
if (t.Species >= Species.Zacian && t.Species <= Species.Eternatus) // Eternatus crashes when changed, keep Zacian and Zamazenta to make final boss battle fair
continue;
t.Species = (Species)srand.GetRandomSpecies((int)t.Species);
t.AltForm = frand.GetRandomForme((int)t.Species, false, true, true, ROM.Data.PersonalData.Table);
t.AltForm = frand.GetRandomForme((int)t.Species, false, false, true, true, ROM.Data.PersonalData.Table);
t.Ability = Randomization.Util.Random.Next(1, 4); // 1, 2, or H
t.HeldItem = PossibleHeldItems[Randomization.Util.Random.Next(PossibleHeldItems.Length)];
t.Nature = Nature.Random25;
@@ -397,12 +397,12 @@ void Randomize()
if (t.CanGigantamax)
{
t.Species = (Species)Legal.GigantamaxForms[Randomization.Util.Random.Next(Legal.GigantamaxForms.Length)];
t.AltForm = t.Species == Species.Pikachu || t.Species == Species.Meowth ? 0 : frand.GetRandomForme((int)t.Species, false, false, false, ROM.Data.PersonalData.Table); // Pikachu & Meowth altforms can't gmax
t.AltForm = t.Species == Species.Pikachu || t.Species == Species.Meowth ? 0 : frand.GetRandomForme((int)t.Species, false, false, false, false, ROM.Data.PersonalData.Table); // Pikachu & Meowth altforms can't gmax
}
else
{
t.Species = (Species)srand.GetRandomSpecies((int)t.Species);
t.AltForm = frand.GetRandomForme((int)t.Species, false, true, true, ROM.Data.PersonalData.Table);
t.AltForm = frand.GetRandomForme((int)t.Species, false, false, true, true, ROM.Data.PersonalData.Table);
}
t.Ability = Randomization.Util.Random.Next(1, 4); // 1, 2, or H
@@ -450,7 +450,7 @@ void Randomize()
{
// what you receive
t.Species = (Species)srand.GetRandomSpecies((int)t.Species);
t.AltForm = frand.GetRandomForme((int)t.Species, false, true, true, ROM.Data.PersonalData.Table);
t.AltForm = frand.GetRandomForme((int)t.Species, false, false, true, true, ROM.Data.PersonalData.Table);
t.Ability = Randomization.Util.Random.Next(1, 4); // 1, 2, or H
t.Ball = (Ball)Randomization.Util.Random.Next(1, 15); // packed bit, only allows for 15 balls
t.HeldItem = PossibleHeldItems[Randomization.Util.Random.Next(PossibleHeldItems.Length)];
@@ -463,7 +463,7 @@ void Randomize()
// what you trade
t.RequiredSpecies = (Species)srand.GetRandomSpecies((int)t.RequiredSpecies);
t.RequiredForm = frand.GetRandomForme((int)t.RequiredSpecies, false, true, true, ROM.Data.PersonalData.Table);
t.RequiredForm = frand.GetRandomForme((int)t.RequiredSpecies, false, false, true, true, ROM.Data.PersonalData.Table);
t.RequiredNature = Nature.Random25; // any
}
}
@@ -476,17 +476,6 @@ void Randomize()
arc[0] = FlatBufferConverter.SerializeFrom(objs);
}
private bool CreateGenericEditor<TA, T1>(ref byte[] data, string title, string[] names = null) where TA : IFlatBufferArchive<T1> where T1 : class
{
var objs = FlatBufferConverter.DeserializeFrom<TA>(data);
if (names == null)
names = Enumerable.Range(1, objs.Table.Length).Select(z => z.ToString()).ToArray();
var result = PopEdit(objs.Table, title, names);
if (result)
data = FlatBufferConverter.SerializeFrom(objs);
return result;
}
private bool PopEdit<T>(T[] data, string title, string[] names) where T : class
{
var cache = new DirectCache<T>(data);

View File

@@ -487,16 +487,18 @@ private string GetTrainerString(VsTrainer Trainer)
sb.AppendLine("======");
sb.Append(file).Append(" - ").Append(trClass[tr.Class]).Append(" ").AppendLine(name);
sb.AppendLine("======");
sb.Append("Pokemon: ").Append(tr.NumPokemon).AppendLine();
sb.Append("Pokémon: ").Append(tr.NumPokemon).AppendLine();
for (int i = 0; i < tr.NumPokemon; i++)
{
var pk = team[i];
if (pk.Shiny)
sb.Append("Shiny ");
sb.Append(specieslist[pk.Species]);
if (pk.Form > 0)
sb.Append("-" + pk.Form);
sb.Append(" (Lv. ").Append(pk.Level).Append(") ");
if (pk.HeldItem > 0)
sb.Append("@").Append(itemlist[pk.HeldItem]);
sb.Append("@ ").Append(itemlist[pk.HeldItem]);
if (pk.Nature != 0)
sb.Append(" (Nature: ").Append(natures[pk.Nature]).Append(")");

View File

@@ -192,7 +192,7 @@ void ApplyRand(IList<EncounterSlot8> slots)
}
s.Species = rand.GetRandomSpecies(s.Species);
s.Form = fr.GetRandomForme(s.Species, false, true, true, ROM.Data.PersonalData.Table);
s.Form = fr.GetRandomForme(s.Species, false, false, true, true, ROM.Data.PersonalData.Table);
if (fill)
s.Probability = RandomScaledRates[slots.Count][i];
}