Przeglądaj źródła

Support for NEGATE/CANCEL abnormalTypes by nik (Require [DP7879]), also minor improve for multisell log by UnAfraid.

MELERIX 14 lat temu
rodzic
commit
aac3b3368c

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/datatables/MultiSell.java

@@ -215,7 +215,7 @@ public class MultiSell
 			}
 		}
 		verify();
-		_log.config("MultiSell: Loaded " + _entries.size() + " lists.");
+		_log.log(Level.INFO, "MultiSell: Loaded " + _entries.size() + " lists.");
 	}
 	
 	private final ListContainer parseDocument(Document doc)
@@ -304,7 +304,7 @@ public class MultiSell
 		File dir = new File(Config.DATAPACK_ROOT, "data/" + dirname);
 		if (!dir.exists())
 		{
-			_log.config("Dir " + dir.getAbsolutePath() + " not exists");
+			_log.log(Level.WARNING, "Dir " + dir.getAbsolutePath() + " not exists");
 			return;
 		}
 		

+ 36 - 0
L2J_Server/java/com/l2jserver/gameserver/model/L2Skill.java

@@ -17,10 +17,12 @@ package com.l2jserver.gameserver.model;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.logging.Logger;
 
 import javolution.util.FastList;
+import javolution.util.FastMap;
 
 import com.l2jserver.Config;
 import com.l2jserver.gameserver.GeoData;
@@ -172,6 +174,7 @@ public abstract class L2Skill implements IChanceSkillTrigger
 	private final int _negateLvl;   // abnormalLvl is negated with negateLvl
 	private final int[] _negateId; 			// cancels the effect of skill ID
 	private final L2SkillType[] _negateStats; 	// lists the effect types that are canceled
+	private final Map<String, Byte> _negateAbnormals; // lists the effect abnormal types with order below the presented that are canceled
 	private final int _maxNegatedEffects; 	// maximum number of effects to negate
 	
 	private final boolean _stayAfterDeath; // skill should stay after death
@@ -350,6 +353,34 @@ public abstract class L2Skill implements IChanceSkillTrigger
 			_negateStats = array;
 		}
 		
+		String negateAbnormals = set.getString("negateAbnormals", null);
+		if (negateAbnormals != null && negateAbnormals != "")
+		{
+			_negateAbnormals = new FastMap<String, Byte>();
+			for (String ngtStack : negateAbnormals.split(";"))
+			{
+				String[] ngt = ngtStack.split(",");
+				if (ngt.length == 1) // Only abnormalType is present, without abnormalLvl
+				{
+					_negateAbnormals.put(ngt[0], Byte.MAX_VALUE);
+				}
+				else if (ngt.length == 2) // Both abnormalType and abnormalLvl are present
+				{
+					try
+					{
+						_negateAbnormals.put(ngt[0], Byte.parseByte(ngt[1]));
+					}
+					catch (Exception e)
+					{
+						throw new IllegalArgumentException("SkillId: "+_id+" Byte value required, but found: "+ngt[1]);
+					}
+				}
+				else // If not both from above, then smth is messed up... throw an error.
+					throw new IllegalArgumentException("SkillId: "+_id+": Incorrect negate Abnormals for "+ngtStack+". Lvl: abnormalType1,abnormalLvl1;abnormalType2,abnormalLvl2;abnormalType3,abnormalLvl3... or abnormalType1;abnormalType2;abnormalType3...");
+			}
+		}
+		else
+			_negateAbnormals = null;
 		
 		String negateId = set.getString("negateId", null);
 		if (negateId != null)
@@ -645,6 +676,11 @@ public abstract class L2Skill implements IChanceSkillTrigger
 		return _negateStats;
 	}
 	
+	public final Map<String, Byte> getNegateAbnormals()
+	{
+		return _negateAbnormals;
+	}
+	
 	public final int getAbnormalLvl()
 	{
 		return _abnormalLvl;

+ 59 - 35
L2J_Server/java/com/l2jserver/gameserver/skills/effects/EffectCancel.java

@@ -116,53 +116,44 @@ public class EffectCancel extends L2Effect
 				_log.info(result);
 		}
 
-		L2Effect eff;
-		int lastCanceledSkillId = 0;
 		final L2Effect[] effects = target.getAllEffects();
-		for (int i = effects.length; --i >= 0;)
+		
+		if (effect.getSkill().getNegateAbnormals() != null) // Cancel for abnormals
 		{
-			eff = effects[i];
-			if (eff == null)
-				continue;
-			
-			if (!eff.canBeStolen())
+			for (L2Effect eff : effects)
 			{
-				effects[i] = null;
-				continue;
-			}
-			
-			// first pass - dances/songs only
-			if (!eff.getSkill().isDance())
-				continue;
-			
-			if (eff.getSkill().getId() == lastCanceledSkillId)
-			{
-				eff.exit(); // this skill already canceled
-				continue;
+				if (eff == null)
+					continue;
+				
+				for (String negateAbnormalType : effect.getSkill().getNegateAbnormals().keySet())
+				{
+					if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && effect.getSkill().getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl())
+					{
+						if (calcCancelSuccess(eff, cancelLvl, (int)rate))
+							eff.exit();
+					}
+				}
 			}
-			
-			if (!calcCancelSuccess(eff, cancelLvl, (int)rate))
-				continue;
-			
-			lastCanceledSkillId = eff.getSkill().getId();
-			eff.exit();
-			count--;
-			
-			if (count == 0)
-				break;
 		}
-		
-		if (count != 0)
+		else
 		{
-			lastCanceledSkillId = 0;
+			L2Effect eff;
+			int lastCanceledSkillId = 0;
+			
 			for (int i = effects.length; --i >= 0;)
 			{
 				eff = effects[i];
 				if (eff == null)
 					continue;
 				
-				// second pass - all except dances/songs
-				if (eff.getSkill().isDance())
+				if (!eff.canBeStolen())
+				{
+					effects[i] = null;
+					continue;
+				}
+				
+				// first pass - dances/songs only
+				if (!eff.getSkill().isDance())
 					continue;
 				
 				if (eff.getSkill().getId() == lastCanceledSkillId)
@@ -175,13 +166,46 @@ public class EffectCancel extends L2Effect
 					continue;
 				
 				lastCanceledSkillId = eff.getSkill().getId();
+				
 				eff.exit();
 				count--;
 				
 				if (count == 0)
 					break;
 			}
+			
+			if (count != 0)
+			{
+				lastCanceledSkillId = 0;
+				for (int i = effects.length; --i >= 0;)
+				{
+					eff = effects[i];
+					if (eff == null)
+						continue;
+					
+					// second pass - all except dances/songs
+					if (eff.getSkill().isDance())
+						continue;
+					
+					if (eff.getSkill().getId() == lastCanceledSkillId)
+					{
+						eff.exit(); // this skill already canceled
+						continue;
+					}
+					
+					if (!calcCancelSuccess(eff, cancelLvl, (int)rate))
+						continue;
+					
+					lastCanceledSkillId = eff.getSkill().getId();
+					eff.exit();
+					count--;
+					
+					if (count == 0)
+						break;
+				}
+			}
 		}
+		
 		return true;
 	}
 	

+ 14 - 0
L2J_Server/java/com/l2jserver/gameserver/skills/effects/EffectNegate.java

@@ -52,6 +52,20 @@ public class EffectNegate extends L2Effect
 		{
 			getEffected().stopSkillEffects(negateSkillType, skill.getNegateLvl());
 		}
+		if (skill.getNegateAbnormals() != null)
+		{
+			for (L2Effect effect : getEffected().getAllEffects())
+			{
+				if (effect == null)
+					continue;
+				
+				for (String negateAbnormalType : skill.getNegateAbnormals().keySet())
+				{
+					if (negateAbnormalType.equalsIgnoreCase(effect.getAbnormalType()) && skill.getNegateAbnormals().get(negateAbnormalType) >= effect.getAbnormalLvl())
+						effect.exit();
+				}
+			}
+		}
 		return true;
 	}