mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 17:56:57 -05:00
Extract toxtricity nature restriction
This commit is contained in:
@@ -21,13 +21,16 @@ protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteri
|
||||
|
||||
var pk9 = (PK9)pk;
|
||||
pk9.Obedience_Level = (byte)pk.Met_Level;
|
||||
var type = Tera9RNG.GetTeraTypeFromPersonal(Species, Form, Util.Rand.Rand64());
|
||||
var rand = new Xoroshiro128Plus(Util.Rand.Rand64());
|
||||
var type = Tera9RNG.GetTeraTypeFromPersonal(Species, Form, rand.Next());
|
||||
pk9.TeraTypeOriginal = (MoveType)type;
|
||||
if (criteria.TeraType != -1 && type != criteria.TeraType)
|
||||
pk9.SetTeraType(type); // sets the override type
|
||||
if (Gender != -1)
|
||||
pk.Gender = (byte)Gender;
|
||||
pk9.Scale = PokeSizeUtil.GetRandomScalar();
|
||||
if (Species == (int)Core.Species.Toxtricity)
|
||||
pk.Nature = ToxtricityUtil.GetRandomNature(ref rand, Form);
|
||||
pk9.EncryptionConstant = Util.Rand32();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,9 @@ public static bool GenerateData(PK9 pk, in GenerateParam9 enc, EncounterCriteria
|
||||
return false;
|
||||
pk.Gender = gender;
|
||||
|
||||
var nature = (int)rand.NextInt(25);
|
||||
byte nature = pk.Species == (int)Species.Toxtricity
|
||||
? ToxtricityUtil.GetRandomNature(ref rand, pk.Form)
|
||||
: (byte)rand.NextInt(25);
|
||||
if (criteria.Nature != Nature.Random && nature != (int)criteria.Nature)
|
||||
return false;
|
||||
pk.Nature = pk.StatNature = nature;
|
||||
@@ -223,7 +225,9 @@ public static bool IsMatch(PKM pk, in GenerateParam9 enc, in ulong seed)
|
||||
if (pk.Gender != gender)
|
||||
return false;
|
||||
|
||||
var nature = (int)rand.NextInt(25);
|
||||
int nature = pk.Species == (int)Species.Toxtricity
|
||||
? ToxtricityUtil.GetRandomNature(ref rand, pk.Form)
|
||||
: (byte)rand.NextInt(25);
|
||||
if (pk.Nature != nature)
|
||||
return false;
|
||||
|
||||
|
||||
13
PKHeX.Core/Legality/RNG/Methods/ToxtricityUtil.cs
Normal file
13
PKHeX.Core/Legality/RNG/Methods/ToxtricityUtil.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace PKHeX.Core;
|
||||
|
||||
public static class ToxtricityUtil
|
||||
{
|
||||
private static readonly byte[] Nature0 = { 3, 4, 2, 8, 9, 19, 22, 11, 13, 14, 0, 6, 24 };
|
||||
private static readonly byte[] Nature1 = { 1, 5, 7, 10, 12, 15, 16, 17, 18, 20, 21, 23 };
|
||||
|
||||
public static byte GetRandomNature(ref Xoroshiro128Plus rand, byte form)
|
||||
{
|
||||
var table = form == 0 ? Nature0 : Nature1;
|
||||
return table[rand.NextInt((uint)table.Length)];
|
||||
}
|
||||
}
|
||||
@@ -143,34 +143,12 @@ private static bool Verify(PKM pk, ulong seed, Span<int> ivs, int iv_count, int
|
||||
break;
|
||||
}
|
||||
|
||||
if (nature_param == -1)
|
||||
{
|
||||
if (pk.Species == (int) Species.Toxtricity && pk.Form == 0)
|
||||
{
|
||||
var table = Nature0;
|
||||
var choice = table[rng.NextInt((uint)table.Length)];
|
||||
if (pk.Nature != choice)
|
||||
return false;
|
||||
}
|
||||
else if (pk.Species == (int) Species.Toxtricity && pk.Form == 1)
|
||||
{
|
||||
var table = Nature1;
|
||||
var choice = table[rng.NextInt((uint)table.Length)];
|
||||
if (pk.Nature != choice)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var nature = (int)rng.NextInt(25);
|
||||
if (pk.Nature != nature)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pk.Nature != nature_param)
|
||||
return false;
|
||||
}
|
||||
int nature = nature_param != -1 ? nature_param
|
||||
: pk.Species == (int)Species.Toxtricity
|
||||
? ToxtricityUtil.GetRandomNature(ref rng, pk.Form)
|
||||
: (byte)rng.NextInt(25);
|
||||
if (pk.Nature != nature)
|
||||
return false;
|
||||
|
||||
if (pk is IScaledSize s)
|
||||
{
|
||||
@@ -272,28 +250,10 @@ private static bool ApplyDetailsTo(PKM pk, ulong seed, Span<int> ivs, int iv_cou
|
||||
_ => (int) rng.NextInt(252) + 1 < gender_ratio ? 1 : 0,
|
||||
};
|
||||
|
||||
int nature;
|
||||
if (nature_param == -1)
|
||||
{
|
||||
if (pk.Species == (int)Species.Toxtricity && pk.Form == 0)
|
||||
{
|
||||
var table = Nature0;
|
||||
nature = table[rng.NextInt((uint)table.Length)];
|
||||
}
|
||||
else if (pk.Species == (int)Species.Toxtricity && pk.Form == 1)
|
||||
{
|
||||
var table = Nature1;
|
||||
nature = table[rng.NextInt((uint)table.Length)];
|
||||
}
|
||||
else
|
||||
{
|
||||
nature = (int)rng.NextInt(25);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nature = nature_param;
|
||||
}
|
||||
int nature = nature_param != -1 ? nature_param
|
||||
: pk.Species == (int)Species.Toxtricity
|
||||
? ToxtricityUtil.GetRandomNature(ref rng, pk.Form)
|
||||
: (byte)rng.NextInt(25);
|
||||
|
||||
pk.StatNature = pk.Nature = nature;
|
||||
|
||||
@@ -323,7 +283,4 @@ private static uint GetShinyXor(uint pid, uint oid)
|
||||
var xor = pid ^ oid;
|
||||
return (xor ^ (xor >> 16)) & 0xFFFF;
|
||||
}
|
||||
|
||||
private static readonly byte[] Nature0 = {3, 4, 2, 8, 9, 19, 22, 11, 13, 14, 0, 6, 24};
|
||||
private static readonly byte[] Nature1 = {1, 5, 7, 10, 12, 15, 16, 17, 18, 20, 21, 23};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user