From 9c8f50f1f76e0fa326cd36b818bdd1fbf2668e32 Mon Sep 17 00:00:00 2001 From: Hash Borgir Date: Wed, 7 Jun 2023 01:09:02 -0600 Subject: [PATCH] item parsing not yet working fully --- CharEditor.php | 8 ++++---- img/items/1.png | Bin 0 -> 228 bytes src/D2Item.php | 22 ++++++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 img/items/1.png diff --git a/CharEditor.php b/CharEditor.php index d91e14f..24a0a13 100644 --- a/CharEditor.php +++ b/CharEditor.php @@ -43,7 +43,7 @@ foreach ($ISCData as $k => $v) { //$filePath = "D:\Diablo II\MODS\MedianXL2012\save\Test.d2s"; -$filePath = "Pest.d2s"; +$filePath = "Sorc.d2s"; $char = new D2Char($filePath); //$char->setChar("CharacterStatus", "Died", 0); @@ -51,8 +51,8 @@ $char = new D2Char($filePath); //$char->setChar("CharacterStatus", "Expansion", 1); //$char->setChar("LeftmousebuttonskillID", 223); -//$char->setAllSkills(1); -$char->setSkill(4, 99); +$char->setAllSkills(1); +//$char->setSkill(3, 20); //$char->setChar("CharacterClass", "Necromancer"); // 127 //$char->setChar("CharacterProgression", 1); // 0 in normal, 1 finished normal, 2 finished nm, 3 finished hell @@ -88,5 +88,5 @@ unset($char); // destroy $char so we can read it again after writing to it to ge $char = new D2Char($filePath); -var_dump($char->cData); +var_dump($char->cData['items']); //var_dump($char->cData['stats']); diff --git a/img/items/1.png b/img/items/1.png new file mode 100644 index 0000000000000000000000000000000000000000..0fcdff2a06e0e1420e42182d096f94204b19925d GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^j35jm7|ip2ssJgLbVpxD28NCO+H=O_NT0@B6_+CQyA5NLR_9Mjv*Y^lM{e!CI-ew zihGQKEY%X%h?11Vl2ohYqEsNoU}RuqsB2)VYiJN+U}gnGMn<|IhJog5$0H~ja`RI% l(<readr(11)); } + + //var_dump($b->getOffset()); // { @@ -178,19 +180,29 @@ class D2Item { case D2ItemQuality::MAGIC: // read 11 bits, prefix. // if no prefix, then next 11 bits will be suffix - $this->iData['$magic_prefix'] = bindec($b->readr(11)); + $this->iData['magic_prefix'] = bindec($b->readr(11)); $this->iData['magic_suffix'] = bindec($b->readr(11)); break; case D2ItemQuality::SET: // Set items have a 12-bit field containing the ID of the set. (Not the set member, but the whole set.) The set member is identified by cross-referencing the item type with the set ID. Also note that set items have an extra field following the item-specific data. // Set identifier; i.e., all items which are part of the set will have the same value in this field. - $set_item = bindec($b->readr(12)); + //var_dump($b->getOffset()); + $setid = bindec($b->readr(12)); + //var_dump($setid); + $sql = "SELECT ROWID,* from sets WHERE ROWID=$setid"; + $res = PDO_FetchRow($sql); + + //ddump($res); + + $this->iData["setname"] = $res; + break; case D2ItemQuality::RARE: $this->iData['iquality'] = "Rare"; break; case D2ItemQuality::UNIQUE: - $this->iData['iquality'] = "Unique"; + //Unique items have an additional 12 bit field, which in most cases is the unique item ID. The few exceptions are certain quest items (e.g., the Horadric Malus). + $uni_item = bindec($b->readr(12)); break; case D2ItemQuality::CRAFTED: $this->iData['iquality'] = "Crafted"; @@ -304,7 +316,9 @@ class D2Item { $sql = "SELECT * from weapons WHERE code = '{$this->iData['code']}'"; $res = PDO_FetchRow($sql); } - //$this->iData['txt'] = ($res); + + // set txt data array + $this->iData['txt'] = ($res); $sql = " SELECT code, namestr