Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. public List<GameItem> access(Player player, double modifier, int repeats) {
  2. int rights = player.getRights().getPrimary().getValue() - 1;
  3. List<GameItem> items = new ArrayList<>();
  4. for (Table table : this) {
  5. TablePolicy policy = table.getPolicy();
  6. if (policy.equals(TablePolicy.CONSTANT)) {
  7. for (Drop drop : table) {
  8. int minimumAmount = drop.getMinimumAmount();
  9.  
  10. items.add(new GameItem(drop.getItemId(), minimumAmount + Misc.random(drop.getMaximumAmount() - minimumAmount)));
  11. }
  12. } else {
  13. for (int i = 0; i < repeats; i++) {
  14. double chance = (1.0 / (double) (table.getAccessibility() * modifier)) * 100D;
  15.  
  16. double roll = Misc.preciseRandom(Range.between(0.0, 100.0));
  17.  
  18. if (chance > 100.0) {
  19. chance = 100.0;
  20. }
  21. if (roll <= chance) {
  22. Drop drop = table.fetchRandom();
  23. int minimumAmount = drop.getMinimumAmount();
  24. GameItem item = new GameItem(drop.getItemId(),
  25. minimumAmount + Misc.random(drop.getMaximumAmount() - minimumAmount));
  26.  
  27. if (policy.equals(TablePolicy.VERY_RARE) || policy.equals(TablePolicy.RARE)) {
  28. player.getCollectionLog().handleDrop(drop.getNpcIds().get(0), item.getId(), item.getAmount());
  29. }
  30. items.add(item);
  31. if (chance <= 1.5) {
  32. if (policy.equals(TablePolicy.VERY_RARE) || policy.equals(TablePolicy.RARE)) {
  33. if (Item.getItemName(item.getId()).toLowerCase().contains("cowhide")
  34. || Item.getItemName(item.getId()).toLowerCase().contains("feather")
  35. || Item.getItemName(item.getId()).toLowerCase().contains("arrow")
  36. || Item.getItemName(item.getId()).toLowerCase().contains("sq shield")
  37. || Item.getItemName(item.getId()).toLowerCase().contains("rune warhammer")
  38. || Item.getItemName(item.getId()).toLowerCase().contains("rune battleaxe")
  39. || Item.getItemName(item.getId()).toLowerCase().contains("casket")
  40. || Item.getItemName(item.getId()).toLowerCase().contains("silver ore")
  41. || Item.getItemName(item.getId()).toLowerCase().contains("rune spear")
  42. || item.getId() >= 554 && item.getId() <= 566) {
  43.  
  44. } else {
  45. PlayerHandler.executeGlobalMessage(
  46. "@red@" + Misc.capitalize(player.playerName) + " received a drop: "
  47. + (item.getAmount() > 1 ? (item.getAmount() + "x ") : ItemAssistant.getItemName(item.getId()) + "@bla@."));
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. return items;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement