Unhardcoded elemental attribute data.
This commit is contained in:
42
L2J_Mobius_CT_2.6_HighFive/dist/game/data/ElementalAttributeData.xml
vendored
Normal file
42
L2J_Mobius_CT_2.6_HighFive/dist/game/data/ElementalAttributeData.xml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/ElementalAttributeData.xsd">
|
||||
<!-- Stone -->
|
||||
<item id="9546" elemental="FIRE" type="STONE" />
|
||||
<item id="9547" elemental="WATER" type="STONE" />
|
||||
<item id="9549" elemental="WIND" type="STONE" />
|
||||
<item id="9548" elemental="EARTH" type="STONE" />
|
||||
<item id="9551" elemental="HOLY" type="STONE" />
|
||||
<item id="9550" elemental="DARK" type="STONE" />
|
||||
|
||||
<!-- Rough Ore -->
|
||||
<item id="10521" elemental="FIRE" type="ROUGH_ORE" />
|
||||
<item id="10522" elemental="WATER" type="ROUGH_ORE" />
|
||||
<item id="10524" elemental="WIND" type="ROUGH_ORE" />
|
||||
<item id="10523" elemental="EARTH" type="ROUGH_ORE" />
|
||||
<item id="10526" elemental="HOLY" type="ROUGH_ORE" />
|
||||
<item id="10525" elemental="DARK" type="ROUGH_ORE" />
|
||||
|
||||
<!-- Crystal -->
|
||||
<item id="9552" elemental="FIRE" type="CRYSTAL" />
|
||||
<item id="9553" elemental="WATER" type="CRYSTAL" />
|
||||
<item id="9555" elemental="WIND" type="CRYSTAL" />
|
||||
<item id="9554" elemental="EARTH" type="CRYSTAL" />
|
||||
<item id="9557" elemental="HOLY" type="CRYSTAL" />
|
||||
<item id="9556" elemental="DARK" type="CRYSTAL" />
|
||||
|
||||
<!-- Jewel -->
|
||||
<item id="9558" elemental="FIRE" type="JEWEL" />
|
||||
<item id="9559" elemental="WATER" type="JEWEL" />
|
||||
<item id="9561" elemental="WIND" type="JEWEL" />
|
||||
<item id="9560" elemental="EARTH" type="JEWEL" />
|
||||
<item id="9563" elemental="HOLY" type="JEWEL" />
|
||||
<item id="9562" elemental="DARK" type="JEWEL" />
|
||||
|
||||
<!-- Not yet supported by client (Freya PTS) -->
|
||||
<item id="9564" elemental="FIRE" type="ENERGY" />
|
||||
<item id="9565" elemental="WATER" type="ENERGY" />
|
||||
<item id="9567" elemental="WIND" type="ENERGY" />
|
||||
<item id="9566" elemental="EARTH" type="ENERGY" />
|
||||
<item id="9569" elemental="HOLY" type="ENERGY" />
|
||||
<item id="9568" elemental="DARK" type="ENERGY" />
|
||||
</list>
|
19
L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/ElementalAttributeData.xsd
vendored
Normal file
19
L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/ElementalAttributeData.xsd
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<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="item" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:int" name="id" use="required"/>
|
||||
<xs:attribute type="xs:string" name="elemental" use="required"/>
|
||||
<xs:attribute type="xs:string" name="type" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -55,6 +55,7 @@ import org.l2jmobius.gameserver.data.xml.BuyListData;
|
||||
import org.l2jmobius.gameserver.data.xml.CategoryData;
|
||||
import org.l2jmobius.gameserver.data.xml.ClassListData;
|
||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||
import org.l2jmobius.gameserver.data.xml.ElementalAttributeData;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemGroupsData;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemHPBonusData;
|
||||
@@ -252,6 +253,7 @@ public class GameServer
|
||||
EnchantItemGroupsData.getInstance();
|
||||
EnchantItemData.getInstance();
|
||||
EnchantItemOptionsData.getInstance();
|
||||
ElementalAttributeData.getInstance();
|
||||
OptionData.getInstance();
|
||||
EnchantItemHPBonusData.getInstance();
|
||||
MerchantPriceConfigTable.getInstance().loadInstances();
|
||||
|
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.gameserver.data.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.enums.ElementalItemType;
|
||||
import org.l2jmobius.gameserver.model.Elementals;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.holders.ElementalItemHolder;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ElementalAttributeData implements IXmlReader
|
||||
{
|
||||
private static final Map<Integer, ElementalItemHolder> ELEMENTAL_ITEMS = new HashMap<>();
|
||||
|
||||
protected ElementalAttributeData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
ELEMENTAL_ITEMS.clear();
|
||||
parseDatapackFile("data/ElementalAttributeData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + ELEMENTAL_ITEMS.size() + " elemental attribute items.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "item", itemNode ->
|
||||
{
|
||||
final StatSet set = new StatSet(parseAttributes(itemNode));
|
||||
|
||||
final int id = set.getInt("id");
|
||||
if (ItemTable.getInstance().getTemplate(id) == null)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find item with id " + id + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
int elementalId = Elementals.NONE;
|
||||
switch (set.getString("elemental"))
|
||||
{
|
||||
case "FIRE":
|
||||
{
|
||||
elementalId = Elementals.FIRE;
|
||||
break;
|
||||
}
|
||||
case "WATER":
|
||||
{
|
||||
elementalId = Elementals.WATER;
|
||||
break;
|
||||
}
|
||||
case "WIND":
|
||||
{
|
||||
elementalId = Elementals.WIND;
|
||||
break;
|
||||
}
|
||||
case "EARTH":
|
||||
{
|
||||
elementalId = Elementals.EARTH;
|
||||
break;
|
||||
}
|
||||
case "HOLY":
|
||||
{
|
||||
elementalId = Elementals.HOLY;
|
||||
break;
|
||||
}
|
||||
case "DARK":
|
||||
{
|
||||
elementalId = Elementals.DARK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ELEMENTAL_ITEMS.put(id, new ElementalItemHolder(id, elementalId, set.getEnum("type", ElementalItemType.class)));
|
||||
}));
|
||||
}
|
||||
|
||||
public ElementalItemHolder getElementalItem(int itemId)
|
||||
{
|
||||
return ELEMENTAL_ITEMS.getOrDefault(itemId, null);
|
||||
}
|
||||
|
||||
public static ElementalAttributeData getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final ElementalAttributeData INSTANCE = new ElementalAttributeData();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.gameserver.enums;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public enum ElementalItemType
|
||||
{
|
||||
STONE(3),
|
||||
ROUGH_ORE(3),
|
||||
CRYSTAL(6),
|
||||
JEWEL(9),
|
||||
ENERGY(12);
|
||||
|
||||
private int _maxLevel;
|
||||
|
||||
ElementalItemType(int maxLevel)
|
||||
{
|
||||
_maxLevel = maxLevel;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return _maxLevel;
|
||||
}
|
||||
}
|
@@ -16,24 +16,14 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.ElementalAttributeData;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.ElementalItemHolder;
|
||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||
import org.l2jmobius.gameserver.model.stats.functions.FuncAdd;
|
||||
|
||||
public class Elementals
|
||||
{
|
||||
private static final Map<Integer, ElementalItems> TABLE = new HashMap<>();
|
||||
static
|
||||
{
|
||||
for (ElementalItems item : ElementalItems.values())
|
||||
{
|
||||
TABLE.put(item._itemId, item);
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte NONE = -1;
|
||||
public static final byte FIRE = 0;
|
||||
public static final byte WATER = 1;
|
||||
@@ -84,87 +74,21 @@ public class Elementals
|
||||
// TODO: Higher stones
|
||||
};
|
||||
|
||||
public enum ElementalItemType
|
||||
{
|
||||
Stone(3),
|
||||
Roughore(3),
|
||||
Crystal(6),
|
||||
Jewel(9),
|
||||
Energy(12);
|
||||
|
||||
public int _maxLevel;
|
||||
|
||||
private ElementalItemType(int maxLevel)
|
||||
{
|
||||
_maxLevel = maxLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ElementalItems
|
||||
{
|
||||
fireStone(FIRE, 9546, ElementalItemType.Stone),
|
||||
waterStone(WATER, 9547, ElementalItemType.Stone),
|
||||
windStone(WIND, 9549, ElementalItemType.Stone),
|
||||
earthStone(EARTH, 9548, ElementalItemType.Stone),
|
||||
divineStone(HOLY, 9551, ElementalItemType.Stone),
|
||||
darkStone(DARK, 9550, ElementalItemType.Stone),
|
||||
|
||||
fireRoughtore(FIRE, 10521, ElementalItemType.Roughore),
|
||||
waterRoughtore(WATER, 10522, ElementalItemType.Roughore),
|
||||
windRoughtore(WIND, 10524, ElementalItemType.Roughore),
|
||||
earthRoughtore(EARTH, 10523, ElementalItemType.Roughore),
|
||||
divineRoughtore(HOLY, 10526, ElementalItemType.Roughore),
|
||||
darkRoughtore(DARK, 10525, ElementalItemType.Roughore),
|
||||
|
||||
fireCrystal(FIRE, 9552, ElementalItemType.Crystal),
|
||||
waterCrystal(WATER, 9553, ElementalItemType.Crystal),
|
||||
windCrystal(WIND, 9555, ElementalItemType.Crystal),
|
||||
earthCrystal(EARTH, 9554, ElementalItemType.Crystal),
|
||||
divineCrystal(HOLY, 9557, ElementalItemType.Crystal),
|
||||
darkCrystal(DARK, 9556, ElementalItemType.Crystal),
|
||||
|
||||
fireJewel(FIRE, 9558, ElementalItemType.Jewel),
|
||||
waterJewel(WATER, 9559, ElementalItemType.Jewel),
|
||||
windJewel(WIND, 9561, ElementalItemType.Jewel),
|
||||
earthJewel(EARTH, 9560, ElementalItemType.Jewel),
|
||||
divineJewel(HOLY, 9563, ElementalItemType.Jewel),
|
||||
darkJewel(DARK, 9562, ElementalItemType.Jewel),
|
||||
|
||||
// not yet supported by client (Freya pts)
|
||||
fireEnergy(FIRE, 9564, ElementalItemType.Energy),
|
||||
waterEnergy(WATER, 9565, ElementalItemType.Energy),
|
||||
windEnergy(WIND, 9567, ElementalItemType.Energy),
|
||||
earthEnergy(EARTH, 9566, ElementalItemType.Energy),
|
||||
divineEnergy(HOLY, 9569, ElementalItemType.Energy),
|
||||
darkEnergy(DARK, 9568, ElementalItemType.Energy);
|
||||
|
||||
public byte _element;
|
||||
public int _itemId;
|
||||
public ElementalItemType _type;
|
||||
|
||||
private ElementalItems(byte element, int itemId, ElementalItemType type)
|
||||
{
|
||||
_element = element;
|
||||
_itemId = itemId;
|
||||
_type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte getItemElement(int itemId)
|
||||
{
|
||||
final ElementalItems item = TABLE.get(itemId);
|
||||
return item != null ? item._element : NONE;
|
||||
final ElementalItemHolder item = ElementalAttributeData.getInstance().getElementalItem(itemId);
|
||||
return item != null ? item.getElementId() : NONE;
|
||||
}
|
||||
|
||||
public static ElementalItems getItemElemental(int itemId)
|
||||
public static ElementalItemHolder getItemElemental(int itemId)
|
||||
{
|
||||
return TABLE.get(itemId);
|
||||
return ElementalAttributeData.getInstance().getElementalItem(itemId);
|
||||
}
|
||||
|
||||
public static int getMaxElementLevel(int itemId)
|
||||
{
|
||||
final ElementalItems item = TABLE.get(itemId);
|
||||
return item != null ? item._type._maxLevel : -1;
|
||||
final ElementalItemHolder item = ElementalAttributeData.getInstance().getElementalItem(itemId);
|
||||
return item != null ? item.getType().getMaxLevel() : -1;
|
||||
}
|
||||
|
||||
public static String getElementName(byte element)
|
||||
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.ElementalItemType;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ElementalItemHolder
|
||||
{
|
||||
private final int _itemId;
|
||||
private final byte _elementId;
|
||||
private final ElementalItemType _type;
|
||||
|
||||
public ElementalItemHolder(int itemId, int elementId, ElementalItemType type)
|
||||
{
|
||||
_itemId = itemId;
|
||||
_elementId = (byte) elementId;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
public byte getElementId()
|
||||
{
|
||||
return _elementId;
|
||||
}
|
||||
|
||||
public ElementalItemType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
@@ -22,6 +22,7 @@ import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import org.l2jmobius.gameserver.model.Elementals;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.ElementalItemHolder;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
@@ -174,25 +175,25 @@ public class RequestExEnchantItemAttribute implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
boolean success = false;
|
||||
switch (Elementals.getItemElemental(stoneId)._type)
|
||||
switch (Elementals.getItemElemental(stoneId).getType())
|
||||
{
|
||||
case Stone:
|
||||
case Roughore:
|
||||
case STONE:
|
||||
case ROUGH_ORE:
|
||||
{
|
||||
success = Rnd.get(100) < Config.ENCHANT_CHANCE_ELEMENT_STONE;
|
||||
break;
|
||||
}
|
||||
case Crystal:
|
||||
case CRYSTAL:
|
||||
{
|
||||
success = Rnd.get(100) < Config.ENCHANT_CHANCE_ELEMENT_CRYSTAL;
|
||||
break;
|
||||
}
|
||||
case Jewel:
|
||||
case JEWEL:
|
||||
{
|
||||
success = Rnd.get(100) < Config.ENCHANT_CHANCE_ELEMENT_JEWEL;
|
||||
break;
|
||||
}
|
||||
case Energy:
|
||||
case ENERGY:
|
||||
{
|
||||
success = Rnd.get(100) < Config.ENCHANT_CHANCE_ELEMENT_ENERGY;
|
||||
break;
|
||||
@@ -262,7 +263,7 @@ public class RequestExEnchantItemAttribute implements IClientIncomingPacket
|
||||
|
||||
public int getLimit(ItemInstance item, int sotneId)
|
||||
{
|
||||
final Elementals.ElementalItems elementItem = Elementals.getItemElemental(sotneId);
|
||||
final ElementalItemHolder elementItem = Elementals.getItemElemental(sotneId);
|
||||
if (elementItem == null)
|
||||
{
|
||||
return 0;
|
||||
@@ -270,9 +271,9 @@ public class RequestExEnchantItemAttribute implements IClientIncomingPacket
|
||||
|
||||
if (item.isWeapon())
|
||||
{
|
||||
return Elementals.WEAPON_VALUES[elementItem._type._maxLevel];
|
||||
return Elementals.WEAPON_VALUES[elementItem.getType().getMaxLevel()];
|
||||
}
|
||||
return Elementals.ARMOR_VALUES[elementItem._type._maxLevel];
|
||||
return Elementals.ARMOR_VALUES[elementItem.getType().getMaxLevel()];
|
||||
}
|
||||
|
||||
public int getPowerToAdd(int stoneId, int oldValue, ItemInstance item)
|
||||
|
Reference in New Issue
Block a user