/* * This file is part of the L2J Mobius project. * * 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 . */ package handlers.effecthandlers; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.effects.EffectFlag; import com.l2jmobius.gameserver.model.effects.L2EffectType; import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; import com.l2jmobius.gameserver.model.skills.Skill; import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.model.stats.Stats; import com.l2jmobius.gameserver.network.SystemMessageId; /** * Lethal effect implementation. * @author Adry_85 */ public final class Lethal extends AbstractEffect { private final double _fullLethal; private final double _halfLethal; public Lethal(StatsSet params) { _fullLethal = params.getDouble("fullLethal", 0); _halfLethal = params.getDouble("halfLethal", 0); } @Override public boolean isInstant() { return true; } @Override public L2EffectType getEffectType() { return L2EffectType.LETHAL_ATTACK; } @Override public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item) { if (effector.isPlayer() && !effector.getAccessLevel().canGiveDamage()) { return; } if (skill.getMagicLevel() < (effected.getLevel() - 6)) { return; } if (!effected.isLethalable() || effected.isHpBlocked()) { return; } if (effector.isPlayer() && effected.isPlayer() && effected.isAffected(EffectFlag.FACEOFF) && (effected.getActingPlayer().getAttackerObjId() != effector.getObjectId())) { return; } final double chanceMultiplier = Formulas.calcAttributeBonus(effector, effected, skill) * Formulas.calcGeneralTraitBonus(effector, effected, skill.getTraitType(), false) * effected.getStat().getValue(Stats.INSTANT_KILL_RESIST, 1); // Lethal Strike if (Rnd.get(100) < (_fullLethal * chanceMultiplier)) { // for Players CP and HP is set to 1. if (effected.isPlayer()) { effected.setCurrentCp(1); effected.setCurrentHp(1); effected.sendPacket(SystemMessageId.LETHAL_STRIKE); } // for Monsters HP is set to 1. else if (effected.isMonster() || effected.isSummon()) { effected.setCurrentHp(1); } effector.sendPacket(SystemMessageId.HIT_WITH_LETHAL_STRIKE); } // Half-Kill else if (Rnd.get(100) < (_halfLethal * chanceMultiplier)) { // for Players CP is set to 1. if (effected.isPlayer()) { effected.setCurrentCp(1); effected.sendPacket(SystemMessageId.HALF_KILL); effected.sendPacket(SystemMessageId.YOUR_CP_WAS_DRAINED_BECAUSE_YOU_WERE_HIT_WITH_A_HALF_KILL_SKILL); } // for Monsters HP is set to 50%. else if (effected.isMonster() || effected.isSummon()) { effected.setCurrentHp(effected.getCurrentHp() * 0.5); } effector.sendPacket(SystemMessageId.HALF_KILL); } // No matter if lethal succeeded or not, its reflected. Formulas.calcDamageReflected(effector, effected, skill, false); } }