d2tools/src/D2CharItem.php

422 lines
8.2 KiB
PHP
Raw Normal View History

<?php
require_once 'D2BitReader.php';
/**
2023-06-02 05:33:06 +00:00
* Class D2CharItem
*/
2022-06-21 02:21:28 +00:00
class D2CharItem {
/**
2023-06-02 05:33:06 +00:00
* @var string The raw binary data of the item
*/
2022-06-21 02:21:28 +00:00
private string $bits;
2023-06-02 05:33:06 +00:00
// Item properties
/**
2023-06-02 05:33:06 +00:00
* @var string The name of the base item
*/
2023-06-02 05:33:06 +00:00
public string $basename = '';
/**
2023-06-02 05:33:06 +00:00
* @var string The name string of the item
*/
2023-06-02 05:33:06 +00:00
public string $item_name = '';
/**
2023-06-02 05:33:06 +00:00
* @var string The rank of the item (normal/exceptional/elite)
*/
2023-06-02 05:33:06 +00:00
public string $item_rank = '';
/**
2023-06-02 05:33:06 +00:00
* @var string The basic type of the item (armor/weapon/misc)
*/
2023-06-02 05:33:06 +00:00
public string $item_type = '';
// Flags
/**
2023-06-02 05:33:06 +00:00
* @var int The identification flag (0 or 1)
*/
2023-06-02 05:33:06 +00:00
public int $identified = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The number of sockets the item has
*/
2023-06-02 05:33:06 +00:00
public int $sockets = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The ear flag (0 or 1)
*/
2023-06-02 05:33:06 +00:00
public int $ear = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The starter flag (0 or 1)
*/
2023-06-02 05:33:06 +00:00
public int $starter = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The compact flag (0 or 1)
*/
2023-06-02 05:33:06 +00:00
public int $compact = 0;
/**
2023-06-02 05:33:06 +00:00
* @var mixed The ethereal flag
*/
public $ethereal;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var mixed The personalized flag
*/
public $personalized;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var mixed The runeword flag
*/
public $runeword;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var mixed The version flag
*/
public $version;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var string The name of the runeword
*/
2023-06-02 05:33:06 +00:00
public string $runeword_name = '';
/**
2023-06-02 05:33:06 +00:00
* @var string The title of the runes used in the runeword
*/
2023-06-02 05:33:06 +00:00
public string $runes_title = '';
// Placement
/**
2023-06-02 05:33:06 +00:00
* @var int The location of the item
*/
2023-06-02 05:33:06 +00:00
public int $location = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The body location of the item
*/
2023-06-02 05:33:06 +00:00
public int $body = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The column location of the item
*/
2023-06-02 05:33:06 +00:00
public int $col = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The row location of the item
*/
2023-06-02 05:33:06 +00:00
public int $row = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The container flag (0 or 1)
*/
2023-06-02 05:33:06 +00:00
public int $container = 0;
/**
2023-06-02 05:33:06 +00:00
* @var mixed The parent flag
*/
public $parent;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var mixed The storage flag
*/
public $storage;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var mixed The body part flag
*/
public $bodypart;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var int The height of the inventory
*/
2023-06-02 05:33:06 +00:00
public int $invH = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The width of the inventory
*/
2023-06-02 05:33:06 +00:00
public int $invW = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The number of rows in the belt
*/
2023-06-02 05:33:06 +00:00
public int $beltrows = 1;
// Features
/**
2023-06-02 05:33:06 +00:00
* @var string The item code (3-letter code from txt)
*/
2023-06-02 05:33:06 +00:00
public string $item_code = '';
/**
2023-06-02 05:33:06 +00:00
* @var int The number of filled sockets
*/
2023-06-02 05:33:06 +00:00
public int $SocketsFilled = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The number of sockets the item can have
*/
2023-06-02 05:33:06 +00:00
public int $SocketsNum = 0;
/**
2023-06-02 05:33:06 +00:00
* @var bool The socketable flag (gem, rune, jewel)
*/
2023-06-02 05:33:06 +00:00
public bool $socketable = false;
/**
2023-06-02 05:33:06 +00:00
* @var string The fingerprint of the item
*/
2023-06-02 05:33:06 +00:00
public string $fingerprint = '';
/**
2023-06-02 05:33:06 +00:00
* @var int The item level
*/
2023-06-02 05:33:06 +00:00
public int $itemlvl = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The quality of the item
*/
2023-06-02 05:33:06 +00:00
public int $quality = 0;
/**
2023-06-02 05:33:06 +00:00
* @var bool The charm flag (true or false)
*/
2023-06-02 05:33:06 +00:00
public bool $isCharm = false;
/**
2023-06-02 05:33:06 +00:00
* @var bool The jewel flag (true or false)
*/
2023-06-02 05:33:06 +00:00
public bool $isJewel = false;
/**
2023-06-02 05:33:06 +00:00
* @var string The rank of the magic item (normal/magic/rare/crafted/set/unique)
*/
2023-06-02 05:33:06 +00:00
public string $magic_rank = 'Normal';
/**
2023-06-02 05:33:06 +00:00
* @var int The set item ID from txt
*/
2023-06-02 05:33:06 +00:00
public int $set_id = 0;
/**
2023-06-02 05:33:06 +00:00
* @var string The set item
*/
2023-06-02 05:33:06 +00:00
public string $set_item = '';
/**
2023-06-02 05:33:06 +00:00
* @var int The set name (if it is a set item)
*/
2023-06-02 05:33:06 +00:00
public int $set_name = 0;
/**
2023-06-02 05:33:06 +00:00
* @var string The name of the person (ear's name)
*/
2023-06-02 05:33:06 +00:00
public string $personname = '';
/**
2023-06-02 05:33:06 +00:00
* @var int The quest difficulty (-1 if not applicable)
*/
2023-06-02 05:33:06 +00:00
public int $questdif = -1;
/**
2023-06-02 05:33:06 +00:00
* @var mixed The gold
*/
public $gold;
2023-06-02 05:33:06 +00:00
/**
2023-06-02 05:33:06 +00:00
* @var string The global unique identifier (GUID) of the item
*/
2023-06-02 05:33:06 +00:00
public string $GUID = '';
/**
2023-06-02 05:33:06 +00:00
* @var int The defense value of the item
*/
2023-06-02 05:33:06 +00:00
public int $defense = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The minimum damage of the item
*/
2023-06-02 05:33:06 +00:00
public int $mindam = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The maximum damage of the item
*/
2023-06-02 05:33:06 +00:00
public int $maxdam = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The second minimum damage of the item
*/
2023-06-02 05:33:06 +00:00
public int $mindam2 = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The second maximum damage of the item
*/
2023-06-02 05:33:06 +00:00
public int $maxdam2 = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The minimum missile damage of the item
*/
2023-06-02 05:33:06 +00:00
public int $mindammi = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The maximum missile damage of the item
*/
2023-06-02 05:33:06 +00:00
public int $maxdammi = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The maximum durability of the item
*/
2023-06-02 05:33:06 +00:00
public int $MaxDur = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The current durability of the item
*/
2023-06-02 05:33:06 +00:00
public int $CurDur = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The required level to use the item
*/
2023-06-02 05:33:06 +00:00
public int $reqlvl = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The required strength to use the item
*/
2023-06-02 05:33:06 +00:00
public int $reqstr = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The required dexterity to use the item
*/
2023-06-02 05:33:06 +00:00
public int $reqdex = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The speed of the item
*/
2023-06-02 05:33:06 +00:00
public int $speed = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The throwing value of the item
*/
2023-06-02 05:33:06 +00:00
public int $throwing = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The stackable value of the item
*/
2023-06-02 05:33:06 +00:00
public int $stackable = 0;
/**
2023-06-02 05:33:06 +00:00
* @var string The character name (ear's name)
*/
2023-06-02 05:33:06 +00:00
public string $charName = '';
/**
2023-06-02 05:33:06 +00:00
* @var mixed The graphic file name
*/
2023-06-02 05:33:06 +00:00
public $gfx;
/**
2023-06-02 05:33:06 +00:00
* @var int The transform indexes for color remap base item (-1 if not applicable)
*/
2023-06-02 05:33:06 +00:00
public int $baseTrans = -1;
/**
2023-06-02 05:33:06 +00:00
* @var int The transform indexes for color remap magic item (-1 if not applicable)
*/
2023-06-02 05:33:06 +00:00
public int $magicTrans = -1;
/**
2023-06-02 05:33:06 +00:00
* @var mixed The type column from txt
*/
2023-06-02 05:33:06 +00:00
public $type;
/**
2023-06-02 05:33:06 +00:00
* @var string The spell description for potions
*/
2023-06-02 05:33:06 +00:00
public string $spelldesc = '';
/**
2023-06-02 05:33:06 +00:00
* @var mixed The link to item properties from txt
*/
2023-06-02 05:33:06 +00:00
public $ditem;
/**
2023-06-02 05:33:06 +00:00
* @var int The damage multiplier of the item
*/
2023-06-02 05:33:06 +00:00
public int $dammult = 100;
/**
2023-06-02 05:33:06 +00:00
* @var int The minimum damage addition of the item
*/
2023-06-02 05:33:06 +00:00
public int $damminadd = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The maximum damage addition of the item
*/
2023-06-02 05:33:06 +00:00
public int $dammaxadd = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int The defense multiplier of the item
*/
2023-06-02 05:33:06 +00:00
public int $defmult = 100;
/**
2023-06-02 05:33:06 +00:00
* @var int The defense addition of the item
*/
2023-06-02 05:33:06 +00:00
public int $defadd = 0;
/**
2023-06-02 05:33:06 +00:00
* @var int[] The resistances of the item (phy, mag, fire, light, cold, poison)
*/
2023-06-02 05:33:06 +00:00
public array $resist = [0, 0, 0, 0, 0, 0];
/**
2023-06-02 05:33:06 +00:00
* @var int[] The attributes of the item (str, dex, vit, ene)
*/
2023-06-02 05:33:06 +00:00
public array $attributes = [0, 0, 0, 0];
/**
2023-06-02 05:33:06 +00:00
* @var array The socketed items collected in the above function because the item has only data for itself and gems/runes/jewels are standalone
*/
2023-06-02 05:33:06 +00:00
public array $SocketItems = [];
/**
2023-06-02 05:33:06 +00:00
* @var array The item variable properties
*/
2023-06-02 05:33:06 +00:00
public array $properties = [];
/**
2023-06-02 05:33:06 +00:00
* @var array The properties IDs list
*/
2023-06-02 05:33:06 +00:00
public array $propids = [];
/**
2023-06-02 05:33:06 +00:00
* D2CharItem constructor.
*
* @param string $bits The item bits
*/
2023-06-02 05:33:06 +00:00
public function __construct(string $bits)
{
if ($bits === '') {
return false;
}
$this->bits = $bits;
2022-06-21 02:21:28 +00:00
return $this->parseItem();
}
/**
2023-06-02 05:33:06 +00:00
* Parses the item.
*
* @return void
*/
2023-06-02 05:33:06 +00:00
public function parseItem()
{
// Implementation goes here
2022-06-21 02:21:28 +00:00
}
}