mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-28 15:00:36 +00:00
Implement Gender/Ability criteria
This commit is contained in:
parent
1c257c0a24
commit
c91512dc15
2 changed files with 37 additions and 11 deletions
29
Misc/PGF.cs
29
Misc/PGF.cs
|
@ -223,20 +223,31 @@ namespace PKHeX
|
||||||
pk.HiddenAbility = true;
|
pk.HiddenAbility = true;
|
||||||
pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av];
|
pk.Ability = PKX.Personal[PKX.Personal[Species].FormeIndex(Species, pk.AltForm)].Abilities[av];
|
||||||
|
|
||||||
switch (PIDType)
|
if (PID != 0) pk.PID = PID;
|
||||||
|
else switch (PIDType)
|
||||||
{
|
{
|
||||||
case 00: // Specified
|
case 00: // Not Shiny
|
||||||
if (PID == 0)
|
do { pk.PID = Util.rnd32();
|
||||||
do { pk.PID = Util.rnd32(); } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 8) + (pk.PID & 0xFFFF)) < 8);
|
// Ensure Ability
|
||||||
else
|
if (av == 0) pk.PID &= 0xFFFEFFFF; else pk.PID |= 0x10000;
|
||||||
pk.PID = PID;
|
} while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 8) + (pk.PID & 0xFFFF)) < 8 || !pk.getGenderIsValid());
|
||||||
break;
|
break;
|
||||||
case 01: // Random
|
case 01: // Can Be Shiny
|
||||||
pk.PID = PID == 0 ? Util.rnd32() : PID;
|
pk.PID = Util.rnd32();
|
||||||
|
// Ensure Ability
|
||||||
|
if (av == 0) pk.PID &= 0xFFFEFFFF; else pk.PID |= 0x10000;
|
||||||
|
// Ensure Gender
|
||||||
|
do { pk.PID = (pk.PID & 0xFFFFFF00) | Util.rnd32() & 0xFF; } while (!pk.getGenderIsValid());
|
||||||
break;
|
break;
|
||||||
case 02: // Random Shiny
|
case 02: // Random Shiny
|
||||||
|
// This is not the actual Shiny PID generation routine.
|
||||||
pk.PID = Util.rnd32();
|
pk.PID = Util.rnd32();
|
||||||
pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 8) + (pk.PID & 0xFFFF));
|
// Ensure Ability
|
||||||
|
if (av == 0) pk.PID &= 0xFFFEFFFF; else pk.PID |= 0x10000;
|
||||||
|
// Ensure Gender
|
||||||
|
do { pk.PID = (pk.PID & 0xFFFFFF00) | Util.rnd32() & 0xFF; } while (!pk.getGenderIsValid());
|
||||||
|
// Ensure Shiny
|
||||||
|
pk.PID = (uint)(pk.PID & 0x0001FFFF | ((TID ^ SID ^ (pk.PID & 0xFFFF)) & 0xFFFE) << 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
Misc/PK5.cs
19
Misc/PK5.cs
|
@ -279,8 +279,8 @@ namespace PKHeX
|
||||||
}
|
}
|
||||||
public int[] EVs { get { return new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; } }
|
public int[] EVs { get { return new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; } }
|
||||||
public int[] Moves { get { return new[] { Move1, Move2, Move3, Move4 }; } }
|
public int[] Moves { get { return new[] { Move1, Move2, Move3, Move4 }; } }
|
||||||
public int PSV { get { return (int)(((PID >> 16) ^ (PID & 0xFFFF)) >> 4); } }
|
public int PSV { get { return (int)(((PID >> 16) ^ (PID & 0xFFFF)) >> 3); } }
|
||||||
public int TSV { get { return (TID ^ SID) >> 4; } }
|
public int TSV { get { return (TID ^ SID) >> 3; } }
|
||||||
public bool IsShiny { get { return TSV == PSV; } }
|
public bool IsShiny { get { return TSV == PSV; } }
|
||||||
public bool PKRS_Infected { get { return PKRS_Strain > 0; } }
|
public bool PKRS_Infected { get { return PKRS_Strain > 0; } }
|
||||||
public bool PKRS_Cured { get { return PKRS_Days == 0 && PKRS_Strain > 0; } }
|
public bool PKRS_Cured { get { return PKRS_Days == 0 && PKRS_Strain > 0; } }
|
||||||
|
@ -339,5 +339,20 @@ namespace PKHeX
|
||||||
RefreshChecksum();
|
RefreshChecksum();
|
||||||
return Data;
|
return Data;
|
||||||
}
|
}
|
||||||
|
public bool getGenderIsValid()
|
||||||
|
{
|
||||||
|
int gv = PKX.Personal[Species].Gender;
|
||||||
|
if (gv == 255 && Gender == 2)
|
||||||
|
return true;
|
||||||
|
if (gv == 0 && Gender == 1)
|
||||||
|
return true;
|
||||||
|
if (gv == 254 && Gender == 0)
|
||||||
|
return true;
|
||||||
|
if (gv <= (PID & 0xFF) && Gender == 0)
|
||||||
|
return true;
|
||||||
|
if (gv > (PID & 0xFF) && Gender == 1)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue