Fixed stacking same type buffs.

Adapted from: L2jUnity free files.
This commit is contained in:
MobiusDev
2017-12-05 19:35:57 +00:00
parent b597f657e5
commit 58abbcf6ec
14 changed files with 81 additions and 286 deletions

View File

@@ -16,9 +16,9 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.Arrays;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -37,19 +37,7 @@ public final class BlockAbnormalSlot extends AbstractEffect
public BlockAbnormalSlot(StatsSet params) public BlockAbnormalSlot(StatsSet params)
{ {
final String blockAbnormalSlots = params.getString("slot", null); _blockAbnormalSlots = Arrays.stream(params.getString("dispel").split(";")).map(slot -> Enum.valueOf(AbnormalType.class, slot)).collect(Collectors.toSet());
if ((blockAbnormalSlots != null) && !blockAbnormalSlots.isEmpty())
{
_blockAbnormalSlots = new HashSet<>();
for (String slot : blockAbnormalSlots.split(";"))
{
_blockAbnormalSlots.add(AbnormalType.getAbnormalType(slot));
}
}
else
{
_blockAbnormalSlots = Collections.<AbnormalType> emptySet();
}
} }
@Override @Override

View File

@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.HashSet;
import java.util.HashMap; import java.util.Set;
import java.util.Map;
import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
@@ -35,26 +34,17 @@ import com.l2jmobius.gameserver.model.skills.Skill;
*/ */
public final class DispelBySlotProbability extends AbstractEffect public final class DispelBySlotProbability extends AbstractEffect
{ {
private final String _dispel; private final Set<AbnormalType> _dispelAbnormals;
private final Map<AbnormalType, Short> _dispelAbnormals;
private final int _rate; private final int _rate;
public DispelBySlotProbability(StatsSet params) public DispelBySlotProbability(StatsSet params)
{ {
_dispel = params.getString("dispel"); final String[] dispelEffects = params.getString("dispel").split(";");
_rate = params.getInt("rate", 100); _rate = params.getInt("rate", 100);
if ((_dispel != null) && !_dispel.isEmpty()) _dispelAbnormals = new HashSet<>(dispelEffects.length);
for (String slot : dispelEffects)
{ {
_dispelAbnormals = new HashMap<>(); _dispelAbnormals.add(Enum.valueOf(AbnormalType.class, slot));
for (String ngtStack : _dispel.split(";"))
{
String[] ngt = ngtStack.split(",");
_dispelAbnormals.put(AbnormalType.getAbnormalType(ngt[0]), Short.MAX_VALUE);
}
}
else
{
_dispelAbnormals = Collections.<AbnormalType, Short> emptyMap();
} }
} }
@@ -73,31 +63,12 @@ public final class DispelBySlotProbability extends AbstractEffect
@Override @Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item) public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{ {
if (_dispelAbnormals.isEmpty()) if (effected == null)
{ {
return; return;
} }
// Dispel transformations (buff and by GM) // The effectlist should already check if it has buff with this abnormal type or not.
if ((Rnd.get(100) < _rate)) effected.getEffectList().stopEffects(info -> !info.getSkill().isIrreplacableBuff() && (Rnd.get(100) < _rate) && _dispelAbnormals.contains(info.getSkill().getAbnormalType()), true, true);
{
final Short transformToDispel = _dispelAbnormals.get(AbnormalType.TRANSFORM);
if ((transformToDispel != null) && ((transformToDispel == effected.getTransformationId()) || (transformToDispel < 0)))
{
effected.stopTransformation(true);
}
}
effected.getEffectList().stopEffects(info ->
{
// We have already dealt with transformation from above.
if (info.isAbnormalType(AbnormalType.TRANSFORM))
{
return false;
}
final Short abnormalLevel = (Rnd.get(100) < _rate) ? _dispelAbnormals.get(info.getSkill().getAbnormalType()) : null;
return (abnormalLevel != null) && ((abnormalLevel < 0) || (abnormalLevel >= info.getSkill().getAbnormalLvl()));
}, true, true);
} }
} }

View File

@@ -943,7 +943,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>IMPROVE_VAMPIRIC_HASTE,-1;ATTACK_TIME_DOWN,-1;VAMPIRIC_ATTACK,-1;CASTING_TIME_DOWN,-1</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
@@ -1043,7 +1043,7 @@
<POISON>50</POISON> <POISON>50</POISON>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_ALIGNMENT,-1;ARMOR_UNHOLY,-1;DANCE_OF_LIGHT,-1;SONG_OF_INVOCATION,-1;RESIST_BLEEDING,-1;RESIST_SHOCK,-1</dispel> <dispel>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot> <slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot>
@@ -1088,7 +1088,7 @@
<SLEEP>50</SLEEP> <SLEEP>50</SLEEP>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_PROTECTION,-1;RESIST_DEBUFF_DISPEL,-1</dispel> <dispel>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot> <slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot>
@@ -1220,7 +1220,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>MULTI_BUFF,-1;COUNTER_CRITICAL,-1</dispel> <dispel>MULTI_BUFF;COUNTER_CRITICAL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>MULTI_BUFF;COUNTER_CRITICAL</slot> <slot>MULTI_BUFF;COUNTER_CRITICAL</slot>

View File

@@ -16,9 +16,9 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.Arrays;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -37,19 +37,7 @@ public final class BlockAbnormalSlot extends AbstractEffect
public BlockAbnormalSlot(StatsSet params) public BlockAbnormalSlot(StatsSet params)
{ {
final String blockAbnormalSlots = params.getString("slot", null); _blockAbnormalSlots = Arrays.stream(params.getString("dispel").split(";")).map(slot -> Enum.valueOf(AbnormalType.class, slot)).collect(Collectors.toSet());
if ((blockAbnormalSlots != null) && !blockAbnormalSlots.isEmpty())
{
_blockAbnormalSlots = new HashSet<>();
for (String slot : blockAbnormalSlots.split(";"))
{
_blockAbnormalSlots.add(AbnormalType.getAbnormalType(slot));
}
}
else
{
_blockAbnormalSlots = Collections.<AbnormalType> emptySet();
}
} }
@Override @Override

View File

@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.HashSet;
import java.util.HashMap; import java.util.Set;
import java.util.Map;
import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
@@ -35,26 +34,17 @@ import com.l2jmobius.gameserver.model.skills.Skill;
*/ */
public final class DispelBySlotProbability extends AbstractEffect public final class DispelBySlotProbability extends AbstractEffect
{ {
private final String _dispel; private final Set<AbnormalType> _dispelAbnormals;
private final Map<AbnormalType, Short> _dispelAbnormals;
private final int _rate; private final int _rate;
public DispelBySlotProbability(StatsSet params) public DispelBySlotProbability(StatsSet params)
{ {
_dispel = params.getString("dispel"); final String[] dispelEffects = params.getString("dispel").split(";");
_rate = params.getInt("rate", 100); _rate = params.getInt("rate", 100);
if ((_dispel != null) && !_dispel.isEmpty()) _dispelAbnormals = new HashSet<>(dispelEffects.length);
for (String slot : dispelEffects)
{ {
_dispelAbnormals = new HashMap<>(); _dispelAbnormals.add(Enum.valueOf(AbnormalType.class, slot));
for (String ngtStack : _dispel.split(";"))
{
String[] ngt = ngtStack.split(",");
_dispelAbnormals.put(AbnormalType.getAbnormalType(ngt[0]), Short.MAX_VALUE);
}
}
else
{
_dispelAbnormals = Collections.<AbnormalType, Short> emptyMap();
} }
} }
@@ -73,31 +63,12 @@ public final class DispelBySlotProbability extends AbstractEffect
@Override @Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item) public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{ {
if (_dispelAbnormals.isEmpty()) if (effected == null)
{ {
return; return;
} }
// Dispel transformations (buff and by GM) // The effectlist should already check if it has buff with this abnormal type or not.
if ((Rnd.get(100) < _rate)) effected.getEffectList().stopEffects(info -> !info.getSkill().isIrreplacableBuff() && (Rnd.get(100) < _rate) && _dispelAbnormals.contains(info.getSkill().getAbnormalType()), true, true);
{
final Short transformToDispel = _dispelAbnormals.get(AbnormalType.TRANSFORM);
if ((transformToDispel != null) && ((transformToDispel == effected.getTransformationId()) || (transformToDispel < 0)))
{
effected.stopTransformation(true);
}
}
effected.getEffectList().stopEffects(info ->
{
// We have already dealt with transformation from above.
if (info.isAbnormalType(AbnormalType.TRANSFORM))
{
return false;
}
final Short abnormalLevel = (Rnd.get(100) < _rate) ? _dispelAbnormals.get(info.getSkill().getAbnormalType()) : null;
return (abnormalLevel != null) && ((abnormalLevel < 0) || (abnormalLevel >= info.getSkill().getAbnormalLvl()));
}, true, true);
} }
} }

View File

@@ -943,7 +943,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>IMPROVE_VAMPIRIC_HASTE,-1;ATTACK_TIME_DOWN,-1;VAMPIRIC_ATTACK,-1;CASTING_TIME_DOWN,-1</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
@@ -1043,7 +1043,7 @@
<POISON>50</POISON> <POISON>50</POISON>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_ALIGNMENT,-1;ARMOR_UNHOLY,-1;DANCE_OF_LIGHT,-1;SONG_OF_INVOCATION,-1;RESIST_BLEEDING,-1;RESIST_SHOCK,-1</dispel> <dispel>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot> <slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot>
@@ -1088,7 +1088,7 @@
<SLEEP>50</SLEEP> <SLEEP>50</SLEEP>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_PROTECTION,-1;RESIST_DEBUFF_DISPEL,-1</dispel> <dispel>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot> <slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot>
@@ -1220,7 +1220,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>MULTI_BUFF,-1;COUNTER_CRITICAL,-1</dispel> <dispel>MULTI_BUFF;COUNTER_CRITICAL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>MULTI_BUFF;COUNTER_CRITICAL</slot> <slot>MULTI_BUFF;COUNTER_CRITICAL</slot>

View File

@@ -16,9 +16,9 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.Arrays;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -37,19 +37,7 @@ public final class BlockAbnormalSlot extends AbstractEffect
public BlockAbnormalSlot(StatsSet params) public BlockAbnormalSlot(StatsSet params)
{ {
final String blockAbnormalSlots = params.getString("slot", null); _blockAbnormalSlots = Arrays.stream(params.getString("dispel").split(";")).map(slot -> Enum.valueOf(AbnormalType.class, slot)).collect(Collectors.toSet());
if ((blockAbnormalSlots != null) && !blockAbnormalSlots.isEmpty())
{
_blockAbnormalSlots = new HashSet<>();
for (String slot : blockAbnormalSlots.split(";"))
{
_blockAbnormalSlots.add(AbnormalType.getAbnormalType(slot));
}
}
else
{
_blockAbnormalSlots = Collections.<AbnormalType> emptySet();
}
} }
@Override @Override

View File

@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.HashSet;
import java.util.HashMap; import java.util.Set;
import java.util.Map;
import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
@@ -35,26 +34,17 @@ import com.l2jmobius.gameserver.model.skills.Skill;
*/ */
public final class DispelBySlotProbability extends AbstractEffect public final class DispelBySlotProbability extends AbstractEffect
{ {
private final String _dispel; private final Set<AbnormalType> _dispelAbnormals;
private final Map<AbnormalType, Short> _dispelAbnormals;
private final int _rate; private final int _rate;
public DispelBySlotProbability(StatsSet params) public DispelBySlotProbability(StatsSet params)
{ {
_dispel = params.getString("dispel"); final String[] dispelEffects = params.getString("dispel").split(";");
_rate = params.getInt("rate", 100); _rate = params.getInt("rate", 100);
if ((_dispel != null) && !_dispel.isEmpty()) _dispelAbnormals = new HashSet<>(dispelEffects.length);
for (String slot : dispelEffects)
{ {
_dispelAbnormals = new HashMap<>(); _dispelAbnormals.add(Enum.valueOf(AbnormalType.class, slot));
for (String ngtStack : _dispel.split(";"))
{
String[] ngt = ngtStack.split(",");
_dispelAbnormals.put(AbnormalType.getAbnormalType(ngt[0]), Short.MAX_VALUE);
}
}
else
{
_dispelAbnormals = Collections.<AbnormalType, Short> emptyMap();
} }
} }
@@ -73,31 +63,12 @@ public final class DispelBySlotProbability extends AbstractEffect
@Override @Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item) public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{ {
if (_dispelAbnormals.isEmpty()) if (effected == null)
{ {
return; return;
} }
// Dispel transformations (buff and by GM) // The effectlist should already check if it has buff with this abnormal type or not.
if ((Rnd.get(100) < _rate)) effected.getEffectList().stopEffects(info -> !info.getSkill().isIrreplacableBuff() && (Rnd.get(100) < _rate) && _dispelAbnormals.contains(info.getSkill().getAbnormalType()), true, true);
{
final Short transformToDispel = _dispelAbnormals.get(AbnormalType.TRANSFORM);
if ((transformToDispel != null) && ((transformToDispel == effected.getTransformationId()) || (transformToDispel < 0)))
{
effected.stopTransformation(true);
}
}
effected.getEffectList().stopEffects(info ->
{
// We have already dealt with transformation from above.
if (info.isAbnormalType(AbnormalType.TRANSFORM))
{
return false;
}
final Short abnormalLevel = (Rnd.get(100) < _rate) ? _dispelAbnormals.get(info.getSkill().getAbnormalType()) : null;
return (abnormalLevel != null) && ((abnormalLevel < 0) || (abnormalLevel >= info.getSkill().getAbnormalLvl()));
}, true, true);
} }
} }

View File

@@ -943,7 +943,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>IMPROVE_VAMPIRIC_HASTE,-1;ATTACK_TIME_DOWN,-1;VAMPIRIC_ATTACK,-1;CASTING_TIME_DOWN,-1</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
@@ -1043,7 +1043,7 @@
<POISON>50</POISON> <POISON>50</POISON>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_ALIGNMENT,-1;ARMOR_UNHOLY,-1;DANCE_OF_LIGHT,-1;SONG_OF_INVOCATION,-1;RESIST_BLEEDING,-1;RESIST_SHOCK,-1</dispel> <dispel>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot> <slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot>
@@ -1088,7 +1088,7 @@
<SLEEP>50</SLEEP> <SLEEP>50</SLEEP>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_PROTECTION,-1;RESIST_DEBUFF_DISPEL,-1</dispel> <dispel>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot> <slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot>
@@ -1220,7 +1220,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>MULTI_BUFF,-1;COUNTER_CRITICAL,-1</dispel> <dispel>MULTI_BUFF;COUNTER_CRITICAL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>MULTI_BUFF;COUNTER_CRITICAL</slot> <slot>MULTI_BUFF;COUNTER_CRITICAL</slot>

View File

@@ -16,9 +16,9 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.Arrays;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -37,19 +37,7 @@ public final class BlockAbnormalSlot extends AbstractEffect
public BlockAbnormalSlot(StatsSet params) public BlockAbnormalSlot(StatsSet params)
{ {
final String blockAbnormalSlots = params.getString("slot", null); _blockAbnormalSlots = Arrays.stream(params.getString("dispel").split(";")).map(slot -> Enum.valueOf(AbnormalType.class, slot)).collect(Collectors.toSet());
if ((blockAbnormalSlots != null) && !blockAbnormalSlots.isEmpty())
{
_blockAbnormalSlots = new HashSet<>();
for (String slot : blockAbnormalSlots.split(";"))
{
_blockAbnormalSlots.add(AbnormalType.getAbnormalType(slot));
}
}
else
{
_blockAbnormalSlots = Collections.<AbnormalType> emptySet();
}
} }
@Override @Override

View File

@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.HashSet;
import java.util.HashMap; import java.util.Set;
import java.util.Map;
import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
@@ -35,26 +34,17 @@ import com.l2jmobius.gameserver.model.skills.Skill;
*/ */
public final class DispelBySlotProbability extends AbstractEffect public final class DispelBySlotProbability extends AbstractEffect
{ {
private final String _dispel; private final Set<AbnormalType> _dispelAbnormals;
private final Map<AbnormalType, Short> _dispelAbnormals;
private final int _rate; private final int _rate;
public DispelBySlotProbability(StatsSet params) public DispelBySlotProbability(StatsSet params)
{ {
_dispel = params.getString("dispel"); final String[] dispelEffects = params.getString("dispel").split(";");
_rate = params.getInt("rate", 100); _rate = params.getInt("rate", 100);
if ((_dispel != null) && !_dispel.isEmpty()) _dispelAbnormals = new HashSet<>(dispelEffects.length);
for (String slot : dispelEffects)
{ {
_dispelAbnormals = new HashMap<>(); _dispelAbnormals.add(Enum.valueOf(AbnormalType.class, slot));
for (String ngtStack : _dispel.split(";"))
{
String[] ngt = ngtStack.split(",");
_dispelAbnormals.put(AbnormalType.getAbnormalType(ngt[0]), Short.MAX_VALUE);
}
}
else
{
_dispelAbnormals = Collections.<AbnormalType, Short> emptyMap();
} }
} }
@@ -73,31 +63,12 @@ public final class DispelBySlotProbability extends AbstractEffect
@Override @Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item) public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{ {
if (_dispelAbnormals.isEmpty()) if (effected == null)
{ {
return; return;
} }
// Dispel transformations (buff and by GM) // The effectlist should already check if it has buff with this abnormal type or not.
if ((Rnd.get(100) < _rate)) effected.getEffectList().stopEffects(info -> !info.getSkill().isIrreplacableBuff() && (Rnd.get(100) < _rate) && _dispelAbnormals.contains(info.getSkill().getAbnormalType()), true, true);
{
final Short transformToDispel = _dispelAbnormals.get(AbnormalType.TRANSFORM);
if ((transformToDispel != null) && ((transformToDispel == effected.getTransformationId()) || (transformToDispel < 0)))
{
effected.stopTransformation(true);
}
}
effected.getEffectList().stopEffects(info ->
{
// We have already dealt with transformation from above.
if (info.isAbnormalType(AbnormalType.TRANSFORM))
{
return false;
}
final Short abnormalLevel = (Rnd.get(100) < _rate) ? _dispelAbnormals.get(info.getSkill().getAbnormalType()) : null;
return (abnormalLevel != null) && ((abnormalLevel < 0) || (abnormalLevel >= info.getSkill().getAbnormalLvl()));
}, true, true);
} }
} }

View File

@@ -923,7 +923,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>IMPROVE_VAMPIRIC_HASTE,-1;ATTACK_TIME_DOWN,-1;VAMPIRIC_ATTACK,-1;CASTING_TIME_DOWN,-1</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel> <dispel>IMPROVE_VAMPIRIC_HASTE;ATTACK_TIME_DOWN;VAMPIRIC_ATTACK;CASTING_TIME_DOWN</dispel>
@@ -1023,7 +1023,7 @@
<POISON>50</POISON> <POISON>50</POISON>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_ALIGNMENT,-1;ARMOR_UNHOLY,-1;DANCE_OF_LIGHT,-1;SONG_OF_INVOCATION,-1;RESIST_BLEEDING,-1;RESIST_SHOCK,-1</dispel> <dispel>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot> <slot>DANCE_OF_ALIGNMENT;ARMOR_UNHOLY;DANCE_OF_LIGHT;SONG_OF_INVOCATION;RESIST_BLEEDING;RESIST_SHOCK</slot>
@@ -1068,7 +1068,7 @@
<SLEEP>50</SLEEP> <SLEEP>50</SLEEP>
</effect> </effect>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>DANCE_OF_PROTECTION,-1;RESIST_DEBUFF_DISPEL,-1</dispel> <dispel>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot> <slot>DANCE_OF_PROTECTION;RESIST_DEBUFF_DISPEL</slot>
@@ -1200,7 +1200,7 @@
<affectScope>SINGLE</affectScope> <affectScope>SINGLE</affectScope>
<effects> <effects>
<effect name="DispelBySlotProbability"> <effect name="DispelBySlotProbability">
<dispel>MULTI_BUFF,-1;COUNTER_CRITICAL,-1</dispel> <dispel>MULTI_BUFF;COUNTER_CRITICAL</dispel>
</effect> </effect>
<effect name="BlockAbnormalSlot"> <effect name="BlockAbnormalSlot">
<slot>MULTI_BUFF;COUNTER_CRITICAL</slot> <slot>MULTI_BUFF;COUNTER_CRITICAL</slot>

View File

@@ -16,9 +16,9 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.Arrays;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -37,19 +37,7 @@ public final class BlockAbnormalSlot extends AbstractEffect
public BlockAbnormalSlot(StatsSet params) public BlockAbnormalSlot(StatsSet params)
{ {
final String blockAbnormalSlots = params.getString("slot", null); _blockAbnormalSlots = Arrays.stream(params.getString("dispel").split(";")).map(slot -> Enum.valueOf(AbnormalType.class, slot)).collect(Collectors.toSet());
if ((blockAbnormalSlots != null) && !blockAbnormalSlots.isEmpty())
{
_blockAbnormalSlots = new HashSet<>();
for (String slot : blockAbnormalSlots.split(";"))
{
_blockAbnormalSlots.add(AbnormalType.getAbnormalType(slot));
}
}
else
{
_blockAbnormalSlots = Collections.<AbnormalType> emptySet();
}
} }
@Override @Override

View File

@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Collections; import java.util.HashSet;
import java.util.HashMap; import java.util.Set;
import java.util.Map;
import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
@@ -35,26 +34,17 @@ import com.l2jmobius.gameserver.model.skills.Skill;
*/ */
public final class DispelBySlotProbability extends AbstractEffect public final class DispelBySlotProbability extends AbstractEffect
{ {
private final String _dispel; private final Set<AbnormalType> _dispelAbnormals;
private final Map<AbnormalType, Short> _dispelAbnormals;
private final int _rate; private final int _rate;
public DispelBySlotProbability(StatsSet params) public DispelBySlotProbability(StatsSet params)
{ {
_dispel = params.getString("dispel"); final String[] dispelEffects = params.getString("dispel").split(";");
_rate = params.getInt("rate", 100); _rate = params.getInt("rate", 100);
if ((_dispel != null) && !_dispel.isEmpty()) _dispelAbnormals = new HashSet<>(dispelEffects.length);
for (String slot : dispelEffects)
{ {
_dispelAbnormals = new HashMap<>(); _dispelAbnormals.add(Enum.valueOf(AbnormalType.class, slot));
for (String ngtStack : _dispel.split(";"))
{
String[] ngt = ngtStack.split(",");
_dispelAbnormals.put(AbnormalType.getAbnormalType(ngt[0]), Short.MAX_VALUE);
}
}
else
{
_dispelAbnormals = Collections.<AbnormalType, Short> emptyMap();
} }
} }
@@ -73,31 +63,12 @@ public final class DispelBySlotProbability extends AbstractEffect
@Override @Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item) public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{ {
if (_dispelAbnormals.isEmpty()) if (effected == null)
{ {
return; return;
} }
// Dispel transformations (buff and by GM) // The effectlist should already check if it has buff with this abnormal type or not.
if ((Rnd.get(100) < _rate)) effected.getEffectList().stopEffects(info -> !info.getSkill().isIrreplacableBuff() && (Rnd.get(100) < _rate) && _dispelAbnormals.contains(info.getSkill().getAbnormalType()), true, true);
{
final Short transformToDispel = _dispelAbnormals.get(AbnormalType.TRANSFORM);
if ((transformToDispel != null) && ((transformToDispel == effected.getTransformationId()) || (transformToDispel < 0)))
{
effected.stopTransformation(true);
}
}
effected.getEffectList().stopEffects(info ->
{
// We have already dealt with transformation from above.
if (info.isAbnormalType(AbnormalType.TRANSFORM))
{
return false;
}
final Short abnormalLevel = (Rnd.get(100) < _rate) ? _dispelAbnormals.get(info.getSkill().getAbnormalType()) : null;
return (abnormalLevel != null) && ((abnormalLevel < 0) || (abnormalLevel >= info.getSkill().getAbnormalLvl()));
}, true, true);
} }
} }