Beispiel #1
0
 public boolean handleInterface(int item, int objectId, int objectX, int objectY) {
   CookingItems cook = CookingItems.forId(item);
   if (cook == null) return false;
   player.getActionSender().removeInterfaces();
   if (!Constants.COOKING_ENABLED) {
     player.getActionSender().sendMessage("This skill is currently disabled.");
     return true;
   }
   player.setOldObject(objectId);
   final CacheObject obj =
       ObjectLoader.object(objectId, objectX, objectY, player.getPosition().getZ());
   final GameObjectDef def =
       SkillHandler.getObject(objectId, objectX, objectY, player.getPosition().getZ());
   if (obj != null || def != null) {
     String name =
         GameObjectData.forId(obj != null ? obj.getDef().getId() : def.getId())
             .getName()
             .toLowerCase();
     if (name.equalsIgnoreCase("fire") || name.equalsIgnoreCase("fireplace")) {
       player.setNewSkillTask();
       player.setStatedInterface("cookFire");
       firePosition = new Position(objectX, objectY, player.getPosition().getZ());
       player.setTempInteger(item);
       if (player.getNewComersSide().isInTutorialIslandStage()
           || player.getInventory().getItemAmount(item) == 1) {
         handleCookingTick(player, 1);
         return true;
       }
       Item itemDef = new Item(item);
       player.getActionSender().sendItemOnInterface(13716, 200, item);
       player.getActionSender().sendString("" + itemDef.getDefinition().getName() + "", 13717);
       player.getActionSender().sendChatInterface(1743);
       return true;
     }
     if (name.equalsIgnoreCase("stove")
         || name.equalsIgnoreCase("range")
         || name.equalsIgnoreCase("cooking range")
         || name.equalsIgnoreCase("cooking pot")) {
       player.setNewSkillTask();
       player.setStatedInterface("cookRange");
       player.setTempInteger(item);
       if (player.getNewComersSide().isInTutorialIslandStage()
           || player.getInventory().getItemAmount(item) == 1) {
         handleCookingTick(player, 1);
         player
             .getUpdateFlags()
             .sendFaceToDirection(
                 new Position(player.getPosition().getX(), player.getPosition().getY() - 1));
         return true;
       }
       Item itemDef = new Item(item);
       player.getActionSender().sendItemOnInterface(13716, 200, item);
       player.getActionSender().sendString("" + itemDef.getDefinition().getName() + "", 13717);
       player.getActionSender().sendChatInterface(1743);
       return true;
     }
   }
   return true;
 }
Beispiel #2
0
  // TODO sounds + correct message & amount interface which is a basic version
  // you can see above ^
  // the ground
  public static void handleCooking(final Player player) {
    final CookingItems toCook = CookingItems.forId(player.getTempInteger());
    if (toCook == null) return; // Means the item exists in cooking enum
    if (player.getSkill().getLevel()[Skill.COOKING] < toCook.getCookLevel()) {
      player
          .getDialogue()
          .sendStatement("You need a cooking level of " + toCook.getCookLevel() + " to cook this.");
      return;
    }
    player.getActionSender().removeInterfaces();
    player.getInventory().removeItem(new Item(player.getTempInteger()));
    if (player.getStatedInterface() == "cookFire") player.getUpdateFlags().sendAnimation(897);
    else if (player.getStatedInterface() == "cookRange") player.getUpdateFlags().sendAnimation(883);
    player.getActionSender().sendSound(357, 0, 0);
    if (player.getNewComersSide().isInTutorialIslandStage()) {
      if (player.getNewComersSide().getTutorialIslandStage() == 12) {
        player
            .getNewComersSide()
            .setTutorialIslandStage(player.getNewComersSide().getTutorialIslandStage() + 1, true);
        giveRewards(player, player.getTempInteger(), true);
      } else if (player.getNewComersSide().getTutorialIslandStage() == 13) {
        player
            .getNewComersSide()
            .setTutorialIslandStage(player.getNewComersSide().getTutorialIslandStage() + 1, true);
        giveRewards(player, player.getTempInteger(), false);
      } else if (player.getNewComersSide().getTutorialIslandStage() == 18
          && player.getTempInteger() == 2307) {
        player
            .getNewComersSide()
            .setTutorialIslandStage(player.getNewComersSide().getTutorialIslandStage() + 1, true);
        giveRewards(player, player.getTempInteger(), false);
      }
      return;
    }
    if (!toCook.fireCook() && player.getStatedInterface() == "cookFire")
      giveRewards(player, player.getTempInteger(), true);
    else giveRewards(player, player.getTempInteger(), false);

    /* some food always burns on fire */

  }
Beispiel #3
0
  private void handleSecondClickItem(Player player, Packet packet) {
    int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A);
    player.setSlot(
        packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE));
    int interfaceID =
        packet.getIn().readShort(StreamBuffer.ValueType.A, 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;
    Pouches.checkEssencePouch(player, item.getId());
    switch (itemId) {
      case 4566: // rubber chicken
        player.getUpdateFlags().sendAnimation(1835);
        return;

      case 2568: // RING OF FORGING CHARGE CHECK
        player
            .getActionSender()
            .sendMessage(
                "You have "
                    + player.getRingOfForgingLife()
                    + " Ring of Forging charge(s) remaining.");
        return;
      case 11074: // BRACELET OF CLAY CHARGE CHECK
        player
            .getActionSender()
            .sendMessage(
                "You have "
                    + player.getClayBraceletLife()
                    + " Bracelet of Clay charge(s) remaining.");
        return;
    }
  }
Beispiel #4
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 #5
0
 public static boolean doItemOnObject(Player player, int object, int item) {
   switch (object) {
     case 3402: // elemental workshop workbench
       if (item == 2893
           && player.getQuestStage(12) >= 10
           && player.getSkill().getLevel()[Skill.SMITHING] >= 20) {
         if (player.getInventory().playerHasItem(2347)) {
           player.getInventory().removeItem(new Item(2893));
           player.getInventory().addItem(new Item(2890));
           if (player.getQuestStage(12) == 10) {
             player.setQuestStage(12, 11);
             QuestHandler.completeQuest(player, 12);
             return true;
           }
           return true;
         } else {
           player.getDialogue().sendStatement("You need a hammer to smith!");
           return true;
         }
       } else if (player.getSkill().getLevel()[Skill.SMITHING] < 20) {
         player.getDialogue().sendStatement("You need 20 smithing to smith and elemental shield.");
         return true;
       }
       break;
     case 3413: // elemental workshop furnace
       if (item == 2889 && player.getQuestStage(12) == 8) {
         player
             .getDialogue()
             .sendStatement("The furnace flares dramatically as you pour the lava in.");
         player.getInventory().replaceItemWithItem(new Item(2889), new Item(2888));
         player.setQuestStage(12, 9);
         return true;
       } else if (item == 2892 && player.getQuestStage(12) >= 9) {
         if (player.getInventory().playerHasItem(453, 4)) {
           player.getInventory().removeItem(new Item(2892));
           player.getInventory().removeItem(new Item(453, 4));
           player.getInventory().addItem(new Item(2893));
           player.getActionSender().sendMessage("You smelt the elemental ore in the furnace.");
           player.getActionSender().sendMessage("You retrieve elemental metal from the furnace.");
           player.getUpdateFlags().sendAnimation(899);
           player.getActionSender().sendSound(469, 0, 0);
           if (player.getQuestStage(12) == 9) {
             player.setQuestStage(12, 10);
           }
           return true;
         } else {
           player.getDialogue().sendStatement("You need 4 coal to smelt Elemental Ore.");
           return true;
         }
       } else if (player.getQuestStage(12) >= 7) {
         if (item == GlassMaking.BUCKET_OF_SAND) GlassMaking.makeMoltenGlass(player);
         else if (item == GemCrafting.GOLD_BAR) GemCrafting.openInterface(player);
         else if (item == SilverCrafting.SILVER_BAR) Menus.sendSkillMenu(player, "silverCrafting");
         else if (ItemManager.getInstance().getItemName(item).toLowerCase().endsWith("ore")
             && item != 668) Smelting.smeltInterface(player);
         else if (item == 668) Dialogues.startDialogue(player, 10200);
         return true;
       }
       break;
     case 3414: // elemental workshop lava trough
       if (item == 2888 && player.getQuestStage(12) == 8) {
         player.getDialogue().sendStatement("You carefully fill the bowl with lava.");
         player.getInventory().replaceItemWithItem(new Item(2888), new Item(2889));
         return true;
       }
       break;
   }
   return false;
 }
Beispiel #6
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 #7
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);
    }
  }