Beispiel #1
0
  public static void handlePassThroughDoor(
      final Player player,
      final int id,
      final int x,
      final int y,
      final int z,
      final int destX,
      final int destY) {
    Doors doors = getDoor(id, x, y, z);
    if (doors == null) {
      player.setStopPacket(false);
      return;
    }
    handleDoor(id, x, y, z);
    final Doors door = doors;
    player.getActionSender().walkTo(destX, destY, false);
    CycleEventHandler.getInstance()
        .addEvent(
            player,
            new CycleEvent() {
              @Override
              public void execute(CycleEventContainer container) {
                handleDoor(door.doorId, door.doorX, door.doorY, door.doorZ);
                container.stop();
              }

              @Override
              public void stop() {}
            },
            2);
  }
Beispiel #2
0
  public static void handleCookingTick(final Player player, final int amount) {
    final int task = player.getTask();
    player.getMovementHandler().reset();
    player.getActionSender().removeInterfaces();
    player.setSkilling(
        new CycleEvent() {
          int cookAmount = amount;

          @Override
          public void execute(CycleEventContainer container) {
            if (!player.checkNewSkillTask()
                || !player.checkTask(task)
                || !player.getInventory().getItemContainer().contains(player.getTempInteger())
                || cookAmount == 0) {
              player.setTempInteger(0);
              container.stop();
              return;
            }

            if (player.getStatedInterface().equals("cookFire")) {
              if (!SkillHandler.checkObject(
                  player.getOldObject(),
                  player.getCooking().firePosition.getX(),
                  player.getCooking().firePosition.getY(),
                  player.getCooking().firePosition.getZ())) {
                container.stop();
                return;
              }
            }
            handleCooking(player);
            cookAmount--;
            container.setTick(4);
          }

          @Override
          public void stop() {
            player.resetAnimation();
          }
        });
    CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1);
  }
Beispiel #3
0
  private void handlePickupSecondItem(final Player player, Packet packet) {
    player.setClickX(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE));
    player.setClickY(
        packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE));
    player.setClickId(packet.getIn().readShort(StreamBuffer.ValueType.A));
    player.setClickZ(player.getPosition().getZ());
    if (player.getStaffRights() > 1 && Constants.SERVER_DEBUG)
      System.out.println(player.getClickX() + " " + player.getClickY());
    if (!player.getInventory().canAddItem(new Item(player.getClickId()))) {
      return;
    }
    final int task = player.getTask();
    player.setSkilling(
        new CycleEvent() {
          @Override
          public void execute(CycleEventContainer container) {
            if (!player.checkTask(task)) {
              container.stop();
              return;
            }
            if (player.getPosition().getX() == player.getClickX()
                && player.getPosition().getY() == player.getClickY()) {
              player
                  .getFiremaking()
                  .attemptFire(
                      player.getClickId(),
                      0,
                      true,
                      player.getClickX(),
                      player.getClickY(),
                      player.getPosition().getZ());
              container.stop();
            }
          }

          @Override
          public void stop() {}
        });
    CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1);
  }
Beispiel #4
0
  private void useItemOnGroundItem(final Player player, Packet packet) {
    packet.getIn().readShort();
    int itemInInven = packet.getIn().readShort(StreamBuffer.ValueType.A);
    player.setClickId(packet.getIn().readShort());
    player.setClickY(packet.getIn().readShort(StreamBuffer.ValueType.A));
    player.setClickZ(player.getPosition().getZ());
    packet.getIn().readShort();
    player.setClickX(packet.getIn().readShort());
    if (itemInInven != 590) {
      return;
    }
    final int task = player.getTask();
    player.setSkilling(
        new CycleEvent() {
          @Override
          public void execute(CycleEventContainer container) {
            if (!player.checkTask(task)) {
              container.stop();
              return;
            }
            if (player.getPosition().getX() == player.getClickX()
                && player.getPosition().getY() == player.getClickY()) {
              player
                  .getFiremaking()
                  .attemptFire(
                      player.getClickId(),
                      0,
                      true,
                      player.getClickX(),
                      player.getClickY(),
                      player.getPosition().getZ());
              container.stop();
            }
          }

          @Override
          public void stop() {}
        });
    CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1);
  }
Beispiel #5
0
  private void handleFirstClickItem(final Player player, Packet packet) {
    int interfaceID =
        packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE);
    player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A));
    int itemId = packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE);
    RSInterface inter = RSInterface.forId(interfaceID);
    if (!player.hasInterfaceOpen(inter)) {
      // player.getActionSender().removeInterfaces();
      return;
    }
    Item item = player.getInventory().getItemContainer().get(player.getSlot());

    if (item == null || item.getId() != itemId) return;
    /*
     * if (player.getRunecrafting().fillEssencePouch(item)) { return; } if
     * (player.getHerblore().cleanHerb(item)) { return; }
     */
    if (itemId == 2329) {
      player.getInventory().replaceItemWithItem(new Item(2329), new Item(2313));
      player.getActionSender().sendMessage("You empty your burnt pie onto the ground.");
      return;
    }
    if (Nests.handleNest(player, itemId)) {
      return;
    }
    if (GhostsAhoy.itemHandling(player, itemId)) {
      return;
    }
    if (itemId == Slayer.ENCHANTED_GEM) {
      Dialogues.startDialogue(player, 10012);
      return;
    }
    if (Cleaning.handleCleaning(player, itemId, player.getSlot())) return;

    if (player.getBoneBurying().buryBone(itemId, player.getSlot())) {
      return;
    }
    if (itemId >= 5509 && itemId <= 5514) {
      Pouches.fillEssencePouch(player, itemId);
      return;
    }

    if (player.getPotion().isPotion(itemId)) {
      player.getPotion().drinkPotion(itemId, player.getSlot());
      return;
    }
    if (player.getFood().eatFood(itemId, player.getSlot())) {
      return;
    }
    ClueScroll.handleCasket(player, itemId);
    if (new Item(itemId).getDefinition().getName().toLowerCase().contains("clue scroll")
        || new Item(itemId).getDefinition().getName().toLowerCase().contains("challenge scroll")) {
      ClueScroll.cleanClueInterface(player);
    }
    if (Puzzle.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (CoordinateScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (DiggingScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (ChallengeScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (SpeakToScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (AnagramsScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (MapScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (SearchScrolls.loadClueInterface(player, itemId)) {
      player.getActionSender().sendMessage("clue id: " + itemId);
      return;
    }
    if (TeleTabs.breakTab(player, itemId, player.getSlot())) {
      return;
    }
    if (TabHandler.breakEnchantTab(player, itemId, player.getSlot())) {
      return;
    }
    if (TabHandler.breakBonesTab(player, itemId, player.getSlot())) {
      return;
    }
    if (ElementalWorkshop.itemHandling(player, itemId)) {
      return;
    }
    if (ShieldOfArrav.itemHandling(player, itemId)) {
      return;
    }
    if (DragonSlayer.itemHandling(player, itemId)) {
      return;
    }
    if (BlackKnightsFortress.itemHandling(player, itemId)) {
      return;
    }
    if (PiratesTreasure.itemHandling(player, itemId)) {
      return;
    }
    if (AnimalMagnetism.itemHandling(player, itemId)) {
      return;
    }
    switch (itemId) {
      case 2528: // genie lamp
        player.setGenieSelect(-1);
        player.getActionSender().sendConfig(261, 0);
        player.getActionSender().sendInterface(2808);
        return;
      case 550: // newcomers map
        player.getActionSender().sendInterface(5392);
        return;
      case 33: // candle
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the candle.");
          player.getInventory().addItemToSlot(new Item(36), player.getSlot());
        }
        return;
      case 594: // torch
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the torch.");
          player.getInventory().addItemToSlot(new Item(596), player.getSlot());
        }
        return;
      case 4531: // candle lantern
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the candle lantern.");
          player.getInventory().addItemToSlot(new Item(4529), player.getSlot());
        }
        return;
      case 4534: // black candle lantern
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the black candle lantern.");
          player.getInventory().addItemToSlot(new Item(4532), player.getSlot());
        }
        return;
      case 4539: // oil lamp
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the oil lamp.");
          player.getInventory().addItemToSlot(new Item(4537), player.getSlot());
        }
        return;
      case 4550: // bullseye lantern
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You extinguish the bullseye lantern.");
          player.getInventory().addItemToSlot(new Item(4548), player.getSlot());
        }
        return;
      case 405: // casket
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          Casket.openCasket(player);
        }
        return;
      case 2150: // swamp toad
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player
              .getActionSender()
              .sendMessage(
                  "You pull the legs off the toad. Poor toad. At least they'll grow back.");
          player.getInventory().addItemToSlot(new Item(2152), player.getSlot());
        }
        return;
      case 407: // oyster
        if (player.getInventory().removeItemSlot(item, player.getSlot())) {
          player.getActionSender().sendMessage("You open the oyster.");
          player.getInventory().addItemToSlot(new Item(411), player.getSlot());
        }
        return;
      case 4033:
        //  ShopManager.openShop(player, 39);
        player.getActionSender().sendMessage("You poke the monkey.");
        return;
      case 10592:
        player.getPets().registerPet(10592, 5428);
        return;
      case 952: // spade
        player.getUpdateFlags().sendAnimation(830);
        player.getActionSender().sendMessage("You dig into the ground...");

        final int task = player.getTask();
        player.setSkilling(
            new CycleEvent() {

              @Override
              public void execute(CycleEventContainer container) {
                if (!player.checkTask(task)) {
                  container.stop();
                  return;
                }
                if (player.getPosition().getX() == 2566
                    && (player.getPosition().getY() == 3331
                        || player.getPosition().getY() == 3333)) {
                  player.fadeTeleport(new Position(2530, 3303));
                  player.getActionSender().sendMessage("and find yourself in plague city.");
                  container.stop();
                  return;
                }
                if (player.getPosition().getX() == 2999
                    && player.getPosition().getY() == 3383
                    && (player.getQuestStage(20) == 6 || player.getQuestStage(20) == 7)) {
                  player.setQuestStage(20, 8);
                  QuestHandler.completeQuest(player, 20);
                  player.getInventory().addItem(new Item(PiratesTreasure.CHEST));
                  container.stop();
                  return;
                }
                if (player.getPosition().equals(GhostsAhoy.TREASURE_LOCATION)
                    && !player.getInventory().playerHasItem(GhostsAhoy.BOOK_OF_HARICANTO)) {
                  player
                      .getDialogue()
                      .sendGiveItemNpc(
                          "You unearth the Book of Haricanto.",
                          new Item(GhostsAhoy.BOOK_OF_HARICANTO));
                  player.getInventory().addItem(new Item(GhostsAhoy.BOOK_OF_HARICANTO));
                  container.stop();
                  return;
                }
                if (!MapScrolls.digClue(player)
                    && !DiggingScrolls.digClue(player)
                    && !CoordinateScrolls.digClue(player)
                    && !Barrows.digCrypt(player)) {
                  player.getActionSender().sendMessage("but do not find anything.");
                  container.stop();
                }
              }

              @Override
              public void stop() {
                player.resetAnimation();
              }
            });
        CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 2);
        return;
      case 2574: // sextant
        Sextant.initializeRandomSextantInterface(player);
        return;
      case 299:
        // MithrilSeeds.plantMithrilSeed(player);
        return;
    }

    player.getActionSender().sendMessage("Nothing interesting happens.");
    /*
     * if (item == 4155) { String slayerNpc = (String)
     * player.getSlayerTask()[0]; if (!slayerNpc.equalsIgnoreCase("")) {
     * player.getDialogue().sendStatement("Your existing task is to kill " +
     * player.getSlayerTask()[1] + " " + slayerNpc + "s.");
     * player.getDialogue().setNextDialogue(0); } else {
     * player.getDialogue().sendStatement("You don't have a slaver task.");
     * } return; }
     */
  }
Beispiel #6
0
  public static boolean perform(final Player player, int itemUsed, int usedWith) {
    final ArrowData arrowData = ArrowData.forId(itemUsed, usedWith);
    if (arrowData == null) return false;
    if (!Constants.FLETCHING_ENABLED) {
      player.getActionSender().sendMessage("This skill is currently disabled.");
      return false;
    }
    if (player.getSkill().getLevel()[Skill.FLETCHING] < arrowData.getLevel()) {
      player
          .getDialogue()
          .sendStatement("You need a fletching level of " + arrowData.getLevel() + " to do this");
      return true;
    }
    if (!player.getInventory().getItemContainer().contains(arrowData.getItem1())
        || !player.getInventory().getItemContainer().contains(arrowData.getItem2())) {
      player
          .getDialogue()
          .sendStatement(
              "You need "
                  + ARROW_COUNT
                  + " "
                  + new Item(arrowData.getItem1()).getDefinition().getName().toLowerCase()
                  + " and "
                  + ARROW_COUNT
                  + " "
                  + new Item(arrowData.getItem2()).getDefinition().getName().toLowerCase()
                  + "s to make this");
      return true;
    }
    int factor = 1;
    if (player.getStatedInterface().contains("brutal")) {
      if (!player.getInventory().getItemContainer().contains(2347)) {
        player.getDialogue().sendStatement("You need a hammer to make brutal arrows");
        return true;
      }
      factor = 4;
    }
    if (player.getInventory().getItemContainer().freeSlots() < 1
        && !player.getInventory().playerHasItem(arrowData.getFinalItem())) {
      player.getActionSender().sendMessage("Not enough space in your inventory.");
      return true;
    }
    final int multiplier = factor;

    final int task = player.getTask();
    int count1 =
        player.getInventory().getItemContainer().getCount(arrowData.getItem1()) < ARROW_COUNT
            ? player.getInventory().getItemContainer().getCount(arrowData.getItem1())
            : ARROW_COUNT;
    int count2 =
        player.getInventory().getItemContainer().getCount(arrowData.getItem2()) < ARROW_COUNT
            ? player.getInventory().getItemContainer().getCount(arrowData.getItem2())
            : ARROW_COUNT;
    final int count = count1 < count2 ? count1 : count2;
    player.setSkilling(
        new CycleEvent() {
          @Override
          public void execute(CycleEventContainer container) {
            if (!player.checkTask(task)
                || !player.getInventory().playerHasItem(new Item(arrowData.getItem1(), count))
                || !player.getInventory().playerHasItem(new Item(arrowData.getItem2(), count))) {
              container.stop();
              return;
            }
            player
                .getActionSender()
                .sendMessage(
                    "You attach the "
                        + new Item(arrowData.getItem1()).getDefinition().getName().toLowerCase()
                        + " to "
                        + count / multiplier
                        + " "
                        + new Item(arrowData.getItem2()).getDefinition().getName().toLowerCase()
                        + "s.");
            player.getInventory().removeItem(new Item(arrowData.getItem1(), count));
            player.getInventory().removeItem(new Item(arrowData.getItem2(), count));
            player.getInventory().addItem(new Item(arrowData.getFinalItem(), count / multiplier));
            player
                .getSkill()
                .addExp(Skill.FLETCHING, count / multiplier * (arrowData.getExperience()));
            container.stop();
          }

          @Override
          public void stop() {
            player.resetAnimation();
          }
        });
    CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1);
    return true;
  }
Beispiel #7
0
  public static void startSmithingBlurite(final Player player, final int item, final int amount) {
    final int id = 0;
    if (id > -1) {
      final Item finalItem = new Item(item);
      if (!player.getInventory().getItemContainer().contains(2347)) {
        player.getActionSender().sendMessage("You need a hammer to smith on an anvil.");
        return;
      }
      final Item bar = new Item(9467, 1);
      if (player.getNewComersSide().isInTutorialIslandStage()) {
        // TutorialIsland.sendStartInfo(player);
      } else {
        player.getActionSender().removeInterfaces();
      }
      final int task = player.getTask();
      player.getUpdateFlags().sendAnimation(898);
      player.getActionSender().sendSound(468, 0, 0);
      player.setSkilling(
          new CycleEvent() {
            int amounts = amount;

            @Override
            public void execute(CycleEventContainer container) {
              if (!player.checkTask(task)) {
                container.stop();
                return;
              }
              if (!player.getInventory().playerHasItem(bar)) {
                player.getActionSender().sendMessage("You have run out of bars!");
                container.stop();
                return;
              }
              player.getInventory().removeItem(bar);
              if (item == 9376) {
                player.getInventory().addItem(new Item(item, 10));
              } else {
                player.getInventory().addItem(new Item(item, 1));
              }
              player.getSkill().addExp(Skill.SMITHING, 5);
              if (player.getNewComersSide().isInTutorialIslandStage()) {
                if (player.getNewComersSide().getTutorialIslandStage() == 36)
                  player
                      .getNewComersSide()
                      .setTutorialIslandStage(
                          player.getNewComersSide().getTutorialIslandStage() + 1, true);
                player.setClickId(0);
                player
                    .getDialogue()
                    .sendStatement(
                        "You hammer the "
                            + bar.getDefinition().getName().toLowerCase()
                            + " and make "
                            + finalItem.getDefinition().getName().toLowerCase()
                            + ".");
              } else {
                player
                    .getActionSender()
                    .sendMessage(
                        "You hammer the "
                            + bar.getDefinition().getName().toLowerCase()
                            + " and make "
                            + finalItem.getDefinition().getName().toLowerCase()
                            + ".");
              }
              amounts--;
              if (amounts < 1) {
                container.stop();
                return;
              }
              if (!player.getInventory().playerHasItem(bar)) {
                player.getActionSender().sendMessage("You have run out of bars!");
                container.stop();
                return;
              }
              player.getUpdateFlags().sendAnimation(898);
              player.getActionSender().sendSound(468, 0, 0);
            }

            @Override
            public void stop() {
              player.getTask();
              player.resetAnimation();
            }
          });
      CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 4);
    }
  }
Beispiel #8
0
  public static void startSmithing(final Player player, final int item, final int amount) {
    final int id = getArrayForFullName(player, item);
    if (id > -1) {
      final Item finalItem = new Item(item);
      final String itemName = finalItem.getDefinition().getName().toLowerCase();
      if (!SkillHandler.hasRequiredLevel(
          player,
          Skill.SMITHING,
          smithLevel(id, player.getSmithInterface()),
          "smith " + itemName)) {
        return;
      }
      if (!player.getInventory().getItemContainer().contains(2347)) {
        player.getActionSender().sendMessage("You need a hammer to smith on an anvil.");
        return;
      }
      final Item bar = new Item(player.getOldItem(), smithInfo[id][2]);
      if (!player.getInventory().playerHasItem(bar)) {
        player
            .getActionSender()
            .sendMessage(
                "You need at least " + smithInfo[id][2] + " bars to make " + itemName + ".");
        return;
      }
      if (player.getNewComersSide().isInTutorialIslandStage()) {
        // TutorialIsland.sendStartInfo(player);
      } else {
        player.getActionSender().removeInterfaces();
      }
      final int task = player.getTask();
      player.getUpdateFlags().sendAnimation(898);
      player.getActionSender().sendSound(468, 0, 0);
      player.setSkilling(
          new CycleEvent() {
            int amounts = amount;

            @Override
            public void execute(CycleEventContainer container) {
              if (player.getOldItem() < 1 || !player.checkTask(task)) {
                container.stop();
                return;
              }
              if (!player.getInventory().playerHasItem(bar)) {
                player.getActionSender().sendMessage("You have run out of bars!");
                container.stop();
                return;
              }
              player.getInventory().removeItem(bar);
              if (itemName.contains("arrowtips") || itemName.contains("nails")) {
                player.getInventory().addItem(new Item(item, 15));
              } else if (itemName.contains("dart tip") || itemName.contains("bolts")) {
                player.getInventory().addItem(new Item(item, 10));
              } else if (itemName.contains("knife")) {
                player.getInventory().addItem(new Item(item, 5));
              } else {
                player.getInventory().addItem(new Item(item, 1));
              }
              player
                  .getSkill()
                  .addExp(
                      Skill.SMITHING,
                      smithInfo[id][1]
                          + 12.5 * smithInfo[id][2] * player.getSmithInterface()
                          + 0.5);
              if (player.getNewComersSide().isInTutorialIslandStage()) {
                if (player.getNewComersSide().getTutorialIslandStage() == 36)
                  player
                      .getNewComersSide()
                      .setTutorialIslandStage(
                          player.getNewComersSide().getTutorialIslandStage() + 1, true);
                player.setClickId(0);
                player
                    .getDialogue()
                    .sendStatement(
                        "You hammer the "
                            + bar.getDefinition().getName().toLowerCase()
                            + " and make "
                            + finalItem.getDefinition().getName().toLowerCase()
                            + ".");
              } else {
                player
                    .getActionSender()
                    .sendMessage(
                        "You hammer the "
                            + bar.getDefinition().getName().toLowerCase()
                            + " and make "
                            + finalItem.getDefinition().getName().toLowerCase()
                            + ".");
              }
              amounts--;
              if (amounts < 1) {
                container.stop();
                return;
              }
              if (!player.getInventory().playerHasItem(bar)) {
                player.getActionSender().sendMessage("You have run out of bars!");
                container.stop();
                return;
              }
              player.getUpdateFlags().sendAnimation(898);
              player.getActionSender().sendSound(468, 0, 0);
            }

            @Override
            public void stop() {
              player.getTask();
              player.resetAnimation();
            }
          });
      CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 4);
    }
  }