@Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    if (actor == null || actor.isDead()) return true;

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

    if (diedTeredor < 3 || currentPoint >= MOVE_LOC.length - 1) {
      List<Creature> list =
          World.getAroundCharacters(
              getActor(), getActor().getAggroRange(), getActor().getAggroRange());
      for (Creature target : list) {
        if (target != null
            && !target.isDead()
            && ArrayUtils.contains(ATTACK_IDS, target.getNpcId())) {
          Skill sk = SkillTable.getInstance().getInfo(SKILL_ID, 1);
          if (lastCastTime + sk.getHitTime() + sk.getReuseDelay() <= System.currentTimeMillis()) {
            lastCastTime = System.currentTimeMillis();
            clearTasks();
            addTaskCast(target, sk);
            return true;
          }
          return false;
        }
      }
    } else if (diedTeredor >= 3 && currentPoint < MOVE_LOC.length - 1) {
      if (loc == null || getActor().getDistance(loc) <= 100) {
        currentPoint++;
        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));
        if (currentPoint == 0) {
          Reflection r = getActor().getReflection();
          if (r instanceof MemoryOfDisaster) {
            ((MemoryOfDisaster) r).spawnTransparentTeredor();
          }
        }
      }
      actor.setWalking();
      clearTasks();
      addTaskMove(loc, true);
      doTask();
      return true;
    }
    return false;
  }
 @Override
 protected void onEvtThink() {
   super.onEvtThink();
   if (!getActor().getAggroList().isEmpty()) {
     List<Creature> chars = World.getAroundCharacters(getActor());
     CollectionUtils.eqSort(chars, _nearestTargetComparator);
     for (Creature cha : chars) {
       if (getActor().getAggroList().get(cha) != null && checkAggression(cha)) {
         Skill sk = SkillTable.getInstance().getInfo(SKILL_ID, 1);
         if (lastCastTime + sk.getHitTime() + sk.getReuseDelay() <= System.currentTimeMillis()) {
           lastCastTime = System.currentTimeMillis();
           addTaskCast(cha, sk);
         }
       }
     }
   }
 }
Example #3
0
  @Override
  protected void onEvtSeeSpell(Skill skill, Creature caster) {
    super.onEvtSeeSpell(skill, caster);
    OrfenInstance actor = getActor();
    if (actor.isCastingNow()) {
      return;
    }

    double distance = actor.getDistance(caster);
    if (_damSkills.length > 0 && skill.getEffectPoint() > 0 && distance < 1000 && Rnd.chance(20)) {
      Functions.npcSay(actor, MsgOnRecall[Rnd.get(MsgOnRecall.length)].sprintf(caster.getName()));
      teleToLocation(caster, Location.findFrontPosition(actor, caster, 0, 50));
      Skill r_skill = _damSkills[Rnd.get(_damSkills.length)];
      if (canUseSkill(r_skill, caster, -1)) {
        addTaskAttack(caster, r_skill, 1000000);
      }
    }
  }