Pet skill data moved to XML.

This commit is contained in:
MobiusDev
2017-10-13 16:38:08 +00:00
parent d1f25efbf7
commit d18cd64569
31 changed files with 12108 additions and 12351 deletions

View File

@@ -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();

View File

@@ -14,62 +14,82 @@
* 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 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;
public class SummonSkillsTable
/**
* @author Mobius
*/
public class PetSkillData implements IXmlReader
{
private static Logger LOGGER = Logger.getLogger(SummonSkillsTable.class.getName());
private final Map<Integer, Map<Integer, L2PetSkillLearn>> _skillTrees = new HashMap<>();
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"))
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())
{
while (rs.next())
if ("list".equalsIgnoreCase(n.getNodeName()))
{
final int npcId = rs.getInt("templateId");
Map<Integer, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
if (skillTree == null)
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
skillTree = new HashMap<>();
_skillTrees.put(npcId, skillTree);
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 + ".");
}
}
}
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)
@@ -110,9 +130,12 @@ public class SummonSkillsTable
}
break;
}
if ((temp.getMinLevel() <= cha.getLevel()) && (temp.getLevel() > lvl))
else if (temp.getMinLevel() <= cha.getLevel())
{
lvl = temp.getLevel();
if (temp.getLevel() > lvl)
{
lvl = temp.getLevel();
}
}
}
return lvl;
@@ -167,13 +190,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();
}
}
}

View File

@@ -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)