mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 16:27:21 +00:00
Extract toxtricity nature restriction
This commit is contained in:
parent
184c206910
commit
310882f375
4 changed files with 33 additions and 56 deletions
|
@ -21,13 +21,16 @@ public sealed record EncounterSlot9 : EncounterSlot
|
|||
|
||||
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 class Encounter9RNG
|
|||
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 class Encounter9RNG
|
|||
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 @@ public static class RaidRNG
|
|||
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 @@ public static class RaidRNG
|
|||
_ => (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 @@ public static class RaidRNG
|
|||
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};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue