@Override public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) { if (!(activeChar instanceof L2PcInstance)) return; if (targets == null) return; for (L2Object tgt : targets) { if (!(tgt instanceof L2MonsterInstance)) continue; final L2MonsterInstance target = (L2MonsterInstance) tgt; if (target.isDead()) continue; if (target.getSpoilerId() != 0) { activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_SPOILED)); continue; } if (Formulas.calcMagicSuccess(activeChar, (L2Character) tgt, skill)) { target.setSpoilerId(activeChar.getObjectId()); activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SPOIL_SUCCESS)); } else activeChar.sendPacket( SystemMessage.getSystemMessage(SystemMessageId.S1_RESISTED_YOUR_S2) .addCharName(target) .addSkillName(skill.getId())); target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar); } }
@Override public String onSkillSee( L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) { // Caster is an allied. if (caster.isAlliedWithKetra()) { // Caster's skill is a positive effect ? Go further. switch (skill.getSkillType()) { case BUFF: case HEAL: case HEAL_PERCENT: case HEAL_STATIC: case BALANCE_LIFE: case HOT: for (L2Character target : (L2Character[]) targets) { // Character isn't existing, is dead or is current caster, we drop check. if (target == null || target.isDead() || target == caster) continue; // Target isn't a summon nor a player, we drop check. if (!(target instanceof L2Playable)) continue; // Retrieve the player behind that target. final L2PcInstance player = target.getActingPlayer(); // If player is neutral or enemy, go further. if (!(player.isAlliedWithKetra())) { // If the NPC got that player registered in aggro list, go further. if (((L2Attackable) npc).containsTarget(player)) { // Save current target for future use. final L2Object oldTarget = npc.getTarget(); // Curse the heretic or his pet. npc.setTarget((isPet && player.getPet() != null) ? caster.getPet() : caster); npc.doCast(FrequentSkill.VARKA_KETRA_PETRIFICATION.getSkill()); // Revert to old target && drop the loop. npc.setTarget(oldTarget); break; } } } break; } } // Continue normal behavior. return super.onSkillSee(npc, caster, skill, targets, isPet); }
/** * Return the number of players in a defined radius.<br> * Dead players aren't counted, invisible ones is the boolean parameter. * * @param range : the radius. * @param npc : the object to make the test on. * @param invisible : true counts invisible characters. * @return the number of targets found. */ public static int getPlayersCountInRadius(int range, L2Character npc, boolean invisible) { int count = 0; for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) { if (player.isDead()) continue; if (!invisible && player.getAppearance().getInvisible()) continue; if (Util.checkIfInRange(range, npc, player, true)) count++; } return count; }
private void makeCast(EffectChanceSkillTrigger effect, L2Character target) { try { if (effect == null || !effect.triggersChanceSkill()) return; L2Skill triggered = SkillTable.getInstance() .getInfo(effect.getTriggeredChanceId(), effect.getTriggeredChanceLevel()); if (triggered == null) return; L2Character caster = triggered.getTargetType() == L2Skill.SkillTargetType.TARGET_SELF ? _owner : effect.getEffector(); if (caster == null || triggered.getSkillType() == L2SkillType.NOTDONE || caster.isSkillDisabled(triggered)) return; if (triggered.getReuseDelay() > 0) caster.disableSkill(triggered, triggered.getReuseDelay()); L2Object[] targets = triggered.getTargetList(caster, false, target); if (targets.length == 0) return; L2Character firstTarget = (L2Character) targets[0]; ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(triggered.getSkillType()); _owner.broadcastPacket( new MagicSkillLaunched(_owner, triggered.getId(), triggered.getLevel(), targets)); _owner.broadcastPacket( new MagicSkillUse(_owner, firstTarget, triggered.getId(), triggered.getLevel(), 0, 0)); // Launch the magic skill and calculate its effects // TODO: once core will support all possible effects, use effects (not handler) if (handler != null) handler.useSkill(caster, triggered, targets); else triggered.useSkill(caster, targets); } catch (Exception e) { _log.log(Level.WARNING, "", e); } }
private void makeCast(L2Skill skill, L2Character target) { try { if (skill.getWeaponDependancy(_owner) && skill.checkCondition(_owner, target, false)) { if (skill .triggersChanceSkill()) // skill will trigger another skill, but only if its not chance // skill { skill = SkillTable.getInstance() .getInfo(skill.getTriggeredChanceId(), skill.getTriggeredChanceLevel()); if (skill == null || skill.getSkillType() == L2SkillType.NOTDONE) return; } if (_owner.isSkillDisabled(skill)) return; if (skill.getReuseDelay() > 0) _owner.disableSkill(skill, skill.getReuseDelay()); L2Object[] targets = skill.getTargetList(_owner, false, target); if (targets.length == 0) return; L2Character firstTarget = (L2Character) targets[0]; ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getSkillType()); _owner.broadcastPacket( new MagicSkillLaunched(_owner, skill.getId(), skill.getLevel(), targets)); _owner.broadcastPacket( new MagicSkillUse(_owner, firstTarget, skill.getId(), skill.getLevel(), 0, 0)); // Launch the magic skill and calculate its effects // TODO: once core will support all possible effects, use effects (not handler) if (handler != null) handler.useSkill(_owner, skill, targets); else skill.useSkill(_owner, targets); } } catch (Exception e) { _log.log(Level.WARNING, "", e); } }
@Override protected int chooseSkillToUseItOnSomeBitch(L2FpInstance player, L2Character enemy) { if (!isCurrentHpLowerThan(enemy, 90) && !enemy.isRaid() && !player.isMoving()) return TRIPLE_SLASH; L2Effect effectVS = player.getFirstEffect(VICIOUS_STANCE); if (isCurrentHpLowerThan(player, 50) || getMyAttackersCount(player) > 2) { if (effectVS == null) { return VICIOUS_STANCE; } } else if (effectVS != null) { effectVS.exit(); } return 0; }
public void onChanceSkillEvent(int event, L2Character target) { if (_owner.isDead()) return; for (Map.Entry<IChanceSkillTrigger, ChanceCondition> entry : entrySet()) { IChanceSkillTrigger trigger = entry.getKey(); ChanceCondition cond = entry.getValue(); if (cond != null && cond.trigger(event)) { if (trigger instanceof L2Skill) makeCast((L2Skill) trigger, target); else if (trigger instanceof EffectChanceSkillTrigger) makeCast((EffectChanceSkillTrigger) trigger, target); } } }
/** * Under that barbarian name, return the number of players in front, back and sides of the npc. * <br> * Dead players aren't counted, invisible ones is the boolean parameter. * * @param range : the radius. * @param npc : the object to make the test on. * @param invisible : true counts invisible characters. * @return an array composed of front, back and side targets number. */ public static int[] getPlayersCountInPositions(int range, L2Character npc, boolean invisible) { int frontCount = 0; int backCount = 0; int sideCount = 0; for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) { if (player.isDead()) continue; if (!invisible && player.getAppearance().getInvisible()) continue; if (!Util.checkIfInRange(range, npc, player, true)) continue; if (player.isInFrontOf(npc)) frontCount++; else if (player.isBehind(npc)) backCount++; else sideCount++; } int[] array = {frontCount, backCount, sideCount}; return array; }
public void reduceHp( double value, L2Character attacker, boolean awake, boolean isDOT, boolean isHPConsumption) { if (getActiveChar().isDead()) return; // invul handling if (getActiveChar().isInvul()) { // other chars can't damage if (attacker != getActiveChar()) return; // only DOT and HP consumption allowed for damage self if (!isDOT && !isHPConsumption) return; } if (attacker != null) { final L2PcInstance attackerPlayer = attacker.getActingPlayer(); if (attackerPlayer != null && attackerPlayer.isGM() && !attackerPlayer.getAccessLevel().canGiveDamage()) return; } if (!isDOT && !isHPConsumption) { getActiveChar().stopEffectsOnDamage(awake); if (getActiveChar().isStunned() && Rnd.get(10) == 0) getActiveChar().stopStunning(true); if (getActiveChar().isImmobileUntilAttacked()) getActiveChar().stopImmobileUntilAttacked(null); } if (value > 0) // Reduce Hp if any setCurrentHp(Math.max(getCurrentHp() - value, 0)); // Die if character is mortal if (getActiveChar().getCurrentHp() < 0.5 && getActiveChar().isMortal()) { getActiveChar().abortAttack(); getActiveChar().abortCast(); getActiveChar().doDie(attacker); } }
public ConfirmDlg addCharName(L2Character cha) { if (cha instanceof L2Npc) return addNpcName((L2Npc) cha); if (cha instanceof L2PcInstance) return addPcName((L2PcInstance) cha); if (cha instanceof L2Summon) return addNpcName((L2Summon) cha); return addString(cha.getName()); }