Bond697

4th gen masuda method + everstone

Feb 6th, 2012
532
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. #define SHINY 1;
  7.  
  8. typedef unsigned long long u64;
  9. typedef unsigned int u32;
  10. typedef unsigned short u16;
  11. typedef unsigned char u8;
  12.  
  13. u32 seed = 0;
  14.  
  15. u32 ARNG(u32 seed);
  16. u32 getNature(u32 seed);
  17. bool isShiny(u32 seed, u32 tid, u32 sid);
  18.  
  19. int main()
  20. {
  21.     u32 nature = 0;
  22.     u32 temp_nature = 0;
  23.     u32 counter = 0;
  24.     u32 seed_counter = 0;
  25.     u32 tid = 0;
  26.     u32 sid = 0;
  27.  
  28.  
  29.     scanf_s("%x", &seed);
  30.     scanf_s("%u", &nature);
  31.     scanf_s("%u", &tid);
  32.     scanf_s("%u", &sid);
  33.  
  34.  
  35.         while(counter < 4)
  36.         {
  37.             if(isShiny(seed, tid, sid))
  38.             {
  39.                 printf("first seed was shiny.");
  40.                 break;
  41.             }
  42.  
  43.             seed = ARNG(seed);
  44.             seed_counter++;
  45.  
  46.             temp_nature = getNature(seed);
  47.  
  48.             if(nature == temp_nature)
  49.             {
  50.                 counter++;
  51.                 if(isShiny(seed, tid, sid))
  52.                 {
  53.                     printf("%u was shiny.", counter);
  54.                     break;
  55.                 }
  56.                
  57.             }
  58.  
  59.         }
  60.  
  61.         printf("%u", seed_counter);
  62.  
  63.     while(1){}
  64.  
  65.  
  66.     return 0;
  67. }
  68.  
  69.  
  70. u32 ARNG(u32 seed)
  71. {
  72.     seed = (seed * 0x6C078965) + 1;
  73.  
  74.     return seed;
  75. }
  76.  
  77. u32 getNature(u32 seed)
  78. {
  79.     return (seed % 25);
  80. }
  81.  
  82. bool isShiny(u32 seed, u32 tid, u32 sid)
  83. {
  84.     u16 hseed = seed >> 16;
  85.     u16 lseed = seed & 0xFFFF;
  86.  
  87.     u16 xid = tid ^ sid;
  88.     u16 xseed = hseed ^ lseed;
  89.  
  90.     u16 xshiny = xid ^ xseed;
  91.  
  92.     if(xshiny < 8)
  93.     {
  94.         return true;
  95.     }
  96.     else
  97.     {
  98.         return false;
  99.     }
  100.  
  101. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment