Jump to content

Recommended Posts

Posted (edited)

Hello friends.
WTB cancellation suspend buff system for our l2jserver highfive fun server.
Short explaning what exactly i need:

I need a system that just suspend these X buffs for X time (example make them in red and stop their effect for X time) and to have limit of how much maximum buffs can be removed.
Example 4 SLH - 4 times steal divinity = 0 buffs.. The idea is to have limit so maximum buffs that can be suspended to be example 8.
Then no matter how much cancellation classes will be in the pvp will not ruin the gamefun to other players. 
Thanks Ahead!

(NOTE:I dont need system that back the stolen buffs after X seconds.i already have it and its usless)

Edited by warlikeinsane
Posted (edited)
Quote

### Eclipse Workspace Patch 1.0
#P L2J_Server
Index: java/com/l2jserver/gameserver/skills/effects/EffectCancel.java
===================================================================
--- java/com/l2jserver/gameserver/skills/effects/EffectCancel.java    (revision 5615)
+++ java/com/l2jserver/gameserver/skills/effects/EffectCancel.java    (working copy)
@@ -14,6 +14,7 @@
  */
package com.l2jserver.gameserver.skills.effects;
 
+import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
 
import com.l2jserver.Config;
@@ -36,6 +37,11 @@
{
    protected static final Logger _log = Logger.getLogger(EffectCancel.class.getName());
 
+    public static L2Effect[] giveback;
+    public static L2PcInstance playah;
+    public static ScheduledFuture<?> _CancelRegTask;
+    public static long _cancelLasts = System.currentTimeMillis() + 15000;
+
    public EffectCancel(Env env, EffectTemplate template)
    {
        super(env, template);
@@ -71,14 +77,15 @@
        return false;
    }
 
-    private static boolean cancel(L2Character caster, L2Character target, L2Effect effect)
+    private static boolean cancel(L2Character caster, final L2Character target, L2Effect effect)
    {
        if (!(target instanceof L2PcInstance)|| target.isDead())
            return false;
    
+        playah = (L2PcInstance) target;
        final int cancelLvl = effect.getSkill().getMagicLevel();
        int count = effect.getSkill().getMaxNegatedEffects();
-
+    
        double rate = effect.getEffectPower();
        final double vulnModifier = Formulas.calcSkillTypeVulnerability(0, target, effect.getSkillType());
        final double profModifier = Formulas.calcSkillTypeProficiency(0, caster, target, effect.getSkillType());
@@ -118,6 +125,11 @@
 
        final L2Effect[] effects = target.getAllEffects();
    
+        if(effects != null)
+        {
+            giveback = effects;
+        }
+    
        if (effect.getSkill().getNegateAbnormals() != null) // Cancel for abnormals
        {
            for (L2Effect eff : effects)
@@ -130,7 +142,11 @@
                    if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && effect.getSkill().getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl())
                    {
                        if (calcCancelSuccess(eff, cancelLvl, (int)rate))
+                        {
+                            if(target instanceof L2PcInstance)
+                                target.addLastCancelledEffect(eff);
                            eff.exit();
+                        }
                    }
                }
            }
@@ -168,6 +184,8 @@
                lastCanceledSkillId = eff.getSkill().getId();
            
                eff.exit();
+                if(target instanceof L2PcInstance)
+                    target.addLastCancelledEffect(eff);
                count--;
            
                if (count == 0)
@@ -198,6 +216,8 @@
                
                    lastCanceledSkillId = eff.getSkill().getId();
                    eff.exit();
+                    if(target instanceof L2PcInstance)
+                        target.addLastCancelledEffect(eff);
                    count--;
                
                    if (count == 0)
@@ -206,6 +226,7 @@
            }
        }
    
+        target.recoverLastCancelledEffects();
        return true;
    }
 
Index: java/com/l2jserver/gameserver/skills/effects/EffectDeflectBuff.java
===================================================================
--- java/com/l2jserver/gameserver/skills/effects/EffectDeflectBuff.java    (revision 0)
+++ java/com/l2jserver/gameserver/skills/effects/EffectDeflectBuff.java    (working copy)
@@ -0,0 +1,97 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.skills.effects;
+
+import com.l2jserver.gameserver.model.L2Effect;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.skills.Env;
+import com.l2jserver.gameserver.templates.effects.EffectTemplate;
+import com.l2jserver.gameserver.templates.skills.L2EffectType;
+import com.l2jserver.gameserver.templates.skills.L2SkillType;
+
+/**
+ * @author Lambda
+ *
+ */
+public final class EffectDeflectBuff extends L2Effect
+{
+    /**
+    * @param env
+    * @param template
+    */
+    public EffectDeflectBuff(Env env, EffectTemplate template)
+    {
+        super(env, template);
+    }
+
+    /*
+    * (non-Javadoc)
+    *
+    * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
+    */
+    @Override
+    public L2EffectType getEffectType()
+    {
+        return L2EffectType.PREVENT_BUFF;
+    }
+
+    /*
+    * (non-Javadoc)
+    *
+    * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
+    */
+    @Override
+    public boolean onActionTime()
+    {
+        // Only cont skills shouldn't end
+        if(getSkill().getSkillType() != L2SkillType.CONT)
+            return false;
+    
+        double manaDam = calc();
+    
+        if(manaDam > getEffected().getCurrentMp())
+        {
+            SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.SKILL_REMOVED_DUE_LACK_MP);
+            getEffected().sendPacket(sm);
+            return false;
+        }
+    
+        getEffected().reduceCurrentMp(manaDam);
+        return true;
+    }
+
+    /*
+    * (non-Javadoc)
+    *
+    * @see com.l2jserver.gameserver.model.L2Effect#onStart()
+    */
+    @Override
+    public boolean onStart()
+    {
+        getEffected().setIsBuffProtected(true);
+        return true;
+    }
+
+    /*
+    * (non-Javadoc)
+    * @see com.l2jserver.gameserver.model.L2Effect#onExit()
+    */
+    @Override
+    public void onExit()
+    {
+        getEffected().setIsBuffProtected(false);
+    }
+}
Index: java/com/l2jserver/gameserver/model/actor/L2Character.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Character.java    (revision 5615)
+++ java/com/l2jserver/gameserver/model/actor/L2Character.java    (working copy)
@@ -23,6 +23,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
 
@@ -69,12 +70,14 @@
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.SkillDat;
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
import com.l2jserver.gameserver.model.actor.instance.L2RiftInvaderInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2VillageMasterInstance;
import com.l2jserver.gameserver.model.actor.knownlist.CharKnownList;
import com.l2jserver.gameserver.model.actor.position.CharPosition;
import com.l2jserver.gameserver.model.actor.stat.CharStat;
import com.l2jserver.gameserver.model.actor.status.CharStatus;
import com.l2jserver.gameserver.model.entity.Instance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
+import com.l2jserver.gameserver.model.olympiad.OlympiadManager;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.AbstractNpcInfo;
@@ -82,6 +85,7 @@
import com.l2jserver.gameserver.network.serverpackets.Attack;
import com.l2jserver.gameserver.network.serverpackets.ChangeMoveType;
import com.l2jserver.gameserver.network.serverpackets.ChangeWaitType;
+import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;
import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
@@ -100,6 +104,7 @@
import com.l2jserver.gameserver.pathfinding.PathFinding;
import com.l2jserver.gameserver.skills.AbnormalEffect;
import com.l2jserver.gameserver.skills.Calculator;
+import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.skills.Stats;
import com.l2jserver.gameserver.skills.effects.EffectChanceSkillTrigger;
@@ -150,6 +155,7 @@
    private L2Skill _lastSkillCast;
    private L2Skill _lastSimultaneousSkillCast;
 
+    private boolean _isBuffProtected = false;
    private boolean _isDead                                    = false;
    private boolean _isImmobilized                            = false;
    private boolean _isOverloaded                            = false; // the char is carrying too much
@@ -209,6 +215,11 @@
    private final byte[] _zones = new byte[22];
    protected byte _zoneValidateCounter = 4;
 
+    //Holds cancelled buffs
+    private List<L2Effect> _lastCancelledEffects = new FastList<L2Effect>();
+    //Task to give back cancelled buffs
+    private ScheduledFuture<?> _lastCancelledEffectsTask;
+
    private L2Character _debugger = null;
 
    /**
@@ -219,6 +230,75 @@
        return _debugger != null;
    }
 
+    public void addLastCancelledEffect(L2Effect e)
+    {
+        if(!_lastCancelledEffects.contains(e))
+            _lastCancelledEffects.add(e);
+    }
+
+    public void recoverLastCancelledEffects()
+    {
+        if(_lastCancelledEffects.isEmpty() || (_lastCancelledEffectsTask != null && !_lastCancelledEffectsTask.isDone()))
+            return;
+    
+        final L2Character target = this;
+    
+        _lastCancelledEffectsTask = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+        {
+            @Override
+            public void run()
+            {
+                Collection<L2Character> knowns  = target.getKnownList().getKnownCharactersInRadius(300);
+                for (L2Object grm : knowns)
+                {
+                    if (grm instanceof L2VillageMasterInstance)
+                    {
+                        return;
+                    }
+                }
+            
+                if(target.isDead())
+                    return;
+            
+                if (OlympiadManager.getInstance().isRegistered((L2PcInstance) target))
+                    return;
+            
+                Env env;
+                L2Effect effect;
+                for(L2Effect e : _lastCancelledEffects)
+                {
+                    env = new Env();
+                    env.target = target;
+                    env.skill = e.getSkill();
+                
+                    try
+                    {
+                        effect = e.getEffectTemplate().getEffect(env);
+                        if (effect != null)
+                        {
+                            effect.scheduleEffect();
+                            if (effect.getShowIcon() && target instanceof L2PcInstance)
+                            {
+                                SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
+                                sm.addSkillName(effect);
+                                target.sendPacket(sm);
+                            }
+                        }
+                        e.exit();
+                    }
+                    catch (RuntimeException ex)
+                    {
+                        _log.log(Level.WARNING, "Cannot return effect: " + e + "to owner: " + target, ex);
+                    }
+                }
+            
+                sendPacket(new ExShowScreenMessage("Your cancelled buffs has been given back.", 2000));
+            
+                _lastCancelledEffects.clear();
+            }
+        }, 15000);
+    }
+
    /**
      * Sets L2Character instance, to which debug packets will be send
      * @param d
@@ -6998,4 +7078,14 @@
    {
        return _effects.isAffected(flag);
    }
+
+    public final void setIsBuffProtected(boolean value)
+    {
+        _isBuffProtected = value;
+    }
+
+    public boolean isBuffProtected()
+    {
+        return _isBuffProtected;
+    }
}
Index: java/com/l2jserver/gameserver/templates/skills/L2EffectType.java
===================================================================
--- java/com/l2jserver/gameserver/templates/skills/L2EffectType.java    (revision 5615)
+++ java/com/l2jserver/gameserver/templates/skills/L2EffectType.java    (working copy)
@@ -76,5 +76,6 @@
    HIDE,
    ABORT_CAST,
    INCREASE_CHARGES,
-    BLOCK_RESURRECTION
+    BLOCK_RESURRECTION,
+    PREVENT_BUFF
}
\ No newline at end of file
Index: java/com/l2jserver/gameserver/skills/effects/EffectCancelDebuff.java
===================================================================
--- java/com/l2jserver/gameserver/skills/effects/EffectCancelDebuff.java    (revision 5615)
+++ java/com/l2jserver/gameserver/skills/effects/EffectCancelDebuff.java    (working copy)
@@ -103,6 +103,8 @@
        
            lastCanceledSkillId = effect.getSkill().getId();
            effect.exit();
+            if(target instanceof L2PcInstance)
+                target.addLastCancelledEffect(effect);
            count--;
        
            if (count == 0)
@@ -135,12 +137,16 @@
            
                lastCanceledSkillId = effect.getSkill().getId();
                effect.exit();
+                if(target instanceof L2PcInstance)
+                    target.addLastCancelledEffect(effect);
                count--;
            
                if (count == 0)
                    break;
            }
        }
+    
+        target.recoverLastCancelledEffects();
        return true;
    }
 
Index: java/com/l2jserver/gameserver/model/L2Effect.java
===================================================================
--- java/com/l2jserver/gameserver/model/L2Effect.java    (revision 5615)
+++ java/com/l2jserver/gameserver/model/L2Effect.java    (working copy)
@@ -112,6 +112,8 @@
 
    public boolean preventExitUpdate;
 
+    private long _cancelLasts = System.currentTimeMillis() + 15000;
+
    private final class EffectTask implements Runnable
    {
        public void run()
@@ -663,4 +665,20 @@
    {
        return false;
    }
+
+    /**
+    * @return the _cancelLasts
+    */
+    public long getcancelLasts()
+    {
+        return _cancelLasts;
+    }
+
+    /**
+    * @param _cancelLasts the _cancelLasts to set
+    */
+    public void setcancelLasts(long _cancelLasts)
+    {
+        this._cancelLasts = _cancelLasts;
+    }
}
\ No newline at end of file
Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java    (revision 5615)
+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java    (working copy)
@@ -46,6 +46,7 @@
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2ClassMasterInstance;
@@ -331,6 +332,9 @@
        if (Config.PLAYER_SPAWN_PROTECTION > 0)
            activeChar.setProtection(true);
    
+        L2Skill skill2 = SkillTable.getInstance().getInfo(26074, 1);
+        activeChar.addSkill(skill2);
+    
        activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
    
        if (L2Event.active && L2Event.connectionLossData.containsKey(activeChar.getName()) && L2Event.isOnEvent(activeChar))
 


### Eclipse Workspace Patch 1.0
#P L2J_DataPack
Index: dist/game/data/scripts/handlers/skillhandlers/Cancel.java
===================================================================
--- dist/game/data/scripts/handlers/skillhandlers/Cancel.java    (revision 9150)
+++ dist/game/data/scripts/handlers/skillhandlers/Cancel.java    (working copy)
@@ -23,6 +23,7 @@
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Summon;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.Rnd;
@@ -40,6 +41,8 @@
        L2SkillType.CANCEL,
    };
 
+    public static L2Character target;
+
    /**
      *
      * @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
@@ -146,6 +149,8 @@
                        {
                            if (calcCancelSuccess(eff, cancelLvl, (int)rate, minRate, maxRate))
                                eff.exit();
+                            if(target instanceof L2PcInstance)
+                                target.addLastCancelledEffect(eff);
                        }
                    }
                }
@@ -179,6 +184,8 @@
                
                    lastCanceledSkillId = effect.getSkill().getId();
                    effect.exit();
+                    if(target instanceof L2PcInstance)
+                        target.addLastCancelledEffect(effect);
                    count--;
                
                    if (count == 0)
@@ -209,6 +216,8 @@
                    
                        lastCanceledSkillId = effect.getSkill().getId();
                        effect.exit();
+                        if(target instanceof L2PcInstance)
+                            target.addLastCancelledEffect(effect);
                        count--;
                    
                        if (count == 0)
@@ -217,6 +226,8 @@
                }
            }
        
+            target.recoverLastCancelledEffects();
+        
            //Possibility of a lethal strike
            Formulas.calcLethalHit(activeChar, target, skill);
        }
@@ -245,7 +256,7 @@
        else if (rate > maxRate)
            rate = maxRate;
    
-        return Rnd.get(100) < rate;
+        return Rnd.get(100) < 10;
    }
 
    /**
Index: dist/game/data/scripts/handlers/skillhandlers/StealBuffs.java
===================================================================
--- dist/game/data/scripts/handlers/skillhandlers/StealBuffs.java    (revision 9150)
+++ dist/game/data/scripts/handlers/skillhandlers/StealBuffs.java    (working copy)
@@ -178,6 +178,7 @@
                    }
                    // Finishing stolen effect
                    eff.exit();
+                    target.addLastCancelledEffect(eff);
                }
                catch (RuntimeException e)
                {
@@ -185,6 +186,8 @@
                }
            }
        
+            target.recoverLastCancelledEffects();
+        
            //Possibility of a lethal strike
            Formulas.calcLethalHit(activeChar, target, skill);
        }
Index: dist/game/data/scripts/handlers/skillhandlers/Continuous.java
===================================================================
--- dist/game/data/scripts/handlers/skillhandlers/Continuous.java    (revision 9150)
+++ dist/game/data/scripts/handlers/skillhandlers/Continuous.java    (working copy)
@@ -95,6 +95,10 @@
            if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
                target = activeChar;
        
+            // Anti-Buff Protection prevents you from getting buffs by other players
+            if (activeChar instanceof L2PcInstance && target != activeChar && target.isBuffProtected() && !skill.isHeroSkill() && (skill.getSkillType() == L2SkillType.BUFF || skill.getSkillType() == L2SkillType.HEAL_PERCENT || skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT || skill.getSkillType() == L2SkillType.COMBATPOINTHEAL))
+                continue;
+        
            // Player holding a cursed weapon can't be buffed and can't buff
            if (skill.getSkillType() == L2SkillType.BUFF && !(activeChar instanceof L2ClanHallManagerInstance))
            {
Index: dist/game/data/stats/skills/26000-26099.xml
===================================================================
--- dist/game/data/stats/skills/26000-26099.xml    (revision 9150)
+++ dist/game/data/stats/skills/26000-26099.xml    (working copy)
@@ -801,4 +801,14 @@
            </and>
        </cond>
    </skill>
+    <skill id="26074" levels="1" name="AntiBuff-Shield">
+        <set name="target" val="TARGET_SELF"/>
+        <set name="skillType" val="CONT"/>
+        <set name="operateType" val="OP_TOGGLE"/>
+        <set name="castRange" val="-1"/>
+        <set name="effectRange" val="-1"/>
+        <for>
+            <effect count="0x7fffffff" name="DeflectBuff" time="3" val="0"/>
+        </for>
+    </skill>
</list>
\ No ne

 

Edited by MaKasTreRo
Posted

thats semi antibuff with buff return makastero :s

 

about topic what you ask is useless because in mechanics is the same thing as the cancelled buff that return with the difference of visually staying there as "red" buff... so the system you have is not useless is working and what you need is possibly client edit.

  • 3 weeks later...
  • Vision locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...