Thread: Crystal Chest Random items?

Results 1 to 3 of 3
  1. #1 Crystal Chest Random items? 
    Registered Member
    Join Date
    May 2013
    Posts
    23
    Thanks given
    1
    Thanks received
    0
    Rep Power
    11
    Hey, I want to add random item rewards on my crystal chest, "p.getInventory().addItem(995, 15000000);" is the only reward from my chest atm. How do I add like instead of getting cash all the time, you get like different costumes each time you get a reward?


    Code:
    package com.rs.game.minigames;
    
    import com.rs.game.player.Player;
    import com.rs.game.Animation;
    import com.rs.utils.Utils;
    
    /**
     * Represents the chest on which the key is used.
     * @author Corey 2012 <Fixed some stuff by bart>
     */
    
    public class CrystalChest {
    	
    	private static final Object[] CHEST_REWARDS = { };
    	public static final int[] KEY_HALVES = { 985, 987 };
    	public static final int KEY = 989;
    	public static final int Animation = 881;
    	
    	/**
    	 * Represents the key being made.
    	 * Using tooth halves.
    	 */
    	public static void makeKey(Player p){
    		if (p.getInventory().containsItem(toothHalf(), 1) 
    				&& p.getInventory().containsItem(loopHalf(), 1)){
    			p.getInventory().deleteItem(toothHalf(), 1);
    			p.getInventory().deleteItem(loopHalf(), 1);
    			p.getInventory().addItem(KEY, 1);
    			p.getPackets().sendGameMessage("You succesfully make a crytal key.");
    		}
    	}
    	
    	/**
    	 * If the player can open the chest.
    	 */
    	public static boolean canOpen(Player p){
    		if(p.getInventory().containsItem(KEY, 1)){
    			return true;
    		}else{
    			p.getPackets().sendGameMessage("<col=FFFF00>This chest is locked.</col>");
    			return false;
    		}
    	}
    	
    	/**
    	 * When the player searches the chest.
    	 */
    	public static void searchChest(final Player p){
    		if (canOpen(p)){
    			p.getPackets().sendGameMessage("You unlock the chest with your key.");
    			p.getInventory().deleteItem(KEY, 1);
    			p.setNextAnimation(new Animation(Animation));
    			p.getInventory().addItem(995, 15000000);
    			p.getPackets().sendGameMessage("You find some treasure in the chest.");
    		}
    	}
    	
    	public static int getLength() {
    		return CHEST_REWARDS.length;
    	}
    	
    	/**
    	 * Represents the toothHalf of the key.
    	 */
    	public static int toothHalf(){
    		return KEY_HALVES[0];
    	}
    	
    	/**
    	 * Represent the loop half of the key.
    	 */
    	public static int loopHalf(){
    		return KEY_HALVES[1];
    	}
    	
    }
    Reply With Quote  
     

  2. #2  
    Donator
    The Stoned's Avatar
    Join Date
    Jan 2013
    Posts
    647
    Thanks given
    62
    Thanks received
    82
    Rep Power
    62
    Code:
    	private static final Object[] CHEST_REWARDS= { };
    	public static final int[] KEY_HALVES = { 985, 987 };
    	public static final int KEY = 989;
    	public static final int Animation = 881;
    Gee thats a tough one. Inside the bracket, or whatever thats called, is blank. Enter the item ids you want it to give out at random.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    May 2013
    Posts
    160
    Thanks given
    8
    Thanks received
    28
    Rep Power
    17
    put items in an array or something and then use math.random etc to generate a random number
    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. Chest giving random items doesn't work
    By Stylo HD in forum Help
    Replies: 8
    Last Post: 01-12-2013, 02:46 AM
  2. Chest giving random items
    By Austin_ in forum Snippets
    Replies: 0
    Last Post: 07-06-2011, 03:09 AM
  3. Help with getting random items from a chest.
    By CommunityX in forum Help
    Replies: 9
    Last Post: 02-27-2011, 12:33 PM
  4. Help with, random item giving chest
    By inlogger in forum Help
    Replies: 2
    Last Post: 11-11-2008, 09:48 AM
  5. fully working crystal chest!
    By Volcom in forum Tutorials
    Replies: 32
    Last Post: 09-11-2007, 01:58 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
  •