d2tools/CharEditor.php
2022-07-03 04:13:50 -06:00

64 lines
1.7 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';
require_once './src/D2Char.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\MedianXL2012\save\Lok.d2s";
//$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Pal.d2s";
//$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Test.d2s";
$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
$char = new D2Char($filePath);
var_dump($char->cData['stats']);