Guest User

Untitled

a guest
Nov 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.79 KB | None | 0 0
  1. package server.model.players;
  2.  
  3. import server.event.EventManager;
  4. import server.event.Event;
  5. import server.event.EventContainer;
  6.  
  7. /**
  8. * @author InsidiaX
  9. */
  10.  
  11. public class Potions {
  12.  
  13. private Client c;
  14.  
  15. public Potions(Client c) {
  16. this.c = c;
  17. }
  18.  
  19. public void handlePotion(int itemId, int slot) {
  20. if (c.duelRule[5]) {
  21. c.sendMessage("You may not drink potions in this duel.");
  22. return;
  23. }
  24. if (System.currentTimeMillis() - c.potDelay >= 750) {
  25. c.potDelay = System.currentTimeMillis();
  26. c.foodDelay = c.potDelay;
  27. c.getCombat().resetPlayerAttack();
  28. c.attackTimer++;
  29. c.sendMessage("You drink some of your "+ server.model.items.Item.getItemName(itemId) +".");
  30. String item = server.model.items.Item.getItemName(itemId);
  31. if(item.endsWith("(4)"))
  32. {
  33. c.sendMessage("You have 3 doses of potion left.");
  34. } else if(item.endsWith("(3)"))
  35. {
  36. c.sendMessage("You have 2 doses of potion left.");
  37. } else if(item.endsWith("(2)"))
  38. {
  39. c.sendMessage("You have 1 dose of potion left.");
  40. } else if(item.endsWith("(1)"))
  41. {
  42. c.sendMessage("You have finished your potion.");
  43. }
  44. switch (itemId) {
  45. case 6685: //brews
  46. doTheBrew(itemId, 6687, slot);
  47. break;
  48. case 15272: //brews
  49. Rocktail(itemId, 15272, slot);
  50. break;
  51. //Magic pots
  52. case 3040:
  53. drinkMagicPotion(itemId,3042,slot,6,false);
  54. break;
  55. case 3042:
  56. drinkMagicPotion(itemId,3044,slot,6,false);
  57. break;
  58. case 3044:
  59. drinkMagicPotion(itemId,3046,slot,6,false);
  60. break;
  61. case 3046:
  62. drinkMagicPotion(itemId,229,slot,6,false);
  63. break;
  64. case 6687:
  65. doTheBrew(itemId, 6689, slot);
  66. break;
  67. case 6689:
  68. doTheBrew(itemId, 6691, slot);
  69. break;
  70. case 6691:
  71. doTheBrew(itemId, 229, slot);
  72. break;
  73. case 2436:
  74. drinkStatPotion(itemId,145,slot,0,true); //sup attack
  75. break;
  76. case 145:
  77. drinkStatPotion(itemId,147,slot,0,true);
  78. break;
  79. case 147:
  80. drinkStatPotion(itemId,149,slot,0,true);
  81. break;
  82. case 149:
  83. drinkStatPotion(itemId,229,slot,0,true);
  84. break;
  85. case 2440:
  86. drinkStatPotion(itemId,157,slot,2,true); //sup str
  87. break;
  88. case 157:
  89. drinkStatPotion(itemId,159,slot,2,true);
  90. break;
  91. case 159:
  92. drinkStatPotion(itemId,161,slot,2,true);
  93. break;
  94. case 161:
  95. drinkStatPotion(itemId,229,slot,2,true);
  96. break;
  97. case 2444:
  98. drinkStatPotion(itemId,169,slot,4,false); //range pot
  99. break;
  100. case 169:
  101. drinkStatPotion(itemId,171,slot,4,false);
  102. break;
  103. case 171:
  104. drinkStatPotion(itemId,173,slot,4,false);
  105. break;
  106. case 173:
  107. drinkStatPotion(itemId,229,slot,4,false);
  108. break;
  109. case 2432:
  110. drinkStatPotion(itemId,133,slot,1,false); //def pot
  111. break;
  112. case 133:
  113. drinkStatPotion(itemId,135,slot,1,false);
  114. break;
  115. case 135:
  116. drinkStatPotion(itemId,137,slot,1,false);
  117. break;
  118. case 137:
  119. drinkStatPotion(itemId,229,slot,1,false);
  120. break;
  121. case 113:
  122. drinkStatPotion(itemId,115,slot,2,false); //str pot
  123. break;
  124. case 115:
  125. drinkStatPotion(itemId,117,slot,2,false);
  126. break;
  127. case 117:
  128. drinkStatPotion(itemId,119,slot,2,false);
  129. break;
  130. case 119:
  131. drinkStatPotion(itemId,229,slot,2,false);
  132. break;
  133. case 2428:
  134. drinkStatPotion(itemId,121,slot,0,false); //attack pot
  135. break;
  136. case 121:
  137. drinkStatPotion(itemId,123,slot,0,false);
  138. break;
  139. case 123:
  140. drinkStatPotion(itemId,125,slot,0,false);
  141. break;
  142. case 125:
  143. drinkStatPotion(itemId,229,slot,0,false);
  144. break;
  145. case 2442:
  146. drinkStatPotion(itemId,163,slot,1,true); //super def pot
  147. break;
  148. case 163:
  149. drinkStatPotion(itemId,165,slot,1,true);
  150. break;
  151. case 165:
  152. drinkStatPotion(itemId,167,slot,1,true);
  153. break;
  154. case 167:
  155. drinkStatPotion(itemId,229,slot,1,true);
  156. break;
  157. case 3024:
  158. drinkPrayerPot(itemId,3026,slot,true); //sup restore
  159. break;
  160. case 3026:
  161. drinkPrayerPot(itemId,3028,slot,true);
  162. break;
  163. case 3028:
  164. drinkPrayerPot(itemId,3030,slot,true);
  165. break;
  166. case 3030:
  167. drinkPrayerPot(itemId,229,slot,true);
  168. break;
  169. case 10925:
  170. drinkPrayerPot(itemId,10927,slot,true); //sanfew serums
  171. curePoison(300000);
  172. break;
  173. case 10927:
  174. drinkPrayerPot(itemId,10929,slot,true);
  175. curePoison(300000);
  176. break;
  177. case 10929:
  178. drinkPrayerPot(itemId,10931,slot,true);
  179. curePoison(300000);
  180. break;
  181. case 10931:
  182. drinkPrayerPot(itemId,229,slot,true);
  183. curePoison(300000);
  184. break;
  185. case 2434:
  186. drinkPrayerPot(itemId,139,slot,false); //pray pot
  187. break;
  188. case 15300: //Recover Special
  189. recoverSpecial(itemId, 15301, slot);
  190. break;
  191. case 15301: //Recover Special
  192. recoverSpecial(itemId, 15302, slot);
  193. break;
  194. case 15302: //Recover Special
  195. recoverSpecial(itemId, 15303, slot);
  196. break;
  197. case 15303: //Recover Special
  198. recoverSpecial(itemId, 229, slot);
  199. break;
  200. case 15328: //Super Prayer
  201. drinkExtremePrayer(itemId, 15329, slot, true);
  202. break;
  203. case 15329: //Super Prayer
  204. drinkExtremePrayer(itemId, 15330, slot, true);
  205. break;
  206. case 15330: //Super Prayer
  207. drinkExtremePrayer(itemId, 15331, slot, true);
  208. break;
  209. case 15331: //Super Prayer
  210. drinkExtremePrayer(itemId, 229, slot, true);
  211. break;
  212. case 139:
  213. drinkPrayerPot(itemId,141,slot,false);
  214. break;
  215. case 141:
  216. drinkPrayerPot(itemId,143,slot,false);
  217. break;
  218. case 143:
  219. drinkPrayerPot(itemId,229,slot,false);
  220. break;
  221. case 2446:
  222. drinkAntiPoison(itemId,175,slot,30000); //anti poisons
  223. break;
  224. case 175:
  225. drinkAntiPoison(itemId,177,slot,30000);
  226. break;
  227. case 177:
  228. drinkAntiPoison(itemId,179,slot,30000);
  229. break;
  230. case 179:
  231. drinkAntiPoison(itemId,229,slot,30000);
  232. break;
  233. case 2448:
  234. drinkAntiPoison(itemId,181,slot,300000); //anti poisons
  235. break;
  236. case 181:
  237. drinkAntiPoison(itemId,183,slot,300000);
  238. break;
  239. case 183:
  240. drinkAntiPoison(itemId,185,slot,300000);
  241. break;
  242. case 185:
  243. drinkAntiPoison(itemId,229,slot,300000);
  244. break;
  245. }
  246. }
  247. }
  248.  
  249. public void drinkAntiPoison(int itemId, int replaceItem, int slot, long delay) {
  250. c.startAnimation(829);
  251. c.playerItems[slot] = replaceItem + 1;
  252. c.getItems().resetItems(3214);
  253. curePoison(delay);
  254. }
  255.  
  256. public void recoverSpecial(int itemId, int replaceItem, int slot) {
  257. if (c.inWild()) {
  258. c.sendMessage("You are unable to restore special in the wilderness.");
  259. return;
  260. } else if (c.specAmount >= 7.5) {
  261. c.sendMessage("You are unable to drink the potion as your special is above 75%.");
  262. } else if (c.specRestore > 0) {
  263. c.specAmount += 2.5;
  264. c.startAnimation(829);
  265. c.sendMessage("As you drink drink the potion, you feel your special attack slightly regenerate.");
  266. c.playerItems[slot] = replaceItem + 1;
  267. c.getItems().resetItems(3214);
  268. c.getItems().updateSpecialBar();
  269. c.specRestore = 180;
  270. } else {
  271. c.sendMessage("You can only restore your special once every 3 minutes.");
  272. }
  273. }
  274.  
  275. public void drinkExtremePotion(int itemId, int replaceItem, int slot, int stat, boolean sup) {
  276. c.startAnimation(829);
  277. c.playerItems[slot] = replaceItem + 1;
  278. c.getItems().resetItems(3214);
  279. enchanceStat2(stat,sup);
  280. }
  281.  
  282. public void drinkExtremePrayer(int itemId, int replaceItem, int slot, boolean rest) {
  283. c.startAnimation(829);
  284. c.playerItems[slot] = replaceItem + 1;
  285. c.getItems().resetItems(3214);
  286. c.playerLevel[5] += (c.getLevelForXP(c.playerXP[5]) * .38);
  287. if (rest)
  288. c.playerLevel[5] += 1;
  289. if (c.playerLevel[5] > c.getLevelForXP(c.playerXP[5]))
  290. c.playerLevel[5] = c.getLevelForXP(c.playerXP[5]);
  291. c.getPA().refreshSkill(5);
  292. if (rest)
  293. restoreStats();
  294. }
  295.  
  296. public void drinkMagicPotion(int itemId, int replaceItem, int slot, int stat, boolean sup) {
  297. int increaseBy = 0;
  298. c.startAnimation(829);
  299. c.playerItems[slot] = replaceItem + 1;
  300. c.getItems().resetItems(3214);
  301. increaseBy = (int)(c.playerLevel[6] += (c.getLevelForXP(c.playerXP[6]) *.06));
  302. c.playerLevel[6] = c.getPA().getLevelForXP(c.playerXP[6]);
  303. c.getPA().refreshSkill(6);
  304. }
  305.  
  306. public void enchanceStat2(int skillID, boolean sup) {
  307. c.playerLevel[skillID] += getExtremeStat(skillID, sup);
  308. c.getPA().refreshSkill(skillID);
  309. }
  310.  
  311. public int getExtremeStat(int skill, boolean sup) {
  312. int increaseBy = 0;
  313. if (sup)
  314. increaseBy = (int)(c.getLevelForXP(c.playerXP[skill])*.25);
  315. else
  316. increaseBy = (int)(c.getLevelForXP(c.playerXP[skill])*.25) + 1;
  317. if (c.playerLevel[skill] + increaseBy > c.getLevelForXP(c.playerXP[skill]) + increaseBy + 1) {
  318. return c.getLevelForXP(c.playerXP[skill]) + increaseBy - c.playerLevel[skill];
  319. }
  320. return increaseBy;
  321. }
  322.  
  323. public void curePoison(long delay) {
  324. c.poisonDamage = 0;
  325. c.poisonImmune = delay;
  326. c.lastPoisonSip = System.currentTimeMillis();
  327. }
  328.  
  329. public void drinkStatPotion(int itemId, int replaceItem, int slot, int stat, boolean sup) {
  330. c.startAnimation(829);
  331. c.playerItems[slot] = replaceItem + 1;
  332. c.getItems().resetItems(3214);
  333. enchanceStat(stat,sup);
  334. }
  335.  
  336. public void drinkPrayerPot(int itemId, int replaceItem, int slot, boolean rest) {
  337. c.startAnimation(829);
  338. c.playerItems[slot] = replaceItem + 1;
  339. c.getItems().resetItems(3214);
  340. c.playerLevel[5] += (c.getLevelForXP(c.playerXP[5]) * .33);
  341. if (rest)
  342. c.playerLevel[5] += 1;
  343. if (c.playerLevel[5] > c.getLevelForXP(c.playerXP[5]))
  344. c.playerLevel[5] = c.getLevelForXP(c.playerXP[5]);
  345. c.getPA().refreshSkill(5);
  346. if (rest)
  347. restoreStats();
  348. }
  349.  
  350.  
  351. public void restoreStats() {
  352. for (int j = 0; j <= 6; j++) {
  353. if (j == 5 || j == 3)
  354. continue;
  355. if (c.playerLevel[j] < c.getLevelForXP(c.playerXP[j])) {
  356. c.playerLevel[j] += (c.getLevelForXP(c.playerXP[j]) * .33);
  357. if (c.playerLevel[j] > c.getLevelForXP(c.playerXP[j])) {
  358. c.playerLevel[j] = c.getLevelForXP(c.playerXP[j]);
  359. }
  360. c.getPA().refreshSkill(j);
  361. c.getPA().setSkillLevel(j, c.playerLevel[j], c.playerXP[j]);
  362. }
  363. }
  364. }
  365.  
  366. public void Rocktail(int itemId, int replaceItem, int slot) {
  367. c.startAnimation(829);
  368. if (c.duelRule[6]) {
  369. c.sendMessage("You may not eat in this duel.");
  370. return;
  371. }
  372. if (System.currentTimeMillis() - c.foodDelay >= 1500 && c.playerLevel[3] > 0) {
  373. c.startAnimation(829);
  374. c.getCombat().resetPlayerAttack();
  375. c.attackTimer += 2;
  376. if (c.playerLevel[3] < c.getLevelForXP(c.playerXP[3])) {
  377. c.playerLevel[3] += 24;
  378. c.playerLevel[3] += getBrewStat(3, .15);
  379. }
  380. c.foodDelay = System.currentTimeMillis();
  381. c.getPA().refreshSkill(3);
  382. c.sendMessage("You eat the Rocktail.");
  383. }
  384. if (c.playerLevel[3] > (c.getLevelForXP(c.playerXP[3]))) {
  385. c.playerLevel[3] = (int)(c.getLevelForXP(c.playerXP[3])*1.09);
  386. }
  387. c.getPA().refreshSkill(3);
  388. }
  389.  
  390. public void doTheBrew(int itemId, int replaceItem, int slot) {
  391. if (c.duelRule[6]) {
  392. c.sendMessage("You may not eat in this duel.");
  393. return;
  394. }
  395. c.startAnimation(829);
  396. c.playerItems[slot] = replaceItem + 1;
  397. c.getItems().resetItems(3214);
  398. int[] toDecrease = {0,2,4,6};
  399.  
  400. int[] toIncrease = {1,3};
  401. for (int tD : toDecrease) {
  402. c.playerLevel[tD] -= getBrewStat(tD, .10);
  403. if (c.playerLevel[tD] < 0)
  404. c.playerLevel[tD] = 1;
  405. c.getPA().refreshSkill(tD);
  406. c.getPA().setSkillLevel(tD, c.playerLevel[tD], c.playerXP[tD]);
  407. }
  408. c.playerLevel[1] += getBrewStat(1, .20);
  409. if (c.playerLevel[1] > (c.getLevelForXP(c.playerXP[1])*1.2 + 1)) {
  410. c.playerLevel[1] = (int)(c.getLevelForXP(c.playerXP[1])*1.2);
  411. }
  412. c.getPA().refreshSkill(1);
  413.  
  414. c.playerLevel[3] += getBrewStat(3, .15);
  415. if (c.playerLevel[3] > (c.getLevelForXP(c.playerXP[3])*1.17 + 1)) {
  416. c.playerLevel[3] = (int)(c.getLevelForXP(c.playerXP[3])*1.17);
  417. }
  418. c.getPA().refreshSkill(3);
  419. }
  420.  
  421. public void enchanceStat(int skillID, boolean sup) {
  422. c.playerLevel[skillID] += getBoostedStat(skillID, sup);
  423. c.getPA().refreshSkill(skillID);
  424. }
  425.  
  426. public int getBrewStat(int skill, double amount) {
  427. return (int)(c.getLevelForXP(c.playerXP[skill]) * amount);
  428. }
  429.  
  430. public int getBoostedStat(int skill, boolean sup) {
  431. int increaseBy = 0;
  432. if (sup)
  433. increaseBy = (int)(c.getLevelForXP(c.playerXP[skill])*.20);
  434. else
  435. increaseBy = (int)(c.getLevelForXP(c.playerXP[skill])*.13) + 1;
  436. if (c.playerLevel[skill] + increaseBy > c.getLevelForXP(c.playerXP[skill]) + increaseBy + 1) {
  437. return c.getLevelForXP(c.playerXP[skill]) + increaseBy - c.playerLevel[skill];
  438. }
  439. return increaseBy;
  440. }
  441.  
  442. public boolean isPotion(int itemId) {
  443. String name = c.getItems().getItemName(itemId);
  444. return name.contains("(4)") || name.contains("(3)") || name.contains("(2)") || name.contains("(1)");
  445. }
  446. }
Add Comment
Please, Sign In to add comment