private void useStatRestorePotion(
     Player player, final InvItem item, final int newItem, final int left) {
   player.setBusy(true);
   player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
   world
       .getDelayedEventHandler()
       .add(
           new MiniEvent(player) {
             public void action() {
               owner.getActionSender().sendMessage("You have " + left + " doses left.");
               for (int i = 0; i < 18; i++) {
                 if (i == 3 || i == 5) {
                   continue;
                 }
                 int max = owner.getMaxStat(i);
                 if (owner.getCurStat(i) < max) {
                   owner.setCurStat(i, max);
                   owner.getActionSender().sendStat(i);
                 }
               }
               owner.getInventory().remove(item);
               owner.getInventory().add(new InvItem(newItem));
               owner.getActionSender().sendInventory();
               owner.setBusy(false);
             }
           });
 }
 public void handlePacket(Packet p, IoSession session) throws Exception {
   Player player = (Player) session.getAttachment();
   Player affectedPlayer = world.getPlayer(p.readShort());
   if (affectedPlayer == null) {
     player.setSuspiciousPlayer(true);
     return;
   }
   if (player.isBusy()) {
     player.resetPath();
     return;
   }
   player.resetAll();
   player.setFollowing(affectedPlayer, 1);
   player.getActionSender().sendMessage("Now following " + affectedPlayer.getUsername());
 }
 private void useFishingPotion(
     Player player, final InvItem item, final int newItem, final int left) {
   player.setBusy(true);
   player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
   world
       .getDelayedEventHandler()
       .add(
           new MiniEvent(player) {
             public void action() {
               owner.getActionSender().sendMessage("You have " + left + " doses left.");
               owner.setCurStat(10, owner.getMaxStat(10) + 3);
               owner.getInventory().remove(item);
               owner.getInventory().add(new InvItem(newItem));
               owner.getActionSender().sendStat(10);
               owner.getActionSender().sendInventory();
               owner.setBusy(false);
             }
           });
 }
 private void useNormalPotion(
     Player player,
     final InvItem item,
     final int affectedStat,
     final int percentageIncrease,
     final int modifier,
     final int newItem,
     final int left) {
   player.setBusy(true);
   player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
   world
       .getDelayedEventHandler()
       .add(
           new MiniEvent(player) {
             public void action() {
               owner.getActionSender().sendMessage("You have " + left + " doses left.");
               int baseStat =
                   owner.getCurStat(affectedStat) > owner.getMaxStat(affectedStat)
                       ? owner.getMaxStat(affectedStat)
                       : owner.getCurStat(affectedStat);
               int newStat =
                   baseStat
                       + DataConversions.roundUp(
                           (owner.getMaxStat(affectedStat) / 100D) * percentageIncrease)
                       + modifier;
               if (newStat > owner.getCurStat(affectedStat)) {
                 owner.setCurStat(affectedStat, newStat);
                 owner.getActionSender().sendStat(affectedStat);
               }
               owner.getInventory().remove(item);
               owner.getInventory().add(new InvItem(newItem));
               owner.getActionSender().sendInventory();
               owner.setBusy(false);
             }
           });
 }
Exemple #5
0
 public void handleNpc(final Npc npc, final Player player) throws Exception {
   if (player.getDemonSlayerStatus() == 6) { // Quest Complete
     player.informOfNpcMessage(
         new ChatMessage(
             npc,
             "Well done brave adventurer. You surely showed Delrith who is boss around here!",
             player));
     return;
   }
   if (player.getDemonSlayerStatus() == 5) { // Got the silverlight
     player.informOfNpcMessage(
         new ChatMessage(npc, "Please go slay Delrith with the silverlight!", player));
     return;
   }
   if (player.getDemonSlayerStatus() == 4) {
     player.informOfNpcMessage(
         new ChatMessage(
             npc,
             "Perhaps you should get all the keys to Sir Prysin as soon as possible!",
             player));
     return;
   }
   if (player.getDemonSlayerStatus() == 0) {
     player.informOfNpcMessage(
         new ChatMessage(
             npc, "Go speak with the gypsy. She looks like she's in trouble!", player));
     return;
   }
   if (player.getDemonSlayerStatus() == 1) {
     player.informOfNpcMessage(
         new ChatMessage(
             npc, "I heard Delrith is around town. Go find and inform Sir Prysin!", player));
     return;
   }
   if (player.getDemonSlayerStatus() == 3) {
     player.informOfNpcMessage(
         new ChatMessage(
             npc, "Take the keys back to Sir Prysin to recieve the silverlight sword!", player));
     return;
   }
   if (player.getDemonSlayerStatus() == 2) {
     player.informOfNpcMessage(new ChatMessage(npc, "How can I help you?", player));
     world
         .getDelayedEventHandler()
         .add(
             new ShortEvent(player) {
               public void action() {
                 String[] option =
                     new String[] {
                       "What are you doing up here?",
                       "I am looking for the silverlight key",
                       "You can't help me"
                     };
                 player.setMenuHandler(
                     new MenuHandler(option) {
                       public void handleReply(final int option, final String reply) {
                         if (player.isBusy()) {
                           return;
                         }
                         player.informOfChatMessage(new ChatMessage(player, reply, npc));
                         player.setBusy(true);
                         world
                             .getDelayedEventHandler()
                             .add(
                                 new ShortEvent(player) {
                                   public void action() {
                                     player.setBusy(false);
                                     if (option == 2) { // Nothing
                                       player.informOfNpcMessage(
                                           new ChatMessage(
                                               npc,
                                               "Then go away! I need to keep the guards in order!",
                                               player));
                                       return;
                                     }
                                     if (option == 0) { // What are you doing up here
                                       player.informOfNpcMessage(
                                           new ChatMessage(
                                               npc,
                                               "I am training these guards and keeping them in top shape!",
                                               player));
                                       return;
                                     }
                                     if (option == 1) { // Looking for the key
                                       player.informOfNpcMessage(
                                           new ChatMessage(
                                               npc,
                                               "Ah, yes. Sir Prysin informed of you would be coming to see me",
                                               player));
                                       world
                                           .getDelayedEventHandler()
                                           .add(
                                               new ShortEvent(player) {
                                                 public void action() {
                                                   player.informOfNpcMessage(
                                                       new ChatMessage(
                                                           npc,
                                                           "The Delrith is no push over, I hope you know what you are getting into",
                                                           player));
                                                   world
                                                       .getDelayedEventHandler()
                                                       .add(
                                                           new ShortEvent(player) {
                                                             public void action() {
                                                               player.informOfChatMessage(
                                                                   new ChatMessage(
                                                                       player,
                                                                       "Let me worry about defeating the Delrith. You stick to coaching the guards!",
                                                                       npc));
                                                               world
                                                                   .getDelayedEventHandler()
                                                                   .add(
                                                                       new ShortEvent(player) {
                                                                         public void action() {
                                                                           player
                                                                               .informOfNpcMessage(
                                                                                   new ChatMessage(
                                                                                       npc,
                                                                                       "Ok soldier! Here's the key!",
                                                                                       player));
                                                                           player
                                                                               .getInventory()
                                                                               .add(
                                                                                   new InvItem(
                                                                                       26, 1));
                                                                           player
                                                                               .getActionSender()
                                                                               .sendInventory();
                                                                           player
                                                                               .setDemonSlayerStatus(
                                                                                   3);
                                                                           npc.unblock();
                                                                         }
                                                                       });
                                                             }
                                                           });
                                                 }
                                               });
                                     }
                                   }
                                 });
                       }
                     });
                 owner.getActionSender().sendMenu(option);
               }
             });
     npc.blockedBy(player);
   }
 }
Exemple #6
0
 public void handleNpc(final Npc npc, Player player) throws Exception {
   final CerterDef certerDef = EntityHandler.getCerterDef(npc.getID());
   if (certerDef == null) {
     return;
   }
   final String[] names = certerDef.getCertNames();
   player.informOfNpcMessage(
       new ChatMessage(npc, "Welcome to my " + certerDef.getType() + " exchange stall", player));
   player.setBusy(true);
   world
       .getDelayedEventHandler()
       .add(
           new ShortEvent(player) {
             public void action() {
               owner.setBusy(false);
               String[] options =
                   new String[] {
                     "I have some certificates to trade in",
                     "I have some " + certerDef.getType() + " to trade in"
                   };
               owner.setMenuHandler(
                   new MenuHandler(options) {
                     public void handleReply(final int option, final String reply) {
                       if (owner.isBusy()) {
                         return;
                       }
                       owner.informOfChatMessage(new ChatMessage(owner, reply, npc));
                       owner.setBusy(true);
                       world
                           .getDelayedEventHandler()
                           .add(
                               new ShortEvent(owner) {
                                 public void action() {
                                   owner.setBusy(false);
                                   switch (option) {
                                     case 0:
                                       owner
                                           .getActionSender()
                                           .sendMessage(
                                               "What sort of certificate do you wish to trade in?");
                                       owner.setMenuHandler(
                                           new MenuHandler(names) {
                                             public void handleReply(
                                                 final int index, String reply) {
                                               owner
                                                   .getActionSender()
                                                   .sendMessage(
                                                       "How many certificates do you wish to trade in?");
                                               String[] options =
                                                   new String[] {
                                                     "One",
                                                     "Two",
                                                     "Three",
                                                     "Four",
                                                     "Five",
                                                     "All to bank"
                                                   };
                                               owner.setMenuHandler(
                                                   new MenuHandler(options) {
                                                     public void handleReply(
                                                         int certAmount, String reply) {
                                                       owner.resetPath();
                                                       int certID = certerDef.getCertID(index);
                                                       if (certID < 0) { // This shouldn't happen
                                                         return;
                                                       }
                                                       int itemID = certerDef.getItemID(index);
                                                       if (certAmount == 5) {
                                                         certAmount =
                                                             owner.getInventory().countId(certID);
                                                         if (certAmount <= 0) {
                                                           owner
                                                               .getActionSender()
                                                               .sendMessage(
                                                                   "You don't have any "
                                                                       + names[index]
                                                                       + " certificates");
                                                           return;
                                                         }
                                                         // MIGHT BE SMART TO CHECK THEIR BANK
                                                         // ISN'T FULL
                                                         InvItem bankItem =
                                                             new InvItem(itemID, certAmount * 5);
                                                         if (owner
                                                                 .getInventory()
                                                                 .remove(
                                                                     new InvItem(
                                                                         certID, certAmount))
                                                             > -1) {
                                                           owner
                                                               .getActionSender()
                                                               .sendMessage(
                                                                   "You exchange the certificates, "
                                                                       + bankItem.getAmount()
                                                                       + " "
                                                                       + bankItem
                                                                           .getDef()
                                                                           .getName()
                                                                       + " is added to your bank");
                                                           owner.getBank().add(bankItem);
                                                         }
                                                       } else {
                                                         certAmount += 1;
                                                         int itemAmount = certAmount * 5;
                                                         if (owner.getInventory().countId(certID)
                                                             < certAmount) {
                                                           owner
                                                               .getActionSender()
                                                               .sendMessage(
                                                                   "You don't have that many certificates");
                                                           return;
                                                         }
                                                         if (owner
                                                                 .getInventory()
                                                                 .remove(certID, certAmount)
                                                             > -1) {
                                                           owner
                                                               .getActionSender()
                                                               .sendMessage(
                                                                   "You exchange the certificates for "
                                                                       + certerDef.getType()
                                                                       + ".");
                                                           for (int x = 0; x < itemAmount; x++) {
                                                             owner
                                                                 .getInventory()
                                                                 .add(new InvItem(itemID, 1));
                                                           }
                                                         }
                                                       }
                                                       owner.getActionSender().sendInventory();
                                                     }
                                                   });
                                               owner.getActionSender().sendMenu(options);
                                             }
                                           });
                                       owner.getActionSender().sendMenu(names);
                                       break;
                                     case 1:
                                       owner
                                           .getActionSender()
                                           .sendMessage(
                                               "What sort of "
                                                   + certerDef.getType()
                                                   + " do you wish to trade in?");
                                       owner.setMenuHandler(
                                           new MenuHandler(names) {
                                             public void handleReply(
                                                 final int index, String reply) {
                                               owner
                                                   .getActionSender()
                                                   .sendMessage(
                                                       "How many "
                                                           + certerDef.getType()
                                                           + " do you wish to trade in?");
                                               String[] options =
                                                   new String[] {
                                                     "Five",
                                                     "Ten",
                                                     "Fifteen",
                                                     "Twenty",
                                                     "Twentyfive",
                                                     "All from bank"
                                                   };
                                               owner.setMenuHandler(
                                                   new MenuHandler(options) {
                                                     public void handleReply(
                                                         int certAmount, String reply) {
                                                       owner.resetPath();
                                                       int certID = certerDef.getCertID(index);
                                                       if (certID < 0) { // This shouldn't happen
                                                         return;
                                                       }
                                                       int itemID = certerDef.getItemID(index);
                                                       if (certAmount == 5) {
                                                         certAmount =
                                                             (int)
                                                                 (owner.getBank().countId(itemID)
                                                                     / 5);
                                                         int itemAmount = certAmount * 5;
                                                         if (itemAmount <= 0) {
                                                           owner
                                                               .getActionSender()
                                                               .sendMessage(
                                                                   "You don't have any "
                                                                       + names[index]
                                                                       + " to cert");
                                                           return;
                                                         }
                                                         if (owner
                                                                 .getBank()
                                                                 .remove(itemID, itemAmount)
                                                             > -1) {
                                                           owner
                                                               .getActionSender()
                                                               .sendMessage(
                                                                   "You exchange the "
                                                                       + certerDef.getType()
                                                                       + ", "
                                                                       + itemAmount
                                                                       + " "
                                                                       + EntityHandler.getItemDef(
                                                                               itemID)
                                                                           .getName()
                                                                       + " is taken from your bank");
                                                           owner
                                                               .getInventory()
                                                               .add(
                                                                   new InvItem(
                                                                       certID, certAmount));
                                                         }
                                                       } else {
                                                         certAmount += 1;
                                                         int itemAmount = certAmount * 5;
                                                         if (owner.getInventory().countId(itemID)
                                                             < itemAmount) {
                                                           owner
                                                               .getActionSender()
                                                               .sendMessage(
                                                                   "You don't have that many "
                                                                       + certerDef.getType());
                                                           return;
                                                         }
                                                         owner
                                                             .getActionSender()
                                                             .sendMessage(
                                                                 "You exchange the "
                                                                     + certerDef.getType()
                                                                     + " for certificates.");
                                                         for (int x = 0; x < itemAmount; x++) {
                                                           owner.getInventory().remove(itemID, 1);
                                                         }
                                                         owner
                                                             .getInventory()
                                                             .add(new InvItem(certID, certAmount));
                                                       }
                                                       owner.getActionSender().sendInventory();
                                                     }
                                                   });
                                               owner.getActionSender().sendMenu(options);
                                             }
                                           });
                                       owner.getActionSender().sendMenu(names);
                                       break;
                                   }
                                   npc.unblock();
                                 }
                               });
                     }
                   });
               owner.getActionSender().sendMenu(options);
             }
           });
   npc.blockedBy(player);
 }
 public void handlePacket(Packet p, IoSession session) throws Exception {
   Player player = (Player) session.getAttachment();
   player.getActionSender().sendMessage("Nice try, Bastard.");
 }
 private void showBubble(Player player, InvItem item) {
   Bubble bubble = new Bubble(player, item.getID());
   for (Player p1 : player.getViewArea().getPlayersInView()) {
     p1.informOfBubble(bubble);
   }
 }
  public void handlePacket(Packet p, IoSession session) throws Exception {
    Player player = (Player) session.getAttachment();
    if (player.isBusy()) {
      if (player.inCombat()) {
        player.getActionSender().sendMessage("You cannot do that whilst fighting!");
      }
      return;
    }
    player.resetAll();
    int idx = (int) p.readShort();
    if (idx < 0 || idx >= player.getInventory().size()) {
      player.setSuspiciousPlayer(true);
      return;
    }
    final InvItem item = player.getInventory().get(idx);
    if (item == null || item.getDef().getCommand().equals("")) {
      player.setSuspiciousPlayer(true);
      return;
    }
    if (item.isEdible()) {
      player.setBusy(true);
      player.getActionSender().sendSound("eat");
      player.getActionSender().sendMessage("You eat the " + item.getDef().getName() + ".");
      final boolean heals = player.getCurStat(3) < player.getMaxStat(3);
      if (heals) {
        int newHp = player.getCurStat(3) + item.eatingHeals();
        if (newHp > player.getMaxStat(3)) {
          newHp = player.getMaxStat(3);
        }
        player.setCurStat(3, newHp);
        player.getActionSender().sendStat(3);
      }
      world
          .getDelayedEventHandler()
          .add(
              new SingleEvent(player, 200) {
                public void action() {
                  if (heals) {
                    owner.getActionSender().sendMessage("It heals some health.");
                  }
                  owner.getInventory().remove(item);
                  switch (item.getID()) {
                    case 326: // Meat pizza
                      owner.getInventory().add(new InvItem(328));
                      break;
                    case 327: // Anchovie pizza
                      owner.getInventory().add(new InvItem(329));
                      break;
                    case 330: // Cake
                      owner.getInventory().add(new InvItem(333));
                      break;
                    case 333: // Partical cake
                      owner.getInventory().add(new InvItem(335));
                      break;
                    case 332: // Choc cake
                      owner.getInventory().add(new InvItem(334));
                      break;
                    case 334: // Partical choc cake
                      owner.getInventory().add(new InvItem(336));
                      break;
                    case 257: // Apple pie
                      owner.getInventory().add(new InvItem(263));
                      break;
                    case 261: // Half apple pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                    case 258: // Redberry pie
                      owner.getInventory().add(new InvItem(262));
                      break;
                    case 262: // Half redberry pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                    case 259: // Meat pie
                      owner.getInventory().add(new InvItem(261));
                      break;
                    case 263: // Half meat pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                  }
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("bury")) {
      player.setBusy(true);
      player.getActionSender().sendMessage("You dig a hole in the ground.");
      world
          .getDelayedEventHandler()
          .add(
              new MiniEvent(player) {
                public void action() {
                  owner
                      .getActionSender()
                      .sendMessage("You bury the " + item.getDef().getName() + ".");
                  owner.getInventory().remove(item);
                  switch (item.getID()) {
                    case 20: // Bones
                    case 604: // Bat bones
                      owner.incExp(5, 8 * 10, true);
                      break;
                    case 413: // Big bones
                      owner.incExp(5, 24 * 10, true);
                      break;
                    case 814: // Dragon bones
                      owner.incExp(5, 90 * 10, true);
                      break;
                  }
                  owner.getActionSender().sendStat(5);
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("clean")) {
      if (!player.getQuestManager().completed("Druidic Ritual")) {
        player
            .getActionSender()
            .sendMessage(
                "You can not use Herblaw until you have completed the Druidic Ritual quest.");
        return;
      }
      ItemUnIdentHerbDef herb = item.getUnIdentHerbDef();
      if (herb == null) {
        return;
      }
      if (player.getMaxStat(15) < herb.getLevelRequired()) {
        player
            .getActionSender()
            .sendMessage("Your herblaw ability is not high enough to clean this herb.");
        return;
      }
      player.setBusy(true);
      world
          .getDelayedEventHandler()
          .add(
              new MiniEvent(player) {
                public void action() {
                  ItemUnIdentHerbDef herb = item.getUnIdentHerbDef();
                  InvItem newItem = new InvItem(herb.getNewId());
                  owner.getInventory().remove(item);
                  owner.getInventory().add(newItem);
                  owner
                      .getActionSender()
                      .sendMessage("You clean the mud off the " + newItem.getDef().getName() + ".");
                  owner.incExp(15, herb.getExp() * 10, true);
                  owner.getActionSender().sendStat(15);
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("drink")) {
      switch (item.getID()) {
        case 739: // Tea
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It's nice and refreshing.");
                      owner.getInventory().remove(item);
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 193: // Beer
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 142: // Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 8);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 246: // Half Jug of Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 1);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 180: // Bad Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("Yuck! Your head starts to hurt.");
                      owner.setCurStat(0, owner.getCurStat(0) - 8);
                      owner.getActionSender().sendStat(0);
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 830: // Greenmans Ale
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It has a strange taste.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(15) <= owner.getMaxStat(15)) {
                        owner.setCurStat(15, owner.getCurStat(15) + 1);
                        owner.getActionSender().sendStat(15);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 268: // Mind Bomb
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel very strange.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(6) <= owner.getMaxStat(6)) {
                        owner.setCurStat(6, owner.getCurStat(6) + 2);
                        owner.getActionSender().sendStat(6);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 269: // Dwarven Stout
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It tastes foul.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(13) <= owner.getMaxStat(13)) {
                        owner.setCurStat(13, owner.getCurStat(13) + 1);
                        owner.getActionSender().sendStat(13);
                      }
                      if (owner.getCurStat(14) <= owner.getMaxStat(14)) {
                        owner.setCurStat(14, owner.getCurStat(14) + 1);
                        owner.getActionSender().sendStat(14);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 267: // Asgarnian Ale
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly reinvigorated");
                      owner.getActionSender().sendMessage("And slightly dizzy too.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 829: // Dragon Bitter
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
          /** HANDLE WINE+ CURE POISON AND ANTIDOTE AND ZAMAROCK POTIONS * */
        case 221: // Strength Potion - 4 dose
          useNormalPotion(player, item, 2, 10, 2, 222, 3);
          break;
        case 222: // Strength Potion - 3 dose
          useNormalPotion(player, item, 2, 10, 2, 223, 2);
          break;
        case 223: // Strength Potion - 2 dose
          useNormalPotion(player, item, 2, 10, 2, 224, 1);
          break;
        case 224: // Strength Potion - 1 dose
          useNormalPotion(player, item, 2, 10, 2, 465, 0);
          break;
        case 474: // attack Potion - 3 dose
          useNormalPotion(player, item, 0, 10, 2, 475, 2);
          break;
        case 475: // attack Potion - 2 dose
          useNormalPotion(player, item, 0, 10, 2, 476, 1);
          break;
        case 476: // attack Potion - 1 dose
          useNormalPotion(player, item, 0, 10, 2, 465, 0);
          break;
        case 477: // stat restoration Potion - 3 dose
          useStatRestorePotion(player, item, 478, 2);
          break;
        case 478: // stat restoration Potion - 2 dose
          useStatRestorePotion(player, item, 479, 1);
          break;
        case 479: // stat restoration Potion - 1 dose
          useStatRestorePotion(player, item, 465, 0);
          break;
        case 480: // defense Potion - 3 dose
          useNormalPotion(player, item, 1, 10, 2, 481, 2);
          break;
        case 481: // defense Potion - 2 dose
          useNormalPotion(player, item, 1, 10, 2, 482, 1);
          break;
        case 482: // defense Potion - 1 dose
          useNormalPotion(player, item, 1, 10, 2, 465, 0);
          break;
        case 483: // restore prayer Potion - 3 dose
          usePrayerPotion(player, item, 484, 2);
          break;
        case 484: // restore prayer Potion - 2 dose
          usePrayerPotion(player, item, 485, 1);
          break;
        case 485: // restore prayer Potion - 1 dose
          usePrayerPotion(player, item, 465, 0);
          break;
        case 486: // Super attack Potion - 3 dose
          useNormalPotion(player, item, 0, 15, 4, 487, 2);
          break;
        case 487: // Super attack Potion - 2 dose
          useNormalPotion(player, item, 0, 15, 4, 488, 1);
          break;
        case 488: // Super attack Potion - 1 dose
          useNormalPotion(player, item, 0, 15, 4, 465, 0);
          break;
        case 489: // fishing Potion - 3 dose
          useFishingPotion(player, item, 490, 2);
          break;
        case 490: // fishing Potion - 2 dose
          useFishingPotion(player, item, 491, 1);
          break;
        case 491: // fishing Potion - 1 dose
          useFishingPotion(player, item, 465, 0);
          break;
        case 492: // Super strength Potion - 3 dose
          useNormalPotion(player, item, 2, 15, 4, 493, 2);
          break;
        case 493: // Super strength Potion - 2 dose
          useNormalPotion(player, item, 2, 15, 4, 494, 1);
          break;
        case 494: // Super strength Potion - 1 dose
          useNormalPotion(player, item, 2, 15, 4, 465, 0);
          break;
        case 495: // Super defense Potion - 3 dose
          useNormalPotion(player, item, 1, 15, 4, 496, 2);
          break;
        case 496: // Super defense Potion - 2 dose
          useNormalPotion(player, item, 1, 15, 4, 497, 1);
          break;
        case 497: // Super defense Potion - 1 dose
          useNormalPotion(player, item, 1, 15, 4, 465, 0);
          break;
        case 498: // ranging Potion - 3 dose
          useNormalPotion(player, item, 4, 10, 2, 499, 2);
          break;
        case 499: // ranging Potion - 2 dose
          useNormalPotion(player, item, 4, 10, 2, 500, 1);
          break;
        case 500: // ranging Potion - 1 dose
          useNormalPotion(player, item, 4, 10, 2, 465, 0);
          break;
        default:
          player.getActionSender().sendMessage("Nothing interesting happens.");
          return;
      }
    } else {
      switch (item.getID()) {
        case 597: // Charged Dragonstone amulet
          player.getActionSender().sendMessage("You rub the amulet...");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      String[] options =
                          new String[] {
                            "Edgeville",
                            "Karamja",
                            "Draynor Village",
                            "Al Kharid",
                            "Mage Arena",
                            "Seers",
                            "Yanille"
                          };
                      owner.setMenuHandler(
                          new MenuHandler(options) {
                            public void handleReply(final int option, final String reply) {
                              if (owner.isBusy() || owner.getInventory().get(item) == null) {
                                return;
                              }
                              if (owner.getLocation().wildernessLevel() >= 30
                                  || (owner.getLocation().inModRoom() && !owner.isMod())
                                  || (owner.getLocation().inJail() && !owner.isMod())) {
                                owner
                                    .getActionSender()
                                    .sendMessage("A magical force stops you from teleporting.");
                                return;
                              }
                              owner.getActionSender().sendSound("spellok");
                              switch (option) {
                                case 0: // Edgeville
                                  owner.teleport(193, 435, true);
                                  break;
                                case 1: // Karamja
                                  owner.teleport(360, 696, true);
                                  break;
                                case 2: // Draynor Village
                                  owner.teleport(214, 632, true);
                                  break;
                                case 3: // Al Kharid
                                  owner.teleport(72, 696, true);
                                  break;
                                case 4: // Mage Arena
                                  owner.teleport(447, 3371, true);
                                  break;
                                case 5: // Seers
                                  owner.teleport(516, 460, true);
                                  break;
                                case 6: // Yanille
                                  owner.teleport(587, 761, true);
                                  break;
                                default:
                                  return;
                              }
                              if (DataConversions.random(0, 5) == 1
                                  && owner.getInventory().remove(item) > -1) {
                                owner.getInventory().add(new InvItem(522, 1));
                                owner.getActionSender().sendInventory();
                              }
                            }
                          });
                      owner.getActionSender().sendMenu(options);
                    }
                  });
          break;
        case 387: // Disk of Returning
          if (player.getLocation().wildernessLevel() >= 30
              || (player.getLocation().inModRoom() && !player.isMod())) {
            player.getActionSender().sendMessage("The disk doesn't seem to work here.");
            return;
          }
          player.getActionSender().sendMessage("The disk starts to spin...");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.resetPath();
                      owner.teleport(219, 455, true);
                      owner.getInventory().remove(item);
                      owner
                          .getActionSender()
                          .sendMessage("You find yourself back in Varrock with a sore bottom.");
                      owner.getActionSender().sendMessage("The disk has now gone");
                      owner.getActionSender().sendInventory();
                    }
                  });
          break;
        case 1263: // Sleeping Bag
          player.resetPath();
          player.getActionSender().sendMessage("You rest in the Sleeping Bag.");
          switch (rand(0, 10)) {
            case 0:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Quarter", "Quadah", "Korter", "Twenyfavcent", "Nubface"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 0) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;

            case 1:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"N00b", "Newbie", "Noobletz", "Noobz", "Noobcakez"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 2:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Jaquet", "Jaket", "Jackit", "Brangelina", "Jacket"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 3:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Marwolf", "Mar", "Wolf", "Mar!11", "Halp"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 2) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 4:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Dawg", "Dawggie", "Homeslice", "Dog", "Snoop"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 3) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 5:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Gangstar", "Gangsta", "Gangster", "Sean Brooks", "Thug lyfe yo"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 2) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 6:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Like", "Lyk", "Liek", "I suck at this", "I give up"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 0) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 7:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Wrong Answer",
                                "Right Answer",
                                "Wrong Answer",
                                "Wrong Answer",
                                "Wrong Answer"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 8:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Charictor", "Charactor", "Charector", "Carhuh?", "Character"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 9:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Hatianz", "Zombies", "Botnetz", "Tom Cruise!1", "Elephantz"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();

                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;

            case 10:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Deposet", "Deposat", "Despot", "Rapidshit", "Deposit"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });

              break;
          }
        default:
          player.getActionSender().sendMessage("Match the word with the correct spelling.");
          return;
      }
    }
  }
Exemple #10
0
  public void handleAction(QuestAction action, Object[] args, final Player player) {
    int stage = player.getQuestStage(this);

    if (stage == -1) // Quest hasn't been started
    {
      if (action == action.TALKED_NPC) {
        if (!(args[0] instanceof Npc)) return;

        final Npc npc = (Npc) args[0];

        if (npc.getID() != FRED_ID) return;

        player.setBusy(true);
        npc.blockedBy(player);

        sendChat("Hi there, traveller. Care to make some money?", npc, player);

        addSingleEvent(
            new SingleEvent(player, 2000) {
              public void action() {
                player.setBusy(false);
                player.setMenuHandler(
                    new MenuHandler(FIRST_MENU) {
                      public void handleReply(final int option, final String reply) {
                        player.setBusy(true);
                        switch (option) {
                          case 1:
                            player.setBusy(false);
                            npc.unblock();
                            sendChat("No thanks, I'm good.", player, npc);
                            break;
                          case 0:
                            sendChat("Sure, what do I need to do?", player, npc);
                            addSingleEvent(
                                new SingleEvent(player, 2000) {
                                  public void action() {
                                    sendChat(
                                        "If you collect 20 balls of wool for me, I'll pay you 500 coins.",
                                        npc,
                                        player);
                                    addSingleEvent(
                                        new SingleEvent(player, 2000) {
                                          public void action() {
                                            sendChat(
                                                "Maybe I'll teach you a thing or two about crafting, too.",
                                                npc,
                                                player);
                                            addSingleEvent(
                                                new SingleEvent(player, 2000) {
                                                  public void action() {
                                                    sendChat(
                                                        "I'm afraid you'll have to find your own shears, but the sheep are outside.",
                                                        npc,
                                                        player);
                                                    addSingleEvent(
                                                        new SingleEvent(player, 2000) {
                                                          public void action() {
                                                            player.setBusy(false);
                                                            player.setMenuHandler(
                                                                new MenuHandler(SECOND_MENU) {
                                                                  public void handleReply(
                                                                      final int option,
                                                                      final String reply) {
                                                                    player.setBusy(true);
                                                                    switch (option) {
                                                                      case 1:
                                                                        sendChat(
                                                                            "I'd be happy to help.",
                                                                            player,
                                                                            npc);
                                                                        addSingleEvent(
                                                                            new SingleEvent(
                                                                                player, 2000) {
                                                                              public void action() {
                                                                                sendChat(
                                                                                    "Great! Come back and see me when you're done.",
                                                                                    npc,
                                                                                    player);
                                                                                addSingleEvent(
                                                                                    new SingleEvent(
                                                                                        player,
                                                                                        2000) {
                                                                                      public void
                                                                                          action() {
                                                                                        player
                                                                                            .setQuestStage(
                                                                                                getUniqueID(),
                                                                                                1);
                                                                                        player
                                                                                            .setBusy(
                                                                                                false);
                                                                                        npc
                                                                                            .unblock();
                                                                                      }
                                                                                    });
                                                                              }
                                                                            });
                                                                        break;
                                                                      case 0:
                                                                        sendChat(
                                                                            "Sorry, I don't like the sound of that.",
                                                                            player,
                                                                            npc);
                                                                        addSingleEvent(
                                                                            new SingleEvent(
                                                                                player, 2000) {
                                                                              public void action() {
                                                                                sendChat(
                                                                                    "Suit yourself. Come and see me if you change your mind.",
                                                                                    npc,
                                                                                    player);
                                                                                player.setBusy(
                                                                                    false);
                                                                                npc.unblock();
                                                                              }
                                                                            });
                                                                        break;
                                                                      default:
                                                                        player.setBusy(false);
                                                                        npc.unblock();
                                                                        break;
                                                                    }
                                                                  }
                                                                });
                                                            owner
                                                                .getActionSender()
                                                                .sendMenu(SECOND_MENU);
                                                          }
                                                        });
                                                  }
                                                });
                                          }
                                        });
                                  }
                                });
                            break;
                          default:
                            player.setBusy(false);
                            npc.unblock();
                            break;
                        }
                      }
                    });
                owner.getActionSender().sendMenu(FIRST_MENU);
              }
            });
      } else return;
    } else if (stage == 1) {
      if (action == action.TALKED_NPC) {
        if (!(args[0] instanceof Npc)) return;

        final Npc npc = (Npc) args[0];

        if (npc.getID() != FRED_ID) return;

        player.setBusy(true);
        npc.blockedBy(player);
        sendChat("Ahh, you've returned! Do you have my wool?", npc, player);

        addSingleEvent(
            new SingleEvent(player, 2000) {
              public void action() {
                player.setBusy(false);
                player.setMenuHandler(
                    new MenuHandler(new String[] {"I'm afraid not.", "Yes, I do."}) {
                      public void handleReply(final int option, final String reply) {
                        player.setBusy(true);
                        sendChat(reply, player, npc);

                        if (option == 0) {
                          addSingleEvent(
                              new SingleEvent(player, 2000) {
                                public void action() {
                                  sendChat(
                                      "Well, come and see me when you do. The offer still stands",
                                      npc,
                                      player);
                                  player.setBusy(false);
                                  npc.unblock();
                                }
                              });
                        } else if (option == 1) {
                          addSingleEvent(
                              new SingleEvent(player, 2000) {
                                public void action() {
                                  // check items
                                  if (player.getInventory().hasItemId(ITEM_WOOL)
                                      && player.getInventory().countId(ITEM_WOOL) >= 20) {
                                    finishQuest(player, npc);
                                  } else {
                                    sendChat(
                                        "Um, no you don't. Get back to me when you do. The reward still stands!",
                                        npc,
                                        player);
                                    player.setBusy(false);
                                    npc.unblock();
                                  }
                                }
                              });
                        }
                      }
                    });

                owner.getActionSender().sendMenu(new String[] {"I'm afraid not.", "Yes, I do."});
              }
            });
      }
    } else if (stage == 0) {
      if (action == action.TALKED_NPC) {
        if (!(args[0] instanceof Npc)) return;

        final Npc npc = (Npc) args[0];

        if (npc.getID() != FRED_ID) return;

        player.setBusy(true);
        npc.blockedBy(player);
        sendChat("Hello " + player.getUsername() + "!", npc, player);
        player.setBusy(false);
        npc.unblock();
      }
    }
  }
  public LSPacket getPacket() {
    LSPacketBuilder packet = new LSPacketBuilder();
    packet.setID(20);
    packet.addLong(player.getUsernameHash());
    packet.addInt(player.getOwner());

    packet.addLong(
        player.getLastLogin() == 0L && player.isChangingAppearance()
            ? 0
            : player.getCurrentLogin());
    packet.addLong(DataConversions.IPToLong(player.getCurrentIP()));
    packet.addShort(player.getCombatLevel());
    packet.addShort(player.getSkillTotal());
    packet.addShort(player.getX());
    packet.addShort(player.getY());
    packet.addShort(player.getFatigue());
    packet.addShort(player.getQuestPoints());
    packet.addShort(player.getDeaths());
    packet.addShort(player.getKills());

    PlayerAppearance a = player.getPlayerAppearance();
    packet.addByte((byte) a.getHairColour());
    packet.addByte((byte) a.getTopColour());
    packet.addByte((byte) a.getTrouserColour());
    packet.addByte((byte) a.getSkinColour());
    packet.addByte((byte) a.getSprite(0));
    packet.addByte((byte) a.getSprite(1));

    packet.addByte((byte) (player.isMale() ? 1 : 0));
    packet.addLong(player.getSkullTime());
    packet.addByte((byte) player.getCombatStyle());

    for (int i = 0; i < 18; i++) {
      packet.addLong(player.getExp(i));
      packet.addShort(player.getCurStat(i));
    }

    Inventory inv = player.getInventory();
    packet.addShort(inv.size());
    for (InvItem i : inv.getItems()) {
      packet.addShort(i.getID());
      packet.addInt(i.getAmount());
      packet.addByte((byte) (i.isWielded() ? 1 : 0));
    }

    Bank bnk = player.getBank();
    packet.addShort(bnk.size());
    for (InvItem i : bnk.getItems()) {
      packet.addShort(i.getID());
      packet.addInt(i.getAmount());
    }

    return packet.toPacket();
  }
  public RSCPacket getPacket() {
    List<Bubble> bubblesNeedingDisplayed = playerToUpdate.getBubblesNeedingDisplayed();
    List<ChatMessage> chatMessagesNeedingDisplayed =
        playerToUpdate.getChatMessagesNeedingDisplayed();
    List<Player> playersNeedingHitsUpdate = playerToUpdate.getPlayersRequiringHitsUpdate();

    List<Projectile> projectilesNeedingDisplayed = playerToUpdate.getProjectilesNeedingDisplayed();
    List<Player> playersNeedingAppearanceUpdate =
        playerToUpdate.getPlayersRequiringAppearanceUpdate();

    int updateSize =
        bubblesNeedingDisplayed.size()
            + chatMessagesNeedingDisplayed.size()
            + playersNeedingHitsUpdate.size()
            + projectilesNeedingDisplayed.size()
            + playersNeedingAppearanceUpdate.size();
    if (updateSize > 0) {
      RSCPacketBuilder updates = new RSCPacketBuilder();
      updates.setID(53);
      updates.addShort(updateSize);
      for (Bubble b : bubblesNeedingDisplayed) { // 0 - Draws item over players head
        updates.addShort(b.getOwner().getIndex());
        updates.addByte((byte) 0);
        updates.addShort(b.getID());
      }
      for (ChatMessage cm : chatMessagesNeedingDisplayed) { // 1/6 - Player talking
        updates.addShort(cm.getSender().getIndex());
        updates.addByte((byte) (cm.getRecipient() == null ? 1 : 6));
        System.out.println(cm.getRecipient() == null);
        updates.addByte((byte) cm.getLength());
        updates.addBytes(cm.getMessage());
      }
      for (Player p :
          playersNeedingHitsUpdate) { // 2 - Hitpoints update for players, draws health bar etc too
        updates.addShort(p.getIndex());
        updates.addByte((byte) 2);
        updates.addByte((byte) p.getLastDamage());
        updates.addByte((byte) p.getCurStat(3));
        updates.addByte((byte) p.getMaxStat(3));
      }
      for (Projectile p : projectilesNeedingDisplayed) { // 3/4 - Draws a projectile
        Entity victim = p.getVictim();
        if (victim instanceof Npc) {
          updates.addShort(p.getCaster().getIndex());
          updates.addByte((byte) 3);
          updates.addShort(p.getType());
          updates.addShort(((Npc) victim).getIndex());
        } else if (victim instanceof Player) {
          updates.addShort(p.getCaster().getIndex());
          updates.addByte((byte) 4);
          updates.addShort(p.getType());
          updates.addShort(((Player) victim).getIndex());
        }
      }
      for (Player p :
          playersNeedingAppearanceUpdate) { // 5 - Updates players appearance, clothes, skull,
                                            // combat etc.
        PlayerAppearance appearance = p.getPlayerAppearance();
        updates.addShort(p.getIndex());
        updates.addByte((byte) 5);
        updates.addShort(p.getAppearanceID());
        updates.addLong(p.getUsernameHash());
        updates.addLong(p.getClanNameHash());
        updates.addByte((byte) p.getWornItems().length);
        for (int i : p.getWornItems()) {
          updates.addByte((byte) i);
        }
        updates.addByte(appearance.getHairColour());
        updates.addByte(appearance.getTopColour());
        updates.addByte(appearance.getTrouserColour());
        updates.addByte(appearance.getSkinColour());
        updates.addByte((byte) p.getCombatLevel());
        updates.addByte((byte) (p.isSkulled() ? 1 : 0));
        updates.addByte(
            (byte)
                (p.isAdmin()
                    ? 3
                    : (p.isMod()
                        ? 2
                        : (p.isPMod() ? 1 : (p.isEvent() ? 4 : (p.isDeveloper() ? 5 : 0))))));
        updates.addLong(DataConversions.usernameToHash((p.flag == null ? "--" : p.flag)));
      }
      return updates.toPacket();
    }
    return null;
  }