mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 12:35:20 -05:00
More generator updates
adds pokewalker handling now stuck on GSC Trade Spearow (likely not setting OT details as needed)
This commit is contained in:
parent
df4fc96f4d
commit
b353701d3e
|
|
@ -80,6 +80,7 @@ public PKM ConvertToPKM(ITrainerInfo SAV)
|
|||
pk.Language = lang;
|
||||
pk.CurrentLevel = level;
|
||||
pk.Version = (int)version;
|
||||
pk.AltForm = Form;
|
||||
pk.Nickname = PKX.GetSpeciesNameGeneration(Species, lang, Generation);
|
||||
pk.Ball = GetBall();
|
||||
gender = pk.GetSaneGender(gender);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public PKM ConvertToPKM(ITrainerInfo SAV)
|
|||
else
|
||||
{
|
||||
var pidtype = GetPIDType();
|
||||
PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, Ability >> 1, gender);
|
||||
PIDGenerator.SetRandomWildPID(pk, pk.Format, nature, Ability >> 1, gender, pidtype);
|
||||
}
|
||||
|
||||
if (IVs != null)
|
||||
|
|
|
|||
|
|
@ -136,6 +136,12 @@ public static void SetValuesFromSeed(PKM pk, PIDType type, uint seed)
|
|||
case PIDType.PokeSpot:
|
||||
return SetRandomPIDIV;
|
||||
|
||||
case PIDType.G5MGShiny:
|
||||
return SetValuesFromSeedMG5Shiny;
|
||||
|
||||
case PIDType.Pokewalker:
|
||||
return (pk, seed) => pk.PID = GetPokeWalkerPID(pk.TID, pk.SID, seed%24, pk.Gender, pk.PersonalInfo.Gender);
|
||||
|
||||
// others: unimplemented
|
||||
case PIDType.CuteCharm:
|
||||
break;
|
||||
|
|
@ -143,10 +149,6 @@ public static void SetValuesFromSeed(PKM pk, PIDType type, uint seed)
|
|||
break;
|
||||
case PIDType.G4MGAntiShiny:
|
||||
break;
|
||||
case PIDType.G5MGShiny:
|
||||
break;
|
||||
case PIDType.Pokewalker:
|
||||
break;
|
||||
}
|
||||
return (pk, seed) => { };
|
||||
}
|
||||
|
|
@ -159,8 +161,60 @@ public static uint GetMG5ShinyPID(uint gval, uint av, int TID, int SID)
|
|||
return PID;
|
||||
}
|
||||
|
||||
public static uint GetPokeWalkerPID(int TID, int SID, uint nature, int gender, int gr)
|
||||
{
|
||||
if (nature >= 24)
|
||||
nature = 0;
|
||||
uint pid = (uint)((TID ^ SID) >> 8 ^ 0xFF) << 24; // the most significant byte of the PID is chosen so the Pokémon can never be shiny.
|
||||
// Ensure nature is set to required nature without affecting shininess
|
||||
pid += nature - pid % 25;
|
||||
|
||||
// Ensure Gender is set to required gender without affecting other properties
|
||||
// If Gender is modified, modify the ability if appropriate
|
||||
int currentGender = gender;
|
||||
if (currentGender != 2) // either m/f
|
||||
{
|
||||
var pidGender = (pid & 0xFF) < gr ? 1 : 0;
|
||||
if (currentGender != pidGender)
|
||||
{
|
||||
if (currentGender == 0) // Male
|
||||
{
|
||||
pid += (uint)(((gr - (pid & 0xFF)) / 25 + 1) * 25);
|
||||
if ((nature & 1) != (pid & 1))
|
||||
pid += 25;
|
||||
}
|
||||
else
|
||||
{
|
||||
pid -= (uint)((((pid & 0xFF) - gr) / 25 + 1) * 25);
|
||||
if ((nature & 1) != (pid & 1))
|
||||
pid -= 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
public static void SetValuesFromSeedMG5Shiny(PKM pk, uint seed)
|
||||
{
|
||||
var gv = seed >> 24;
|
||||
var av = seed & 1;
|
||||
pk.PID = GetMG5ShinyPID(gv, av, pk.TID, pk.SID);
|
||||
SetRandomIVs(pk);
|
||||
}
|
||||
|
||||
public static void SetRandomWildPID(PKM pk, int gen, int nature, int ability, int gender, PIDType specific = PIDType.None)
|
||||
{
|
||||
if (specific == PIDType.Pokewalker)
|
||||
{
|
||||
pk.Gender = gender;
|
||||
do
|
||||
{
|
||||
pk.PID = GetPokeWalkerPID(pk.TID, pk.SID, (uint) nature, gender, pk.PersonalInfo.Gender);
|
||||
} while (!pk.IsGenderValid());
|
||||
pk.RefreshAbility((int)(pk.PID & 1));
|
||||
SetRandomIVs(pk);
|
||||
return;
|
||||
}
|
||||
switch (gen)
|
||||
{
|
||||
case 3:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user