Advertisement
Guest User

Mewtwo_ball.php

a guest
Apr 15th, 2013
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. <?php
  2. //Only works with shiny pokemon
  3.  
  4. //natures
  5. $nature = array("hardy", "lonely", "brave", "adamant", "naughty",
  6. "bold", "docile", "relaxed", "impish", "lax", "timid", "hasty",
  7. "serious", "jolly", "naive", "modest", "mild", "quiet", "bashful",
  8. "rash", "calm", "gentle", "sassy", "careful", "quirky");
  9.  
  10. if($_POST["submit"] == "submit"){
  11. //input must be in decimal
  12. $hid = $_POST["hid"];//high id, first half of PID
  13. $tid = $_POST["tid"];
  14. $sid = $_POST["sid"];
  15. $lid = "0000000000000";//low id, second half of PID
  16. //convert decimal to binary
  17. $bhid = decbin($hid);
  18. $btid = decbin($tid);
  19. $bsid = decbin($sid);
  20. //arrays
  21. $pids = array();
  22.  
  23. //fill preceding 0s
  24. while(strlen($btid)<16){
  25. $btid = "0".$btid;
  26. }
  27. while(strlen($bsid)<16){
  28. $bsid = "0".$bsid;
  29. }
  30. while(strlen($bhid)<16){
  31. $bhid = "0".$bhid;
  32. }
  33.  
  34. //find first 13 bits of lid
  35. for($i=0;$i<13;$i++){
  36. $test = 0;
  37. $test = $btid[$i] + $bsid[$i] + $bhid[$i];
  38. if(($test % 2) != 0){$lid[$i] = 1;}
  39. }
  40.  
  41. //calculate min/max PID
  42. $pidmin = $bhid.$lid."000";
  43. $pidmax = $bhid.$lid."111";
  44. $min = bindec($pidmin);
  45. $max = bindec($pidmax);
  46. for($i=0;$i<8;$i++){
  47. $pids[] = $min + $i;
  48. }
  49. print("Min PID: ".$min." Max PID: ".$max."<br>");
  50.  
  51. if(!empty($_POST['method'])){
  52. //check natures if method 1 (gen 3/4)
  53. if(!empty($_POST['nature'])){
  54. foreach($pids as $value){
  55. $num = substr($value, -2);
  56. $num = $num%25;
  57. if($nature[$num] == $_POST['nature'])
  58. $possible = $value;
  59. }
  60.  
  61. print("PID based on nature (type 1): $possible <br>");
  62. }
  63. }
  64.  
  65. //alter the pkm's PID
  66. if(!empty($_POST['pkm'])){
  67. $file = "pokemon.pkm";
  68. //If exact PID is known (method 1 checked)
  69. if(!empty($possible)){
  70. print "possible<br>";
  71. $data = pack("V", $possible);
  72. $fp = fopen($file, 'c');
  73. fwrite($fp, $data);
  74. fclose($fp);
  75. }
  76. else{
  77. $count = 0;
  78. //If multiple possible PIDs
  79. foreach($pids as $value){
  80. $fname = "zip/".$count.$file;
  81. copy($file, $fname);
  82. $data = pack("V", $value);
  83. $fp = fopen($fname, 'c');
  84. fwrite($fp, $data);
  85. fclose($fp);
  86. $count++;
  87. }
  88. }
  89. }
  90. }
  91.  
  92. $string = "<form action='mewtwo_ball.php' method='post'><br>";
  93. $string.= "TID: <input type='text' name='tid'>";
  94. $string.= "SID: <input type='text' name='sid'>";
  95. $string.= "HID: <input type='text' name='hid'><br>";
  96. $string.= "Method 1? <input type='checkbox' name='method' value='method'>";
  97. $string.= "<select name='nature'>";
  98. foreach($nature as $value){
  99. $string.= "<option value='".$value."'>".$value."</option>";
  100. }
  101. $string.= "</select><br>";
  102. $string.= "PKM file? <input type='checkbox' name='pkm' value='pkm'><br>";
  103. $string.= "<input type='submit' name='submit' value='submit'>";
  104. $string.-"</form>";
  105. print $string;
  106.  
  107. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement