Lineage Justice

Spells & Skills

Lookup and validate skills and spells.

CounterMirror
MP: 10 HP: 0 Item: 40319 Amount: 1 Duration: 16 Skill Type: Change
Delay: 1000 Cast Invis: Yes Ignores CM: Yes Element: None Range: N/A Area: N/A
Dmg Value: 0.0 Dmg Dice: 0 Dice Count: 0 Prob Value: 0 Prob Dice: 0 Prob Max: 99
L1Magic Execution:

private static boolean tryCounterMirror(L1PcInstance target, int type, L1PcInstance pcAttacker, L1NpcInstance npcAttacker, int damage) {

	if (!target.hasSkillEffect(COUNTER_MIRROR) || type == NPC_NPC || type == PC_NPC || target.getInt() <= ThreadLocalRandom.current().nextInt(100) )
		return false;
	if (type == NPC_PC) {
		int npcId = npcAttacker.getNpcTemplate().getNpcId();
		// Lindvior, Antharas, Fafurion, Valakas
		if (npcId == 45681 || npcId == 45682 || npcId == 45683 || npcId == 45684 || !npcAttacker.getNpcTemplate().isEnableErase())
			return false;
		npcAttacker.broadcastPacket(new S_DoActionGFX(npcAttacker.getId(), ActionCodes.ACTION_Damage));
		npcAttacker.receiveDamage(target, damage);
	} else { // PC_PC
		if (pcAttacker.hasSkillEffect(COUNTER_MAGIC)) {
			pcAttacker.removeSkillEffect(COUNTER_MAGIC);
			int castgfx = 10702;
			pcAttacker.broadcastPacket(new S_SkillSound(pcAttacker.getId(), castgfx));
			pcAttacker.sendPackets(new S_SkillSound(pcAttacker.getId(), castgfx));
			pcAttacker.sendPackets(new S_SystemMessage("\\fUYou've countered a magical attack."));
		} else {
			damage /= 2;
			if (pcAttacker.hasSkillEffect(IMMUNE_TO_HARM)) {
				damage /= 2;
			}
			if (pcAttacker.hasSkillEffect(ERASE_MAGIC)) {
				pcAttacker.removeSkillEffect(ERASE_MAGIC);
				damage *= 2;
			}
			pcAttacker.sendAndBroadcast(new S_DoActionGFX(pcAttacker.getId(), ActionCodes.ACTION_Damage));
			pcAttacker.receiveDamage(target, damage, false);
		}
	}

	target.sendAndBroadcast(new S_SkillSound(target.getId(), 4395));
	target.killSkillEffectTimer(COUNTER_MIRROR);
	return true;
}