Guest User

Fishing.java

a guest
Jun 10th, 2012
11
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package server.model.players.skills;
  2.  
  3. import server.Config;
  4. import server.util.Misc;
  5. import server.model.players.Client;
  6. /**
  7. * Fishing.java
  8. *
  9. * @author Sanity
  10. *
  11. **/
  12.  
  13. public class Fishing {
  14.  
  15. private Client c;
  16. private int fishType;
  17. private int exp;
  18. private int req;
  19. private int equipmentType;
  20. private final int SALMON_EXP = 70;
  21. private final int SWORD_EXP = 100;
  22. private final int SALMON_ID = 331;
  23. private final int SWORD_ID = 371;
  24. public boolean fishing = false;
  25.  
  26. private final int[] REQS = {1,20,40,35,62,76,81};
  27. private final int[] FISH_TYPES = {317,335,359,359,7944,383,389};
  28. private final int[] EXP = {10,50,80,90,120,110,46};
  29. private final int[] EMOTE = {622,619,618,621};
  30.  
  31. public Fishing(Client c) {
  32. this.c = c;
  33. }
  34.  
  35. public void setupFishing(int fishType) {
  36. if (c.getItems().playerHasItem(getEquipment(fishType))) {
  37. if (c.playerLevel[c.playerFishing] >= req) {
  38. int slot = getSlot(fishType);
  39. if (slot > -1) {
  40. this.req = REQS[slot];
  41. this.fishType = FISH_TYPES[slot];
  42. this.equipmentType = getEquipment(fishType);
  43. this.exp = EXP[slot];
  44. c.fishing = true;
  45. c.fishTimer = 3 + Misc.random(2);
  46. }
  47. } else {
  48. c.sendMessage("You need a fishing level of " + req + " to fish here.");
  49. resetFishing();
  50. }
  51. } else {
  52. c.sendMessage("You do not have the correct equipment to use this fishing spot.");
  53. resetFishing();
  54. }
  55. }
  56.  
  57.  
  58. public void catchFish() {
  59. if (c.getItems().playerHasItem(getEquipment(fishType))) {
  60. if (c.playerLevel[c.playerFishing] >= req) {
  61. c.startAnimation(getEmote(fishType));
  62. if (c.getItems().freeSlots() > 0) {
  63. if (canFishOther(fishType)) {
  64. c.getItems().addItem(otherFishId(fishType),1);
  65. c.getPA().addSkillXP(otherFishXP(fishType),c.playerFishing);
  66. } else {
  67. c.getItems().addItem(fishType,1);
  68. c.getPA().addSkillXP(exp * Config.FISHING_EXPERIENCE,c.playerFishing);
  69. }
  70. c.sendMessage("You catch a fish.");
  71. c.fishTimer = 2 + Misc.random(2);
  72. }
  73. } else {
  74. c.sendMessage("You need a fishing level of " + req + " to fish here.");
  75. resetFishing();
  76. }
  77. } else {
  78. c.sendMessage("You do not have the correct equipment to use this fishing spot.");
  79. resetFishing();
  80. }
  81. }
  82.  
  83. private int getSlot(int fishType) {
  84. for (int j = 0; j < REQS.length; j++)
  85. if (FISH_TYPES[j] == fishType)
  86. return j;
  87. return -1;
  88. }
  89.  
  90. private int getEmote(int fish) {
  91. if (fish == 335) //rod
  92. return 622;
  93. if (fish == 337) //pot
  94. return 619;
  95. if (fish == 383) //harpoon
  96. return 618;
  97. if (fish == 303) //net
  98. return 621;
  99. return 0;
  100. }
  101.  
  102. private int getEquipment(int fish) {
  103. if (fish == 317) //shrimp
  104. return 303;
  105. if (fish == 335) //trout + salmon
  106. return 309;
  107. if (fish == 337) //lobs
  108. return 301;
  109. if (fish == 361)//tuna
  110. return 311;
  111. if (fish == 7944)//monks
  112. return 303;
  113. if (fish == 383)//sharks
  114. return 311;
  115. if (fish == 389)//mantas
  116. return 303;
  117. return -1;
  118. }
  119.  
  120. private boolean canFishOther(int fishType) {
  121. if (fishType == 335 && c.playerLevel[c.playerFishing] >= 30)
  122. return true;
  123. if (fishType == 361 && c.playerLevel[c.playerFishing] >= 50)
  124. return true;
  125. return false;
  126. }
  127.  
  128. private int otherFishId(int fishType) {
  129. if (fishType == 335)
  130. return SALMON_ID;
  131. else if (fishType == 361)
  132. return SWORD_ID;
  133. return -1;
  134. }
  135.  
  136. private int otherFishXP(int fishType) {
  137. if (fishType == 335)
  138. return SALMON_EXP;
  139. else if (fishType == 361)
  140. return SWORD_EXP;
  141. return 0;
  142. }
  143.  
  144. public void resetFishing() {
  145. this.exp = 0;
  146. this.fishType = -1;
  147. this.equipmentType = -1;
  148. this.req = 0;
  149. c.fishTimer = -1;
  150. c.fishing = false;
  151. }
  152. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×