Thread: Rewards and Rarity

Results 1 to 2 of 2
  1. #1 Rewards and Rarity 
    Registered Member
    Join Date
    Jan 2018
    Posts
    6
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Hi guys I am using Exotic source just to play around and self-learn. I'm trying to edit the hourly rewards to my owntouch, but it doesn't seem to work well?

    Sometimes I open the box and get 4 items from the ULTRARARE array, other times I just get from another array, it isn't balanced?

    Also can you please help me understand how the RARITY works?

    Code:
    package ethos.model.content;
    
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.Objects;
    
    import ethos.event.CycleEvent;
    import ethos.event.CycleEventContainer;
    import ethos.event.CycleEventHandler;
    import ethos.model.items.GameItem;
    import ethos.model.items.ItemAssistant;
    import ethos.model.players.Player;
    import ethos.model.players.PlayerHandler;
    import ethos.util.Misc;
    
    /**
     * Revamped a simple means of receiving a random item based on chance.
     * 
     */
    public class HourlyRewardBox extends CycleEvent {
    
    	/**
    	 * The item id of the mystery box required to trigger the event
    	 */
    	public static final int MYSTERY_BOX = 11739;
    
    	/**
    	 * A map containing a List of {@link GameItem}'s that contain items relevant to their rarity.
    	 */
    	private static Map<Rarity, List<GameItem>> items = new HashMap<>();
    
    	/**
    	 * Stores an array of items into each map with the corresponding rarity to the list
    	 */
    	static {
    		items.put(Rarity.COMMON, 
    			Arrays.asList(
    				new GameItem(20199),
    				new GameItem(12325, 1))
    		);
    		
    	items.put(Rarity.UNCOMMON,
    			Arrays.asList(
    					new GameItem(892, 100),
    					new GameItem(452, 12),
    					new GameItem(2364, 7),
    					new GameItem(450, 28),
    					new GameItem(2362, 10))
    	);
    	
    	items.put(Rarity.RARE,
    			Arrays.asList(
    					new GameItem(11212, 80),
    					new GameItem(11230, 60),
    					new GameItem(892, 300),
    					new GameItem(452, 45),
    					new GameItem(2364, 25),
    					new GameItem(450, 70),
    					new GameItem(2362, 45),
    					new GameItem(2722),
    			        new GameItem(21027))
    	);
    	
    	items.put(Rarity.VERYRARE,
    			Arrays.asList(
    					new GameItem(20784),
    					new GameItem(21018),
    					new GameItem(21021),
    					new GameItem(21024),
    					new GameItem(21015),
    					new GameItem(21012),
    					new GameItem(21000),
    					new GameItem(21028),
    					new GameItem(21009),
    					new GameItem(20849, 50),
    					new GameItem(995, 5000000),
    					new GameItem(21034))
    	);
    		
    		
    		items.put(Rarity.ULTRARARE,
    				Arrays.asList(
    						new GameItem(20997, 1), 
    						new GameItem(21006, 1),
    						new GameItem(21003, 1)));
    	}
    
    	/**
    	 * The player object that will be triggering this event
    	 */
    	private Player player;
    
    	/**
    	 * Constructs a new myster box to handle item receiving for this player and this player alone
    	 * 
    	 * @param player the player
    	 */
    	public HourlyRewardBox(Player player) {
    		this.player = player;
    	}
    
    	/**
    	 * Opens a mystery box if possible, and ultimately triggers and event, if possible.
    	 * 
    	 * @param player the player triggering the evnet
    	 */
    	public void open() {
    		CycleEventHandler.getSingleton().stopEvents(this);
    		CycleEventHandler.getSingleton().addEvent(this, this, 2);
    	}
    
    	/**
    	 * Executes the event for receiving the mystery box
    	 */
    	@Override
    	public void execute(CycleEventContainer container) {
    		if (player.disconnected || Objects.isNull(player)) {
    			container.stop();
    			return;
    		}
    		List<GameItem> itemList = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    		List<GameItem> itemList2 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    		List<GameItem> itemList3 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    		List<GameItem> itemList4 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    		//List<GameItem> itemList = random < 55 ? items.get(Rarity.COMMON) : random >= 55 && random <= 80 ? items.get(Rarity.UNCOMMON) : items.get(Rarity.RARE);
    		GameItem item = Misc.getRandomItem(itemList);
    		GameItem item2 = Misc.getRandomItem(itemList2);
    		GameItem item3 = Misc.getRandomItem(itemList3);
    		GameItem item4 = Misc.getRandomItem(itemList4);
    		
    		if (Misc.random(300) == 2 && player.getItems().getItemCount(20851, true) == 0 && player.summonId != 20851) {
    			PlayerHandler.executeGlobalMessage("[@red@Announcement@bla@] " + player.playerName
    					+ " has just recieved the Olmlet pet!");
    
    		}
    
    		if (Misc.random(1) == 0) {
    			player.getItems().addItem(item.getId(), item.getAmount());
    			player.sendMessage("You receive <col=255>" + item.getAmount() + " x " + ItemAssistant.getItemName(item.getId()) + "</col>.");
    			player.getItems().addItem(item2.getId(), item2.getAmount());
    			player.sendMessage("You receive <col=255>" + item2.getAmount() + " x " + ItemAssistant.getItemName(item2.getId()) + "</col>.");
    			player.getItems().addItem(item3.getId(), item3.getAmount());
    			player.sendMessage("You receive <col=255>" + item3.getAmount() + " x " + ItemAssistant.getItemName(item3.getId()) + "</col>.");
    			player.getItems().addItem(item4.getId(), item4.getAmount());
    			player.sendMessage("You receive <col=255>" + item4.getAmount() + " x " + ItemAssistant.getItemName(item4.getId()) + "</col>.");
    				
    		}
    		container.stop();
    	}
    
    	/**
    	 * Represents the rarity of a certain list of items
    	 */
    	enum Rarity {
    		UNCOMMON, COMMON, RARE, VERYRARE, ULTRARARE
    	}
    
    }
    Last edited by Spooky; 12-04-2018 at 06:03 PM.
    Reply With Quote  
     

  2. #2  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Code:
    		List<GameItem> itemList = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    		List<GameItem> itemList2 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    		List<GameItem> itemList3 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    		List<GameItem> itemList4 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    Seems to me that the term "random" in this case is the same for all 4 items.
    Just debug the value by doing System.out.println("debug.... " + random); under each one of them:
    Code:
    		List<GameItem> itemList = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    System.out.println("debug for 1.... " + random);
    		List<GameItem> itemList2 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    System.out.println("debug for 2.... " + random);
    		List<GameItem> itemList3 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    System.out.println("debug for 3.... " + random);
    		List<GameItem> itemList4 = random < 80 ? items.get(Rarity.COMMON) : random < 230 ? items.get(Rarity.UNCOMMON): random < 287 ? items.get(Rarity.RARE) : random >= 293 && random <= 299 ? items.get(Rarity.VERYRARE) : items.get(Rarity.ULTRARARE);
    System.out.println("debug for 4.... " + random);
    This way you'll know if the value "random" have the same for all or can go above 300.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    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. delete
    By copycopy in forum Advertise
    Replies: 17
    Last Post: 02-01-2018, 01:01 AM
  2. Replies: 14
    Last Post: 08-12-2012, 04:25 PM
  3. Pi pk rewards and pk p amounts.
    By aki2k4 in forum Help
    Replies: 11
    Last Post: 07-17-2012, 04:30 AM
  4. Slayer rewards and pkp shops
    By egghead85 in forum Help
    Replies: 0
    Last Post: 01-25-2012, 10:36 PM
  5. Replies: 0
    Last Post: 04-10-2009, 03:57 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •