mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Update gen4 gift PIDIV checks
fix method1 PIDIV creation, check for antishiny manaphy gift
This commit is contained in:
parent
0cb17ccb42
commit
9e3ee6eacb
3 changed files with 24 additions and 13 deletions
|
@ -71,7 +71,7 @@ namespace PKHeX.Core
|
|||
var deferred = new List<IEncounterable>();
|
||||
foreach (var z in GenerateRawEncounters4(pkm))
|
||||
{
|
||||
if (info.PIDIV.Type.IsCompatible4(z))
|
||||
if (info.PIDIV.Type.IsCompatible4(z, pkm))
|
||||
yield return z;
|
||||
else
|
||||
deferred.Add(z);
|
||||
|
@ -903,12 +903,10 @@ namespace PKHeX.Core
|
|||
|
||||
if (pkm.Species == 490 && (pkm.WasEgg || pkm.IsEgg)) // Manaphy
|
||||
{
|
||||
if (pkm.IsEgg && pkm.Format != 4) // transferred
|
||||
yield break;
|
||||
int loc = pkm.IsEgg ? pkm.Met_Location : pkm.Egg_Location;
|
||||
bool valid = loc == 2002; // Link Trade Egg
|
||||
valid |= loc == 3001 && !pkm.IsShiny; // Ranger & notShiny
|
||||
if (pkm.IsEgg && !pkm.IsNative) // transferred
|
||||
valid = false;
|
||||
if (valid)
|
||||
if (loc == 2002 || loc == 3001) // Link Trade Egg || Ranger
|
||||
yield return new PGT { Data = { [0] = 7, [8] = 1 } };
|
||||
yield break;
|
||||
}
|
||||
|
|
|
@ -534,7 +534,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsCompatible4(this PIDType val, IEncounterable encounter)
|
||||
public static bool IsCompatible4(this PIDType val, IEncounterable encounter, PKM pkm)
|
||||
{
|
||||
switch (encounter)
|
||||
{
|
||||
|
@ -544,12 +544,23 @@ namespace PKHeX.Core
|
|||
return s.Shiny == true ? val == PIDType.ChainShiny : val == PIDType.Method_1;
|
||||
case EncounterSlot _:
|
||||
return val == PIDType.Method_1;
|
||||
case PGT g: // manaphy
|
||||
return val == PIDType.Method_1 || val == PIDType.None; // regular && antishiny
|
||||
case PGT _: // manaphy
|
||||
return IsG4ManaphyPIDValid(val, pkm);
|
||||
default:
|
||||
return val == PIDType.None;
|
||||
}
|
||||
}
|
||||
private static bool IsG4ManaphyPIDValid(PIDType val, PKM pkm)
|
||||
{
|
||||
if (val == PIDType.Method_1)
|
||||
return pkm.WasTradedEgg || !pkm.IsShiny; // can't be shiny on received game
|
||||
if (val != PIDType.G4MGAntiShiny)
|
||||
return false;
|
||||
if (pkm.WasTradedEgg)
|
||||
return true;
|
||||
var shinyPID = RNG.ARNG.Prev(pkm.PID);
|
||||
return (pkm.TID ^ pkm.SID ^ (shinyPID & 0xFFFF) ^ (shinyPID >> 16)) < 8; // shiny proc
|
||||
}
|
||||
|
||||
private static readonly PIDType[] MethodH = { PIDType.Method_1, PIDType.Method_2, PIDType.Method_4 };
|
||||
private static readonly PIDType[] MethodH14 = { PIDType.Method_1, PIDType.Method_4 };
|
||||
|
|
|
@ -243,20 +243,22 @@ namespace PKHeX.Core
|
|||
uint testPID = pid1 | pid2 << 16;
|
||||
|
||||
// Call the ARNG to change the PID
|
||||
testPID = testPID * 0x6c078965 + 1;
|
||||
testPID = RNG.ARNG.Next(testPID);
|
||||
|
||||
pid1 = testPID & 0xFFFF;
|
||||
pid2 = testPID >> 16;
|
||||
}
|
||||
pk4.PID = pid1 | (pid2 << 16);
|
||||
}
|
||||
if (!IsManaphyEgg)
|
||||
seed = Util.rnd32(); // reseed, do not have method 1 correlation
|
||||
|
||||
// Generate IVs
|
||||
if (pk4.IV32 == 0)
|
||||
{
|
||||
uint iv1 = PKX.LCRNG(ref seed) >> 16;
|
||||
uint iv2 = PKX.LCRNG(ref seed) >> 16;
|
||||
pk4.IV32 = (iv1 | iv2 << 16) & 0x3FFFFFFF;
|
||||
uint iv1 = (PKX.LCRNG(ref seed) >> 16) & 0x7FFF;
|
||||
uint iv2 = (PKX.LCRNG(ref seed) >> 16) & 0x7FFF;
|
||||
pk4.IV32 = iv1 | iv2 << 15;
|
||||
}
|
||||
|
||||
// Generate Met Info
|
||||
|
|
Loading…
Reference in a new issue