Merge pull request #79 from chenzw95/unown-pid

Generate legal PID for Gen III Unown
This commit is contained in:
Kaphotics 2016-03-09 00:38:05 -08:00
commit 9729e5a30e
2 changed files with 10 additions and 2 deletions

View file

@ -520,7 +520,7 @@ namespace PKHeX
{ {
return (TID ^ SID) >> 4; return (TID ^ SID) >> 4;
} }
internal static uint getRandomPID(int species, int cg, int origin, int nature) internal static uint getRandomPID(int species, int cg, int origin, int nature, int form)
{ {
int gt = Personal[species].Gender; int gt = Personal[species].Gender;
while (true) // Loop until we find a suitable PID while (true) // Loop until we find a suitable PID
@ -535,6 +535,14 @@ namespace PKHeX
if (origin <= 15 && pid%25 != nature) if (origin <= 15 && pid%25 != nature)
continue; continue;
// Gen 3 Unown: Letter/form derived from PID
if (origin <= 5 && species == 201)
{
uint pidLetter = ( (pid & 0x3000000) >> 18 | (pid & 0x30000) >> 12 | (pid & 0x300) >> 6 | (pid & 0x3) ) % 28;
if (pidLetter != form)
continue;
}
// Gen 3/4/5: Gender derived from PID // Gen 3/4/5: Gender derived from PID
uint gv = pid & 0xFF; uint gv = pid & 0xFF;
if (gt == 255 || gt == 254 || gt == 0) // Set Gender(less) if (gt == 255 || gt == 254 || gt == 0) // Set Gender(less)

View file

@ -1604,7 +1604,7 @@ namespace PKHeX
private void updateRandomPID(object sender, EventArgs e) private void updateRandomPID(object sender, EventArgs e)
{ {
int origin = Util.getIndex(CB_GameOrigin); int origin = Util.getIndex(CB_GameOrigin);
uint PID = PKX.getRandomPID(Util.getIndex(CB_Species), PKX.getGender(Label_Gender.Text), origin, Util.getIndex(CB_Nature)); uint PID = PKX.getRandomPID(Util.getIndex(CB_Species), PKX.getGender(Label_Gender.Text), origin, Util.getIndex(CB_Nature), CB_Form.SelectedIndex);
TB_PID.Text = PID.ToString("X8"); TB_PID.Text = PID.ToString("X8");
getQuickFiller(dragout); getQuickFiller(dragout);
if (origin >= 24) if (origin >= 24)