From 9e494febda50400ab357695f11e1f2c4e9d76c84 Mon Sep 17 00:00:00 2001 From: "color.diff=auto" Date: Sun, 21 Mar 2021 23:43:02 -0600 Subject: [PATCH] latest working copy, file backup, tbl entry done --- UniqueItems.txt | 16 ++ UniqueItemsTblEntries.txt | 1 + config.php | 11 +- index.php | 76 +++++--- res/app.js | 30 ++++ res/style.css | 37 ++++ src/D2UM.php | 258 +++++++++++++++++++++++++++ src/functions.php | 10 ++ src/head.php | 47 +++++ src/saveFile.php | 67 +++++++ src/txtParser.php | 63 +++++++ uniqueitems.php | 364 -------------------------------------- 12 files changed, 587 insertions(+), 393 deletions(-) create mode 100644 UniqueItemsTblEntries.txt create mode 100644 res/app.js create mode 100644 res/style.css create mode 100644 src/D2UM.php create mode 100644 src/functions.php create mode 100644 src/head.php create mode 100644 src/saveFile.php create mode 100644 src/txtParser.php delete mode 100644 uniqueitems.php diff --git a/UniqueItems.txt b/UniqueItems.txt index 5aa94c0..5ac153b 100644 --- a/UniqueItems.txt +++ b/UniqueItems.txt @@ -1432,3 +1432,19 @@ Hell Forge Hammer 0 1 1 1 0 hfh Hammer 5 5000 cred fire-min 5 5 fire- KhalimFlail 0 1 1 1 0 qf1 Flail 5 5000 dblu ltng-min 1 1 ltng-max 20 20 swing3 50 50 att 40 40 0 0 0 0 0 0 0 SuperKhalimFlail 0 1 1 1 0 qf2 Flail 5 5000 dblu ltng-min 1 1 ltng-max 40 40 swing3 50 50 att 40 40 manasteal 6 6 lifesteal 6 6 0 0 0 0 +"My Awesome Unique" 100 1 1 12 0 12 15 stu 1 5 5000 invxyz inabc hp 1 1 1 0 +"My Awesome Unique" 100 1 1 12 0 12 15 stu 1 5 5000 invxyz inabc hp 1 1 1 0 +"My Awesome Unique" 100 1 1 12 0 12 15 stu 1 5 5000 invxyz inabc hp 1 1 1 0 +"My Awesome Unique" 100 1 1 12 0 12 15 stu 1 5 5000 invxyz inabc hp 1 1 1 0 +"My Awesome Unique122" 100 1 1 12 0 12 15 1 5 5000 invxyz inabc 0 +asdfasdfasdf 100 1 1 12 0 12 15 1 5 5000 invxyz inabc 0 +f234 100 1 1 12 0 12 15 1 5 5000 invxyz inabc 0 +a3fadfsf 100 1 1 12 0 12 15 1 5 5000 invxyz inabc 0 +"What is this Item" 100 1 1 12 0 12 15 1 5 5000 invxyz inabc 0 +"My Awesome Unique" 100 1 1 12 0 12 15 stu 1 5 5000 invxyz inabc hp 1 1 1 0 +"My Awesome Unique3" 100 1 1 12 0 12 15 msk 1 5 5000 invxyz inabc 0 +"My Awesome Unique3" 100 1 1 12 0 12 15 msk 1 5 5000 invxyz inabc 0 +"My Awesome Unique3" 100 1 1 12 0 12 15 msk 1 5 5000 invxyz inabc 0 +"My Awesome Unique3" 100 1 1 12 0 12 15 msk 1 5 5000 invxyz inabc 0 +"My Awesome Unique3" 100 1 1 12 0 12 15 msk 1 5 5000 invxyz inabc 0 +"My Awesome Unique3" 100 1 1 12 0 12 15 msk 1 5 5000 invxyz inabc 0 diff --git a/UniqueItemsTblEntries.txt b/UniqueItemsTblEntries.txt new file mode 100644 index 0000000..5efea06 --- /dev/null +++ b/UniqueItemsTblEntries.txt @@ -0,0 +1 @@ +"My Awesome Unique3" "My Awesome Unique3" diff --git a/config.php b/config.php index 8963cee..4756d01 100644 --- a/config.php +++ b/config.php @@ -1,4 +1,11 @@ + + This file is part of D2UM. + + D2UM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + D2UM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with D2UM. If not, see . + */ + ini_set('display_errors', 1); ini_set('log_errors', 1); +// Misc functions +require_once "./src/functions.php"; + +// Configuration Options & Constants require_once "./config.php"; -//$path = $d2_dir."data\\global\\excel\\"; -$path = $d2_dir; +// $path is a shorter alias to writing TXT_DIR a lot. +$path = TXT_DIR; -$post = $_POST; -if (!empty($post['code'])) { - array_filter($post['code']); +// Txt Parser +require_once './src/txtParser.php'; - if(!empty($post['code'][0])) { - $post['code'] = $post['code'][0]; - } else { - $post['code'] = $post['code'][1]; - } -} -require_once 'uniqueitems.php'; -$fp = fopen($u, 'a+'); +// parse txt data +$txtParser = new txtParser(); +$parser = $txtParser->getData(); +$armor = $parser['a']; +$weapon = $parser['w']; +$prop = $parser['p']; +$uni = $parser['u']; -echo "
";
-print_r($post);
-
-foreach ($post as $p){
-    echo "$p\t";
-}
-
-echo "
"; +$files = $txtParser->getFiles(); +$u = $files['u']; if (!empty($_POST)) { - fputcsv($fp, $post, "\t"); - - // write for .tbl - $str = '"'.$post["index"].'" "'. $post["index"] .'"'; - - file_put_contents("UniqueItemsTblEntries.txt", $str, FILE_APPEND | LOCK_EX); + // Saver Object + require_once './src/saveFile.php'; + $saver = new saveFile(); + + // save files + $saver->saveTxt($u); + $saver->saveTblEnries($path); } +// header stuff +require_once './src/D2UM.php'; + + + diff --git a/res/app.js b/res/app.js new file mode 100644 index 0000000..6cdc5f6 --- /dev/null +++ b/res/app.js @@ -0,0 +1,30 @@ +function val() { + w = document.getElementById("w-select"); + w.value = ''; + + a = document.getElementById("a-select"); + a.required = "required"; +} +function val2() { + a = document.getElementById("a-select"); + a.value = ''; + + w = document.getElementById("w-select"); + w.required = "required"; +} + +$(document).ready(function () { + $('.form-text').hide(); + $('.help').click(function () { + $('.form-text').slideToggle(); + }); + + $('#op1').val(this.checked); + $('#op1').change(function () { + if (this.checked) { + $('option[disabled="disabled"]').hide(); + } else { + $('option[disabled="disabled"]').show(); + } + }); +}); \ No newline at end of file diff --git a/res/style.css b/res/style.css new file mode 100644 index 0000000..fbd29cf --- /dev/null +++ b/res/style.css @@ -0,0 +1,37 @@ +input { + width: 108px; + padding: 5px; + margin: 5xp; + text-align: center; + border: 0px; + background: #eef; +} + +.form-text, +.help { + font-size: 11px; + color: #999; +} + +.form-text { + background: white; + padding: 5px; + border-radius: 4px; + +} + +select, +input, +option { + border: #ccc; +} + +.row { + padding: 0 5px; +} + +.col-2, +.col-3, +.col-4 { + padding: 5px; +} diff --git a/src/D2UM.php b/src/D2UM.php new file mode 100644 index 0000000..a5d998f --- /dev/null +++ b/src/D2UM.php @@ -0,0 +1,258 @@ + + + section*/ + require_once "head.php"; +?> + + +
+

D2UM: Diablo 2 Unique Maker, v2. By HashCasper

+
+
+ +
+
+
+
+ +
+
+ + +
[show/hide Help] + Index: the ID pointer that is referenced by the game in TreasureClassEx.txt and CubeMain.txt, this column also contains the string-key used in the TBL files. +
+ + +
+

Version:

+
+ + +
+
+ + +
+
+ + +
[show/hide Help] + Version: Switch, what game version was this unique item added in, 0 referes to real classic Diablo II (1.00-1.06), 1 refers to new classic Diablo II (1.07-1.11) and 100 refers to the Expansion Set. Items with 100 will be unable to drop in Classic Diablo II. +
+ + +
+

Enabled:

+
+ + +
+
+ + +
[show/hide Help] + Ladder: Boolean, 1 = item available only on the realms (enabled), 0 = item available both in single player/open games, TCP/IP and on the realms. +
+ + +
+ +

Ladder:

+
+ + +
+
+ + +
[show/hide Help] + Ladder: Boolean, 1 = item available only on the realms (ladder), 0 = item available both in single player/open games, TCP/IP and on the realms. +
+ + +
+
+ +
[show/hide Help] + Rarity: chance to pick this unique item if more then one unique item of the same base item exist, this uses the common rarity/total_rarity formula, so if you have two unique rings, one with a rarity of 100 the other with a rarity of 1, then the first will drop 100/101 percent of the time (99%) and the other will drop 1/101 percent of the time (1%), rarity can be anything between 1 and 255 (rarity of less then 1 will be set to 1 by the code). +
+
+
+
+

NoLimit

+ [show/hide Help] + NoLimit: Boolean, 0 = can drop only once per game, 1 = can drop more then once per game. + +
+ +
+ [show/hide Help] + Lvl: the quality level of this unique item. Monsters, cube recipes, vendors, objects and the like most be at least this level or higher to be able to drop this item, otherwise they would drop a rare item with enhanced durability. +
+ + +
+ [show/hide Help] + Lvl Req: the character level required to use this unique item. +
+ + +
+ + +
+ + +
+ + +
+
+
+
+
+
+

Carry1

+ [show/hide Help] + Carry1: Boolean, 0 = allow the player to hold as many of this item as he wants, 1 = allow the player to hold a single copy only. In reality this just prevents the player from picking up the item when it is dropped on the floor and it prevents the player from putting this item in the trading window. + +
+ + +
+ [show/hide Help] + Cost Mult: the base item's price is multiplied by this value when sold, repaired or bought from a vendor. +
+ + +
+ [show/hide Help] + Cost Add: after the price has been multiplied, this amount of gold is added to the price on top. +
+ + +
+ [show/hide Help] + ChrTransform: palette shift to apply to the the DCC component-file and the DC6 flippy-file (whenever or not the color shift will apply is determined by Weapons.txt, Armor.txt or Misc.txt). This is an ID pointer from Colors.txt. +
+
+
+ +
+ [show/hide Help] + InvTransform: palette shift to apply to the the DC6 inventory-file (whenever or not the color shift will apply is determined by Weapons.txt, Armor.txt or Misc.txt). This is an ID pointer from Colors.txt. +
+ + +
+ [show/hide Help] + FlippyFile: overrides the flippyfile specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains the file name of the DC6 flippy animation. +
+ + +
+ [show/hide Help] + InvFile: overrides the invfile and uniqueinvfile specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains the file name of the DC6 inventory graphic. +
+ + +
+ [show/hide Help] + DropSound: overrides the dropsound (the sound played when the item hits the ground) specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains an ID pointer from Sounds.txt. +
+ + +
+ [show/hide Help] + DropSfxFrame: how many frames after the flippy animation starts playing will the associated drop sound start to play. This overrides the values in Weapons.txt, Armor.txt or Misc.txt. +
+ +
+ [show/hide Help]UseSound: overrides the usesound (the sound played when the item is consumed by the player) specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains an ID pointer from Sounds.txt. +
+
+
+ +
+ + + + + + + + + +
+ + + + +
+
+
+

Options:
+ (Hide 'unspawnable' items) + +

+
+
+ + +
+ +
+
+ + +
+ + diff --git a/src/functions.php b/src/functions.php new file mode 100644 index 0000000..73e18c0 --- /dev/null +++ b/src/functions.php @@ -0,0 +1,10 @@ +"; + var_dump($post); + foreach ($post as $p) { + echo "$p\t"; + } + echo ""; +} diff --git a/src/head.php b/src/head.php new file mode 100644 index 0000000..6324780 --- /dev/null +++ b/src/head.php @@ -0,0 +1,47 @@ + + +This file is part of D2UM. + +D2UM is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +D2UM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with D2UM. If not, see . +*/ +?> + + + + + + + + + + + + + + + + + + + + Unique Maker + diff --git a/src/saveFile.php b/src/saveFile.php new file mode 100644 index 0000000..97e7c33 --- /dev/null +++ b/src/saveFile.php @@ -0,0 +1,67 @@ + + + This file is part of D2UM. + + D2UM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + D2UM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with D2UM. If not, see . + */ + +class saveFile { + + public function saveTxt($file) { + $post = $_POST; + if (!empty($post['code'])) { + array_filter($post['code']); + + if (!empty($post['code'][0])) { + $post['code'] = $post['code'][0]; + } else { + $post['code'] = $post['code'][1]; + } + } + $fp = fopen($file, 'a+'); + + $this->saveBackup($file); + + fputcsv($fp, $post, "\t"); + + } + + public function saveBackup($file){ + + mkdir(TXT_DIR."backup", 0700); + + $newfile = TXT_DIR."backup".DIRECTORY_SEPARATOR.$file.".d2um"; + + if (!copy($file, $newfile)) { + echo "Failed to create backup of $file...\n"; + } + } + + public function saveTblEnries($path) { + $post = $_POST; + + // write for .tbl + $str[0] = $post['index']; + $str[1] = $post['index']; + $fp = fopen($path . "UniqueItemsTblEntries.txt", 'a+'); + fputcsv($fp, $str, "\t"); + + + } + +} diff --git a/src/txtParser.php b/src/txtParser.php new file mode 100644 index 0000000..c0c35a1 --- /dev/null +++ b/src/txtParser.php @@ -0,0 +1,63 @@ + + + This file is part of D2UM. + + D2UM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + D2UM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with D2UM. If not, see . + + + This is a generic D2 Txt Parser + */ + +class txtParser { + + public $path = TXT_DIR; + // Files specific to Unique Items + + public $u = "UniqueItems.txt"; + public $w = "Weapons.txt"; + public $a = "Armor.txt"; + public $p = "Properties.txt"; + + public function getFiles(){ + return ['u'=>$this->u, 'w'=>$this->w, 'a'=>$this->a, 'p'=>$this->p]; + } + + function toPHP($file) { + $file = TXT_DIR . $file; + $rows = array_map(function ($v) { + return str_getcsv($v, "\t"); + } + , file($file)); + $header = array_shift($rows); + foreach ($rows as $row) { + $data[] = @array_combine($header, $row); + } + return $data; + } + + public function getData() { + + $data['a'] = $this->toPHP($this->a); + $data['w'] = $this->toPHP($this->w); + $data['p'] = $this->toPHP($this->p); + $data['u'] = $this->toPHP($this->u); + + return $data; + } + +} diff --git a/uniqueitems.php b/uniqueitems.php deleted file mode 100644 index b62fe15..0000000 --- a/uniqueitems.php +++ /dev/null @@ -1,364 +0,0 @@ - - - - - - - - - - - - - - - - Uniqe Maker - -
-

Unique Maker by Hash

- -'; -// print_r($uni); -// die(); - -?> - - - -
-
- -
-
-
-
- -
-
- - -
- Index: the ID pointer that is referenced by the game in TreasureClassEx.txt and CubeMain.txt, this column also contains the string-key used in the TBL files. -
- - -
-

Version:

-
- - -
-
- - -
-
- - -
- Version: Switch, what game version was this unique item added in, 0 referes to real classic Diablo II (1.00-1.06), 1 refers to new classic Diablo II (1.07-1.11) and 100 refers to the Expansion Set. Items with 100 will be unable to drop in Classic Diablo II. -
- - -
-

Enabled:

-
- - -
-
- - -
- Ladder: Boolean, 1 = item available only on the realms (enabled), 0 = item available both in single player/open games, TCP/IP and on the realms. -
- - -
- -

Ladder:

-
- - -
-
- - -
- Ladder: Boolean, 1 = item available only on the realms (ladder), 0 = item available both in single player/open games, TCP/IP and on the realms. -
- - -
-
-
-
- -
-
- -
- Rarity: chance to pick this unique item if more then one unique item of the same base item exist, this uses the common rarity/total_rarity formula, so if you have two unique rings, one with a rarity of 100 the other with a rarity of 1, then the first will drop 100/101 percent of the time (99%) and the other will drop 1/101 percent of the time (1%), rarity can be anything between 1 and 255 (rarity of less then 1 will be set to 1 by the code). -
-
-
-
-

NoLimit

- [show/hide Help] - NoLimit: Boolean, 0 = can drop only once per game, 1 = can drop more then once per game. - -
- -
- [show/hide Help] - Lvl: the quality level of this unique item. Monsters, cube recipes, vendors, objects and the like most be at least this level or higher to be able to drop this item, otherwise they would drop a rare item with enhanced durability. -
- - -
- [show/hide Help] - Lvl Req: the character level required to use this unique item. -
- - -
- - -
- - -
- - -
-
-
-
-
-
-

Carry1

- [show/hide Help] - Carry1: Boolean, 0 = allow the player to hold as many of this item as he wants, 1 = allow the player to hold a single copy only. In reality this just prevents the player from picking up the item when it is dropped on the floor and it prevents the player from putting this item in the trading window. - -
- - -
- [show/hide Help] - Cost Mult: the base item's price is multiplied by this value when sold, repaired or bought from a vendor. -
- - -
- [show/hide Help] - Cost Add: after the price has been multiplied, this amount of gold is added to the price on top. -
- - -
- [show/hide Help] - ChrTransform: palette shift to apply to the the DCC component-file and the DC6 flippy-file (whenever or not the color shift will apply is determined by Weapons.txt, Armor.txt or Misc.txt). This is an ID pointer from Colors.txt. -
-
-
- -
- [show/hide Help] - InvTransform: palette shift to apply to the the DC6 inventory-file (whenever or not the color shift will apply is determined by Weapons.txt, Armor.txt or Misc.txt). This is an ID pointer from Colors.txt. -
- - -
- [show/hide Help] - FlippyFile: overrides the flippyfile specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains the file name of the DC6 flippy animation. -
- - -
- [show/hide Help] - InvFile: overrides the invfile and uniqueinvfile specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains the file name of the DC6 inventory graphic. -
- - -
- [show/hide Help] - DropSound: overrides the dropsound (the sound played when the item hits the ground) specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains an ID pointer from Sounds.txt. -
- - -
- [show/hide Help] - DropSfxFrame: how many frames after the flippy animation starts playing will the associated drop sound start to play. This overrides the values in Weapons.txt, Armor.txt or Misc.txt. -
- -
- [show/hide Help]UseSound: overrides the usesound (the sound played when the item is consumed by the player) specified in Weapons.txt, Armor.txt or Misc.txt for the base item. This field contains an ID pointer from Sounds.txt. -
-
-
- -
- - - - - - - - - -
- - - - -
-
-
-

Options:
- (Hide 'unspawnable' items) - -

-
-
- - -
- -
-
- - -
- -