mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 12:36:03 +00:00
Processing custom strings for some properties, like skill-rand. https://d2mods.info/forum/kb/viewarticle?a=345. fixed
This commit is contained in:
parent
c40f67545f
commit
db3c6473ca
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
class D2ItemData {
|
class D2ItemData {
|
||||||
|
|
||||||
public $strings;
|
public $strings;
|
||||||
public $images;
|
public $images;
|
||||||
|
|
||||||
public function getImages() {
|
public function getImages() {
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT code,invfile,type,type2 FROM armor
|
SELECT code,invfile,type,type2 FROM armor
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT code,invfile,type,type2 FROM misc
|
SELECT code,invfile,type,type2 FROM misc
|
||||||
@ -14,216 +14,216 @@ class D2ItemData {
|
|||||||
SELECT code,invfile,type,type2 FROM weapons
|
SELECT code,invfile,type,type2 FROM weapons
|
||||||
";
|
";
|
||||||
|
|
||||||
$res = PDO_FetchAll($sql);
|
$res = PDO_FetchAll($sql);
|
||||||
|
|
||||||
$isc = null;
|
$isc = null;
|
||||||
foreach ($res as $r) {
|
foreach ($res as $r) {
|
||||||
$isc1[$r['code']] = $r;
|
$isc1[$r['code']] = $r;
|
||||||
$isc1[$r['code']]['code'] = $r['prop'];
|
$isc1[$r['code']]['code'] = $r['prop'];
|
||||||
|
|
||||||
$isc2[$r['type']] = $r;
|
$isc2[$r['type']] = $r;
|
||||||
$isc2[$r['type']]['type'] = $r['prop'];
|
$isc2[$r['type']]['type'] = $r['prop'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->images = array_merge($isc1, $isc2);
|
$this->images = array_merge($isc1, $isc2);
|
||||||
|
|
||||||
unset($isc1);
|
unset($isc1);
|
||||||
unset($isc2);
|
unset($isc2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uniqueItems($index, $doc = FALSE) {
|
public function uniqueItems($index, $doc = FALSE) {
|
||||||
|
|
||||||
// This is where we get props for each item
|
|
||||||
$sql = "SELECT * FROM uniqueitems WHERE enabled='1' AND `index`=?";
|
|
||||||
|
|
||||||
$res = (PDO_FetchRow($sql, [$index]));
|
// This is where we get props for each item
|
||||||
|
$sql = "SELECT * FROM uniqueitems WHERE enabled='1' AND `index`=?";
|
||||||
|
|
||||||
/*
|
$res = (PDO_FetchRow($sql, [$index]));
|
||||||
* Get invfile code all 3 item tables wherever it is
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (empty($this->images)) {
|
/*
|
||||||
$this->getImages();
|
* Get invfile code all 3 item tables wherever it is
|
||||||
}
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
$res['invfile'] = $this->images[$res['code']]['invfile'];
|
if (empty($this->images)) {
|
||||||
$return = $res;
|
$this->getImages();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
$res['invfile'] = $this->images[$res['code']]['invfile'];
|
||||||
* for all props for this unique item, get ISC strings
|
$return = $res;
|
||||||
*/
|
|
||||||
|
|
||||||
$props = array_filter([
|
/*
|
||||||
"Prop1" => array_filter(
|
* for all props for this unique item, get ISC strings
|
||||||
["prop1" => $return['prop1'], "par1" => $return['par1'], "min1" => $return['min1'], "max1" => $return['max1']]
|
*/
|
||||||
),
|
|
||||||
"Prop2" => array_filter(
|
|
||||||
["prop2" => $return['prop2'], "par1" => $return['par2'], "min1" => $return['min2'], "max1" => $return['max2']]
|
|
||||||
),
|
|
||||||
"Prop3" => array_filter(
|
|
||||||
["prop3" => $return['prop3'], "par1" => $return['par3'], "min1" => $return['min3'], "max1" => $return['max3']]
|
|
||||||
),
|
|
||||||
"Prop4" => array_filter(
|
|
||||||
["prop4" => $return['prop4'], "par1" => $return['par4'], "min1" => $return['min4'], "max1" => $return['max4']]
|
|
||||||
),
|
|
||||||
"Prop5" => array_filter(
|
|
||||||
["prop5" => $return['prop5'], "par1" => $return['par5'], "min1" => $return['min5'], "max1" => $return['max5']]
|
|
||||||
),
|
|
||||||
"Prop6" => array_filter(
|
|
||||||
["prop6" => $return['prop6'], "par1" => $return['par6'], "min1" => $return['min6'], "max1" => $return['max6']]
|
|
||||||
),
|
|
||||||
"Prop7" => array_filter(
|
|
||||||
["prop7" => $return['prop7'], "par1" => $return['par7'], "min1" => $return['min7'], "max1" => $return['max7']]
|
|
||||||
),
|
|
||||||
"Prop8" => array_filter(
|
|
||||||
["prop8" => $return['prop8'], "par1" => $return['par8'], "min1" => $return['min8'], "max1" => $return['max8']]
|
|
||||||
),
|
|
||||||
"Prop9" => array_filter(
|
|
||||||
["prop9" => $return['prop9'], "par1" => $return['par9'], "min1" => $return['min9'], "max1" => $return['max9']]
|
|
||||||
),
|
|
||||||
"Prop10" => array_filter(
|
|
||||||
["prop10" => $return['prop10'], "par1" => $return['par10'], "min1" => $return['min10'], "max1" => $return['max10']]
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
|
|
||||||
// need par, min, max value for each prop
|
$props = array_filter([
|
||||||
// ( Also need func1 and val1 for each prop )
|
"Prop1" => array_filter(
|
||||||
// for each prop, get stat
|
["prop1" => $return['prop1'], "par1" => $return['par1'], "min1" => $return['min1'], "max1" => $return['max1']]
|
||||||
$counter = 1;
|
),
|
||||||
foreach ($props as $key => $val) {
|
"Prop2" => array_filter(
|
||||||
// val = Prop1,Prop2 etc.
|
["prop2" => $return['prop2'], "par1" => $return['par2'], "min1" => $return['min2'], "max1" => $return['max2']]
|
||||||
// for each propr, get all 7 stats in ISC
|
),
|
||||||
// for now only get stat1, and for else, use dgrp
|
"Prop3" => array_filter(
|
||||||
|
["prop3" => $return['prop3'], "par1" => $return['par3'], "min1" => $return['min3'], "max1" => $return['max3']]
|
||||||
|
),
|
||||||
// prop funcs
|
"Prop4" => array_filter(
|
||||||
|
["prop4" => $return['prop4'], "par1" => $return['par4'], "min1" => $return['min4'], "max1" => $return['max4']]
|
||||||
|
),
|
||||||
|
"Prop5" => array_filter(
|
||||||
|
["prop5" => $return['prop5'], "par1" => $return['par5'], "min1" => $return['min5'], "max1" => $return['max5']]
|
||||||
|
),
|
||||||
|
"Prop6" => array_filter(
|
||||||
|
["prop6" => $return['prop6'], "par1" => $return['par6'], "min1" => $return['min6'], "max1" => $return['max6']]
|
||||||
|
),
|
||||||
|
"Prop7" => array_filter(
|
||||||
|
["prop7" => $return['prop7'], "par1" => $return['par7'], "min1" => $return['min7'], "max1" => $return['max7']]
|
||||||
|
),
|
||||||
|
"Prop8" => array_filter(
|
||||||
|
["prop8" => $return['prop8'], "par1" => $return['par8'], "min1" => $return['min8'], "max1" => $return['max8']]
|
||||||
|
),
|
||||||
|
"Prop9" => array_filter(
|
||||||
|
["prop9" => $return['prop9'], "par1" => $return['par9'], "min1" => $return['min9'], "max1" => $return['max9']]
|
||||||
|
),
|
||||||
|
"Prop10" => array_filter(
|
||||||
|
["prop10" => $return['prop10'], "par1" => $return['par10'], "min1" => $return['min10'], "max1" => $return['max10']]
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
|
||||||
|
// need par, min, max value for each prop
|
||||||
|
// ( Also need func1 and val1 for each prop )
|
||||||
|
// for each prop, get stat
|
||||||
|
$counter = 1;
|
||||||
|
foreach ($props as $key => $val) {
|
||||||
|
// val = Prop1,Prop2 etc.
|
||||||
|
// for each propr, get all 7 stats in ISC
|
||||||
|
// for now only get stat1, and for else, use dgrp
|
||||||
|
// prop funcs
|
||||||
/*
|
/*
|
||||||
* 1 - Applies a value to a stat, can use SetX parameter.
|
* 1 - Applies a value to a stat, can use SetX parameter.
|
||||||
2 - defensive function only, similar to 1 ???
|
2 - defensive function only, similar to 1 ???
|
||||||
3 - Apply the same min-max range as used in the previous function block (see res-all).
|
3 - Apply the same min-max range as used in the previous function block (see res-all).
|
||||||
4 - not used ???
|
4 - not used ???
|
||||||
5 - Dmg-min related ???
|
5 - Dmg-min related ???
|
||||||
6 - Dmg-max related ???
|
6 - Dmg-max related ???
|
||||||
7 - Dmg% related ???
|
7 - Dmg% related ???
|
||||||
8 - ??? use for speed properties (ias, fcr, etc ...)
|
8 - ??? use for speed properties (ias, fcr, etc ...)
|
||||||
9 - Apply the same param and value in min-max range, as used in the previous function block.
|
9 - Apply the same param and value in min-max range, as used in the previous function block.
|
||||||
10 - skilltab skill group ???
|
10 - skilltab skill group ???
|
||||||
11 - event-based skills ???
|
11 - event-based skills ???
|
||||||
12 - random selection of parameters for parameter-based stat ???
|
12 - random selection of parameters for parameter-based stat ???
|
||||||
13 - durability-related ???
|
13 - durability-related ???
|
||||||
14 - inventory positions on item ??? (related to socket)
|
14 - inventory positions on item ??? (related to socket)
|
||||||
15 - use min field only
|
15 - use min field only
|
||||||
16 - use max field only
|
16 - use max field only
|
||||||
17 - use param field only
|
17 - use param field only
|
||||||
18 - Related to /time properties.
|
18 - Related to /time properties.
|
||||||
19 - Related to charged item.
|
19 - Related to charged item.
|
||||||
20 - Simple boolean stuff. Use by indestruct.
|
20 - Simple boolean stuff. Use by indestruct.
|
||||||
21 - Add to group of skills, group determined by stat ID, uses ValX parameter.
|
21 - Add to group of skills, group determined by stat ID, uses ValX parameter.
|
||||||
22 - Individual skill, using param for skill ID, random between min-max.
|
22 - Individual skill, using param for skill ID, random between min-max.
|
||||||
23 - ethereal
|
23 - ethereal
|
||||||
24 - property applied to character or target monster ???
|
24 - property applied to character or target monster ???
|
||||||
25--32 can be used in custom code. Check plugin documentation for syntax.
|
25--32 can be used in custom code. Check plugin documentation for syntax.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT func1,stat1 FROM properties WHERE code = ?";
|
|
||||||
$props[$key]['stat'] = PDO_FetchRow($sql, [$val['prop' . $counter]]);
|
|
||||||
|
|
||||||
// if not empty, filter props key stat
|
|
||||||
if (!empty($props[$key]['stat'])) {
|
|
||||||
$props[$key]['stat'] = array_filter($props[$key]['stat']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$counter = 1;
|
|
||||||
//each stat now goes into getIscStrings
|
|
||||||
foreach ($props as $k => $v) {
|
|
||||||
$props[$k]['desc'] = $this->getIscStrings($v['prop' . $counter]);
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Values in params, so I can get generated string for that prop
|
|
||||||
$counter = 1;
|
|
||||||
foreach ($props as $k => $v) { // for each property Prop1 Prop2
|
|
||||||
$params = [
|
|
||||||
'string1' => $v['desc']['string1'],
|
|
||||||
'string2' => $v['desc']['string2'],
|
|
||||||
'gstring1' => $v['desc']['gstring1'],
|
|
||||||
'gstring2' => $v['desc']['gstring2'],
|
|
||||||
'descfunc' => $v['desc']['descfunc'],
|
|
||||||
'descval' => $v['desc']['descval'],
|
|
||||||
'dgrp' => $v['desc']['dgrp'],
|
|
||||||
'dgrpfunc' => $v['desc']['dgrpfunc'],
|
|
||||||
'dgrpval' => $v['desc']['dgrpval'],
|
|
||||||
"prop" => $return['prop' . $counter],
|
|
||||||
"par" => $return['par' . $counter],
|
|
||||||
"min" => $return['min' . $counter],
|
|
||||||
"max" => $return['max' . $counter],
|
|
||||||
];
|
|
||||||
|
|
||||||
/*
|
$sql = "SELECT func1,stat1 FROM properties WHERE code = ?";
|
||||||
* getDesc should process string1, not file guide copy pasta
|
$props[$key]['stat'] = PDO_FetchRow($sql, [$val['prop' . $counter]]);
|
||||||
*
|
|
||||||
*/
|
|
||||||
if ( (!empty($v['desc'])) ) {
|
|
||||||
require_once 'D2ItemDesc.php';
|
|
||||||
$idesc = new D2ItemDesc();
|
|
||||||
$props[$k]['string'][] = ($idesc->getDesc($params));
|
|
||||||
if ($v['stat']['func1'] == '12'){
|
|
||||||
$props[$k]['string'] = "+{$params['par']} to a Random Skill";
|
|
||||||
}
|
|
||||||
ddump($props[$k]['string']);
|
|
||||||
|
|
||||||
}
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$return['props'] = $props;
|
// if not empty, filter props key stat
|
||||||
|
if (!empty($props[$key]['stat'])) {
|
||||||
|
$props[$key]['stat'] = array_filter($props[$key]['stat']);
|
||||||
|
}
|
||||||
|
|
||||||
$sqlArmor = "SELECT * FROM armor WHERE code=?";
|
$counter++;
|
||||||
$sqlMisc = "SELECT * FROM misc WHERE code=?";
|
}
|
||||||
$sqlWeapons = "SELECT * FROM weapons WHERE code=?";
|
|
||||||
|
|
||||||
$baseItemInfo = PDO_FetchRow($sqlArmor, [$res['code']]);
|
$counter = 1;
|
||||||
$uTable = "armor";
|
//each stat now goes into getIscStrings
|
||||||
|
foreach ($props as $k => $v) {
|
||||||
|
$props[$k]['desc'] = $this->getIscStrings($v['prop' . $counter]);
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($baseItemInfo)) {
|
// Values in params, so I can get generated string for that prop
|
||||||
$baseItemInfo = PDO_FetchRow($sqlMisc, [$res['code']]);
|
$counter = 1;
|
||||||
}
|
foreach ($props as $k => $v) { // for each property Prop1 Prop2
|
||||||
if (empty($baseItemInfo)) {
|
$params = [
|
||||||
$baseItemInfo = PDO_FetchRow($sqlWeapons, [$res['code']]);
|
'string1' => $v['desc']['string1'],
|
||||||
}
|
'string2' => $v['desc']['string2'],
|
||||||
|
'gstring1' => $v['desc']['gstring1'],
|
||||||
|
'gstring2' => $v['desc']['gstring2'],
|
||||||
|
'descfunc' => $v['desc']['descfunc'],
|
||||||
|
'descval' => $v['desc']['descval'],
|
||||||
|
'dgrp' => $v['desc']['dgrp'],
|
||||||
|
'dgrpfunc' => $v['desc']['dgrpfunc'],
|
||||||
|
'dgrpval' => $v['desc']['dgrpval'],
|
||||||
|
"prop" => $return['prop' . $counter],
|
||||||
|
"par" => $return['par' . $counter],
|
||||||
|
"min" => $return['min' . $counter],
|
||||||
|
"max" => $return['max' . $counter],
|
||||||
|
];
|
||||||
|
|
||||||
$return['baseItemInfo'] = $baseItemInfo;
|
/*
|
||||||
|
* getDesc should process string1, not file guide copy pasta
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ((!empty($v['desc']))) {
|
||||||
|
require_once 'D2ItemDesc.php';
|
||||||
|
$idesc = new D2ItemDesc();
|
||||||
|
|
||||||
if (!empty($baseItemInfo)) {
|
// process all properties.txt func1 here, total 25 in comments above
|
||||||
$return['baseItemInfo'] = array_filter($baseItemInfo);
|
//process property func 12, random skill
|
||||||
}
|
if ($v['stat']['func1'] == '12') {
|
||||||
|
$props[$k]['string'][] = "+{$params['par']} to Random Skill";
|
||||||
|
} else {
|
||||||
|
$props[$k]['string'][] = ($idesc->getDesc($params));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$doc) {
|
$return['props'] = $props;
|
||||||
header('Content-Type: application/json');
|
|
||||||
return json_encode($return, JSON_INVALID_UTF8_IGNORE | JSON_PRETTY_PRINT);
|
|
||||||
} else {
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIscStrings($iscStat) {
|
$sqlArmor = "SELECT * FROM armor WHERE code=?";
|
||||||
if (empty($this->strings)) {
|
$sqlMisc = "SELECT * FROM misc WHERE code=?";
|
||||||
$this->getStrings();
|
$sqlWeapons = "SELECT * FROM weapons WHERE code=?";
|
||||||
}
|
|
||||||
return ($this->strings[$iscStat]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStrings() {
|
$baseItemInfo = PDO_FetchRow($sqlArmor, [$res['code']]);
|
||||||
$sql = "
|
$uTable = "armor";
|
||||||
|
|
||||||
|
if (empty($baseItemInfo)) {
|
||||||
|
$baseItemInfo = PDO_FetchRow($sqlMisc, [$res['code']]);
|
||||||
|
}
|
||||||
|
if (empty($baseItemInfo)) {
|
||||||
|
$baseItemInfo = PDO_FetchRow($sqlWeapons, [$res['code']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$return['baseItemInfo'] = $baseItemInfo;
|
||||||
|
|
||||||
|
if (!empty($baseItemInfo)) {
|
||||||
|
$return['baseItemInfo'] = array_filter($baseItemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$doc) {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
return json_encode($return, JSON_INVALID_UTF8_IGNORE | JSON_PRETTY_PRINT);
|
||||||
|
} else {
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIscStrings($iscStat) {
|
||||||
|
if (empty($this->strings)) {
|
||||||
|
$this->getStrings();
|
||||||
|
}
|
||||||
|
return ($this->strings[$iscStat]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStrings() {
|
||||||
|
$sql = "
|
||||||
SELECT p.`code` as prop,
|
SELECT p.`code` as prop,
|
||||||
p.stat1,
|
p.stat1,
|
||||||
i.descstrpos,
|
i.descstrpos,
|
||||||
@ -254,9 +254,10 @@ class D2ItemData {
|
|||||||
LEFT JOIN strings as s4
|
LEFT JOIN strings as s4
|
||||||
ON i.dgrpstr2= s4.Key
|
ON i.dgrpstr2= s4.Key
|
||||||
";
|
";
|
||||||
$strings = PDO_FetchAll($sql);
|
$strings = PDO_FetchAll($sql);
|
||||||
foreach ($strings as $k => $v) {
|
foreach ($strings as $k => $v) {
|
||||||
$this->strings[$v['prop']] = $v;
|
$this->strings[$v['prop']] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user