mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 08:24:24 -05:00
latest, d2s stuff
This commit is contained in:
101
CharEditor.php
101
CharEditor.php
@@ -14,6 +14,7 @@ require_once './src/D2Functions.php';
|
||||
require_once './src/D2ByteReader.php';
|
||||
require_once './src/D2BitReader.php';
|
||||
require_once './src/D2Item.php';
|
||||
require_once './src/D2Char.php';
|
||||
|
||||
define('DB_FILE', $_SESSION['modname'] . ".db");
|
||||
PDO_Connect("sqlite:" . DB_FILE);
|
||||
@@ -31,99 +32,33 @@ $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]);
|
||||
//}
|
||||
$filePath = "Test.d2s";
|
||||
$char = new D2Char($filePath);
|
||||
//$char->setAllSkills(56);
|
||||
//$char->setSkill(1, 99);
|
||||
//$char->setChar("CharacterClass", 1); // 127
|
||||
$char->setChar("CharacterLevel", 0);
|
||||
$char->setStat("strength", 30);
|
||||
$char->setStat("energy", 30);
|
||||
$char->setStat("dexterity", 30);
|
||||
$char->setStat("vitality", 30);
|
||||
$char->setStat("mana", 120);
|
||||
$char->setStat("maxmana", 200);
|
||||
$char->setStat("stamina", 80);
|
||||
$char->setStat("maxstamina", 120);
|
||||
|
||||
|
||||
unset($char); // destroy $char so we can read it again after writing to it to get updated stats
|
||||
|
||||
$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);
|
||||
$char = new D2Char($filePath);
|
||||
var_dump($char->cData['stats']);
|
Reference in New Issue
Block a user