From c0338dfaaf7feedd9ec6b58d529afc643bdfc5c1 Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Thu, 16 Mar 2017 03:01:42 -0700 Subject: [PATCH 1/2] Better way to generate final IVs - HP IV isn't fixed --- PKHeX/MysteryGifts/WC6.cs | 7 +++---- PKHeX/MysteryGifts/WC7.cs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/PKHeX/MysteryGifts/WC6.cs b/PKHeX/MysteryGifts/WC6.cs index c19ba173b..0a07e96ee 100644 --- a/PKHeX/MysteryGifts/WC6.cs +++ b/PKHeX/MysteryGifts/WC6.cs @@ -381,11 +381,10 @@ namespace PKHeX.Core switch (IVs[0]) { case 0xFE: - finalIVs[0] = 31; - do { // 31 HP IV, 2 other 31s - for (int i = 1; i < 6; i++) + do { // 3 Perfect IVs + for (int i = 0; i < 6; i++) finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; - } while (finalIVs.Count(r => r == 31) < 3); // 31 + 2*31 + } while (finalIVs.Count(r => r == 31) < 3); // 3*31 break; case 0xFD: do { // 2 other 31s diff --git a/PKHeX/MysteryGifts/WC7.cs b/PKHeX/MysteryGifts/WC7.cs index 582a82179..18173f598 100644 --- a/PKHeX/MysteryGifts/WC7.cs +++ b/PKHeX/MysteryGifts/WC7.cs @@ -408,11 +408,10 @@ namespace PKHeX.Core switch (IVs[0]) { case 0xFE: - finalIVs[0] = 31; - do { // 31 HP IV, 2 other 31s - for (int i = 1; i < 6; i++) + do { // 3 Perfect IVs + for (int i = 0; i < 6; i++) finalIVs[i] = IVs[i] > 31 ? (int)(Util.rnd32() & 0x1F) : IVs[i]; - } while (finalIVs.Count(r => r == 31) < 3); // 31 + 2*31 + } while (finalIVs.Count(r => r == 31) < 3); // 3*31 break; case 0xFD: do { // 2 other 31s From c5cde538a6f4bbac173085bbe252d25345f94605 Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Thu, 16 Mar 2017 03:02:54 -0700 Subject: [PATCH 2/2] Actual Shiny Lock Mechanics --- PKHeX/MysteryGifts/WC6.cs | 3 ++- PKHeX/MysteryGifts/WC7.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PKHeX/MysteryGifts/WC6.cs b/PKHeX/MysteryGifts/WC6.cs index 0a07e96ee..82d0ef872 100644 --- a/PKHeX/MysteryGifts/WC6.cs +++ b/PKHeX/MysteryGifts/WC6.cs @@ -428,7 +428,8 @@ namespace PKHeX.Core pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)); break; case 03: // Random Nonshiny - do { pk.PID = Util.rnd32(); } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16); + pk.PID = Util.rnd32(); + if ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16) pk.PID ^= 0x10000000; break; } diff --git a/PKHeX/MysteryGifts/WC7.cs b/PKHeX/MysteryGifts/WC7.cs index 18173f598..8d75b1e12 100644 --- a/PKHeX/MysteryGifts/WC7.cs +++ b/PKHeX/MysteryGifts/WC7.cs @@ -455,7 +455,8 @@ namespace PKHeX.Core pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)); break; case 03: // Random Nonshiny - do { pk.PID = Util.rnd32(); } while ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16); + pk.PID = Util.rnd32(); + if ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16) pk.PID ^= 0x10000000; break; }