Updated Crystallizable item data.

Adapted from: L2jUnity free files.
This commit is contained in:
MobiusDev 2017-12-19 21:12:43 +00:00
parent 3f9c0c6696
commit 00fc352835
66 changed files with 8262 additions and 1895 deletions

View File

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/CrystalizableItems.xsd">
<crystalizable_item id="19776"> <!-- Seraph Gloves - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19777"> <!-- Seraph Shoes - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19473"> <!-- Twilight Belt -->
<item id="17527" count="1" chance="47.76" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="1.0" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="8.29" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="1.19" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18065"> <!-- Blessed Seraph Sigil - Robe -->
<item id="17527" count="5" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.38" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.87" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="10.06" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18706"> <!-- Apocalypse Shaper - Focus -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="6676"> <!-- Sealed Imperial Crusader Gauntlets -->
<item id="960" count="1" chance="63.9" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="2.84" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="1.78" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="3.2" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19544"> <!-- Twilight Leather Helmet - Assassin Type / Light -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="16025"> <!-- Freya's Necklace -->
<item id="960" count="4" chance="75.96" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="13.5" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="8.44" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="15.19" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19545"> <!-- Twilight Leather Armor - Assassin Type / Light -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19546"> <!-- Twilight Leather Leggings - Assassin Type / Light -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19547"> <!-- Twilight Leather Gloves - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19548"> <!-- Twilight Leather Boots - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="30048"> <!-- Apocalypse Buster - Mana Up + Acumen -->
<item id="17526" count="2" chance="62.35" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.99" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="33.25" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="39.9" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18722"> <!-- Apocalypse Thrower - Damage Up -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19746"> <!-- Twilight Helmet - Defense Type / Heavy -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19747"> <!-- Twilight Breastplate - Defense Type / Heavy -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19748"> <!-- Twilight Gaiters - Defense Type / Heavy -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19749"> <!-- Twilight Gauntlets - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19750"> <!-- Twilight Boots - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19751"> <!-- Twilight Shield - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18732"> <!-- Apocalypse Caster - Acumen -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="17401"> <!-- Seraph Shield - Heavy Armor -->
<item id="17527" count="4" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.71" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="55.89" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="8.05" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19773"> <!-- Seraph Circlet - Recovery Type / Robe -->
<item id="17527" count="5" chance="91.98" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="9.58" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="79.85" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="11.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19774"> <!-- Seraph Tunic - Recovery Type / Robe -->
<item id="17527" count="13" chance="94.34" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="25.55" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="3" chance="70.98" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="30.66" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19455"> <!-- Istina's Bracelet -->
<item id="17527" count="1" chance="28.45" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="0.59" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="4.94" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="0.71" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19775"> <!-- Seraph Stockings - Recovery Type / Robe -->
<item id="17527" count="8" chance="95.82" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="15.97" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="2" chance="66.54" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="19.16" /> <!-- Elcyum Crystal -->
</crystalizable_item>
</list>

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
@ -259,7 +259,7 @@ public class AdminReload implements IAdminCommandHandler
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
break;
}

View File

@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.SayuneData;
@ -217,7 +217,7 @@ public class Reload implements ITelnetCommand
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded item crystalization data.");
}
case "ability":

View File

@ -1,22 +0,0 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="crystalizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,49 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="templates">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_template" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="crystalType" use="required" />
<xs:attribute type="xs:string" name="crystallizationType" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -66,7 +66,7 @@ import com.l2jmobius.gameserver.data.xml.impl.HennaData;
import com.l2jmobius.gameserver.data.xml.impl.HitConditionBonusData;
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.KarmaData;
import com.l2jmobius.gameserver.data.xml.impl.LuckyGameData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
@ -220,7 +220,7 @@ public class GameServer
EnchantItemGroupsData.getInstance();
EnchantItemData.getInstance();
EnchantItemOptionsData.getInstance();
ItemCrystalizationData.getInstance();
ItemCrystallizationData.getInstance();
OptionData.getInstance();
AugmentationData.getInstance();
EnchantItemHPBonusData.getInstance();

View File

@ -1,102 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public final class ItemCrystalizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystalizationData.class.getName());
private final Map<Integer, CrystalizationData> _items = new HashMap<>();
protected ItemCrystalizationData()
{
load();
}
@Override
public void load()
{
parseDatapackFile("data/CrystalizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded: " + _items.size() + " Items");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystalizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final CrystalizationData data = new CrystalizationData(id);
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
final NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
data.addItem(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, data);
}
}
}
}
}
public CrystalizationData getCrystalization(int itemId)
{
return _items.get(itemId);
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystalizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystalizationData _instance = new ItemCrystalizationData();
}
}

View File

@ -0,0 +1,243 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.CrystallizationType;
import com.l2jmobius.gameserver.model.holders.CrystallizationDataHolder;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
/**
* @author UnAfraid
*/
public final class ItemCrystallizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystallizationData.class.getName());
private final Map<CrystalType, Map<CrystallizationType, List<ItemChanceHolder>>> _crystallizationTemplates = new EnumMap<>(CrystalType.class);
private final Map<Integer, CrystallizationDataHolder> _items = new HashMap<>();
protected ItemCrystallizationData()
{
load();
}
@Override
public void load()
{
_crystallizationTemplates.clear();
for (CrystalType crystalType : CrystalType.values())
{
_crystallizationTemplates.put(crystalType, new EnumMap<>(CrystallizationType.class));
}
_items.clear();
parseDatapackFile("data/CrystallizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _crystallizationTemplates.size() + " crystallization templates.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _items.size() + " pre-defined crystallizable items.");
// Generate remaining data.
generateCrystallizationData();
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
{
if ("templates".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_template".equalsIgnoreCase(d.getNodeName()))
{
final CrystalType crystalType = parseEnum(d.getAttributes(), CrystalType.class, "crystalType");
final CrystallizationType crystallizationType = parseEnum(d.getAttributes(), CrystallizationType.class, "crystallizationType");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_crystallizationTemplates.get(crystalType).put(crystallizationType, crystallizeRewards);
}
}
}
else if ("items".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, new CrystallizationDataHolder(id, crystallizeRewards));
}
}
}
}
}
}
}
public int getLoadedCrystallizationTemplateCount()
{
return _crystallizationTemplates.size();
}
private List<ItemChanceHolder> calculateCrystallizeRewards(L2Item item, List<ItemChanceHolder> crystallizeRewards)
{
if (crystallizeRewards == null)
{
return null;
}
final List<ItemChanceHolder> rewards = new ArrayList<>();
for (ItemChanceHolder reward : crystallizeRewards)
{
double chance = reward.getChance() * item.getCrystalCount();
long count = reward.getCount();
if (chance > 100.)
{
double countMul = Math.ceil(chance / 100.);
chance /= countMul;
count *= countMul;
}
rewards.add(new ItemChanceHolder(reward.getId(), chance, count));
}
return rewards;
}
private void generateCrystallizationData()
{
final int previousCount = _items.size();
for (L2Item item : ItemTable.getInstance().getAllItems())
{
// Check if the data has not been generated.
if (((item instanceof L2Weapon) || (item instanceof L2Armor)) && item.isCrystallizable() && !_items.containsKey(item.getId()))
{
final List<ItemChanceHolder> holder = _crystallizationTemplates.get(item.getCrystalType()).get((item instanceof L2Weapon) ? CrystallizationType.WEAPON : CrystallizationType.ARMOR);
if (holder != null)
{
_items.put(item.getId(), new CrystallizationDataHolder(item.getId(), calculateCrystallizeRewards(item, holder)));
}
}
}
LOGGER.info(getClass().getSimpleName() + ": Generated " + (_items.size() - previousCount) + " crystallizable items from templates.");
}
public List<ItemChanceHolder> getCrystallizationTemplate(CrystalType crystalType, CrystallizationType crystallizationType)
{
return _crystallizationTemplates.get(crystalType).get(crystallizationType);
}
/**
* @param itemId
* @return {@code CrystallizationData} for unenchanted items (enchanted items just have different crystal count, but same rewards),<br>
* or {@code null} if there is no such data registered.
*/
public CrystallizationDataHolder getCrystallizationData(int itemId)
{
return _items.get(itemId);
}
/**
* @param item to calculate its worth in crystals.
* @return List of {@code ItemChanceHolder} for the rewards with altered crystal count.
*/
public List<ItemChanceHolder> getCrystallizationRewards(L2ItemInstance item)
{
final List<ItemChanceHolder> result = new ArrayList<>();
final CrystallizationDataHolder data = getCrystallizationData(item.getId());
if (data != null)
{
// If there are no crystals on the template, add such.
if (data.getItems().stream().noneMatch(i -> i.getId() == item.getItem().getCrystalItemId()))
{
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
result.addAll(data.getItems());
}
else
{
// Add basic crystal reward.
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
return result;
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystallizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystallizationData _instance = new ItemCrystallizationData();
}
}

View File

@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
/**
* @author Nik
*/
public enum CrystallizationType
{
NONE,
WEAPON,
ARMOR,
ACCESORY;
public static CrystallizationType getByItem(L2Item item)
{
if (item instanceof L2Weapon)
{
return WEAPON;
}
if (item instanceof L2Armor)
{
return ARMOR;
}
switch (item.getBodyPart())
{
case L2Item.SLOT_R_EAR:
case L2Item.SLOT_L_EAR:
case L2Item.SLOT_R_FINGER:
case L2Item.SLOT_L_FINGER:
case L2Item.SLOT_NECK:
case L2Item.SLOT_HAIR:
case L2Item.SLOT_HAIR2:
case L2Item.SLOT_HAIRALL:
{
return ACCESORY;
}
}
return NONE;
}
}

View File

@ -1,51 +1,45 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public class CrystalizationData
{
private final int _id;
private final List<ItemChanceHolder> _items = new ArrayList<>();
public CrystalizationData(int id)
{
_id = id;
}
public int getId()
{
return _id;
}
public void addItem(ItemChanceHolder item)
{
_items.add(item);
}
public List<ItemChanceHolder> getItems()
{
return _items;
}
}
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.holders;
import java.util.Collections;
import java.util.List;
/**
* @author UnAfraid
*/
public class CrystallizationDataHolder
{
private final int _id;
private final List<ItemChanceHolder> _items;
public CrystallizationDataHolder(int id, List<ItemChanceHolder> items)
{
_id = id;
_items = Collections.unmodifiableList(items);
}
public int getId()
{
return _id;
}
public List<ItemChanceHolder> getItems()
{
return Collections.unmodifiableList(_items);
}
}

View File

@ -16,16 +16,14 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
@ -110,6 +108,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
if (item.isHeroItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
@ -122,18 +121,19 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE))
{
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId());
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
{
activeChar.sendMessage("You cannot use this item.");
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
@ -199,6 +199,13 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
return;
}
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(itemToRemove);
if ((crystallizationRewards == null) || crystallizationRewards.isEmpty())
{
activeChar.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
return;
}
// activeChar.setInCrystallize(true);
// unequip if needed
@ -234,19 +241,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
iu.addRemovedItem(removedItem);
activeChar.sendInventoryUpdate(iu);
final int crystalId = itemToRemove.getItem().getCrystalItemId();
final int crystalAmount = itemToRemove.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
if (data != null)
{
data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
}
for (ItemChanceHolder holder : items)
for (ItemChanceHolder holder : crystallizationRewards)
{
final double rand = Rnd.nextDouble() * 100;
if (rand < holder.getChance())

View File

@ -16,14 +16,12 @@
*/
package com.l2jmobius.gameserver.network.clientpackets.crystalization;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
@ -180,26 +178,17 @@ public class RequestCrystallizeEstimate implements IClientIncomingPacket
return;
}
activeChar.setInCrystallize(true);
// add crystals
final int crystalId = item.getItem().getCrystalItemId();
final int crystalAmount = item.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(item.getId());
if (data != null)
// Show crystallization rewards window.
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(item);
if ((crystallizationRewards != null) && !crystallizationRewards.isEmpty())
{
for (ItemChanceHolder holder : data.getItems())
{
if (holder.getId() != crystalId)
{
items.add(holder);
}
}
activeChar.setInCrystallize(true);
client.sendPacket(new ExGetCrystalizingEstimation(crystallizationRewards));
}
else
{
client.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
}
client.sendPacket(new ExGetCrystalizingEstimation(items));
}
}

View File

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/CrystalizableItems.xsd">
<crystalizable_item id="19776"> <!-- Seraph Gloves - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19777"> <!-- Seraph Shoes - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19473"> <!-- Twilight Belt -->
<item id="17527" count="1" chance="47.76" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="1.0" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="8.29" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="1.19" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18065"> <!-- Blessed Seraph Sigil - Robe -->
<item id="17527" count="5" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.38" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.87" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="10.06" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18706"> <!-- Apocalypse Shaper - Focus -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="6676"> <!-- Sealed Imperial Crusader Gauntlets -->
<item id="960" count="1" chance="63.9" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="2.84" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="1.78" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="3.2" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19544"> <!-- Twilight Leather Helmet - Assassin Type / Light -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="16025"> <!-- Freya's Necklace -->
<item id="960" count="4" chance="75.96" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="13.5" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="8.44" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="15.19" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19545"> <!-- Twilight Leather Armor - Assassin Type / Light -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19546"> <!-- Twilight Leather Leggings - Assassin Type / Light -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19547"> <!-- Twilight Leather Gloves - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19548"> <!-- Twilight Leather Boots - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="30048"> <!-- Apocalypse Buster - Mana Up + Acumen -->
<item id="17526" count="2" chance="62.35" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.99" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="33.25" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="39.9" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18722"> <!-- Apocalypse Thrower - Damage Up -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19746"> <!-- Twilight Helmet - Defense Type / Heavy -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19747"> <!-- Twilight Breastplate - Defense Type / Heavy -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19748"> <!-- Twilight Gaiters - Defense Type / Heavy -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19749"> <!-- Twilight Gauntlets - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19750"> <!-- Twilight Boots - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19751"> <!-- Twilight Shield - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18732"> <!-- Apocalypse Caster - Acumen -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="17401"> <!-- Seraph Shield - Heavy Armor -->
<item id="17527" count="4" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.71" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="55.89" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="8.05" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19773"> <!-- Seraph Circlet - Recovery Type / Robe -->
<item id="17527" count="5" chance="91.98" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="9.58" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="79.85" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="11.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19774"> <!-- Seraph Tunic - Recovery Type / Robe -->
<item id="17527" count="13" chance="94.34" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="25.55" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="3" chance="70.98" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="30.66" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19455"> <!-- Istina's Bracelet -->
<item id="17527" count="1" chance="28.45" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="0.59" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="4.94" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="0.71" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19775"> <!-- Seraph Stockings - Recovery Type / Robe -->
<item id="17527" count="8" chance="95.82" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="15.97" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="2" chance="66.54" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="19.16" /> <!-- Elcyum Crystal -->
</crystalizable_item>
</list>

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
@ -259,7 +259,7 @@ public class AdminReload implements IAdminCommandHandler
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
break;
}

View File

@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.SayuneData;
@ -217,7 +217,7 @@ public class Reload implements ITelnetCommand
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded item crystalization data.");
}
case "ability":

View File

@ -1,22 +0,0 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="crystalizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,49 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="templates">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_template" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="crystalType" use="required" />
<xs:attribute type="xs:string" name="crystallizationType" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -68,7 +68,7 @@ import com.l2jmobius.gameserver.data.xml.impl.HennaData;
import com.l2jmobius.gameserver.data.xml.impl.HitConditionBonusData;
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.KarmaData;
import com.l2jmobius.gameserver.data.xml.impl.LuckyGameData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
@ -225,7 +225,7 @@ public class GameServer
EnchantItemGroupsData.getInstance();
EnchantItemData.getInstance();
EnchantItemOptionsData.getInstance();
ItemCrystalizationData.getInstance();
ItemCrystallizationData.getInstance();
OptionData.getInstance();
AugmentationData.getInstance();
EnsoulData.getInstance();

View File

@ -1,102 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public final class ItemCrystalizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystalizationData.class.getName());
private final Map<Integer, CrystalizationData> _items = new HashMap<>();
protected ItemCrystalizationData()
{
load();
}
@Override
public void load()
{
parseDatapackFile("data/CrystalizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded: " + _items.size() + " Items");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystalizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final CrystalizationData data = new CrystalizationData(id);
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
final NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
data.addItem(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, data);
}
}
}
}
}
public CrystalizationData getCrystalization(int itemId)
{
return _items.get(itemId);
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystalizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystalizationData _instance = new ItemCrystalizationData();
}
}

View File

@ -0,0 +1,243 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.CrystallizationType;
import com.l2jmobius.gameserver.model.holders.CrystallizationDataHolder;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
/**
* @author UnAfraid
*/
public final class ItemCrystallizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystallizationData.class.getName());
private final Map<CrystalType, Map<CrystallizationType, List<ItemChanceHolder>>> _crystallizationTemplates = new EnumMap<>(CrystalType.class);
private final Map<Integer, CrystallizationDataHolder> _items = new HashMap<>();
protected ItemCrystallizationData()
{
load();
}
@Override
public void load()
{
_crystallizationTemplates.clear();
for (CrystalType crystalType : CrystalType.values())
{
_crystallizationTemplates.put(crystalType, new EnumMap<>(CrystallizationType.class));
}
_items.clear();
parseDatapackFile("data/CrystallizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _crystallizationTemplates.size() + " crystallization templates.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _items.size() + " pre-defined crystallizable items.");
// Generate remaining data.
generateCrystallizationData();
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
{
if ("templates".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_template".equalsIgnoreCase(d.getNodeName()))
{
final CrystalType crystalType = parseEnum(d.getAttributes(), CrystalType.class, "crystalType");
final CrystallizationType crystallizationType = parseEnum(d.getAttributes(), CrystallizationType.class, "crystallizationType");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_crystallizationTemplates.get(crystalType).put(crystallizationType, crystallizeRewards);
}
}
}
else if ("items".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, new CrystallizationDataHolder(id, crystallizeRewards));
}
}
}
}
}
}
}
public int getLoadedCrystallizationTemplateCount()
{
return _crystallizationTemplates.size();
}
private List<ItemChanceHolder> calculateCrystallizeRewards(L2Item item, List<ItemChanceHolder> crystallizeRewards)
{
if (crystallizeRewards == null)
{
return null;
}
final List<ItemChanceHolder> rewards = new ArrayList<>();
for (ItemChanceHolder reward : crystallizeRewards)
{
double chance = reward.getChance() * item.getCrystalCount();
long count = reward.getCount();
if (chance > 100.)
{
double countMul = Math.ceil(chance / 100.);
chance /= countMul;
count *= countMul;
}
rewards.add(new ItemChanceHolder(reward.getId(), chance, count));
}
return rewards;
}
private void generateCrystallizationData()
{
final int previousCount = _items.size();
for (L2Item item : ItemTable.getInstance().getAllItems())
{
// Check if the data has not been generated.
if (((item instanceof L2Weapon) || (item instanceof L2Armor)) && item.isCrystallizable() && !_items.containsKey(item.getId()))
{
final List<ItemChanceHolder> holder = _crystallizationTemplates.get(item.getCrystalType()).get((item instanceof L2Weapon) ? CrystallizationType.WEAPON : CrystallizationType.ARMOR);
if (holder != null)
{
_items.put(item.getId(), new CrystallizationDataHolder(item.getId(), calculateCrystallizeRewards(item, holder)));
}
}
}
LOGGER.info(getClass().getSimpleName() + ": Generated " + (_items.size() - previousCount) + " crystallizable items from templates.");
}
public List<ItemChanceHolder> getCrystallizationTemplate(CrystalType crystalType, CrystallizationType crystallizationType)
{
return _crystallizationTemplates.get(crystalType).get(crystallizationType);
}
/**
* @param itemId
* @return {@code CrystallizationData} for unenchanted items (enchanted items just have different crystal count, but same rewards),<br>
* or {@code null} if there is no such data registered.
*/
public CrystallizationDataHolder getCrystallizationData(int itemId)
{
return _items.get(itemId);
}
/**
* @param item to calculate its worth in crystals.
* @return List of {@code ItemChanceHolder} for the rewards with altered crystal count.
*/
public List<ItemChanceHolder> getCrystallizationRewards(L2ItemInstance item)
{
final List<ItemChanceHolder> result = new ArrayList<>();
final CrystallizationDataHolder data = getCrystallizationData(item.getId());
if (data != null)
{
// If there are no crystals on the template, add such.
if (data.getItems().stream().noneMatch(i -> i.getId() == item.getItem().getCrystalItemId()))
{
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
result.addAll(data.getItems());
}
else
{
// Add basic crystal reward.
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
return result;
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystallizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystallizationData _instance = new ItemCrystallizationData();
}
}

View File

@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
/**
* @author Nik
*/
public enum CrystallizationType
{
NONE,
WEAPON,
ARMOR,
ACCESORY;
public static CrystallizationType getByItem(L2Item item)
{
if (item instanceof L2Weapon)
{
return WEAPON;
}
if (item instanceof L2Armor)
{
return ARMOR;
}
switch (item.getBodyPart())
{
case L2Item.SLOT_R_EAR:
case L2Item.SLOT_L_EAR:
case L2Item.SLOT_R_FINGER:
case L2Item.SLOT_L_FINGER:
case L2Item.SLOT_NECK:
case L2Item.SLOT_HAIR:
case L2Item.SLOT_HAIR2:
case L2Item.SLOT_HAIRALL:
{
return ACCESORY;
}
}
return NONE;
}
}

View File

@ -1,51 +1,45 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public class CrystalizationData
{
private final int _id;
private final List<ItemChanceHolder> _items = new ArrayList<>();
public CrystalizationData(int id)
{
_id = id;
}
public int getId()
{
return _id;
}
public void addItem(ItemChanceHolder item)
{
_items.add(item);
}
public List<ItemChanceHolder> getItems()
{
return _items;
}
}
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.holders;
import java.util.Collections;
import java.util.List;
/**
* @author UnAfraid
*/
public class CrystallizationDataHolder
{
private final int _id;
private final List<ItemChanceHolder> _items;
public CrystallizationDataHolder(int id, List<ItemChanceHolder> items)
{
_id = id;
_items = Collections.unmodifiableList(items);
}
public int getId()
{
return _id;
}
public List<ItemChanceHolder> getItems()
{
return Collections.unmodifiableList(_items);
}
}

View File

@ -16,16 +16,14 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
@ -110,6 +108,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
if (item.isHeroItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
@ -122,18 +121,19 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE))
{
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId());
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
{
activeChar.sendMessage("You cannot use this item.");
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
@ -199,6 +199,13 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
return;
}
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(itemToRemove);
if ((crystallizationRewards == null) || crystallizationRewards.isEmpty())
{
activeChar.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
return;
}
// activeChar.setInCrystallize(true);
// unequip if needed
@ -234,19 +241,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
iu.addRemovedItem(removedItem);
activeChar.sendInventoryUpdate(iu);
final int crystalId = itemToRemove.getItem().getCrystalItemId();
final int crystalAmount = itemToRemove.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
if (data != null)
{
data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
}
for (ItemChanceHolder holder : items)
for (ItemChanceHolder holder : crystallizationRewards)
{
final double rand = Rnd.nextDouble() * 100;
if (rand < holder.getChance())

View File

@ -16,14 +16,12 @@
*/
package com.l2jmobius.gameserver.network.clientpackets.crystalization;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
@ -180,26 +178,17 @@ public class RequestCrystallizeEstimate implements IClientIncomingPacket
return;
}
activeChar.setInCrystallize(true);
// add crystals
final int crystalId = item.getItem().getCrystalItemId();
final int crystalAmount = item.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(item.getId());
if (data != null)
// Show crystallization rewards window.
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(item);
if ((crystallizationRewards != null) && !crystallizationRewards.isEmpty())
{
for (ItemChanceHolder holder : data.getItems())
{
if (holder.getId() != crystalId)
{
items.add(holder);
}
}
activeChar.setInCrystallize(true);
client.sendPacket(new ExGetCrystalizingEstimation(crystallizationRewards));
}
else
{
client.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
}
client.sendPacket(new ExGetCrystalizingEstimation(items));
}
}

View File

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/CrystalizableItems.xsd">
<crystalizable_item id="19776"> <!-- Seraph Gloves - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19777"> <!-- Seraph Shoes - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19473"> <!-- Twilight Belt -->
<item id="17527" count="1" chance="47.76" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="1.0" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="8.29" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="1.19" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18065"> <!-- Blessed Seraph Sigil - Robe -->
<item id="17527" count="5" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.38" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.87" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="10.06" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18706"> <!-- Apocalypse Shaper - Focus -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="6676"> <!-- Sealed Imperial Crusader Gauntlets -->
<item id="960" count="1" chance="63.9" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="2.84" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="1.78" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="3.2" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19544"> <!-- Twilight Leather Helmet - Assassin Type / Light -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="16025"> <!-- Freya's Necklace -->
<item id="960" count="4" chance="75.96" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="13.5" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="8.44" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="15.19" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19545"> <!-- Twilight Leather Armor - Assassin Type / Light -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19546"> <!-- Twilight Leather Leggings - Assassin Type / Light -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19547"> <!-- Twilight Leather Gloves - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19548"> <!-- Twilight Leather Boots - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="30048"> <!-- Apocalypse Buster - Mana Up + Acumen -->
<item id="17526" count="2" chance="62.35" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.99" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="33.25" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="39.9" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18722"> <!-- Apocalypse Thrower - Damage Up -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19746"> <!-- Twilight Helmet - Defense Type / Heavy -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19747"> <!-- Twilight Breastplate - Defense Type / Heavy -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19748"> <!-- Twilight Gaiters - Defense Type / Heavy -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19749"> <!-- Twilight Gauntlets - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19750"> <!-- Twilight Boots - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19751"> <!-- Twilight Shield - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18732"> <!-- Apocalypse Caster - Acumen -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="17401"> <!-- Seraph Shield - Heavy Armor -->
<item id="17527" count="4" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.71" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="55.89" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="8.05" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19773"> <!-- Seraph Circlet - Recovery Type / Robe -->
<item id="17527" count="5" chance="91.98" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="9.58" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="79.85" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="11.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19774"> <!-- Seraph Tunic - Recovery Type / Robe -->
<item id="17527" count="13" chance="94.34" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="25.55" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="3" chance="70.98" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="30.66" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19455"> <!-- Istina's Bracelet -->
<item id="17527" count="1" chance="28.45" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="0.59" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="4.94" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="0.71" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19775"> <!-- Seraph Stockings - Recovery Type / Robe -->
<item id="17527" count="8" chance="95.82" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="15.97" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="2" chance="66.54" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="19.16" /> <!-- Elcyum Crystal -->
</crystalizable_item>
</list>

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
@ -259,7 +259,7 @@ public class AdminReload implements IAdminCommandHandler
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
break;
}

View File

@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.SayuneData;
@ -217,7 +217,7 @@ public class Reload implements ITelnetCommand
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded item crystalization data.");
}
case "ability":

View File

@ -1,22 +0,0 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="crystalizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,49 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="templates">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_template" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="crystalType" use="required" />
<xs:attribute type="xs:string" name="crystallizationType" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -68,7 +68,7 @@ import com.l2jmobius.gameserver.data.xml.impl.HennaData;
import com.l2jmobius.gameserver.data.xml.impl.HitConditionBonusData;
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.KarmaData;
import com.l2jmobius.gameserver.data.xml.impl.LuckyGameData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
@ -225,7 +225,7 @@ public class GameServer
EnchantItemGroupsData.getInstance();
EnchantItemData.getInstance();
EnchantItemOptionsData.getInstance();
ItemCrystalizationData.getInstance();
ItemCrystallizationData.getInstance();
OptionData.getInstance();
AugmentationData.getInstance();
EnsoulData.getInstance();

View File

@ -1,102 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public final class ItemCrystalizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystalizationData.class.getName());
private final Map<Integer, CrystalizationData> _items = new HashMap<>();
protected ItemCrystalizationData()
{
load();
}
@Override
public void load()
{
parseDatapackFile("data/CrystalizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded: " + _items.size() + " Items");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystalizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final CrystalizationData data = new CrystalizationData(id);
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
final NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
data.addItem(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, data);
}
}
}
}
}
public CrystalizationData getCrystalization(int itemId)
{
return _items.get(itemId);
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystalizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystalizationData _instance = new ItemCrystalizationData();
}
}

View File

@ -0,0 +1,243 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.CrystallizationType;
import com.l2jmobius.gameserver.model.holders.CrystallizationDataHolder;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
/**
* @author UnAfraid
*/
public final class ItemCrystallizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystallizationData.class.getName());
private final Map<CrystalType, Map<CrystallizationType, List<ItemChanceHolder>>> _crystallizationTemplates = new EnumMap<>(CrystalType.class);
private final Map<Integer, CrystallizationDataHolder> _items = new HashMap<>();
protected ItemCrystallizationData()
{
load();
}
@Override
public void load()
{
_crystallizationTemplates.clear();
for (CrystalType crystalType : CrystalType.values())
{
_crystallizationTemplates.put(crystalType, new EnumMap<>(CrystallizationType.class));
}
_items.clear();
parseDatapackFile("data/CrystallizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _crystallizationTemplates.size() + " crystallization templates.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _items.size() + " pre-defined crystallizable items.");
// Generate remaining data.
generateCrystallizationData();
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
{
if ("templates".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_template".equalsIgnoreCase(d.getNodeName()))
{
final CrystalType crystalType = parseEnum(d.getAttributes(), CrystalType.class, "crystalType");
final CrystallizationType crystallizationType = parseEnum(d.getAttributes(), CrystallizationType.class, "crystallizationType");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_crystallizationTemplates.get(crystalType).put(crystallizationType, crystallizeRewards);
}
}
}
else if ("items".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, new CrystallizationDataHolder(id, crystallizeRewards));
}
}
}
}
}
}
}
public int getLoadedCrystallizationTemplateCount()
{
return _crystallizationTemplates.size();
}
private List<ItemChanceHolder> calculateCrystallizeRewards(L2Item item, List<ItemChanceHolder> crystallizeRewards)
{
if (crystallizeRewards == null)
{
return null;
}
final List<ItemChanceHolder> rewards = new ArrayList<>();
for (ItemChanceHolder reward : crystallizeRewards)
{
double chance = reward.getChance() * item.getCrystalCount();
long count = reward.getCount();
if (chance > 100.)
{
double countMul = Math.ceil(chance / 100.);
chance /= countMul;
count *= countMul;
}
rewards.add(new ItemChanceHolder(reward.getId(), chance, count));
}
return rewards;
}
private void generateCrystallizationData()
{
final int previousCount = _items.size();
for (L2Item item : ItemTable.getInstance().getAllItems())
{
// Check if the data has not been generated.
if (((item instanceof L2Weapon) || (item instanceof L2Armor)) && item.isCrystallizable() && !_items.containsKey(item.getId()))
{
final List<ItemChanceHolder> holder = _crystallizationTemplates.get(item.getCrystalType()).get((item instanceof L2Weapon) ? CrystallizationType.WEAPON : CrystallizationType.ARMOR);
if (holder != null)
{
_items.put(item.getId(), new CrystallizationDataHolder(item.getId(), calculateCrystallizeRewards(item, holder)));
}
}
}
LOGGER.info(getClass().getSimpleName() + ": Generated " + (_items.size() - previousCount) + " crystallizable items from templates.");
}
public List<ItemChanceHolder> getCrystallizationTemplate(CrystalType crystalType, CrystallizationType crystallizationType)
{
return _crystallizationTemplates.get(crystalType).get(crystallizationType);
}
/**
* @param itemId
* @return {@code CrystallizationData} for unenchanted items (enchanted items just have different crystal count, but same rewards),<br>
* or {@code null} if there is no such data registered.
*/
public CrystallizationDataHolder getCrystallizationData(int itemId)
{
return _items.get(itemId);
}
/**
* @param item to calculate its worth in crystals.
* @return List of {@code ItemChanceHolder} for the rewards with altered crystal count.
*/
public List<ItemChanceHolder> getCrystallizationRewards(L2ItemInstance item)
{
final List<ItemChanceHolder> result = new ArrayList<>();
final CrystallizationDataHolder data = getCrystallizationData(item.getId());
if (data != null)
{
// If there are no crystals on the template, add such.
if (data.getItems().stream().noneMatch(i -> i.getId() == item.getItem().getCrystalItemId()))
{
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
result.addAll(data.getItems());
}
else
{
// Add basic crystal reward.
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
return result;
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystallizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystallizationData _instance = new ItemCrystallizationData();
}
}

View File

@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
/**
* @author Nik
*/
public enum CrystallizationType
{
NONE,
WEAPON,
ARMOR,
ACCESORY;
public static CrystallizationType getByItem(L2Item item)
{
if (item instanceof L2Weapon)
{
return WEAPON;
}
if (item instanceof L2Armor)
{
return ARMOR;
}
switch (item.getBodyPart())
{
case L2Item.SLOT_R_EAR:
case L2Item.SLOT_L_EAR:
case L2Item.SLOT_R_FINGER:
case L2Item.SLOT_L_FINGER:
case L2Item.SLOT_NECK:
case L2Item.SLOT_HAIR:
case L2Item.SLOT_HAIR2:
case L2Item.SLOT_HAIRALL:
{
return ACCESORY;
}
}
return NONE;
}
}

View File

@ -1,51 +1,45 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public class CrystalizationData
{
private final int _id;
private final List<ItemChanceHolder> _items = new ArrayList<>();
public CrystalizationData(int id)
{
_id = id;
}
public int getId()
{
return _id;
}
public void addItem(ItemChanceHolder item)
{
_items.add(item);
}
public List<ItemChanceHolder> getItems()
{
return _items;
}
}
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.holders;
import java.util.Collections;
import java.util.List;
/**
* @author UnAfraid
*/
public class CrystallizationDataHolder
{
private final int _id;
private final List<ItemChanceHolder> _items;
public CrystallizationDataHolder(int id, List<ItemChanceHolder> items)
{
_id = id;
_items = Collections.unmodifiableList(items);
}
public int getId()
{
return _id;
}
public List<ItemChanceHolder> getItems()
{
return Collections.unmodifiableList(_items);
}
}

View File

@ -16,16 +16,14 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
@ -110,6 +108,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
if (item.isHeroItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
@ -122,18 +121,19 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE))
{
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId());
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
{
activeChar.sendMessage("You cannot use this item.");
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
@ -199,6 +199,13 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
return;
}
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(itemToRemove);
if ((crystallizationRewards == null) || crystallizationRewards.isEmpty())
{
activeChar.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
return;
}
// activeChar.setInCrystallize(true);
// unequip if needed
@ -234,19 +241,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
iu.addRemovedItem(removedItem);
activeChar.sendInventoryUpdate(iu);
final int crystalId = itemToRemove.getItem().getCrystalItemId();
final int crystalAmount = itemToRemove.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
if (data != null)
{
data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
}
for (ItemChanceHolder holder : items)
for (ItemChanceHolder holder : crystallizationRewards)
{
final double rand = Rnd.nextDouble() * 100;
if (rand < holder.getChance())

View File

@ -16,14 +16,12 @@
*/
package com.l2jmobius.gameserver.network.clientpackets.crystalization;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
@ -180,26 +178,17 @@ public class RequestCrystallizeEstimate implements IClientIncomingPacket
return;
}
activeChar.setInCrystallize(true);
// add crystals
final int crystalId = item.getItem().getCrystalItemId();
final int crystalAmount = item.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(item.getId());
if (data != null)
// Show crystallization rewards window.
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(item);
if ((crystallizationRewards != null) && !crystallizationRewards.isEmpty())
{
for (ItemChanceHolder holder : data.getItems())
{
if (holder.getId() != crystalId)
{
items.add(holder);
}
}
activeChar.setInCrystallize(true);
client.sendPacket(new ExGetCrystalizingEstimation(crystallizationRewards));
}
else
{
client.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
}
client.sendPacket(new ExGetCrystalizingEstimation(items));
}
}

View File

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/CrystalizableItems.xsd">
<crystalizable_item id="19776"> <!-- Seraph Gloves - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19777"> <!-- Seraph Shoes - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19473"> <!-- Twilight Belt -->
<item id="17527" count="1" chance="47.76" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="1.0" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="8.29" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="1.19" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18065"> <!-- Blessed Seraph Sigil - Robe -->
<item id="17527" count="5" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.38" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.87" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="10.06" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18706"> <!-- Apocalypse Shaper - Focus -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="6676"> <!-- Sealed Imperial Crusader Gauntlets -->
<item id="960" count="1" chance="63.9" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="2.84" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="1.78" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="3.2" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19544"> <!-- Twilight Leather Helmet - Assassin Type / Light -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="16025"> <!-- Freya's Necklace -->
<item id="960" count="4" chance="75.96" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="13.5" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="8.44" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="15.19" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19545"> <!-- Twilight Leather Armor - Assassin Type / Light -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19546"> <!-- Twilight Leather Leggings - Assassin Type / Light -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19547"> <!-- Twilight Leather Gloves - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19548"> <!-- Twilight Leather Boots - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="30048"> <!-- Apocalypse Buster - Mana Up + Acumen -->
<item id="17526" count="2" chance="62.35" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.99" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="33.25" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="39.9" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18722"> <!-- Apocalypse Thrower - Damage Up -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19746"> <!-- Twilight Helmet - Defense Type / Heavy -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19747"> <!-- Twilight Breastplate - Defense Type / Heavy -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19748"> <!-- Twilight Gaiters - Defense Type / Heavy -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19749"> <!-- Twilight Gauntlets - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19750"> <!-- Twilight Boots - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19751"> <!-- Twilight Shield - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18732"> <!-- Apocalypse Caster - Acumen -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="17401"> <!-- Seraph Shield - Heavy Armor -->
<item id="17527" count="4" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.71" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="55.89" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="8.05" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19773"> <!-- Seraph Circlet - Recovery Type / Robe -->
<item id="17527" count="5" chance="91.98" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="9.58" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="79.85" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="11.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19774"> <!-- Seraph Tunic - Recovery Type / Robe -->
<item id="17527" count="13" chance="94.34" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="25.55" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="3" chance="70.98" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="30.66" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19455"> <!-- Istina's Bracelet -->
<item id="17527" count="1" chance="28.45" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="0.59" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="4.94" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="0.71" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19775"> <!-- Seraph Stockings - Recovery Type / Robe -->
<item id="17527" count="8" chance="95.82" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="15.97" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="2" chance="66.54" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="19.16" /> <!-- Elcyum Crystal -->
</crystalizable_item>
</list>

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
@ -258,7 +258,7 @@ public class AdminReload implements IAdminCommandHandler
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
break;
}

View File

@ -31,7 +31,7 @@ import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.SayuneData;
@ -216,7 +216,7 @@ public class Reload implements ITelnetCommand
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded item crystalization data.");
}
case "appearance":

View File

@ -1,22 +0,0 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="crystalizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,49 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="templates">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_template" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="crystalType" use="required" />
<xs:attribute type="xs:string" name="crystallizationType" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -67,7 +67,7 @@ import com.l2jmobius.gameserver.data.xml.impl.HennaData;
import com.l2jmobius.gameserver.data.xml.impl.HitConditionBonusData;
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.KarmaData;
import com.l2jmobius.gameserver.data.xml.impl.LuckyGameData;
import com.l2jmobius.gameserver.data.xml.impl.MonsterBookData;
@ -224,7 +224,7 @@ public class GameServer
EnchantItemGroupsData.getInstance();
EnchantItemData.getInstance();
EnchantItemOptionsData.getInstance();
ItemCrystalizationData.getInstance();
ItemCrystallizationData.getInstance();
OptionData.getInstance();
AugmentationData.getInstance();
EnsoulData.getInstance();

View File

@ -1,102 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public final class ItemCrystalizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystalizationData.class.getName());
private final Map<Integer, CrystalizationData> _items = new HashMap<>();
protected ItemCrystalizationData()
{
load();
}
@Override
public void load()
{
parseDatapackFile("data/CrystalizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded: " + _items.size() + " Items");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystalizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final CrystalizationData data = new CrystalizationData(id);
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
final NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
data.addItem(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, data);
}
}
}
}
}
public CrystalizationData getCrystalization(int itemId)
{
return _items.get(itemId);
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystalizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystalizationData _instance = new ItemCrystalizationData();
}
}

View File

@ -0,0 +1,243 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.CrystallizationType;
import com.l2jmobius.gameserver.model.holders.CrystallizationDataHolder;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
/**
* @author UnAfraid
*/
public final class ItemCrystallizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystallizationData.class.getName());
private final Map<CrystalType, Map<CrystallizationType, List<ItemChanceHolder>>> _crystallizationTemplates = new EnumMap<>(CrystalType.class);
private final Map<Integer, CrystallizationDataHolder> _items = new HashMap<>();
protected ItemCrystallizationData()
{
load();
}
@Override
public void load()
{
_crystallizationTemplates.clear();
for (CrystalType crystalType : CrystalType.values())
{
_crystallizationTemplates.put(crystalType, new EnumMap<>(CrystallizationType.class));
}
_items.clear();
parseDatapackFile("data/CrystallizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _crystallizationTemplates.size() + " crystallization templates.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _items.size() + " pre-defined crystallizable items.");
// Generate remaining data.
generateCrystallizationData();
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
{
if ("templates".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_template".equalsIgnoreCase(d.getNodeName()))
{
final CrystalType crystalType = parseEnum(d.getAttributes(), CrystalType.class, "crystalType");
final CrystallizationType crystallizationType = parseEnum(d.getAttributes(), CrystallizationType.class, "crystallizationType");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_crystallizationTemplates.get(crystalType).put(crystallizationType, crystallizeRewards);
}
}
}
else if ("items".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, new CrystallizationDataHolder(id, crystallizeRewards));
}
}
}
}
}
}
}
public int getLoadedCrystallizationTemplateCount()
{
return _crystallizationTemplates.size();
}
private List<ItemChanceHolder> calculateCrystallizeRewards(L2Item item, List<ItemChanceHolder> crystallizeRewards)
{
if (crystallizeRewards == null)
{
return null;
}
final List<ItemChanceHolder> rewards = new ArrayList<>();
for (ItemChanceHolder reward : crystallizeRewards)
{
double chance = reward.getChance() * item.getCrystalCount();
long count = reward.getCount();
if (chance > 100.)
{
double countMul = Math.ceil(chance / 100.);
chance /= countMul;
count *= countMul;
}
rewards.add(new ItemChanceHolder(reward.getId(), chance, count));
}
return rewards;
}
private void generateCrystallizationData()
{
final int previousCount = _items.size();
for (L2Item item : ItemTable.getInstance().getAllItems())
{
// Check if the data has not been generated.
if (((item instanceof L2Weapon) || (item instanceof L2Armor)) && item.isCrystallizable() && !_items.containsKey(item.getId()))
{
final List<ItemChanceHolder> holder = _crystallizationTemplates.get(item.getCrystalType()).get((item instanceof L2Weapon) ? CrystallizationType.WEAPON : CrystallizationType.ARMOR);
if (holder != null)
{
_items.put(item.getId(), new CrystallizationDataHolder(item.getId(), calculateCrystallizeRewards(item, holder)));
}
}
}
LOGGER.info(getClass().getSimpleName() + ": Generated " + (_items.size() - previousCount) + " crystallizable items from templates.");
}
public List<ItemChanceHolder> getCrystallizationTemplate(CrystalType crystalType, CrystallizationType crystallizationType)
{
return _crystallizationTemplates.get(crystalType).get(crystallizationType);
}
/**
* @param itemId
* @return {@code CrystallizationData} for unenchanted items (enchanted items just have different crystal count, but same rewards),<br>
* or {@code null} if there is no such data registered.
*/
public CrystallizationDataHolder getCrystallizationData(int itemId)
{
return _items.get(itemId);
}
/**
* @param item to calculate its worth in crystals.
* @return List of {@code ItemChanceHolder} for the rewards with altered crystal count.
*/
public List<ItemChanceHolder> getCrystallizationRewards(L2ItemInstance item)
{
final List<ItemChanceHolder> result = new ArrayList<>();
final CrystallizationDataHolder data = getCrystallizationData(item.getId());
if (data != null)
{
// If there are no crystals on the template, add such.
if (data.getItems().stream().noneMatch(i -> i.getId() == item.getItem().getCrystalItemId()))
{
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
result.addAll(data.getItems());
}
else
{
// Add basic crystal reward.
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
return result;
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystallizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystallizationData _instance = new ItemCrystallizationData();
}
}

View File

@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
/**
* @author Nik
*/
public enum CrystallizationType
{
NONE,
WEAPON,
ARMOR,
ACCESORY;
public static CrystallizationType getByItem(L2Item item)
{
if (item instanceof L2Weapon)
{
return WEAPON;
}
if (item instanceof L2Armor)
{
return ARMOR;
}
switch (item.getBodyPart())
{
case L2Item.SLOT_R_EAR:
case L2Item.SLOT_L_EAR:
case L2Item.SLOT_R_FINGER:
case L2Item.SLOT_L_FINGER:
case L2Item.SLOT_NECK:
case L2Item.SLOT_HAIR:
case L2Item.SLOT_HAIR2:
case L2Item.SLOT_HAIRALL:
{
return ACCESORY;
}
}
return NONE;
}
}

View File

@ -1,51 +1,45 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public class CrystalizationData
{
private final int _id;
private final List<ItemChanceHolder> _items = new ArrayList<>();
public CrystalizationData(int id)
{
_id = id;
}
public int getId()
{
return _id;
}
public void addItem(ItemChanceHolder item)
{
_items.add(item);
}
public List<ItemChanceHolder> getItems()
{
return _items;
}
}
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.holders;
import java.util.Collections;
import java.util.List;
/**
* @author UnAfraid
*/
public class CrystallizationDataHolder
{
private final int _id;
private final List<ItemChanceHolder> _items;
public CrystallizationDataHolder(int id, List<ItemChanceHolder> items)
{
_id = id;
_items = Collections.unmodifiableList(items);
}
public int getId()
{
return _id;
}
public List<ItemChanceHolder> getItems()
{
return Collections.unmodifiableList(_items);
}
}

View File

@ -16,16 +16,14 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
@ -110,6 +108,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
if (item.isHeroItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
@ -122,18 +121,19 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE))
{
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId());
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
{
activeChar.sendMessage("You cannot use this item.");
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
@ -199,6 +199,13 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
return;
}
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(itemToRemove);
if ((crystallizationRewards == null) || crystallizationRewards.isEmpty())
{
activeChar.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
return;
}
// activeChar.setInCrystallize(true);
// unequip if needed
@ -234,19 +241,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
iu.addRemovedItem(removedItem);
activeChar.sendInventoryUpdate(iu);
final int crystalId = itemToRemove.getItem().getCrystalItemId();
final int crystalAmount = itemToRemove.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
if (data != null)
{
data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
}
for (ItemChanceHolder holder : items)
for (ItemChanceHolder holder : crystallizationRewards)
{
final double rand = Rnd.nextDouble() * 100;
if (rand < holder.getChance())

View File

@ -16,14 +16,12 @@
*/
package com.l2jmobius.gameserver.network.clientpackets.crystalization;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
@ -180,26 +178,17 @@ public class RequestCrystallizeEstimate implements IClientIncomingPacket
return;
}
activeChar.setInCrystallize(true);
// add crystals
final int crystalId = item.getItem().getCrystalItemId();
final int crystalAmount = item.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(item.getId());
if (data != null)
// Show crystallization rewards window.
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(item);
if ((crystallizationRewards != null) && !crystallizationRewards.isEmpty())
{
for (ItemChanceHolder holder : data.getItems())
{
if (holder.getId() != crystalId)
{
items.add(holder);
}
}
activeChar.setInCrystallize(true);
client.sendPacket(new ExGetCrystalizingEstimation(crystallizationRewards));
}
else
{
client.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
}
client.sendPacket(new ExGetCrystalizingEstimation(items));
}
}

View File

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/CrystalizableItems.xsd">
<crystalizable_item id="19776"> <!-- Seraph Gloves - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19777"> <!-- Seraph Shoes - Recovery Type / Robe -->
<item id="17527" count="4" chance="76.65" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.39" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="53.23" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="7.67" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19473"> <!-- Twilight Belt -->
<item id="17527" count="1" chance="47.76" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="1.0" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="8.29" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="1.19" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18065"> <!-- Blessed Seraph Sigil - Robe -->
<item id="17527" count="5" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.38" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.87" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="10.06" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18706"> <!-- Apocalypse Shaper - Focus -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="6676"> <!-- Sealed Imperial Crusader Gauntlets -->
<item id="960" count="1" chance="63.9" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="2.84" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="1.78" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="3.2" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19544"> <!-- Twilight Leather Helmet - Assassin Type / Light -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="16025"> <!-- Freya's Necklace -->
<item id="960" count="4" chance="75.96" /> <!-- Scroll: Enchant Armor (S-grade) -->
<item id="6578" count="1" chance="13.5" /> <!-- Blessed Scroll: Enchant Armor (S-grade) -->
<item id="36390" count="1" chance="8.44" /> <!-- Giant's Scroll: Enchant Armor (S-grade) -->
<item id="36513" count="1" chance="15.19" /> <!-- Elcyum Powder -->
</crystalizable_item>
<crystalizable_item id="19545"> <!-- Twilight Leather Armor - Assassin Type / Light -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19546"> <!-- Twilight Leather Leggings - Assassin Type / Light -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19547"> <!-- Twilight Leather Gloves - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19548"> <!-- Twilight Leather Boots - Assassin Type / Light -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="30048"> <!-- Apocalypse Buster - Mana Up + Acumen -->
<item id="17526" count="2" chance="62.35" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.99" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="33.25" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="39.9" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18722"> <!-- Apocalypse Thrower - Damage Up -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19746"> <!-- Twilight Helmet - Defense Type / Heavy -->
<item id="17527" count="2" chance="74.95" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="3.12" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="26.02" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="3.75" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19747"> <!-- Twilight Breastplate - Defense Type / Heavy -->
<item id="17527" count="4" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="8.33" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="69.39" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="9.99" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19748"> <!-- Twilight Gaiters - Defense Type / Heavy -->
<item id="17527" count="3" chance="83.27" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="5.2" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="43.37" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="6.25" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19749"> <!-- Twilight Gauntlets - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19750"> <!-- Twilight Boots - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19751"> <!-- Twilight Shield - Defense Type / Heavy -->
<item id="17527" count="1" chance="99.93" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="2.08" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="17.35" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="2.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="18732"> <!-- Apocalypse Caster - Acumen -->
<item id="17526" count="2" chance="55.16" /> <!-- Scroll: Enchant Weapon (R-grade) -->
<item id="19447" count="1" chance="3.53" /> <!-- Blessed Scroll: Enchant Weapon (R-grade) -->
<item id="36386" count="1" chance="29.42" /> <!-- Giant's Scroll: Enchant Weapon (R-grade) -->
<item id="36514" count="1" chance="35.3" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="17401"> <!-- Seraph Shield - Heavy Armor -->
<item id="17527" count="4" chance="80.49" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="6.71" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="55.89" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="8.05" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19773"> <!-- Seraph Circlet - Recovery Type / Robe -->
<item id="17527" count="5" chance="91.98" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="9.58" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="79.85" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="11.5" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19774"> <!-- Seraph Tunic - Recovery Type / Robe -->
<item id="17527" count="13" chance="94.34" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="25.55" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="3" chance="70.98" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="30.66" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19455"> <!-- Istina's Bracelet -->
<item id="17527" count="1" chance="28.45" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="0.59" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="1" chance="4.94" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="0.71" /> <!-- Elcyum Crystal -->
</crystalizable_item>
<crystalizable_item id="19775"> <!-- Seraph Stockings - Recovery Type / Robe -->
<item id="17527" count="8" chance="95.82" /> <!-- Scroll: Enchant Armor (R-grade) -->
<item id="19448" count="1" chance="15.97" /> <!-- Blessed Scroll: Enchant Armor (R-grade) -->
<item id="36389" count="2" chance="66.54" /> <!-- Giant's Scroll: Enchant Armor (R-grade) -->
<item id="36514" count="1" chance="19.16" /> <!-- Elcyum Crystal -->
</crystalizable_item>
</list>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/CrystallizableItems.xsd">
<!-- Templates for generating automatically crystallization data. Chance is multiplied by the amount of crystals the item template has. -->
</list>

View File

@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
@ -259,7 +259,7 @@ public class AdminReload implements IAdminCommandHandler
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
break;
}

View File

@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.SayuneData;
@ -217,7 +217,7 @@ public class Reload implements ITelnetCommand
}
case "crystalizable":
{
ItemCrystalizationData.getInstance().load();
ItemCrystallizationData.getInstance().load();
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded item crystalization data.");
}
case "ability":

View File

@ -1,22 +0,0 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="crystalizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,49 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="templates" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_template" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="crystalType" use="required" />
<xs:attribute type="xs:string" name="crystallizationType" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="items" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="crystallizable_item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="xs:int" name="id" use="required" />
<xs:attribute type="xs:long" name="count" use="required" />
<xs:attribute type="xs:float" name="chance" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="id" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -68,7 +68,7 @@ import com.l2jmobius.gameserver.data.xml.impl.HennaData;
import com.l2jmobius.gameserver.data.xml.impl.HitConditionBonusData;
import com.l2jmobius.gameserver.data.xml.impl.InitialEquipmentData;
import com.l2jmobius.gameserver.data.xml.impl.InitialShortcutData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.data.xml.impl.KarmaData;
import com.l2jmobius.gameserver.data.xml.impl.LuckyGameData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
@ -223,7 +223,7 @@ public class GameServer
EnchantItemGroupsData.getInstance();
EnchantItemData.getInstance();
EnchantItemOptionsData.getInstance();
ItemCrystalizationData.getInstance();
ItemCrystallizationData.getInstance();
OptionData.getInstance();
AugmentationData.getInstance();
EnsoulData.getInstance();

View File

@ -1,102 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public final class ItemCrystalizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystalizationData.class.getName());
private final Map<Integer, CrystalizationData> _items = new HashMap<>();
protected ItemCrystalizationData()
{
load();
}
@Override
public void load()
{
parseDatapackFile("data/CrystalizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded: " + _items.size() + " Items");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystalizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final CrystalizationData data = new CrystalizationData(id);
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
final NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
data.addItem(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, data);
}
}
}
}
}
public CrystalizationData getCrystalization(int itemId)
{
return _items.get(itemId);
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystalizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystalizationData _instance = new ItemCrystalizationData();
}
}

View File

@ -0,0 +1,243 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.CrystallizationType;
import com.l2jmobius.gameserver.model.holders.CrystallizationDataHolder;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
/**
* @author UnAfraid
*/
public final class ItemCrystallizationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystallizationData.class.getName());
private final Map<CrystalType, Map<CrystallizationType, List<ItemChanceHolder>>> _crystallizationTemplates = new EnumMap<>(CrystalType.class);
private final Map<Integer, CrystallizationDataHolder> _items = new HashMap<>();
protected ItemCrystallizationData()
{
load();
}
@Override
public void load()
{
_crystallizationTemplates.clear();
for (CrystalType crystalType : CrystalType.values())
{
_crystallizationTemplates.put(crystalType, new EnumMap<>(CrystallizationType.class));
}
_items.clear();
parseDatapackFile("data/CrystallizableItems.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _crystallizationTemplates.size() + " crystallization templates.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _items.size() + " pre-defined crystallizable items.");
// Generate remaining data.
generateCrystallizationData();
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
{
if ("templates".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_template".equalsIgnoreCase(d.getNodeName()))
{
final CrystalType crystalType = parseEnum(d.getAttributes(), CrystalType.class, "crystalType");
final CrystallizationType crystallizationType = parseEnum(d.getAttributes(), CrystallizationType.class, "crystallizationType");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_crystallizationTemplates.get(crystalType).put(crystallizationType, crystallizeRewards);
}
}
}
else if ("items".equalsIgnoreCase(o.getNodeName()))
{
for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("crystallizable_item".equalsIgnoreCase(d.getNodeName()))
{
final int id = parseInteger(d.getAttributes(), "id");
final List<ItemChanceHolder> crystallizeRewards = new ArrayList<>();
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("item".equalsIgnoreCase(c.getNodeName()))
{
NamedNodeMap attrs = c.getAttributes();
final int itemId = parseInteger(attrs, "id");
final long itemCount = parseLong(attrs, "count");
final double itemChance = parseDouble(attrs, "chance");
crystallizeRewards.add(new ItemChanceHolder(itemId, itemChance, itemCount));
}
}
_items.put(id, new CrystallizationDataHolder(id, crystallizeRewards));
}
}
}
}
}
}
}
public int getLoadedCrystallizationTemplateCount()
{
return _crystallizationTemplates.size();
}
private List<ItemChanceHolder> calculateCrystallizeRewards(L2Item item, List<ItemChanceHolder> crystallizeRewards)
{
if (crystallizeRewards == null)
{
return null;
}
final List<ItemChanceHolder> rewards = new ArrayList<>();
for (ItemChanceHolder reward : crystallizeRewards)
{
double chance = reward.getChance() * item.getCrystalCount();
long count = reward.getCount();
if (chance > 100.)
{
double countMul = Math.ceil(chance / 100.);
chance /= countMul;
count *= countMul;
}
rewards.add(new ItemChanceHolder(reward.getId(), chance, count));
}
return rewards;
}
private void generateCrystallizationData()
{
final int previousCount = _items.size();
for (L2Item item : ItemTable.getInstance().getAllItems())
{
// Check if the data has not been generated.
if (((item instanceof L2Weapon) || (item instanceof L2Armor)) && item.isCrystallizable() && !_items.containsKey(item.getId()))
{
final List<ItemChanceHolder> holder = _crystallizationTemplates.get(item.getCrystalType()).get((item instanceof L2Weapon) ? CrystallizationType.WEAPON : CrystallizationType.ARMOR);
if (holder != null)
{
_items.put(item.getId(), new CrystallizationDataHolder(item.getId(), calculateCrystallizeRewards(item, holder)));
}
}
}
LOGGER.info(getClass().getSimpleName() + ": Generated " + (_items.size() - previousCount) + " crystallizable items from templates.");
}
public List<ItemChanceHolder> getCrystallizationTemplate(CrystalType crystalType, CrystallizationType crystallizationType)
{
return _crystallizationTemplates.get(crystalType).get(crystallizationType);
}
/**
* @param itemId
* @return {@code CrystallizationData} for unenchanted items (enchanted items just have different crystal count, but same rewards),<br>
* or {@code null} if there is no such data registered.
*/
public CrystallizationDataHolder getCrystallizationData(int itemId)
{
return _items.get(itemId);
}
/**
* @param item to calculate its worth in crystals.
* @return List of {@code ItemChanceHolder} for the rewards with altered crystal count.
*/
public List<ItemChanceHolder> getCrystallizationRewards(L2ItemInstance item)
{
final List<ItemChanceHolder> result = new ArrayList<>();
final CrystallizationDataHolder data = getCrystallizationData(item.getId());
if (data != null)
{
// If there are no crystals on the template, add such.
if (data.getItems().stream().noneMatch(i -> i.getId() == item.getItem().getCrystalItemId()))
{
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
result.addAll(data.getItems());
}
else
{
// Add basic crystal reward.
result.add(new ItemChanceHolder(item.getItem().getCrystalItemId(), 100, item.getCrystalCount()));
}
return result;
}
/**
* Gets the single instance of ItemCrystalizationData.
* @return single instance of ItemCrystalizationData
*/
public static ItemCrystallizationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final ItemCrystallizationData _instance = new ItemCrystallizationData();
}
}

View File

@ -0,0 +1,60 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
/**
* @author Nik
*/
public enum CrystallizationType
{
NONE,
WEAPON,
ARMOR,
ACCESORY;
public static CrystallizationType getByItem(L2Item item)
{
if (item instanceof L2Weapon)
{
return WEAPON;
}
if (item instanceof L2Armor)
{
return ARMOR;
}
switch (item.getBodyPart())
{
case L2Item.SLOT_R_EAR:
case L2Item.SLOT_L_EAR:
case L2Item.SLOT_R_FINGER:
case L2Item.SLOT_L_FINGER:
case L2Item.SLOT_NECK:
case L2Item.SLOT_HAIR:
case L2Item.SLOT_HAIR2:
case L2Item.SLOT_HAIRALL:
{
return ACCESORY;
}
}
return NONE;
}
}

View File

@ -1,51 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
/**
* @author UnAfraid
*/
public class CrystalizationData
{
private final int _id;
private final List<ItemChanceHolder> _items = new ArrayList<>();
public CrystalizationData(int id)
{
_id = id;
}
public int getId()
{
return _id;
}
public void addItem(ItemChanceHolder item)
{
_items.add(item);
}
public List<ItemChanceHolder> getItems()
{
return _items;
}
}

View File

@ -0,0 +1,45 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.holders;
import java.util.Collections;
import java.util.List;
/**
* @author UnAfraid
*/
public class CrystallizationDataHolder
{
private final int _id;
private final List<ItemChanceHolder> _items;
public CrystallizationDataHolder(int id, List<ItemChanceHolder> items)
{
_id = id;
_items = Collections.unmodifiableList(items);
}
public int getId()
{
return _id;
}
public List<ItemChanceHolder> getItems()
{
return Collections.unmodifiableList(_items);
}
}

View File

@ -16,16 +16,14 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
@ -110,6 +108,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
if (item.isHeroItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
@ -122,18 +121,19 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem())
{
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE))
{
_log.warning(activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId());
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId()))
{
activeChar.sendMessage("You cannot use this item.");
client.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_CRYSTALLIZED);
return;
}
@ -199,6 +199,13 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
return;
}
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(itemToRemove);
if ((crystallizationRewards == null) || crystallizationRewards.isEmpty())
{
activeChar.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
return;
}
// activeChar.setInCrystallize(true);
// unequip if needed
@ -234,19 +241,7 @@ public final class RequestCrystallizeItem implements IClientIncomingPacket
iu.addRemovedItem(removedItem);
activeChar.sendInventoryUpdate(iu);
final int crystalId = itemToRemove.getItem().getCrystalItemId();
final int crystalAmount = itemToRemove.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
if (data != null)
{
data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
}
for (ItemChanceHolder holder : items)
for (ItemChanceHolder holder : crystallizationRewards)
{
final double rand = Rnd.nextDouble() * 100;
if (rand < holder.getChance())

View File

@ -16,14 +16,12 @@
*/
package com.l2jmobius.gameserver.network.clientpackets.crystalization;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystallizationData;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.CrystalizationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
@ -180,26 +178,17 @@ public class RequestCrystallizeEstimate implements IClientIncomingPacket
return;
}
activeChar.setInCrystallize(true);
// add crystals
final int crystalId = item.getItem().getCrystalItemId();
final int crystalAmount = item.getCrystalCount();
final List<ItemChanceHolder> items = new ArrayList<>();
items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));
final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(item.getId());
if (data != null)
// Show crystallization rewards window.
final List<ItemChanceHolder> crystallizationRewards = ItemCrystallizationData.getInstance().getCrystallizationRewards(item);
if ((crystallizationRewards != null) && !crystallizationRewards.isEmpty())
{
for (ItemChanceHolder holder : data.getItems())
{
if (holder.getId() != crystalId)
{
items.add(holder);
}
}
activeChar.setInCrystallize(true);
client.sendPacket(new ExGetCrystalizingEstimation(crystallizationRewards));
}
else
{
client.sendPacket(SystemMessageId.CRYSTALLIZATION_CANNOT_BE_PROCEEDED_BECAUSE_THERE_ARE_NO_ITEMS_REGISTERED);
}
client.sendPacket(new ExGetCrystalizingEstimation(items));
}
}