Example #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;
 }
Example #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 */

  }
Example #3
0
 public static void giveRewards(Player player, int item, boolean forcedBurn) {
   CookingItems food = CookingItems.forId(item);
   if ((cookedSuccessfully(
               player, food.getCookLevel(), food.getBurnStopLevelWith(), food.getBurnStopLevel())
           && !forcedBurn)
       || (player.getNewComersSide().isInTutorialIslandStage() && !forcedBurn)) {
     player.getInventory().addItem(new Item(food.getCookedId()));
     player.getSkill().addExp(Skill.COOKING, food.getExperience());
     player
         .getActionSender()
         .sendMessage(
             "You successfully cook a "
                 + ItemDefinition.forId(food.getCookedId()).getName().toLowerCase()
                 + ".");
   } else {
     player.getInventory().addItem(new Item(food.getBurntID()));
     player
         .getActionSender()
         .sendMessage(
             "You accidentally burn the "
                 + ItemDefinition.forId(food.getCookedId()).getName().toLowerCase()
                 + ".");
   }
 }
Example #4
0
 static {
   for (CookingItems item : CookingItems.values()) {
     cookingItems.put(item.rawId, item);
   }
 }