Thread: 718 Crystal chest chance

Results 1 to 3 of 3
  1. #1 718 Crystal chest chance 
    Registered Member
    Join Date
    Nov 2013
    Posts
    815
    Thanks given
    111
    Thanks received
    109
    Rep Power
    14
    How would i go ahead adding a 1/50 chance for a rare drop?


    Handled
    Code:
     public static void searchChest2(final Player p, Item item, final Player player) {
            final int itemId = item.getId();
            final ItemDefinitions itemDef = new ItemDefinitions(item.getId());
            WorldTasksManager.schedule(new WorldTask() {
                public void run() {
                    try {
                        if (!p.getInventory().containsItem(itemId, 1)) {
                            stop();
                            return;
                        }
                        p.getPackets()
                                .sendGameMessage(
                                        "You unlock the chest with your key.");
                        p.setNextAnimation(new Animation(881)); //Opening anim
                        p.getInventory().deleteItem(new Item(itemId, 1));
                        p.getInventory().addItem(995, Utils.random(3000000)); //Random amount of coins (MAX 5M)
                        p.sm("Message: You receive a random item from the Crystal chest!");
                        int index = Utils.random(CHEST_REWARDS.length);
                            p.getInventory().addItem(CHEST_REWARDS[index], 1); //Adds a random chest reward    
                        
                        for (int i = 0; i < RARE_REWARDS.length; i++) {
                            int item = RARE_REWARDS[i];
                            
                            if (CHEST_REWARDS[index] == RARE_REWARDS[i]) {
                            	for (Player p : World.getPlayers()) {
                                        World.sendWorldMessage("<img=6><col=B80000>News: "+player.getDisplayName()+" has just received a "+ItemDefinitions.getItemDefinitions(item).getName()+" from the Crystal Chest!", false);
               
                                    player.sm("<col=05AA8B>Message: You receive a rare item ("+ItemDefinitions.getItemDefinitions(item).getName()+") from the Crystal Chest!");
                                }
                            }
                        }
                        
                        p.getInventory().refresh();
                        p.resetWalkSteps();
                        
                      p.lock(2);
                        
                    } catch (Throwable e) {
                        Logger.handle(e);
                    }
                }
            }, 0, 3);
        }
    }
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    May 2011
    Age
    29
    Posts
    2,246
    Thanks given
    2,469
    Thanks received
    1,120
    Rep Power
    943
    if(new Random().nextInt(50) == 0)
    doThing();
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Nov 2013
    Posts
    815
    Thanks given
    111
    Thanks received
    109
    Rep Power
    14
    Quote Originally Posted by Tylurr View Post
    if(new Random().nextInt(50) == 0)
    Where would i go adding that about?
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [718] Crystal Chest Tweaks
    By -Robbie in forum Snippets
    Replies: 7
    Last Post: 12-09-2015, 04:32 PM
  2. 718 - Crystal chest system [RSGP]
    By Ownedin3d in forum Buying
    Replies: 5
    Last Post: 09-17-2013, 01:21 PM
  3. 718 crystal chest problem
    By Dan_ in forum Help
    Replies: 2
    Last Post: 06-06-2013, 08:57 PM
  4. [718] Crystal Chest Problems
    By Hendereye in forum Help
    Replies: 0
    Last Post: 06-06-2013, 02:58 PM
  5. 718 Crystal Chest
    By king dark in forum Snippets
    Replies: 7
    Last Post: 05-26-2013, 09:11 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •