Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.53 KB | None | 0 0
  1. public boolean AttackNPC() {
  2.  
  3. int EnemyX = server.npcHandler.npcs[attacknpc].absX;
  4. int EnemyY = server.npcHandler.npcs[attacknpc].absY;
  5. int EnemyHP = server.npcHandler.npcs[attacknpc].HP;
  6. int hitDiff = 0;
  7. if (EnemyHP < 1) {
  8. sendMessage("You can't attack that monster!");
  9. return false;
  10. }
  11. int type = server.npcHandler.npcs[attacknpc].npcType;
  12. int[] staffs = { 2415, 2416, 2417 };
  13. int[] arrowIds = { 882, 884, 886, 888, 890, 892 };
  14. int[] arrowGfx = { 10, 9, 11, 12, 13, 15 };
  15. int[] prem = { 1643, 158, 49, 1613 };
  16. for (int element : prem) {
  17. if ((element == type) && !premium) {
  18. resetPos();
  19. return false;
  20. }
  21. }
  22. if (type == 1125) {
  23. if (combatLevel < 70) {
  24. sendMessage("You must be level 70 or higher to attack Dad");
  25. ResetAttackNPC();
  26. return false;
  27. }
  28. }
  29. if ((type == 110) || (type == 936)) {
  30. if (!playerHasItem(1543)) {
  31. resetPos();
  32. ResetAttackNPC();
  33. return false;
  34. }
  35. }
  36. if ((type == 221) || (type == 1961)) {
  37. if (!playerHasItem(1544)) {
  38. resetPos();
  39. ResetAttackNPC();
  40. return false;
  41. }
  42. }
  43. if (((type == 941) || (type == 55)) && !premium) {
  44. resetPos();
  45. return false;
  46. }
  47. for (int element : staffs) {
  48. if ((playerEquipment[playerWeapon] == element)
  49. && (autocast_spellIndex >= 0)) {
  50. if (System.currentTimeMillis() - lastAttack < coolDown[coolDownGroup[autocast_spellIndex]]) {
  51. return false;
  52. }
  53. inCombat = true;
  54. lastCombat = System.currentTimeMillis();
  55. lastAttack = System.currentTimeMillis();
  56. if (playerLevel[6] >= requiredLevel[autocast_spellIndex]) {
  57. int roll = misc.random(100);
  58. int hit = misc.random(baseDamage[autocast_spellIndex]
  59. + playerBonus[11]);
  60. hitDiff = hit;
  61. setAnimation(1979);
  62. updateRequired = true;
  63. // AnimationReset = true;
  64. // teleportToX = absX;
  65. // teleportToY = absY;
  66. resetWalkingQueue();
  67. if (ancientType[autocast_spellIndex] == 3) {
  68. // coolDown[coolDownGroup[autocast_spellIndex]] = 35;
  69. server.npcHandler.npcs[attacknpc].effects[0] = 15;
  70. stillgfx(369, EnemyY, EnemyX);
  71. } else if (ancientType[autocast_spellIndex] == 2) {
  72. stillgfx(377, EnemyY, EnemyX);
  73. // coolDown[coolDownGroup[autocast_spellIndex]] = 12;
  74. currentHealth += (int) (hit / 2);
  75. if (currentHealth > playerLevel[playerHitpoints])
  76. currentHealth = playerLevel[playerHitpoints];
  77. } else
  78. animation(78, EnemyY, EnemyX);
  79. } else {
  80. sendMessage("You need a magic level of "
  81. + requiredLevel[autocast_spellIndex]);
  82. }
  83. // coolDown[coolDownGroup[autocast_spellIndex]] = 12;
  84. TurnPlayerTo(EnemyX, EnemyY);
  85. addSkillXP(90 * hitDiff, playerMagic);
  86. addSkillXP(hitDiff * CombatExpRate, playerHitpoints);
  87. teleportToX = absX;
  88. teleportToY = absY;
  89. server.npcHandler.npcs[attacknpc].StartKilling = localId;
  90. server.npcHandler.npcs[attacknpc].RandomWalk = false;
  91. server.npcHandler.npcs[attacknpc].IsUnderAttack = true;
  92. server.npcHandler.npcs[attacknpc].hitDiff = hitDiff;
  93. server.npcHandler.npcs[attacknpc].Killing[playerId] += hitDiff;
  94. server.npcHandler.npcs[attacknpc].updateRequired = true;
  95. server.npcHandler.npcs[attacknpc].hitUpdateRequired = true;
  96. server.npcHandler.npcs[attacknpc].hit = true;
  97. faceNPC(attacknpc);
  98. updateRequired = true;
  99. appearanceUpdateRequired = true;
  100. // server.npcHandler.npcs[attacknpc].TurnNPCTo(absX,absY);
  101. // server.npcHandler.npcs[attacknpc].FocusUpdateRequired = true;
  102. return true;
  103. }
  104. }
  105. long thisTime = System.currentTimeMillis();
  106. if(GetWepAnim(playerEquipment[playerWeapon]) < 0){
  107. sendMessage("Use another attack style to attack!");
  108. return false;
  109. }
  110. if (thisTime - lastAttack >= getbattleTimer(playerEquipment[playerWeapon])) {
  111. setAnimation(GetWepAnim(playerEquipment[playerWeapon]));
  112. hitDiff = misc.random(playerMaxHit);
  113. if(AttackType == 1 && (misc.randomd(playerLevel[0]+(playerBonus[0]*.515)) >= misc.randomd(server.npcHandler.GetNPCDefence(type)+(server.npcHandler.StabDef[type]*.515)))){
  114. hitDiff = hitDiff;
  115. } else if(AttackType == 2 && (misc.randomd(playerLevel[0]+(playerBonus[1]*.515)) >= misc.randomd(server.npcHandler.GetNPCDefence(type)+(server.npcHandler.SlashDef[type]*.515)))){
  116. hitDiff = hitDiff;
  117. } else if(AttackType == 3 && (misc.randomd(playerLevel[0]+(playerBonus[2]*.515)) >= misc.randomd(server.npcHandler.GetNPCDefence(type)+(server.npcHandler.CrushDef[type]*.515)))){
  118. hitDiff = hitDiff;
  119. } else {
  120. hitDiff = 0;
  121. }
  122. }
  123. if (server.npcHandler.npcs[attacknpc].npcType == 5 && AttackType != 1) {
  124. hitDiff = (int)(hitDiff * .5);
  125. } else {
  126. hitDiff = hitDiff;
  127. }
  128. /*if(playerEquipment[playerWeapon] == 5698){
  129. server.npcHandler.npcs[attacknpc].poisonTimer = 120;
  130. server.npcHandler.npcs[attacknpc].poisonDmg = true;
  131. server.npcHandler.poisonNpc(type);
  132. PoisonDamage(6.8);
  133. }*/
  134. if(hitDiff >= 20){
  135. hitDiff = hitDiff*(100-server.npcHandler.AbMel[type])/100;
  136. }
  137. boolean UseBow = false;
  138.  
  139. for (int i = 0; i < shortbow.length; i++) {
  140. if ((playerEquipment[playerWeapon] == shortbow[i])
  141. || (playerEquipment[playerWeapon] == longbow[i])) {
  142. UseBow = true;
  143. break;
  144. }
  145. }
  146. int arrowgfx = 10;
  147. for (int i1 = 0; i1 < arrowIds.length; i1++) {
  148. if (playerEquipment[playerArrows] == arrowIds[i1]) {
  149. arrowgfx = arrowGfx[i1];
  150. }
  151. }
  152.  
  153. if (thisTime - lastAttack >= getbattleTimer(playerEquipment[playerWeapon]) && UseBow == true) {
  154. teleportToX = absX;
  155. teleportToY = absY;
  156. CalculateRange();
  157. hitDiff = misc.random(CalculateRange());
  158. if (DeleteArrow()) {
  159. int offsetX = (absY - EnemyY) * -1;
  160. int offsetY = (absX - EnemyX) * -1;
  161. for (int a = 0; a < handler.maxPlayers; a++) {
  162. client temp = (client) handler.players[a];
  163. if ((temp != null) && (temp.absX > 0) && !temp.disconnected
  164. && (Math.abs(absX - temp.absX) < 60)
  165. && (Math.abs(absY - temp.absY) < 60)) {
  166. temp.createProjectile(absY, absX, offsetY, offsetX, 50,
  167. 90, arrowgfx, 43, 35, attacknpc + 1);
  168. }
  169. }
  170. server.npcHandler.npcs[attacknpc].hitDiff = hitDiff;
  171. server.npcHandler.npcs[attacknpc].Killing[playerId] += hitDiff;
  172. server.npcHandler.npcs[attacknpc].updateRequired = true;
  173. server.npcHandler.npcs[attacknpc].hitUpdateRequired = true;
  174. server.npcHandler.npcs[attacknpc].hit = true;
  175. if ((hitDiff == 0)
  176. && (server.npcHandler.npcs[attacknpc].npcType == 941)) {
  177. server.npcHandler.npcs[attacknpc].animNumber = 89;
  178. server.npcHandler.npcs[attacknpc].animUpdateRequired = true;
  179. server.npcHandler.npcs[attacknpc].updateRequired = true;
  180. }
  181. updateRequired = true;
  182. appearanceUpdateRequired = true;
  183. } else {
  184. ResetAttackNPC();
  185. sendMessage("You're out of arrows!");
  186. return false;
  187. }
  188. }
  189. if (thisTime - lastAttack >= getbattleTimer(playerEquipment[playerWeapon])) {
  190. inCombat = true;
  191. lastCombat = System.currentTimeMillis();
  192. } else {
  193. return false;
  194. }
  195. if (UseBow || (GoodDistance(EnemyX, EnemyY, absX, absY, 1) == true)) {
  196. walkTo_old(absX, absY);
  197. if (server.npcHandler.npcs[attacknpc].IsDead == true) {
  198. ResetAttackNPC();
  199. } else {
  200. TurnPlayerTo(EnemyX, EnemyY);
  201. updateRequired = true;
  202. appearanceUpdateRequired = true;
  203. actionAmount++;
  204. setAnimation(playerSEA);
  205. if ((EnemyHP - hitDiff) < 0) {
  206. hitDiff = EnemyHP;
  207. }
  208. server.npcHandler.npcs[attacknpc].StartKilling = playerId;
  209. server.npcHandler.npcs[attacknpc].hitDiff = hitDiff;
  210. server.npcHandler.npcs[attacknpc].Killing[playerId] += hitDiff;
  211. server.npcHandler.npcs[attacknpc].updateRequired = true;
  212. server.npcHandler.npcs[attacknpc].hitUpdateRequired = true;
  213. server.npcHandler.npcs[attacknpc].hit = true;
  214. attackedNpc = true;
  215. attackedNpcId = attacknpc;
  216. double TotalExp = 0;
  217. if (!UseBow)
  218. animationReset = System.currentTimeMillis() + 1200;
  219. if (server.npcHandler.npcs[attacknpc].npcType != 2745){
  220. server.npcHandler.npcs[attacknpc].animNumber = server.npcHandler.GetNPCBlockAnim(type);
  221. server.npcHandler.npcs[attacknpc].animUpdateRequired = true;
  222. if (UseBow) {
  223. TotalExp = (double) (60 * hitDiff); // added *2 for
  224. // faster
  225. // leveling
  226. // -bakatool
  227. TotalExp = (double) (TotalExp * CombatExpRate);
  228. addSkillXP((int) (TotalExp), 4);
  229. } else if (FightType != 3) {
  230. TotalExp = (double) (60 * hitDiff); // added *2 for
  231. // faster
  232. // leveling
  233. // -bakatool
  234. TotalExp = (double) (TotalExp * CombatExpRate);
  235. addSkillXP((int) (TotalExp), SkillID);
  236. } else {
  237. TotalExp = (double) (20 * hitDiff); // added *2 for
  238. // faster
  239. // leveling
  240. // -bakatool2
  241. TotalExp = (double) (TotalExp * CombatExpRate);
  242. addSkillXP((int) (TotalExp), playerAttack);
  243. addSkillXP((int) (TotalExp), playerDefence);
  244. addSkillXP((int) (TotalExp), playerStrength);
  245. }
  246. TotalExp = (double) (20 * hitDiff * 2); // added *2 for
  247. // faster leveling
  248. // -bakatool
  249. TotalExp = (double) (TotalExp * CombatExpRate);
  250. addSkillXP((int) (TotalExp), playerHitpoints);
  251. attackTimer = 7;
  252. if (debug)
  253. sendMessage("hitDiff=" + hitDiff + ", elapsed="
  254. + (thisTime - lastAttack));
  255. lastAttack = System.currentTimeMillis();
  256. }
  257. return true;
  258.  
  259. }
  260. }
  261. if(server.npcHandler.npcs[attacknpc].IsUnderAttack == false){
  262. walkTo_old(absX, absY);
  263. setAnimation(GetStandAnim(playerEquipment[playerWeapon]));
  264. }
  265. return false;
  266. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement