try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
ResultSet npcskills = statement.executeQuery();
L2NpcTemplate npcDat = null;
L2Skill npcSkill = null;
while (npcskills.next())
{
int mobId = npcskills.getInt("npcid");
npcDat = _npcs.get(mobId);
if (npcDat == null)
continue;
int skillId = npcskills.getInt("skillid");
int level = npcskills.getInt("level");
if (npcDat.race == null && skillId == 4416)
{
npcDat.setRace(level);
continue;
}
npcSkill = SkillTable.getInstance().getInfo(skillId, level);
if (npcSkill == null)
continue;
npcDat.addSkill(npcSkill);
}
npcskills.close();
statement.close();
}
catch (Exception e) {
_log.severe("NPCTable: Error reading NPC skills table: " + e);
}
try
{
PreparedStatement statement2 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"mobId", "itemId", "min", "max", "category", "chance"}) + " FROM droplist ORDER BY mobId, chance DESC");
ResultSet dropData = statement2.executeQuery();
L2DropData dropDat = null;
L2NpcTemplate npcDat = null;
while (dropData.next())
{
int mobId = dropData.getInt("mobId");
npcDat = _npcs.get(mobId);
if (npcDat == null)
{
_log.severe("NPCTable: No npc correlating with id : " + mobId);
continue;
}
dropDat = new L2DropData();
dropDat.setItemId(dropData.getInt("itemId"));
dropDat.setMinDrop(dropData.getInt("min"));
dropDat.setMaxDrop(dropData.getInt("max"));
dropDat.setChance(dropData.getInt("chance"));
int category = dropData.getInt("category");
npcDat.addDropData(dropDat, category);
}
dropData.close();
statement2.close();
}
catch (Exception e) {
_log.severe("NPCTable: Error reading NPC drop data: " + e);
}
try
{
PreparedStatement statement3 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "class_id"}) + " FROM skill_learn");
ResultSet learndata = statement3.executeQuery();
while (learndata.next())
{
int npcId = learndata.getInt("npc_id");
int classId = learndata.getInt("class_id");
L2NpcTemplate npc = getTemplate(npcId);
if (npc == null)
{
_log.warning("NPCTable: Error getting NPC template ID " + npcId + " while trying to load skill trainer data.");
continue;
}
npc.addTeachInfo(ClassId.values()[classId]);
}
learndata.close();
statement3.close();
}
catch (Exception e) {
_log.severe("NPCTable: Error reading NPC trainer data: " + e);
}
try
{
PreparedStatement statement4 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"boss_id", "minion_id", "amount_min", "amount_max"}) + " FROM minions");
ResultSet minionData = statement4.executeQuery();
L2MinionData minionDat = null;
L2NpcTemplate npcDat = null;
int cnt = 0;
while (minionData.next())
{
int raidId = minionData.getInt("boss_id");
npcDat = _npcs.get(raidId);
minionDat = new L2MinionData();
minionDat.setMinionId(minionData.getInt("minion_id"));
minionDat.setAmountMin(minionData.getInt("amount_min"));
minionDat.setAmountMax(minionData.getInt("amount_max"));
npcDat.addRaidData(minionDat);
cnt++;
}
minionData.close();
statement4.close();