mystery box with common,uncommon,rare etc.
well this is my first tutorial, but basicly this adds a mysterybox system with common 60%, uncommon 30%, rare 7%, super rare 2.7%, and ultra rare loot 0.3% (this is changable, its easy to find in the code where).
its very simple, you just need to add this bit of code to InventoryOptionsHandler:
Code:
if (itemId == 6199) {
int[] Common = {*here goes the items from common loot with*}; //dont forget to put "," between item id's!
int[] Uncommon = {*here goes the items from uncommon loot*};
int[] Rare = {*here goes the items from rare loot*};
int[] SuperRare = {*here goes the items from super rare loot*};
int[] Legendary = {*here goes the items from ultra rare loot*};
player.getInventory().deleteItem(6199, 1);
int rarity = Utils.getRandom(1000);
if (rarity > 0 && rarity <= 600) {
int length = Common.length;
length--;
int reward = Utils.getRandom(length);
player.getInventory().addItem(Common[reward], 1);
player.getPackets().sendGameMessage("You've recieved a Common item from the Mystery Box!");
}
if (rarity > 600 && rarity <= 900) {
int length = Uncommon.length;
length--;
int reward = Utils.getRandom(length);
player.getInventory().addItem(Uncommon[reward], 1);
player.getPackets().sendGameMessage("You've recieved a uncommon item from the Mystery Box!");
}
if (rarity > 900 && rarity <= 970) {
int length = Rare.length;
length--;
int reward = Utils.getRandom(length);
player.getInventory().addItem(Rare[reward], 1);
player.getPackets().sendGameMessage("You've recieved a rare item from the Mystery Box!");
}
if (rarity > 970 && rarity <= 997) {
int length = SuperRare.length;
length--;
int reward = Utils.getRandom(length);
player.getInventory().addItem(SuperRare[reward], 1);
player.getPackets().sendGameMessage("You've recieved a super rare item from the Mystery Box!");
}
if (rarity > 997 && rarity <= 1000) {
int length = Legendary.length;
length--;
int reward = Utils.getRandom(length);
player.getInventory().addItem(Legendary[reward], 1);
player.getPackets().sendGameMessage("You've recieved a ultra rare item from the Mystery Box!");
}
return;
}
credits: 99% me, 1% bits and pieces of other codes.
hope this helps you in any way! :)
please leave a thanks if this helped you!