/* * 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.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.effects.AbstractEffect; import com.l2jmobius.gameserver.model.effects.L2EffectType; import com.l2jmobius.gameserver.model.skills.BuffInfo; import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; /** * MagicalAttack-damage over time effect implementation. * @author Nik */ public final class MagicalDamOverTime extends AbstractEffect { private final double _power; private final boolean _canKill; public MagicalDamOverTime(StatsSet params) { _power = params.getDouble("power", 0); _canKill = params.getBoolean("canKill", false); setTicks(params.getInt("ticks")); } @Override public L2EffectType getEffectType() { return L2EffectType.MAGICAL_DMG_OVER_TIME; } @Override public boolean onActionTime(BuffInfo info) { final L2Character activeChar = info.getEffector(); final L2Character target = info.getEffected(); if (target.isDead()) { return false; } double damage = Formulas.calcMagicDam(activeChar, target, info.getSkill(), activeChar.getMAtk(), _power, target.getMDef(), false, false, false); // In retail spiritshots change nothing. damage *= getTicksMultiplier(); if (damage >= (target.getCurrentHp() - 1)) { if (info.getSkill().isToggle()) { target.sendPacket(SystemMessageId.YOUR_SKILL_HAS_BEEN_CANCELED_DUE_TO_LACK_OF_HP); return false; } // For DOT skills that will not kill effected player. if (!_canKill) { // Fix for players dying by DOTs if HP < 1 since reduceCurrentHP method will kill them if (target.getCurrentHp() <= 1) { return info.getSkill().isToggle(); } damage = target.getCurrentHp() - 1; } } info.getEffected().reduceCurrentHp(damage, info.getEffector(), info.getSkill(), true, false, false, false); return info.getSkill().isToggle(); } }