Pet skill data moved to XML.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
2360
L2J_Mobius_1.0_Ertheia/dist/game/data/PetSkillData.xml
vendored
Normal file
2360
L2J_Mobius_1.0_Ertheia/dist/game/data/PetSkillData.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package handlers.playeractions;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||
import com.l2jmobius.gameserver.model.ActionDataHolder;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
@@ -53,7 +53,7 @@ public final class ServitorSkillUse implements IPlayerActionHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final int skillLevel = SummonSkillsTable.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
final int skillLevel = PetSkillData.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
if (skillLevel > 0)
|
||||
{
|
||||
servitor.setTarget(activeChar.getTarget());
|
||||
|
20
L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
20
L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="list">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="skill" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:short" name="templateId"/>
|
||||
<xs:attribute type="xs:byte" name="minLvl"/>
|
||||
<xs:attribute type="xs:short" name="skillId"/>
|
||||
<xs:attribute type="xs:byte" name="skillLvl"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -38,7 +38,6 @@ import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ActionData;
|
||||
@@ -88,6 +87,7 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillLearnData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.UIData;
|
||||
@@ -213,7 +213,7 @@ public class GameServer
|
||||
EnchantSkillGroupsData.getInstance();
|
||||
SkillTreesData.getInstance();
|
||||
SkillData.getInstance();
|
||||
SummonSkillsTable.getInstance();
|
||||
PetSkillData.getInstance();
|
||||
|
||||
printSection("Items");
|
||||
ConditionHandler.getInstance().executeScript();
|
||||
|
@@ -14,62 +14,81 @@
|
||||
* 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.sql.impl;
|
||||
package com.l2jmobius.gameserver.data.xml.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
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.actor.L2Summon;
|
||||
|
||||
public class SummonSkillsTable
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PetSkillData implements IGameXmlReader
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(SummonSkillsTable.class.getName());
|
||||
private static Logger LOGGER = Logger.getLogger(PetSkillData.class.getName());
|
||||
private final Map<Integer, Map<Long, L2PetSkillLearn>> _skillTrees = new HashMap<>();
|
||||
|
||||
protected SummonSkillsTable()
|
||||
protected PetSkillData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_skillTrees.clear();
|
||||
int count = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
final int npcId = rs.getInt("templateId");
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
parseDatapackFile("data/PetSkillData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _skillTrees.size() + " skills.");
|
||||
}
|
||||
|
||||
final int id = rs.getInt("skillId");
|
||||
final int lvl = rs.getInt("skillLvl");
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, rs.getInt("minLvl")));
|
||||
count++;
|
||||
@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 ("skill".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
final NamedNodeMap attrs = d.getAttributes();
|
||||
|
||||
final int npcId = parseInteger(attrs, "templateId");
|
||||
final int id = parseInteger(attrs, "skillId");
|
||||
final int lvl = parseInteger(attrs, "skillLvl");
|
||||
final int minLvl = parseInteger(attrs, "minLvl");
|
||||
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
|
||||
if (SkillData.getInstance().getSkill(id, lvl == 0 ? 1 : lvl) != null)
|
||||
{
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, minLvl));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill with id " + id + ", level " + lvl + " for NPC " + npcId + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Error while loading pet skill tree:", e);
|
||||
}
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + count + " skills.");
|
||||
}
|
||||
|
||||
public int getAvailableLevel(L2Summon cha, int skillId)
|
||||
@@ -170,13 +189,13 @@ public class SummonSkillsTable
|
||||
}
|
||||
}
|
||||
|
||||
public static SummonSkillsTable getInstance()
|
||||
public static PetSkillData getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final SummonSkillsTable _instance = new SummonSkillsTable();
|
||||
protected static final PetSkillData _instance = new PetSkillData();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
2360
L2J_Mobius_2.5_Underground/dist/game/data/PetSkillData.xml
vendored
Normal file
2360
L2J_Mobius_2.5_Underground/dist/game/data/PetSkillData.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package handlers.playeractions;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||
import com.l2jmobius.gameserver.model.ActionDataHolder;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
@@ -53,7 +53,7 @@ public final class ServitorSkillUse implements IPlayerActionHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final int skillLevel = SummonSkillsTable.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
final int skillLevel = PetSkillData.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
if (skillLevel > 0)
|
||||
{
|
||||
servitor.setTarget(activeChar.getTarget());
|
||||
|
20
L2J_Mobius_2.5_Underground/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
20
L2J_Mobius_2.5_Underground/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="list">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="skill" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:short" name="templateId"/>
|
||||
<xs:attribute type="xs:byte" name="minLvl"/>
|
||||
<xs:attribute type="xs:short" name="skillId"/>
|
||||
<xs:attribute type="xs:byte" name="skillLvl"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -38,7 +38,6 @@ import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ActionData;
|
||||
@@ -90,6 +89,7 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillLearnData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.UIData;
|
||||
@@ -218,7 +218,7 @@ public class GameServer
|
||||
EnchantSkillGroupsData.getInstance();
|
||||
SkillTreesData.getInstance();
|
||||
SkillData.getInstance();
|
||||
SummonSkillsTable.getInstance();
|
||||
PetSkillData.getInstance();
|
||||
|
||||
printSection("Items");
|
||||
ConditionHandler.getInstance().executeScript();
|
||||
|
@@ -14,62 +14,81 @@
|
||||
* 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.sql.impl;
|
||||
package com.l2jmobius.gameserver.data.xml.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
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.actor.L2Summon;
|
||||
|
||||
public class SummonSkillsTable
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PetSkillData implements IGameXmlReader
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(SummonSkillsTable.class.getName());
|
||||
private static Logger LOGGER = Logger.getLogger(PetSkillData.class.getName());
|
||||
private final Map<Integer, Map<Long, L2PetSkillLearn>> _skillTrees = new HashMap<>();
|
||||
|
||||
protected SummonSkillsTable()
|
||||
protected PetSkillData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_skillTrees.clear();
|
||||
int count = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
final int npcId = rs.getInt("templateId");
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
parseDatapackFile("data/PetSkillData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _skillTrees.size() + " skills.");
|
||||
}
|
||||
|
||||
final int id = rs.getInt("skillId");
|
||||
final int lvl = rs.getInt("skillLvl");
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, rs.getInt("minLvl")));
|
||||
count++;
|
||||
@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 ("skill".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
final NamedNodeMap attrs = d.getAttributes();
|
||||
|
||||
final int npcId = parseInteger(attrs, "templateId");
|
||||
final int id = parseInteger(attrs, "skillId");
|
||||
final int lvl = parseInteger(attrs, "skillLvl");
|
||||
final int minLvl = parseInteger(attrs, "minLvl");
|
||||
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
|
||||
if (SkillData.getInstance().getSkill(id, lvl == 0 ? 1 : lvl) != null)
|
||||
{
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, minLvl));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill with id " + id + ", level " + lvl + " for NPC " + npcId + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Error while loading pet skill tree:", e);
|
||||
}
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + count + " skills.");
|
||||
}
|
||||
|
||||
public int getAvailableLevel(L2Summon cha, int skillId)
|
||||
@@ -170,13 +189,13 @@ public class SummonSkillsTable
|
||||
}
|
||||
}
|
||||
|
||||
public static SummonSkillsTable getInstance()
|
||||
public static PetSkillData getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final SummonSkillsTable _instance = new SummonSkillsTable();
|
||||
protected static final PetSkillData _instance = new PetSkillData();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
2360
L2J_Mobius_3.0_Helios/dist/game/data/PetSkillData.xml
vendored
Normal file
2360
L2J_Mobius_3.0_Helios/dist/game/data/PetSkillData.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package handlers.playeractions;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||
import com.l2jmobius.gameserver.model.ActionDataHolder;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
@@ -53,7 +53,7 @@ public final class ServitorSkillUse implements IPlayerActionHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final int skillLevel = SummonSkillsTable.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
final int skillLevel = PetSkillData.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
if (skillLevel > 0)
|
||||
{
|
||||
servitor.setTarget(activeChar.getTarget());
|
||||
|
20
L2J_Mobius_3.0_Helios/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
20
L2J_Mobius_3.0_Helios/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="list">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="skill" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:short" name="templateId"/>
|
||||
<xs:attribute type="xs:byte" name="minLvl"/>
|
||||
<xs:attribute type="xs:short" name="skillId"/>
|
||||
<xs:attribute type="xs:byte" name="skillLvl"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -38,7 +38,6 @@ import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ActionData;
|
||||
@@ -90,6 +89,7 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillLearnData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.UIData;
|
||||
@@ -218,7 +218,7 @@ public class GameServer
|
||||
EnchantSkillGroupsData.getInstance();
|
||||
SkillTreesData.getInstance();
|
||||
SkillData.getInstance();
|
||||
SummonSkillsTable.getInstance();
|
||||
PetSkillData.getInstance();
|
||||
|
||||
printSection("Items");
|
||||
ConditionHandler.getInstance().executeScript();
|
||||
|
@@ -14,62 +14,81 @@
|
||||
* 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.sql.impl;
|
||||
package com.l2jmobius.gameserver.data.xml.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
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.actor.L2Summon;
|
||||
|
||||
public class SummonSkillsTable
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PetSkillData implements IGameXmlReader
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(SummonSkillsTable.class.getName());
|
||||
private static Logger LOGGER = Logger.getLogger(PetSkillData.class.getName());
|
||||
private final Map<Integer, Map<Long, L2PetSkillLearn>> _skillTrees = new HashMap<>();
|
||||
|
||||
protected SummonSkillsTable()
|
||||
protected PetSkillData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_skillTrees.clear();
|
||||
int count = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
final int npcId = rs.getInt("templateId");
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
parseDatapackFile("data/PetSkillData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _skillTrees.size() + " skills.");
|
||||
}
|
||||
|
||||
final int id = rs.getInt("skillId");
|
||||
final int lvl = rs.getInt("skillLvl");
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, rs.getInt("minLvl")));
|
||||
count++;
|
||||
@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 ("skill".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
final NamedNodeMap attrs = d.getAttributes();
|
||||
|
||||
final int npcId = parseInteger(attrs, "templateId");
|
||||
final int id = parseInteger(attrs, "skillId");
|
||||
final int lvl = parseInteger(attrs, "skillLvl");
|
||||
final int minLvl = parseInteger(attrs, "minLvl");
|
||||
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
|
||||
if (SkillData.getInstance().getSkill(id, lvl == 0 ? 1 : lvl) != null)
|
||||
{
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, minLvl));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill with id " + id + ", level " + lvl + " for NPC " + npcId + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Error while loading pet skill tree:", e);
|
||||
}
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + count + " skills.");
|
||||
}
|
||||
|
||||
public int getAvailableLevel(L2Summon cha, int skillId)
|
||||
@@ -170,13 +189,13 @@ public class SummonSkillsTable
|
||||
}
|
||||
}
|
||||
|
||||
public static SummonSkillsTable getInstance()
|
||||
public static PetSkillData getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final SummonSkillsTable _instance = new SummonSkillsTable();
|
||||
protected static final PetSkillData _instance = new PetSkillData();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
1951
L2J_Mobius_CT_2.6_HighFive/dist/game/data/PetSkillData.xml
vendored
Normal file
1951
L2J_Mobius_CT_2.6_HighFive/dist/game/data/PetSkillData.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
20
L2J_Mobius_CT_2.6_HighFive/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="list">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="skill" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:short" name="templateId"/>
|
||||
<xs:attribute type="xs:byte" name="minLvl"/>
|
||||
<xs:attribute type="xs:short" name="skillId"/>
|
||||
<xs:attribute type="xs:byte" name="skillLvl"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -41,7 +41,6 @@ import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.NpcBufferTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
|
||||
@@ -67,6 +66,7 @@ import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PlayerTemplateData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PlayerXpPercentLostData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.RecipeData;
|
||||
@@ -193,7 +193,7 @@ public final class GameServer
|
||||
EnchantSkillGroupsData.getInstance();
|
||||
SkillTreesData.getInstance();
|
||||
SkillData.getInstance();
|
||||
SummonSkillsTable.getInstance();
|
||||
PetSkillData.getInstance();
|
||||
|
||||
printSection("Items");
|
||||
ItemTable.getInstance();
|
||||
|
@@ -1,179 +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.sql.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
|
||||
public class SummonSkillsTable
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(SummonSkillsTable.class.getName());
|
||||
private final Map<Integer, Map<Integer, L2PetSkillLearn>> _skillTrees = new HashMap<>();
|
||||
|
||||
protected SummonSkillsTable()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
_skillTrees.clear();
|
||||
int count = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
final int npcId = rs.getInt("templateId");
|
||||
Map<Integer, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
|
||||
final int id = rs.getInt("skillId");
|
||||
final int lvl = rs.getInt("skillLvl");
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, rs.getInt("minLvl")));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Error while loading pet skill tree:", e);
|
||||
}
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + count + " skills.");
|
||||
}
|
||||
|
||||
public int getAvailableLevel(L2Summon cha, int skillId)
|
||||
{
|
||||
int lvl = 0;
|
||||
if (!_skillTrees.containsKey(cha.getId()))
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Pet id " + cha.getId() + " does not have any skills assigned.");
|
||||
return lvl;
|
||||
}
|
||||
final Collection<L2PetSkillLearn> skills = _skillTrees.get(cha.getId()).values();
|
||||
for (L2PetSkillLearn temp : skills)
|
||||
{
|
||||
if (temp.getId() != skillId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (temp.getLevel() == 0)
|
||||
{
|
||||
if (cha.getLevel() < 70)
|
||||
{
|
||||
lvl = cha.getLevel() / 10;
|
||||
if (lvl <= 0)
|
||||
{
|
||||
lvl = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lvl = 7 + ((cha.getLevel() - 70) / 5);
|
||||
}
|
||||
|
||||
// formula usable for skill that have 10 or more skill levels
|
||||
final int maxLvl = SkillData.getInstance().getMaxLevel(temp.getId());
|
||||
if (lvl > maxLvl)
|
||||
{
|
||||
lvl = maxLvl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((temp.getMinLevel() <= cha.getLevel()) && (temp.getLevel() > lvl))
|
||||
{
|
||||
lvl = temp.getLevel();
|
||||
}
|
||||
}
|
||||
return lvl;
|
||||
}
|
||||
|
||||
public List<Integer> getAvailableSkills(L2Summon cha)
|
||||
{
|
||||
final List<Integer> skillIds = new ArrayList<>();
|
||||
if (!_skillTrees.containsKey(cha.getId()))
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Pet id " + cha.getId() + " does not have any skills assigned.");
|
||||
return skillIds;
|
||||
}
|
||||
final Collection<L2PetSkillLearn> skills = _skillTrees.get(cha.getId()).values();
|
||||
for (L2PetSkillLearn temp : skills)
|
||||
{
|
||||
if (skillIds.contains(temp.getId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
skillIds.add(temp.getId());
|
||||
}
|
||||
return skillIds;
|
||||
}
|
||||
|
||||
public static final class L2PetSkillLearn
|
||||
{
|
||||
private final int _id;
|
||||
private final int _level;
|
||||
private final int _minLevel;
|
||||
|
||||
public L2PetSkillLearn(int id, int lvl, int minLvl)
|
||||
{
|
||||
_id = id;
|
||||
_level = lvl;
|
||||
_minLevel = minLvl;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public int getMinLevel()
|
||||
{
|
||||
return _minLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public static SummonSkillsTable getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final SummonSkillsTable _instance = new SummonSkillsTable();
|
||||
}
|
||||
}
|
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* 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.Collection;
|
||||
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.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.util.data.xml.IXmlReader;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PetSkillData implements IXmlReader
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(PetSkillData.class.getName());
|
||||
private final Map<Integer, Map<Long, L2PetSkillLearn>> _skillTrees = new HashMap<>();
|
||||
|
||||
protected PetSkillData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_skillTrees.clear();
|
||||
parseDatapackFile("data/PetSkillData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _skillTrees.size() + " skills.");
|
||||
}
|
||||
|
||||
@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 ("skill".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
final NamedNodeMap attrs = d.getAttributes();
|
||||
|
||||
final int npcId = parseInteger(attrs, "templateId");
|
||||
final int id = parseInteger(attrs, "skillId");
|
||||
final int lvl = parseInteger(attrs, "skillLvl");
|
||||
final int minLvl = parseInteger(attrs, "minLvl");
|
||||
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
|
||||
if (SkillData.getInstance().getSkill(id, lvl == 0 ? 1 : lvl) != null)
|
||||
{
|
||||
skillTree.put((long) SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, minLvl));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill with id " + id + ", level " + lvl + " for NPC " + npcId + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getAvailableLevel(L2Summon cha, int skillId)
|
||||
{
|
||||
int lvl = 0;
|
||||
if (!_skillTrees.containsKey(cha.getId()))
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Pet id " + cha.getId() + " does not have any skills assigned.");
|
||||
return lvl;
|
||||
}
|
||||
final Collection<L2PetSkillLearn> skills = _skillTrees.get(cha.getId()).values();
|
||||
for (L2PetSkillLearn temp : skills)
|
||||
{
|
||||
if (temp.getId() != skillId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (temp.getLevel() == 0)
|
||||
{
|
||||
if (cha.getLevel() < 70)
|
||||
{
|
||||
lvl = cha.getLevel() / 10;
|
||||
if (lvl <= 0)
|
||||
{
|
||||
lvl = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lvl = 7 + ((cha.getLevel() - 70) / 5);
|
||||
}
|
||||
|
||||
// formula usable for skill that have 10 or more skill levels
|
||||
final int maxLvl = SkillData.getInstance().getMaxLevel(temp.getId());
|
||||
if (lvl > maxLvl)
|
||||
{
|
||||
lvl = maxLvl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (temp.getMinLevel() <= cha.getLevel())
|
||||
{
|
||||
if (temp.getLevel() > lvl)
|
||||
{
|
||||
lvl = temp.getLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return lvl;
|
||||
}
|
||||
|
||||
public List<Integer> getAvailableSkills(L2Summon cha)
|
||||
{
|
||||
final List<Integer> skillIds = new ArrayList<>();
|
||||
if (!_skillTrees.containsKey(cha.getId()))
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Pet id " + cha.getId() + " does not have any skills assigned.");
|
||||
return skillIds;
|
||||
}
|
||||
final Collection<L2PetSkillLearn> skills = _skillTrees.get(cha.getId()).values();
|
||||
for (L2PetSkillLearn temp : skills)
|
||||
{
|
||||
if (skillIds.contains(temp.getId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
skillIds.add(temp.getId());
|
||||
}
|
||||
return skillIds;
|
||||
}
|
||||
|
||||
public static final class L2PetSkillLearn
|
||||
{
|
||||
private final int _id;
|
||||
private final int _level;
|
||||
private final int _minLevel;
|
||||
|
||||
public L2PetSkillLearn(int id, int lvl, int minLvl)
|
||||
{
|
||||
_id = id;
|
||||
_level = lvl;
|
||||
_minLevel = minLvl;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public int getMinLevel()
|
||||
{
|
||||
return _minLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public static PetSkillData getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PetSkillData _instance = new PetSkillData();
|
||||
}
|
||||
}
|
@@ -23,8 +23,8 @@ import com.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.ai.L2SummonAI;
|
||||
import com.l2jmobius.gameserver.ai.NextAction;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.datatables.BotReportTable;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
@@ -1136,7 +1136,7 @@ public final class RequestActionUse extends L2GameClientPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
lvl = SummonSkillsTable.getInstance().getAvailableLevel(summon, skillId);
|
||||
lvl = PetSkillData.getInstance().getAvailableLevel(summon, skillId);
|
||||
}
|
||||
|
||||
if (lvl > 0)
|
||||
|
File diff suppressed because it is too large
Load Diff
1951
L2J_Mobius_Classic_2.0_Saviors/dist/game/data/PetSkillData.xml
vendored
Normal file
1951
L2J_Mobius_Classic_2.0_Saviors/dist/game/data/PetSkillData.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package handlers.playeractions;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||
import com.l2jmobius.gameserver.model.ActionDataHolder;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
@@ -53,7 +53,7 @@ public final class ServitorSkillUse implements IPlayerActionHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final int skillLevel = SummonSkillsTable.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
final int skillLevel = PetSkillData.getInstance().getAvailableLevel(servitor, data.getOptionId());
|
||||
if (skillLevel > 0)
|
||||
{
|
||||
servitor.setTarget(activeChar.getTarget());
|
||||
|
20
L2J_Mobius_Classic_2.0_Saviors/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
20
L2J_Mobius_Classic_2.0_Saviors/dist/game/data/xsd/PetSkillData.xsd
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="list">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="skill" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:short" name="templateId"/>
|
||||
<xs:attribute type="xs:byte" name="minLvl"/>
|
||||
<xs:attribute type="xs:short" name="skillId"/>
|
||||
<xs:attribute type="xs:byte" name="skillLvl"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -38,7 +38,6 @@ import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.SummonSkillsTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ActionData;
|
||||
@@ -90,6 +89,7 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillLearnData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetSkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.UIData;
|
||||
@@ -216,7 +216,7 @@ public class GameServer
|
||||
EnchantSkillGroupsData.getInstance();
|
||||
SkillTreesData.getInstance();
|
||||
SkillData.getInstance();
|
||||
SummonSkillsTable.getInstance();
|
||||
PetSkillData.getInstance();
|
||||
|
||||
printSection("Items");
|
||||
ConditionHandler.getInstance().executeScript();
|
||||
|
@@ -14,62 +14,81 @@
|
||||
* 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.sql.impl;
|
||||
package com.l2jmobius.gameserver.data.xml.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
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.actor.L2Summon;
|
||||
|
||||
public class SummonSkillsTable
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PetSkillData implements IGameXmlReader
|
||||
{
|
||||
private static Logger LOGGER = Logger.getLogger(SummonSkillsTable.class.getName());
|
||||
private static Logger LOGGER = Logger.getLogger(PetSkillData.class.getName());
|
||||
private final Map<Integer, Map<Long, L2PetSkillLearn>> _skillTrees = new HashMap<>();
|
||||
|
||||
protected SummonSkillsTable()
|
||||
protected PetSkillData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_skillTrees.clear();
|
||||
int count = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
final int npcId = rs.getInt("templateId");
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
parseDatapackFile("data/PetSkillData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _skillTrees.size() + " skills.");
|
||||
}
|
||||
|
||||
final int id = rs.getInt("skillId");
|
||||
final int lvl = rs.getInt("skillLvl");
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, rs.getInt("minLvl")));
|
||||
count++;
|
||||
@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 ("skill".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
final NamedNodeMap attrs = d.getAttributes();
|
||||
|
||||
final int npcId = parseInteger(attrs, "templateId");
|
||||
final int id = parseInteger(attrs, "skillId");
|
||||
final int lvl = parseInteger(attrs, "skillLvl");
|
||||
final int minLvl = parseInteger(attrs, "minLvl");
|
||||
|
||||
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
|
||||
if (skillTree == null)
|
||||
{
|
||||
skillTree = new HashMap<>();
|
||||
_skillTrees.put(npcId, skillTree);
|
||||
}
|
||||
|
||||
if (SkillData.getInstance().getSkill(id, lvl == 0 ? 1 : lvl) != null)
|
||||
{
|
||||
skillTree.put(SkillData.getSkillHashCode(id, lvl + 1), new L2PetSkillLearn(id, lvl, minLvl));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Could not find skill with id " + id + ", level " + lvl + " for NPC " + npcId + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Error while loading pet skill tree:", e);
|
||||
}
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + count + " skills.");
|
||||
}
|
||||
|
||||
public int getAvailableLevel(L2Summon cha, int skillId)
|
||||
@@ -170,13 +189,13 @@ public class SummonSkillsTable
|
||||
}
|
||||
}
|
||||
|
||||
public static SummonSkillsTable getInstance()
|
||||
public static PetSkillData getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final SummonSkillsTable _instance = new SummonSkillsTable();
|
||||
protected static final PetSkillData _instance = new PetSkillData();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user