예제 #1
0
  private boolean startAttack() {
    NpcInstance actor = getActor();
    if (target == null) {
      List<Creature> around = actor.getAroundCharacters(3000, 150);
      if (around != null && !around.isEmpty()) {
        for (Creature obj : around) {
          if (checkTarget(obj)) {
            if (target == null || actor.getDistance3D(obj) < actor.getDistance3D(target))
              target = obj;
          }
        }
      }
    }

    if (target != null
        && !actor.isAttackingNow()
        && !actor.isCastingNow()
        && !target.isDead()
        && GeoEngine.canSeeTarget(actor, target, false)
        && target.isVisible()) {
      actor.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
      return true;
    }

    if (target != null
        && (!target.isVisible()
            || target.isDead()
            || !GeoEngine.canSeeTarget(actor, target, false))) {
      target = null;
      return false;
    }

    return false;
  }
예제 #2
0
  /**
   * Method onEvtClanAttacked.
   *
   * @param attacked_member Creature
   * @param attacker Creature
   * @param damage int
   */
  @Override
  protected void onEvtClanAttacked(Creature attacked_member, Creature attacker, int damage) {
    super.onEvtClanAttacked(attacked_member, attacker, damage);
    final NpcInstance actor = getActor();

    if (_healSkills.length == 0) {
      return;
    }

    if (attacked_member.isDead()
        || actor.isDead()
        || (attacked_member.getCurrentHpPercents() > 50)) {
      return;
    }

    int heal_chance = 0;

    if (attacked_member.getId() == actor.getId()) {
      heal_chance = (attacked_member.getObjectId() == actor.getObjectId()) ? 100 : 0;
    } else {
      heal_chance = (attacked_member.getId() == Orfen_id) ? 90 : 10;
    }

    if (Rnd.chance(heal_chance) && canUseSkill(_healSkills[0], attacked_member, -1)) {
      addTaskAttack(attacked_member, _healSkills[0], 1000000);
    }
  }
예제 #3
0
파일: MDam.java 프로젝트: teeelle/l2jeuropa
 /**
  * Method useSkill.
  *
  * @param activeChar Creature
  * @param targets List<Creature>
  */
 @Override
 public void useSkill(Creature activeChar, List<Creature> targets) {
   int sps =
       isSSPossible()
           ? (isMagic()
               ? activeChar.getChargedSpiritShot()
               : activeChar.getChargedSoulShot() ? 2 : 0)
           : 0;
   Creature realTarget;
   boolean reflected;
   for (Creature target : targets) {
     if (target != null) {
       if (target.isDead()) {
         continue;
       }
       reflected = target.checkReflectSkill(activeChar, this);
       realTarget = reflected ? activeChar : target;
       Formulas.AttackInfo info = Formulas.calcMagicDam(activeChar, realTarget, this, sps);
       if (info.damage >= 1) {
         realTarget.reduceCurrentHp(
             info.damage,
             info.reflectableDamage,
             activeChar,
             this,
             true,
             true,
             false,
             true,
             false,
             false,
             true);
       }
       getEffects(activeChar, target, getActivateRate() > 0, false, reflected);
     }
   }
   if (isSuicideAttack()) {
     activeChar.doDie(null);
   } else if (isSSPossible()) {
     activeChar.unChargeShots(isMagic());
   }
 }
예제 #4
0
  /**
   * Method useSkill.
   *
   * @param activeChar Creature
   * @param targets List<Creature>
   */
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    if (!activeChar.isPlayer()) {
      return;
    }

    boolean ss = activeChar.getChargedSoulShot() && isSSPossible();

    if (ss && (getTargetType() != SkillTargetType.TARGET_SELF)) {
      activeChar.unChargeShots(false);
    }

    Creature realTarget;
    boolean reflected;

    for (Creature target : targets) {
      if (target != null) {
        if (target.isDead()) {
          continue;
        }

        reflected = (target != activeChar) && target.checkReflectSkill(activeChar, this);
        realTarget = reflected ? activeChar : target;

        if (getPower() > 0) {
          AttackInfo info =
              Formulas.calcPhysDam(activeChar, realTarget, this, false, false, ss, false);

          if (info.lethal_dmg > 0) {
            realTarget.reduceCurrentHp(
                info.lethal_dmg,
                info.reflectableDamage,
                activeChar,
                this,
                true,
                true,
                false,
                false,
                false,
                false,
                false);
          }

          realTarget.reduceCurrentHp(
              info.damage,
              info.reflectableDamage,
              activeChar,
              this,
              true,
              true,
              false,
              true,
              false,
              false,
              true);

          if (!reflected) {
            realTarget.doCounterAttack(this, activeChar, false);
          }
        }

        if (realTarget.isPlayable() || realTarget.isMonster()) {
          activeChar.setConsumedSouls(activeChar.getConsumedSouls() + _numSouls, null);
        }

        getEffects(activeChar, target, getActivateRate() > 0, false, reflected);
      }
    }

    if (isSSPossible()) {
      activeChar.unChargeShots(isMagic());
    }
  }
예제 #5
0
  /**
   * Method thinkActive.
   *
   * @return boolean
   */
  @Override
  protected boolean thinkActive() {
    final NpcInstance actor = getActor();

    if ((actor == null) || actor.isDead()) {
      return true;
    }

    if (_def_think) {
      doTask();
      return true;
    }

    if ((diedTentacle < 3) || (currentPoint > (MOVE_LOC.length - 1))) {
      final List<Creature> list =
          World.getAroundCharacters(
              getActor(), getActor().getAggroRange(), getActor().getAggroRange());

      for (Creature target : list) {
        if ((target != null) && !target.isDead() && Util.contains(ATTACK_IDS, target.getId())) {
          clearTasks();
          actor.setRunning();
          addTaskAttack(target);
          return true;
        }
      }

      if ((currentPoint > (MOVE_LOC.length - 1)) && (currentPoint2 <= (way.length - 1))) {
        if (loc == null) {
          loc =
              new Location(
                  (way[currentPoint2].getX() + Rnd.get(50)) - Rnd.get(50),
                  (way[currentPoint2].getY() + Rnd.get(50)) - Rnd.get(50),
                  (way[currentPoint2].getZ() + Rnd.get(50)) - Rnd.get(50));
        }

        actor.setRunning();
        clearTasks();
        addTaskMove(loc, true);
        doTask();
        return true;
      }

      return false;
    } else if ((diedTentacle >= 3) && (currentPoint <= (MOVE_LOC.length - 1))) {
      if (loc == null) {
        loc =
            new Location(
                (MOVE_LOC[currentPoint].getX() + Rnd.get(50)) - Rnd.get(50),
                (MOVE_LOC[currentPoint].getY() + Rnd.get(50)) - Rnd.get(50),
                (MOVE_LOC[currentPoint].getZ() + Rnd.get(50)) - Rnd.get(50));
      }

      actor.setRunning();
      clearTasks();
      addTaskMove(loc, true);
      doTask();
      return true;
    }

    return false;
  }