Guest User

Untitled

a guest
Oct 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. package server.model.players.skills;
  2.  
  3. import server.Config;
  4. import server.model.players.Client;
  5.  
  6. /**
  7. * RuneCrafting.java
  8. *
  9. * @author Sanity
  10. *
  11. **/
  12.  
  13. public class Runecrafting {
  14.  
  15. private static Client c;
  16.  
  17. public Runecrafting(Client c) {
  18. this.c = c;
  19. }
  20.  
  21. /**
  22. * Rune essence ID constant.
  23. */
  24. private static final int RUNE_ESS = 1436;
  25.  
  26. /**
  27. * Pure essence ID constant.
  28. */
  29. private static final int PURE_ESS = 7936;
  30.  
  31. /**
  32. * An array containing the rune item numbers.
  33. */
  34. public static int[] runes = { 556, 558, 555, 557, 554, 559, 564, 562, 561, 563,
  35. 560, 565 };
  36.  
  37. /**
  38. * An array containing the object IDs of the runecrafting altars.
  39. */
  40. public static int[] altarID = { 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2487,
  41. 2486, 2485, 2488, 2489 };
  42.  
  43. /**
  44. * 2D Array containing the levels required to craft the specific rune.
  45. */
  46. public static int[][] craftLevelReq = { { 556, 1 }, { 558, 2 }, { 555, 5 },
  47. { 557, 9 }, { 554, 14 }, { 559, 20 }, { 564, 27 }, { 562, 35 },
  48. { 561, 44 }, { 563, 54 }, { 560, 65 }, { 565, 77 } };
  49.  
  50. /**
  51. * 2D Array containing the levels that you can craft multiple runes.
  52. */
  53. public static int[][] multipleRunes = { { 11, 22, 33, 44, 55, 66, 77, 88, 99 },
  54. { 14, 28, 42, 56, 70, 84, 98 }, { 19, 38, 57, 76, 95 },
  55. { 26, 52, 78 }, { 35, 70 }, { 46, 92 }, { 59 }, { 74 }, { 91 },
  56. { 100 }, { 100 }, { 100 } };
  57.  
  58. public static int[] runecraftExp = { 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 11, 11 };
  59.  
  60. /**
  61. * Checks through all 28 item inventory slots for the specified item.
  62. */
  63. private static boolean itemInInv(int itemID, int slot, boolean checkWholeInv) {
  64. if (checkWholeInv) {
  65. for (int i = 0; i < 28; i++) {
  66. if (c.playerItems[i] == itemID + 1) {
  67. return true;
  68. }
  69. }
  70. } else {
  71. if (c.playerItems[slot] == itemID + 1) {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77.  
  78. /**
  79. * Replaces essence in the inventory with the specified rune.
  80. */
  81. private static void replaceEssence(Client c, int essType, int runeID, int multiplier,
  82. int index) {
  83. System.out.println("c.playerName" + " multipler: " + multiplier);
  84. int exp = 0;
  85. for (int i = 0; i < 28; i++) {
  86. if (itemInInv(essType, i, false)) {
  87. c.getItems().deleteItem(essType, i, 1);
  88. c.getItems().addItem(runeID, 1 * multiplier);
  89. exp += runecraftExp[index];
  90. }
  91. }
  92. c.getPA().addSkillXP(exp * Config.RUNECRAFTING_EXPERIENCE,
  93. c.playerRunecrafting);
  94. }
  95.  
  96. /**
  97. * Crafts the specific rune.
  98. */
  99. public static void craftRunes(Client c, int altarID) {
  100. int runeID = 0;
  101.  
  102. for (int i = 0; i < this.altarID.length; i++) {
  103. if (altarID == this.altarID[i]) {
  104. runeID = runes[i];
  105. }
  106. }
  107. for (int i = 0; i < craftLevelReq.length; i++) {
  108. if (runeID == runes[i]) {
  109. if (c.playerLevel[20] >= craftLevelReq[i][1]) {
  110. if (c.getItems().playerHasItem(RUNE_ESS)
  111. || c.getItems().playerHasItem(PURE_ESS)) {
  112. int multiplier = 1;
  113. for (int j = 0; j < multipleRunes[i].length; j++) {
  114. if (c.playerLevel[20] >= multipleRunes[i][j]) {
  115. multiplier += 1;
  116. }
  117. }
  118. replaceEssence(c, RUNE_ESS, runeID, multiplier, i);
  119. c.startAnimation(791);
  120. // c.frame174(481, 0, 0); for sound
  121. c.gfx100(186);
  122. return;
  123. }
  124. c.sendMessage("You need to have essence to craft runes!");
  125. return;
  126. }
  127. c.sendMessage("You need a Runecrafting level of "
  128. + craftLevelReq[i][1] + " to craft this rune.");
  129. }
  130. }
  131. }
  132.  
  133. }
Add Comment
Please, Sign In to add comment