{
if (!Rnd.chance(info.getChance()))
{
return;
}
final Skill skill = info.getSkill();
Creature target = null;
if (player.isInCombat())
{
GameObject object = player.getTarget();
target = (object != null) && object.isCreature() ? (Creature) object : null;
}
if ((target == null) || target.isDead() || (target.isDoor() && !info.isCanAttackDoor()) || !player.isInRangeZ(target, skill.getCastRange()) || !target.isAutoAttackable(player))
{
return;
}
final Creature aimTarget = target;
player.broadcastPacket(new MagicSkillUse(player, target, skill.getDisplayId(), skill.getDisplayLevel(), skill.getHitTime(), 0));
player.disableSkill(skill, delay * 1000L);
ThreadPoolManager.getInstance().schedule(new RunnableImpl()
{
@Override
public void runImpl()
{
final List<Creature> targets = new ArrayList<>(1);
targets.add(aimTarget);
player.broadcastPacket(new MagicSkillLaunched(player.getObjectId(), skill.getDisplayId(), skill.getDisplayLevel(), targets));
final boolean succ = Formulas.calcSkillSuccess(player, aimTarget, skill, info.getChance());
if (succ)
{
player.callSkill(skill, targets, false);
}
if (aimTarget.isNpc())
{
if (aimTarget.paralizeOnAttack(player))
{
if (Config.PARALIZE_ON_RAID_DIFF)
{
player.paralizeMe(aimTarget);
}
}
else
{
int damage = skill.getEffectPoint() != 0 ? skill.getEffectPoint() : (int) skill.getPower();
aimTarget.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, player, damage);
}
}
}
}, skill.getHitTime());
}