Browse Source

support for effect negate (effectType and effectAbnormalLvl has to be set on skill)

janiii 15 years ago
parent
commit
2b95546ff1

+ 48 - 0
L2_GameServer/java/com/l2jserver/gameserver/model/CharEffectList.java

@@ -32,6 +32,7 @@ import com.l2jserver.gameserver.network.serverpackets.ExOlympiadSpelledInfo;
 import com.l2jserver.gameserver.network.serverpackets.PartySpelled;
 import com.l2jserver.gameserver.network.serverpackets.PartySpelled;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.templates.skills.L2EffectType;
 import com.l2jserver.gameserver.templates.skills.L2EffectType;
+import com.l2jserver.gameserver.templates.skills.L2SkillType;
 
 
 import javolution.util.FastList;
 import javolution.util.FastList;
 import javolution.util.FastMap;
 import javolution.util.FastMap;
@@ -494,6 +495,53 @@ public class CharEffectList
 		}
 		}
 		FastList.recycle(temp);
 		FastList.recycle(temp);
 	}
 	}
+	
+	/**
+	 * Exits all effects created by a specific skill type
+	 * @param skillType skill type
+	 */
+	public final void stopSkillEffects(L2SkillType skillType, int negateLvl)
+	{
+		// Go through all active skills effects
+		FastList<L2Effect> temp = FastList.newInstance();
+		if (_buffs != null) 
+		{
+			synchronized (_buffs)
+			{
+				if (!_buffs.isEmpty())
+				{
+					for (L2Effect e : _buffs)
+					{
+						if (e != null && (e.getSkill().getSkillType() == skillType || (e.getSkill().getEffectType() != null && e.getSkill().getEffectType() == skillType)) 
+								&& (negateLvl == -1 || (e.getSkill().getEffectType() != null && e.getSkill().getEffectAbnormalLvl() >= 0 && e.getSkill().getEffectAbnormalLvl() <= negateLvl) || (e.getSkill().getAbnormalLvl() >= 0 && e.getSkill().getAbnormalLvl() <= negateLvl)))
+							temp.add(e);
+					}
+				}
+			}
+		}
+		if (_debuffs != null) 
+		{
+			synchronized (_debuffs)
+			{
+				if (!_debuffs.isEmpty())
+				{
+					for (L2Effect e : _debuffs)
+					{
+						if (e != null && (e.getSkill().getSkillType() == skillType || (e.getSkill().getEffectType() != null && e.getSkill().getEffectType() == skillType)) 
+								&& (negateLvl == -1 || (e.getSkill().getEffectType() != null && e.getSkill().getEffectAbnormalLvl() >= 0 && e.getSkill().getEffectAbnormalLvl() <= negateLvl) || (e.getSkill().getAbnormalLvl() >= 0 && e.getSkill().getAbnormalLvl() <= negateLvl)))
+							temp.add(e);
+					}
+				}
+			}
+		}
+		if (!temp.isEmpty())
+		{
+			for (L2Effect e : temp)
+				if (e != null)
+					e.exit();
+		}
+		FastList.recycle(temp);
+	}
 
 
 	/**
 	/**
 	 * Exits all buffs effects of the skills with "removedOnAnyAction" set.
 	 * Exits all buffs effects of the skills with "removedOnAnyAction" set.

+ 24 - 4
L2_GameServer/java/com/l2jserver/gameserver/model/actor/L2Character.java

@@ -2976,7 +2976,27 @@ public abstract class L2Character extends L2Object
 	{
 	{
 		_effects.stopSkillEffects(skillId);
 		_effects.stopSkillEffects(skillId);
 	}
 	}
-
+	
+	/**
+	 * Stop and remove the L2Effects corresponding to the L2SkillType and update client magic icon.<BR><BR>
+	 *
+	 * <B><U> Concept</U> :</B><BR><BR>
+	 * All active skills effects in progress on the L2Character are identified in ConcurrentHashMap(Integer,L2Effect) <B>_effects</B>.
+	 * The Integer key of _effects is the L2Skill Identifier that has created the L2Effect.<BR><BR>
+	 *
+	 * @param skillType The L2SkillType of the L2Effect to remove from _effects
+	 *
+	 */
+	public final void stopSkillEffects(L2SkillType skillType, int negateLvl)
+	{
+		_effects.stopSkillEffects(skillType, negateLvl);
+	}
+	
+	public final void stopSkillEffects(L2SkillType skillType)
+	{
+		_effects.stopSkillEffects(skillType, -1);
+	}
+	
 	/**
 	/**
 	 * Stop and remove all L2Effect of the selected type (ex : BUFF, DMG_OVER_TIME...) from the L2Character and update client magic icon.<BR><BR>
 	 * Stop and remove all L2Effect of the selected type (ex : BUFF, DMG_OVER_TIME...) from the L2Character and update client magic icon.<BR><BR>
 	 *
 	 *
@@ -3131,10 +3151,10 @@ public abstract class L2Character extends L2Object
             removeEffect(effect);
             removeEffect(effect);
             if (effect.getSkill().getNegateId().length != 0)
             if (effect.getSkill().getNegateId().length != 0)
             {
             {
-            	for (int i = 0; i < effect.getSkill().getNegateId().length; i++)
+            	for (int negateSkillId : effect.getSkill().getNegateId())
             	{
             	{
-            		if (effect.getSkill().getNegateId()[i] != 0)
-            			stopSkillEffects(effect.getSkill().getNegateId()[i]);
+            		if (negateSkillId != 0)
+            			stopSkillEffects(negateSkillId);
             	}
             	}
             }
             }
         }
         }

+ 9 - 7
L2_GameServer/java/com/l2jserver/gameserver/skills/effects/EffectNegate.java

@@ -19,6 +19,7 @@ import com.l2jserver.gameserver.model.L2Skill;
 import com.l2jserver.gameserver.skills.Env;
 import com.l2jserver.gameserver.skills.Env;
 import com.l2jserver.gameserver.templates.effects.EffectTemplate;
 import com.l2jserver.gameserver.templates.effects.EffectTemplate;
 import com.l2jserver.gameserver.templates.skills.L2EffectType;
 import com.l2jserver.gameserver.templates.skills.L2EffectType;
+import com.l2jserver.gameserver.templates.skills.L2SkillType;
 
 
 /**
 /**
  * 
  * 
@@ -42,13 +43,14 @@ public class EffectNegate extends L2Effect
 	{
 	{
 		L2Skill skill = getSkill();
 		L2Skill skill = getSkill();
 		
 		
-		if (skill.getNegateId().length != 0)
+		for (int negateSkillId : skill.getNegateId())
 		{
 		{
-			for (int i = 0; i < skill.getNegateId().length; i++)
-			{
-				if (skill.getNegateId()[i] != 0)
-					getEffected().stopSkillEffects(skill.getNegateId()[i]);
-			}
+			if (negateSkillId != 0)
+				getEffected().stopSkillEffects(negateSkillId);
+		}
+		for (L2SkillType negateSkillType : skill.getNegateStats())
+		{
+			getEffected().stopSkillEffects(negateSkillType, skill.getNegateLvl());
 		}
 		}
 		return true;
 		return true;
 	}
 	}
@@ -58,4 +60,4 @@ public class EffectNegate extends L2Effect
 	{
 	{
 		return false;
 		return false;
 	}
 	}
-}
+}