Thread: Elven Crystal Chest

Results 1 to 6 of 6
  1. #1 Elven Crystal Chest 
    Owner of Ghreborn

    Sgsrocks's Avatar
    Join Date
    Mar 2014
    Posts
    820
    Thanks given
    34
    Thanks received
    86
    Rep Power
    84
    i started working on priff so here
    Code:
    package ghreborn.model.content;
    
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import ghreborn.Server;
    import ghreborn.definitions.ItemCacheDefinition;
    import ghreborn.model.items.GameItem;
    import ghreborn.model.players.Boundary;
    import ghreborn.model.players.Client;
    import ghreborn.util.Misc;
    
    public class ElvenCrystalChest {
    
    	private static final int KEY = 23951;
    	private static final int DRAGONSTONE = 1631;
    	private static final int ANIMATION = 881;
    
    	private static final Map<Rarity, List<GameItem>> items = new HashMap<>();
    
    	static {
    		items.put(Rarity.COMMON, Arrays.asList(
    				new GameItem(989, 1),
    				new GameItem(985, 1),
    				new GameItem(987, 1),
    				new GameItem(995, 10000+Misc.random(5000)),
    				new GameItem(5315, 1),
    				new GameItem(1620, 10+Misc.random(3)),
    				new GameItem(1618, 5+Misc.random(3)),
    				new GameItem(1079, 1),
    				new GameItem(1093, 1),
    				new GameItem(23866, 4+Misc.random(2)),
    				new GameItem(564, 50+Misc.random(50)),
    				new GameItem(562, 50+Misc.random(50)),
    				new GameItem(561, 50+Misc.random(50)),
    				new GameItem(563, 50+Misc.random(50)),
    				new GameItem(560, 50+Misc.random(50))));
    		
    		items.put(Rarity.UNCOMMON, Arrays.asList(
    				new GameItem(23661, 1+Misc.random(1)),
    				new GameItem(445, 380+Misc.random(117)),
    				new GameItem(452, 7+Misc.random(3)),
    				new GameItem(384, 50+Misc.random(50)),
    				new GameItem(23866, 9+Misc.random(1)),
    				new GameItem(995, 30000+Misc.random(20000)),
    				new GameItem(23866, 20+Misc.random(9))));
    		
    	       items.put(Rarity.RARE,
    	                Arrays.asList(
    	                        new GameItem(4087, 1),
    	                        new GameItem(4585, 1),
    	                        new GameItem(2366, 1),
    	                        new GameItem(6571, 1),
    	                        new GameItem(24034, 1),
    	                        new GameItem(24037, 1),
    	                        new GameItem(24040, 1),
    	                        new GameItem(24043, 1),
    	                        new GameItem(24046, 1)));//place holder
    	}
    
    	private static GameItem randomChestRewards(int chance) {
    		int random = Misc.random(chance);
    		List<GameItem> itemList = random < 105 ? items.get(Rarity.COMMON) : random >= 105 && random <= 190 ? items.get(Rarity.UNCOMMON) : items.get(Rarity.RARE);
    		return Misc.getRandomItem(itemList);
    	}
    
    
    	public static void searchChest(Client c) {
     if (c.getItems().playerHasItem(KEY)) {
    			c.getItems().deleteItem(KEY, 1);
    			c.startAnimation(ANIMATION);
    			c.getItems().addItem(DRAGONSTONE, 1);
    			GameItem reward = Boundary.isIn(c, Boundary.DONATOR_ZONE) && c.getRights().isDonator() ? randomChestRewards(2) : randomChestRewards(9);
    			if (!c.getItems().addItem(reward.getId(), reward.getAmount())) {
    				Server.itemHandler.createGroundItem(c, reward.getId(), c.getX(), c.getY(), c.heightLevel, reward.getAmount());
    			}
    			//Achievements.increase(c, AchievementType.LOOT_CRYSTAL_CHEST, 1);
    			c.sendMessage("@[email protected] stick your hand in the chest and pull an item out of the chest.");
     } else {
    			c.sendMessage("@[email protected] Elven Chest is locked, it won't budge!");
    		}
     }
    
    	enum Rarity {
    		UNCOMMON, COMMON, RARE
    	}
    
    }
    hope you guys enjoy this
    Last edited by Sgsrocks; 08-16-2019 at 10:16 PM. Reason: removed a uneeded import

    Discord: Sgsrocks#5004
    Reply With Quote  
     

  2. #2  
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,326
    Thanks given
    700
    Thanks received
    1,265
    Rep Power
    5000
    u realise the amount will stay the same on server launch?
    MY DISCORD IS Optimum#9547
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Owner of Ghreborn

    Sgsrocks's Avatar
    Join Date
    Mar 2014
    Posts
    820
    Thanks given
    34
    Thanks received
    86
    Rep Power
    84
    ya i know. just putting it out there i just finished it. so ya LOL

    Discord: Sgsrocks#5004
    Reply With Quote  
     

  5. #4  
    Registered Member
    Optimum's Avatar
    Join Date
    Apr 2012
    Posts
    3,326
    Thanks given
    700
    Thanks received
    1,265
    Rep Power
    5000
    so ya, fix the randoms and make them actual random, ya lol
    MY DISCORD IS Optimum#9547
    Reply With Quote  
     

  6. #5  
    Registered Member
    Tamatea's Avatar
    Join Date
    Aug 2010
    Posts
    1,110
    Thanks given
    348
    Thanks received
    256
    Rep Power
    362
    God code





    Reply With Quote  
     

  7. #6  
    Extreme Donator

    Patrity's Avatar
    Join Date
    Jul 2008
    Age
    26
    Posts
    759
    Thanks given
    51
    Thanks received
    123
    Rep Power
    126
    Monitize everything lol..
    Code:
    GameItem reward = Boundary.isIn(c, Boundary.DONATOR_ZONE) && c.getRights().isDonator() ? randomChestRewards(2) : randomChestRewards(9);
    Free map releases: [Only registered and activated users can see links. ]


    [Only registered and activated users can see links. ]
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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

Similar Threads

  1. [pi]Fully working Crystal Chest
    By deadsoul in forum Tutorials
    Replies: 2
    Last Post: 01-04-2011, 06:17 PM
  2. Replies: 4
    Last Post: 02-07-2010, 10:09 PM
  3. Adding rare Crystal chest
    By Jukk in forum Tutorials
    Replies: 18
    Last Post: 02-18-2008, 07:40 PM
  4. Crystal chest V2
    By Volcom in forum Tutorials
    Replies: 18
    Last Post: 12-11-2007, 12:54 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
  •