Lineage Justice

Spells & Skills

Lookup and validate skills and spells.

CounterBarrier
MP: 10 HP: 100 Item: None Amount: N/A Duration: 64 Skill Type: Change
Delay: 3000 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: 20 Prob Dice: 5 Prob Max: N/A
L1PcInstance Attack:

@Override
public void onAction(L1PcInstance attacker, int skillId) {
		
	if (getCurrentHp() > 0 && !isDead()) {
		attacker.delInvis();
			
		boolean isCounterBarrier = false;
		int rnd = _random.nextInt(100) + 1;

		L1Attack attack = new L1Attack(attacker, this);

		if (attack.calcHit()) {
			if (hasSkillEffect(COUNTER_BARRIER) && !hasSkillEffect(EARTH_BIND)) {
				L1Magic magic = new L1Magic(this, attacker);
				if (magic.calcProbabilityMagic(COUNTER_BARRIER)
						&& attack.isShortDistance() && !attacker.isFoeSlayer()) {
						isCounterBarrier = true;
				}
			}
			if (!isCounterBarrier) {
				attacker.setPetTarget(this);
				attack.calcDamage();
				attack.calcStaffOfMana();
				attack.addPcPoisonAttack(attacker, this);
				attack.addChaserAttack();
				attack.addEvilAttack();
			}
				
		}
		if (isCounterBarrier) {
			attack.actionCounterBarrier();
			attack.commitCounterBarrier();
		} else {
			attack.action();
			attack.commit();
		}
	}
}
L1NpcInstance Attack:

public void attackTarget(L1Character target) {
                                
	boolean isCounterBarrier = false;
	L1Attack attack = new L1Attack(this, target);
	
	if (attack.calcHit()) {
		if (target.hasSkillEffect(COUNTER_BARRIER)) {
			L1Magic magic = new L1Magic(target, this);
			if (magic.calcProbabilityMagic(COUNTER_BARRIER)
					&& attack.isShortDistance()) {
				isCounterBarrier = true;
			}
		}
		if (!isCounterBarrier) {
			attack.calcDamage();
		} else {
			attack.calcDamage();
		}
			
		if (target instanceof L1ScarecrowInstance) {
			if (target.getHeading() < 7) {
				target.setHeading(target.getHeading() + 1);
			} else {
				target.setHeading(0);
			}
			target.broadcastPacket(new S_ChangeHeading(target));
		}
	}
		
	if (isCounterBarrier) {
		attack.actionCounterBarrier();
		attack.commitCounterBarrier();
	} else {
		attack.action();
		attack.commit();
	}
			
	setSleepTime(calcSleepTime(getAtkSpeed(), ATTACK_SPEED));
}
L1Magic Probability:

private int calcProbability(int skillId) {
	L1Skill skill = SkillTable.getInstance().findBySkillId(skillId);
	int attackLevel = 0;
	int defenseLevel = 0;
	int probability = 0;

	if (_calcType == PC_PC || _calcType == PC_NPC) {
		attackLevel = _pc.getLevel();
	} else {
		attackLevel = _npc.getLevel();
	}
		
	if (_calcType == PC_PC || _calcType == NPC_PC) {
		defenseLevel = _targetPc.getLevel();
	} else {
		defenseLevel = _targetNpc.getLevel();
		if (skillId == RETURN_TO_NATURE) {
			if (_targetNpc instanceof L1SummonInstance) {
				L1SummonInstance summon = (L1SummonInstance) _targetNpc;
				defenseLevel = summon.getMaster().getLevel();
			}
		}
	}

	int levelDifference = attackLevel - defenseLevel;

	if (skillId == SHOCK_STUN || skillId == MASS_SHOCK_STUN ||
			skillId == COUNTER_BARRIER ||
			skillId == ELEMENTAL_FALL_DOWN || skillId == RETURN_TO_NATURE ||
			skillId == ENTANGLE || skillId == ERASE_MAGIC || skillId == EARTH_BIND ||
			skillId == AREA_OF_SILENCE || skillId == WIND_SHACKLE || skillId == AREA_WIND_SHACKLE ||
			skillId == STRIKER_GALE || skillId == POLLUTE_WATER ||
			skillId == ARMOR_BREAK ||
			skillId == ELZABE_AREA_SILENCE) {
			
		probability = (int) (((skill.getProbabilityDice()) / 10D) * levelDifference) + skill.getProbabilityValue();
			
		if (_calcType == PC_PC || _calcType == PC_NPC) {
			probability += 2 * _pc.getOriginalMagicHit();
		}
			
	} else if (skillId == GUARD_BRAKE || skillId == RESIST_FEAR
			|| skillId == HORROR_OF_DEATH) {
		probability = 100;
			
	} else if (skillId == THUNDER_GRAB) {
			
		probability = skill.getProbabilityValue()
				* (attackLevel / Math.max(1, defenseLevel))
				- _random.nextInt(21);

		if (_calcType == PC_PC || _calcType == PC_NPC) {
			probability += 2 * _pc.getOriginalMagicHit();
		}
			
	} else if (skillId == PHANTASM) {
			
		if (_calcType == PC_NPC) {
			probability = skill.getProbabilityValue();
		} else {
			probability = skill.getProbabilityValue() + 20;
		}
			
	} else {
		int dice = skill.getProbabilityDice();
		int diceCount = getMagicBonus() + getMagicLevel();
			
		if (_calcType == PC_PC || _calcType == PC_NPC) {
			diceCount += _pc.isWizard() ? 1 : -1;
		}
			
		diceCount = diceCount < 1 ? 1 : diceCount;
		for (int i = 0; i < diceCount; i++) {
			probability += (_random.nextInt(dice) + 1);
		}
		probability = probability * getLeverage() / 10;

		if (_calcType == PC_PC || _calcType == PC_NPC) {
			probability += 2 * _pc.getOriginalMagicHit();
		}

		probability -= getTargetMr();

		if (skillId == TAMING_MONSTER) {
			double probabilityRevision = 1;
			if ((_targetNpc.getMaxHp() * 1 / 4) > _targetNpc.getCurrentHp()) {
				probabilityRevision = 1.3;
			} else if ((_targetNpc.getMaxHp() * 2 / 4) > _targetNpc
					.getCurrentHp()) {
				probabilityRevision = 1.2;
			} else if ((_targetNpc.getMaxHp() * 3 / 4) > _targetNpc
					.getCurrentHp()) {
				probabilityRevision = 1.1;
			}
			probability *= probabilityRevision;
		}
	}

	if (_calcType == PC_PC || _calcType == NPC_PC) {
		switch (skillId) {
		case EARTH_BIND:
			probability -= _target.getResistHold();
			break;
		case MASS_SHOCK_STUN:
		case SHOCK_STUN:
			probability -= 2 * _target.getResistStun();
			break;
		case CURSE_PARALYZE:
			probability -= _target.getResistStone();
			break;
		case FOG_OF_SLEEPING:
			probability -= _target.getResistSleep();
			break;
		case ICE_LANCE:
		case FREEZING_BLIZZARD:
			probability -= _target.getResistFreeze();
			break;
		case CURSE_BLIND:
		case DARKNESS:
			probability -= _target.getResistBlind();
			break;
		}
	}
	return probability;
}