mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-28 09:25:21 -05:00
Misc tweaks
Fixes shiny rayquaza some lowering int->byte Fix event3 random restricted seed fetch for gender Fix gen8a encdb filters excluding static encounters, now will be properly excluded
This commit is contained in:
@@ -54,7 +54,7 @@ public bool MoveNext()
|
||||
case YieldState.EventLocal:
|
||||
if (TryGetNext(EncounterEvent.EGDB_G8A))
|
||||
return true;
|
||||
Index = 0; State = YieldState.Static; goto case YieldState.Static;
|
||||
Index = 0; goto case YieldState.StaticStart;
|
||||
|
||||
case YieldState.StaticStart:
|
||||
if (!Flags.HasFlag(EncounterTypeGroup.Static))
|
||||
|
||||
@@ -231,7 +231,7 @@ public static uint GetRandomRestrictedGenderBit0(uint seed, byte gender5)
|
||||
while (true)
|
||||
{
|
||||
var u16 = seed & 0xFFFF;
|
||||
var rand5 = LCRNG.Next5(seed) >> 16;
|
||||
var rand5 = LCRNG.Next5(u16) >> 16;
|
||||
if (GetGenderBit0(rand5) == gender5)
|
||||
return u16;
|
||||
seed = LCRNG.Next(seed);
|
||||
|
||||
@@ -167,7 +167,7 @@ public static bool TryApply(PK8 pk, ulong seed, Span<int> ivs, in GenerateParam8
|
||||
ForceShinyState(false, ref pid, trID, 0);
|
||||
isShiny = false;
|
||||
}
|
||||
if (isShiny != criteria.Shiny.IsShiny())
|
||||
if (param.Shiny is Shiny.Random && isShiny != criteria.Shiny.IsShiny())
|
||||
return false;
|
||||
|
||||
if (isShiny)
|
||||
|
||||
@@ -40,7 +40,7 @@ public static bool TryApply64<TEnc>(this TEnc enc, PK9 pk, in ulong init, in Gen
|
||||
for (int ctr = 0; ctr < maxCtr; ctr++)
|
||||
{
|
||||
ulong seed = rand.Next(); // fake cryptosecure
|
||||
if (!GenerateData(pk, param, criteria, seed))
|
||||
if (!GenerateData(pk, param, criteria, seed, param.IVs.IsSpecified))
|
||||
continue;
|
||||
|
||||
var type = Tera9RNG.GetTeraType(seed, enc.TeraType, enc.Species, enc.Form);
|
||||
@@ -60,7 +60,7 @@ public static bool GenerateData(PK9 pk, in GenerateParam9 enc, EncounterCriteria
|
||||
pk.EncryptionConstant = (uint)rand.NextInt(uint.MaxValue);
|
||||
pk.PID = GetAdaptedPID(ref rand, pk, enc);
|
||||
|
||||
if (criteria.Shiny.IsShiny() != pk.IsShiny)
|
||||
if (enc.Shiny is Shiny.Random && criteria.Shiny.IsShiny() != pk.IsShiny)
|
||||
return false;
|
||||
|
||||
const int UNSET = -1;
|
||||
@@ -120,16 +120,11 @@ public static bool GenerateData(PK9 pk, in GenerateParam9 enc, EncounterCriteria
|
||||
var nature = enc.Nature != Nature.Random ? enc.Nature : enc.Species == (int)Species.Toxtricity
|
||||
? ToxtricityUtil.GetRandomNature(ref rand, pk.Form)
|
||||
: (Nature)rand.NextInt(25);
|
||||
pk.Nature = pk.StatNature = nature;
|
||||
|
||||
// Compromise on Nature -- some are fixed, some are random. If the request wants a specific nature, just mint it.
|
||||
var requestNature = criteria.GetNature();
|
||||
if (criteria.Nature != Nature.Random && nature != requestNature)
|
||||
{
|
||||
if (!requestNature.IsMint())
|
||||
return false;
|
||||
pk.StatNature = requestNature;
|
||||
}
|
||||
if (criteria.IsSpecifiedNature() && !criteria.IsSatisfiedNature(nature))
|
||||
return false;
|
||||
pk.Nature = pk.StatNature = nature;
|
||||
|
||||
pk.HeightScalar = enc.Height != 0 ? enc.Height : (byte)(rand.NextInt(0x81) + rand.NextInt(0x80));
|
||||
pk.WeightScalar = enc.Weight != 0 ? enc.Weight : (byte)(rand.NextInt(0x81) + rand.NextInt(0x80));
|
||||
@@ -302,7 +297,7 @@ private static uint GetAdaptedPID(ref Xoroshiro128Plus rand, PKM pk, in Generate
|
||||
return pid;
|
||||
}
|
||||
|
||||
public static byte GetGender(in int ratio, in ulong rand100) => ratio switch
|
||||
public static byte GetGender(in byte ratio, in ulong rand100) => ratio switch
|
||||
{
|
||||
0x1F => rand100 < 12 ? (byte)1 : (byte)0, // 12.5%
|
||||
0x3F => rand100 < 25 ? (byte)1 : (byte)0, // 25%
|
||||
|
||||
@@ -24,7 +24,7 @@ public override void Verify(LegalityAnalysis data)
|
||||
{
|
||||
// Trading from PLA origin -> SW/SH will replace the Legends: Arceus ball with a regular Poké Ball
|
||||
// Enamorus is a special case where the ball is not replaced with a Poké Ball (it's a Cherish Ball)
|
||||
PK8 when enc.Version == GameVersion.PLA && enc is not IFixedBall { FixedBall: (>0 and < Strange) } => Poke,
|
||||
PK8 when enc.Version == GameVersion.PLA && enc is not IFixedBall { FixedBall: (> 0 and < Strange) } => Poke,
|
||||
|
||||
// No replacement done.
|
||||
_ => NoBallReplace,
|
||||
|
||||
@@ -125,12 +125,12 @@ private void VerifyOTMisc(LegalityAnalysis data, bool neverOT)
|
||||
VerifyOTFriendship(data, neverOT, Info.Generation, pk);
|
||||
}
|
||||
|
||||
private void VerifyOTFriendship(LegalityAnalysis data, bool neverOT, int origin, PKM pk)
|
||||
private void VerifyOTFriendship(LegalityAnalysis data, bool neverOT, byte generation, PKM pk)
|
||||
{
|
||||
if (origin < 0)
|
||||
if (generation == 0) // other things are invalid, don't bother checking
|
||||
return;
|
||||
|
||||
if (origin <= 2)
|
||||
if (generation <= 2)
|
||||
{
|
||||
VerifyOTFriendshipVC12(data, pk);
|
||||
return;
|
||||
|
||||
@@ -52,7 +52,7 @@ public sealed class GameDataPB7 : HomeOptional1, IGameDataSide<PB7>, IScaledSize
|
||||
public byte FieldEventFatigue2 { get => Data[0x28]; set => Data[0x28] = value; }
|
||||
public byte Fullness { get => Data[0x29]; set => Data[0x29] = value; }
|
||||
public byte Rank { get => Data[0x2A]; set => Data[0x2A] = value; }
|
||||
public int OriginalTrainerAffection { get => Data[0x2B]; set => Data[0x2B] = (byte)value; }
|
||||
public byte OriginalTrainerAffection { get => Data[0x2B]; set => Data[0x2B] = (byte)value; }
|
||||
public byte OriginalTrainerMemoryIntensity { get => Data[0x2C]; set => Data[0x2C] = value; }
|
||||
public byte OriginalTrainerMemory { get => Data[0x2D]; set => Data[0x2D] = value; }
|
||||
public ushort OriginalTrainerMemoryVariable { get => ReadUInt16LittleEndian(Data[0x2E..]); set => WriteUInt16LittleEndian(Data[0x2E..], value); }
|
||||
|
||||
@@ -16,13 +16,13 @@ public static class ObedienceExtensions
|
||||
/// <summary>
|
||||
/// Suggests the <see cref="IObedienceLevelReadOnly.ObedienceLevel"/> for the entity.
|
||||
/// </summary>
|
||||
public static byte GetSuggestedObedienceLevel(this IObedienceLevelReadOnly _, PKM entity, int originalMet)
|
||||
public static byte GetSuggestedObedienceLevel(this IObedienceLevelReadOnly _, PKM entity, byte originalMet)
|
||||
{
|
||||
if (entity.Species is (int)Species.Koraidon or (int)Species.Miraidon && entity is PK9 { FormArgument: not 0 })
|
||||
return 0; // Box Legend ride-able is default 0. Everything else is met level!
|
||||
if (entity.Version is not (GameVersion.SL or GameVersion.VL))
|
||||
return entity.CurrentLevel; // foreign, play it safe.
|
||||
// Can just assume min-level
|
||||
return (byte)originalMet;
|
||||
return originalMet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2134,8 +2134,11 @@ private void L_Obedience_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Entity is not IObedienceLevel l)
|
||||
return;
|
||||
|
||||
var met = Util.ToInt32(TB_MetLevel.Text);
|
||||
var suggest = l.GetSuggestedObedienceLevel(Entity, met);
|
||||
var metLevel = (byte)Math.Clamp(0, 100, met);
|
||||
var suggest = l.GetSuggestedObedienceLevel(Entity, metLevel);
|
||||
|
||||
var current = Util.ToInt32(TB_ObedienceLevel.Text);
|
||||
if (suggest != current)
|
||||
TB_ObedienceLevel.Text = suggest.ToString();
|
||||
|
||||
Reference in New Issue
Block a user