Jump to content
  • 0

Question

Posted (edited)

hi! im using a sub stuck mod i found in the forum. Everything works ok but there is a bug..  if you cancel the subclass the first time and you dont go back to the main class, all skills from that class are removed (thats how supposed to work) but if you go back to main and you cancel the subclass, the skills from the subclass are not removed. So you can have skills from whatever subclass you want at the same time ( :S ) . ill paste te code here if anyone can give me some suggestion to fix this, i will be gratefull. Thanks !

edit: Im using Acis rev.399 

 

/*
 * L2J_EngineMods
 * Engine developed by Fissban.
 *
 * This software is not free and you do not have permission
 * to distribute without the permission of its owner.
 *
 * This software is distributed only under the rule
 * of www.devsadmins.com.
 * 
 * Contact us with any questions by the media
 * provided by our web or email marco.faccio@gmail.com
 */
package main.engine.mods;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;

import main.data.ConfigData;
import main.engine.AbstractMods;
import net.sf.l2j.commons.pool.ConnectionPool;
import net.sf.l2j.gameserver.data.SkillTable;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.skills.L2Skill;

/**
 * @author fissban
 */
public class SubClassAcumulatives extends AbstractMods
{
	// SQL
	private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level,class_index FROM character_skills WHERE char_obj_id=?";
	
	/**
	 * Constructor
	 */
	public SubClassAcumulatives()
	{
		registerMod(ConfigData.ENABLE_SubClassAcumulatives);
	}
	
	@Override
	public void onModState()
	{
		//
	}
	
	@Override
	public boolean onRestoreSkills(Player player)
	{
		Map<Integer, Integer> skills = new HashMap<>();
		
		try (Connection con = ConnectionPool.getConnection();
			PreparedStatement ps = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
		{
			// Retrieve all skills of this Player from the database
			ps.setInt(1, player.getObjectId());
			
			try (ResultSet rs = ps.executeQuery())
			{
				while (rs.next())
				{
					final int id = rs.getInt("skill_id");
					final int level = rs.getInt("skill_level");
					final int classIndex = rs.getInt("class_index");
					
					// fake skills for base stats
					if (id > 9000)
					{
						continue;
					}
					
					if (player.getClassIndex() != classIndex)
					{
						final L2Skill skill = SkillTable.getInstance().getInfo(id, level);
						
						if (skill == null)
						{
							LOG.log(Level.SEVERE, "Skipped null skill Id: " + id + ", Level: " + level + " while restoring player skills for " + player.getName());
							continue;
						}
						
						if (!ConfigData.ACUMULATIVE_PASIVE_SKILLS)
						{
							if (skill.isPassive())
							{
								continue;
							}
						}
						
						if (ConfigData.DONT_ACUMULATIVE_SKILLS_ID.contains(id))
						{
							continue;
						}
						
					}
					
					// We save all the skills that we will teach our character.
					// This will avoid teaching a skill from lvl 1 to 15 for example
					// And directly we teach the lvl 15 =)
					skills.put(id, level);
				}
			}
		}
		catch (Exception e)
		{
			LOG.log(Level.SEVERE, "Could not restore " + player.getName() + " skills:", e);
		}
		
		for (Entry<Integer, Integer> skillLearn : skills.entrySet())
		{
			final int id = skillLearn.getKey();
			final int level = skillLearn.getValue();
			// Create a L2Skill object for each record
			final L2Skill skill = SkillTable.getInstance().getInfo(id, level);
			
			if (skill == null)
			{
				LOG.log(Level.SEVERE, "Skipped null skill Id: " + id + ", Level: " + level + " while restoring player skills for " + player.getName());
				continue;
			}
			
			// solo le enseniamos el skill si es que el mismo no lo tiene aun o si es el inferior al q le vamos a enseniar
			if (player.getSkillLevel(id) < level)
			{
				// Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
				player.addSkill(skill, true);
			}
		}
		
		return true;
	}
	
	public static SubClassAcumulatives getInstance()
	{
		return SingletonHolder.INSTANCE;
	}
	
	private static class SingletonHolder
	{
		protected static final SubClassAcumulatives INSTANCE = new SubClassAcumulatives();
	}
}

 

Edited by Kotegaeshi92

2 answers to this question

Recommended Posts

  • 0
Posted (edited)
On 12/8/2021 at 12:56 AM, Kotegaeshi92 said:

hi! im using a sub stuck mod i found in the forum. Everything works ok but there is a bug..  if you cancel the subclass the first time and you dont go back to the main class, all skills from that class are removed (thats how supposed to work) but if you go back to main and you cancel the subclass, the skills from the subclass are not removed. So you can have skills from whatever subclass you want at the same time ( :S ) . ill paste te code here if anyone can give me some suggestion to fix this, i will be gratefull. Thanks !

edit: Im using Acis rev.399 

 

/*
 * L2J_EngineMods
 * Engine developed by Fissban.
 *
 * This software is not free and you do not have permission
 * to distribute without the permission of its owner.
 *
 * This software is distributed only under the rule
 * of www.devsadmins.com.
 * 
 * Contact us with any questions by the media
 * provided by our web or email marco.faccio@gmail.com
 */
package main.engine.mods;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;

import main.data.ConfigData;
import main.engine.AbstractMods;
import net.sf.l2j.commons.pool.ConnectionPool;
import net.sf.l2j.gameserver.data.SkillTable;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.skills.L2Skill;

/**
 * @author fissban
 */
public class SubClassAcumulatives extends AbstractMods
{
	// SQL
	private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level,class_index FROM character_skills WHERE char_obj_id=?";
	
	/**
	 * Constructor
	 */
	public SubClassAcumulatives()
	{
		registerMod(ConfigData.ENABLE_SubClassAcumulatives);
	}
	
	@Override
	public void onModState()
	{
		//
	}
	
	@Override
	public boolean onRestoreSkills(Player player)
	{
		Map<Integer, Integer> skills = new HashMap<>();
		
		try (Connection con = ConnectionPool.getConnection();
			PreparedStatement ps = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
		{
			// Retrieve all skills of this Player from the database
			ps.setInt(1, player.getObjectId());
			
			try (ResultSet rs = ps.executeQuery())
			{
				while (rs.next())
				{
					final int id = rs.getInt("skill_id");
					final int level = rs.getInt("skill_level");
					final int classIndex = rs.getInt("class_index");
					
					// fake skills for base stats
					if (id > 9000)
					{
						continue;
					}
					
					if (player.getClassIndex() != classIndex)
					{
						final L2Skill skill = SkillTable.getInstance().getInfo(id, level);
						
						if (skill == null)
						{
							LOG.log(Level.SEVERE, "Skipped null skill Id: " + id + ", Level: " + level + " while restoring player skills for " + player.getName());
							continue;
						}
						
						if (!ConfigData.ACUMULATIVE_PASIVE_SKILLS)
						{
							if (skill.isPassive())
							{
								continue;
							}
						}
						
						if (ConfigData.DONT_ACUMULATIVE_SKILLS_ID.contains(id))
						{
							continue;
						}
						
					}
					
					// We save all the skills that we will teach our character.
					// This will avoid teaching a skill from lvl 1 to 15 for example
					// And directly we teach the lvl 15 =)
					skills.put(id, level);
				}
			}
		}
		catch (Exception e)
		{
			LOG.log(Level.SEVERE, "Could not restore " + player.getName() + " skills:", e);
		}
		
		for (Entry<Integer, Integer> skillLearn : skills.entrySet())
		{
			final int id = skillLearn.getKey();
			final int level = skillLearn.getValue();
			// Create a L2Skill object for each record
			final L2Skill skill = SkillTable.getInstance().getInfo(id, level);
			
			if (skill == null)
			{
				LOG.log(Level.SEVERE, "Skipped null skill Id: " + id + ", Level: " + level + " while restoring player skills for " + player.getName());
				continue;
			}
			
			// solo le enseniamos el skill si es que el mismo no lo tiene aun o si es el inferior al q le vamos a enseniar
			if (player.getSkillLevel(id) < level)
			{
				// Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
				player.addSkill(skill, true);
			}
		}
		
		return true;
	}
	
	public static SubClassAcumulatives getInstance()
	{
		return SingletonHolder.INSTANCE;
	}
	
	private static class SingletonHolder
	{
		protected static final SubClassAcumulatives INSTANCE = new SubClassAcumulatives();
	}
}

 

Your code is confusing class_index

 

Looked in the code, when adding a sub class, it assigns the desired index. You re-assign the index -1 to the skills.

try

			// solo le enseniamos el skill si es que el mismo no lo tiene aun o si es el inferior al q le vamos a enseniar
			if (player.getSkillLevel(id) < level)
			{
				// Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
				player.addSkill(skill, false);
			}
Edited by Psygrammator
  • 0
Posted
20 hours ago, Psygrammator said:

Your code is confusing class_index

 

Looked in the code, when adding a sub class, it assigns the desired index. You re-assign the index -1 to the skills.

try

			// solo le enseniamos el skill si es que el mismo no lo tiene aun o si es el inferior al q le vamos a enseniar
			if (player.getSkillLevel(id) < level)
			{
				// Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
				player.addSkill(skill, false);
			}

thanks !! this worked 😄

Guest
This topic is now closed to further replies.


  • Posts

    • TG Support: https://t.me/buyingproxysup | Channel: https://t.me/buyingproxycom Discord support: #buyingproxy | Server: Join the BuyingProxy Discord Server!  Create your free account here
    • Dalam World — This is a new gaming project that brings together all the mechanics of your favorite games! I want to say right away that the game will run on all devices: Windows, Linux, macOS (Intel/Apple)! The Dalam World client features advanced graphics that will look great! The client also provides stable FPS even with a huge number of players! Dalam World is not a Salve or Chronicle client ported upward — it’s a completely remade game on its own proprietary game engine! Dalam World servers allow more than 100,000 people to exist in a single world without virtual instances, thanks to server technologies built with Elixir and Rust! Dalam World is the childhood game we love so much! From each of our favorite MMOs we took only the best elements! Low system requirements will let the game run on an old laptop! We redesigned the game so there are no bots or real-money traders! Game website: https://Dalam.World Game forum: https://Dalam.World/forums/ For arbitragers: https://careers.dalam.world/ Discord: https://discord.gg/vbQ347nuxd Telegram: https://t.me/+u1DNZPzscaRmNjYx Opening July 16, 2026 at 16:00 UTC!  
    • I'll give you my wallet if you want, haha
    • To make up for some of the waiting time we’re hosting a 3v3 Tournament on open Beta, and this time we’re raising the stakes with a $1,300 prize pool 💰   🏆 PRIZE POOL BREAKDOWN (Over 2000$ Worth of prices total)   🥇 1st Place — $700 🥈 2nd Place —$300 🥉 3rd Place — $200 🏅 4th Place — $100  5th -6th Place - $100 in Gold Coins each    All Participating Teams: $50 in Gold!   All Prices will be Paid out instantly after the tour, no waiting time and conditions. This is not simply a marketing move, we want to give back to the community.   📅 Date: Wednesday 06.05.2026 ⏰ Time: 20:00 Central European Timezone (Berlin) 📍Format: 3v3   ⚔️Why join? Cash Prices for top 4 and rewards for all participants Payments to winners sent out straight after the tournament - No waiting time or rules that you have to play live server to obtain the reward. Clean format, smooth matches, and solid prize pool and a chance to experience our brand new files   📝How to join: Form your 3-player team Group Leader Sign up here: ⁠📍・3v3-tour-registration (Include Name of Group, Name of Group Leader)   Be ready on match day!     A separate post with rules for the tournament and class setups will follow shortly.   Tag your teammates, lock in your roster, and get ready to compete. We'll be happy to see you on the OBT!   💬 Questions? Ask in ⁠🎫・ticket or send us a message   See you on L2Dark! 😏   Discord: https://discord.gg/FAJwnFpb8M
    • You should check if that condition is supported by your current sources. You can find this in  DocumentBase#parsePlayerCondition If it isnt there and you want to follow the same pattern of the other item conditions, create a custom condition to parse the classId (or multiple class ids) (there are examples to copy the code). Alternatively, you can create your own condition handler. Your condition should look like this: <cond msgId="1518"> <or> <player classId="ADVENTURER" /> <player classId="PALADIN" /> </or> </cond> or <cond msgId="1518"> <or> <player classId="93" /> <player classId="5" /> </or> </cond>  
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..