Bluur

Custom Cancel Task

Jan 12th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.24 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java
  3. ===================================================================
  4. --- java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java    (revision 1)
  5. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java    (working copy)
  6. @@ -14,14 +14,19 @@
  7.   */
  8.  package net.sf.l2j.gameserver.handler.skillhandlers;
  9.  
  10. +import java.util.Vector;
  11. +
  12.  import net.sf.l2j.Config;
  13. +import net.sf.l2j.gameserver.ThreadPoolManager;
  14.  import net.sf.l2j.gameserver.handler.ISkillHandler;
  15.  import net.sf.l2j.gameserver.model.L2Effect;
  16.  import net.sf.l2j.gameserver.model.L2Object;
  17.  import net.sf.l2j.gameserver.model.L2Skill;
  18.  import net.sf.l2j.gameserver.model.ShotType;
  19.  import net.sf.l2j.gameserver.model.actor.L2Character;
  20. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21.  import net.sf.l2j.gameserver.skills.Formulas;
  22. +import net.sf.l2j.gameserver.taskmanager.CustomCancelTaskManager;
  23.  import net.sf.l2j.gameserver.templates.skills.L2SkillType;
  24.  import net.sf.l2j.util.Rnd;
  25.  
  26. @@ -56,6 +61,8 @@
  27.  
  28.              if (target.isDead())
  29.                  continue;
  30.            
  31. +            Vector<L2Skill> cancelledBuffs = new Vector<>();
  32. +            
  33.              int lastCanceledSkillId = 0;
  34.              int count = skill.getMaxNegatedEffects();
  35.            
  36. @@ -98,6 +105,9 @@
  37.  
  38.                  // Calculate the success chance following previous variables.
  39.                  if (calcCancelSuccess(effect.getPeriod(), diffLevel, skillPower, skillVuln, minRate, maxRate))
  40.                  {
  41. +                    if (!cancelledBuffs.contains(effect.getSkill()) && !((L2PcInstance)activeChar).isInOlympiadMode())                        
  42. +                        cancelledBuffs.add(effect.getSkill());
  43. +                    
  44.                      // Stores the last canceled skill for further use.
  45.                      lastCanceledSkillId = effect.getSkill().getId();
  46.                  
  47. @@ -105,6 +115,9 @@
  48.  
  49.                      effect.exit();
  50.                  }
  51.                
  52. +                if (cancelledBuffs.size() > 0)                    
  53. +                    ThreadPoolManager.getInstance().scheduleGeneral(new CustomCancelTaskManager((L2PcInstance)target, cancelledBuffs), 10*1000);
  54. +
  55.                  // Remove 1 to the stack of buffs to remove.
  56.                  count--;
  57.                
  58. Index: java/net/sf/l2j/gameserver/taskmanager/CustomCancelTaskManager.java
  59. ===================================================================
  60. --- java/net/sf/l2j/gameserver/taskmanager/CustomCancelTaskManager.java    (revision 0)
  61. +++ java/net/sf/l2j/gameserver/taskmanager/CustomCancelTaskManager.java    (working copy)
  62. @@ -0,0 +1,51 @@
  63. +/*
  64. + * This program is free software: you can redistribute it and/or modify it under
  65. + * the terms of the GNU General Public License as published by the Free Software
  66. + * Foundation, either version 3 of the License, or (at your option) any later
  67. + * version.
  68. + *
  69. + * This program is distributed in the hope that it will be useful, but WITHOUT
  70. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  71. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  72. + * details.
  73. + *
  74. + * You should have received a copy of the GNU General Public License along with
  75. + * this program. If not, see <http://www.gnu.org/licenses/>.
  76. + */
  77. +package net.sf.l2j.gameserver.taskmanager;
  78. +
  79. +import java.util.Vector;
  80. +
  81. +import net.sf.l2j.gameserver.model.L2Skill;
  82. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  83. +
  84. + /**
  85. + * @author Anarchy, Bluur
  86. + *
  87. + */
  88. +public class CustomCancelTaskManager implements Runnable
  89. +{
  90. +    private L2PcInstance player = null;
  91. +    private Vector<L2Skill> buffsCanceled = null;
  92. +
  93. +    public CustomCancelTaskManager(L2PcInstance p, Vector<L2Skill> skill)
  94. +    {
  95. +        player = p;
  96. +        buffsCanceled = skill;
  97. +    }
  98. +    
  99. +    @Override
  100. +    public void run()
  101. +    {
  102. +        if (player == null)        
  103. +            return;
  104. +        
  105. +        for (L2Skill skill : buffsCanceled)
  106. +        {
  107. +            if (skill == null)
  108. +                continue;
  109. +            
  110. +            skill.getEffects(player, player);
  111. +        }
  112. +    }
  113. +}
Add Comment
Please, Sign In to add comment