mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
c6a961bda6
Due to how the game generates the Pokémon data, the first two (or three) RNG calls are used to set the 32-bit `EncryptionConstant` and `PID`. With 2x 32-bit and 1x 64-bit values, we can algorithmically reverse the movement & manipulation of bits to recover the initial seed. Notably, certain bits of the initial state are not captured by our first two (or three) outputs, so we must brute-force guess at the initial state, and verify the RNG's output yields the expected values. **With the ability for real-time Xoroshiro128+ seed reversal, we can now validate RNG correlations for SW/SH raid encounters natively within the program.** For now, the legality fail error message is extremely vague and any validated seed won't be "remembered" for the Legality Parse like other RNG methods. These seeds are 64bit, while every other "remembered" `PID/IV` seed-info is 32-bit. Co-Authored-By: SciresM <8676005+SciresM@users.noreply.github.com>
67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Nature ID values for the corresponding English nature name.
|
|
/// </summary>
|
|
public enum Nature : byte
|
|
{
|
|
Hardy = 0,
|
|
Lonely = 1,
|
|
Brave = 2,
|
|
Adamant = 3,
|
|
Naughty = 4,
|
|
Bold = 5,
|
|
Docile = 6,
|
|
Relaxed = 7,
|
|
Impish = 8,
|
|
Lax = 9,
|
|
Timid = 10,
|
|
Hasty = 11,
|
|
Serious = 12,
|
|
Jolly = 13,
|
|
Naive = 14,
|
|
Modest = 15,
|
|
Mild = 16,
|
|
Quiet = 17,
|
|
Bashful = 18,
|
|
Rash = 19,
|
|
Calm = 20,
|
|
Gentle = 21,
|
|
Sassy = 22,
|
|
Careful = 23,
|
|
Quirky = 24,
|
|
|
|
Random = 25,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Extension methods for <see cref="Nature"/>.
|
|
/// </summary>
|
|
public static class NatureUtil
|
|
{
|
|
/// <summary>
|
|
/// Gets the <see cref="Nature"/> value that corresponds to the provided <see cref="value"/>.
|
|
/// </summary>
|
|
/// <remarks>Actual nature values will be unchanged; only out-of-bounds values re-map to <see cref="Nature.Random"/>.</remarks>
|
|
public static Nature GetNature(int value) => value switch
|
|
{
|
|
< 0 or >= (int)Nature.Random => Nature.Random,
|
|
_ => (Nature)value,
|
|
};
|
|
|
|
/// <summary>
|
|
/// Checks if the provided <see cref="value"/> is a valid stored <see cref="Nature"/> value.
|
|
/// </summary>
|
|
/// <returns>True if value is an actual nature.</returns>
|
|
public static bool IsFixed(this Nature value) => value is >= 0 and < Nature.Random;
|
|
|
|
/// <summary>
|
|
/// Checks if the provided <see cref="value"/> is a possible mint nature.
|
|
/// </summary>
|
|
public static bool IsMint(this Nature value) => (value.IsFixed() && (byte)value % 6 != 0) || value == Nature.Serious;
|
|
|
|
/// <summary>
|
|
/// Checks if the provided <see cref="value"/> is a neutral nature which has no stat amps applied.
|
|
/// </summary>
|
|
public static bool IsNeutral(this Nature value) => value.IsFixed() && (byte)value % 6 == 0;
|
|
}
|