Welcome to RUSaCis - эмулятор Interlude

Присоединяйтесь к нам прямо сейчас, чтобы получить доступ ко всем нашим возможностям. После регистрации и входа в систему вы сможете создавать темы, публиковать ответы в существующих темах, давать репутацию пользователям - так же приобрести исходный код. Это также быстро, так чего же вы ждете?

Custom Cancel Task Acis 398+

Mayhem

Бродяга
Регистрация
12 Июн 2021
Сообщения
18
Реакции
18
Баллы
3
Возраст
32
Адрес
Argentina
RaCoin
0
Sharing a new useful code for some servers

Java:
diff --git a/aCis_gameserver/config/players.properties b/aCis_gameserver/config/players.properties
index 3e58ec8..42b9fcd 100644
--- a/aCis_gameserver/config/players.properties
+++ b/aCis_gameserver/config/players.properties
@@ -250,3 +250,12 @@
 # Allow player subclass addition without checking for unique quest items. Default : False.
 SubClassWithoutQuests = False
 
+#=============================================================
+#                Custom Cancel Task
+#=============================================================
+# this setting back the buffs after the set time in CustomCancelSeconds
+# Default : False
+AllowCustomCancelTask = True
+# 5 = 5 seconds.
+CustomCancelSeconds = 7
+
diff --git a/aCis_gameserver/java/net/sf/l2j/Config.java b/aCis_gameserver/java/net/sf/l2j/Config.java
index 146971c..bf447a0 100644
--- a/aCis_gameserver/java/net/sf/l2j/Config.java
+++ b/aCis_gameserver/java/net/sf/l2j/Config.java
@@ -435,6 +435,9 @@
     public static boolean DIVINE_SP_BOOK_NEEDED;
     public static boolean SUBCLASS_WITHOUT_QUESTS;
    
+    /** Custom Cansel Segunds */
+    public static boolean ALLOW_CUSTOM_CANCEL;
+    public static int CUSTOM_CANCEL_SECONDS;
    
     // --------------------------------------------------
     // Sieges
@@ -1078,6 +1081,9 @@
         DIVINE_SP_BOOK_NEEDED = players.getProperty("DivineInspirationSpBookNeeded", true);
         SUBCLASS_WITHOUT_QUESTS = players.getProperty("SubClassWithoutQuests", false);
        
+        ALLOW_CUSTOM_CANCEL = players.getProperty("AllowCustomCancelTask", false);
+        CUSTOM_CANCEL_SECONDS = players.getProperty("CustomCancelSeconds", 5);
+
     }
    
     /**
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java b/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java
index 9722407..ebe3c59 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java
@@ -3,6 +3,7 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Vector;
 
 import net.sf.l2j.commons.math.MathUtil;
+import net.sf.l2j.commons.pool.ThreadPool;
@@ -13,8 +14,10 @@
 import net.sf.l2j.gameserver.enums.skills.EffectType;
 import net.sf.l2j.gameserver.enums.skills.SkillType;
 import net.sf.l2j.gameserver.handler.ISkillHandler;
+import net.sf.l2j.gameserver.model.CustomCancelTask;
 import net.sf.l2j.gameserver.model.WorldObject;
 import net.sf.l2j.gameserver.model.actor.Creature;
+import net.sf.l2j.gameserver.model.actor.Player;
 import net.sf.l2j.gameserver.skills.AbstractEffect;
 import net.sf.l2j.gameserver.skills.Formulas;
 import net.sf.l2j.gameserver.skills.L2Skill;
@@ -31,6 +34,7 @@
     @Override
     public void useSkill(Creature activeChar, L2Skill skill, WorldObject[] targets)
     {
+        Vector<L2Skill> cancelledBuffs = new Vector<>();
         // Delimit min/max % success.
         final int minRate = (skill.getSkillType() == SkillType.CANCEL) ? 25 : 40;
         final int maxRate = (skill.getSkillType() == SkillType.CANCEL) ? 75 : 95;
@@ -58,6 +62,15 @@
            
             for (AbstractEffect effect : list)
             {
+
+                if (Config.ALLOW_CUSTOM_CANCEL)
+                {
+                    if (!cancelledBuffs.contains(effect.getSkill()))
+                    {
+                        cancelledBuffs.add(effect.getSkill());
+                    }
+                }
+
                 // Don't cancel toggles or debuffs.
                 if (effect.getSkill().isToggle() || effect.getSkill().isDebuff())
                     continue;
@@ -88,6 +101,14 @@
                         continue;
                 }
                
+                if (Config.ALLOW_CUSTOM_CANCEL)
+                {
+                    if (cancelledBuffs.size() > 0)
+                    {
+                        ThreadPool.schedule(new CustomCancelTask((Player) target, cancelledBuffs), Config.CUSTOM_CANCEL_SECONDS * 1000);
+                    }
+                }
+
                 // Calculate the success chance following previous variables.
                 if (calcCancelSuccess(effect.getPeriod(), diffLevel, skillPower, skillVuln, minRate, maxRate))
                     effect.exit();
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/CustomCancelTask.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/CustomCancelTask.java
new file mode 100644
index 0000000..412d6d0
--- /dev/null
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/CustomCancelTask.java
@@ -0,0 +1,41 @@
+package net.sf.l2j.gameserver.model;
+
+import java.util.Vector;
+
+import net.sf.l2j.gameserver.model.actor.Player;
+import net.sf.l2j.gameserver.skills.L2Skill;
+
+
+/**
+ * @author Anarchy
+ *
+ */
+public class CustomCancelTask implements Runnable
+{
+    private Player _player = null;
+    private Vector<L2Skill> _buffs = null;
+   
+    public CustomCancelTask(Player _player, Vector<L2Skill> _buffs)
+    {
+        this._player = _player;
+        this._buffs = _buffs;
+    }
+   
+    @Override
+    public void run()
+    {
+        if (_player == null || !_player.isOnline())
+        {
+            return;
+        }
+        for (L2Skill s : _buffs)
+        {
+            if (s == null)
+            {
+                continue;
+            }
+           
+            s.getEffects(_player, _player);
+        }
+    }
+}
 

BezneR

Преемник
INTERLUDE
Регистрация
27 Мар 2021
Сообщения
161
Реакции
238
Баллы
43
RaCoin
50
First of all its isn`t new and second you can use ArrayList (for thread unsafe) or CopyOnWriteArrayList (for thread safe) instead of Vector.


Anyway good initiative!
 

Mayhem

Бродяга
Регистрация
12 Июн 2021
Сообщения
18
Реакции
18
Баллы
3
Возраст
32
Адрес
Argentina
RaCoin
0
First of all its isn`t new and second you can use ArrayList (for thread unsafe) or CopyOnWriteArrayList (for thread safe) instead of Vector.


Anyway good initiative!
i have been use this methos since acis 290, that was my bad on updating up to new revs could be fixed by anyone who want it or you can post your updated version just right here, i posted a few more codes if you wantto check it out, and tell me better ways to make it work, withoit resource leaks or things like that.
 

BezneR

Преемник
INTERLUDE
Регистрация
27 Мар 2021
Сообщения
161
Реакции
238
Баллы
43
RaCoin
50
i have been use this methos since acis 290, that was my bad on updating up to new revs could be fixed by anyone who want it or you can post your updated version just right here, i posted a few more codes if you wantto check it out, and tell me better ways to make it work, withoit resource leaks or things like that.
ATM I'm not currently working with java. I'm just working (real life) and playing mobile legends in free time, but I still follow the l2java forums to stay up to date on what's going on. You can try to update the writing of the codes, I'll try to analyze your other codes as you asked and if I find something that can be improved, I'll let you know.
Keep going!
 

Mayhem

Бродяга
Регистрация
12 Июн 2021
Сообщения
18
Реакции
18
Баллы
3
Возраст
32
Адрес
Argentina
RaCoin
0
ATM I'm not currently working with java. I'm just working (real life) and playing mobile legends in free time, but I still follow the l2java forums to stay up to date on what's going on. You can try to update the writing of the codes, I'll try to analyze your other codes as you asked and if I find something that can be improved, I'll let you know.
Keep going!
thanks a lot, also, i'm playin a lot of mobile legends too, since 2017 haha.
maybe i will start working in a java server, but dunno, these times everyones open server just to cash out. don't know if you understand that.
 
Сверху Снизу