Package org.moparscape.msc.gs.model.landscape

Examples of org.moparscape.msc.gs.model.landscape.ActiveTile


      }
      // incExp
      player.resetAll();
      Point location = Point.location(p.readShort(), p.readShort());
      int id = p.readShort();
      final ActiveTile tile = world.getTile(location);
      if (tile == null)
        return;
      final InvItem myItem = player.getInventory().getSlot(p.readShort());
      if (myItem == null)
        return;
      if (tile.hasGameObject() && myItem.id != 135) {
        player.getActionSender().sendMessage(
            "You cannot do that here, please move to a new area.");
        return;
      }
      final Item item = getItem(id, tile, player);

      if (item == null || myItem == null) {
        player.setSuspiciousPlayer(true);
        player.resetPath();
        return;
      }
      world.addEntryToSnapshots(new Activity(player.getUsername(), player
          .getUsername()
          + " used item "
          + myItem.getDef().getName()
          + "("
          + myItem.id
          + ")"
          + " [CMD: "
          + myItem.getDef().getCommand()
          + "] ON A GROUND ITEM "
          + myItem.getDef().getName()
          + "("
          + myItem.id
          + ")"
          + " [CMD: "
          + myItem.getDef().getCommand()
          + "] at: "
          + player.getX() + "/" + player.getY()));

      player.setStatus(Action.USING_INVITEM_ON_GITEM);
      Instance.getDelayedEventHandler().add(
          new WalkToPointEvent(player, location, 1, false) {
            public void arrived() {
              if (owner.isBusy()
                  || owner.isRanging()
                  || !tile.hasItem(item)
                  || !owner.nextTo(item)
                  || owner.getStatus() != Action.USING_INVITEM_ON_GITEM) {
                return;
              }
              if (myItem == null || item == null)
                return;
              switch (item.getID()) {
              case 23:
                if (myItem.id == 135) {
                  if (owner.getInventory().remove(myItem.id,
                      myItem.amount, false))
                    return;
                  owner.getActionSender().sendMessage(
                      "You put the flour in the pot.");
                  Bubble bubble = new Bubble(owner, 135);
                  for (Player p : owner.getViewArea()
                      .getPlayersInView()) {
                    p.informOfBubble(bubble);
                  }
                  world.unregisterItem(item);
                  owner.getInventory().add(136, 1, false);
                  owner.getActionSender().sendInventory();
                  return;
                }
              case 14:
              case 632:
              case 633:
              case 634:
              case 635:
              case 636:
                handleFireMaking();
                break;
              default:
                owner.getActionSender().sendMessage(
                    "Nothing interesting happens.");
                return;
              }
            }

            private void handleFireMaking() {
              handleFireMaking((int) Math.ceil(owner
                  .getMaxStat(11) / 10));

            }

            private void handleFireMaking(int tries) {
              final int retries = --tries;
              final FiremakingDef def = EntityHandler
                  .getFiremakingDef(item.getID());
              if (!itemId(new int[] { 166 }) || def == null) {
                owner.getActionSender().sendMessage(
                    "Nothing interesting happens.");
                return;
              }
              if (owner.getCurStat(11) < def.getRequiredLevel()) {
                owner.getActionSender()
                    .sendMessage(
                        "You need at least "
                            + def.getRequiredLevel()
                            + " firemaking to light these logs.");
                return;
              }
              owner.setBusy(true);
              Bubble bubble = new Bubble(owner, 166);
              for (Player p : owner.getViewArea()
                  .getPlayersInView()) {
                p.informOfBubble(bubble);
              }
              owner.getActionSender().sendMessage(
                  "You attempt to light the logs...");
              Instance.getDelayedEventHandler().add(
                  new ShortEvent(owner) {
                    public void action() {
                      if (Formulae.lightLogs(def,
                          owner.getCurStat(11))) {
                        owner.getActionSender()
                            .sendMessage(
                                "They catch fire and start to burn.");
                        world.unregisterItem(item);
                        final GameObject fire = new GameObject(
                            item.getLocation(), 97,
                            0, 0);
                        world.registerGameObject(fire);
                        world.getDelayedEventHandler()
                            .add(new DelayedEvent(
                                null,
                                def.getLength()) {
                              public void run() {
                                if (tile.hasGameObject()
                                    && tile.getGameObject()
                                        .equals(fire)) {
                                  world.unregisterGameObject(fire);
                                  world.registerItem(new Item(
                                      181,
                                      tile.getX(),
                                      tile.getY(),
                                      1,
                                      null));
                                }
                                matchRunning = false;
                              }
View Full Code Here


  public GameObject getObject() {
    return object;
  }

  public void run() {
    ActiveTile tile = world.getTile(object.getLocation());
    if (!tile.hasGameObject() || !tile.getGameObject().equals(object)) {
      super.matchRunning = false;
      return;
    }
    tile.remove(object);
    world.unregisterGameObject(object);
    super.matchRunning = false;
  }
View Full Code Here

    return isBlocking(t.mapValue, (byte) bit)
        || isBlocking(t.objectValue, (byte) bit) || isMobBlocking(x, y);
  }

  private boolean isMobBlocking(int x, int y) {
    ActiveTile t = world.getTile(x, y);
    if (mob instanceof Player) {
      if (t.hasNpcs()) {
        for (Npc n : t.getNpcs()) {
          if (n.getDef().isAggressive()
              && !n.getLocation().inWilderness())
            return true;
        }
      }
    }
    if (mob instanceof Npc) {
      Npc n = (Npc) mob;
      if (n.getChasing() != null)
        if (t.hasPlayers() && t.getPlayers().contains(n.getChasing()))
          if (x == n.getChasing().getX()
              && y == n.getChasing().getY())
            return false;
      if (t.hasNpcs() || (t.hasPlayers() && n.getChasing() != null))
        return true;
    }
    return false;
  }
View Full Code Here

    if (player.isBusy()) {
      player.resetPath();// sendSound
      return;
    }
    player.resetAll();
    ActiveTile tile = world.getTile(p.readShort(), p.readShort());
    if (tile == null) {
      player.setSuspiciousPlayer(true);
      player.resetPath();
      return;
    }
    GameObject object = tile.getGameObject();
    InvItem item;
    switch (pID) {
    case 36: // Use Item on Door
      int dir = p.readByte();
      item = player.getInventory().getSlot(p.readShort());
      if (object == null || object.getType() == 0 || item == null) { // This
        // shoudln't
        // happen
        player.setSuspiciousPlayer(true);
        return;
      }
      world.addEntryToSnapshots(new Activity(player.getUsername(), player
          .getUsername()
          + " used item on door"
          + item.getDef().getName()
          + "("
          + item.id
          + ")"
          + " [CMD: "
          + item.getDef().getCommand()
          + "] ON A DOOR ("
          + tile.getX()
          + "/"
          + tile.getY()
          + ") at: "
          + player.getX() + "/" + player.getY()));

      handleDoor(player, tile, object, dir, item);
      break;
    case 94: // Use Item on GameObject
      item = player.getInventory().getSlot(p.readShort());
      if (object == null || object.getType() == 1 || item == null) { // This
        // shoudln't
        // happen
        player.setSuspiciousPlayer(true);
        return;
      }
      world.addEntryToSnapshots(new Activity(player.getUsername(), player
          .getUsername()
          + " used item on GameObject"
          + item.getDef().getName()
          + "("
          + item.id
          + ")"
          + " [CMD: "
          + item.getDef().getCommand()
          + "] ON A DOOR ("
          + tile.getX()
          + "/"
          + tile.getY()
          + ") at: "
          + player.getX() + "/" + player.getY()));

      handleObject(player, tile, object, item);
      break;
    }
    tile.cleanItself();
  }
View Full Code Here

      return null;
    }
    ActiveTile[][] tiles = getViewArea().getViewedArea(2, 2, 2, 2);
    for (int x = 0; x < tiles.length; x++) {
      for (int y = 0; y < tiles[x].length; y++) {
        ActiveTile t = tiles[x][y];
        if (t != null) {
          for (Player p : t.getPlayers()) {
            if (p.inCombat()) {
              continue;
            }
            /*
             * if(p.isBusy() || p.isNonaggro() || now -
View Full Code Here

      if (item.id == 1323) {
        return;
      }
    } else if (item.getDef().getCommand().equalsIgnoreCase("open")
        && item.id == 796) {
      final ActiveTile tile = world.getTile(player.getLocation());
      if (tile.hasGameObject()) {
        player.getActionSender().sendMessage(
            "You cannot do that here, please move to a new area.");
        return;
      }
      if (player.getInventory().remove(796, 1, false)) {
View Full Code Here

    Instance.getDelayedEventHandler().add(
        new WalkToPointEvent(player, affectedItem.getLocation(), 5,
            true) {
          public void arrived() {
            owner.resetPath();
            ActiveTile tile = world.getTile(location);
            if (!canCast(owner) || !tile.hasItem(affectedItem)
                || owner.getStatus() != Action.CASTING_GITEM
                || affectedItem.isRemoved()) {
              return;
            }
            // check if the item is a rare
View Full Code Here

      if (player.isDueling()) {
        player.getActionSender().sendMessage(
            "This type of spell cannot be used in a duel.");
        return;
      }
      ActiveTile t = world.getTile(p.readShort(), p.readShort());
      int itemId = p.readShort();
      Item affectedItem = null;
      for (Item i : t.getItems()) {
        if (i.getID() == itemId && i.visibleTo(player)) {
          affectedItem = i;
          break;
        }
      }
      t.cleanItself();
      if (affectedItem == null) { // This shouldn't happen
        return;
      }
      handleItemCast(player, spell, idx, affectedItem);
      break;
View Full Code Here

      if (player.isBusy()) {
        player.resetPath();
        return;
      }
      player.resetAll();
      ActiveTile t = world.getTile(p.readShort(), p.readShort());
      final GameObject object = t.getGameObject();
      final int click = pID == 126 ? 0 : 1;
      if (object == null) {
        t.cleanItself();
        player.setSuspiciousPlayer(true);
        return;
      }
      world.addEntryToSnapshots(new Activity(player.getUsername(), player
          .getUsername()
View Full Code Here

TOP

Related Classes of org.moparscape.msc.gs.model.landscape.ActiveTile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.