<?php
require_once "L2Data.php";
$data = L2SData::loadData("npcdata.txt", 2);
$pch = L2SData::loadPch("item_pch.txt");
// ===
function getGroupedList($type, $data)
{
global $dom;
$node = $dom->createElement("rewardlist");
$node->setAttribute("type", $type);
for ($i = 0; $i < $data["count"]; $i++)
{
$gNode = $dom->createElement("group");
$gNode->setAttribute("chance", $data[$i]["chance"]);
for ($j = 0; $j < $data[$i]["count"]; $j++)
{
$rNode = $dom->createElement("reward");
$rNode->setAttribute("id", $data[$i][$j][0]);
$rNode->setAttribute("min", $data[$i][$j][1]);
$rNode->setAttribute("max", $data[$i][$j][2]);
$rNode->setAttribute("chance", $data[$i][$j][3]);
$gNode->appendChild($rNode);
}
$node->appendChild($gNode);
}
return $node;
}
function getNotGroupedList($type, $data)
{
global $dom;
$node = $dom->createElement("rewardlist");
$node->setAttribute("type", $type);
for ($j = 0; $j < $data["count"]; $j++)
{
$rNode = $dom->createElement("reward");
$rNode->setAttribute("id", $data[$j][0]);
$rNode->setAttribute("min", $data[$j][1]);
$rNode->setAttribute("max", $data[$j][2]);
$rNode->setAttribute("chance", $data[$j][3]);
$node->appendChild($rNode);
}
return $node;
}
// ===
$dom = new DOMDocument();
$dom->formatOutput = true;
$node = $dom->appendChild($dom->createElement("list"));
ksort($data);
foreach ($data as $id => $npc)
{
$drop1 = L2SData::parseList(L2SData::getValue($npc, "additional_make_multi_list"), L2_ITEMS_LIST_GROUPED);
$drop2 = L2SData::parseList(L2SData::getValue($npc, "ex_item_drop_list"), L2_ITEMS_LIST_GROUPED);
$drop3 = L2SData::parseList(L2SData::getValue($npc, "additional_make_list"), L2_ITEMS_LIST_NOT_GROUPED);
$spoil = L2SData::parseList(L2SData::getValue($npc, "corpse_make_list"), L2_ITEMS_LIST_NOT_GROUPED);
if (empty($drop1) && empty($drop2) && empty($drop3) && empty($spoil))
continue;
$npcNode = $dom->createElement("npc");
$npcNode->setAttribute("id", $id);
if (!empty($drop1))
{
$drop1 = L2SData::applyPch($drop1, $pch);
$npcNode->appendChild(getGroupedList("RATED_GROUPED", $drop1));
}
if (!empty($drop2))
{
$drop2 = L2SData::applyPch($drop2, $pch);
$npcNode->appendChild(getGroupedList("NOT_RATED_GROUPED", $drop2));
}
if (!empty($drop3))
{
$drop3 = L2SData::applyPch($drop3, $pch);
$npcNode->appendChild(getNotGroupedList("NOT_RATED_NOT_GROUPED", $drop3));
}
if (!empty($spoil))
{
$spoil = L2SData::applyPch($spoil, $pch);
$npcNode->appendChild(getNotGroupedList("SWEEP", $spoil));
}
$node->appendChild($npcNode);
}
file_put_contents("droplist.xml", $dom->saveXML());
?>