Autor Tema: Error - Enchant Skills  (Leído 169 veces)

Mordor

  • Jr. Member
  • **
  • Mensajes: 83
  • Karma: +0/-0
    • Ver Perfil
Error - Enchant Skills
« en: Mayo 28, 2018, 03:11:15 pm »
Cuando el char comienza a enchantear skilles y fallan, no bajan a 0 y quedan al mismo level, y al volver a intentar subirlos no te pide el libro (Book of Giant). Adjunto una imagen del problema.
https://ibb.co/iZR0Ay

fissban

  • Administrador
  • Full Member
  • *
  • Mensajes: 183
  • Karma: +0/-0
    • Ver Perfil
Re:Error - Enchant Skills
« Respuesta #1 en: Mayo 29, 2018, 02:46:41 am »
buen reporte, lo primero que veo que cuando me pidieron que el sistema de subclass acu no bajara de nivellos skills afecto el sistema de enchants cosa que no considere por lo que al fallar el skil jamas lo bajaba a su base aqui te dejo un "parche" probalo y me cuentas

Código
Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 1091)
+++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
@@ -3830,14 +3830,35 @@
  */
  public Skill addSkill(Skill newSkill)
  {
+ return addSkill(newSkill, false);
+ }
+
+ /**
+ * Add a skill to the L2Character skills and its Func objects to the calculator set of the L2Character.<br>
+ * <b><u> Concept</u> :</b><br>
+ * All skills own by a L2Character are identified in <b>_skills</b><br>
+ * <b><u> Actions</u> :</b><br>
+ * <li>Replace oldSkill by newSkill or Add the newSkill
+ * <li>If an old skill has been replaced, remove all its Func objects of L2Character calculator set
+ * <li>Add Func objects of newSkill to the calculator set of the L2Character <b><u> Overridden in </u> :</b><br>
+ * <li>L2PcInstance : Save update in the character_skills table of the database
+ * @param newSkill The Skill to add to the L2Character
+ * @param ignoreLvl "false" dont delevel skill
+ * @return The Skill replaced or null if just added a new Skill
+ */
+ public Skill addSkill(Skill newSkill, boolean ignoreLvl)
+ {
  Skill oldSkill = null;
 
  if (newSkill != null)
  {
- Skill s = skills.get(newSkill.getId());
- if (s != null && s.getLevel() > newSkill.getLevel())
+ if (ignoreLvl)
  {
- return s;
+ Skill s = skills.get(newSkill.getId());
+ if (s != null && s.getLevel() > newSkill.getLevel())
+ {
+ return s;
+ }
  }
 
  // Replace oldSkill by newSkill or Add the newSkill
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 1091)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -240,7 +240,7 @@
  private static final String DELETE_SKILL_FROM_CHAR = "DELETE FROM character_skills WHERE skill_id=? AND char_obj_id=? AND class_index=?";
  private static final String DELETE_CHAR_SKILLS = "DELETE FROM character_skills WHERE char_obj_id=? AND class_index=?";
 
- private static final String ADD_SKILL_SAVE = "INSERT INTO character_skills_save (char_obj_id,skill_id,skill_level,effect_count,effect_cur_time,reuse_delay,systime,restore_type,class_index,buff_index) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ private static final String ADD_SKILL_SAVE = "INSERT INTO character_skills_save (char_obj_id,class_index,skill_id,skill_level,effect_count,effect_cur_time,reuse_delay,systime,restore_type,buff_index) VALUES (?,?,?,?,?,?,?,?,?,?)";
  private static final String RESTORE_SKILL_SAVE = "SELECT skill_id,skill_level,effect_count,effect_cur_time,reuse_delay,systime,restore_type FROM character_skills_save WHERE char_obj_id=? AND class_index=? ORDER BY buff_index ASC";
  private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
 
@@ -3801,23 +3801,30 @@
 
  storedSkills.add(skill.getReuseHashCode());
 
- add.setInt(1, getObjectId());
- add.setInt(2, skill.getId());
- add.setInt(3, skill.getLevel());
- add.setInt(4, effect.getCount());
- add.setInt(5, effect.getTime());
+ var i = 0;
+ add.setInt(++i, getObjectId());
+ add.setInt(++i, getClassIndex());
+ add.setInt(++i, skill.getId());
+ add.setInt(++i, skill.getLevel());
+ add.setInt(++i, effect.getCount());
+ add.setInt(++i, effect.getTime());
 
- TimeStampHolder t = reuseTimeStamps.get(skill.getReuseHashCode());
- add.setLong(6, (t != null) && t.hasNotPassed() ? t.getReuse() : 0);
- add.setDouble(7, (t != null) && t.hasNotPassed() ? t.getStamp() : 0);
+ var t = reuseTimeStamps.get(skill.getReuseHashCode());
+ add.setLong(++i, (t != null) && t.hasNotPassed() ? t.getReuse() : 0);
+ add.setDouble(++i, (t != null) && t.hasNotPassed() ? t.getStamp() : 0);
 
- add.setInt(8, 0);
- add.setInt(9, getClassIndex());
- add.setInt(10, ++buffIndex);
+ add.setInt(++i, 0);
+ add.setInt(++i, ++buffIndex);
  add.addBatch(); // Add SQL;
  count++;
  }
 
+ if (count > 0)
+ {
+ add.executeBatch(); // Execute SQLs
+ }
+
+ count = 0;
  // Store the reuse delays of remaining skills which
  // lost effect but still under reuse delay. 'restore_type' 1.
  for (Entry<Integer, TimeStampHolder> entry : reuseTimeStamps.entrySet())
@@ -3834,16 +3841,18 @@
  {
  storedSkills.add(reuseHashCode);
 
- add.setInt(1, getObjectId());
- add.setInt(2, t.getSkill().getId());
- add.setInt(3, t.getSkill().getLevel());
- add.setInt(4, -1);
- add.setInt(5, -1);
- add.setLong(6, t.hasNotPassed() ? t.getReuse() : 0);
- add.setDouble(7, t.hasNotPassed() ? t.getStamp() : 0);
- add.setInt(8, 1);
- add.setInt(9, getClassIndex());
- add.setInt(10, ++buffIndex);
+ var i = 0;
+ add.setInt(++i, getObjectId());
+ add.setInt(++i, getClassIndex());
+ add.setInt(++i, t.getSkill().getId());
+ add.setInt(++i, t.getSkill().getLevel());
+ add.setInt(++i, -1);
+ add.setInt(++i, -1);
+ add.setLong(++i, t.hasNotPassed() ? t.getReuse() : 0);
+ add.setDouble(++i, t.hasNotPassed() ? t.getStamp() : 0);
+ add.setInt(++i, 1);
+ add.setInt(++i, getClassIndex());
+ add.setInt(++i, ++buffIndex);
  add.addBatch(); // Add SQL
  count++;
  }
@@ -3873,10 +3882,29 @@
  * @param store
  * @return The Skill replaced or null if just added a new Skill
  */
+ @Override
  public Skill addSkill(Skill newSkill, boolean store)
  {
+ return addSkill(newSkill, store, false);
+ }
+
+ /**
+ * Add a skill to the L2PcInstance skills and its Func objects to the calculator set of the L2PcInstance and save update in the character_skills table of the database.<BR>
+ * <B><U> Concept</U> :</B><BR>
+ * All skills own by a L2PcInstance are identified in <B>_skills</B><BR>
+ * <B><U> Actions</U> :</B><BR>
+ * <li>Replace oldSkill by newSkill or Add the newSkill
+ * <li>If an old skill has been replaced, remove all its Func objects of L2Character calculator set
+ * <li>Add Func objects of newSkill to the calculator set of the L2Character
+ * @param newSkill The Skill to add to the L2Character
+ * @param store
+ * @param ignoreLvl
+ * @return The Skill replaced or null if just added a new Skill
+ */
+ public Skill addSkill(Skill newSkill, boolean store, boolean ignoreLvl)
+ {
  // Add a skill to the L2PcInstance skills and its Func objects to the calculator set of the L2PcInstance
- final Skill oldSkill = super.addSkill(newSkill);
+ final Skill oldSkill = super.addSkill(newSkill, ignoreLvl);
 
  // Add or update a L2PcInstance skill in the character_skills table of the database
  if (store)
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestExEnchantSkill.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestExEnchantSkill.java (revision 1091)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestExEnchantSkill.java (working copy)
@@ -181,7 +181,7 @@
  if (skill.getLevel() > 100)
  {
  skillLvl = baseLvl;
- player.addSkill(SkillData.getInstance().getSkill(skillId, skillLvl), true);
+ player.addSkill(SkillData.getInstance().getSkill(skillId, baseLvl), true, true);
  player.sendSkillList();
  }
         

Mordor

  • Jr. Member
  • **
  • Mensajes: 83
  • Karma: +0/-0
    • Ver Perfil
Re:Error - Enchant Skills
« Respuesta #2 en: Mayo 29, 2018, 11:22:28 am »
Hice las modificaciones, me cree un nuevo char, hice las subs, fui a enchantear skilles pero sigue igual, no baja de level ni tampoco te pide otro libro para seguir enchanteando en caso de falla.
« Última modificación: Mayo 29, 2018, 11:24:47 am por Mordor »