Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Only works with shiny pokemon
- //natures
- $nature = array("hardy", "lonely", "brave", "adamant", "naughty",
- "bold", "docile", "relaxed", "impish", "lax", "timid", "hasty",
- "serious", "jolly", "naive", "modest", "mild", "quiet", "bashful",
- "rash", "calm", "gentle", "sassy", "careful", "quirky");
- if($_POST["submit"] == "submit"){
- //input must be in decimal
- $hid = $_POST["hid"];//high id, first half of PID
- $tid = $_POST["tid"];
- $sid = $_POST["sid"];
- $lid = "0000000000000";//low id, second half of PID
- //convert decimal to binary
- $bhid = decbin($hid);
- $btid = decbin($tid);
- $bsid = decbin($sid);
- //arrays
- $pids = array();
- //fill preceding 0s
- while(strlen($btid)<16){
- $btid = "0".$btid;
- }
- while(strlen($bsid)<16){
- $bsid = "0".$bsid;
- }
- while(strlen($bhid)<16){
- $bhid = "0".$bhid;
- }
- //find first 13 bits of lid
- for($i=0;$i<13;$i++){
- $test = 0;
- $test = $btid[$i] + $bsid[$i] + $bhid[$i];
- if(($test % 2) != 0){$lid[$i] = 1;}
- }
- //calculate min/max PID
- $pidmin = $bhid.$lid."000";
- $pidmax = $bhid.$lid."111";
- $min = bindec($pidmin);
- $max = bindec($pidmax);
- for($i=0;$i<8;$i++){
- $pids[] = $min + $i;
- }
- print("Min PID: ".$min." Max PID: ".$max."<br>");
- if(!empty($_POST['method'])){
- //check natures if method 1 (gen 3/4)
- if(!empty($_POST['nature'])){
- foreach($pids as $value){
- $num = substr($value, -2);
- $num = $num%25;
- if($nature[$num] == $_POST['nature'])
- $possible = $value;
- }
- print("PID based on nature (type 1): $possible <br>");
- }
- }
- //alter the pkm's PID
- if(!empty($_POST['pkm'])){
- $file = "pokemon.pkm";
- //If exact PID is known (method 1 checked)
- if(!empty($possible)){
- print "possible<br>";
- $data = pack("V", $possible);
- $fp = fopen($file, 'c');
- fwrite($fp, $data);
- fclose($fp);
- }
- else{
- $count = 0;
- //If multiple possible PIDs
- foreach($pids as $value){
- $fname = "zip/".$count.$file;
- copy($file, $fname);
- $data = pack("V", $value);
- $fp = fopen($fname, 'c');
- fwrite($fp, $data);
- fclose($fp);
- $count++;
- }
- }
- }
- }
- $string = "<form action='mewtwo_ball.php' method='post'><br>";
- $string.= "TID: <input type='text' name='tid'>";
- $string.= "SID: <input type='text' name='sid'>";
- $string.= "HID: <input type='text' name='hid'><br>";
- $string.= "Method 1? <input type='checkbox' name='method' value='method'>";
- $string.= "<select name='nature'>";
- foreach($nature as $value){
- $string.= "<option value='".$value."'>".$value."</option>";
- }
- $string.= "</select><br>";
- $string.= "PKM file? <input type='checkbox' name='pkm' value='pkm'><br>";
- $string.= "<input type='submit' name='submit' value='submit'>";
- $string.-"</form>";
- print $string;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement