latest working copy, file backup, tbl entry done

This commit is contained in:
color.diff=auto 2021-03-21 23:43:02 -06:00
parent 35b3f1ae00
commit 9e494febda
12 changed files with 587 additions and 393 deletions

View File

@ -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

View File

@ -0,0 +1 @@
"My Awesome Unique3" "My Awesome Unique3"

View File

@ -1,4 +1,11 @@
<?php
//$d2_dir = 'D:\\Diablo II\\MODS\\ironman-dev\\';
$d2_dir = '/home/stoned/code/d2/';
/*
Enter full path to Diablo II Mod's data\excel\global directory
Or wherever your txt files are.
*/
//define('TXT_DIR', "D:\\Diablo II\\MODS\\ironman-dev\\");
define('TXT_DIR', "/home/stoned/code/d2/");

View File

@ -1,44 +1,66 @@
<?php
/*
D2UniqueMaker
GPLv2 (C) <2021> <HashCasper>
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 <http://www.gnu.org/licenses/>.
*/
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 "<pre>";
print_r($post);
foreach ($post as $p){
echo "$p\t";
}
echo "</pre>";
$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';

30
res/app.js Normal file
View File

@ -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();
}
});
});

37
res/style.css Normal file
View File

@ -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;
}

258
src/D2UM.php Normal file
View File

@ -0,0 +1,258 @@
<!doctype html>
<html lang="en">
<?php
/*Require the <head> section*/
require_once "head.php";
?>
<body>
<div class="container">
<p>D2UM: Diablo 2 Unique Maker, v2. By HashCasper</p>
<form action="/index.php" method="post">
<div class="form-group row">
<div class="col-3">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="fa fa-align-justify"></i>
</div>
</div>
<input id="index" name="index" placeholder="Index (Item Name)" type="text" aria-describedby="indexHelpBlock" required="required" class="form-control">
</div><span class="help">[show/hide Help]</span>
<span id="indexHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-3" style="background: #ddc;">
<p>Version:</p>
<div class="custom-control custom-radio custom-control-inline">
<input name="version" id="version_0" type="radio" aria-describedby="versionHelpBlock" required="required" class="custom-control-input" value="0">
<label for="version_0" class="custom-control-label">0</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="version" id="version_1" type="radio" aria-describedby="versionHelpBlock" required="required" class="custom-control-input" value="1">
<label for="version_1" class="custom-control-label">1</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="version" id="version_2" type="radio" aria-describedby="versionHelpBlock" required="required" class="custom-control-input" value="100" checked>
<label for="version_2" class="custom-control-label">100</label>
</div><span class="help">[show/hide Help]</span>
<span id="versionHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #def;">
<p>Enabled:</p>
<div class="custom-control custom-radio custom-control-inline">
<input name="enabled" id="enabled_0" type="radio" class="custom-control-input" value="0" aria-describedby="enabledHelpBlock" required="required">
<label for="enabled_0" class="custom-control-label">0</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="enabled" id="enabled_1" type="radio" class="custom-control-input" value="1" aria-describedby="enabledHelpBlock" required="required" checked>
<label for="enabled_1" class="custom-control-label">1</label>
</div><span class="help">[show/hide Help]</span>
<span id="enabledHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #dac;">
<p>Ladder:</p>
<div class="custom-control custom-radio custom-control-inline">
<input name="ladder" id="ladder_0" type="radio" class="custom-control-input" value="0" aria-describedby="ladderHelpBlock" required="required">
<label for="ladder_0" class="custom-control-label">0</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="ladder" id="ladder_1" type="radio" class="custom-control-input" value="1" aria-describedby="ladderHelpBlock" required="required" checked>
<label for="ladder_1" class="custom-control-label">1</label>
</div><span class="help">[show/hide Help]</span>
<span id="ladderHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #dec;">
<div class="input-group">
<input id="rarity" name="rarity" placeholder="Rarity" type="text" aria-describedby="rarityHelpBlock" required="required" class="form-control">
</div><span class="help">[show/hide Help]</span>
<span id="rarityHelpBlock" class="form-text text-muted">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).</span>
</div>
</div>
<div class="form-group row">
<div class="col-3">
<p>NoLimit</p>
<select id="nolimit" name="nolimit" class="custom-select" aria-describedby="nolimitHelpBlock">
<option value="0">0</option>
<option value="1">1</option>
</select><span class="help">[show/hide Help]</span>
<span id="nolimitHelpBlock" class="form-text text-muted">NoLimit: Boolean, 0 = can drop only once per game, 1 = can drop more then once per game.</span>
</div>
<div class="col-3" style="background: #edd;">
<input id="lvl" name="lvl" placeholder="Lvl" type="text" aria-describedby="lvlHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="lvlHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #edd;">
<input id="lvlreq" name="lvlreq" placeholder="Level Required" type="text" aria-describedby="lvlreqHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="lvlreqHelpBlock" class="form-text text-muted">Lvl Req: the character level required to use this unique item.</span>
</div>
<div class="col-2" style="background: #ccd;">
<label for="a-select">Armor</label>
<select class="custom-select" onChange="val();" name="code[]" id="a-select">
<option value=""></option>
<?php
foreach ($armor as $a)
if ($a['spawnable']) {
echo '<option value="' . $a['code'] . '">' . $a['name'] . '</option>';
} else {
echo '<option disabled value="' . $a['code'] . '">' . $a['name'] . '</option>';
}
?>
</select>
</div>
<div class="col-2" style="background: #ddc;">
<label for="w-select">Weapon</label>
<select class="custom-select" onChange="val2();" name="code[]" id="w-select">
<option value=""></option>
<?php
foreach ($weapon as $a) {
echo '<option value="' . $a['code'] . '">' . $a['name'] . '</option>';
}
?>
</select>
</div>
</div>
<div class="form-group row">
<input type="hidden" name="type" value=""> <br>
<input type="hidden" name="uber" value=""><br>
<div class="col-3">
<p>Carry1</p>
<select id="carry1" name="carry1" class="custom-select" aria-describedby="carry1HelpBlock" required="required">
<option value="0">0</option>
<option value="1" selected>1</option>
</select><span class="help">[show/hide Help]</span>
<span id="carry1HelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-3" style="background: #def;">
<input id="costmult" value="5" name="costmult" placeholder="Cost Mult" type="text" aria-describedby="costmultHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="costmultHelpBlock" class="form-text text-muted">Cost Mult: the base item's price is multiplied by this value when sold, repaired or bought from a vendor.</span>
</div>
<div class="col-3" style="background: #def;">
<input id="costadd" value="5000" name="costadd" placeholder="Cost Add" type="text" aria-describedby="costaddHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="costaddHelpBlock" class="form-text text-muted">Cost Add: after the price has been multiplied, this amount of gold is added to the price on top.</span>
</div>
<div class="col-3">
<input id="chrtransform" name="chrtransform" placeholder="ChrTransform" type="text" aria-describedby="chrtransformHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="chrtransformHelpBlock" class="form-text text-muted">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.</span>
</div>
</div>
<div class="form-group row">
<div class="col-2">
<input id="invtransform" name="invtransform" type="text" placeholder="InvTransform" aria-describedby="invtransformHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="invtransformHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #eef;">
<input id="flippyfile" name="flippyfile" placeholder="Flippy File" type="text" aria-describedby="flippyfileHelpBlock" class="form-control" required="required"><span class="help">[show/hide Help]</span>
<span id="flippyfileHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #eef;">
<input id="invfile" name="invfile" placeholder="InvFile" type="text" aria-describedby="invfileHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="invfileHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #fed;">
<input id="dropsound" name="dropsound" placeholder="DropSound" type="text" aria-describedby="dropsoundHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="dropsoundHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #fed;">
<input id="dropsfxframe" name="dropsfxframe" placeholder="DropSfxFrame" type="text" aria-describedby="dropsfxframeHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="dropsfxframeHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #fed;">
<input id="usesound" name="usesound" placeholder="UseSound" type="text" aria-describedby="usesoundHelpBlock" class="form-control"><span class="help">[show/hide Help]</span><span id="usesoundHelpBlock" class="form-text text-muted">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.</span>
</div>
</div>
<div class="form-group row">
<?php
$html = '';
foreach (range(01, 12) as $p) {
?>
<div class="col-2" style="padding: 15px;margin: 10px 0px; background: #ddd;">
<select id="prop<?php echo $p ?>-select" name="prop<?php echo $p ?>" class="custom-select">
<option class="PropFirst" value="">Prop<?php echo $p ?></option>
<?php
foreach ($prop as $a) {
echo '<option value="' . $a['code'] . '">' . $a['code'] . '</option>';
}
?>
</select>
<input id="par<?php echo $p ?>" name="par<?php echo $p ?>" placeholder="Par<?php echo $p ?>" type="number" aria-describedby="par<?php echo $p ?>HelpBlock" class="form-control par<?php echo $p ?>">
<input id="min<?php echo $p ?>" name="min<?php echo $p ?>" placeholder="min<?php echo $p ?>" type="number" aria-describedby="min<?php echo $p ?>HelpBlock" class="form-control min<?php echo $p ?>">
<input id="max<?php echo $p ?>" name="max<?php echo $p ?>" placeholder="max<?php echo $p ?>" type="number" aria-describedby="max<?php echo $p ?>HelpBlock" class="form-control max<?php echo $p ?>">
</div>
<?php
}
?>
<input type="hidden" name="*eol" value="0">
</div>
<div class="form-group row" style="background: none;">
<div class="col-9" style="background: none;">
<p>Options: <br>
(Hide 'unspawnable' items) <input type="checkbox" id="op1" name="opt-hide-disabled" checked>
</p>
</div>
<div class="col-3" style="background: none;">
<button name="submit" type="submit" class="btn btn-success">Save Item</button>
<button name="submit" type="reset" class="btn btn-danger">Clear</button>
</div>
</div>
</form>
<footer>
<h1 id="credits-">Credits:</h1>
<p>Thanks Phrozen Keep! My favorite mod community since 2002!</p>
<ul>
<li><a href="https://d2mods.info/forum/viewtopic.php?t=34455">Intro to the D2 Files and File Guide/Tutorial Masterlist</a></li>
<li><a href="https://d2mods.info/index.php?ind=reviews&amp;op=entry_view&amp;iden=2">Armor.txt by Kingpin et al. [ex Nefarius] (accurate)</a></li>
<li><a href="https://d2mods.info/index.php?ind=reviews&amp;op=entry_view&amp;iden=345">Properties.txt by Joel (revised by Myhrginoc 8/22/06)</a></li>
<li><a href="https://d2mods.info/index.php?ind=reviews&amp;op=entry_view&amp;iden=346">Weapons.txt by Kingpin and Ric Faith (accurate)</a></li>
<li><a href="https://d2mods.info/index.php?ind=reviews&amp;op=entry_view&amp;iden=386">UniqueItems.txt by Nefarius (accurate)</a></li>
</ul>
</footer>
</div>
</body>
</html>

10
src/functions.php Normal file
View File

@ -0,0 +1,10 @@
<?php
function db() {
echo "<pre>";
var_dump($post);
foreach ($post as $p) {
echo "$p\t";
}
echo "</pre>";
}

47
src/head.php Normal file
View File

@ -0,0 +1,47 @@
<?php
/*
D2UniqueMaker
GPLv2 (C) <2021> <HashCasper>
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 <http://www.gnu.org/licenses/>.
*/
?>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<link rel="stylesheet" href="https://bootswatch.com/4/materia/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="res/style.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap" rel="stylesheet">
<style>
</style>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<script src="res/app.js"></script>
</script>
<title>Unique Maker</title>
</head>

67
src/saveFile.php Normal file
View File

@ -0,0 +1,67 @@
<?php
/*
D2UniqueMaker
GPLv2 (C) <2021> <HashCasper>
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 <http://www.gnu.org/licenses/>.
*/
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");
}
}

63
src/txtParser.php Normal file
View File

@ -0,0 +1,63 @@
<?php
/*
D2UniqueMaker
GPLv2 (C) <2021> <HashCasper>
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 <http://www.gnu.org/licenses/>.
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;
}
}

View File

@ -1,364 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<link rel="stylesheet" href="https://bootswatch.com/4/materia/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
input {
width: 108px;
padding: 5px;
margin: 5xp;
text-align: center;
border: 0px;
background: #eef;
}
.form-text,.help {
font-size: 11px;
color: #999;
}
.form-text {
border: 1px solid #ddd;
padding: 5px;
border-radius: 4px;
}
select,input,option{
border: #ccc;
}
.row {
padding: 0 5px;
}
</style>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<script type="text/javascript">
function val() {
d = document.getElementById("w-select");
d.value = '';
}
function val2() {
d = document.getElementById("a-select");
d.value = '';
}
$(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();
}
});
});
</script>
<title>Uniqe Maker</title>
</head>
<div class="container type">
<h1>Unique Maker by Hash</h1>
<body>
<?php
$u = "UniqueItems.txt";
$w = "Weapons.txt";
$a = "Armor.txt";
$p = "Properties.txt";
$u = $path.$u;
$w = $path.$w;
$a = $path.$a;
$p = $path.$p;
function toPHP($file)
{
$rows = array_map(function ($v)
{
return str_getcsv($v, "\t");
}
, file($file));
$header = array_shift($rows);
foreach ($rows as $row)
{
$csv[] = array_combine($header, $row);
}
return $csv;
}
$armor = toPHP($a);
$weapon = toPHP($w);
$prop = toPHP($p);
$uni = toPHP($u);
// echo '<pre>';
// print_r($uni);
// die();
?>
<form action="/index.php" method="post">
<div class="form-group row">
<div class="col-3">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="fa fa-align-justify"></i>
</div>
</div>
<input id="index" name="index" placeholder="Index (Item Name)" type="text" aria-describedby="indexHelpBlock" required="required" class="form-control">
</div>
<span id="indexHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-3" style="background: #ddc;">
<p>Version:</p>
<div class="custom-control custom-radio custom-control-inline">
<input name="version" id="version_0" type="radio" aria-describedby="versionHelpBlock" required="required" class="custom-control-input" value="0">
<label for="version_0" class="custom-control-label">0</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="version" id="version_1" type="radio" aria-describedby="versionHelpBlock" required="required" class="custom-control-input" value="1">
<label for="version_1" class="custom-control-label">1</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="version" id="version_2" type="radio" aria-describedby="versionHelpBlock" required="required" class="custom-control-input" value="100" checked>
<label for="version_2" class="custom-control-label">100</label>
</div>
<span id="versionHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #def;">
<p>Enabled:</p>
<div class="custom-control custom-radio custom-control-inline">
<input name="enabled" id="enabled_0" type="radio" class="custom-control-input" value="0" aria-describedby="enabledHelpBlock" required="required">
<label for="enabled_0" class="custom-control-label">0</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="enabled" id="enabled_1" type="radio" class="custom-control-input" value="1" aria-describedby="enabledHelpBlock" required="required" checked>
<label for="enabled_1" class="custom-control-label">1</label>
</div>
<span id="enabledHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #dac;">
<p>Ladder:</p>
<div class="custom-control custom-radio custom-control-inline">
<input name="ladder" id="ladder_0" type="radio" class="custom-control-input" value="0" aria-describedby="ladderHelpBlock" required="required">
<label for="ladder_0" class="custom-control-label">0</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="ladder" id="ladder_1" type="radio" class="custom-control-input" value="1" aria-describedby="ladderHelpBlock" required="required" checked>
<label for="ladder_1" class="custom-control-label">1</label>
</div>
<span id="ladderHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #dec;">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="fa fa-american-sign-language-interpreting"></i>
</div>
</div>
<input id="rarity" name="rarity" placeholder="Rarity" type="text" aria-describedby="rarityHelpBlock" required="required" class="form-control">
</div>
<span id="rarityHelpBlock" class="form-text text-muted">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).</span>
</div>
</div>
<div class="form-group row">
<div class="col-3">
<p>NoLimit</p>
<select id="nolimit" name="nolimit" class="custom-select" aria-describedby="nolimitHelpBlock">
<option value="0">0</option>
<option value="1">1</option>
</select><span class="help">[show/hide Help]</span>
<span id="nolimitHelpBlock" class="form-text text-muted">NoLimit: Boolean, 0 = can drop only once per game, 1 = can drop more then once per game.</span>
</div>
<div class="col-3" style="background: #edd;">
<input id="lvl" name="lvl" placeholder="Lvl" type="text" aria-describedby="lvlHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="lvlHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #edd;">
<input id="lvlreq" name="lvlreq" placeholder="Level Required" type="text" aria-describedby="lvlreqHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="lvlreqHelpBlock" class="form-text text-muted">Lvl Req: the character level required to use this unique item.</span>
</div>
<div class="col-2" style="background: #ccd;">
<label for="a-select">Armor</label>
<select class="custom-select" onChange="val();" name="code[]" id="a-select">
<option value=""></option>
<?php
foreach ($armor as $a)
if ($a['spawnable'])
{
echo '<option value="' . $a['code'] . '">' . $a['name'] . '</option>';
} else {
echo '<option disabled value="' . $a['code'] . '">' . $a['name'] . '</option>';
}
?>
</select>
</div>
<div class="col-2" style="background: #ddc;">
<label for="w-select">Weapon</label>
<select class="custom-select" onChange="val2();" name="code[]" id="w-select">
<option value=""></option>
<?php
foreach ($weapon as $a)
{
echo '<option value="' . $a['code'] . '">' . $a['name'] . '</option>';
}
?>
</select>
</div>
</div>
<div class="form-group row">
<input type="hidden" name="type" value=""> <br>
<input type="hidden" name="uber" value=""><br>
<div class="col-3">
<p>Carry1</p>
<select id="carry1" name="carry1" class="custom-select" aria-describedby="carry1HelpBlock" required="required">
<option value="0">0</option>
<option value="1" selected>1</option>
</select><span class="help">[show/hide Help]</span>
<span id="carry1HelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-3" style="background: #def;">
<input id="costmult" value="5" name="costmult" placeholder="Cost Mult" type="text" aria-describedby="costmultHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="costmultHelpBlock" class="form-text text-muted">Cost Mult: the base item's price is multiplied by this value when sold, repaired or bought from a vendor.</span>
</div>
<div class="col-3" style="background: #def;">
<input id="costadd" value="5000" name="costadd" placeholder="Cost Add" type="text" aria-describedby="costaddHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="costaddHelpBlock" class="form-text text-muted">Cost Add: after the price has been multiplied, this amount of gold is added to the price on top.</span>
</div>
<div class="col-3">
<input id="chrtransform" name="chrtransform" placeholder="ChrTransform" type="text" aria-describedby="chrtransformHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="chrtransformHelpBlock" class="form-text text-muted">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.</span>
</div>
</div>
<div class="form-group row">
<div class="col-2">
<input id="invtransform" name="invtransform" type="text" placeholder="InvTransform" aria-describedby="invtransformHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="invtransformHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #eef;">
<input id="flippyfile" name="flippyfile" placeholder="Flippy File" type="text" aria-describedby="flippyfileHelpBlock" class="form-control" required="required"><span class="help">[show/hide Help]</span>
<span id="flippyfileHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #eef;">
<input id="invfile" name="invfile" placeholder="InvFile" type="text" aria-describedby="invfileHelpBlock" required="required" class="form-control"><span class="help">[show/hide Help]</span>
<span id="invfileHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #fed;">
<input id="dropsound" name="dropsound" placeholder="DropSound" type="text" aria-describedby="dropsoundHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="dropsoundHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #fed;">
<input id="dropsfxframe" name="dropsfxframe" placeholder="DropSfxFrame" type="text" aria-describedby="dropsfxframeHelpBlock" class="form-control"><span class="help">[show/hide Help]</span>
<span id="dropsfxframeHelpBlock" class="form-text text-muted">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.</span>
</div>
<div class="col-2" style="background: #fed;">
<input id="usesound" name="usesound" placeholder="UseSound" type="text" aria-describedby="usesoundHelpBlock" class="form-control"><span class="help">[show/hide Help]</span><span id="usesoundHelpBlock" class="form-text text-muted">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.</span>
</div>
</div>
<div class="form-group row">
<?php
$html = '';
foreach (range(01, 12) as $p){
?>
<div class="col-2" style="padding: 15px;margin: 10px 0px; background: #ddd;">
<select id="prop<?php echo $p?>-select" name="prop<?php echo $p?>" class="custom-select">
<option class="PropFirst" value="">Prop<?php echo $p?></option>
<?php
foreach ($prop as $a)
{
echo '<option value="' . $a['code'] . '">' . $a['code'] . '</option>';
}
?>
</select>
<input id="par<?php echo $p?>" name="par<?php echo $p?>" placeholder="Par<?php echo $p?>" type="number" aria-describedby="par<?php echo $p?>HelpBlock" class="form-control par<?php echo $p?>">
<input id="min<?php echo $p?>" name="min<?php echo $p?>" placeholder="min<?php echo $p?>" type="number" aria-describedby="min<?php echo $p?>HelpBlock" class="form-control min<?php echo $p?>">
<input id="max<?php echo $p?>" name="max<?php echo $p?>" placeholder="max<?php echo $p?>" type="number" aria-describedby="max<?php echo $p?>HelpBlock" class="form-control max<?php echo $p?>">
</div>
<?php
}
?>
<input type="hidden" name="*eol" value="0">
</div>
<div class="form-group row" style="background: none;">
<div class="col-9" style="background: none;">
<p>Options: <br>
(Hide 'unspawnable' items) <input type="checkbox" id="op1" name="opt-hide-disabled" checked>
</p>
</div>
<div class="col-3" style="background: none;">
<button name="submit" type="submit" class="btn btn-success">Save Item</button>
<button name="submit" type="reset" class="btn btn-danger">Clear</button>
</div>
</div>
</form>
</div>
</body>
</html>