}
if ((effected.isEffectImmune() || (effected.isInvul() && isOffensive())) && (effector != effected))
{
if (effector.isPlayer())
{
effector.sendPacket(new SystemMessage(SystemMessage.C1_HAS_RESISTED_YOUR_S2).addName(effected).addSkillName(_displayId, _displayLevel));
}
return;
}
if (effected.isDoor() || (effected.isAlikeDead() && !isPreservedOnDeath()))
{
return;
}
ThreadPoolManager.getInstance().execute(new RunnableImpl()
{
@Override
public void runImpl()
{
boolean success = false;
boolean skillMastery = false;
int sps = effector.getChargedSpiritShot();
if (effector.getSkillMastery(getId()) == 2)
{
skillMastery = true;
effector.removeSkillMastery(getId());
}
for (EffectTemplate et : getEffectTemplates())
{
if ((applyOnCaster != et._applyOnCaster) || (et._count == 0))
{
continue;
}
Creature character = et._applyOnCaster || (et._isReflectable && skillReflected) ? effector : effected;
List<Creature> targets = new LazyArrayList<Creature>(1);
targets.add(character);
if (et._applyOnSummon && character.isPlayer())
{
for (Summon summon : character.getPlayer().getSummonList())
{
if ((summon != null) && summon.isServitor() && !isOffensive() && !isToggle() && !isCubicSkill())
{
targets.add(summon);
}
}
}
loop:
for (Creature target : targets)
{
if (target.isAlikeDead() && !isPreservedOnDeath())
{
continue;
}
if (target.isRaid() && et.getEffectType().isRaidImmune())
{
continue;
}
if (((effected.isBuffImmune() && !isOffensive()) || (effected.isDebuffImmune() && isOffensive())) && (et.getPeriod() > 0) && (effector != effected))
{
continue;
}
if (isBlockedByChar(target, et))
{
continue;
}
if (et._stackOrder == -1)
{
if (!et._stackTypes.contains(EffectTemplate.NO_STACK))
{
for (Effect e : target.getEffectList().getAllEffects())
{
for (String arg : et._stackTypes)
{
if (e.getStackType().contains(arg))
{
continue loop;
}
}
}
}
else if (target.getEffectList().getEffectsBySkillId(getId()) != null)
{
continue;
}
}
Env env = new Env(effector, target, Skill.this);
int chance = et.chance(getActivateRate());
if ((calcChance || (chance >= 0)) && !et._applyOnCaster)
{
env.value = chance;
if (!Formulas.calcSkillSuccess(env, et, sps))
{
continue;
}
}
if (_isReflectable && et._isReflectable && isOffensive() && (target != effector) && !effector.isTrap())
{
if (Rnd.chance(target.calcStat(isMagic() ? Stats.REFLECT_MAGIC_DEBUFF : Stats.REFLECT_PHYSIC_DEBUFF, 0, effector, Skill.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.value = Integer.MAX_VALUE;
}
final Effect e = et.getEffect(env);
if (e != null)
{
if (chance > 0)
{
success = true;
}
if (e.isOneTime())
{
if (e.checkCondition())
{
e.onStart();
e.onActionTime();
e.onExit();
}
}
else
{
int count = et.getCount();
long period = et.getPeriod();
if (skillMastery)
{
if (count > 1)
{
count *= 2;
}
else
{
period *= 2;
}
}
if (!et._applyOnCaster && isOffensive() && !isIgnoreResists() && !effector.isRaid())
{
double res = 0;
if (et.getEffectType().getResistType() != null)
{
res += effected.calcStat(et.getEffectType().getResistType(), effector, Skill.this);
}
if (et.getEffectType().getAttributeType() != null)
{
res -= effector.calcStat(et.getEffectType().getAttributeType(), effected, Skill.this);
}
res += effected.calcStat(Stats.DEBUFF_RESIST, effector, Skill.this);
if (res != 0)
{
double mod = 1 + Math.abs(0.01 * res);
if (res > 0)
{
mod = 1. / mod;
}
if (count > 1)
{
count = (int) Math.floor(Math.max(count * mod, 1));
}
else
{
period = (long) Math.floor(Math.max(period * mod, 1));
}
}
}
if (timeConst > 0L)
{
if (count > 1)
{
period = timeConst / count;
}
else
{
period = timeConst;
}
}
else if (timeMult > 1.0)
{
if (count > 1)
{
count *= timeMult;
}
else
{
period *= timeMult;
}
}
e.setCount(count);
e.setPeriod(period);
e.schedule();
}
}
}
}
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));
}
}
}
});
}