Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P L2J_Server_BETA
- Index: java/com/l2jserver/gameserver/skills/effects/EffectCancel.java
- ===================================================================
- --- java/com/l2jserver/gameserver/skills/effects/EffectCancel.java (revision 4769)
- +++ java/com/l2jserver/gameserver/skills/effects/EffectCancel.java (working copy)
- @@ -17,6 +17,7 @@
- import java.util.logging.Logger;
- import com.l2jserver.Config;
- +import com.l2jserver.gameserver.model.CancelSystem;
- import com.l2jserver.gameserver.model.L2Effect;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- @@ -130,7 +131,10 @@
- if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && effect.getSkill().getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl())
- {
- if (calcCancelSuccess(eff, cancelLvl, (int)rate))
- + {
- eff.exit();
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- + }
- }
- }
- }
- @@ -159,6 +163,7 @@
- if (eff.getSkill().getId() == lastCanceledSkillId)
- {
- eff.exit(); // this skill already canceled
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- continue;
- }
- @@ -168,6 +173,7 @@
- lastCanceledSkillId = eff.getSkill().getId();
- eff.exit();
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- count--;
- if (count == 0)
- @@ -190,6 +196,7 @@
- if (eff.getSkill().getId() == lastCanceledSkillId)
- {
- eff.exit(); // this skill already canceled
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- continue;
- }
- @@ -198,6 +205,7 @@
- lastCanceledSkillId = eff.getSkill().getId();
- eff.exit();
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- count--;
- if (count == 0)
- Index: java/com/l2jserver/gameserver/model/CancelSystem.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/CancelSystem.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/CancelSystem.java (revision 0)
- @@ -0,0 +1,54 @@
- +/*
- + * 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.model;
- +
- +import com.l2jserver.gameserver.ThreadPoolManager;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
- +import com.l2jserver.gameserver.skills.Env;
- +
- +/**
- + *
- + * @author horato
- + *
- + */
- +
- +public class CancelSystem
- +{
- +
- + public static void onCancel(final L2PcInstance player, final L2Effect eff)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + public void run()
- + {
- + restore(player, eff);
- + }
- +
- + }, 30*1000);
- + }
- +
- + private static void restore(L2PcInstance player, L2Effect eff)
- + {
- + Env env = new Env();
- + env.target = player;
- + env.skill = eff.getSkill();
- + L2Effect effect = eff.getEffectTemplate().getStolenEffect(env, eff);
- + if (effect != null)
- + effect.scheduleEffect();
- + player.sendPacket(new ExShowScreenMessage("Your stolen effect has been given back", 5000));
- + }
- +
- +}
- #P L2J_DataPack_BETA
- Index: data/scripts/handlers/skillhandlers/Cancel.java
- ===================================================================
- --- data/scripts/handlers/skillhandlers/Cancel.java (revision 8223)
- +++ data/scripts/handlers/skillhandlers/Cancel.java (working copy)
- @@ -16,6 +16,7 @@
- import com.l2jserver.Config;
- import com.l2jserver.gameserver.handler.ISkillHandler;
- +import com.l2jserver.gameserver.model.CancelSystem;
- import com.l2jserver.gameserver.model.L2Effect;
- import com.l2jserver.gameserver.model.L2ItemInstance;
- import com.l2jserver.gameserver.model.L2Object;
- @@ -23,6 +24,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;
- @@ -145,7 +147,11 @@
- if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && skill.getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl())
- {
- if (calcCancelSuccess(eff, cancelLvl, (int)rate, minRate, maxRate))
- + {
- eff.exit();
- + if(target instanceof L2PcInstance)
- + CancelSystem.onCancel(target.getActingPlayer(), eff);
- + }
- }
- }
- }
- @@ -171,6 +177,8 @@
- if (effect.getSkill().getId() == lastCanceledSkillId)
- {
- effect.exit(); // this skill already canceled
- + if(target instanceof L2PcInstance)
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- continue;
- }
- @@ -179,6 +187,8 @@
- lastCanceledSkillId = effect.getSkill().getId();
- effect.exit();
- + if(target instanceof L2PcInstance)
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- count--;
- if (count == 0)
- @@ -201,7 +211,8 @@
- if (effect.getSkill().getId() == lastCanceledSkillId)
- {
- effect.exit(); // this skill already canceled
- - continue;
- + if(target instanceof L2PcInstance)
- + CancelSystem.onCancel(target.getActingPlayer(), effect); continue;
- }
- if (!calcCancelSuccess(effect, cancelLvl, (int)rate, minRate, maxRate))
- @@ -209,6 +220,8 @@
- lastCanceledSkillId = effect.getSkill().getId();
- effect.exit();
- + if(target instanceof L2PcInstance)
- + CancelSystem.onCancel(target.getActingPlayer(), effect);
- count--;
- if (count == 0)
- Index: data/scripts/handlers/skillhandlers/StealBuffs.java
- ===================================================================
- --- data/scripts/handlers/skillhandlers/StealBuffs.java (revision 8223)
- +++ data/scripts/handlers/skillhandlers/StealBuffs.java (working copy)
- @@ -13,11 +13,16 @@
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package handlers.skillhandlers;
- -
- +/*
- + * This class is called when 'steal divinity' skill is used.
- + * Each buff have its own chance to be stealed defined by the 'chance' variable
- + *
- + * */
- import java.util.ArrayList;
- import java.util.logging.Level;
- import com.l2jserver.gameserver.handler.ISkillHandler;
- +import com.l2jserver.gameserver.model.CancelSystem;
- import com.l2jserver.gameserver.model.L2Effect;
- import com.l2jserver.gameserver.model.L2ItemInstance;
- import com.l2jserver.gameserver.model.L2Object;
- @@ -31,13 +36,11 @@
- import com.l2jserver.gameserver.skills.Env;
- import com.l2jserver.gameserver.skills.Formulas;
- import com.l2jserver.gameserver.templates.skills.L2SkillType;
- +import com.l2jserver.util.Rnd;
- public class StealBuffs implements ISkillHandler
- {
- - private static final L2SkillType[] SKILL_IDS =
- - {
- - L2SkillType.STEAL_BUFF
- - };
- + private static final L2SkillType[] SKILL_IDS = { L2SkillType.STEAL_BUFF };
- /**
- *
- @@ -75,12 +78,14 @@
- L2Character target;
- L2Effect effect;
- - int count = (int)skill.getPower();
- - for (L2Object obj: targets)
- + int count = (int) skill.getPower();
- + // Chance for buff to be stealed
- + int chance = 70;
- + for (L2Object obj : targets)
- {
- if (!(obj instanceof L2Character))
- continue;
- - target = (L2Character)obj;
- + target = (L2Character) obj;
- if (target.isDead())
- continue;
- @@ -90,67 +95,53 @@
- Env env;
- int lastSkillId = 0;
- - final L2Effect[] effects = target.getAllEffects();
- final ArrayList<L2Effect> toSteal = new ArrayList<L2Effect>(count);
- + final ArrayList<L2Effect> effects = new ArrayList<L2Effect>(target.getAllEffects().length);
- - for (int i = effects.length; --i >= 0;) // reverse order
- + for (L2Effect eff : target.getAllEffects())
- {
- - effect = effects[i];
- - if (effect == null)
- + if (eff == null)
- continue;
- - if (!effect.canBeStolen()) // remove effect if can't be stolen
- - {
- - effects[i] = null;
- + if (!eff.canBeStolen()) // Do not add effect if can't be stolen
- continue;
- - }
- // if eff time is smaller than 5 sec, will not be stolen, just to save CPU,
- // avoid synchronization(?) problems and NPEs
- - if (effect.getAbnormalTime() - effect.getTime() < 5)
- - {
- - effects[i] = null;
- + if (eff.getAbnormalTime() - eff.getTime() < 5)
- continue;
- - }
- - // first pass - only dances/songs
- - if (!effect.getSkill().isDance())
- - continue;
- -
- - if (effect.getSkill().getId() != lastSkillId)
- - {
- - lastSkillId = effect.getSkill().getId();
- - count--;
- - }
- -
- - toSteal.add(effect);
- - if (count == 0)
- - break;
- + effects.add(eff);
- }
- -
- - if (count > 0) // second pass
- + while (count >= 0 && effects.size() > 0)
- {
- - lastSkillId = 0;
- - for (int i = effects.length; --i >= 0;)
- + if (Rnd.get(1, 100) >= 100 - chance)
- {
- - effect = effects[i];
- - if (effect == null)
- - continue;
- -
- - // second pass - all except dances/songs
- - if (effect.getSkill().isDance())
- - continue;
- -
- - if (effect.getSkill().getId() != lastSkillId)
- + if (effects.size() >= (int) skill.getPower() - 1)
- {
- - lastSkillId = effect.getSkill().getId();
- - count--;
- + effect = effects.get(Rnd.get(1, effects.size() - 1));
- +
- + if (effect.getSkill().getId() != lastSkillId)
- + {
- + lastSkillId = effect.getSkill().getId();
- + count--;
- + toSteal.add(effect);
- + }
- }
- -
- - toSteal.add(effect);
- - if (count == 0)
- - break;
- + else
- + {
- + if (effects.size() > 0)
- + {
- + for (L2Effect eff : effects)
- + {
- + toSteal.add(eff);
- + count--;
- + }
- + }
- + }
- }
- + else
- + count--;
- }
- if (toSteal.size() == 0)
- @@ -178,6 +169,7 @@
- }
- // Finishing stolen effect
- eff.exit();
- + CancelSystem.onCancel(target.getActingPlayer(), eff);
- }
- catch (RuntimeException e)
- {
- @@ -211,4 +203,4 @@
- return SKILL_IDS;
- }
- -}
- \ No newline at end of file
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement