}
}
}
}
set.set("bodypart", slot);
ItemTemplate template = null;
try
{
template = new EtcItemTemplate(set);
}
catch (Exception e)
{
warn("Fail create item: " + set.get("item_id"), e);
continue;
}
for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();)
{
org.dom4j.Element subElement = subIterator.next();
String subName = subElement.getName();
if (subName.equalsIgnoreCase("for"))
{
parseFor(subElement, template);
}
else if (subName.equalsIgnoreCase("triggers"))
{
parseTriggers(subElement, template);
}
else if (subName.equalsIgnoreCase("skills"))
{
for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator.hasNext();)
{
org.dom4j.Element nextElement = nextIterator.next();
int id = Integer.parseInt(nextElement.attributeValue("id"));
int level = Integer.parseInt(nextElement.attributeValue("level"));
Skill skill = SkillTable.getInstance().getInfo(id, level);
if (skill != null)
{
template.attachSkill(skill);
}
else
{
info("Skill not found(" + id + "," + level + ") for item:" + set.getObject("item_id") + "; file:" + getCurrentFileName());
}
}
}
else if (subName.equalsIgnoreCase("enchant4_skill"))
{
int id = Integer.parseInt(subElement.attributeValue("id"));
int level = Integer.parseInt(subElement.attributeValue("level"));
Skill skill = SkillTable.getInstance().getInfo(id, level);
if (skill != null)
{
template.setEnchant4Skill(skill);
}
}
else if (subName.equalsIgnoreCase("unequip_skill"))
{
int id = Integer.parseInt(subElement.attributeValue("id"));
int level = Integer.parseInt(subElement.attributeValue("level"));
Skill skill = SkillTable.getInstance().getInfo(id, level);
if (skill != null)
{
template.setUnequipeSkill(skill);
}
}
else if (subName.equalsIgnoreCase("cond"))
{
Condition condition = parseFirstCond(subElement);
if (condition != null)
{
int msgId = parseNumber(subElement.attributeValue("msgId")).intValue();
condition.setSystemMsg(msgId);
template.setCondition(condition);
}
}
else if (subName.equalsIgnoreCase("attributes"))
{
int[] attributes = new int[6];
for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator.hasNext();)
{
org.dom4j.Element nextElement = nextIterator.next();
Element element;
if (nextElement.getName().equalsIgnoreCase("attribute"))
{
element = Element.getElementByName(nextElement.attributeValue("element"));
attributes[element.getId()] = Integer.parseInt(nextElement.attributeValue("value"));
}
}
template.setBaseAtributeElements(attributes);
}
else if (subName.equalsIgnoreCase("enchant_options"))
{
for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator.hasNext();)
{
org.dom4j.Element nextElement = nextIterator.next();
if (nextElement.getName().equalsIgnoreCase("level"))
{
int val = Integer.parseInt(nextElement.attributeValue("val"));
int i = 0;
int[] options = new int[3];
for (org.dom4j.Element optionElement : nextElement.elements())
{
OptionDataTemplate optionData = OptionDataHolder.getInstance().getTemplate(Integer.parseInt(optionElement.attributeValue("id")));
if (optionData == null)
{
error("Not found option_data for id: " + optionElement.attributeValue("id") + "; item_id: " + set.get("item_id"));
continue;
}
options[i++] = optionData.getId();
}
template.addEnchantOptions(val, options);
}
}
}
}
getHolder().addItem(template);