Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/com/l2jserver/gameserver/GameServer.java
- ===================================================================
- --- java/com/l2jserver/gameserver/GameServer.java (revision 4587)
- +++ java/com/l2jserver/gameserver/GameServer.java (working copy)
- @@ -150,7 +150,7 @@
- private final DeadLockDetector _deadDetectThread;
- private final IdFactory _idFactory;
- public static GameServer gameServer;
- - private LoginServerThread _loginThread;
- + private final LoginServerThread _loginThread;
- private static Status _statusServer;
- public static final Calendar dateTimeServerStarted = Calendar.getInstance();
- @@ -241,7 +241,7 @@
- SkillSpellbookTable.getInstance();
- printSection("Characters");
- - CharTemplateTable.getInstance();
- + CharTemplateTable.getInstance().init();
- CharNameTable.getInstance();
- LevelUpData.getInstance();
- AccessLevels.getInstance();
- Index: java/com/l2jserver/gameserver/datatables/CharTemplateTable.java
- ===================================================================
- --- java/com/l2jserver/gameserver/datatables/CharTemplateTable.java (revision 4587)
- +++ java/com/l2jserver/gameserver/datatables/CharTemplateTable.java (working copy)
- @@ -14,21 +14,80 @@
- */
- package com.l2jserver.gameserver.datatables;
- +import java.io.File;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- +import java.util.Map;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- +import javax.xml.parsers.DocumentBuilderFactory;
- +
- +import javolution.util.FastMap;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +import com.l2jserver.Config;
- import com.l2jserver.L2DatabaseFactory;
- import com.l2jserver.gameserver.model.base.ClassId;
- import com.l2jserver.gameserver.templates.StatsSet;
- import com.l2jserver.gameserver.templates.chars.L2PcTemplate;
- /**
- + * Values that are set though StatsSet
- *
- - * @author Unknown, Forsaiken
- + * [CharTemplates]:
- + * baseSTR
- + * baseDEX
- + * baseCON
- + * baseINT
- + * baseWIT
- + * baseMEN
- + * baseHpMax
- + * lvlHpAdd
- + * lvlHpMod
- + * baseMpMax
- + * baseCpMax
- + * lvlCpAdd
- + * lvlCpMod
- + * lvlMpAdd
- + * lvlMpMod
- + * baseHpReg
- + * baseMpReg
- + * baseMAtkSpd
- + * baseRunSpd
- + * baseWalkSpd
- + * baseShldDef
- + * baseShldRate
- + *
- + * [PcBaseStats]:
- + * basePAtk
- + * baseRcrit
- + * baseAtkType
- + * baseAtkSpd
- + * basePDef
- + * baseMAtk
- + * baseMDef
- + * baseCanPenetrate
- + * baseAtkRange
- + * baseDamRange
- + * baseRndDam
- + *
- + * [PcBreathBonus]:
- + * pcBreathBonus
- + *
- + * [PcCollision]:
- + * collision_radius
- + * collision_height
- + *
- + * [PcSafeFallHeight]:
- + * safeFallHeight
- + *
- + * @author Unknown, Forsaiken, reworked by Nik
- *
- */
- public final class CharTemplateTable
- @@ -41,88 +100,36 @@
- }
- private final L2PcTemplate[] _templates;
- + Map<Integer, StatsSet> _ssMap; // Temp map sith StatsSet that we use until finalazing the current StatsSet that we are going to use to create L2PcTemplate
- private CharTemplateTable()
- {
- _templates = new L2PcTemplate[ClassId.values().length];
- -
- - Connection con = null;
- + _ssMap = new FastMap<Integer, StatsSet>();
- + }
- +
- + public void init()
- + {
- + // Load the PCs stats
- + loadCharTemplates();
- + loadPcBaseStats();
- + loadPcBreathBonus();
- + loadPcCollision();
- + loadPcSafeFallHeight();
- - try
- - {
- - con = L2DatabaseFactory.getInstance().getConnection();
- - PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list, char_templates, lvlupgain"
- - + " WHERE class_list.id = char_templates.classId" + " AND class_list.id = lvlupgain.classId"
- - + " ORDER BY class_list.id");
- - ResultSet rset = statement.executeQuery();
- -
- - int count = 0;
- - while (rset.next())
- - {
- - StatsSet set = new StatsSet();
- - set.set("classId", rset.getInt("id"));
- - set.set("className", rset.getString("className"));
- - set.set("raceId", rset.getInt("raceId"));
- - set.set("baseSTR", rset.getInt("STR"));
- - set.set("baseCON", rset.getInt("CON"));
- - set.set("baseDEX", rset.getInt("DEX"));
- - set.set("baseINT", rset.getInt("_INT"));
- - set.set("baseWIT", rset.getInt("WIT"));
- - set.set("baseMEN", rset.getInt("MEN"));
- - set.set("baseHpMax", rset.getFloat("defaultHpBase"));
- - set.set("lvlHpAdd", rset.getFloat("defaultHpAdd"));
- - set.set("lvlHpMod", rset.getFloat("defaultHpMod"));
- - set.set("baseMpMax", rset.getFloat("defaultMpBase"));
- - set.set("baseCpMax", rset.getFloat("defaultCpBase"));
- - set.set("lvlCpAdd", rset.getFloat("defaultCpAdd"));
- - set.set("lvlCpMod", rset.getFloat("defaultCpMod"));
- - set.set("lvlMpAdd", rset.getFloat("defaultMpAdd"));
- - set.set("lvlMpMod", rset.getFloat("defaultMpMod"));
- - set.set("baseHpReg", 1.5);
- - set.set("baseMpReg", 0.9);
- - set.set("basePAtk", rset.getInt("p_atk"));
- - set.set("basePDef", /*classId.isMage()? 77 : 129*/rset.getInt("p_def"));
- - set.set("baseMAtk", rset.getInt("m_atk"));
- - set.set("baseMDef", rset.getInt("char_templates.m_def"));
- - set.set("classBaseLevel", rset.getInt("class_lvl"));
- - set.set("basePAtkSpd", rset.getInt("p_spd"));
- - set.set("baseMAtkSpd", /*classId.isMage()? 166 : 333*/rset.getInt("char_templates.m_spd"));
- - set.set("baseCritRate", rset.getInt("char_templates.critical") / 10);
- - set.set("baseRunSpd", rset.getInt("move_spd"));
- - set.set("baseWalkSpd", 0);
- - set.set("baseShldDef", 0);
- - set.set("baseShldRate", 0);
- - set.set("baseAtkRange", 40);
- -
- - set.set("spawnX", rset.getInt("x"));
- - set.set("spawnY", rset.getInt("y"));
- - set.set("spawnZ", rset.getInt("z"));
- -
- - L2PcTemplate ct;
- -
- - set.set("collision_radius", rset.getDouble("m_col_r"));
- - set.set("collision_height", rset.getDouble("m_col_h"));
- - set.set("collision_radius_female", rset.getDouble("f_col_r"));
- - set.set("collision_height_female", rset.getDouble("f_col_h"));
- - ct = new L2PcTemplate(set);
- -
- - _templates[ct.classId.getId()] = ct;
- - ++count;
- - }
- -
- - rset.close();
- - statement.close();
- -
- - _log.info("CharTemplateTable: Loaded " + count + " Character Templates.");
- - }
- - catch (SQLException e)
- + // Now since everything is loaded, the StatsSet are ready, now we can generate the _templates
- + for (StatsSet set : _ssMap.values())
- {
- - _log.log(Level.SEVERE, "Failed loading char templates", e);
- + _log.info("CharTemplates: Loading " + set.getInteger("classId") + " class...");
- + L2PcTemplate ct = new L2PcTemplate(set);
- + _templates[ct.classId.getId()] = ct;
- + _log.info("CharTemplates: Loaded " + ct.classId.getId() + " class.");
- }
- - finally
- - {
- - L2DatabaseFactory.close(con);
- - }
- + _log.info("CharTemplates: Loaded " + _ssMap.size() + " character templates.");
- + _ssMap.clear();
- +
- +
- + Connection con = null;
- try
- {
- @@ -178,6 +185,428 @@
- }
- }
- + private void loadCharTemplates()
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- + factory.setIgnoringElementContentWhitespace(true);
- + File file = new File(Config.DATAPACK_ROOT, "data/CharTemplates.xml");
- + Document doc = null;
- +
- + if (file.exists())
- + {
- + try
- + {
- + doc = factory.newDocumentBuilder().parse(file);
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not parse CharTemplates.xml file: " + e.getMessage(), e);
- + }
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + StringBuilder spawnXarr = new StringBuilder();
- + StringBuilder spawnYarr = new StringBuilder();
- + StringBuilder spawnZarr = new StringBuilder();
- +
- + if ("list".equalsIgnoreCase(n.getNodeName()))
- + {
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + if ("class".equalsIgnoreCase(d.getNodeName()))
- + {
- + StatsSet set = new StatsSet();
- + String className;
- + int classId;
- + NamedNodeMap attrs = d.getAttributes();
- + Node att;
- +
- + att = attrs.getNamedItem("name");
- + if (att == null)
- + {
- + _log.severe("[CharTemplates.xml] Missing name, skipping");
- + continue;
- + }
- + className = att.getNodeValue();
- + set.set("className", className);
- +
- + att = attrs.getNamedItem("id");
- + if (att == null)
- + {
- + _log.severe("[CharTemplates.xml] Missing id for name:"+className+", skipping");
- + continue;
- + }
- + classId = Integer.parseInt(att.getNodeValue());
- + set.set("classId", classId);
- +
- + /*att = attrs.getNamedItem("parentId");
- + if (att == null)
- + {
- + _log.severe("[CharTemplates.xml] Missing parentId for name:"+className+", skipping");
- + continue;
- + }
- + parentClassId = Integer.parseInt(att.getNodeValue());*/
- +
- + att = attrs.getNamedItem("classBaseLevel");
- + if (att == null)
- + {
- + _log.severe("[CharTemplates.xml] Missing classLvl for name:"+className+", skipping");
- + continue;
- + }
- + set.set("classBaseLevel", Integer.parseInt(att.getNodeValue()));
- +
- + att = attrs.getNamedItem("raceId");
- + if (att == null)
- + {
- + _log.severe("[CharTemplates.xml] Missing raceId for name:"+className+", skipping");
- + continue;
- + }
- + set.set("raceId", Integer.parseInt(att.getNodeValue()));
- +
- + for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
- + {
- + if ("set".equalsIgnoreCase(cd.getNodeName()))
- + {
- + String stat = null;
- + double value = 0;
- + try
- + {
- + stat = cd.getAttributes().getNamedItem("name").getNodeValue();
- + value = Double.parseDouble(cd.getAttributes().getNamedItem("val").getNodeValue());
- + }
- + catch(NullPointerException npe)
- + {
- + npe.printStackTrace();
- + }
- + catch(NumberFormatException nfe)
- + {
- + _log.severe("[CharTemplates.xml] at "+stat+","+cd.getAttributes().getNamedItem("val").getNodeValue()+" is not a number! "+nfe.getMessage());
- + }
- + finally
- + {
- +
- + if (stat.equals("baseSTR")
- + || stat.equals("baseDEX")
- + || stat.equals("baseCON")
- + || stat.equals("baseINT")
- + || stat.equals("baseWIT")
- + || stat.equals("baseMEN")
- + || stat.equals("baseHpMax")
- + || stat.equals("lvlHpAdd")
- + || stat.equals("lvlHpMod")
- + || stat.equals("baseMpMax")
- + || stat.equals("baseCpMax")
- + || stat.equals("lvlCpAdd")
- + || stat.equals("lvlCpMod")
- + || stat.equals("lvlMpAdd")
- + || stat.equals("lvlMpMod")
- + || stat.equals("baseHpReg")
- + || stat.equals("baseMpReg")
- + || stat.equals("baseMAtkSpd")
- + || stat.equals("baseRunSpd")
- + || stat.equals("baseWalkSpd")
- + || stat.equals("baseShldDef")
- + || stat.equals("baseShldRate"))
- + set.set(stat, value);
- + }
- + }
- + else if ("spawn".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + try
- + {
- + spawnXarr.append(attrs.getNamedItem("X").getNodeValue()+";");
- + spawnYarr.append(attrs.getNamedItem("Y").getNodeValue()+";");
- + spawnZarr.append(attrs.getNamedItem("Z").getNodeValue()+";");
- + }
- + catch (NumberFormatException nfe)
- + {
- + _log.severe("[CharTemplates.xml] invalid spawn location: "+nfe.getMessage());
- + }
- + }
- + }
- + set.set("spawnsX", spawnXarr.toString());
- + set.set("spawnsY", spawnYarr.toString());
- + set.set("spawnsZ", spawnZarr.toString());
- +
- + // The CharTemplate is ready, put the StatsSet in the map, we will need it to add more values to this set
- + _ssMap.put(classId, set);
- + }
- + }
- + }
- + }
- + }
- + }
- +
- + private void loadPcBaseStats()
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- + factory.setIgnoringElementContentWhitespace(true);
- + File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcBaseStats.xml");
- + Document doc = null;
- +
- + if (file.exists())
- + {
- + try
- + {
- + doc = factory.newDocumentBuilder().parse(file);
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not parse pcBaseStats.xml file: " + e.getMessage(), e);
- + }
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + if ("pcBaseStats".equalsIgnoreCase(n.getNodeName()))
- + {
- + String[] nodeNames = {
- + "basePAtk",
- + "baseRcrit",
- + "baseAtkType",
- + "baseAtkSpd",
- + "basePDef",
- + "baseMAtk",
- + "baseMDef",
- + "baseCanPenetrate",
- + "baseAtkRange",
- + "baseDamRange",
- + "baseRndDam"
- + };
- +
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + for (String nn : nodeNames)
- + {
- + if (nn.equalsIgnoreCase(d.getNodeName()))
- + {
- + Object[] properties = getProperties(file.getName(), d);
- + if (properties == null)
- + break;
- +
- + _ssMap.get(properties[0]).set((Boolean) properties[1] ? nn+"_female" : nn, (String)properties[2]);
- + }
- + }
- + }
- + }
- + }
- + }
- + else
- + _log.severe("CharTemplates: data/stats/chars/pcBaseStats.xml not found!");
- + }
- + private void loadPcBreathBonus()
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- + factory.setIgnoringElementContentWhitespace(true);
- + File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcBreathBonus.xml");
- + Document doc = null;
- +
- + if (file.exists())
- + {
- + try
- + {
- + doc = factory.newDocumentBuilder().parse(file);
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not parse pcBreathBonus.xml file: " + e.getMessage(), e);
- + }
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + if ("pcBreathBonus".equalsIgnoreCase(n.getNodeName()))
- + {
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + if ("breathBonus".equalsIgnoreCase(d.getNodeName()))
- + {
- + Object[] properties = getProperties(file.getName(), d);
- + if (properties == null)
- + break;
- +
- + _ssMap.get(properties[0]).set((Boolean) properties[1] ? "pcBreathBonus_female" : "pcBreathBonus", (String) properties[2]);
- + }
- + }
- + }
- + }
- + }
- + else
- + _log.severe("CharTemplates: data/stats/chars/pcBreathBonus.xml not found!");
- + }
- +
- + private void loadPcCollision()
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- + factory.setIgnoringElementContentWhitespace(true);
- + File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcCollision.xml");
- + Document doc = null;
- +
- + if (file.exists())
- + {
- + try
- + {
- + doc = factory.newDocumentBuilder().parse(file);
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not parse pcCollision.xml file: " + e.getMessage(), e);
- + }
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + if ("pcCollision".equalsIgnoreCase(n.getNodeName()))
- + {
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + if ("collision".equalsIgnoreCase(d.getNodeName()))
- + {
- + NamedNodeMap attrs = d.getAttributes();
- + Node att;
- + int classId = 0;
- + boolean isFemale = false;
- + double radius = 0;
- + double height = 0;
- +
- + att = attrs.getNamedItem("classId");
- + if (att == null)
- + {
- + _log.severe("["+file.getName()+"] Missing classId, skipping");
- + continue;
- + }
- + classId = Integer.parseInt(att.getNodeValue());
- +
- + att = attrs.getNamedItem("sex");
- + if (att == null)
- + {
- + _log.severe("["+file.getName()+"] Missing sex, skipping");
- + continue;
- + }
- + if ("female".equals(att.getNodeValue()))
- + isFemale = true;
- +
- + att = attrs.getNamedItem("radius");
- + if (att == null)
- + {
- + _log.severe("["+file.getName()+"] Missing radius, skipping");
- + continue;
- + }
- + radius = Double.parseDouble(att.getNodeValue());
- +
- + att = attrs.getNamedItem("height");
- + if (att == null)
- + {
- + _log.severe("["+file.getName()+"] Missing height, skipping");
- + continue;
- + }
- + height = Double.parseDouble(att.getNodeValue());
- +
- +
- + _ssMap.get(classId).set(isFemale ? "collision_radius_female" : "collision_radius", radius);
- + _ssMap.get(classId).set(isFemale ? "collision_height_female" : "collision_height", height);
- + }
- + }
- + }
- + }
- + }
- + else
- + _log.severe("CharTemplates: data/stats/chars/pcCollision.xml not found!");
- + }
- +
- + private void loadPcSafeFallHeight()
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- + factory.setIgnoringElementContentWhitespace(true);
- + File file = new File(Config.DATAPACK_ROOT, "data/stats/chars/pcSafeFallHeight.xml");
- + Document doc = null;
- +
- + if (file.exists())
- + {
- + try
- + {
- + doc = factory.newDocumentBuilder().parse(file);
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not parse pcSafeFallHeight.xml file: " + e.getMessage(), e);
- + }
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + if ("pcSafeFallHeight".equalsIgnoreCase(n.getNodeName()))
- + {
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + if ("safeFallHeight".equalsIgnoreCase(d.getNodeName()))
- + {
- + Object[] properties = getProperties(file.getName(), d);
- + if (properties == null)
- + break;
- +
- + _ssMap.get(properties[0]).set((Boolean) properties[1] ? "safeFallHeight_female" : "safeFallHeight", (String) properties[2]);
- + }
- + }
- + }
- + }
- + }
- + else
- + _log.severe("CharTemplates: data/stats/chars/pcSafeFallHeight.xml not found!");
- + }
- +
- + /**
- + *
- + * @param docName - the file's name (used for logging)
- + * @param d - the node we use to get the values
- + * @return Object[0] = classId(int)<BR>
- + * Object[1] = isFemale(boolean)<BR>
- + * Object[2] = value(String)<BR>
- + */
- + private Object[] getProperties(String docName, Node d)
- + {
- + Object[] toReturn = new Object[3];
- +
- + NamedNodeMap attrs = d.getAttributes();
- + Node att;
- +
- + att = attrs.getNamedItem("classId");
- + if (att == null)
- + {
- + _log.severe("["+docName+"] Missing classId, skipping");
- + return null;
- + }
- + toReturn[0] = Integer.parseInt(att.getNodeValue());
- +
- + att = attrs.getNamedItem("sex");
- + if (att == null)
- + {
- + _log.severe("["+docName+"] Missing sex, skipping");
- + return null;
- + }
- + if ("female".equals(att.getNodeValue()))
- + toReturn[1] = true;
- + else
- + toReturn[1] = false;
- +
- + att = attrs.getNamedItem("val");
- + if (att == null)
- + {
- + _log.severe("["+docName+"] Missing val, skipping");
- + return null;
- + }
- + toReturn[2] = att.getNodeValue();
- +
- + return toReturn;
- + }
- +
- public L2PcTemplate getTemplate(ClassId classId)
- {
- return this.getTemplate(classId.getId());
- Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 4587)
- +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -523,11 +523,11 @@
- private int _transformationId = 0;
- /** The table containing all L2RecipeList of the L2PcInstance */
- - private Map<Integer, L2RecipeList> _dwarvenRecipeBook = new FastMap<Integer, L2RecipeList>();
- - private Map<Integer, L2RecipeList> _commonRecipeBook = new FastMap<Integer, L2RecipeList>();
- + private final Map<Integer, L2RecipeList> _dwarvenRecipeBook = new FastMap<Integer, L2RecipeList>();
- + private final Map<Integer, L2RecipeList> _commonRecipeBook = new FastMap<Integer, L2RecipeList>();
- /** Premium Items */
- - private Map<Integer, L2PremiumItem> _premiumItems = new FastMap<Integer, L2PremiumItem>();
- + private final Map<Integer, L2PremiumItem> _premiumItems = new FastMap<Integer, L2PremiumItem>();
- /** True if the L2PcInstance is sitting */
- private boolean _waitTypeSitting;
- @@ -539,7 +539,7 @@
- private boolean _observerMode = false;
- /** Stored from last ValidatePosition **/
- - private Point3D _lastServerPosition = new Point3D(0, 0, 0);
- + private final Point3D _lastServerPosition = new Point3D(0, 0, 0);
- /** The number of recommendation obtained by the L2PcInstance */
- private int _recomHave; // how much I was recommended by others
- @@ -552,7 +552,7 @@
- /** Recommendation Two Hours bonus **/
- private boolean _recoTwoHoursGiven = false;
- - private PcInventory _inventory = new PcInventory(this);
- + private final PcInventory _inventory = new PcInventory(this);
- private PcWarehouse _warehouse;
- private PcRefund _refund;
- @@ -581,16 +581,16 @@
- private int _questNpcObject = 0;
- /** The table containing all Quests began by the L2PcInstance */
- - private Map<String, QuestState> _quests = new FastMap<String, QuestState>();
- + private final Map<String, QuestState> _quests = new FastMap<String, QuestState>();
- /** The list containing all shortCuts of this L2PcInstance */
- - private ShortCuts _shortCuts = new ShortCuts(this);
- + private final ShortCuts _shortCuts = new ShortCuts(this);
- /** The list containing all macroses of this L2PcInstance */
- - private MacroList _macroses = new MacroList(this);
- + private final MacroList _macroses = new MacroList(this);
- - private List<L2PcInstance> _snoopListener = new FastList<L2PcInstance>();
- - private List<L2PcInstance> _snoopedPlayer = new FastList<L2PcInstance>();
- + private final List<L2PcInstance> _snoopListener = new FastList<L2PcInstance>();
- + private final List<L2PcInstance> _snoopedPlayer = new FastList<L2PcInstance>();
- private ClassId _skillLearningClassId;
- @@ -656,7 +656,7 @@
- private int _deathPenaltyBuffLevel = 0;
- // charges
- - private AtomicInteger _charges = new AtomicInteger();
- + private final AtomicInteger _charges = new AtomicInteger();
- private ScheduledFuture<?> _chargeTask = null;
- // Absorbed Souls
- @@ -681,7 +681,7 @@
- // there can only be one active party request at once
- private L2PcInstance _activeRequester;
- private long _requestExpireTime = 0;
- - private L2Request _request = new L2Request(this);
- + private final L2Request _request = new L2Request(this);
- private L2ItemInstance _arrowItem;
- private L2ItemInstance _boltItem;
- @@ -737,10 +737,10 @@
- private byte _handysBlockCheckerEventArena = -1;
- /** new loto ticket **/
- - private int _loto[] = new int[5];
- + private final int _loto[] = new int[5];
- //public static int _loto_nums[] = {0,1,2,3,4,5,6,7,8,9,};
- /** new race ticket **/
- - private int _race[] = new int[2];
- + private final int _race[] = new int[2];
- private final BlockList _blockList = new BlockList(this);
- @@ -762,8 +762,8 @@
- private ScheduledFuture<?> _taskWater;
- /** Bypass validations */
- - private List<String> _validBypass = new FastList<String>();
- - private List<String> _validBypass2 = new FastList<String>();
- + private final List<String> _validBypass = new FastList<String>();
- + private final List<String> _validBypass2 = new FastList<String>();
- private Forum _forumMail;
- private Forum _forumMemo;
- @@ -896,11 +896,11 @@
- private class HerbTask implements Runnable
- {
- - private String _process;
- - private int _itemId;
- - private long _count;
- - private L2Object _reference;
- - private boolean _sendMessage;
- + private final String _process;
- + private final int _itemId;
- + private final long _count;
- + private final L2Object _reference;
- + private final boolean _sendMessage;
- HerbTask(String process, int itemId, long count, L2Object reference, boolean sendMessage)
- {
- @@ -951,9 +951,9 @@
- /** Skill casting information (used to queue when several skills are cast in a short time) **/
- public static class SkillDat
- {
- - private L2Skill _skill;
- - private boolean _ctrlPressed;
- - private boolean _shiftPressed;
- + private final L2Skill _skill;
- + private final boolean _ctrlPressed;
- + private final boolean _shiftPressed;
- protected SkillDat(L2Skill skill, boolean ctrlPressed, boolean shiftPressed)
- {
- @@ -984,7 +984,7 @@
- }
- //summon friend
- - private SummonRequest _summonRequest = new SummonRequest();
- + private final SummonRequest _summonRequest = new SummonRequest();
- private static class SummonRequest
- {
- @@ -1009,7 +1009,7 @@
- }
- // open/close gates
- - private GatesRequest _gatesRequest = new GatesRequest();
- + private final GatesRequest _gatesRequest = new GatesRequest();
- private static class GatesRequest
- {
- @@ -12997,7 +12997,7 @@
- addSkill(SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel()), false);
- }
- - private FastMap<Integer, TimeStamp> _reuseTimeStamps = new FastMap<Integer, TimeStamp>().shared();
- + private final FastMap<Integer, TimeStamp> _reuseTimeStamps = new FastMap<Integer, TimeStamp>().shared();
- private boolean _canFeed;
- private int _eventEffectId = 0;
- private boolean _isInSiege;
- @@ -14330,7 +14330,7 @@
- * list of character friends
- *
- */
- - private List<Integer> _friendList = new FastList<Integer>();
- + private final List<Integer> _friendList = new FastList<Integer>();
- public List<Integer> getFriendList()
- {
- @@ -14543,7 +14543,7 @@
- return true;
- final int deltaZ = getZ() - z;
- - if (deltaZ <= getBaseTemplate().getFallHeight())
- + if (deltaZ <= getBaseTemplate().safeFallHeight)
- return false;
- final int damage = (int)Formulas.calcFallDam(this, deltaZ);
- Index: java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java
- ===================================================================
- --- java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java (revision 4587)
- +++ java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java (working copy)
- @@ -44,6 +44,7 @@
- import com.l2jserver.gameserver.templates.chars.L2PcTemplate;
- import com.l2jserver.gameserver.templates.chars.L2PcTemplate.PcTemplateItem;
- import com.l2jserver.gameserver.util.Util;
- +import com.l2jserver.util.Rnd;
- @SuppressWarnings("unused")
- @@ -233,7 +234,8 @@
- newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
- - newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
- + int rnd = Rnd.get(template.spawnsX.length);
- + newChar.setXYZInvisible(template.spawnsX[rnd], template.spawnsY[rnd], template.spawnsZ[rnd]);
- newChar.setTitle("");
- if (Config.ENABLE_VITALITY)
- Index: java/com/l2jserver/gameserver/templates/StatsSet.java
- ===================================================================
- --- java/com/l2jserver/gameserver/templates/StatsSet.java (revision 4587)
- +++ java/com/l2jserver/gameserver/templates/StatsSet.java (working copy)
- @@ -349,7 +349,7 @@
- * @param deflt : float designating the default value if value associated with the key is null
- * @return double : value associated to the key
- */
- - public double getDouble(String name, float deflt)
- + public double getDouble(String name, double deflt)
- {
- Object val = _set.get(name);
- if (val == null)
- Index: java/com/l2jserver/gameserver/templates/chars/L2CharTemplate.java
- ===================================================================
- --- java/com/l2jserver/gameserver/templates/chars/L2CharTemplate.java (revision 4587)
- +++ java/com/l2jserver/gameserver/templates/chars/L2CharTemplate.java (working copy)
- @@ -40,23 +40,23 @@
- /** MP Regen base */
- public final float baseMpReg;
- - public final int basePAtk;
- - public final int baseMAtk;
- - public final int basePDef;
- - public final int baseMDef;
- - public final int basePAtkSpd;
- + public int basePAtk;
- + public int baseMAtk;
- + public int basePDef;
- + public int baseMDef;
- + public int basePAtkSpd;
- public final int baseMAtkSpd;
- public final float baseMReuseRate;
- public final int baseShldDef;
- - public final int baseAtkRange;
- + public int baseAtkRange;
- public final int baseShldRate;
- - public final int baseCritRate;
- + public int baseCritRate;
- public final int baseMCritRate;
- public final int baseWalkSpd;
- public final int baseRunSpd;
- // SpecialStats
- - public final int baseBreath;
- + public int baseBreath;
- public final int baseAggression;
- public final int baseBleed;
- public final int basePoison;
- @@ -96,17 +96,17 @@
- * For client info use {@link fCollisionRadius}
- * </B></FONT><BR><BR>
- */
- - public final int collisionRadius;
- + public int collisionRadius;
- /**
- * <FONT COLOR=#FF0000><B> <U>Caution</U> :
- * For client info use {@link fCollisionHeight}
- * </B></FONT><BR><BR>
- */
- - public final int collisionHeight;
- + public int collisionHeight;
- - public final double fCollisionRadius;
- - public final double fCollisionHeight;
- + public double fCollisionRadius;
- + public double fCollisionHeight;
- public L2CharTemplate(StatsSet set)
- {
- @@ -122,23 +122,58 @@
- baseMpMax = set.getFloat("baseMpMax");
- baseHpReg = set.getFloat("baseHpReg");
- baseMpReg = set.getFloat("baseMpReg");
- - basePAtk = set.getInteger("basePAtk");
- - baseMAtk = set.getInteger("baseMAtk");
- - basePDef = set.getInteger("basePDef");
- - baseMDef = set.getInteger("baseMDef");
- - basePAtkSpd = set.getInteger("basePAtkSpd");
- + basePAtk = set.getInteger("basePAtk", -1);
- + baseMAtk = set.getInteger("baseMAtk", -1);
- + try
- + {
- + basePDef = set.getInteger("basePDef", -1);
- + }
- + catch(IllegalArgumentException iae)
- + {
- + try
- + {
- + basePDef = calcIntArray(set.getIntegerArray("basePDef"));
- + }
- + catch(IllegalArgumentException iae2)
- + {
- + basePDef = -1;
- + }
- + }
- + try
- + {
- + baseMDef = set.getInteger("baseMDef", -1);
- + }
- + catch(IllegalArgumentException iae)
- + {
- + try
- + {
- + baseMDef = calcIntArray(set.getIntegerArray("baseMDef"));
- + }
- + catch(IllegalArgumentException iae2)
- + {
- + baseMDef = -1;
- + }
- + }
- + basePAtkSpd = set.getInteger("basePAtkSpd", -1);
- baseMAtkSpd = set.getInteger("baseMAtkSpd");
- baseMReuseRate = set.getFloat("baseMReuseDelay", 1.f);
- baseShldDef = set.getInteger("baseShldDef");
- - baseAtkRange = set.getInteger("baseAtkRange");
- + baseAtkRange = set.getInteger("baseAtkRange", -1);
- baseShldRate = set.getInteger("baseShldRate");
- - baseCritRate = set.getInteger("baseCritRate");
- + baseCritRate = set.getInteger("baseCritRate", -1);
- baseMCritRate = set.getInteger("baseMCritRate", 80); // CT2: The magic critical rate has been increased to 10 times.
- baseWalkSpd = set.getInteger("baseWalkSpd");
- baseRunSpd = set.getInteger("baseRunSpd");
- // SpecialStats
- - baseBreath = set.getInteger("baseBreath", 100);
- + try
- + {
- + baseBreath = set.getInteger("baseBreath", 100);
- + }
- + catch(IllegalArgumentException iae)
- + {
- + baseBreath = set.getInteger("pcBreathBonus", 100);
- + }
- baseAggression = set.getInteger("baseAggression", 0);
- baseBleed = set.getInteger("baseBleed", 0);
- basePoison = set.getInteger("basePoison", 0);
- @@ -174,9 +209,17 @@
- baseHpConsumeRate = set.getInteger("baseHpConsumeRate", 0);
- // Geometry
- - fCollisionHeight = set.getDouble("collision_height");
- - fCollisionRadius = set.getDouble("collision_radius");
- + fCollisionHeight = set.getDouble("collision_height", -1);
- + fCollisionRadius = set.getDouble("collision_radius", -1);
- collisionRadius = (int) fCollisionRadius;
- collisionHeight = (int) fCollisionHeight;
- }
- +
- + protected int calcIntArray(int[] val)
- + {
- + int toReturn = 0;
- + for (int i = 0; i < val.length; i++)
- + toReturn += val[i];
- + return toReturn;
- + }
- }
- Index: java/com/l2jserver/gameserver/templates/chars/L2PcTemplate.java
- ===================================================================
- --- java/com/l2jserver/gameserver/templates/chars/L2PcTemplate.java (revision 4587)
- +++ java/com/l2jserver/gameserver/templates/chars/L2PcTemplate.java (working copy)
- @@ -18,6 +18,7 @@
- import javolution.util.FastList;
- +import com.l2jserver.gameserver.datatables.CharTemplateTable;
- import com.l2jserver.gameserver.model.base.ClassId;
- import com.l2jserver.gameserver.model.base.Race;
- import com.l2jserver.gameserver.templates.StatsSet;
- @@ -33,9 +34,9 @@
- public final Race race;
- public final String className;
- - public final int spawnX;
- - public final int spawnY;
- - public final int spawnZ;
- + public final int[] spawnsX;
- + public final int[] spawnsY;
- + public final int[] spawnsZ;
- public final int classBaseLevel;
- public final float lvlHpAdd;
- @@ -45,10 +46,25 @@
- public final float lvlMpAdd;
- public final float lvlMpMod;
- - public final double fCollisionHeight_female;
- - public final double fCollisionRadius_female;
- + public int basePAtk_female;
- + public int baseMAtk_female;
- + public int basePDef_female;
- + public int baseMDef_female;
- + public int basePAtkSpd_female;
- + public int baseAtkRange_female;
- + public int baseCritRate_female;
- +
- + public int baseBreath_female;
- - private List<PcTemplateItem> _items = new FastList<PcTemplateItem>();
- + public double fCollisionHeight_female;
- + public double fCollisionRadius_female;
- + public double collisionHeight_female;
- + public double collisionRadius_female;
- +
- + public int safeFallHeight;
- + public int safeFallHeight_female;
- +
- + private final List<PcTemplateItem> _items = new FastList<PcTemplateItem>();
- public L2PcTemplate(StatsSet set)
- {
- @@ -57,9 +73,9 @@
- race = Race.values()[set.getInteger("raceId")];
- className = set.getString("className");
- - spawnX = set.getInteger("spawnX");
- - spawnY = set.getInteger("spawnY");
- - spawnZ = set.getInteger("spawnZ");
- + spawnsX = set.getIntegerArray("spawnsX");
- + spawnsY = set.getIntegerArray("spawnsY");
- + spawnsZ = set.getIntegerArray("spawnsZ");
- classBaseLevel = set.getInteger("classBaseLevel");
- lvlHpAdd = set.getFloat("lvlHpAdd");
- @@ -69,8 +85,67 @@
- lvlMpAdd = set.getFloat("lvlMpAdd");
- lvlMpMod = set.getFloat("lvlMpMod");
- - fCollisionRadius_female = set.getDouble("collision_radius_female");
- - fCollisionHeight_female = set.getDouble("collision_height_female");
- + if (basePAtk == -1)
- + basePAtk = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtk;
- + if (baseMAtk == -1)
- + baseMAtk = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseMAtk;
- + if (basePDef == -1)
- + basePDef = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePDef;
- + if (baseMDef == -1)
- + baseMDef = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePDef;
- + if (basePAtkSpd == -1)
- + basePAtkSpd = set.getInteger("baseAtkSpd", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtkSpd);
- + if (baseAtkRange == -1)
- + baseAtkRange = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseAtkRange;
- + if (baseCritRate == -1)
- + baseCritRate = set.getInteger("baseRcrit", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseCritRate);
- + if (fCollisionRadius == -1)
- + fCollisionRadius = set.getDouble("collision_radius", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionRadius);
- + if (fCollisionHeight == -1)
- + fCollisionHeight = set.getDouble("collision_height", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionHeight);
- +
- + basePAtk_female = set.getInteger("basePAtk_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtk_female);
- + baseMAtk_female = set.getInteger("baseMAtk_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseMAtk_female);
- + // Since we dont have support for base p.def per seperate armor piece, we get the total
- + try
- + {
- + basePDef_female = calcIntArray(set.getIntegerArray("basePDef_female"));
- + }
- + catch(IllegalArgumentException iae)
- + {
- + basePDef_female = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePDef_female;
- + }
- + try
- + {
- + baseMDef_female = calcIntArray(set.getIntegerArray("baseMDef_female"));
- + }
- + catch(IllegalArgumentException iae)
- + {
- + baseMDef_female = classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseMDef_female;
- + }
- + basePAtkSpd_female = set.getInteger("baseAtkSpd_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).basePAtkSpd_female);
- + baseAtkRange_female = set.getInteger("baseAtkRange_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseAtkRange_female);
- + baseCritRate_female = set.getInteger("baseRcrit_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseCritRate_female);
- +
- + baseBreath = set.getInteger("pcBreathBonus", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseBreath);
- + baseBreath_female = set.getInteger("pcBreathBonus_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).baseBreath_female);
- +
- + safeFallHeight = set.getInteger("safeFallHeight", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).safeFallHeight);
- + safeFallHeight_female = set.getInteger("safeFallHeight_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).safeFallHeight_female);
- +
- + fCollisionRadius_female = set.getDouble("collision_radius_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionRadius_female);
- + fCollisionHeight_female = set.getDouble("collision_height_female", classId.getParent() == null ? -1 : CharTemplateTable.getInstance().getTemplate(classId.getParent()).fCollisionHeight_female);
- +
- + collisionRadius = (int) fCollisionRadius;
- + collisionHeight = (int) fCollisionHeight;
- + collisionRadius_female = (int) fCollisionRadius_female;
- + collisionHeight_female = (int) fCollisionHeight_female;
- + /* TODO: Unimplemented values:
- + * baseAtkType
- + * baseCanPenetrate
- + * baseDamRange
- + * baseRndDam
- + */
- }
- /**
- @@ -132,9 +207,4 @@
- return _equipped;
- }
- }
- -
- - public final int getFallHeight()
- - {
- - return 333; // TODO: unhardcode it
- - }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement