{
// Get a target
if(!(targets[index] instanceof L2Character))
continue;
L2Character target = (L2Character) targets[index];
if(target == null || target.isDead()) //bypass if target is null or dead
continue;
switch(type)
{
case BETRAY:
{
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
skill.getEffects(activeChar, target, ss, sps, bss);
else
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
sm.addString(target.getName());
sm.addSkillName(skill.getId());
activeChar.sendPacket(sm);
sm = null;
}
break;
}
case FAKE_DEATH:
{
// stun/fakedeath is not mdef dependant, it depends on lvl difference, target CON and power of stun
skill.getEffects(activeChar, target, ss, sps, bss);
break;
}
case STUN:
// Calculate skill evasion
if(Formulas.calcPhysicalSkillEvasion(target, skill))
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.ATTACK_FAILED));
break;
}
// Calculate vengeance
if(target.vengeanceSkill(skill))
{
target = activeChar;
}
case ROOT:
{
if(target.reflectSkill(skill))
target = activeChar;
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
skill.getEffects(activeChar, target, ss, sps, bss);
else
{
if(activeChar instanceof L2PcInstance)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
sm.addString(target.getName());
sm.addSkillName(skill.getDisplayId());
activeChar.sendPacket(sm);
sm = null;
}
}
break;
}
case SLEEP:
case PARALYZE: //use same as root for now
{
if(target.reflectSkill(skill))
target = activeChar;
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
skill.getEffects(activeChar, target, ss, sps, bss);
else
{
if(activeChar instanceof L2PcInstance)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
sm.addString(target.getName());
sm.addSkillName(skill.getDisplayId());
activeChar.sendPacket(sm);
sm = null;
}
}
break;
}
case CONFUSION:
case MUTE:
{
if(target.reflectSkill(skill))
target = activeChar;
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
{
skill.getEffects(activeChar, target, ss, sps, bss);
}
else
{
if(activeChar instanceof L2PcInstance)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
sm.addString(target.getName());
sm.addSkillName(skill.getDisplayId());
activeChar.sendPacket(sm);
sm = null;
}
}
break;
}
case CONFUSE_MOB_ONLY:
{
// do nothing if not on mob
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
{
L2Effect[] effects = target.getAllEffects();
for(L2Effect e : effects)
{
if(e.getSkill().getSkillType() == type)
e.exit(false);
}
skill.getEffects(activeChar, target, ss, sps, bss);
}
else
{
if(activeChar instanceof L2PcInstance)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
activeChar.sendPacket(sm);
sm = null;
}
}
}
case AGGDAMAGE:
{
if(target instanceof L2Attackable)
target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, (int) ((150 * skill.getPower()) / (target.getLevel() + 7)));
//TODO [Nemesiss] should this have 100% chance?
skill.getEffects(activeChar, target, ss, sps, bss);
break;
}
case AGGREDUCE:
{
// these skills needs to be rechecked
if(target instanceof L2Attackable)
{
skill.getEffects(activeChar, target, ss, sps, bss);
double aggdiff = ((L2Attackable) target).getHating(activeChar) - target.calcStat(Stats.AGGRESSION, ((L2Attackable) target).getHating(activeChar), target, skill);
if(skill.getPower() > 0)
((L2Attackable) target).reduceHate(null, (int) skill.getPower());
else if(aggdiff > 0)
((L2Attackable) target).reduceHate(null, (int) aggdiff);
}
break;
}
case AGGREDUCE_CHAR:
{
// these skills needs to be rechecked
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
{
if(target instanceof L2Attackable)
{
L2Attackable targ = (L2Attackable) target;
targ.stopHating(activeChar);
if(targ.getMostHated() == null)
{
((L2AttackableAI) targ.getAI()).setGlobalAggro(-25);
targ.clearAggroList();
targ.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
targ.setWalking();
}
targ = null;
}
skill.getEffects(activeChar, target, ss, sps, bss);
}
else
{
if(activeChar instanceof L2PcInstance)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
sm.addString(target.getName());
sm.addSkillName(skill.getId());
activeChar.sendPacket(sm);
sm = null;
}
}
break;
}
case AGGREMOVE:
{
// these skills needs to be rechecked
if(target instanceof L2Attackable && !target.isRaid())
{
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
{
if(skill.getTargetType() == L2Skill.SkillTargetType.TARGET_UNDEAD)
{
if(target.isUndead())
((L2Attackable) target).reduceHate(null, ((L2Attackable) target).getHating(((L2Attackable) target).getMostHated()));
}
else
((L2Attackable) target).reduceHate(null, ((L2Attackable) target).getHating(((L2Attackable) target).getMostHated()));
}
else
{
if(activeChar instanceof L2PcInstance)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
sm.addString(target.getName());
sm.addSkillName(skill.getId());
activeChar.sendPacket(sm);
sm = null;
}
}
}
break;
}
case UNBLEED:
{
negateEffect(target, SkillType.BLEED, skill.getPower());
break;
}
case UNPOISON:
{
negateEffect(target, SkillType.POISON, skill.getPower());
break;
}
case ERASE:
{
if(Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss)
// Doesn't affect siege golem, wild hog cannon and Pets
&& !(target instanceof L2SiegeSummonInstance) && !(target instanceof L2PetInstance))
{
L2PcInstance summonOwner = null;
L2Summon summonPet = null;
summonOwner = ((L2Summon) target).getOwner();
summonPet = summonOwner.getPet();
summonPet.unSummon(summonOwner);
summonPet = null;
SystemMessage sm = new SystemMessage(SystemMessageId.LETHAL_STRIKE);
summonOwner.sendPacket(sm);
sm = null;
}
else
{
if(activeChar instanceof L2PcInstance)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
sm.addString(target.getName());
sm.addSkillName(skill.getId());
activeChar.sendPacket(sm);
sm = null;
}
}
break;
}
case MAGE_BANE: {
for (L2Object t : targets) {
L2Character target1 = (L2Character) t;
if (target1.reflectSkill(skill)) {
target1 = activeChar;
}
if (!Formulas.getInstance().calcSkillSuccess(activeChar,
target1, skill, ss, sps, bss)) {
continue;
}
L2Effect[] effects = target1.getAllEffects();
for (L2Effect e : effects) {
if (e.getStackType().equals("mAtkSpeedUp")
|| e.getStackType().equals("mAtk")
|| e.getSkill().getId() == 1059
|| e.getSkill().getId() == 1085
|| e.getSkill().getId() == 4356
|| e.getSkill().getId() == 4355)
e.exit();
}
}
break;
}
case WARRIOR_BANE: {
for (L2Object t : targets) {
L2Character target1 = (L2Character) t;
if (target1.reflectSkill(skill)) {
target1 = activeChar;
}
if (!Formulas.getInstance().calcSkillSuccess(activeChar,
target1, skill, ss, sps, bss)) {
continue;
}
L2Effect[] effects = target1.getAllEffects();
for (L2Effect e : effects) {
if (e.getStackType().equals("SpeedUp")
|| e.getStackType().equals("pAtkSpeedUp")
|| e.getSkill().getId() == 1204
|| e.getSkill().getId() == 1086