Example #1
0
  @Override
  public Event read(Player player, GameMessage msg) throws Exception {
    int opcode = msg.getOpcode();
    int size = msg.getSize();
    ByteMessage payload = msg.getPayload();

    if (opcode == 248) { // Minimap click.
      size -= 14;
      player.interruptAction();
    } else if (opcode == 164) { // Yellow <x> click.
      player.interruptAction();
    } else if (opcode == 98) { // Red <x> click.
      // impl
    }

    int pathSize = (size - 5) / 2;
    int[][] path = new int[pathSize][2];

    int x = payload.getShort(false, ByteTransform.A, ByteOrder.LITTLE);
    for (int i = 0; i < pathSize; i++) {
      path[i][0] = payload.get();
      path[i][1] = payload.get();
    }
    int y = payload.getShort(false, ByteOrder.LITTLE);
    boolean running = payload.get(false, ByteTransform.S) == 1;

    WalkingQueue walkingQueue = player.getWalkingQueue();
    walkingQueue.setRunningPath(running);
    walkingQueue.clear();
    Step[] steps = new Step[pathSize + 1];
    walkingQueue.addFirst(steps[0] = new Step(x, y));
    for (int i = 0; i < pathSize; i++) {
      walkingQueue.add(steps[i + 1] = new Step(path[i][0] + x, path[i][1] + y));
    }
    return new WalkingEvent(steps, running);
  }
 @Override
 public void write(Player mob, ByteMessage msg) {
   msg.putShort(mob.getGraphic().getId(), ByteOrder.LITTLE);
   msg.putInt(mob.getGraphic().getHeight() << 16 | mob.getGraphic().getDelay() & 0xFFFF);
 }
Example #3
0
 /** Queues {@code player} for logout on the next tick. */
 public void queueLogout(Player player) {
   if (player.getState() == EntityState.ACTIVE && !logouts.contains(player)) {
     logouts.add(player);
   }
 }
Example #4
0
 /** Queues {@code player} for login on the next tick. */
 public void queueLogin(Player player) {
   if (player.getState() == EntityState.IDLE && !logins.contains(player)) {
     logins.add(player);
   }
 }