Jump to content
  • 0

Java / enchant8_skill + enchant12_skill


Question

Posted

Seems easy enough, but last days after many tests, i failed hard multiple times, so i have to ask for help.

Pretty sure some fella can give me the solution here. xml / item / skill all done correctly. Also by compiling there is no error. 

 

#Weapon.java	
  
	private IntIntHolder _enchant4Skill;
+	private IntIntHolder _enchant8Skill;
+	private IntIntHolder _enchant12Skill;

		
		if (set.containsKey("enchant4_skill"))
			_enchant4Skill = set.getIntIntHolder("enchant4_skill");
+	
+		if (set.containsKey("enchant8_skill"))
+			_enchant8Skill = set.getIntIntHolder("enchant8_skill");
+
+		if (set.containsKey("enchant12_skill"))
+			_enchant12Skill = set.getIntIntHolder("enchant12_skill");
+
  
  	public L2Skill getEnchant4Skill()
	{
		return (_enchant4Skill == null) ? null : _enchant4Skill.getSkill();
	}
+	
+	public L2Skill getEnchant8Skill()
+	{
+		return (_enchant8Skill == null) ? null : _enchant8Skill.getSkill();
+	}
+	
+	public L2Skill getEnchant12Skill()
+	{
+		return (_enchant12Skill == null) ? null : _enchant12Skill.getSkill();
+	}
+	
  
  ------------------------------------------------------
  #RequestEnchantItem.java
  
  					if (it instanceof Weapon && item.getEnchantLevel() == 4)
					{
						final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
						if (enchant4Skill != null)
						{
							player.addSkill(enchant4Skill, false);
							player.sendSkillList();
						}
					}
+					else if (it instanceof Weapon && item.getEnchantLevel() == 8)
+					{
+						final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+						if (enchant8Skill != null)
+						{
+							player.addSkill(enchant8Skill, false);
+							player.sendSkillList();
+						}
+					}
+					else if (it instanceof Weapon && item.getEnchantLevel() == 12)
+					{
+						final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+						if (enchant12Skill != null)
+						{
+							player.addSkill(enchant12Skill, false);
+							player.sendSkillList();
+						}
+					}
+

  
  					if (it instanceof Weapon && item.getEnchantLevel() >= 4)
					{
						final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
						if (enchant4Skill != null)
						{
							player.removeSkill(enchant4Skill.getId(), false);
							player.sendSkillList();
						}
					}
+					else if (it instanceof Weapon && item.getEnchantLevel() >= 8)
+					{
+						final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+						if (enchant8Skill != null)
+						{
+							player.removeSkill(enchant8Skill.getId(), false);
+							player.sendSkillList();
+						}
+					}
+					else if (it instanceof Weapon && item.getEnchantLevel() >= 12)
+					{
+						final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+						if (enchant12Skill != null)
+						{
+							player.removeSkill(enchant12Skill.getId(), false);
+							player.sendSkillList();
+						}
+					}
+

  ------------------------------------------------
  
  #ItemPassiveSkillsListener.java
  
  
  			if (item.getEnchantLevel() >= 4)
			{
				final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
				if (enchant4Skill != null)
				{
					player.addSkill(enchant4Skill, false);
					update = true;
				}
			}
+			
+			else if (item.getEnchantLevel() >= 8)
+			{
+				final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+				if (enchant8Skill != null)
+				{
+					player.addSkill(enchant8Skill, false);
+					update = true;
+				}
+			}
+
+			else if (item.getEnchantLevel() >= 12)
+			{
+				final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+				if (enchant12Skill != null)
+				{
+					player.addSkill(enchant12Skill, false);
+					update = true;
+				}
+			}
+
  
  			if (item.getEnchantLevel() >= 4)
			{
				final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
				if (enchant4Skill != null)
				{
					player.removeSkill(enchant4Skill.getId(), false, enchant4Skill.isPassive() || enchant4Skill.isToggle());
					update = true;
				}
			}
+			
+			else if (item.getEnchantLevel() >= 8)
+			{
+				final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+				if (enchant8Skill != null)
+				{
+					player.removeSkill(enchant8Skill.getId(), false, enchant8Skill.isPassive() || enchant8Skill.isToggle());
+					update = true;
+				}
+			}
+			
+			else if (item.getEnchantLevel() >= 12)
+			{
+				final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+				if (enchant12Skill != null)
+				{
+					player.removeSkill(enchant12Skill.getId(), false, enchant12Skill.isPassive() || enchant12Skill.isToggle());
+					update = true;
+				}
+			}

 

4 answers to this question

Recommended Posts

  • 0
Posted

Hello,  to be honest with you, your question is a bit unclear, at least to me.

Are you trying to give special skills to players based upon their weapon enchant level?

 

Also there are parts of the code that are wrong, for example you do:

if (item.getEnchantLevel() >= 4)

and then immediately after

else if (item.getEnchantLevel() >= 8)

This last block will never be evaluated since the previous one will be true, and so on.

From the snippets you posted I can't figure out, maybe try to post the whole files somewhere 😄

  • 0
Posted
On 7/11/2024 at 10:15 AM, killer666 said:

Seems easy enough, but last days after many tests, i failed hard multiple times, so i have to ask for help.

Pretty sure some fella can give me the solution here. xml / item / skill all done correctly. Also by compiling there is no error. 

 

#Weapon.java	
  
	private IntIntHolder _enchant4Skill;
+	private IntIntHolder _enchant8Skill;
+	private IntIntHolder _enchant12Skill;

		
		if (set.containsKey("enchant4_skill"))
			_enchant4Skill = set.getIntIntHolder("enchant4_skill");
+	
+		if (set.containsKey("enchant8_skill"))
+			_enchant8Skill = set.getIntIntHolder("enchant8_skill");
+
+		if (set.containsKey("enchant12_skill"))
+			_enchant12Skill = set.getIntIntHolder("enchant12_skill");
+
  
  	public L2Skill getEnchant4Skill()
	{
		return (_enchant4Skill == null) ? null : _enchant4Skill.getSkill();
	}
+	
+	public L2Skill getEnchant8Skill()
+	{
+		return (_enchant8Skill == null) ? null : _enchant8Skill.getSkill();
+	}
+	
+	public L2Skill getEnchant12Skill()
+	{
+		return (_enchant12Skill == null) ? null : _enchant12Skill.getSkill();
+	}
+	
  
  ------------------------------------------------------
  #RequestEnchantItem.java
  
  					if (it instanceof Weapon && item.getEnchantLevel() == 4)
					{
						final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
						if (enchant4Skill != null)
						{
							player.addSkill(enchant4Skill, false);
							player.sendSkillList();
						}
					}
+					else if (it instanceof Weapon && item.getEnchantLevel() == 8)
+					{
+						final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+						if (enchant8Skill != null)
+						{
+							player.addSkill(enchant8Skill, false);
+							player.sendSkillList();
+						}
+					}
+					else if (it instanceof Weapon && item.getEnchantLevel() == 12)
+					{
+						final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+						if (enchant12Skill != null)
+						{
+							player.addSkill(enchant12Skill, false);
+							player.sendSkillList();
+						}
+					}
+

  
  					if (it instanceof Weapon && item.getEnchantLevel() >= 4)
					{
						final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
						if (enchant4Skill != null)
						{
							player.removeSkill(enchant4Skill.getId(), false);
							player.sendSkillList();
						}
					}
+					else if (it instanceof Weapon && item.getEnchantLevel() >= 8)
+					{
+						final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+						if (enchant8Skill != null)
+						{
+							player.removeSkill(enchant8Skill.getId(), false);
+							player.sendSkillList();
+						}
+					}
+					else if (it instanceof Weapon && item.getEnchantLevel() >= 12)
+					{
+						final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+						if (enchant12Skill != null)
+						{
+							player.removeSkill(enchant12Skill.getId(), false);
+							player.sendSkillList();
+						}
+					}
+

  ------------------------------------------------
  
  #ItemPassiveSkillsListener.java
  
  
  			if (item.getEnchantLevel() >= 4)
			{
				final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
				if (enchant4Skill != null)
				{
					player.addSkill(enchant4Skill, false);
					update = true;
				}
			}
+			
+			else if (item.getEnchantLevel() >= 8)
+			{
+				final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+				if (enchant8Skill != null)
+				{
+					player.addSkill(enchant8Skill, false);
+					update = true;
+				}
+			}
+
+			else if (item.getEnchantLevel() >= 12)
+			{
+				final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+				if (enchant12Skill != null)
+				{
+					player.addSkill(enchant12Skill, false);
+					update = true;
+				}
+			}
+
  
  			if (item.getEnchantLevel() >= 4)
			{
				final L2Skill enchant4Skill = ((Weapon) it).getEnchant4Skill();
				if (enchant4Skill != null)
				{
					player.removeSkill(enchant4Skill.getId(), false, enchant4Skill.isPassive() || enchant4Skill.isToggle());
					update = true;
				}
			}
+			
+			else if (item.getEnchantLevel() >= 8)
+			{
+				final L2Skill enchant8Skill = ((Weapon) it).getEnchant8Skill();
+				if (enchant8Skill != null)
+				{
+					player.removeSkill(enchant8Skill.getId(), false, enchant8Skill.isPassive() || enchant8Skill.isToggle());
+					update = true;
+				}
+			}
+			
+			else if (item.getEnchantLevel() >= 12)
+			{
+				final L2Skill enchant12Skill = ((Weapon) it).getEnchant12Skill();
+				if (enchant12Skill != null)
+				{
+					player.removeSkill(enchant12Skill.getId(), false, enchant12Skill.isPassive() || enchant12Skill.isToggle());
+					update = true;
+				}
+			}

 


The solution is what the guy before me said. You need to either place the higher value before the smaller value or limit the range.

Ex. 1: 
 

if (item.getEnchantLevel() >= 12)
{
     // do whatever
}
else if (item.getEnchantLevel() >= 8)
{
     // do whatever
}
else if (item.getEnchantLevel() >= 4)
{
     // do whatever
}


Ex. 2:
 

if (item.getEnchantLevel() >= 4 && item.getEnchantLevel() <= 7)
{
     // do whatever
}
else if (item.getEnchantLevel() >= 8 && item.getEnchantLevel() <= 11)
{
     // do whatever
}
else if (item.getEnchantLevel() >= 12)
{
     // do whatever
}

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Posts

    • how do I make it so that you only deal damage to a mob if you have the right items equipped, like jewels, belt, underwear, bracelet, so if you don't have one of those items equipped, you don't deal any damage to the mob thanks
    • I always welcome bug reports and never ban ppl - until proven leaker - not sure where the "arrogant" part comes from, I would like to know what exactly let you think that (quote me please, and not 12y old quotes as the other frog meme dude). I request bug reports to be properly detailed, otherwise it's a waste of time. Other than that, I don't see where I have been arrogant. I got proper discussions with many ppl, not sure why you wouldn't be one of them.   I got 76 bug reports in my list (21 on forums, 55 on gitlab).   I have a single bug report regarding lvl 4 clan quest, which has to be tested since it's not even clear about what is supposed to be broken. Seven Signs was never reworked and is basically L2J based (we got a rework branch to test/commit with reworked AIs). Geoengine got no specific issues (at my knowledge), pathfinding was reworked lately to be way more performant, and I still try to improve performance using some pool system. Movement was partially fixed in latest 410, and probably will get another rework soon (notably reverting to the task wallclock).   "I" surely didn't spend 12y over geoengine - Hasha cared about geoengine during rev 334 / 354 / 390 / 395 and 397. It is solely his work, and always tagged as it. He was rewarded with money for his work, and almost a decade of aCis access.   aCis is a community work, things tagged with Tryskell is my work, the leftover is someone else work. 22 ppl worked as developers in this project over 14 years.   I would gladly accept whatever list of fixes/reports you have to share. You will even be rewarded (you probably know about cookie system), as anyone else sharing bug report or fixes.   My main concerns lately is the lack of decent L2OFF IL data, it is my main bottleneck actually. If you're aware about decent L2OFF data to parse, let me know.
    • Your project doesn't compare to aCis; you have to be an idiot to use that. I know someone who bought the High Five "PREMIUM" version, which has the same bugs as the free version. If you want, I can share his latest premium version. Players are going through walls with their bad geoengine, falling under the Olympiad. If you want, I can record and prove what I'm saying. The aCis project is 50 steps ahead of yours and it's not even stable...
    • l2jteon, l2joneo l2jscoria etc etc. and from that we went to this 
  • 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..

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock