123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- /*
- * Copyright (C) 2004-2013 L2J DataPack
- *
- * This file is part of L2J DataPack.
- *
- * L2J DataPack 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.
- *
- * L2J DataPack 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 handlers.skillhandlers;
- import java.util.List;
- import com.l2jserver.gameserver.datatables.SkillTable;
- import com.l2jserver.gameserver.enums.ShotType;
- import com.l2jserver.gameserver.handler.ISkillHandler;
- import com.l2jserver.gameserver.instancemanager.DuelManager;
- import com.l2jserver.gameserver.model.L2Object;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.L2Summon;
- import com.l2jserver.gameserver.model.actor.instance.L2ClanHallManagerInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.effects.L2Effect;
- import com.l2jserver.gameserver.model.skills.L2Skill;
- import com.l2jserver.gameserver.model.skills.L2SkillType;
- import com.l2jserver.gameserver.model.stats.Env;
- import com.l2jserver.gameserver.model.stats.Formulas;
- import com.l2jserver.gameserver.network.SystemMessageId;
- public class Continuous implements ISkillHandler
- {
- private static final L2SkillType[] SKILL_IDS =
- {
- L2SkillType.BUFF,
- L2SkillType.DEBUFF,
- L2SkillType.CONT,
- L2SkillType.FUSION
- };
-
- @Override
- public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
- {
- boolean acted = true;
-
- L2PcInstance player = null;
- if (activeChar.isPlayer())
- {
- player = activeChar.getActingPlayer();
- }
-
- if (skill.getEffectId() != 0)
- {
- L2Skill sk = SkillTable.getInstance().getInfo(skill.getEffectId(), skill.getEffectLvl() == 0 ? 1 : skill.getEffectLvl());
-
- if (sk != null)
- {
- skill = sk;
- }
- }
-
- boolean ss = skill.useSoulShot() && activeChar.isChargedShot(ShotType.SOULSHOTS);
- boolean sps = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
- boolean bss = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
-
- for (L2Character target : (L2Character[]) targets)
- {
- byte shld = 0;
-
- if (Formulas.calcBuffDebuffReflection(target, skill))
- {
- target = activeChar;
- }
-
- // Player holding a cursed weapon can't be buffed and can't buff
- if ((skill.getSkillType() == L2SkillType.BUFF) && !(activeChar instanceof L2ClanHallManagerInstance))
- {
- if (target != activeChar)
- {
- if (target.isPlayer())
- {
- L2PcInstance trg = target.getActingPlayer();
- if (trg.isCursedWeaponEquipped())
- {
- continue;
- }
- else if (trg.getBlockCheckerArena() != -1)
- {
- continue;
- }
- }
- else if ((player != null) && player.isCursedWeaponEquipped())
- {
- continue;
- }
- }
- }
-
- if (skill.isBad())
- {
- shld = Formulas.calcShldUse(activeChar, target, skill);
- acted = Formulas.calcSkillSuccess(activeChar, target, skill, shld, ss, sps, bss);
- }
-
- if (acted)
- {
- if (skill.isToggle())
- {
- List<L2Effect> effects = target.getAllEffects();
- if (effects != null)
- {
- for (L2Effect e : effects)
- {
- if (e != null)
- {
- if (e.getSkill().getId() == skill.getId())
- {
- e.exit();
- return;
- }
- }
- }
- }
- }
-
- // if this is a debuff let the duel manager know about it
- // so the debuff can be removed after the duel
- // (player & target must be in the same duel)
- if (target.isPlayer() && target.getActingPlayer().isInDuel() && ((skill.getSkillType() == L2SkillType.DEBUFF) || (skill.getSkillType() == L2SkillType.BUFF)) && (player != null) && (player.getDuelId() == target.getActingPlayer().getDuelId()))
- {
- DuelManager dm = DuelManager.getInstance();
- for (L2Effect buff : skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss)))
- {
- if (buff != null)
- {
- dm.onBuff(target.getActingPlayer(), buff);
- }
- }
- }
- else
- {
- List<L2Effect> effects = skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
- L2Summon summon = target.getSummon();
- if ((summon != null) && (summon != activeChar) && summon.isServitor() && !effects.isEmpty())
- {
- if (effects.get(0).canBeStolen() || skill.isHeroSkill() || skill.isStatic())
- {
- skill.getEffects(activeChar, target.getSummon(), new Env(shld, ss, sps, bss));
- }
- }
- }
- }
- else
- {
- activeChar.sendPacket(SystemMessageId.ATTACK_FAILED);
- }
- }
-
- // self Effect :]
- if (skill.hasSelfEffects())
- {
- final L2Effect effect = activeChar.getFirstEffect(skill.getId());
- if ((effect != null) && effect.isSelfEffect())
- {
- // Replace old effect with new one.
- effect.exit();
- }
- skill.getEffectsSelf(activeChar);
- }
-
- activeChar.setChargedShot(bss ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
- }
-
- @Override
- public L2SkillType[] getSkillIds()
- {
- return SKILL_IDS;
- }
- }
|