<?xml version="1.0"?>
<rss version="2.0"><channel><title>Docs: Docs</title><link>https://metin2.dev/docs/pages/file-formats/?d=16</link><description>Docs: Docs</description><language>en</language><item><title>Crypted Object</title><link>https://metin2.dev/docs/pages/file-formats/crypted-object-r7/</link><description><![CDATA[<p>
	A Crypted Object is a Metin2 internal file format used to crypt and compress raw file informations. It is currently used used for the following files: Item Proto, Mob Proto, EterPack Index and EterPack Content with type 2 and 6. A kaitai structure file for reading this formats is available here <span>:</span>
</p>

<div class="ipsSpoiler" data-ipsspoiler="">
	<div class="ipsSpoiler_header">
		<span>Spoiler</span>
	</div>

	<div class="ipsSpoiler_contents ipsClearfix" data-gramm="false">
		<pre class="ipsCode" id="ips_uid_8231_5">meta:
  id: m2cryptedobject
  endian: le
seq:
  - id: header
    type: header
  - id: magic_verification
    type: u4
    if: header.crypted_size == 0
    enum: cryptedmagic
  - id: crypted_magic_verification
    type: u4
    if: header.crypted_size != 0
  - id: crypted_content
    size: header.crypted_size
    if: header.crypted_size &gt; 0
  - id: compressed_content
    size: header.compressed_size
    if: header.crypted_size == 0
types:
  header:
    seq:
      - id: magic
        type: u4
        enum: cryptedmagic
      - id: crypted_size
        type: u4
      - id: compressed_size
        type: u4
      - id: real_size
        type: u4
enums:
  cryptedmagic:
    1347633997: mcsp
    1515144013: mcoz</pre>
	</div>
</div>

<p>
	The format contains a 20 bytes header followed by the content (either crypted or compressed) of the data.
</p>

<p>
	 
</p>

<p>
	<strong>Header</strong>
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="13.85" height="91" style="height: auto;" width="657" data-src="https://metin2.download/picture/1jfYDqxwk3WyAbTQzN489QNxS8PdY8mF/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<pre class="ipsCode" id="ips_uid_8231_7">Bytes colored in red (first 4 bytes): A FourCC code that identify the type of object.
Bytes colored in blue: Size of the data after being crypted
Bytes colored in green: Size of the data after being compressed
Bytes colored in yellow: Size of the data without any cryptation or compression (real data size)
Bytes colored in black: Crypted FourCC code, used to verify if the XTEA decryptation was successfull or not.</pre>

<p>
	<strong>NOTE</strong>: If the Crypted object is not crypted, the bytes in black will contains the FourCC.
</p>

<p>
	 
</p>

<p>
	<strong>Data compression</strong>
</p>

<p>
	The data is compressed by one of the following algorithm based from the FourCC code. A list of known compression algorithms is provided below.
</p>

<table style="width: 100%;">
	<caption>
		Known compression algorithm
	</caption>
	<tbody>
		<tr>
			<th style="text-align:left;">
				FourCC Code
			</th>
			<th>
				Algorithm
			</th>
		</tr>
		<tr>
			<td>
				MCOZ
			</td>
			<td>
				LZO 1x
			</td>
		</tr>
		<tr>
			<td>
				MCSP
			</td>
			<td>
				Snappy
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>Data cryptation</strong>
</p>

<p>
	 
</p>

<p>
	<strong>NOTE</strong>: If the blue bytes are 00 00 00 00 it means that the data is not crypted, therefore the game will not attempt to decrypt the content.<br>
	The data is crypted with the XTEA algorithm, therefore all the data requires some keys in order to function correctly, a list of known keys is provided down below:
</p>

<table style="width: 100%;">
	<caption>
		Known XTEA keys
	</caption>
	<tbody>
		<tr>
			<th style="text-align:left;">
				Used in
			</th>
			<th>
				Key (16 bytes)
			</th>
		</tr>
		<tr>
			<td>
				Item Proto
			</td>
			<td>
				A1 A4 02 00 AA 15 54 04 E7 8B 5A 18 AB D6 AA 01
			</td>
		</tr>
		<tr>
			<td>
				Mob Proto
			</td>
			<td>
				46 74 49 00 0B 4A 00 00 B7 6E 08 00 9D 18 68 00
			</td>
		</tr>
		<tr>
			<td>
				EterPack Index
			</td>
			<td>
				B9 9E B0 02 6F 69 81 05 63 98 9B 28 79 18 1A 00
			</td>
		</tr>
		<tr>
			<td>
				EterPack Content
			</td>
			<td>
				22 B8 B4 04 64 B2 6E 1F AE EA 18 00 A6 F6 FB 1C
			</td>
		</tr>
	</tbody>
</table>
]]></description><guid isPermaLink="false">7</guid><pubDate>Tue, 07 Nov 2023 06:08:34 +0000</pubDate></item><item><title>DDS Texture Caching</title><link>https://metin2.dev/docs/pages/file-formats/dds-texture-caching-r8/</link><description><![CDATA[<p style="text-align: justify;">
	The texture caching was an old method used by the old Metin2 autopatcher to reduce download time of big texture files. The autopatcher will download RDCH files, once this files have been downloaded, the patcher will read this files and generate a new EterPack called that ends with _texcache, meaning that this texture cache has been generated by the patcher.
</p>

<p style="text-align: justify;">
	This method went in disuse some time after 40k files, as today no official server still uses Texture caching.
</p>

<p>
	 
</p>

<p>
	<strong>RDCH format</strong>
</p>

<ul>
	<li>
		The first 4-bytes: Number of texture cached.
	</li>
	<li>
		Then, each texture cached is contained inside, at least 8 bytes per texture.
	</li>
	<li>
		First 4 bytes: Length of the cached texture (The name is a file contained inside the corrisponding EterPack)
	</li>
	<li>
		Next 4 bytes: Mipmap count
	</li>
	<li>
		Then it follows the name of the file without a null terminator.
	</li>
	<li>
		Last, the DDS texture for each mipmap compressed.
	</li>
</ul>
]]></description><guid isPermaLink="false">8</guid><pubDate>Tue, 07 Nov 2023 06:13:01 +0000</pubDate></item><item><title>EterPack</title><link>https://metin2.dev/docs/pages/file-formats/eterpack-r9/</link><description><![CDATA[<p style="text-align: justify;">
	The EterPack is a proprietary Virtual File System used for containing all the Client assets (such as 3d meshes, sfx, textures).
</p>

<p style="text-align: justify;">
	All the EterPacks are stored inside the pack/ folder of the game client, and they are load in a specified order, defined by the Pack Index file stored inside pack/ folder.
</p>

<p style="text-align: justify;">
	An EterPack consists of two files, the Index file (.eix) and the Content file (.epk).
</p>

<p style="text-align: justify;">
	The Content file is where the files are stored, either crypted or decrypted, while the Index file is where all informations of the files are stored. (An information might be the file's compression type or the directory where it should virtually mapped).
</p>

<p style="text-align: justify;">
	Index files are usually encrypted as a <a href="https://metin2.dev/docs/pages/crypted-object-r7/" rel="">Crypted Object</a>, therefore, before reading the header, the client must decrypt the file following the method described in the Crypted Object page.
</p>

<p>
	 
</p>

<p>
	<strong>Index file</strong>
</p>

<p>
	An Index file contains 12 bytes as header, described as follows:
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="4.37" height="31" style="height: auto;" width="710" data-src="https://metin2.download/picture/Yg18ZZYEyh8b537X3NRnIV0Y29g3OjLY/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<pre class="ipsCode" id="ips_uid_9495_5">Bytes in red: FourCC (EPKD)
Bytes in blue: Version (Must be 2, it is not known if a EPK with version 1 exists)
Bytes in green: Number of files included in this EterPack.
Bytes in brown: Start of the file index information</pre>

<p>
	From the number of files included in this EterPack, it follows one or more "Index File Information" or simply File information.
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="43.00" height="292" style="height: auto;" width="679" data-src="https://metin2.download/picture/PsLFA0ItVuDB7S4j0HgVfPw71EWsAeZT/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<pre class="ipsCode" id="ips_uid_9495_7">Bytes in red: A 32-bit number that identify the file, this number starts by 0
Bytes in blue: A filename encoded in ASCI (160 bytes + the null terminator)
Bytes in black (1): Padding bytes
Bytes in green: CRC32 of the file name
Bytes in yellow: Decompressed and decrypted file size
Bytes in gray: File size stored in the EterPack content file
Bytes in orange: CRC32 of the file content
Bytes in brown: Offset of the file position in EterPack content file
Byte in purple: Identify the type of algorithm used to crypt the file
Bytes in black (2): Padding bytes</pre>

<p>
	 
</p>

<p>
	<strong>Content file</strong>
</p>

<p>
	An EterPack content file (.epk) just contains the data crypted by the specified algorithm (Also known as Type), there is no header or any format in this file, they are pure RAW files which could be accessed and used from the index file.
</p>

<table style="width: 100%;">
	<caption>
		Known EterPack types
	</caption>
	<tbody>
		<tr>
			<th style="text-align:left;">
				Type number
			</th>
			<th>
				Description
			</th>
		</tr>
		<tr>
			<td>
				Type 0
			</td>
			<td>
				The file is RAW, no compression or cryptation.
			</td>
		</tr>
		<tr>
			<td>
				Type 1
			</td>
			<td>
				The file is compressed with LZO but it does not use XTEA.
			</td>
		</tr>
		<tr>
			<td>
				Type 2
			</td>
			<td>
				The file is compressed with LZO, then it's crypted with XTEA using the EterPack Content keys. (In other words, a MCOZ CryptedObject)
			</td>
		</tr>
		<tr>
			<td>
				Type 3
			</td>
			<td>
				The file is crypted with <span ipsnoautolink="true">Panama</span>
			</td>
		</tr>
		<tr>
			<td>
				Type 4
			</td>
			<td>
				<a href="https://metin2.dev/docs/pages/hybridcrypt-r10/" rel="">HybridCrypt</a>
			</td>
		</tr>
		<tr>
			<td>
				Type 5
			</td>
			<td>
				<a href="https://metin2.dev/docs/pages/hybridcrypt-r10/" rel="">HybridCrypt with extra data</a>
			</td>
		</tr>
		<tr>
			<td>
				Type 6
			</td>
			<td>
				The file is compressed with Snappy, then it's crypted with XTEA using the EterPack Content keys. (In other words, a MCSP CryptedObject)
			</td>
		</tr>
	</tbody>
</table>
]]></description><guid isPermaLink="false">9</guid><pubDate>Tue, 07 Nov 2023 16:48:44 +0000</pubDate></item><item><title>HybridCrypt</title><link>https://metin2.dev/docs/pages/file-formats/hybridcrypt-r10/</link><description><![CDATA[<p>
	The hybrid cryptation is a new type of cryptation introduced somewhere around 40k files.<br>
	What makes this cryptation secure from everyother ones are two key factors:
</p>

<ul>
	<li>
		The algorithm that is used changes from the file name, this means that new algorithms can be used and implement in newer versions
	</li>
	<li>
		The key and the IV are sent from the server (after a successfull login), forcing the user to bruteforce a key for every single file extension crypted.
	</li>
</ul>

<p>
	The Hybrid cryptation is divided in two parts:
</p>

<ul>
	<li>
		The extension keys
	</li>
	<li>
		The file cryptation
	</li>
</ul>

<p>
	 
</p>

<p>
	<strong>Extension keys</strong>
</p>

<p>
	The extensions keys is a 16 byte key and 16 byte IV associated to an extension. The keys does not change based from the cryptation type used. The keys are randomly generated during the creation of an EterPack.
</p>

<p>
	An extension key is generated by performing the following actions:
</p>

<ol>
	<li>
		Calculate an hash of the extension (the extension is written in lowercase and does not contain the . before the extension).
	</li>
	<li>
		Generate two 16-byte values and associate them to the extension hash.
	</li>
</ol>

<p>
	The hash used is simply a 32-bit FNV-1a hash function with the offset_basis set as 0. Written here, a modified version of a MIT implementation found <a href="https://github.com/SRombauts/cpp-algorithms/blob/master/src/algo/hash.cpp" rel="external nofollow">here</a>:
</p>

<pre class="ipsCode prettyprint lang-c prettyprinted" id="ips_uid_6875_5" style=""><span class="com">// License: MIT</span><span class="pln">
</span><span class="com">// Famous 32 bits FNV-1a hash function by Glenn Fowler, Landon Curt Noll, and Phong Vo.</span><span class="pln">
</span><span class="typ">uint32_t</span><span class="pln"> fnv1a32</span><span class="pun">(</span><span class="kwd">const</span><span class="pln"> </span><span class="kwd">char</span><span class="pun">*</span><span class="pln"> apStr</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
    </span><span class="typ">uint32_t</span><span class="pln"> hash </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> </span><span class="com">// 32 bit offset_basis = 0</span><span class="pln">

    </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="typ">uint32_t</span><span class="pln"> idx </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> apStr</span><span class="pun">[</span><span class="pln">idx</span><span class="pun">]</span><span class="pln"> </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> </span><span class="pun">++</span><span class="pln">idx</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        </span><span class="com">// 32 bit FNV_prime = 224 + 28 + 0x93 = 16777619</span><span class="pln">
        hash </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="lit">16777619U</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> hash</span><span class="pun">)</span><span class="pln"> </span><span class="pun">^</span><span class="pln"> </span><span class="kwd">static_cast</span><span class="pun">&lt;</span><span class="kwd">unsigned</span><span class="pln"> </span><span class="kwd">char</span><span class="pun">&gt;(</span><span class="pln">apStr</span><span class="pun">[</span><span class="pln">idx</span><span class="pun">]);</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">

    </span><span class="kwd">return</span><span class="pln"> hash</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span></pre>

<p>
	 
</p>

<p>
	<strong>File cryptation</strong>
</p>

<p>
	A file is crypted with an unique key and IV generated from the extension key. Each file might be encrypted with a different cryptation type, as it's chosen during the cryptation of the file.
</p>

<p>
	A file is encrypted by doing the following actions:
</p>

<ol>
	<li>
		Calculate a CRC32 of the filename (the filename will contain the extension and it's all written in lower case).
	</li>
	<li>
		Select the algorithm to use for cryptation.
	</li>
	<li>
		Get the extension key for the file.
	</li>
	<li>
		Generate the IV and key used for the algorithm from the extension key.
	</li>
</ol>

<p>
	The algorithm is chosen by doing the module of the filename crc with the cryptation types (currently 3).<br>
	The key and IV are simply the extension key and IV XORed with the CRC filename (every 4 bytes of the key/IV is XORed).
</p>

<p>
	 
</p>

<p>
	<strong>Known cryptation types</strong>
</p>

<ul>
	<li>
		Camellia
	</li>
	<li>
		Twofish
	</li>
	<li>
		XTEA
	</li>
</ul>

<p>
	 
</p>

<p>
	 
</p>

<p>
	<strong>Extra data</strong>
</p>

<p>
	 
</p>

<p>
	HybridCrypt Extra data (also known as Type5) is a special cryptation type, where some portion of the file are removed from the client cryptation and stored in the server.<br>
	This method ensures that it's impossible to fully retrive the content of a file without connecting to the server, despite being more consuming in terms of bandwidth.
</p>

<p>
	A extra data cryptation will work as follows:
</p>

<ol>
	<li>
		Choose a part at the end of the file to remove (From 64 to 128 bytes)
	</li>
	<li>
		Crypt the file without the remaining 64/128 bytes with an usual HybridCrypt
	</li>
	<li>
		Store the remaining bytes in the Server
	</li>
</ol>

<p>
	The extra data will be sent to the client once the client has successfully logged in (same as the HybridCrypt keys)<br>
	The data sent from the Server is not encrypted in any form.
</p>
]]></description><guid isPermaLink="false">10</guid><pubDate>Tue, 07 Nov 2023 16:51:51 +0000</pubDate></item><item><title>Item Proto</title><link>https://metin2.dev/docs/pages/file-formats/item-proto-r11/</link><description><![CDATA[<p>
	The Item Proto is a crypted file that contains all informations about the items included in the game. This file is both present in the client and the server.
</p>

<p>
	In the server, this file is used to process all the item (such as when you equip an item, if you can actually equip it).
</p>

<p>
	In the client, this file is used to perform several client-side checks (in order to reduce the amount of data sent to the server) and what actually is displayed in the item information.
</p>

<p>
	The Item proto must be in one of this two formats, MIPX format or MIPT format.
</p>

<p>
	Although the client is able to load a MIPT Item Proto (as references exists in the binary), no MIPT proto has ever been found.
</p>

<p>
	 
</p>

<p>
	<strong>MIPX format</strong>
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="7.91" height="44" style="height: auto;" width="556" data-src="https://metin2.download/picture/9YGQMK5HYpmZw60b1HkgAOtMrKst1vT0/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<pre class="ipsCode" id="ips_uid_1389_4">Bytes in red: FourCC (MIPX)
Bytes in blue: Version of the item proto (Generally 1)
Bytes in green: Stride (Size of the structure that contains the items)
Bytes in black: Number of elements
Bytes in gray: Size of the Crypted Object data
Bytes in orange: Begin of Crypted Object data</pre>

<p>
	 
</p>

<p>
	<strong>MIPT format</strong>
</p>

<p>
	While references of this file format still exists in the executable, no public client that ships a MIPT proto has ever surfaced. It might have been used during development of Metin2 or in very old clients (like 2004 or 2003). The CryptedObject format is the same as a MIPX proto.
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="6.67" height="45" style="height: auto;" width="675" data-src="https://metin2.download/picture/w1Y5NK46bbWoC9tg9358oL38XcvBQ2fr/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<pre class="ipsCode" id="ips_uid_1389_6">Bytes in red: FourCC (MIPT)
Bytes in blue: Number of elements
Bytes in gray: Size of the Crypted Object data
Bytes in orange: Begin of Crypted Object data</pre>

<p>
	 
</p>

<p>
	<strong>Structure: Generic 40k (Stride: 163)</strong>
</p>

<pre class="ipsCode prettyprint lang-c prettyprinted" id="ips_uid_1389_8" style=""><span class="com">// Item Proto applies and limits are the same.</span><span class="pln">
</span><span class="kwd">typedef</span><span class="pln"> stuct </span><span class="typ">Limits</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> type</span><span class="pun">;</span><span class="pln">
</span><span class="typ">int32</span><span class="pln"> value</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span><span class="pln"> </span><span class="typ">Applies</span><span class="pun">;</span></pre>

<p>
	 
</p>

<p>
	<strong>Item table</strong>
</p>

<pre class="ipsCode prettyprint lang-c prettyprinted" id="ips_uid_1389_10" style=""><span class="com">//// Size: 163</span><span class="pln">

</span><span class="typ">uint32</span><span class="pln"> id</span><span class="pun">;</span><span class="pln"> </span><span class="com">// vnum</span><span class="pln">
</span><span class="typ">uint32</span><span class="pln"> range</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">char</span><span class="pln"> indexName</span><span class="pun">[</span><span class="lit">25</span><span class="pun">];</span><span class="pln">
</span><span class="kwd">char</span><span class="pln"> translatedName</span><span class="pun">[</span><span class="lit">25</span><span class="pun">];</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> type</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> subtype</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> weight</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> size</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint32</span><span class="pln"> antiflags</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint32</span><span class="pln"> flags</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint32</span><span class="pln"> wearflags</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint32</span><span class="pln"> immuneflags</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint32</span><span class="pln"> buyprice</span><span class="pun">;</span><span class="pln"> 
</span><span class="typ">uint32</span><span class="pln"> sellprice</span><span class="pun">;</span><span class="pln">
</span><span class="typ">Limits</span><span class="pln"> limits</span><span class="pun">[</span><span class="lit">2</span><span class="pun">];</span><span class="pln">
</span><span class="typ">Applies</span><span class="pln"> apply</span><span class="pun">[</span><span class="lit">3</span><span class="pun">];</span><span class="pln">
</span><span class="typ">int32</span><span class="pln"> values</span><span class="pun">[</span><span class="lit">6</span><span class="pun">];</span><span class="pln">
</span><span class="typ">int32</span><span class="pln"> sockets</span><span class="pun">[</span><span class="lit">3</span><span class="pun">];</span><span class="pln">
</span><span class="typ">uint32</span><span class="pln"> refineditemid</span><span class="pun">;</span><span class="pln"> </span><span class="com">//refinedvnum</span><span class="pln">
</span><span class="typ">int16</span><span class="pln"> refineset</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> altermagicvalues</span><span class="pun">;</span><span class="pln"> </span><span class="com">//altertomagic</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> specular</span><span class="pun">;</span><span class="pln">
</span><span class="typ">uint8</span><span class="pln"> altersocketpercentage</span><span class="pun">;</span><span class="pln"> </span><span class="com">//gainsocket</span></pre>

<table style="width: 100%;">
	<tbody>
		<tr>
			<td>
				Id
			</td>
			<td>
				Number of the item (ie. Sword+0 = 10)
			</td>
		</tr>
		<tr>
			<td>
				Range
			</td>
			<td>
				The range is used to associate a certain item id range to one item in the item proto table.
			</td>
		</tr>
		<tr>
			<td>
				Index name
			</td>
			<td>
				Internally used in the game (such as in parsing server side tables)
			</td>
		</tr>
		<tr>
			<td>
				Translated name
			</td>
			<td>
				Actual name displayed in the client or in quests
			</td>
		</tr>
		<tr>
			<td>
				Type
			</td>
			<td>
				Type of the item, see <a class="new" href="/wiki/index.php?title=List_of_item_types&amp;action=edit&amp;redlink=1" rel="" title="List of item types (page does not exist)">List of known Item types</a>
			</td>
		</tr>
		<tr>
			<td>
				Subtype
			</td>
			<td>
				Extra information which tells the item what it is based from the item type, see <a class="new" href="/wiki/index.php?title=List_of_item_types&amp;action=edit&amp;redlink=1" rel="" title="List of item types (page does not exist)">List of known Item types</a>
			</td>
		</tr>
		<tr>
			<td>
				Weight
			</td>
			<td>
				Unused?
			</td>
		</tr>
		<tr>
			<td>
				Size
			</td>
			<td>
				How many cells does the item take
			</td>
		</tr>
		<tr>
			<td>
				Antiflags
			</td>
			<td>
				Bitflag that defines what you can't do without the item, see <a class="new" href="/wiki/index.php?title=List_of_item_flags&amp;action=edit&amp;redlink=1" rel="" title="List of item flags (page does not exist)">List of known Item flags</a>
			</td>
		</tr>
		<tr>
			<td>
				Flags
			</td>
			<td>
				Bitflag that defines extra informations in what the item can be used for, see <a class="new" href="/wiki/index.php?title=List_of_item_flags&amp;action=edit&amp;redlink=1" rel="" title="List of item flags (page does not exist)">List of known Item flags</a>
			</td>
		</tr>
		<tr>
			<td>
				Wearflags
			</td>
			<td>
				Bitflag that defines where you can equip the item, see <a class="new" href="/wiki/index.php?title=List_of_item_flags&amp;action=edit&amp;redlink=1" rel="" title="List of item flags (page does not exist)">List of known Item flags</a>
			</td>
		</tr>
		<tr>
			<td>
				Immuneflag
			</td>
			<td>
				Unused?
			</td>
		</tr>
		<tr>
			<td>
				buyprice
			</td>
			<td>
				Price that you can buy the item
			</td>
		</tr>
		<tr>
			<td>
				sellprice
			</td>
			<td>
				Price that you can sell the item
			</td>
		</tr>
		<tr>
			<td>
				limits
			</td>
			<td>
				Limits certain usage of the item (Time expire for example)
			</td>
		</tr>
		<tr>
			<td>
				applies
			</td>
			<td>
				Standard bonuses that the item have
			</td>
		</tr>
		<tr>
			<td>
				values
			</td>
			<td>
				The usage of values vary from the type of item
			</td>
		</tr>
		<tr>
			<td>
				sockets
			</td>
			<td>
				The usage of sockets vary from the type of item
			</td>
		</tr>
		<tr>
			<td>
				refineditemid
			</td>
			<td>
				ID of the item that will evolve once it's refined (example: from Sword+0 to Sword+1, refineditemid will be 11)
			</td>
		</tr>
		<tr>
			<td>
				refineset
			</td>
			<td>
				Unused?
			</td>
		</tr>
		<tr>
			<td>
				altermagicvalues
			</td>
			<td>
				Unused?
			</td>
		</tr>
		<tr>
			<td>
				specular
			</td>
			<td>
				Sets the intensity of how the item will shine (The effect that +9 weapons have)
			</td>
		</tr>
		<tr>
			<td>
				altersocketpercentage
			</td>
			<td>
				Unused?
			</td>
		</tr>
	</tbody>
</table>
]]></description><guid isPermaLink="false">11</guid><pubDate>Tue, 07 Nov 2023 16:59:22 +0000</pubDate></item><item><title>Sub file</title><link>https://metin2.dev/docs/pages/file-formats/sub-file-r12/</link><description><![CDATA[<p>
	The Metin2 Subimage file (.sub) is a special type of <a href="https://metin2.dev/docs/pages/script-file-r13/" rel="">Script file</a> that is used to tell the client a rectangle that would be used as a rapresentation of the image.
</p>

<p>
	Consider this example:
</p>

<ul>
	<li>
		You have a big texture atlas of the minimap (like d:/ymir work/ui/minimap.dds), the sub file is used to tell the client where the button location is.
	</li>
	<li>
		All the options listed here are REQUIRED otherwise the file will not get loaded correctly.
	</li>
</ul>

<table style="width: 100%;">
	<caption>
		Options
	</caption>
	<tbody>
		<tr>
			<th>
				Name
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				title
			</td>
			<td>
				subImage
			</td>
			<td>
				Must be subImage
			</td>
		</tr>
		<tr>
			<td>
				version
			</td>
			<td>
				The version changes the image path that is loaded
			</td>
			<td>
				Either "1.0" or "2.0", see below for additional information
			</td>
		</tr>
		<tr>
			<td>
				image
			</td>
			<td>
				The name of the base texture
			</td>
			<td>
				String (includes the commads)
			</td>
		</tr>
		<tr>
			<td>
				left
			</td>
			<td>
				The X position where the image section should start
			</td>
			<td>
				Integer
			</td>
		</tr>
		<tr>
			<td>
				top
			</td>
			<td>
				The Y position where the image section should start
			</td>
			<td>
				Integer
			</td>
		</tr>
		<tr>
			<td>
				right
			</td>
			<td>
				The X position where the image section should end (must be the left+the width of the section)
			</td>
			<td>
				Integer
			</td>
		</tr>
		<tr>
			<td>
				bottom
			</td>
			<td>
				The Y position where the image section should end (must be the top+the height of the section)
			</td>
			<td>
				Integer
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>Version</strong>
</p>

<p>
	The version field is used to tell the client a specific base path where the file should be loaded.<br>
	Both directories supports multiple subdirectories.
</p>

<p>
	<strong>1.0</strong>
</p>

<p>
	The base directory of the file will be "D:/ymir work/ui"<br>
	<strong>Example</strong>: if "image" is "new_system/test.dds" the full image directory will be "D:/ymir work/ui/new_system/test.dds"
</p>

<p>
	<strong>2.0</strong>
</p>

<p>
	The base directory of the file will be the current directory where the sub file exists.<br>
	<strong>Example</strong>: if "image" is "new_system/test.dds" and the sub is stored inside "locale/en/test.sub", the full directory of the image file is "locale/en/new_system/test.dds"
</p>
]]></description><guid isPermaLink="false">12</guid><pubDate>Tue, 07 Nov 2023 17:19:18 +0000</pubDate></item><item><title>Maps</title><link>https://metin2.dev/docs/pages/file-formats/maps-r14/</link><description><![CDATA[<p>
	In Metin2, a Client map is divided in chunks (or areas), each chunk represents a portion of the map.
</p>

<p>
	There are two types of map that the client can load, Indoor and Outdoor maps.
</p>

<p>
	Outdoor maps are all the maps that you freely stay on the outside (not in a closed place), an example of this could be a village.
</p>

<p>
	Indoor maps are all the maps that are closed, an example of this could be the monkey dungeon or the spider dungeon. Indoor maps does not load an environment, as the presence of the sky and the sun should not exist.
</p>

<p>
	Each chunk has it's own ID and represents an area of 128x128.
</p>

<p>
	The chunks size are defined in the Settings file, when you warp to a coordinate, for example: (20, 0), the client will divide the current X and Y of the chunk size to the coordinates, and generate an X and Y id, the X id will be multiplied by 1000.
</p>

<p>
	For example, (0, 20) will be chunk 000000, while chunk (128, 0) will be associated to chunk 001000.
</p>

<p>
	 
</p>

<p>
	<strong>MapProperty.txt</strong>
</p>

<p>
	This file contains the type of the Map. This file is a text file that honors the Metin2 <a href="https://metin2.dev/docs/pages/script-file-r13/" rel="">Script file</a>.<br>
	NOTE: The type of this script MUST be MapProperty
</p>

<table style="width: 100%;">
	<caption>
		Options
	</caption>
	<tbody>
		<tr>
			<th>
				Name
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				MapType
			</td>
			<td>
				Described the type of the map
			</td>
			<td>
				Either "Indoor" or "Outdoor" (with the commas)
			</td>
		</tr>
		<tr>
			<td>
				ParentMapName
			</td>
			<td>
				The map where this map is contained, this is used for boss rooms and guild village zones per each reign.
			</td>
			<td>
				A string (with or without comma)
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>Settings.txt</strong>
</p>

<p>
	 
</p>

<p>
	This file contains the configuration of the Map. This file is a text file that honors the Metin2 <a href="https://metin2.dev/docs/pages/script-file-r13/" rel="">Script file</a>.<br>
	NOTE: The type of this script MUST be MapSetting
</p>

<table style="width: 100%;">
	<caption>
		Options
	</caption>
	<tbody>
		<tr>
			<th>
				Name
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				CellScale
			</td>
			<td>
				?
			</td>
			<td>
				Signed number (Always 200?)
			</td>
		</tr>
		<tr>
			<td>
				HeightScale
			</td>
			<td>
				?
			</td>
			<td>
				Floated number (Always 0.500000?)
			</td>
		</tr>
		<tr>
			<td>
				ViewRadius
			</td>
			<td>
				?
			</td>
			<td>
				Signed number (Always 128?)
			</td>
		</tr>
		<tr>
			<td>
				MapSize
			</td>
			<td>
				Width and Height of the map
			</td>
			<td>
				Two signed numbers
			</td>
		</tr>
		<tr>
			<td>
				BasePosition
			</td>
			<td>
				Base X and Y of the map (Although it is present in the Client but it is only used in the Server)
			</td>
			<td>
				Two signed numbers
			</td>
		</tr>
		<tr>
			<td>
				TextureSet
			</td>
			<td>
				The <span ipsnoautolink="true">TextureSet</span> file name
			</td>
			<td>
				A string
			</td>
		</tr>
		<tr>
			<td>
				Environment
			</td>
			<td>
				The name of the <span ipsnoautolink="true">Environment</span> file
			</td>
			<td>
				A string
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>Atlas minimap</strong>
</p>

<p>
	The following minimap shown when you press M (internally called Atlas).
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="124.52" height="259" style="height: auto;" width="208" data-src="https://metin2.download/picture/KEBjj3vx3ilpUxV80v9hKYM44uicoT99/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<p>
	There are two known ways of setting up the atlas, first is by providing a file called "atlas.sub" inside the map directory, the second way is by creating a file called "atlas.sub" inside the following folder: "d:/ymir work/ui/atlas/(map name)".
</p>

<p>
	If this image does not exist then the game will report that the Atlas map cannot be shown.<br>
	The sub file respect the style of a Metin2 <a href="https://metin2.dev/docs/pages/sub-file-r12/" rel="">Sub file</a>.
</p>

<p>
	 
</p>

<p>
	<span style="font-size:36px;">Chunk files</span>
</p>

<p>
	The following files listed are contained in each chunk map folder.
</p>

<p>
	 
</p>

<p>
	<strong>attr.atr</strong>
</p>

<p>
	This file defines the collision of an area.<br>
	The first 6 bytes MUST contain the following data:
</p>

<pre class="ipsCode" id="ips_uid_8278_11">0x4A 0x0A (File identifier)
0x00 0x01 (Width of the area, always 256)
0x00 0x01 (Height of the area, always 256)</pre>

<p>
	What follows after is the collision data of every point of the map. The data lists each X coordinate for one Y coordinate. (From (0,0) to (256,0) then (0,1) and so on).<br>
	A collision byte contains informations inside it's bits.
</p>

<table style="width: 100%;">
	<caption>
		Known collsion bits
	</caption>
	<tbody>
		<tr>
			<th style="text-align:left;">
				Number
			</th>
			<th>
				Description
			</th>
		</tr>
		<tr>
			<td>
				Bit 1
			</td>
			<td>
				An entity can walk into that coordinate
			</td>
		</tr>
		<tr>
			<td>
				Bit 2
			</td>
			<td>
				The coordinate is filled with water
			</td>
		</tr>
		<tr>
			<td>
				Bit 3
			</td>
			<td>
				PVP is disabled in that coordinate
			</td>
		</tr>
		<tr>
			<td>
				Bit 8
			</td>
			<td>
				A guild building can be built in that coordinate
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>water.wtr</strong>
</p>

<p>
	This file defines the water height information, this defines how much space should the water occupy in the map.<br>
	The first 6 bytes MUST contain the following content:
</p>

<pre class="ipsCode" id="ips_uid_5054_4">32 15 (File identifier)
80 00 (Width of the water map)
80 00 (Height of the water map)</pre>

<p>
	The 7th byte contains the number of water height contained in the map, if the number is 0, no map will be loaded.<br>
	The next data contains the water height numbers, the data lists each X coordinate for one Y coordinate. (From (0,0) to (256,0) then (0,1) and so on assuming 256 is the width of the chunk).
</p>

<p>
	Each height number is stored in a 4-byte number.<br>
	For example, the coordinate (1,2) will start in the 2052th ( (2*256) + 1) * 4) position of the data array, assuming the map width and height are 256.
</p>

<p>
	NOTE: The game references a support for 2-byte height, but they looks like they can throw a copy error / disabled.<br>
	NOTE: The client only supports width and height of 256, although is possible to make bigger chunks.
</p>

<p>
	 
</p>

<p>
	<strong>AreaProperty.txt</strong>
</p>

<p>
	This file is a text file that honors the Metin2 [Script file].<br>
	NOTE: The type of this script MUST be AreaProperty
</p>

<table style="width: 100%;">
	<caption>
		Options
	</caption>
	<tbody>
		<tr>
			<th>
				Name
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				AreaName
			</td>
			<td>
				?
			</td>
			<td>
				A string with comma
			</td>
		</tr>
		<tr>
			<td>
				NumWater
			</td>
			<td>
				Number of water maps contained?
			</td>
			<td>
				A signed number
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>AreaData.txt</strong>
</p>

<p>
	This file contains all the 3D objects that the chunk contains.<br>
	This file is a text file that honors the Metin2 <a href="https://metin2.dev/docs/pages/script-file-r13/" rel="">Script file</a> with nodes.<br>
	NOTE: This file starts with AreaDataFile not with a ScriptFile.
</p>

<table style="width: 100%;">
	<caption>
		Options
	</caption>
	<tbody>
		<tr>
			<th>
				Name
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				ObjectCount
			</td>
			<td>
				Number of objects contained in the map
			</td>
			<td>
				A signed number
			</td>
		</tr>
	</tbody>
</table>

<p>
	Based from the number of object counts, there will be one or more object information vector contained inside.<br>
	NOTE: Please note that the count starts from 0.
</p>

<table style="width: 100%;">
	<caption>
		Object vector
	</caption>
	<tbody>
		<tr>
			<th>
				Number
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				1
			</td>
			<td>
				X position
			</td>
			<td>
				Float number
			</td>
		</tr>
		<tr>
			<td>
				2
			</td>
			<td>
				Y position
			</td>
			<td>
				Float number
			</td>
		</tr>
		<tr>
			<td>
				3
			</td>
			<td>
				Z position
			</td>
			<td>
				Float number
			</td>
		</tr>
		<tr>
			<td>
				4
			</td>
			<td>
				CRC32 of the file name (.prt)
			</td>
			<td>
				Signed integer
			</td>
		</tr>
		<tr>
			<td>
				5
			</td>
			<td>
				Rotation
			</td>
			<td>
				if the rotation value contains # then 3 float numbers are used to represent the yaw, pitch and roll (Yaw#Pitch#Roll), otherwise, only one float number is used to represent the roll
			</td>
		</tr>
		<tr>
			<td>
				6
			</td>
			<td>
				A number that will be added to the object height
			</td>
			<td>
				Signed integer (can start with - to indicate a subtraction)
			</td>
		</tr>
		<tr>
			<td>
				7 to 15
			</td>
			<td>
				The name of the portal point
			</td>
			<td>
				One or more name that represents the id of the portal (if the object is a portal), the ID of the portal starts from 0 to 7 (max numbers of portals is 8).
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>AreaAmbienceData.txt</strong>
</p>

<p>
	This is another file that loads the 3D objects that a chunk contains, it is currently not known the difference between ambience data and normal data.<br>
	This file is a text file that honors the Metin2 [Script file].<br>
	NOTE: This file starts with AreaAmbienceDataFile not with a ScriptType.
</p>

<table style="width: 100%;">
	<caption>
		Options
	</caption>
	<tbody>
		<tr>
			<th>
				Name
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				ObjectCount
			</td>
			<td>
				Number of objects in this map
			</td>
			<td>
				Signed number
			</td>
		</tr>
	</tbody>
</table>

<p>
	Based from the number of object counts, there will be one or more object information vector contained inside.<br>
	NOTE: Please note that the count starts from 0.
</p>

<table style="width: 100%;">
	<caption>
		Object vector
	</caption>
	<tbody>
		<tr>
			<th>
				Number
			</th>
			<th>
				Description
			</th>
			<th>
				Possible values
			</th>
		</tr>
		<tr>
			<td>
				1
			</td>
			<td>
				X position
			</td>
			<td>
				Float number
			</td>
		</tr>
		<tr>
			<td>
				2
			</td>
			<td>
				Y position
			</td>
			<td>
				Float number
			</td>
		</tr>
		<tr>
			<td>
				3
			</td>
			<td>
				Z position
			</td>
			<td>
				Float number
			</td>
		</tr>
		<tr>
			<td>
				4
			</td>
			<td>
				CRC32 of the file name (.prt)
			</td>
			<td>
				Signed integer
			</td>
		</tr>
		<tr>
			<td>
				5
			</td>
			<td>
				?
			</td>
			<td>
				Signed integer
			</td>
		</tr>
		<tr>
			<td>
				6
			</td>
			<td>
				?
			</td>
			<td>
				Float number
			</td>
		</tr>
	</tbody>
</table>

<p>
	 
</p>

<p>
	<strong>minimap.dds</strong>
</p>

<p>
	This texture contains a 256x256 representation of the chunk that will be used in this minimap:
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="100.73" height="138" style="height: auto;" width="137" data-src="https://metin2.download/picture/n1R0IHFr6ZH9vOTNrD7lUuL8vrvS8i8H/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<p>
	 
</p>

<p>
	<strong>shadowmap.dds</strong>
</p>

<p>
	This texture contains a 256x256 used to draw the shadows of the minimap chunk.
</p>

<p>
	 
</p>

<p>
	<strong>height.raw</strong>
</p>

<p>
	This file contains the information of the height of the terrain.<br>
	The file has a fixed size of 34322 bytes and it always represents a map chunk with width and height 131x131.<br>
	The Z axes of the map is expressed inside two bytes (hence why the size is 131*131*2).
</p>

<p>
	 
</p>

<p>
	<strong>tile.raw</strong>
</p>

<p>
	The file usage is unknown.<br>
	This file has a fixed size of 66564 byes and it always represents a map chunk with width and height 258x258.
</p>
]]></description><guid isPermaLink="false">14</guid><pubDate>Tue, 07 Nov 2023 17:26:00 +0000</pubDate></item><item><title>Mob Proto</title><link>https://metin2.dev/docs/pages/file-formats/mob-proto-r15/</link><description><![CDATA[<p>
	The Mob Proto is a crypted file that contains all informations about the monsters and NPCs included in the game. This file is present both in the client and the server.
</p>

<ul>
	<li>
		In the server, this file is used to process the mob information (such as damage).
	</li>
	<li>
		In the client, this file is used to perform several client-side checks (in order to reduce the amount of data sent to the server) and what actually is displayed in the item information, another example if the mob directory.
	</li>
</ul>

<p>
	The Mob Proto contains only one format (MMPT), which is then crypted as a Crypted Object.
</p>

<p>
	 
</p>

<p>
	<strong>MMPT format</strong>
</p>

<p>
	<img alt=".png" class="ipsImage" data-ratio="6.59" height="44" style="height: auto;" width="668" data-src="https://metin2.download/picture/Y0Ys2a4kU896Mnvl0T3Bjc03Qh6SxDy6/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<pre class="ipsCode" id="ips_uid_9708_4">Bytes in red: FourCC (MMPT)
Bytes in blue: Number of elements
Bytes in gray: Size of the crypted object data
Bytes in orange: Begin of crypted object data</pre>
]]></description><guid isPermaLink="false">15</guid><pubDate>Tue, 07 Nov 2023 17:47:39 +0000</pubDate></item><item><title>TarPackage</title><link>https://metin2.dev/docs/pages/file-formats/tarpackage-r18/</link><description><![CDATA[<p>
	Tar package file is a file format used to compress Metin1 data files.<br>
	NOTE: The files are encrypted with an unknown format.  
</p>

<p>
	 <img alt=".png" class="ipsImage" data-ratio="14.78" height="110" style="height: auto;" width="744" data-src="https://metin2.download/picture/8kd0krI4KNUoNvFqkvQY9RV11xJ2nkjy/.png" src="https://metin2.dev/applications/core/interface/js/spacer.png">
</p>

<ul>
	<li>
		4 bytes in black, only present at the beginning: Number of file entries included.
	</li>
	<li>
		One or more file entry
	</li>
</ul>

<p>
	 
</p>

<p>
	<strong>File Entry</strong>
</p>

<ul>
	<li>
		32 bytes in green: Filename (Encoded in Windows-949).
	</li>
	<li>
		4 bytes in purple: Offset of the file (relative to the stat of the tar file)-.
	</li>
	<li>
		4 bytes in blue: Size of the file.
	</li>
	<li>
		Bytes in grey: beginning of a new entry.
	</li>
</ul>
]]></description><guid isPermaLink="false">18</guid><pubDate>Tue, 07 Nov 2023 18:24:55 +0000</pubDate></item></channel></rss>
