{
if (Rnd.chance(5))
{
info.damage = 0;
target.sendPacket(SystemMsg.YOUR_EXCELLENT_SHIELD_DEFENSE_WAS_A_SUCCESS);
attacker.sendPacket(new SystemMessage(SystemMessage.C1_RESISTED_C2S_MAGIC).addName(target).addName(attacker));
}
else
{
target.sendPacket(SystemMsg.YOUR_SHIELD_DEFENSE_HAS_SUCCEEDED);
attacker.sendPacket(new SystemMessage(SystemMessage.YOUR_OPPONENT_HAS_RESISTANCE_TO_MAGIC_THE_DAMAGE_WAS_DECREASED));
}
}
int levelDiff = target.getLevel() - attacker.getLevel();
if ((info.damage > 1) && skill.isDeathlink())
{
info.damage *= 1.8 * (1.0 - attacker.getCurrentHpRatio());
}
if ((info.damage > 1) && skill.isBasedOnTargetDebuff())
{
info.damage *= 1 + (0.05 * target.getEffectList().getAllEffects().size());
}
info.damage += info.lethal_dmg;
if (skill.getSkillType() == SkillType.MANADAM)
{
info.damage = Math.max(1, info.damage / 4.);
}
if (isPvP && (info.damage > 1))
{
info.damage *= attacker.calcStat(Stats.PVP_MAGIC_SKILL_DMG_BONUS, 1, null, null);
info.damage /= target.calcStat(Stats.PVP_MAGIC_SKILL_DEFENCE_BONUS, 1, null, null);
}
double magic_rcpt = target.calcStat(Stats.MAGIC_RESIST, attacker, skill) - attacker.calcStat(Stats.MAGIC_POWER, target, skill);
double failChance = 4. * Math.max(1., levelDiff) * (1. + (magic_rcpt / 100.));
if (Rnd.chance(failChance))
{
if (levelDiff > 9)
{
info.damage = 0;
SystemMessage msg = new SystemMessage(SystemMessage.C1_RESISTED_C2S_MAGIC).addName(target).addName(attacker);
attacker.sendPacket(msg);
target.sendPacket(msg);
}
else
{
info.damage /= 2;
SystemMessage msg = new SystemMessage(SystemMessage.DAMAGE_IS_DECREASED_BECAUSE_C1_RESISTED_AGAINST_C2S_MAGIC).addName(target).addName(attacker);
attacker.sendPacket(msg);
target.sendPacket(msg);
}
}
if ((info.damage > 1) && skill.isMagic() && calcMagicMiss(attacker,target))
{
attacker.sendPacket(new SystemMessage(SystemMessage.C1S_ATTACK_WENT_ASTRAY).addName(attacker));
target.sendPacket(new SystemMessage(SystemMessage.C1_HAS_EVADED_C2S_ATTACK).addName(target).addName(attacker));
info.damage = 0;
}
if (info.damage > 0)
{
attacker.displayGiveDamageMessage(target, (int) info.damage, info.crit, false, false, true);