L2JMobius

C6 Cancellation skill - Return lost buffs to the player after a few seconds.

G-hamsteR · 9 · 5820

Online G-hamsteR

  • Viscount
  • *****
    • Posts: 328
Hello,

With this code you can return all the buffs that were removed from a player using the Cancellation skill.

Code: [Select]
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java
index a1fffe9..3b0f603 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java
@@ -17,9 +17,11 @@
 package org.l2jmobius.gameserver.handler.skillhandlers;
 
 import java.io.IOException;
+import java.util.Vector;
 import java.util.logging.Logger;
 
 import org.l2jmobius.Config;
+import org.l2jmobius.commons.concurrent.ThreadPool;
 import org.l2jmobius.commons.util.Rnd;
 import org.l2jmobius.gameserver.ai.AttackableAI;
 import org.l2jmobius.gameserver.ai.CtrlEvent;
@@ -27,6 +29,7 @@
 import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
 import org.l2jmobius.gameserver.handler.ISkillHandler;
 import org.l2jmobius.gameserver.handler.SkillHandler;
+import org.l2jmobius.gameserver.model.CustomCancelTask;
 import org.l2jmobius.gameserver.model.Effect;
 import org.l2jmobius.gameserver.model.Effect.EffectType;
 import org.l2jmobius.gameserver.model.Skill;
@@ -427,6 +430,7 @@
  }
  break;
  }
+ Vector<Skill> cancelledBuffs = new Vector<>();
  int lvlmodifier = 52 + (skill.getLevel() * 2);
  if (skill.getLevel() == 12)
  {
@@ -480,6 +484,12 @@
 
  if (Rnd.get(100) < rate)
  {
+ // store them
+ if (!cancelledBuffs.contains(e.getSkill()))
+ {
+ cancelledBuffs.add(e.getSkill());
+ }
+ // cancel them
  e.exit(true);
  maxfive--;
  if (maxfive == 0)
@@ -490,6 +500,10 @@
  }
  }
  }
+ if (cancelledBuffs.size() > 0)
+ {
+ ThreadPool.schedule(new CustomCancelTask((PlayerInstance) target, cancelledBuffs), 20 * 1000);
+ }
  }
  else if (creature instanceof PlayerInstance)
  {

diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CustomCancelTask.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CustomCancelTask.java
new file mode 100644
index 0000000..4059087
--- /dev/null
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CustomCancelTask.java
@@ -0,0 +1,35 @@
+package org.l2jmobius.gameserver.model;
+
+import java.util.Vector;
+
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+
+public class CustomCancelTask implements Runnable
+{
+ private PlayerInstance _player = null;
+ private Vector<Skill> _buffs = null;
+
+ public CustomCancelTask(PlayerInstance _player, Vector<Skill> _buffs)
+ {
+ this._player = _player;
+ this._buffs = _buffs;
+ }
+
+ @Override
+ public void run()
+ {
+ if ((_player == null) || !_player.isOnline())
+ {
+ return;
+ }
+ for (Skill s : _buffs)
+ {
+ if (s == null)
+ {
+ continue;
+ }
+
+ s.getEffects(_player, _player);
+ }
+ }
+}
\ No newline at end of file

Buffs are returned in 20 seconds, but you can change it by editing this line: ThreadPool.schedule(new CustomCancelTask((PlayerInstance) target, cancelledBuffs), 20 * 1000);




Online G-hamsteR

  • Viscount
  • *****
    • Posts: 328
I would assign a variable for that 20.

If you want to commit it, I can add a config to config/custom/Other.ini where you can enable/disable and specify seconds. For my personal use, I just added the seconds without variables or configs.  ;D




Online Mobius

  • Distinguished King
  • *****
    • Posts: 16011
I would assign a variable for that 20.

If you want to commit it, I can add a config to config/custom/Other.ini where you can enable/disable and specify seconds. For my personal use, I just added the seconds without variables or configs.  ;D

If you can make configs.


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 328
Here you go. I haven't tested it, but I see no reason for it not to work. I will give it a try later today :)

Code: [Select]
diff --git dist/game/config/custom/Other.ini dist/game/config/custom/Other.ini
index e0d7bed..9797bb3 100644
--- dist/game/config/custom/Other.ini
+++ dist/game/config/custom/Other.ini
@@ -124,6 +124,16 @@
 # Retail: False
 KeepSubClassSkills = False
 
+# Restore lost buffs on Cancellation skill after a few seconds.
+# Input the value in seconds. Type 0 to disable.
+# Default : 0
+SecondsToReturnCancelledBuffs = 0
+
 # Allow players to use the .online command.
 # Displays the number of online players.
 # Default : False

diff --git java/org/l2jmobius/Config.java java/org/l2jmobius/Config.java
index efe7330..7248345 100644
--- java/org/l2jmobius/Config.java
+++ java/org/l2jmobius/Config.java
@@ -647,6 +648,7 @@
  public static boolean CASTLE_CROWN;
  public static boolean CASTLE_CIRCLETS;
  public static boolean KEEP_SUBCLASS_SKILLS;
+ public static int RESTORE_CANCELLED_BUFFS_SECONDS;
  public static boolean CHAR_TITLE;
  public static String ADD_CHAR_TITLE;
  public static boolean NOBLE_CUSTOM_ITEMS;
@@ -1865,6 +1868,7 @@
  ALLOW_DETAILED_STATS_VIEW = customServerConfig.getBoolean("AllowDetailedStatsView", false);
  ALLOW_ONLINE_VIEW = customServerConfig.getBoolean("AllowOnlineView", false);
  KEEP_SUBCLASS_SKILLS = customServerConfig.getBoolean("KeepSubClassSkills", false);
+ RESTORE_CANCELLED_BUFFS_SECONDS = customServerConfig.getInt("SecondsToReturnCancelledBuffs", 800);
  ALLOWED_SKILLS = customServerConfig.getString("AllowedSkills", "541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,617,618,619");
  ALLOWED_SKILLS_LIST = new ArrayList<>();
  for (String id : ALLOWED_SKILLS.trim().split(","))
diff --git java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java
index a1fffe9..30efa3a 100644
--- java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java
+++ java/org/l2jmobius/gameserver/handler/skillhandlers/Disablers.java
@@ -17,9 +17,11 @@
 package org.l2jmobius.gameserver.handler.skillhandlers;
 
 import java.io.IOException;
+import java.util.Vector;
 import java.util.logging.Logger;
 
 import org.l2jmobius.Config;
+import org.l2jmobius.commons.concurrent.ThreadPool;
 import org.l2jmobius.commons.util.Rnd;
 import org.l2jmobius.gameserver.ai.AttackableAI;
 import org.l2jmobius.gameserver.ai.CtrlEvent;
@@ -27,6 +29,7 @@
 import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
 import org.l2jmobius.gameserver.handler.ISkillHandler;
 import org.l2jmobius.gameserver.handler.SkillHandler;
+import org.l2jmobius.gameserver.model.CustomCancelTask;
 import org.l2jmobius.gameserver.model.Effect;
 import org.l2jmobius.gameserver.model.Effect.EffectType;
 import org.l2jmobius.gameserver.model.Skill;
@@ -427,6 +430,7 @@
  }
  break;
  }
+ Vector<Skill> cancelledBuffs = new Vector<>();
  int lvlmodifier = 52 + (skill.getLevel() * 2);
  if (skill.getLevel() == 12)
  {
@@ -480,6 +484,15 @@
 
  if (Rnd.get(100) < rate)
  {
+ if (Config.RESTORE_CANCELLED_BUFFS_SECONDS > 0)
+ {
+ // store them
+ if (!cancelledBuffs.contains(e.getSkill()))
+ {
+ cancelledBuffs.add(e.getSkill());
+ }
+ }
+ // cancel them
  e.exit(true);
  maxfive--;
  if (maxfive == 0)
@@ -490,6 +503,10 @@
  }
  }
  }
+ if ((Config.RESTORE_CANCELLED_BUFFS_SECONDS > 0) && (cancelledBuffs.size() > 0))
+ {
+ ThreadPool.schedule(new CustomCancelTask((PlayerInstance) target, cancelledBuffs), Config.RESTORE_CANCELLED_BUFFS_SECONDS * 1000);
+ }
  }
  else if (creature instanceof PlayerInstance)
  {
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CustomCancelTask.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CustomCancelTask.java
new file mode 100644
index 0000000..4059087
--- /dev/null
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CustomCancelTask.java
@@ -0,0 +1,35 @@
+package org.l2jmobius.gameserver.model;
+
+import java.util.Vector;
+
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+
+public class CustomCancelTask implements Runnable
+{
+ private PlayerInstance _player = null;
+ private Vector<Skill> _buffs = null;
+
+ public CustomCancelTask(PlayerInstance _player, Vector<Skill> _buffs)
+ {
+ this._player = _player;
+ this._buffs = _buffs;
+ }
+
+ @Override
+ public void run()
+ {
+ if ((_player == null) || !_player.isOnline())
+ {
+ return;
+ }
+ for (Skill s : _buffs)
+ {
+ if (s == null)
+ {
+ continue;
+ }
+
+ s.getEffects(_player, _player);
+ }
+ }
+}
\ No newline at end of file