<?php
$file = file_get_contents('http://svn.otland.net/public/viewvc.cgi/forgottenserver/tags/0.3.6pl1/data/items/items.xml?revision=80&view=co');
$xml = new DOMDocument();
$xml->loadXML($file);
$attrs = array(
'type',
'name',
'plural',
'description',
'runespellname',
'weight',
'showcount',
'armor',
'defense',
'extradefense', 'extradef',
'attack',
'extraattack', 'extraatk',
'attackspeed',
'rotateto',
'moveable', 'movable',
'blockprojectile',
'allowpickupable',
'floorchange',
'corpsetype',
'containersize',
'fluidsource',
'writeable',
'readable',
'maxtextlen',
'writeonceitemid',
'worth',
'forceserialize', 'forceserialization', 'forcesave',
'leveldoor',
'weapontype',
'slottype',
'ammotype',
'shoottype',
'effect',
'range',
'stopduration',
'decayto',
'transformequipto',
'transformdeequipto',
'duration',
'showduration',
'charges',
'showcharges',
'showattributes',
'breakchance',
'ammoaction',
'hitchance',
'maxhitchance',
'preventloss',
'preventdrop',
'invisible',
'speed',
'healthgain',
'healthticks',
'managain',
'manaticks',
'manashield',
'skillsword',
'skillaxe',
'skillclub',
'skilldist',
'skillfish',
'skillshield',
'skillfist',
'maxhealthpoints', 'maxhitpoints',
'maxhealthpercent', 'maxhitpointspercent',
'maxmanapoints',
'maxmanapercent', 'maxmanapointspercent',
'soulpoints',
'soulpercent', 'soulpointspercent',
'magiclevelpoints', 'magicpoints',
'magiclevelpercent', 'magicpointspercent',
'increasemagicvalue',
'increasemagicpercent',
'increasehealingvalue',
'increasehealingpercent',
'absorbpercentall',
'absorbpercentelements',
'absorbpercentmagic',
'absorbpercentenergy',
'absorbpercentfire',
'absorbpercentpoison', 'absorbpercentearth',
'absorbpercentice',
'absorbpercentholy',
'absorbpercentdeath',
'absorbpercentlifedrain',
'absorbpercentmanadrain',
'absorbpercentdrown',
'absorbpercentphysical',
'absorbpercenthealing',
'absorbpercentundefined',
'reflectpercentall',
'reflectpercentelements',
'reflectpercentmagic',
'reflectpercentenergy',
'reflectpercentfire',
'reflectpercentpoison', 'reflectpercentearth',
'reflectpercentice',
'reflectpercentholy',
'reflectpercentdeath',
'reflectpercentlifedrain',
'reflectpercentmanadrain',
'reflectpercentdrown',
'reflectpercentphysical',
'reflectpercenthealing',
'reflectpercentundefined',
'reflectchanceall',
'reflectchanceelements',
'reflectchancemagic',
'reflectchanceenergy',
'reflectchancefire',
'reflectchancepoison', 'reflectchanceearth',
'reflectchanceice',
'reflectchanceholy',
'reflectchancedeath',
'reflectchancelifedrain',
'reflectchancemanadrain',
'reflectchancedrown',
'reflectchancephysical',
'reflectchancehealing',
'reflectchanceundefined',
'suppressshock', 'suppressenergy',
'suppressburn', 'suppressfire',
'suppresspoison', 'suppressearth',
'suppressfreeze', 'suppressice',
'suppressdazzle', 'suppressholy',
'suppresscurse', 'suppressdeath',
'suppressdrown',
'suppressphysical',
'suppresshaste',
'suppressparalyze',
'suppressdrunk',
'suppressregeneration',
'suppresssoul',
'suppressoutfit',
'suppressinvisible',
'suppressinfight',
'suppressexhaust',
'suppressmuted',
'suppresspacified',
'suppresslight',
'suppressattributes',
'suppressmanashield',
'elementphysical',
'elementfire',
'elementenergy',
'elementearth',
'elementice',
'elementholy',
'elementdeath',
'elementlifedrain',
'elementmanadrain',
'elementhealing',
'elementundefined',
'replaceable', 'replacable',
'partnerdirection',
'maletransformto',
'femaletransformto',
'transformto'
);
$items = array();
foreach($xml->getElementsByTagName('item') as $item)
{
if($item->getAttribute('id'))
{
if($item->getAttribute('name'))
$items[$item->getAttribute('id')]['name'] = $item->getAttribute('name');
if($item->getAttribute('article'))
$items[$item->getAttribute('id')]['article'] = $item->getAttribute('article');
if($item->getAttribute('plural'))
$items[$item->getAttribute('id')]['plural'] = $item->getAttribute('plural');
foreach($item->getElementsByTagName('attribute') as $attr)
{
foreach($attrs as $attr_)
{
if(strtolower($attr->getAttribute('key')) == $attr_)
$items[$item->getAttribute('id')][$attr_] = $attr->getAttribute('value');
elseif(strtolower($attr->getAttribute('key')) == 'field')
{
$items[$item->getAttribute('id')]['fieldtype'] = $attr->getAttribute('value');
$fieldAttrs = array('damage', 'ticks', 'count', 'start');
$dmg = 1;
foreach($attr->getElementsByTagName('attribute') as $field)
foreach($fieldAttrs as $fattr)
{
if(strtolower($field->getAttribute('key')) == 'start')
$items[$item->getAttribute('id')]['startingdamage'] = $field->getAttribute('value');
elseif(strtolower($field->getAttribute('key')) == 'damage')
if($items[$item->getAttribute('id')]['startingdamage'] > 0)
$items[$item->getAttribute('id')]['totaldamage'] = $field->getAttribute('value');
else
{
if($dmg == 1)
$items[$item->getAttribute('id')]['stepindamage'] = $field->getAttribute('value');
else
$items[$item->getAttribute('id')]['conditiondamage'] = $field->getAttribute('value');
$dmg = 0;
}
elseif(strtolower($field->getAttribute('key')) == $fattr)
$items[$item->getAttribute('id')][$fattr] = $field->getAttribute('value');
}
}
}
}
}
}
var_dump($items);
?>