}
// Mystic Immunity Makes a target temporarily immune to buffs/debuffs
if(effected.isEffectImmune())
{
//effector.sendMessage(new CustomMessage("l2p.gameserver.skills.Formulas.NoChance", effector).addString(effected.getName()).addString(getName()));
effector.sendPacket(new SystemMessage(SystemMessage.C1_HAS_RESISTED_YOUR_S2).addString(effected.getName()).addSkillName(_displayId, _displayLevel));
return;
}
if (Config.DisableDeBuffInCommandChannel)
{
if (!(effector instanceof L2Player))
return;
if (!(effected instanceof L2Player))
return;
L2Party p1 = ((L2Player) effector).getParty();
L2Party p2 = ((L2Player) effected).getParty();
if (p1 == null || p2 == null)
return;
L2CommandChannel c1 = p1.getCommandChannel();
L2CommandChannel c2 = p2.getCommandChannel();
if (c1 == null || c2 == null)
return;
if (getSkillType() == SkillType.DEBUFF && c1 == c2)
return;
}
// No effect on invulnerable characters unless they cast it themselves.
if(effector != effected && isOffensive() && effected.isInvul())
{
if(effector.isPlayer())
{
effector.sendPacket(new SystemMessage(SystemMessage.C1_HAS_RESISTED_YOUR_S2).addString(effected.getName()).addSkillName(_displayId, _displayLevel));
}
return;
}
// No effect on doors/walls
if(effected.isDoor())
{
return;
}
if(getSkillType() == SkillType.TRANSFORMATION)
{
if(effected.isPlayer())
{
L2Player p = (L2Player) effected;
if(p.isMounted())
{
p.unMount();
}
}
}
final int sps = effector.getChargedSpiritShot();
ThreadPoolManager.getInstance().executeGeneral(new Runnable()
{
public void run()
{
final int mastery = effector.getSkillMastery(getId());
if(mastery == 2 && !applyOnCaster)
{
effector.removeSkillMastery(getId());
}
boolean success = false;
loop:
for(EffectTemplate et : _effectTemplates)
{
if(applyOnCaster != et._applyOnCaster || et._counter == 0)
{
continue;
}
L2Character target = et._applyOnCaster ? effector : effected;
if(et._stackOrder == -1)
{
if(et._stackType != EffectTemplate.NO_STACK)
{
for(L2Effect e : target.getEffectList().getAllEffects())
{
if(e.getStackType().equalsIgnoreCase(et._stackType))
{
continue loop;
}
}
}
else if(target.getEffectList().getEffectsBySkillId(getId()) != null)
{
continue;
}
}
if(target.isRaid() && et.getEffectType().isRaidImmune())
{
effector.sendPacket(new SystemMessage(SystemMessage.C1_HAS_RESISTED_YOUR_S2).addString(effected.getName()).addSkillName(_displayId, _displayLevel));
continue;
}
if(isBlockedByChar(target, et))
{
continue;
}
Env env = new Env(effector, target, L2Skill.this);
int chance = et.getParam().getInteger("activateRate", getActivateRate());
if(calcChance && !et._applyOnCaster)
{
env.value = chance;
if(!Formulas.calcSkillSuccess(env, et.getEffectType().getResistType(), et.getEffectType().getAttibuteType(), sps))
{
effector.sendPacket(new SystemMessage(SystemMessage.C1_HAS_RESISTED_YOUR_S2).addString(effected.getName()).addSkillName(_displayId, _displayLevel));
continue;
}
}
if(target != effector && isOffensive() && !effector.isTrap())
{
if(Rnd.chance(target.calcStat(isMagic() ? Stats.REFLECT_MAGIC_DEBUFF : Stats.REFLECT_PHYSIC_DEBUFF, 0, effector, L2Skill.this)))
{
target.sendPacket(new SystemMessage(SystemMessage.YOU_COUNTERED_C1S_ATTACK).addName(effector));
effector.sendPacket(new SystemMessage(SystemMessage.C1_DODGES_THE_ATTACK).addName(target));
target = effector;
env.target = target;
}
}
if(success)
{
env.arraymap = ArrayMap.set(env.arraymap, Env.FirstEffectSuccess, Integer.MAX_VALUE);
}
if(mastery != 0)
{
env.arraymap = ArrayMap.set(env.arraymap, Env.SkillMastery, mastery);
}
final L2Effect e = et.getEffect(env);
if(e != null)
{
if(chance > 0)
{
success = true;
}
if(e._count == 1 && e.getPeriod() == 0)
{
// Эффекты однократного действия не шедулятся, а применяются немедленно
// Как правило это побочные эффекты для скиллов моментального действия
e.onStart();
e.onActionTime();
e.onExit();
}
else
{
e.getEffected().getEffectList().addEffect(e);
}
}
}
if(calcChance)
{
if(success)
{
effector.sendPacket(new SystemMessage(SystemMessage.S1_HAS_SUCCEEDED).addSkillName(_displayId, _displayLevel));
}
else
{
effector.sendPacket(new SystemMessage(SystemMessage.S1_HAS_FAILED).addSkillName(_displayId, _displayLevel));
}
}
}
});
}