Advertisement
MystoGan64

[Share] Custom subclass configuration. More than 3 subs.

Oct 15th, 2013
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1. net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.java
  2. ============================================================================================
  3. private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
  4. +/** The Constant RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS. */
  5. +private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";
  6.  
  7.  
  8. -try
  9. - {
  10. - // Retrieve all skills of this L2PcInstance from the database
  11. - con = L2DatabaseFactory.getInstance().getConnection();
  12. - PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR);
  13. - statement.setInt(1, getObjectId());
  14. - statement.setInt(2, getClassIndex());
  15. - ResultSet rset = statement.executeQuery();
  16. -
  17. - // Go though the recordset of this SQL query
  18. - while (rset.next())
  19. - {
  20. - int id = rset.getInt("skill_id");
  21. - int level = rset.getInt("skill_level");
  22. -
  23. - if (id > 9000)
  24. - continue; // fake skills for base stats
  25. -
  26. - // Create a L2Skill object for each record
  27. - L2Skill skill = SkillTable.getInstance().getInfo(id, level);
  28. -
  29. - // Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
  30. - super.addSkill(skill);
  31. - }
  32. -
  33. - rset.close();
  34. - statement.close();
  35. - }
  36.  
  37. +try
  38. + {
  39. + if (!Config.KEEP_SUBCLASS_SKILLS)
  40. + {
  41. + // Retrieve all skills of this L2PcInstance from the database
  42. + con = L2DatabaseFactory.getInstance().getConnection();
  43. + PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR);
  44. + statement.setInt(1, getObjectId());
  45. + statement.setInt(2, getClassIndex());
  46. + ResultSet rset = statement.executeQuery();
  47. +
  48. + // Go though the recordset of this SQL query
  49. + while (rset.next())
  50. + {
  51. + int id = rset.getInt("skill_id");
  52. + int level = rset.getInt("skill_level");
  53. +
  54. + if (id > 9000)
  55. + {
  56. + continue; // fake skills for base stats
  57. + }
  58. +
  59. + // Create a L2Skill object for each record
  60. + L2Skill skill = SkillTable.getInstance().getInfo(id, level);
  61. +
  62. + // Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
  63. + super.addSkill(skill);
  64. + }
  65. +
  66. + rset.close();
  67. + statement.close();
  68. + rset = null;
  69. + statement = null;
  70. + }
  71. + else
  72. + {
  73. + // Retrieve all skills of this L2PcInstance from the database
  74. + con = L2DatabaseFactory.getInstance().getConnection();
  75. + PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS);
  76. + statement.setInt(1, getObjectId());
  77. + ResultSet rset = statement.executeQuery();
  78. +
  79. + // Go though the recordset of this SQL query
  80. + while (rset.next())
  81. + {
  82. + int id = rset.getInt("skill_id");
  83. + int level = rset.getInt("skill_level");
  84. +
  85. + if (id > 9000)
  86. + {
  87. + continue; // fake skills for base stats
  88. + }
  89. +
  90. + // Create a L2Skill object for each record
  91. + L2Skill skill = SkillTable.getInstance().getInfo(id, level);
  92. +
  93. + // Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
  94. + super.addSkill(skill);
  95. + }
  96. +
  97. + rset.close();
  98. + statement.close();
  99. + rset = null;
  100. + statement = null;
  101. + }
  102. +
  103. + }
  104.  
  105.  
  106. -if (getTotalSubClasses() == 3 || classIndex == 0)
  107. +if ((getTotalSubClasses() == Config.MAX_SUBCLASS) || (classIndex == 0))
  108.  
  109. --------------------------------------------------------------------------------------------
  110. net.sf.l2j.gameserver.model.actor.instance.L2VillageMasterInstance.java
  111. ============================================================================================
  112. // Avoid giving player an option to add a new sub class, if they have three already.
  113. - if (player.getTotalSubClasses() == 3)
  114. + if (player.getTotalSubClasses() == Config.MAX_SUBCLASS)
  115.  
  116. --------------------------------------------------------------------------------------------
  117. net.sf.l2j.Config.java
  118. ============================================================================================
  119. public static int AUTO_REWARD_COUNT;
  120. + public static int MAX_SUBCLASS;
  121. + public static boolean KEEP_SUBCLASS_SKILLS;
  122.  
  123. AUTO_REWARD_COUNT = Integer.parseInt(customSettings.getProperty("AutoRewardCount", "1000"));
  124. +MAX_SUBCLASS = Integer.parseInt(customSettings.getProperty("MaxSubClasses", "3"));
  125. +KEEP_SUBCLASS_SKILLS = Boolean.parseBoolean(customSettings.getProperty("KeepSubClassSkills", "False"));
  126.  
  127. --------------------------------------------------------------------------------------------
  128. gameserver/config/custom.properties
  129. ============================================================================================
  130. # ------------------------------------------------------------
  131. # SubClass Configuration L2JLisvus-c4
  132. # ------------------------------------------------------------
  133. #Max allowed subclass for a player
  134. #Default : 3
  135. MaxSubClasses = 3
  136. #Enable/Disable custom subclass option
  137. #If True then player will keep all the skill from all subclass
  138. #Default: False
  139. KeepSubClassSkills = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement