Advertisement
n10sit

Untitled

Mar 27th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 KB | None | 0 0
  1. package server.model.players;
  2.  
  3. import server.Server;
  4. import server.model.npcs.*;
  5. import server.model.players.Client;
  6. import server.util.Misc;
  7.  
  8.  
  9. /**
  10. *
  11. * @author Tokashi
  12. *
  13. */
  14.  
  15.  
  16. public class Pets {
  17.  
  18. private Client c;
  19.  
  20. public Pets(Client client) {
  21. this.c = client;
  22. }
  23.  
  24. public void pickUp(int Type) {
  25. /*if (c.inWild){
  26. c.sendMessage("How did you get a pet in the wilderness?");
  27. }*/
  28. for (int i = 0; i < NPCHandler.maxNPCs; i++) {
  29. if (NPCHandler.npcs[i] == null)
  30. continue;
  31. }
  32. for (int i = 0; i < NPCHandler.maxNPCs; i++) {
  33. if (NPCHandler.npcs[i] != null) {
  34. if (NPCHandler.npcs[i].npcType == Type) {
  35. if (NPCHandler.npcs[i].spawnedBy == c.playerId && NPCHandler.npcs[i].spawnedBy > 0) {
  36. NPCHandler.npcs[i].absX = 0;
  37. NPCHandler.npcs[i].absY = 0;
  38. NPCHandler.npcs[i] = null;
  39. break;
  40. }
  41. }
  42. }
  43. }
  44. }
  45.  
  46. public int[][] Pets = {
  47. {766, 1560}, //Pet Kitten
  48. {765, 1559}, //Pet Kitten
  49. {764, 1558}, //Pet Kitten
  50. {763, 1557}, //Pet Kitten
  51. {762, 1556}, //Pet Kitten
  52. {761, 1555}, //Pet Kitten
  53. {768, 1561}, //Pet Cat
  54. {769, 1562}, //Pet Cat
  55. {770, 1563}, //Pet Cat
  56. {771, 1564}, //Pet Cat
  57. {772, 1565}, //Pet Cat
  58. {773, 1566}, //Pet Cat
  59. {774, 1567}, //Pet Cat Overgrown
  60. {775, 1568}, //Pet Cat overgrown
  61. {776, 1569}, //Pet Cat overgrown
  62. {777, 1570}, //Pet Cat overgrown
  63. {778, 1571}, //Pet Cat overgrown
  64. {779, 1572}, //Pet Cat overgrown
  65. {3000, 4149}, //Abyssal demon
  66. {3001, 4133}, //Crawling hand
  67. {3002, 4134}, //Cave crawler
  68. {3003, 4135}, //Banshee
  69. {3004, 4136}, //Rockslug
  70. {3005, 4137}, //Cockatrice
  71. {3006, 4138}, //Pyrefiend
  72. {3007, 4139}, //Basilisk
  73. {3008, 4141}, //Bloodveld
  74. {3009, 4142}, //Jelly
  75. {3010, 4143}, //Turoth
  76. {3011, 4144}, //Aberrant specter
  77. {3012, 4145}, //Dust devil
  78. {3013, 4146}, //Kurask
  79. {3014, 4147}, //Gargoyle
  80. {3015, 4148}, //Nechryael
  81. };
  82.  
  83. public int[][] petStats = { //id, health, attack, defense, speed
  84. {761, 10, 1, 1, 4}, //kittens //noob
  85. {762, 10, 1, 1, 4},
  86. {763, 10, 1, 1, 4},
  87. {764, 10, 1, 1, 4},
  88. {765, 10, 1, 1, 4},
  89. {766, 10, 1, 1, 4}, //end kittens //end noob
  90. {768, 25, 5, 3, 3}, //cats
  91. {769, 25, 5, 3, 3},
  92. {770, 25, 5, 3, 3},
  93. {771, 25, 5, 3, 3},
  94. {772, 25, 5, 3, 3},
  95. {773, 25, 5, 3, 3}, //end cats
  96. {774, 40, 3, 7, 1}, //fat cats
  97. {775, 40, 3, 7, 1},
  98. {776, 40, 3, 7, 1},
  99. {777, 40, 3, 7, 1},
  100. {778, 40, 3, 7, 1},
  101. {779, 40, 3, 7, 1}, //end fat cats
  102. {3001, 15, 2, 2, 2}, //crawling hand //novice
  103. {3002, 20, 3, 3, 2}, //cave crawler
  104. {3003, 15, 6, 2, 2}, //banshee
  105. {3004, 30, 3, 5, 2}, //rockslug
  106. {3005, 25, 6, 3, 3}, //cockatrice
  107. {3006, 20, 8, 2, 4}, //pyrefiend //end novice
  108. {3007, 55, 6, 5, 2}, //basilisk //veteran
  109. {3008, 60, 5, 6, 2}, //bloodveld
  110. {3009, 80, 3, 9, 1}, //jelly
  111. {3010, 30, 12, 3, 4}, //turoth //end veteran
  112. {3011, 100, 7, 12, 3}, //aberrant specter //renowned
  113. {3012, 60, 14, 5, 5}, //dust devil
  114. {3013, 80, 10, 10, 3}, //kurask
  115. {3014, 70, 12, 8, 4}, //gargoyle
  116. {3015, 40, 15, 9, 3}, //nechryael
  117. {3000, 66, 16, 6, 6}, //abyssal demon //end renowned
  118. };
  119.  
  120. int[] array = {1,2,3,4};
  121. int[][] array2 = {{1, 1}, {2, 2}};
  122.  
  123. public void fightPets(int oppPet, int myPet, Client opp, Client me) {
  124. int myHP = 0, myAtt = 0, myDef = 0, mySpe = 0;
  125. int oppHP = 0, oppAtt = 0, oppDef = 0, oppSpe = 0;
  126. for (int mP = 0; mP < petStats.length; mP++) {
  127. if (petStats[mP][0] == myPet) {
  128. myHP = petStats[mP][1];
  129. myAtt = petStats[mP][2];
  130. myDef = petStats[mP][3];
  131. mySpe = petStats[mP][4];
  132. }
  133. }
  134. for (int oP = 0; oP < petStats.length; oP++) {
  135. if (petStats[oP][0] == oppPet) {
  136. oppHP = petStats[oP][1];
  137. oppAtt = petStats[oP][2];
  138. oppDef = petStats[oP][3];
  139. oppSpe = petStats[oP][4];
  140. }
  141. }
  142. while (myHP > 0 && oppHP > 0) {
  143. if (mySpe > oppSpe) {
  144. oppHP -= (myAtt*Misc.random(2)) - oppDef + 1;
  145. if (oppHP < 0)
  146. oppHP = 0;
  147. opp.sendMessage("Your monsters health: "+oppHP);
  148. if (oppHP <= 0) {
  149. me.PVPMonsterFights++;
  150. me.sendMessage("You win! Your monster has won "+me.PVPMonsterFights+" fights!");
  151. if (me.PVPMonsterFights % 5 == 0) {
  152. me.monsterLevel++;
  153. me.sendMessage("Congratulations! Your monster is now level "+me.monsterLevel);
  154. }
  155. opp.sendMessage("You lose! Better luck next time!");
  156. return;
  157. }
  158. } else if (oppSpe > mySpe) {
  159. myHP -= (oppAtt*Misc.random(2)) - myDef + 1;
  160. if (myHP < 0)
  161. myHP = 0;
  162. me.sendMessage("Your monsters health: "+myHP);
  163. if (myHP <= 0) {
  164. opp.PVPMonsterFights++;
  165. opp.sendMessage("You win! Your monster has won "+opp.PVPMonsterFights+" fights!");
  166. if (opp.PVPMonsterFights % 5 == 0) {
  167. opp.monsterLevel++;
  168. opp.sendMessage("Congratulations! Your monster is now level "+opp.monsterLevel);
  169. }
  170. me.sendMessage("You lose! Better luck next time!");
  171. return;
  172. }
  173. } else {
  174. if (Misc.random(1) == 0) {
  175. oppHP -= (myAtt*Misc.random(2)) - oppDef + 1;
  176. if (oppHP < 0)
  177. oppHP = 0;
  178. opp.sendMessage("Your monsters health: "+oppHP);
  179. if (oppHP <= 0) {
  180. me.PVPMonsterFights++;
  181. me.sendMessage("You win! Your monster has won "+me.PVPMonsterFights+" fights!");
  182. if (me.PVPMonsterFights % 5 == 0) {
  183. me.monsterLevel++;
  184. me.sendMessage("Congratulations! Your monster is now level "+me.monsterLevel);
  185. }
  186. opp.sendMessage("You lose! Better luck next time!");
  187. return;
  188. }
  189. } else {
  190. myHP -= (oppAtt*Misc.random(2)) - myDef + 1;
  191. if (myHP < 0)
  192. myHP = 0;
  193. me.sendMessage("Your monsters health: "+myHP);
  194. if (myHP <= 0) {
  195. opp.PVPMonsterFights++;
  196. opp.sendMessage("You win! Your monster has won "+opp.PVPMonsterFights+" fights!");
  197. if (opp.PVPMonsterFights % 5 == 0) {
  198. opp.monsterLevel++;
  199. opp.sendMessage("Congratulations! Your monster is now level "+opp.monsterLevel);
  200. }
  201. me.sendMessage("You lose! Better luck next time!");
  202. return;
  203. }
  204. }
  205. }
  206. }
  207. }
  208.  
  209. public void pickUpClean(int id) {
  210. for (int i = 0; i < Pets.length; i++)
  211. if (Pets[i][0] == id) {
  212. //c.getItems().addItem(Pets[i][1], 1);
  213. if (!c.getItems().playerHasItem(2717)) {
  214. c.sendMessage("You need your monster chest to pick up your pet!");
  215. return;
  216. }
  217. }
  218. for (int i = 0; i < NPCHandler.maxNPCs; i++) {
  219. if (NPCHandler.npcs[i] == null)
  220. continue;
  221. if (NPCHandler.npcs[i].npcType == id) {
  222. NPCHandler.npcs[i].absX = 0;
  223. NPCHandler.npcs[i].absY = 0;
  224. }
  225. }
  226. c.sendMessage("You pick up your pet.");
  227. c.summonId = -1;
  228. c.hasNpc = false;
  229. }
  230.  
  231. public int getPetNpc(int petItem) {
  232. for (int i = 0; i < Pets.length; i++) {
  233. //System.out.println("a");
  234. if (Pets[i][1] == petItem) {
  235. //System.out.println(""+Pets[i][1]);
  236. return Pets[i][0];
  237. }
  238. }
  239. return -1;
  240. }
  241.  
  242. public boolean isPet(int npcId) {
  243. for (int i = 0; i < Pets.length; i++) {
  244. if (Pets[i][0] == npcId) {
  245. return true;
  246. }
  247. }
  248. return false;
  249. }
  250.  
  251. public void dropPet(int itemId) {
  252. if (!c.hasNpc && c.summonId < 1) {
  253. c.turnPlayerTo(c.absX, c.absY-1);
  254. Server.npcHandler.spawnNpc3(c, getPetNpc(itemId), c.absX, c.absY-1, c.heightLevel, 0, 0, 0, 0, 0, false, false, true);
  255. c.getPA().followPlayer();
  256. c.getItems().deleteItem(itemId, 1);
  257. c.sendMessage("You set your pet on the ground.");
  258. c.hasNpc = true;
  259. } else {
  260. c.sendMessage("You already have a pet following you.");
  261. return;
  262. }
  263. }
  264. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement