L2JMobius

Epilogue Steal Divinity fix

Vinter · 2 · 6361

Offline Vinter

  • Heir
  • **
    • Posts: 15
Steal Divinity greatly changed in High Five, so a few changes had to be done to make it work as it did in Epilgoue.

First, I separated the calcCancelStealEffects into calcCancelEffects and calcStealEffects as to not disrupt the DispelByCategory effect handler with the necessary changes to rate and whatnot.
calcStealEffects has been added to be used in the StealAbnormal effect handler. Rate has been removed as it is 100% in Epilogue.

Code: [Select]
diff --git a/java/org/l2jmobius/gameserver/model/stats/Formulas.java b/java/org/l2jmobius/gameserver/model/stats/Formulas.java
index e098319..c1cedaa 100644
--- a/java/org/l2jmobius/gameserver/model/stats/Formulas.java
+++ b/java/org/l2jmobius/gameserver/model/stats/Formulas.java
@@ -1858,7 +1858,34 @@
  return Rnd.get(100) < rate;
  }
 
- public static List<BuffInfo> calcCancelStealEffects(Creature creature, Creature target, Skill skill, String slot, int rate, int max)
+ public static List<BuffInfo> calcStealEffects(Creature target, int amount)
+ {
+ final List<BuffInfo> canceled = new ArrayList<>(amount);
+
+ // Prevent initialization.
+ final List<BuffInfo> buffs = target.getEffectList().hasBuffs() ? new ArrayList<>(target.getEffectList().getBuffs()) : new ArrayList<>(1);
+ if (target.getEffectList().hasTriggered())
+ {
+ buffs.addAll(target.getEffectList().getTriggered());
+ }
+ if (target.getEffectList().hasDances())
+ {
+ buffs.addAll(target.getEffectList().getDances());
+ }
+
+ for (int i = buffs.size() - 1; i >= 0 && canceled.size() < amount; i--) // reverse order
+ {
+ final BuffInfo info = buffs.get(i);
+ if (!info.getSkill().canBeStolen())
+ {
+ continue;
+ }
+ canceled.add(info);
+ }
+ return canceled;
+ }
+
+ public static List<BuffInfo> calcCancelEffects(Creature creature, Creature target, Skill skill, String slot, int rate, int max)
  {
  final List<BuffInfo> canceled = new ArrayList<>(max);
  switch (slot)



StealAbnormal has been changed to not take Rate nor Slot, as it's not needed anymore and it now uses calcStealEffects formula.

Code: [Select]
diff --git a/dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java b/dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java
index f2522d4..a0d3c17 100644
--- a/dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java
+++ b/dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java
@@ -32,17 +32,12 @@
  */
 public class StealAbnormal extends AbstractEffect
 {
- private final String _slot;
- private final int _rate;
- private final int _max;
+ private final int _amount;
 
  public StealAbnormal(Condition attachCond, Condition applyCond, StatSet set, StatSet params)
  {
  super(attachCond, applyCond, set, params);
-
- _slot = params.getString("slot", null);
- _rate = params.getInt("rate", 0);
- _max = params.getInt("max", 0);
+ _amount = params.getInt("amount", 0);
  }
 
  @Override
@@ -62,7 +57,7 @@
  {
  if ((info.getEffected() != null) && info.getEffected().isPlayer() && (info.getEffector() != info.getEffected()))
  {
- final List<BuffInfo> toSteal = Formulas.calcCancelStealEffects(info.getEffector(), info.getEffected(), info.getSkill(), _slot, _rate, _max);
+ final List<BuffInfo> toSteal = Formulas.calcStealEffects(info.getEffected(), _amount);
  if (toSteal.isEmpty())
  {
  return;





DispelByCategory uses the calcCancelEffects formula.
Code: [Select]
diff --git a/dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java b/dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java
index 301042f..a1c8b53 100644
--- a/dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java
+++ b/dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java
@@ -64,7 +64,7 @@
  return;
  }
 
- final List<BuffInfo> canceled = Formulas.calcCancelStealEffects(info.getEffector(), info.getEffected(), info.getSkill(), _slot, _rate, _max);
+ final List<BuffInfo> canceled = Formulas.calcCancelEffects(info.getEffector(), info.getEffected(), info.getSkill(), _slot, _rate, _max);
  for (BuffInfo can : canceled)
  {
  info.getEffected().getEffectList().stopSkillEffects(true, can.getSkill());


Lastly the XML of the only two skills that use StealAbnormal effect handler are changed to reflect the StealAbnormal handler.

Code: [Select]
diff --git a/dist/game/data/stats/skills/01400-01499.xml b/dist/game/data/stats/skills/01400-01499.xml
index 0290889..ebe85a2 100644
--- a/dist/game/data/stats/skills/01400-01499.xml
+++ b/dist/game/data/stats/skills/01400-01499.xml
@@ -1369,7 +1369,7 @@
  <set name="targetType" val="ONE" />
  <for>
  <effect name="StealAbnormal">
- <param slot="buff" rate="25" max="#maxNegated" />
+ <param amount="#maxNegated" />
  </effect>
  </for>
  </skill>
diff --git a/dist/game/data/stats/skills/08300-08399.xml b/dist/game/data/stats/skills/08300-08399.xml
index 682064f..a4bf6ea 100644
--- a/dist/game/data/stats/skills/08300-08399.xml
+++ b/dist/game/data/stats/skills/08300-08399.xml
@@ -570,7 +570,7 @@
  <set name="targetType" val="ONE" />
  <for>
  <effect name="StealAbnormal">
- <param slot="buff" rate="25" max="3" />
+ <param amount="3" />
  </effect>
  </for>
  </skill>