$v) { $ISC[$v['ID']] = $v; } //$filePath = "D:\Diablo II\MODS\ironman-dev\save\Aldur.d2s"; $filePath = "D:\Diablo II\MODS\ironman-dev\save\Sorc.d2s"; //$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Lok.d2s"; //$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Pal.d2s"; //$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Test.d2s"; $data = file_get_contents($filePath); $ByteReader = new D2ByteReader($data); $gf = strposX($data, 'gf', 1) + 2; // find gf and skip it $if = strposX($data, 'if', 1); $len = $if - $gf; $stats = new D2BitReader($ByteReader->toBits($ByteReader->readh($gf, $len))); $bits = $stats->getBits(); $cleanbits = substr($bits, 0, -11); $stats->setBits($cleanbits); //$stats->rewind(); //foreach ($ISC as $i) { // $stat = $i['Stat']; // $CSvBits = (int) $i['CSvBits']; // // $id = hexdec($ByteReader->toBytesR($stats->readb(9))); // $stats->skip($CSvBits); // $ids[$id] = ($ISC[$id]); //} $stats->rewind(); for($i=0; $i <= strlen($bits); $i++) { $id = hexdec($ByteReader->toBytesR($stats->readb(9))); $stats->skip($ISC[$id]['CSvBits']); $ids[$id] = $id; } $stats->rewind(); foreach($ids as $id){ $stats->skip(9); $val = $stats->readb($ISC[$id]['CSvBits']); $stat = $ISC[$id]['Stat']; $values[$stat] = hexdec($ByteReader->toBytesR($val)); } $values['hitpoints'] = (int) round($values['hitpoints'] >> 11); $values['maxhp'] = (int) round($values['maxhp'] >> 11); $values['mana'] = (int) round($values['mana'] >> 11); $values['maxmana'] = (int) round($values['maxmana'] >> 11); $values['stamina'] = (int) round($values['stamina'] >> 11); $values['maxstamina'] = (int) round($values['maxstamina'] >> 11); $values['killcounter'] = (int) round($values['killcounter'] >> 1); var_dump($values); //$stats->rewind(); //for($i=0; $i <= strlen($bits); $i++) { // $id = hexdec($ByteReader->toBytesR($stats->readb(9))); // if (!empty($ISC[$id])){ // $val = $stats->readb($ISC[$id]['CSvBits']); // $stat = $ISC[$id]['Stat']; // $values[$stat] = hexdec($ByteReader->toBytesR($val)); // } //} //$values['hitpoints'] = (int) round($values['hitpoints'] / 2048); //$values['maxhp'] = (int) round($values['maxhp'] / 2048); //$values['mana'] = (int) round($values['mana'] / 2048); //$values['maxmana'] = (int) round($values['maxmana'] / 2048); //$values['stamina'] = (int) round($values['stamina'] / 2048); //$values['maxstamina'] = (int) round($values['maxstamina'] / 2048); //$values['killcounter'] = (int) round($values['killcounter'] / 2); // //var_dump($values); //array_pop($ids); // //$stats->rewind(); //foreach($ids as $k => $v){ // $stat = $v['Stat']; // $CSvBits = (int) $v['CSvBits']; // $ValShift = (int) $i['ValShift']; // $stats->skip(9); // $values[$stat] = hexdec($ByteReader->toBytesR($stats->readb($CSvBits))); //} //$values['hitpoints'] = (int) round($values['hitpoints'] / 2048); //$values['maxhp'] = (int) round($values['maxhp'] / 2048); //$values['mana'] = (int) round($values['mana'] / 2048); //$values['maxmana'] = (int) round($values['maxmana'] / 2048); //$values['stamina'] = (int) round($values['stamina'] / 2048); //$values['maxstamina'] = (int) round($values['maxstamina'] / 2048); // //dump($values);