Exemplo n.º 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);
    }
  }
Exemplo n.º 2
0
/**
 * @author Mobius
 * @version $Revision: 1.0 $
 */
public final class Kama56Boss extends Fighter {
  private long _nextOrderTime = 0;
  private HardReference<Player> _lastMinionsTargetRef = HardReferences.emptyRef();

  /**
   * Constructor for Kama56Boss.
   *
   * @param actor NpcInstance
   */
  public Kama56Boss(NpcInstance actor) {
    super(actor);
  }

  /**
   * 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);
    }
  }

  /** Method thinkAttack. */
  @Override
  protected void thinkAttack() {
    final NpcInstance actor = getActor();

    if (actor == null) {
      return;
    }

    sendOrderToMinions(actor);
    super.thinkAttack();
  }
}