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
 private void handleDropItem(Player player, Packet packet) {
   int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A);
   packet.getIn().readShort();
   player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A));
   Item item = player.getInventory().getItemContainer().get(player.getSlot());
   if (Puzzle.moveSlidingPiece(player, itemId)) return;
   if (item == null || item.getId() != itemId || !item.validItem()) return;
   if (item.getDefinition().isStackable()) {
     item.setCount(player.getInventory().getItemContainer().getCount(item.getId()));
   } else {
     item.setCount(1);
   }
   if (!player.getInventory().getItemContainer().contains(item.getId())) {
     return;
   }
   if (item.getId() == 530
       && player.getPosition().getX() == 2780
       && player.getPosition().getY() == 3515) {
     if (player.getInventory().playerHasItem(32)) {
       player.getInventory().removeItem(new Item(530));
       MerlinsCrystal.summon(player);
       return;
     } else {
       player
           .getDialogue()
           .sendStatement("Nothing happens. Perhaps you should light the candle first.");
       return;
     }
   }
   if (WarriorsGuild.itemHandling(player, itemId)) {
     return;
   }
   if (item.getId() == 10592) {
     player.getActionSender().sendMessage("Play the bongos instead.");
     return;
   }
   if (item.getId() == 6541) {
     player.getActionSender().sendMessage("You don't want to destroy your pet!");
     return;
   }
   for (int[] element : Pets.PET_IDS) {
     if (item.getDefinition().getId() == element[0]) {
       player.getPets().registerPet(element[0], element[1]);
       return;
     }
   }
   if (item.getDefinition().isUntradable()
       || item.getId() == 763
       || item.getId() == 765
       || item.getId() == 769
       || item.getId() == 288
       || item.getId() == 10498
       || item.getId() == 10499) {
     if (BarrowsItems.notDroppable(BarrowsItems.getBarrowsItem(item), item)) {
       String[][] info = {
         {"Are you sure you want to drop this item?", "14174"},
         {"Yes.", "14175"},
         {"No.", "14176"},
         {"", "14177"},
         {"Dropping this item will make it break completely.", "14182"},
         {"", "14183"},
         {item.getDefinition().getName(), "14184"}
       };
       for (String[] element : info) {
         player.getActionSender().sendString(element[0], Integer.parseInt(element[1]));
       }
     } else {
       String[][] info = {
         {"Are you sure you want to drop this item?", "14174"},
         {"Yes.", "14175"},
         {"No.", "14176"},
         {"", "14177"},
         {"Dropping this item will make you lose it forever.", "14182"},
         {"", "14183"},
         {item.getDefinition().getName(), "14184"}
       };
       for (String[] element : info) {
         player.getActionSender().sendString(element[0], Integer.parseInt(element[1]));
       }
     }
     player.getActionSender().sendUpdateItem(item, 0, 14171, 1);
     player.setDestroyItem(item);
     player.getActionSender().sendChatInterface(14170);
     return;
   }
   if (player.getInventory().getItemContainer().contains(item.getId())) {
     player.getActionSender().sendSound(376, 1, 0);
     if (!Constants.ADMINS_CAN_INTERACT && player.getStaffRights() >= 2) {
       player
           .getActionSender()
           .sendMessage("Your item disappears because you're an administrator.");
     } else {
       GroundItemManager.getManager()
           .dropItem(new GroundItem(new Item(item.getId(), item.getCount()), player));
     }
     if (!player.getInventory().removeItemSlot(item, player.getSlot())) {
       player.getInventory().removeItem(item);
     }
     player.getActionSender().removeInterfaces();
     player.getDialogue().resetDialogue();
   }
   player.getEquipment().updateWeight();
 }
Beispiel #3
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);
    }
  }