Exemple #1
0
  /**
   * Method sendOrderToMinions.
   *
   * @param actor NpcInstance
   */
  private void sendOrderToMinions(NpcInstance actor) {
    if (!actor.isInCombat()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final MinionList ml = actor.getMinionList();

    if ((ml == null) || !ml.hasMinions()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final long now = System.currentTimeMillis();

    if ((_nextOrderTime > now) && (_lastMinionsTargetRef.get() != null)) {
      final Player old_target = _lastMinionsTargetRef.get();

      if ((old_target != null) && !old_target.isAlikeDead()) {
        for (MinionInstance m : ml.getAliveMinions()) {
          if (!m.getAI().getAttackTarget().equals(old_target)) {
            m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, old_target, 10000000);
          }
        }

        return;
      }
    }

    _nextOrderTime = now + 30000;
    final List<Player> pl = World.getAroundPlayers(actor);

    if (pl.isEmpty()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final List<Player> alive = new LazyArrayList<>();

    for (Player p : pl) {
      if (!p.isAlikeDead()) {
        alive.add(p);
      }
    }

    if (alive.isEmpty()) {
      _lastMinionsTargetRef = HardReferences.emptyRef();
      return;
    }

    final Player target = alive.get(Rnd.get(alive.size()));
    _lastMinionsTargetRef = target.getRef();
    Functions.npcSay(actor, "You " + target.getName() + "! Attack them!");

    for (MinionInstance m : ml.getAliveMinions()) {
      m.getAggroList().clear();
      m.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 10000000);
    }
  }
Exemple #2
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);
      }
    }
 /**
  * Method getPlayer.
  *
  * @return Player
  */
 public Player getPlayer() {
   return _playerRef.get();
 }