Пример #1
0
  private boolean startAttack() {
    NpcInstance actor = getActor();
    if (target == null) {
      List<NpcInstance> around = actor.getAroundNpc(3000, 150);
      if (around != null && !around.isEmpty()) {
        for (NpcInstance npc : around) {
          if (checkTarget(npc)) {
            if (target == null || actor.getDistance3D(npc) < actor.getDistance3D(target)) {
              target = npc;
            }
          }
        }
      }
    }

    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
 @Override
 protected boolean thinkActive() {
   NpcInstance actor = getActor();
   if (actor.isDead()) {
     return false;
   }
   List<NpcInstance> around = actor.getAroundNpc(800, 500);
   if ((around != null) && (!around.isEmpty())) {
     for (NpcInstance npc : around) {
       if (npc.getNpcId() == 51030) {
         actor.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, npc, Integer.valueOf(500));
       }
     }
   }
   return true;
 }
Пример #3
0
    /** Method runImpl. */
    @Override
    public void runImpl() {
      final NpcInstance actor = (NpcInstance) getActor();
      final Player attacker = _playerRef.get();

      if ((attacker == null) || (actor == null)) {
        return;
      }

      for (NpcInstance npc : actor.getAroundNpc(1500, 200)) {
        if (npc.isSiegeGuard() && Rnd.chance(20)) {
          npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, attacker, 5000);
        }
      }

      if ((attacker.getCastingSkill() != null)
          && (attacker.getCastingSkill().getTargetType() == Skill.SkillTargetType.TARGET_HOLY)) {
        ThreadPoolManager.getInstance().schedule(this, 10000);
      }
    }