Thread: Elven Crystal Chest

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

    Sgsrocks's Avatar
    Join Date
    Mar 2014
    Posts
    825
    Thanks given
    34
    Thanks received
    89
    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,358
    Thanks given
    725
    Thanks received
    1,376
    Discord
    Optimum#9547
    Rep Power
    5000
    u realise the amount will stay the same on server launch?
    [Only registered and activated users can see links. ]
    MY DISCORD IS Optimum#9547
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Owner of Ghreborn

    Sgsrocks's Avatar
    Join Date
    Mar 2014
    Posts
    825
    Thanks given
    34
    Thanks received
    89
    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,358
    Thanks given
    725
    Thanks received
    1,376
    Discord
    Optimum#9547
    Rep Power
    5000
    so ya, fix the randoms and make them actual random, ya lol
    [Only registered and activated users can see links. ]
    MY DISCORD IS Optimum#9547
    Reply With Quote  
     

  6. #5  
    Registered Member
    Tamatea's Avatar
    Join Date
    Aug 2010
    Posts
    1,137
    Thanks given
    351
    Thanks received
    260
    Discord
    tamatea#0001
    Rep Power
    418
    God code



    Reply With Quote  
     

  7. #6  
    Rune-Server Affiliate
    Patrity's Avatar
    Join Date
    Jul 2008
    Age
    27
    Posts
    814
    Thanks given
    88
    Thanks received
    161
    Discord
    Patrity#0001
    Rep Power
    334
    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. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. #7  
    Registered Member
    Join Date
    May 2019
    Posts
    60
    Thanks given
    1
    Thanks received
    7
    Rep Power
    22
    Quote Originally Posted by Patrity View Post
    Monitize everything lol..
    Code:
    GameItem reward = Boundary.isIn(c, Boundary.DONATOR_ZONE) && c.getRights().isDonator() ? randomChestRewards(2) : randomChestRewards(9);
    thats the goal.
    someone will find this useful :-)
    [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)


User Tag List

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
  •