Пример #1
0
  @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);
  }
Пример #2
0
  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);
    }
  }