mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 04:26:03 +00:00
130 lines
4.0 KiB
PHP
130 lines
4.0 KiB
PHP
<?php
|
|
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
set_time_limit(-1);
|
|
ini_set('max_input_time', '-1');
|
|
ini_set('max_execution_time', '0');
|
|
session_start();
|
|
ob_start();
|
|
|
|
require_once './config.php';
|
|
require_once './_pdo.php';
|
|
|
|
require_once './src/D2Functions.php';
|
|
require_once './src/D2ByteReader.php';
|
|
require_once './src/D2BitReader.php';
|
|
require_once './src/D2Item.php';
|
|
|
|
define('DB_FILE', $_SESSION['modname'] . ".db");
|
|
PDO_Connect("sqlite:" . DB_FILE);
|
|
|
|
$sql = "SELECT * FROM strings";
|
|
$strings = PDO_FetchAssoc($sql);
|
|
|
|
$sql = "SELECT code,namestr
|
|
FROM armor
|
|
UNION SELECT code,namestr
|
|
FROM misc
|
|
UNION SELECT code,namestr
|
|
FROM weapons";
|
|
$namestr = PDO_FetchAssoc($sql);
|
|
|
|
$sql = "SELECT ID,Stat,CSvBits FROM itemstatcost WHERE Saved=1";
|
|
$ISCData = PDO_FetchAll($sql);
|
|
|
|
foreach ($ISCData as $k => $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);
|