Sharing and looking for a bit of H-E-L-P :?

Find the proper support area, Saga-Version.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

Well, hello guys, althrough being basicaly a "copy" of the normal skill tree's (as far as i think it is cause there isn't much diferences :P ) i've just made some new class' trying to create an instance where players can get new skills/buffs on their characters doing certain amount of pvps... So, i've made these class', they haven't errors as i can apreciate but, anyway, just made correct the imports and everything else, it's doesn't log the table on the server startup, i don't really knows which is the problem here, some of the imports may are missing, or it's just that it wont work cause of something that i didn't noticed, anyway.
I will let the class' here and hope a bit of help from you to finish it; i will keept trying to find a way and updating the post if it's neccessary :)


It's the PvpSkillLearn.class:

Code: Select all

 +package net.sf.l2j.gameserver.model;++/**+ * + * @author GuillermoKiss+ * + *Class made for PvpSkillTrees, + */++public class PvpSkillLearn +{++	// these two build the primary key+	private final int _id;+	private final int _level;++	// not needed, just for easier debug+	private final String _name;+	+	private final int _minLevel;+	private final int _pvpKills;+	+	public PvpSkillLearn(int id, int lvl, String name, int minLvl, int pvpKills)+	{+		_id = id;+		_level = lvl;+		_name = name.intern();+		_minLevel = minLvl;+		_pvpKills = pvpKills;+	}++	/**+	 * @return Returns the id.+	 */+	public int getId()+	{+		return _id;+	}++	/**+	 * @return Returns the level.+	 */+	public int getLevel()+	{+		return _level;+	}++	/**+	 * @return Returns the name.+	 */+	public String getName()+	{+		return _name;+	}++	public int getMinLevel()+	{+		return _minLevel;+	}++	public int getPvpKills()+	{+		return _pvpKills;+	}++}+ 
It's the PvpSkillTree.class:

Code: Select all

 +package net.sf.l2j.gameserver.datatables;++import java.sql.Connection;+import java.sql.PreparedStatement;+import java.sql.ResultSet;+import java.sql.SQLException;+import java.util.Collection;+import java.util.List;+import java.util.Map;+import java.util.logging.Logger;++import javolution.util.FastList;+import javolution.util.FastMap;+import net.sf.l2j.L2DatabaseFactory;+import net.sf.l2j.gameserver.model.L2Skill;+import net.sf.l2j.gameserver.model.PvpSkillLearn;+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;+import net.sf.l2j.gameserver.model.base.ClassId;++/**+ * + * @author GuillermoKiss+ *+ *Class made for PVP testing skill tables.+ */++public class PvpSkillTreeTable +{+	+	private static Logger _log = Logger.getLogger(PvpSkillTreeTable.class.getName());+	+	private Map<ClassId, Map<Integer, PvpSkillLearn>> _pvpSkillTrees;+	+	public static PvpSkillTreeTable getInstance()+	+	{+		return SingletonHolder._instance;+	}++	/**+	 * Return the minimum level needed to have this Expertise.<BR><BR>+	 *+	 * @param grade The grade level searched+	 */+	public int getExpertiseLevel(int grade)+	{+		if (grade <= 0)+			return 0;+		+		Map<Integer, PvpSkillLearn> learnMap = getPvpSkillTrees().get(ClassId.paladin);+		+		int skillHashCode = SkillTable.getSkillHashCode(239, grade);+		if (learnMap.containsKey(skillHashCode))+		{+			return learnMap.get(skillHashCode).getPvpKills();+		}+		+		_log.severe("Expertise not found for grade " + grade);+		return 0;+	}+	+	public int getMinSkillLevel(int skillId, ClassId classId, int skillLvl)+	{+		Map<Integer, PvpSkillLearn> map = getPvpSkillTrees().get(classId);+		+		int skillHashCode = SkillTable.getSkillHashCode(skillId, skillLvl);+		+		if (map.containsKey(skillHashCode))+		{+			return map.get(skillHashCode).getMinLevel();+		}+		+		return 0;+	}+	+	public int getMinSkillLevel(int skillId, int skillLvl)+	{+		int skillHashCode = SkillTable.getSkillHashCode(skillId, skillLvl);+		+		for (Map<Integer, PvpSkillLearn> map : getPvpSkillTrees().values())+		{+			if (map.containsKey(skillHashCode))+			{+				return map.get(skillHashCode).getMinLevel();+			}+		}+		return 0;+	}+	+	private PvpSkillTreeTable()+	{+		int classId = 0;+		int count = 0;++		Connection con = null;+		+		try+		{+			try +			{+				con = L2DatabaseFactory.getInstance().getConnection();+			} catch (SQLException e1) +			{+				e1.printStackTrace();+			}+			try+			{+				PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list ORDER BY id");+				ResultSet classlist = statement.executeQuery();+				+				Map<Integer, PvpSkillLearn> map;+				int parentClassId;+				PvpSkillLearn skillLearn;+				+				while (classlist.next())+				{+					map = new FastMap<Integer, PvpSkillLearn>();+					parentClassId = classlist.getInt("parent_id");+					classId = classlist.getInt("id");+					PreparedStatement statement2 = con.prepareStatement("SELECT class_id, skill_id, level, name, min_level, pvpKills FROM pvp_skill_trees where class_id=? ORDER BY skill_id, level");+					statement2.setInt(1, classId);+					ResultSet pvpskilltree = statement2.executeQuery();+					+					if (parentClassId != -1)+					{+						Map<Integer, PvpSkillLearn> parentMap = getPvpSkillTrees().get(ClassId.values()[parentClassId]);+						map.putAll(parentMap);+					}+					+					int prevSkillId = -1;+					+					while (pvpskilltree.next())+					{+						int id = pvpskilltree.getInt("skill_id");+						int lvl = pvpskilltree.getInt("level");+						String name = pvpskilltree.getString("name");+						int minLvl = pvpskilltree.getInt("min_level");+						int pvpKills = pvpskilltree.getInt("pvpKills");+						+						if (prevSkillId != id)+							prevSkillId = id;+						+						skillLearn = new PvpSkillLearn(id, lvl, name, minLvl, pvpKills);+						map.put(SkillTable.getSkillHashCode(id, lvl), skillLearn);+					}+					+					getPvpSkillTrees().put(ClassId.values()[classId], map);+					pvpskilltree.close();+					statement2.close();+					+					count += map.size();+					_log.fine("PvpSkillTreeTable: skill tree for class " + classId + " has " + map.size() + " skills");+				}+				+				classlist.close();+				statement.close();+			}+			catch (Exception e)+			{+				_log.severe("Error while creating pvp skill tree (Class ID " + classId + "):" + e);+			}+			+			_log.config("PvpSkillTreeTable: Loaded " + count + " skills.");+		}+		finally+		{+			try+			{+				con.close();+			}+			catch (Exception e)+			{+			}+		}+		}+		+		private Map<ClassId, Map<Integer, PvpSkillLearn>> getPvpSkillTrees()+		{+			if (_pvpSkillTrees == null)+				_pvpSkillTrees = new FastMap<ClassId, Map<Integer, PvpSkillLearn>>();+			+			return _pvpSkillTrees;+		}+		+		public PvpSkillLearn[] getAvailableSkills(L2PcInstance cha, ClassId classId)+		{+			List<PvpSkillLearn> result = new FastList<PvpSkillLearn>();+			Collection<PvpSkillLearn> skills = getPvpSkillTrees().get(classId).values();+			+			if (skills == null)+			{+				_log.warning("PvpSkilltree for class " + classId + " is not defined !");+				return new PvpSkillLearn[0];+			}+			+			L2Skill[] oldSkills = cha.getAllSkills();+			+			for (PvpSkillLearn temp : skills)+			{+				if (temp.getMinLevel() <= cha.getLevel())+				{+					boolean knownSkill = false;+					+					for (int j = 0; j < oldSkills.length && !knownSkill; j++)+					{+						if (oldSkills[j].getId() == temp.getId())+						{+							knownSkill = true;+							+							if (oldSkills[j].getLevel() == temp.getLevel() - 1)+							{+								// this is the next level of a skill that we know+								result.add(temp);+							}+						}+					}+					+					if (!knownSkill && temp.getLevel() == 1)+					{+						// this is a new skill+						result.add(temp);+					}+				}+			}+			return result.toArray(new PvpSkillLearn[result.size()]);+		}+		+		@SuppressWarnings("synthetic-access")+		private static class SingletonHolder+		{+			protected static final PvpSkillTreeTable _instance = new PvpSkillTreeTable();+		}+}+ 
Here's the imports and the table decriptions and actions on L2PcInstance:

Code: Select all

 ==============================================================================================================NEW SCRIPTS APPLIEDS AT LINES ++71++  //  ++139++import net.sf.l2j.gameserver.datatables.ItemTable;import net.sf.l2j.gameserver.datatables.MapRegionTable;import net.sf.l2j.gameserver.datatables.NobleSkillTable;import net.sf.l2j.gameserver.datatables.NpcTable;import net.sf.l2j.gameserver.datatables.SkillTable;import net.sf.l2j.gameserver.datatables.SkillTreeTable;+                 import net.sf.l2j.gameserver.datatables.PvpSkillTreeTable;import net.sf.l2j.gameserver.handler.AdminCommandHandler;import net.sf.l2j.gameserver.handler.IAdminCommandHandler;import net.sf.l2j.gameserver.handler.IItemHandler;import net.sf.l2j.gameserver.handler.ItemHandler;import net.sf.l2j.gameserver.instancemanager.CastleManager;import net.sf.l2j.gameserver.instancemanager.CoupleManager;import net.sf.l2j.gameserver.instancemanager.CursedWeaponsManager;import net.sf.l2j.gameserver.instancemanager.DimensionalRiftManager;import net.sf.l2j.gameserver.instancemanager.DuelManager;import net.sf.l2j.gameserver.instancemanager.FortManager;import net.sf.l2j.gameserver.instancemanager.FortSiegeManager;import net.sf.l2j.gameserver.instancemanager.InstanceManager;import net.sf.l2j.gameserver.instancemanager.ItemsOnGroundManager;import net.sf.l2j.gameserver.instancemanager.QuestManager;import net.sf.l2j.gameserver.instancemanager.SiegeManager;import net.sf.l2j.gameserver.model.BlockList;import net.sf.l2j.gameserver.model.Elementals;import net.sf.l2j.gameserver.model.FishData;import net.sf.l2j.gameserver.model.L2AccessLevel;import net.sf.l2j.gameserver.model.L2CharPosition;import net.sf.l2j.gameserver.model.L2Clan;import net.sf.l2j.gameserver.model.L2ClanMember;import net.sf.l2j.gameserver.model.L2Effect;import net.sf.l2j.gameserver.model.L2Fishing;import net.sf.l2j.gameserver.model.L2HennaInstance;import net.sf.l2j.gameserver.model.L2ItemInstance;import net.sf.l2j.gameserver.model.L2Macro;import net.sf.l2j.gameserver.model.L2ManufactureList;import net.sf.l2j.gameserver.model.L2Object;import net.sf.l2j.gameserver.model.L2Party;import net.sf.l2j.gameserver.model.L2PetData;import net.sf.l2j.gameserver.model.L2PetDataTable;import net.sf.l2j.gameserver.model.L2Radar;import net.sf.l2j.gameserver.model.L2RecipeList;import net.sf.l2j.gameserver.model.L2Request;import net.sf.l2j.gameserver.model.L2ShortCut;import net.sf.l2j.gameserver.model.L2Skill;import net.sf.l2j.gameserver.model.L2SkillLearn;+                 import net.sf.l2j.gameserver.model.PvpSkillLearn;import net.sf.l2j.gameserver.model.L2Transformation;import net.sf.l2j.gameserver.model.L2World;import net.sf.l2j.gameserver.model.L2WorldRegion;import net.sf.l2j.gameserver.model.MacroList; ================================================================================================================NEW SCRIPTS APPLIEDS AT LINES ++2840,2864,++	/**	 * Give all available skills to the player.<br><br>	 *	 */	private void giveAvailableSkills()	{		int unLearnable = 0;		int skillCounter = 0; 		// Get available skills		L2SkillLearn[] skills = SkillTreeTable.getInstance().getAvailableSkills(this, getClassId());		while (skills.length > unLearnable)		{			for (L2SkillLearn s: skills)			{				L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());				if (sk == null || (sk.getId() == L2Skill.SKILL_DIVINE_INSPIRATION && !Config.AUTO_LEARN_DIVINE_INSPIRATION))				{					unLearnable++;					continue;				} 				if (getSkillLevel(sk.getId()) == -1)					skillCounter++; 				// fix when learning toggle skills				if (sk.isToggle())				{					L2Effect toggleEffect = getFirstEffect(sk.getId());					if (toggleEffect != null)					{						// stop old toggle skill effect, and give new toggle skill effect back						toggleEffect.exit();						sk.getEffects(this, this);					}				} 				addSkill(sk, true);			} 			// Get new available skills			skills = SkillTreeTable.getInstance().getAvailableSkills(this, getClassId());		} 		sendMessage("You have learned " + skillCounter + " new skills.");	}++	public void givePvpSkills()+	{+		int unLearnable = 0;+		int skillCounter = 0;+		+		PvpSkillLearn[] skills = PvpSkillTreeTable.getInstance().getAvailableSkills(this, getClassId());+		while (skills.length > unLearnable)+		{+			for (PvpSkillLearn s: skills)+			{+				L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());+				{+					unLearnable++;+					continue;+				}+			}++			// Get new available skills+			skills = PvpSkillTreeTable.getInstance().getAvailableSkills(this, getClassId());+		}++		sendMessage("You have learned " + skillCounter + " new skills.");+	}+	/** Set the Experience value of the L2PcInstance. */	public void setExp(long exp)	{		if (exp < 0)			exp = 0; 		getStat().setExp(exp);	} 
So, hope that somebody can halp with this a bit, cheers!. :mrgreen:
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

Someone's alive here? :cry:
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by JIV »

do you call PvpSkillTreeTable.getInstance()?
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

Well, yes, i've done.. i'm taking a look about all the configs again, but i can't find the error yet :|
if you can give to this a bit of your time, cause i've seen that many persons here and somewhereelse have made too many post asking for a way to get skills based on the pvpkills of a character, and also i'm needing it too, so, hope that someone can help me a bit to finish with this...
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

:arrow: :!: !S.O.S! :!: :arrow:
User avatar
Aikimaniac
L2j Inner Circle
L2j Inner Circle
Posts: 3048
Joined: Sun Aug 07, 2005 11:42 pm
Location: Slovakia

Re: Sharing and looking for a bit of H-E-L-P :?

Post by Aikimaniac »

guillermokiss wrote::arrow: :!: !S.O.S! :!: :arrow:
Devs are currently on Freya features implementations and for sure when there will be free time, they will try to help you..be patient..
Image
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

Well, just noticed about, but anyway, i think that maybe someone can take a look at this and bring an opinion about if there is any mistake, or atleast if there's any wrong import which is causing that it doesn't works :|
antons007
Posts: 149
Joined: Sat Sep 12, 2009 4:18 pm

Re: Sharing and looking for a bit of H-E-L-P :?

Post by antons007 »

Have you defined those "pvp skills" anywhere?
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

yes i have, as how it's supossed to be done, at that table, but anyway it doesn't works yet :?
antons007
Posts: 149
Joined: Sat Sep 12, 2009 4:18 pm

Re: Sharing and looking for a bit of H-E-L-P :?

Post by antons007 »

and have you called

Code: Select all

givePvpSkills()
somewhere?
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

antons007 wrote:and have you called

Code: Select all

givePvpSkills()
somewhere?
Well yes, as you can see here...

Code: Select all

 ++	public void givePvpSkills()   <=========== (HERE)+	{+		int unLearnable = 0;+		int skillCounter = 0;+		+		PvpSkillLearn[] skills = PvpSkillTreeTable.getInstance().getAvailableSkills(this, getClassId());+		while (skills.length > unLearnable)+		{+			for (PvpSkillLearn s: skills)+			{+				L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());+				{+					unLearnable++;+					continue;+				}+			}++			// Get new available skills+			skills = PvpSkillTreeTable.getInstance().getAvailableSkills(this, getClassId());+		}++		sendMessage("You have learned " + skillCounter + " new skills.");+	}+	/** Set the Experience value of the L2PcInstance. */	public void setExp(long exp)	+              {		+                       if (exp < 0)	exp = 0; 	getStat().setExp(exp);+	} 
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Sharing and looking for a bit of H-E-L-P :?

Post by jurchiks »

umm...
you seem to misunderstand, he asked WHERE DO YOU CALL THE METHOD, not the method itself!
just because you've made the method doesn't mean it will do anything, you need to call it from somewhere.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
guillermokiss
Posts: 99
Joined: Mon May 24, 2010 2:19 pm
Location: Argentina
Contact:

Re: Sharing and looking for a bit of H-E-L-P :?

Post by guillermokiss »

Rofl, it's called at L2PcInstance where it's supossed to add the "skills" to the character...
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Sharing and looking for a bit of H-E-L-P :?

Post by jurchiks »

and again you don't get it!
just because you have
public void givePvpSkills()
in L2PcInstance doesn't mean it will be used, you need to call it from another method.
either you're hiding some part of code or you don't call it.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Post Reply