Guest User

Untitled

a guest
Mar 8th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 180.07 KB | None | 0 0
  1. package org.luzox.game.players.content;
  2.  
  3. import net.utility.Misc;
  4.  
  5. import org.luzox.Config;
  6. import org.luzox.event.CycleEvent;
  7. import org.luzox.event.CycleEventContainer;
  8. import org.luzox.event.CycleEventHandler;
  9. import org.luzox.event.Event;
  10. import org.luzox.event.EventContainer;
  11. import org.luzox.event.EventManager;
  12. import org.luzox.game.Server;
  13. import org.luzox.game.npcs.NPC;
  14. import org.luzox.game.npcs.NPCHandler;
  15. import org.luzox.game.players.Client;
  16. import org.luzox.game.players.Player;
  17. import org.luzox.game.players.PlayerHandler;
  18.  
  19. public class CombatAssistant {
  20. private Client c;
  21.  
  22. public CombatAssistant(Client Client) {
  23. this.c = Client;
  24. }
  25.  
  26. public void multiSpellEffectNPC(int npcId, int damage) {
  27. switch (c.MAGIC_SPELLS[c.oldSpellId][0]) {
  28. case 12891:
  29. case 12881:
  30. if (NPCHandler.npcs[npcId].freezeTimer < -4) {
  31. NPCHandler.npcs[npcId].freezeTimer = getFreezeTime();
  32. }
  33. break;
  34. }
  35. }
  36.  
  37. public boolean checkMultiBarrageReqsNPC(int i) {
  38. if (NPCHandler.npcs[i] == null) {
  39. return false;
  40. } else {
  41. return true;
  42. }
  43. }
  44.  
  45. public void appendMultiBarrageNPC(int npcId, boolean splashed) {
  46. if (NPCHandler.npcs[npcId] != null) {
  47. NPC n = (NPC) NPCHandler.npcs[npcId];
  48. if (n.isDead)
  49. return;
  50. if (n.heightLevel != c.heightLevel)
  51. return;
  52. if (checkMultiBarrageReqsNPC(npcId)) {
  53. c.barrageCount++;
  54. NPCHandler.npcs[npcId].underAttackBy = c.playerId;
  55. NPCHandler.npcs[npcId].underAttack = true;
  56. if (Misc.random(mageAtk()) > Misc.random(mageDef())
  57. && !c.magicFailed) {
  58. if (getEndGfxHeight() == 100) { // end GFX
  59. n.gfx100(c.MAGIC_SPELLS[c.oldSpellId][5]);
  60. } else {
  61. n.gfx0(c.MAGIC_SPELLS[c.oldSpellId][5]);
  62. }
  63. int damage = Misc.random(c.MAGIC_SPELLS[c.oldSpellId][6]);
  64. if (NPCHandler.npcs[npcId].HP - damage < 0) {
  65. damage = NPCHandler.npcs[npcId].HP;
  66. }
  67. c.getPA().addSkillXP(
  68. (c.MAGIC_SPELLS[c.oldSpellId][7] + damage
  69. * Config.MAGIC_EXP_RATE), 6);
  70. c.getPA().addSkillXP(
  71. (c.MAGIC_SPELLS[c.oldSpellId][7] + damage
  72. * Config.MAGIC_EXP_RATE / 3), 3);
  73. NPCHandler.npcs[npcId].handleHitMask(damage);
  74. // Server.npcHandler.applyDamage(npcId);
  75. NPCHandler.npcs[npcId].hitDiff = damage;
  76. NPCHandler.npcs[npcId].HP -= damage;
  77. NPCHandler.npcs[npcId].hitUpdateRequired = true;
  78. NPCHandler.npcs[npcId].freezeTimer = getFreezeTime();
  79. c.totalPlayerDamageDealt += damage;
  80. multiSpellEffectNPC(npcId, damage);
  81. } else {
  82. n.gfx100(85);
  83. }
  84. }
  85. }
  86. }
  87.  
  88. public void appendVengeanceNPC(int otherPlayer, int damage) {
  89. if (c.getItems().playerHasItem(7671, 1)
  90. || c.playerEquipment[c.playerHands] == 7671) {
  91. c.sendMessage("You can't use Vengeance with boxing gloves!");
  92. return;
  93. }
  94. if (damage <= 0)
  95. return;
  96. if (c.npcIndex > 0 && NPCHandler.npcs[c.npcIndex] != null) {
  97. c.forcedText = "Taste Vengeance!";
  98. c.forcedChatUpdateRequired = true;
  99. c.updateRequired = true;
  100. c.vengOn = false;
  101. if ((NPCHandler.npcs[c.npcIndex].HP - damage) > 0) {
  102. damage = (int) (damage * 0.75);
  103. if (damage > NPCHandler.npcs[c.npcIndex].HP) {
  104. damage = NPCHandler.npcs[c.npcIndex].HP;
  105. }
  106. NPCHandler.npcs[c.npcIndex].HP -= damage;
  107. NPCHandler.npcs[c.npcIndex].hitDiff2 = damage;
  108. NPCHandler.npcs[c.npcIndex].hitUpdateRequired2 = true;
  109. NPCHandler.npcs[c.npcIndex].updateRequired = true;
  110. }
  111. }
  112. c.updateRequired = true;
  113. }
  114.  
  115. public int[][] slayerReqs = { { 1648, 1 }, { 1612, 1 }, { 1643, 1 },
  116. { 1618, 1 }, { 1624, 1 }, { 1610, 1 }, { 1613, 1 }, { 1615, 1 },
  117. { 2783, 1 }, { 3068, 90 } };
  118.  
  119. public boolean goodSlayer(int i) {
  120. for (int j = 0; j < slayerReqs.length; j++) {
  121. if (slayerReqs[j][0] == NPCHandler.npcs[i].npcType) {
  122. if (slayerReqs[j][1] > c.playerLevel[c.playerSlayer]) {
  123. c.sendMessage("You need a slayer level of "
  124. + slayerReqs[j][1] + " to harm this NPC.");
  125. return false;
  126. }
  127. }
  128. }
  129. return true;
  130. }
  131.  
  132. public int salveDamage() {
  133. int damage = Misc.random(calculateMeleeMaxHit());
  134. return damage *= 1.55;
  135. }
  136.  
  137. private void applyLeeches(int index) {
  138. if (c.lastTime > 0) {
  139. c.lastTime--;
  140. return;
  141. }
  142. if (c.curseActive[10]) {
  143. if (Misc.random(19) == 0) {
  144. leechAttack(index);
  145. c.lastTime++;
  146. return;
  147. }
  148. }
  149. if (c.curseActive[11]) {
  150. if (Misc.random(19) == 0) {
  151. leechRanged(index);
  152. c.lastTime++;
  153. return;
  154. }
  155. }
  156. if (c.curseActive[12]) {
  157. if (Misc.random(19) == 0) {
  158. leechMagic(index);
  159. c.lastTime++;
  160. return;
  161. }
  162. }
  163. if (c.curseActive[13]) {
  164. if (Misc.random(19) == 0) {
  165. leechDefence(index);
  166. c.lastTime++;
  167. return;
  168. }
  169. }
  170. if (c.curseActive[14]) {
  171. if (Misc.random(19) == 0) {
  172. leechStrength(index);
  173. c.lastTime++;
  174. return;
  175. }
  176. }
  177. if (c.curseActive[16]) {
  178. if (Misc.random(19) == 0) {
  179. leechSpecial(index);
  180. c.lastTime++;
  181. return;
  182. }
  183. }
  184. }
  185.  
  186. public void leechRanged(int index) {
  187. int failed = Misc.random(5);
  188. Client c2 = (Client) PlayerHandler.players[index];
  189. if (failed < 5) {
  190. c.Lranged = false;
  191. return;
  192. } else if (failed == 5) {
  193. c2.playerLevel[4] -= Misc.random(8);
  194. if (c2.playerLevel[4] < 1)
  195. c2.playerLevel[4] = 1;
  196. c2.getPA().refreshSkill(4);
  197. }
  198. if (c.oldPlayerIndex > 0) {
  199. if (PlayerHandler.players[c.oldPlayerIndex] != null) {
  200. final int pX = c.getX();
  201. final int pY = c.getY();
  202. final int nX = c2.getX();
  203. final int nY = c2.getY();
  204. final int offX = (pY - nY) * -1;
  205. final int offY = (pX - nX) * -1;
  206. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50,
  207. 2236, 9, 9, -c.oldPlayerIndex - 1, 24, 0);
  208. c2.sendMessage("Your ranged has been leeched by "
  209. + Misc.optimizeText(c.playerName) + "!");
  210. c2.gfx0(2238);
  211. c.startAnimation(12575);
  212. c.Lranged = false;
  213. }
  214. }
  215. }
  216.  
  217. public void leechMagic(int index) {
  218. int failed = Misc.random(5);
  219. Client c2 = (Client) PlayerHandler.players[index];
  220. if (failed < 5) {
  221. c.Lmagic = false;
  222. return;
  223. } else if (failed == 5) {
  224. c2.playerLevel[6] -= Misc.random(7) + 1;
  225. if (c2.playerLevel[6] < 1)
  226. c2.playerLevel[6] = 1;
  227. c2.getPA().refreshSkill(6);
  228. }
  229. if (c.oldPlayerIndex > 0) {
  230. if (PlayerHandler.players[c.oldPlayerIndex] != null) {
  231. final int pX = c.getX();
  232. final int pY = c.getY();
  233. final int nX = c2.getX();
  234. final int nY = c2.getY();
  235. final int offX = (pY - nY) * -1;
  236. final int offY = (pX - nX) * -1;
  237. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50,
  238. 2240, 9, 9, -c.oldPlayerIndex - 1, 24, 0);
  239. c2.sendMessage("Your Magic has been leeched by "
  240. + Misc.optimizeText(c.playerName) + "!");
  241. c2.gfx0(2242);
  242. c.startAnimation(12575);
  243. c.Lmagic = false;
  244. }
  245. }
  246. }
  247.  
  248. public void leechDefence(int index) {
  249. int failed = Misc.random(5);
  250. Client c2 = (Client) PlayerHandler.players[index];
  251. if (failed < 5) {
  252. c.Ldefense = false;
  253. return;
  254. } else if (failed == 5) {
  255. c2.playerLevel[1] -= Misc.random(8);
  256. if (c2.playerLevel[1] < 1)
  257. c2.playerLevel[1] = 1;
  258. c2.getPA().refreshSkill(1);
  259. }
  260. if (c.oldPlayerIndex > 0) {
  261. if (PlayerHandler.players[c.oldPlayerIndex] != null) {
  262. final int pX = c.getX();
  263. final int pY = c.getY();
  264. final int nX = c2.getX();
  265. final int nY = c2.getY();
  266. final int offX = (pY - nY) * -1;
  267. final int offY = (pX - nX) * -1;
  268. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50,
  269. 2242, 9, 9, -c.oldPlayerIndex - 1, 24, 0);
  270. c2.sendMessage("Your defense has been leeched by "
  271. + Misc.optimizeText(c.playerName) + "!");
  272. c2.gfx0(2246);
  273. c.startAnimation(12575);
  274. c.Ldefense = false;
  275. }
  276. }
  277. }
  278.  
  279. public void leechSpecial(int index) {
  280. int failed = Misc.random(10);
  281. Client c2 = (Client) PlayerHandler.players[index];
  282. if (failed < 10) {
  283. c.Lspecial = false;
  284. return;
  285. } else if (failed == 10) {
  286. c2.specAmount -= 0.5;
  287. c.specAmount += 0.5;
  288. final int pX = c.getX();
  289. final int pY = c.getY();
  290. final int nX = c2.getX();
  291. final int nY = c2.getY();
  292. final int offX = (pY - nY) * -1;
  293. final int offY = (pX - nX) * -1;
  294. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50,
  295. 2256, 9, 9, -c.oldPlayerIndex - 1, 24, 0);
  296. c2.sendMessage("Your special attack has been leeched by "
  297. + Misc.optimizeText(c.playerName) + "!");
  298. c2.gfx0(2258);
  299. c.startAnimation(12575);
  300. c.getItems().updateSpecialBar();
  301. c.sendMessage("You have leeched "
  302. + Misc.optimizeText(c2.playerName) + "'s special attack!");
  303. // c2.specAmount -= Misc.random(8);
  304. if (c2.specAmount < 1)
  305. c2.specAmount = 1;
  306. }
  307. if (c.oldPlayerIndex > 0) {
  308. if (PlayerHandler.players[c.oldPlayerIndex] != null) {
  309. final int pX = c.getX();
  310. final int pY = c.getY();
  311. final int nX = c2.getX();
  312. final int nY = c2.getY();
  313. final int offX = (pY - nY) * -1;
  314. final int offY = (pX - nX) * -1;
  315. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50,
  316. 2256, 9, 9, -c.oldPlayerIndex - 1, 24, 0);
  317. // c2.sendMessage("Your special attack has been leeched by "
  318. // +Misc.optimizeText(c.playerName)+"!");
  319. c2.gfx0(2258);
  320. c.startAnimation(12575);
  321. c.getItems().updateSpecialBar();
  322. c.Lspecial = false;
  323. }
  324. }
  325. }
  326.  
  327. public void leechStrength(int index) {
  328. int failed = Misc.random(5);
  329. Client c2 = (Client) PlayerHandler.players[index];
  330. if (failed < 5) {
  331. c.Lstrength = false;
  332. return;
  333. } else if (failed == 5) {
  334. c2.playerLevel[2] -= Misc.random(8);
  335. if (c2.playerLevel[2] < 1)
  336. c2.playerLevel[2] = 1;
  337. c2.getPA().refreshSkill(2);
  338. }
  339. if (c.oldPlayerIndex > 0) {
  340. if (PlayerHandler.players[c.oldPlayerIndex] != null) {
  341. final int pX = c.getX();
  342. final int pY = c.getY();
  343. final int nX = c2.getX();
  344. final int nY = c2.getY();
  345. final int offX = (pY - nY) * -1;
  346. final int offY = (pX - nX) * -1;
  347. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50,
  348. 2248, 9, 9, -c.oldPlayerIndex - 1, 24, 0);
  349. c2.sendMessage("Your strength has been leeched by "
  350. + Misc.optimizeText(c.playerName) + "!");
  351. c2.gfx0(2250);
  352. c.startAnimation(12575);
  353. c.Lstrength = false;
  354. }
  355. }
  356. }
  357.  
  358. public void leechAttack(int index) {
  359. int failed = Misc.random(5);
  360. Client c2 = (Client) PlayerHandler.players[index];
  361. if (failed < 5) {
  362. c.Lattack = false;
  363. return;
  364. } else if (failed == 5) {
  365. c2.playerLevel[0] -= Misc.random(8);
  366. if (c2.playerLevel[0] < 1)
  367. c2.playerLevel[0] = 1;
  368. c2.getPA().refreshSkill(0);
  369. }
  370. if (c.oldPlayerIndex > 0) {
  371. if (PlayerHandler.players[c.oldPlayerIndex] != null) {
  372. final int pX = c.getX();
  373. final int pY = c.getY();
  374. final int nX = c2.getX();
  375. final int nY = c2.getY();
  376. final int offX = (pY - nY) * -1;
  377. final int offY = (pX - nX) * -1;
  378. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50,
  379. 2252, 9, 9, -c.oldPlayerIndex - 1, 24, 0);
  380. c2.sendMessage("Your attack has been leeched by "
  381. + Misc.optimizeText(c.playerName) + "!");
  382. c2.gfx0(2253);
  383. c.startAnimation(12575);
  384. c.Lattack = false;
  385. }
  386. }
  387. }
  388.  
  389. public void applyNpcSoulSplit(int i, int damage) {
  390. int pX = c.getX();
  391. int pY = c.getY();
  392. int oX = NPCHandler.npcs[i].absX;
  393. int oY = NPCHandler.npcs[i].absY;
  394. int offX = (pY - oY) * -1;
  395. int offY = (pX - oX) * -1;
  396. if (!c.curseActive[18])
  397. return;
  398. if (damage <= 0)
  399. return;
  400. if (NPCHandler.npcs[i] != null) {
  401. NPC c2 = (NPC) NPCHandler.npcs[i];
  402. c2.HP -= (int) (damage / 40);
  403. c2.hitUpdateRequired = true;
  404. c.getPA().createPlayersProjectile(pX, pY, offX, offY, 50, 80, 2263,
  405. 43, 31, -c.oldPlayerIndex - 1, 0);
  406. c.gfx0(2264);
  407. if (c.playerLevel[3] < c.getLevelForXP(c.playerXP[3])) {
  408. c.playerLevel[3] += (int) (damage / 4);
  409. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  410. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  411. c.getPA().refreshSkill(3);
  412. }
  413. }
  414.  
  415. }
  416.  
  417. public void npcMageDamage(int damage) {
  418. int i = c.npcIndex;
  419. c.previousDamage = damage;
  420. int bonusAttack = getBonusAttack(i);
  421. if (Misc.random(NPCHandler.npcs[i].defence) > 10
  422. + Misc.random(mageAtk()) + bonusAttack) {
  423. damage /= 2;
  424. } else if (NPCHandler.npcs[i].npcType == 2881
  425. || NPCHandler.npcs[i].npcType == 2882) {
  426. damage /= 2;
  427. }
  428. if (NPCHandler.npcs[i].HP - damage < 0) {
  429. damage = NPCHandler.npcs[i].HP;
  430. }
  431. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE), 6);
  432. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE / 3), 3);
  433. c.getPA().refreshSkill(3);
  434. c.getPA().refreshSkill(6);
  435. if (damage > 0) {
  436. if (NPCHandler.npcs[i].npcType >= 3777
  437. && NPCHandler.npcs[i].npcType <= 3780) {
  438. c.pcDamage += damage;
  439. }
  440. }
  441. NPCHandler.npcs[i].underAttack = true;
  442. c.killingNpcIndex = c.npcIndex;
  443. c.lastNpcAttacked = i;
  444. NPCHandler.npcs[i].hitDiff = damage;
  445. NPCHandler.npcs[i].HP -= damage;
  446. NPCHandler.npcs[i].hitUpdateRequired = true;
  447. c.totalDamageDealt += damage;
  448. NPCHandler.npcs[i].updateRequired = true;
  449. }
  450.  
  451. public void applyMageDamage(int damage) {
  452. int i = c.playerIndex;
  453. Client o = (Client) PlayerHandler.players[i];
  454. if (c.Kspec && o.prayerActive[16]) {
  455. damage *= 0.5;
  456. }
  457. c.previousDamage = damage;
  458. if (o == null) {
  459. return;
  460. }
  461. if (o.vengOn && damage > 0)
  462. appendVengeance(i, damage);
  463. if (c.fightMode == 3) {
  464. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE / 3), 0);
  465. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE / 3), 1);
  466. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE / 3), 2);
  467. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE / 3), 3);
  468. c.getPA().refreshSkill(0);
  469. c.getPA().refreshSkill(1);
  470. c.getPA().refreshSkill(2);
  471. c.getPA().refreshSkill(3);
  472. } else {
  473. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE), c.fightMode);
  474. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE / 3), 3);
  475. c.getPA().refreshSkill(c.fightMode);
  476. c.getPA().refreshSkill(3);
  477. }
  478. PlayerHandler.players[i].logoutDelay = System.currentTimeMillis();
  479. PlayerHandler.players[i].underAttackBy = c.playerId;
  480. PlayerHandler.players[i].killerId = c.playerId;
  481. PlayerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  482. if (c.killedBy != PlayerHandler.players[i].playerId)
  483. c.totalPlayerDamageDealt = 0;
  484. c.killedBy = PlayerHandler.players[i].playerId;
  485. applySmite(i, damage);
  486. if (c.prayerActive[3] == true)
  487. applySmite(i, damage * 3);
  488. PlayerHandler.players[i].dealDamage(damage);
  489. PlayerHandler.players[i].damageTaken[c.playerId] += damage;
  490. c.totalPlayerDamageDealt += damage;
  491. PlayerHandler.players[i].updateRequired = true;
  492. o.getPA().refreshSkill(3);
  493. PlayerHandler.players[i].handleHitMask(damage);
  494. }
  495.  
  496. /**
  497. * Attack Npcs
  498. */
  499. public void attackNpc(int i) {
  500.  
  501. if (NPCHandler.npcs[i] != null) {
  502. if (NPCHandler.npcs[i].isDead || NPCHandler.npcs[i].MaxHP <= 0) {
  503. c.usingMagic = false;
  504. c.faceUpdate(0);
  505. c.npcIndex = 0;
  506. return;
  507. }
  508. if (NPCHandler.npcs[i].npcType == 110 && c.absY <= 10326) {
  509. c.usingMagic = false;
  510. c.faceUpdate(0);
  511. c.npcIndex = 0;
  512. return;
  513. }
  514.  
  515. if (c.respawnTimer > 0) {
  516. c.npcIndex = 0;
  517. return;
  518. }
  519. if (NPCHandler.npcs[i].underAttackBy > 0
  520. && NPCHandler.npcs[i].underAttackBy != c.playerId
  521. && !NPCHandler.npcs[i].inMulti()) {
  522. c.npcIndex = 0;
  523. c.sendMessage("This monster is already in combat.");
  524. return;
  525. }
  526. if ((c.underAttackBy > 0 || c.underAttackBy2 > 0)
  527. && c.underAttackBy2 != i && !c.inMulti()) {
  528. resetPlayerAttack();
  529. c.sendMessage("I am already under attack.");
  530. return;
  531. }
  532. if (!goodSlayer(i)) {
  533. resetPlayerAttack();
  534. return;
  535. }
  536. if (NPCHandler.npcs[i].spawnedBy != c.playerId
  537. && NPCHandler.npcs[i].spawnedBy > 0) {
  538. resetPlayerAttack();
  539. c.sendMessage("This monster was not spawned for you.");
  540. return;
  541. }
  542. c.followId2 = i;
  543. c.followId = 0;
  544. if (c.attackTimer <= 0) {
  545. boolean usingBow = false;
  546. boolean usingArrows = false;
  547. boolean usingOtherRangeWeapons = false;
  548. boolean usingCross = false;
  549. c.usingBow = false;
  550.  
  551. if (c.playerEquipment[c.playerWeapon] == 9185
  552. || c.playerEquipment[c.playerWeapon] == 15041
  553. || c.playerEquipment[c.playerWeapon] == 7885)
  554. usingCross = true;
  555. c.bonusAttack = 0;
  556. c.rangeItemUsed = 0;
  557. c.projectileStage = 0;
  558. c.SaveGame();
  559. if (c.autocasting && c.playerMagicBook != 2) {
  560. c.spellId = c.autocastId;
  561. c.usingMagic = true;
  562. }
  563.  
  564. if (c.playerEquipment[c.playerWeapon] == 22494) {
  565. c.autocasting = true;
  566. c.spellId = 52;
  567. c.usingMagic = true;
  568. c.mageFollow = true;
  569. }
  570.  
  571. if (c.spellId > 0) {
  572. c.usingMagic = true;
  573. }
  574. c.attackTimer = getAttackDelay(c.getItems()
  575. .getItemName(c.playerEquipment[c.playerWeapon])
  576. .toLowerCase());
  577. c.specAccuracy = 1.0;
  578. c.specDamage = 1.0;
  579. if (!c.usingMagic) {
  580. for (int bowId : c.BOWS) {
  581. if (c.playerEquipment[c.playerWeapon] == bowId) {
  582. usingBow = true;
  583. c.usingBow = true;
  584. for (int arrowId : c.ARROWS) {
  585. if (c.playerEquipment[c.playerArrows] == arrowId) {
  586. usingArrows = true;
  587. }
  588. }
  589. }
  590. }
  591.  
  592. if (c.playerEquipment[c.playerWeapon] == 13022) {
  593. usingBow = true;
  594. c.usingBow = true;
  595. }
  596.  
  597. for (int otherRangeId : c.OTHER_RANGE_WEAPONS) {
  598. if (c.playerEquipment[c.playerWeapon] == otherRangeId) {
  599. usingOtherRangeWeapons = true;
  600. }
  601. }
  602. }
  603. if ((!c.goodDistance(c.getX(), c.getY(),
  604. NPCHandler.npcs[i].getX(), NPCHandler.npcs[i].getY(), 2) && (usingHally()
  605. && !usingOtherRangeWeapons
  606. && !usingBow
  607. && !c.usingMagic && !usingCrystalBow()))
  608. || (!c.goodDistance(c.getX(), c.getY(),
  609. NPCHandler.npcs[i].getX(),
  610. NPCHandler.npcs[i].getY(), 4) && (usingOtherRangeWeapons
  611. && !usingBow && !c.usingMagic && !usingCrystalBow()))
  612. || (!c.goodDistance(c.getX(), c.getY(),
  613. NPCHandler.npcs[i].getX(),
  614. NPCHandler.npcs[i].getY(), 1) && (!usingOtherRangeWeapons
  615. && !usingHally() && !usingBow && !c.usingMagic && !usingCrystalBow()))
  616. || ((!c.goodDistance(c.getX(), c.getY(),
  617. NPCHandler.npcs[i].getX(),
  618. NPCHandler.npcs[i].getY(), 8) && (usingBow
  619. || c.usingMagic || usingCrystalBow())))) {
  620. c.attackTimer = 2;
  621. return;
  622. }
  623.  
  624. if (!usingCross
  625. && !usingArrows
  626. && usingBow
  627. && (c.playerEquipment[c.playerWeapon] < 4212 || c.playerEquipment[c.playerWeapon] > 4223)
  628. && c.playerEquipment[c.playerWeapon] != 13022) {
  629. c.sendMessage("You have run out of arrows!");
  630. c.stopMovement();
  631. c.npcIndex = 0;
  632. return;
  633. }
  634. if (correctBowAndArrows() < c.playerEquipment[c.playerArrows]
  635. && Config.CORRECT_ARROWS && usingBow
  636. && !usingCrystalBow()
  637. && c.playerEquipment[c.playerWeapon] != 9185
  638. && c.playerEquipment[c.playerWeapon] != 7865
  639. && c.playerEquipment[c.playerWeapon] != 7885
  640. && c.playerEquipment[c.playerWeapon] != 15041) {
  641. c.sendMessage("You can't use "
  642. + c.getItems()
  643. .getItemName(
  644. c.playerEquipment[c.playerArrows])
  645. .toLowerCase()
  646. + "s with a "
  647. + c.getItems()
  648. .getItemName(
  649. c.playerEquipment[c.playerWeapon])
  650. .toLowerCase() + ".");
  651. c.stopMovement();
  652. c.npcIndex = 0;
  653. return;
  654. }
  655. if ((c.playerEquipment[c.playerWeapon] == 9185
  656. || c.playerEquipment[c.playerWeapon] == 15041
  657. || c.playerEquipment[c.playerWeapon] == 7885 || c.playerEquipment[c.playerWeapon] == 7865)
  658. && !properBolts()) {
  659. c.sendMessage("You must use bolts with a crossbow.");
  660. c.stopMovement();
  661. resetPlayerAttack();
  662. return;
  663. }
  664. if (armaNpc(i) && !usingCross && !usingBow && !c.usingMagic
  665. && !usingCrystalBow() && !usingOtherRangeWeapons) {
  666. resetPlayerAttack();
  667. c.sendMessage("You can only attack this npc with ranged or magic!");
  668. return;
  669. }
  670. if (usingBow
  671. || c.usingMagic
  672. || c.spellId > 0
  673. || usingOtherRangeWeapons
  674. || usingCrystalBow()
  675. || (c.goodDistance(c.getX(), c.getY(),
  676. NPCHandler.npcs[i].getX(),
  677. NPCHandler.npcs[i].getY(), 2) && usingHally())) {
  678. c.stopMovement();
  679. }
  680.  
  681. if (!checkMagicReqs(c.spellId)) {
  682. c.stopMovement();
  683. c.npcIndex = 0;
  684. return;
  685. }
  686.  
  687. c.faceUpdate(i);
  688. // c.specAccuracy = 1.0;
  689. // c.specDamage = 1.0;
  690. NPCHandler.npcs[i].underAttackBy = c.playerId;
  691. NPCHandler.npcs[i].lastDamageTaken = System.currentTimeMillis();
  692. if (c.usingSpecial && !c.usingMagic) {
  693. if (checkSpecAmount(c.playerEquipment[c.playerWeapon])) {
  694. c.lastWeaponUsed = c.playerEquipment[c.playerWeapon];
  695. c.lastArrowUsed = c.playerEquipment[c.playerArrows];
  696. activateSpecial(c.playerEquipment[c.playerWeapon], i);
  697. return;
  698. } else {
  699. c.sendMessage("You don't have the required special energy to use this attack.");
  700. c.usingSpecial = false;
  701. c.getItems().updateSpecialBar();
  702. c.npcIndex = 0;
  703. return;
  704. }
  705. }
  706. c.specMaxHitIncrease = 0;
  707. if (!c.usingMagic) {
  708. c.startAnimation(getWepAnim(c.getItems()
  709. .getItemName(c.playerEquipment[c.playerWeapon])
  710. .toLowerCase()));
  711. } else {
  712. c.startAnimation(c.MAGIC_SPELLS[c.spellId][2]);
  713. }
  714. c.lastWeaponUsed = c.playerEquipment[c.playerWeapon];
  715. c.lastArrowUsed = c.playerEquipment[c.playerArrows];
  716. if (!usingBow && !c.usingMagic && !usingOtherRangeWeapons) { // melee
  717. // hit
  718. // delay
  719. c.hitDelay = getHitDelay(c.getItems()
  720. .getItemName(c.playerEquipment[c.playerWeapon])
  721. .toLowerCase());
  722. c.projectileStage = 0;
  723. c.oldNpcIndex = i;
  724. }
  725.  
  726. if (usingBow && !usingOtherRangeWeapons && !c.usingMagic
  727. || usingCross) { // range
  728. // hit
  729. // delay
  730. if (usingCross)
  731. c.usingBow = true;
  732. if (c.fightMode == 2)
  733. c.attackTimer--;
  734. c.lastArrowUsed = c.playerEquipment[c.playerArrows];
  735. c.lastWeaponUsed = c.playerEquipment[c.playerWeapon];
  736. c.gfx100(getRangeStartGFX());
  737. c.hitDelay = getHitDelay(c.getItems()
  738. .getItemName(c.playerEquipment[c.playerWeapon])
  739. .toLowerCase());
  740. c.projectileStage = 1;
  741. c.oldNpcIndex = i;
  742. if (c.playerEquipment[c.playerWeapon] >= 4212
  743. && c.playerEquipment[c.playerWeapon] <= 4223) {
  744. c.rangeItemUsed = c.playerEquipment[c.playerWeapon];
  745. c.crystalBowArrowCount++;
  746. c.lastArrowUsed = 0;
  747. } else {
  748. c.rangeItemUsed = c.playerEquipment[c.playerArrows];
  749. c.getItems().deleteArrow();
  750. }
  751. fireProjectileNpc();
  752. }
  753.  
  754. if (usingOtherRangeWeapons && !c.usingMagic && !usingBow) { // knives,
  755. // darts,
  756. // etc
  757. // hit
  758. // delay
  759. c.rangeItemUsed = c.playerEquipment[c.playerWeapon];
  760. c.getItems().deleteEquipment();
  761. c.gfx100(getRangeStartGFX());
  762. c.lastArrowUsed = 0;
  763. c.hitDelay = getHitDelay(c.getItems()
  764. .getItemName(c.playerEquipment[c.playerWeapon])
  765. .toLowerCase());
  766. c.projectileStage = 1;
  767. c.oldNpcIndex = i;
  768. if (c.fightMode == 2)
  769. c.attackTimer--;
  770. fireProjectileNpc();
  771. }
  772.  
  773. if (c.usingMagic) { // magic hit delay
  774.  
  775. int pX = c.getX();
  776. int pY = c.getY();
  777. int nX = NPCHandler.npcs[i].getX();
  778. int nY = NPCHandler.npcs[i].getY();
  779. int offX = (pY - nY) * -1;
  780. int offY = (pX - nX) * -1;
  781. c.castingMagic = true;
  782. c.projectileStage = 2;
  783. if (c.MAGIC_SPELLS[c.spellId][3] > 0) {
  784. if (getStartGfxHeight() == 100) {
  785. c.gfx100(c.MAGIC_SPELLS[c.spellId][3]);
  786. } else {
  787. c.gfx0(c.MAGIC_SPELLS[c.spellId][3]);
  788. }
  789. }
  790. if (c.MAGIC_SPELLS[c.spellId][4] > 0) {
  791. c.getPA().createPlayersProjectile(pX, pY, offX, offY,
  792. 50, 78, c.MAGIC_SPELLS[c.spellId][4],
  793. getStartHeight(), getEndHeight(), i + 1, 50);
  794. }
  795. c.hitDelay = getHitDelay(c.getItems()
  796. .getItemName(c.playerEquipment[c.playerWeapon])
  797. .toLowerCase());
  798. c.oldNpcIndex = i;
  799. c.oldSpellId = c.spellId;
  800. c.spellId = 0;
  801. if (!c.autocasting)
  802. c.npcIndex = 0;
  803. }
  804.  
  805. if (usingBow && Config.CRYSTAL_BOW_DEGRADES) {
  806. if (c.playerEquipment[c.playerWeapon] == 4212) {
  807. c.getItems().wearItem(4214, 1, 3);
  808. }
  809.  
  810. if (c.crystalBowArrowCount >= 250) {
  811. switch (c.playerEquipment[c.playerWeapon]) {
  812.  
  813. case 4223: // 1/10 bow
  814. c.getItems().wearItem(-1, 1, 3);
  815. c.sendMessage("Your crystal bow has fully degraded.");
  816. if (!c.getItems().addItem(4207, 1)) {
  817. Server.itemHandler.createGroundItem(c, 4207,
  818. c.getX(), c.getY(), 1, c.getId());
  819. }
  820. c.crystalBowArrowCount = 0;
  821. break;
  822.  
  823. default:
  824. c.getItems().wearItem(
  825. ++c.playerEquipment[c.playerWeapon], 1, 3);
  826. c.sendMessage("Your crystal bow degrades.");
  827. c.crystalBowArrowCount = 0;
  828. break;
  829.  
  830. }
  831. }
  832. }
  833. }
  834. }
  835. }
  836.  
  837. public void delayedHit(final int i) { // npc hit delay
  838. if (NPCHandler.npcs[i] != null) {
  839. if (NPCHandler.npcs[i].isDead) {
  840. c.npcIndex = 0;
  841. return;
  842. }
  843. NPCHandler.npcs[i].facePlayer(c.playerId);
  844.  
  845. if (NPCHandler.npcs[i].underAttackBy > 0
  846. && Server.npcHandler.getsPulled(i)) {
  847. NPCHandler.npcs[i].killerId = c.playerId;
  848. } else if (NPCHandler.npcs[i].underAttackBy < 0
  849. && !Server.npcHandler.getsPulled(i)) {
  850. NPCHandler.npcs[i].killerId = c.playerId;
  851. }
  852. c.lastNpcAttacked = i;
  853. double slayerBonus = 1 + ((double) ((double) c.playerLevel[18] / 99));// getback2
  854. // double slayerBonus = 1.0;
  855.  
  856. if (c.projectileStage == 0 && !c.usingMagic && !c.castingMagic) { // melee
  857. // hit
  858. // damage
  859. int damageOnNPC = (int) (Misc.random(calculateMeleeMaxHit()) * (slayerBonus));
  860. c.clawDamage[0] = (int) Math.round(damageOnNPC / 2);
  861. c.clawDamage[1] = (int) Math.round(damageOnNPC / 2);
  862. c.clawDamage[2] = (int) Math.round(damageOnNPC / 4);
  863. applyNpcMeleeDamage2(i, 1, damageOnNPC);
  864. if (c.doubleHit && !c.usingClaws) {
  865. applyNpcMeleeDamage2(
  866. i,
  867. 2,
  868. Misc.random(calculateMeleeMaxHit()
  869. * (1 + (c.playerLevel[18] / 99))));
  870. }
  871. if (c.doubleHit && c.usingClaws) {
  872. applyNpcMeleeDamage2(i, 2, c.clawDamage[0]);
  873. CycleEventHandler.getSingleton().addEvent(c,
  874. new CycleEvent() {
  875. @Override
  876. public void execute(
  877. CycleEventContainer container) {
  878. container.stop();
  879. }
  880.  
  881. @Override
  882. public void stop() {
  883. applyNpcMeleeDamage2(i, 1, c.clawDamage[1]);
  884. applyNpcMeleeDamage2(i, 2, c.clawDamage[2]);
  885. // System.out.println("yes.");
  886. }
  887. }, 1);
  888. c.usingClaws = false;
  889. }
  890. }
  891.  
  892. if (!c.castingMagic && c.projectileStage > 0) { // range hit damage
  893. int damage = (int) ((double) ((double) Misc
  894. .random(rangeMaxHit()) * (slayerBonus)));
  895. int damage2 = -1;
  896.  
  897. if (c.lastWeaponUsed == 11235 || c.bowSpecShot == 1
  898. || c.cannonSpec == 1)
  899. damage2 = Misc.random(rangeMaxHit())
  900. * (1 + (c.playerLevel[18] / 99));
  901.  
  902. boolean ignoreDef = false;
  903. if (Misc.random(5) == 1
  904. && c.lastArrowUsed == 9243
  905. && (c.playerEquipment[c.playerWeapon] == 9185
  906. || c.playerEquipment[c.playerWeapon] == 15041
  907. || c.playerEquipment[c.playerWeapon] == 7885 || c.playerEquipment[c.playerWeapon] == 7865)) {
  908. ignoreDef = true;
  909. NPCHandler.npcs[i].gfx0(758);
  910. }
  911.  
  912. if (Misc.random(NPCHandler.npcs[i].defence) > Misc
  913. .random(10 + calculateRangeAttack()) && !ignoreDef) {
  914. damage = 0;
  915. } else if (NPCHandler.npcs[i].npcType == 2881
  916. || NPCHandler.npcs[i].npcType == 2883 && !ignoreDef) {
  917. damage = 0;
  918. }
  919.  
  920. if (Misc.random(4) == 1 && c.lastArrowUsed == 9242
  921. && damage > 0) {
  922. NPCHandler.npcs[i].gfx0(754);
  923. damage = NPCHandler.npcs[i].HP / 5;
  924. c.handleHitMask(c.playerLevel[3] / 10);
  925. c.dealDamage(c.playerLevel[3] / 10);
  926. c.gfx0(754);
  927. }
  928.  
  929. if (c.lastWeaponUsed == 11235 || c.bowSpecShot == 1) {
  930. if (Misc.random(NPCHandler.npcs[i].defence) > Misc
  931. .random(10 + calculateRangeAttack()))
  932. damage2 = 0;
  933. }
  934.  
  935. if (c.dbowSpec) {
  936. NPCHandler.npcs[i].gfx100(1100);
  937. if (damage < 8)
  938. damage = 8;
  939. if (damage2 < 8)
  940. damage2 = 8;
  941. c.dbowSpec = false;
  942. }
  943.  
  944. if (damage > 0
  945. && Misc.random(5) == 1
  946. && c.lastArrowUsed == 9244
  947. && (c.playerEquipment[c.playerWeapon] == 9185
  948. || c.playerEquipment[c.playerWeapon] == 7885
  949. || c.playerEquipment[c.playerWeapon] == 15041 || c.playerEquipment[c.playerWeapon] == 7865)) {
  950. damage *= 1.65;
  951. NPCHandler.npcs[i].gfx0(756);
  952. }
  953.  
  954. if (NPCHandler.npcs[i].HP - damage < 0) {
  955. damage = NPCHandler.npcs[i].HP;
  956. }
  957. if (NPCHandler.npcs[i].HP - damage <= 0 && damage2 > 0) {
  958. damage2 = 0;
  959. }
  960. if (c.fightMode == 3) {
  961. c.getPA().addSkillXP((damage * Config.RANGE_EXP_RATE / 3),
  962. 4);
  963. c.getPA().addSkillXP((damage * Config.RANGE_EXP_RATE / 3),
  964. 1);
  965. c.getPA().addSkillXP((damage * Config.RANGE_EXP_RATE / 3),
  966. 3);
  967. c.getPA().refreshSkill(1);
  968. c.getPA().refreshSkill(3);
  969. c.getPA().refreshSkill(4);
  970. } else {
  971. c.getPA().addSkillXP((damage * Config.RANGE_EXP_RATE), 4);
  972. c.getPA().addSkillXP((damage * Config.RANGE_EXP_RATE / 3),
  973. 3);
  974. c.getPA().refreshSkill(3);
  975. c.getPA().refreshSkill(4);
  976. }
  977. boolean dropArrows = true;
  978.  
  979. for (int noArrowId : c.NO_ARROW_DROP) {
  980. if (c.lastWeaponUsed == noArrowId) {
  981. dropArrows = false;
  982. break;
  983. }
  984. }
  985. if(dropArrows) {
  986. c.getItems().dropArrowNpc();
  987. }
  988. //if(c.cannonSpec == 1)
  989. // Server.playerHandler.players[i].gfx100(89);
  990. Server.npcHandler.npcs[i].underAttack = true;
  991. Server.npcHandler.npcs[i].hitDiff = damage;
  992. Server.npcHandler.npcs[i].HP -= damage;
  993.  
  994. if (damage2 != -1) {
  995. if(c.cannonSpec != 1){
  996. Server.npcHandler.npcs[i].hitDiff = damage2;
  997. Server.npcHandler.npcs[i].HP -= damage2;
  998. } else {
  999. c.cannonSpec = 0;
  1000. final int d2 = damage2;
  1001. final int pId = c.playerId;
  1002. final int index = i;
  1003. //int distance = Server.playerHandler.players[pId].distanceToPoint(Server.playerHandler.players[index].getX(), Server.playerHandler.players[index].getY());
  1004. int totalDistance = 2;
  1005.  
  1006. CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
  1007. @Override
  1008. public void execute(CycleEventContainer c) {
  1009. if(Server.playerHandler.players[index] == null)
  1010. return;
  1011. Server.npcHandler.npcs[index].hitDiff = d2;
  1012. Server.npcHandler.npcs[index].HP -= d2;
  1013. c.stop();
  1014. }
  1015.  
  1016. @Override
  1017. public void stop() {
  1018.  
  1019. }
  1020.  
  1021. }, totalDistance);
  1022. }
  1023. }
  1024. if (c.killingNpcIndex != c.oldNpcIndex) {
  1025. c.totalDamageDealt = 0;
  1026. }
  1027. c.killingNpcIndex = c.oldNpcIndex;
  1028. c.totalDamageDealt += damage;
  1029. NPCHandler.npcs[i].hitUpdateRequired = true;
  1030. if (damage2 > -1)
  1031. NPCHandler.npcs[i].hitUpdateRequired2 = true;
  1032. NPCHandler.npcs[i].updateRequired = true;
  1033.  
  1034. } else if (c.projectileStage > 0) { // magic hit damage
  1035. // double slayerBonus = 1+(c.playerLevel[18] / 99);
  1036. int damage = (int) ((double) ((double) Misc
  1037. .random(c.MAGIC_SPELLS[c.oldSpellId][6]) * (slayerBonus)));
  1038. if (godSpells()) {
  1039. if (System.currentTimeMillis() - c.godSpellDelay < Config.GOD_SPELL_CHARGE) {
  1040. damage += Misc.random(10);
  1041. }
  1042. }
  1043. if (c.playerEquipment[c.playerWeapon] == 4170) {// getback
  1044. damage = (damage + damage);
  1045. }
  1046. boolean magicFailed = false;
  1047. // c.npcIndex = 0;
  1048. int bonusAttack = getBonusAttack(i);
  1049. if (Misc.random(NPCHandler.npcs[i].defence) > 10
  1050. + Misc.random(mageAtk()) + bonusAttack) {
  1051. damage = 0;
  1052. magicFailed = true;
  1053. } else if (NPCHandler.npcs[i].npcType == 2881
  1054. || NPCHandler.npcs[i].npcType == 2882) {
  1055. damage = 0;
  1056. magicFailed = true;
  1057. }
  1058.  
  1059. int totalBarraged = 0;
  1060. for (int j = 0; j < NPCHandler.npcs.length; j++) {
  1061. if (NPCHandler.npcs[j] != null
  1062. && NPCHandler.npcs[j].MaxHP > 0) {
  1063. int nX = NPCHandler.npcs[j].getX();
  1064. int nY = NPCHandler.npcs[j].getY();
  1065. int pX = NPCHandler.npcs[i].getX();
  1066. int pY = NPCHandler.npcs[i].getY();
  1067.  
  1068. if ((nX - pX == -1 || nX - pX == 0 || nX - pX == 1)
  1069. && (nY - pY == -1 || nY - pY == 0 || nY - pY == 1)) {
  1070. if (multis() && NPCHandler.npcs[i].inMulti()) {
  1071. Client p = (Client) PlayerHandler.players[c.playerId];
  1072. appendMultiBarrageNPC(j, c.magicFailed);
  1073. totalBarraged++;
  1074. if (Server.npcHandler.goodDistance(
  1075. NPCHandler.npcs[i].absX,
  1076. NPCHandler.npcs[i].absY, c.absX,
  1077. c.absY, 1))
  1078. Server.npcHandler.attackPlayer(p, j);
  1079. }
  1080. }
  1081. }
  1082. }
  1083.  
  1084. if (totalBarraged > 1)
  1085. return;
  1086.  
  1087. if (NPCHandler.npcs[i].HP - damage < 0) {
  1088. damage = NPCHandler.npcs[i].HP;
  1089. }
  1090.  
  1091. c.getPA().addSkillXP(
  1092. (c.MAGIC_SPELLS[c.oldSpellId][7] + damage
  1093. * Config.MAGIC_EXP_RATE), 6);
  1094. c.getPA().addSkillXP(
  1095. (c.MAGIC_SPELLS[c.oldSpellId][7] + damage
  1096. * Config.MAGIC_EXP_RATE / 3), 3);
  1097. c.getPA().refreshSkill(3);
  1098. c.getPA().refreshSkill(6);
  1099. if (getEndGfxHeight() == 100 && !magicFailed) { // end GFX
  1100. NPCHandler.npcs[i].gfx100(c.MAGIC_SPELLS[c.oldSpellId][5]);
  1101. } else if (!magicFailed) {
  1102. NPCHandler.npcs[i].gfx0(c.MAGIC_SPELLS[c.oldSpellId][5]);
  1103. }
  1104.  
  1105. if (magicFailed) {
  1106. NPCHandler.npcs[i].gfx100(85);
  1107. }
  1108. if (!magicFailed) {
  1109. int freezeDelay = getFreezeTime(); // freeze
  1110. if (freezeDelay > 0 && NPCHandler.npcs[i].freezeTimer == 0) {
  1111. NPCHandler.npcs[i].freezeTimer = freezeDelay;
  1112. }
  1113. switch (c.MAGIC_SPELLS[c.oldSpellId][0]) {
  1114. case 12901:
  1115. case 12919: // blood spells
  1116. case 12911:
  1117. case 12929:
  1118. int heal = Misc.random(damage / 2);
  1119. if (c.playerLevel[3] + heal >= c.getPA().getLevelForXP(
  1120. c.playerXP[3])) {
  1121. c.playerLevel[3] = c.getPA().getLevelForXP(
  1122. c.playerXP[3]);
  1123. } else {
  1124. c.playerLevel[3] += heal;
  1125. }
  1126. c.getPA().refreshSkill(3);
  1127. break;
  1128. }
  1129.  
  1130. }
  1131. NPCHandler.npcs[i].underAttack = true;
  1132. if (c.MAGIC_SPELLS[c.oldSpellId][6] != 0) {
  1133. NPCHandler.npcs[i].hitDiff = damage;
  1134. NPCHandler.npcs[i].HP -= damage;
  1135. NPCHandler.npcs[i].hitUpdateRequired = true;
  1136. c.totalDamageDealt += damage;
  1137. }
  1138. c.killingNpcIndex = c.oldNpcIndex;
  1139. NPCHandler.npcs[i].updateRequired = true;
  1140. c.usingMagic = false;
  1141. c.castingMagic = false;
  1142. c.oldSpellId = 0;
  1143. }
  1144. }
  1145.  
  1146. if (c.bowSpecShot <= 0) {
  1147. c.oldNpcIndex = 0;
  1148. c.projectileStage = 0;
  1149. c.doubleHit = false;
  1150. c.lastWeaponUsed = 0;
  1151. c.bowSpecShot = 0;
  1152. }
  1153. if (c.bowSpecShot >= 2) {
  1154. c.bowSpecShot = 0;
  1155. // c.attackTimer =
  1156. // getAttackDelay(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1157. }
  1158. if (c.bowSpecShot == 1) {
  1159. fireProjectileNpc();
  1160. c.hitDelay = 2;
  1161. c.bowSpecShot = 0;
  1162. }
  1163. }
  1164.  
  1165. public void applyNpcMeleeDamage2(int i, int damageMask, int damage) {
  1166. c.previousDamage = damage;
  1167. boolean fullVeracsEffect = c.getPA().fullVeracs()
  1168. && Misc.random(3) == 1;
  1169. if (NPCHandler.npcs[i].HP - damage < 0) {
  1170. damage = NPCHandler.npcs[i].HP;
  1171. }
  1172.  
  1173. if (!fullVeracsEffect) {
  1174. if (Misc.random(NPCHandler.npcs[i].defence) > Misc.random(15)
  1175. + Misc.random(calculateMeleeAttack())) {
  1176. damage = 0;
  1177. } else if (NPCHandler.npcs[i].npcType == 2882
  1178. || NPCHandler.npcs[i].npcType == 2883) {
  1179. damage = 0;
  1180. }
  1181. }
  1182. boolean guthansEffect = false;
  1183. if (c.getPA().fullGuthans()) {
  1184. if (Misc.random(3) == 1) {
  1185. guthansEffect = true;
  1186. }
  1187. }
  1188. if (c.fightMode == 3) {
  1189. c.getPA().addSkillXP((damage * Config.MELEE_EXP_RATE / 3), 0);
  1190. c.getPA().addSkillXP((damage * Config.MELEE_EXP_RATE / 3), 1);
  1191. c.getPA().addSkillXP((damage * Config.MELEE_EXP_RATE / 3), 2);
  1192. c.getPA().addSkillXP((damage * Config.MELEE_EXP_RATE / 3), 3);
  1193. c.getPA().refreshSkill(0);
  1194. c.getPA().refreshSkill(1);
  1195. c.getPA().refreshSkill(2);
  1196. c.getPA().refreshSkill(3);
  1197. } else {
  1198. c.getPA().addSkillXP((damage * Config.MELEE_EXP_RATE), c.fightMode);
  1199. c.getPA().addSkillXP((damage * Config.MELEE_EXP_RATE / 3), 3);
  1200. c.getPA().refreshSkill(c.fightMode);
  1201. c.getPA().refreshSkill(3);
  1202. }
  1203. if (damage > 0 && guthansEffect) {
  1204. c.playerLevel[3] += damage;
  1205. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  1206. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  1207. c.getPA().refreshSkill(3);
  1208. NPCHandler.npcs[i].gfx0(398);
  1209. }
  1210. NPCHandler.npcs[i].underAttack = true;
  1211. // Server.npcHandler.npcs[i].killerId = c.playerId;
  1212. c.killingNpcIndex = c.npcIndex;
  1213. c.lastNpcAttacked = i;
  1214. switch (c.specEffect) {
  1215. case 4:
  1216. if (damage > 0) {
  1217. if (c.playerLevel[3] + damage > c.getLevelForXP(c.playerXP[3]))
  1218. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  1219. ;
  1220. else
  1221. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  1222. else
  1223. c.playerLevel[3] += damage;
  1224. c.getPA().refreshSkill(3);
  1225. c.specEffect = 0;
  1226. }
  1227. break;
  1228. case 5:
  1229. c.clawDelay = 2;
  1230. break;
  1231.  
  1232. }
  1233. switch (damageMask) {
  1234. case 1:
  1235. NPCHandler.npcs[i].hitDiff = damage;
  1236. NPCHandler.npcs[i].HP -= damage;
  1237. c.totalDamageDealt += damage;
  1238. NPCHandler.npcs[i].hitUpdateRequired = true;
  1239. NPCHandler.npcs[i].updateRequired = true;
  1240. break;
  1241.  
  1242. case 2:
  1243. NPCHandler.npcs[i].hitDiff2 = damage;
  1244. NPCHandler.npcs[i].HP -= damage;
  1245. c.totalDamageDealt += damage;
  1246. NPCHandler.npcs[i].hitUpdateRequired2 = true;
  1247. NPCHandler.npcs[i].updateRequired = true;
  1248. c.doubleHit = false;
  1249. break;
  1250.  
  1251. }
  1252. }
  1253.  
  1254. public void applyPlayerHit(int i, int damage) {
  1255. int damageMask = 1;
  1256. c.previousDamage = damage;
  1257. Client o = (Client) PlayerHandler.players[i];
  1258. if (o == null) {
  1259. return;
  1260. }
  1261. int damage1 = damage;
  1262. if (PlayerHandler.players[i].playerLevel[3] - damage1 < 0) {
  1263. damage1 = PlayerHandler.players[i].playerLevel[3];
  1264. }
  1265. if (o.vengOn && damage1 > 0)
  1266. appendVengeance(i, damage1);
  1267. if (damage1 > 0)
  1268. applyRecoil(damage1, i);
  1269.  
  1270. PlayerHandler.players[i].logoutDelay = System.currentTimeMillis();
  1271. PlayerHandler.players[i].underAttackBy = c.playerId;
  1272. PlayerHandler.players[i].killerId = c.playerId;
  1273. PlayerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  1274. if (c.killedBy != PlayerHandler.players[i].playerId)
  1275. c.totalPlayerDamageDealt = 0;
  1276. c.killedBy = PlayerHandler.players[i].playerId;
  1277. applySmite(i, damage1);
  1278. if (c.prayerActive[3] == true)
  1279. applySmite(i, damage1 * 3);
  1280. switch (damageMask) {
  1281. case 1:
  1282. PlayerHandler.players[i].dealDamage(damage1);
  1283. PlayerHandler.players[i].damageTaken[c.playerId] += damage1;
  1284. c.totalPlayerDamageDealt += damage1;
  1285. PlayerHandler.players[i].updateRequired = true;
  1286. o.getPA().refreshSkill(3);
  1287. break;
  1288. }
  1289. PlayerHandler.players[i].handleHitMask(damage1);
  1290. }
  1291.  
  1292. public void applyNpcMeleeDamage(int i, int damageMask) {
  1293. double slayerBonus = 1 + ((double) ((double) c.playerLevel[18] / 99));
  1294. // double slayerBonus = 1.0;
  1295. int damage = (int) ((double) ((double) Misc
  1296. .random(calculateMeleeMaxHit()) * (slayerBonus)));
  1297. boolean fullVeracsEffect = c.getPA().fullVeracs()
  1298. && Misc.random(3) == 1;
  1299. if (NPCHandler.npcs[i].HP - damage < 0) {
  1300. damage = NPCHandler.npcs[i].HP;
  1301. }
  1302.  
  1303. if (!fullVeracsEffect) {
  1304. if (Misc.random(Server.npcHandler.npcs[i].defence) > 10 + Misc.random(calculateMeleeAttack())) {
  1305. damage = 0;
  1306. } else if (Server.npcHandler.npcs[i].npcType == 2882 || Server.npcHandler.npcs[i].npcType == 2883) {
  1307. damage = 0;
  1308. }
  1309. }
  1310. boolean guthansEffect = false;
  1311. if (c.getPA().fullGuthans()) {
  1312. if (Misc.random(3) == 1) {
  1313. guthansEffect = true;
  1314. }
  1315. }
  1316. if (c.getPA().salveAmulet()) {
  1317. for (int undead : Config.UNDEAD_NPCS) {
  1318. if (NPCHandler.npcs[i].npcType == undead && damage < 0) {
  1319. damage = salveDamage();
  1320. if (damage > NPCHandler.npcs[i].HP) {
  1321. damage = NPCHandler.npcs[i].HP;
  1322. } else {
  1323. damage = damage;
  1324. }
  1325. }
  1326. }
  1327. }
  1328. if(c.fightMode == 3) {
  1329. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 0);
  1330. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 1);
  1331. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 2);
  1332. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 3);
  1333. c.getPA().refreshSkill(0);
  1334. c.getPA().refreshSkill(1);
  1335. c.getPA().refreshSkill(2);
  1336. c.getPA().refreshSkill(3);
  1337. } else {
  1338. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE), c.fightMode);
  1339. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 3);
  1340. c.getPA().refreshSkill(c.fightMode);
  1341. c.getPA().refreshSkill(3);
  1342. }
  1343. if (damage > 0 && guthansEffect) {
  1344. c.playerLevel[3] += damage;
  1345. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  1346. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  1347. c.getPA().refreshSkill(3);
  1348. Server.npcHandler.npcs[i].gfx0(398);
  1349. }
  1350. Server.npcHandler.npcs[i].underAttack = true;
  1351. //Server.npcHandler.npcs[i].killerId = c.playerId;
  1352. c.killingNpcIndex = c.npcIndex;
  1353. c.lastNpcAttacked = i;
  1354. switch (c.specEffect) {
  1355. case 4:
  1356. if (damage > 0) {
  1357. if (c.playerLevel[3] + damage > c.getLevelForXP(c.playerXP[3]))
  1358. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]));
  1359. else
  1360. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  1361. else
  1362. c.playerLevel[3] += damage;
  1363. c.getPA().refreshSkill(3);
  1364. }
  1365. break;
  1366.  
  1367. }
  1368. switch(damageMask) {
  1369. case 1:
  1370. Server.npcHandler.npcs[i].hitDiff = damage;
  1371. Server.npcHandler.npcs[i].HP -= damage;
  1372. c.totalDamageDealt += damage;
  1373. Server.npcHandler.npcs[i].hitUpdateRequired = true;
  1374. //Server.npcHandler.npcs[i].hitUpdateRequired2 = true;
  1375. Server.npcHandler.npcs[i].updateRequired = true;
  1376. break;
  1377.  
  1378. case 2:
  1379. Server.npcHandler.npcs[i].hitDiff2 = damage;
  1380. Server.npcHandler.npcs[i].HP -= damage;
  1381. c.totalDamageDealt += damage;
  1382. Server.npcHandler.npcs[i].hitUpdateRequired2 = true;
  1383. c.doubleHit = false;
  1384. break;
  1385.  
  1386. }
  1387. }
  1388.  
  1389. public void fireProjectileNpc() {
  1390. if(c.oldNpcIndex > 0) {
  1391. if(Server.npcHandler.npcs[c.oldNpcIndex] != null) {
  1392. c.projectileStage = 2;
  1393. int pX = c.getX();
  1394. int pY = c.getY();
  1395. int nX = Server.npcHandler.npcs[c.oldNpcIndex].getX();
  1396. int nY = Server.npcHandler.npcs[c.oldNpcIndex].getY();
  1397. int offX = (pY - nY)* -1;
  1398. int offY = (pX - nX)* -1;
  1399. c.getPA().createPlayersProjectile(pX, pY, offX, offY, 50, getProjectileSpeed(), getRangeProjectileGFX(), 43, 31, c.oldNpcIndex + 1, getStartDelay());
  1400. if (usingDbow())
  1401. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, getProjectileSpeed(), getRangeProjectileGFX(), 60, 31, c.oldNpcIndex + 1, getStartDelay(), 35);
  1402. }
  1403. }
  1404. }
  1405.  
  1406. /**
  1407. * Attack Players, same as npc tbh xD
  1408. **/
  1409.  
  1410. public void attackPlayer(int i) {
  1411.  
  1412.  
  1413. /*if(c.curseActive[18]) { // SoulSplit GFX's - CAUSES CRASH
  1414. if(c.oldPlayerIndex > 0) {
  1415. if(Server.playerHandler.players[c.oldPlayerIndex] != null) {
  1416. try {
  1417. final int pX = c.getX();
  1418. final int pY = c.getY();
  1419. final int nX = Server.playerHandler.players[i].getX();
  1420. final int nY = Server.playerHandler.players[i].getY();
  1421. final int offX = (pY - nY)* -1;
  1422. final int offY = (pX - nX)* -1;
  1423. c.SSPLIT = true;
  1424. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 50, 2263, 9, 9, - c.oldPlayerIndex - 1, 24, 0);
  1425. Server.playerHandler.players[c.oldPlayerIndex].gfx0(2264); // 1738
  1426. c.SSPLIT = false;
  1427. } catch (Exception e) {
  1428. e.printStackTrace();
  1429. }
  1430. }
  1431. }
  1432. }*/
  1433.  
  1434. if (Server.playerHandler.players[i] != null) {
  1435.  
  1436.  
  1437. if (PlayerHandler.players[i].hasPin) {
  1438. c.sendMessage("This player is currently typing in there account pin!");
  1439. return;
  1440. }
  1441.  
  1442. if(c.getItems().playerHasItem(7671,1) || c.playerEquipment[c.playerHands] == 7671) {
  1443. for(int x = 0; x < 40; x++){
  1444. if(c.prayerActive[x]) {
  1445. c.getCombat().resetPrayers();
  1446. c.sendMessage("@red@You can't pray with these boxing gloves!");
  1447. }
  1448. }
  1449.  
  1450. }
  1451.  
  1452. if(c.lastWeaponUsed > 862 && c.lastWeaponUsed < 877 || c.lastWeaponUsed == 13022) {
  1453. c.playerIndex = 0;
  1454. }
  1455.  
  1456. if(c.getItems().playerHasItem(7671,1) || c.playerEquipment[c.playerHands] == 7671) {
  1457. for(int z = 0; z < 20; z++){
  1458. c.playerLevel[z] = c.playerLevel[z];
  1459. if(c.playerLevel[z] > 99) {
  1460. c.playerLevel[z] = 99;
  1461. c.sendMessage("@red@You need to bank your boxing gloves before you can drink this!");
  1462. c.getPA().refreshSkill(z);
  1463. return;
  1464. }
  1465. }
  1466. }
  1467.  
  1468.  
  1469. if (Server.playerHandler.players[i].isDead) {
  1470. resetPlayerAttack();
  1471. return;
  1472. }
  1473.  
  1474. if(c.respawnTimer > 0 || Server.playerHandler.players[i].respawnTimer > 0) {
  1475. resetPlayerAttack();
  1476. return;
  1477. }
  1478.  
  1479. /*if (c.teleTimer > 0 || Server.playerHandler.players[i].teleTimer > 0) {
  1480. resetPlayerAttack();
  1481. return;
  1482. }*/
  1483.  
  1484. if(!c.getCombat().checkReqs()) {
  1485. return;
  1486. }
  1487.  
  1488.  
  1489.  
  1490. boolean sameSpot = c.absX == Server.playerHandler.players[i].getX() && c.absY == Server.playerHandler.players[i].getY();
  1491. if(!c.goodDistance(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), c.getX(), c.getY(), 25) && !sameSpot) {
  1492. resetPlayerAttack();
  1493. return;
  1494. }
  1495.  
  1496. if(Server.playerHandler.players[i].respawnTimer > 0) {
  1497. Server.playerHandler.players[i].playerIndex = 0;
  1498. resetPlayerAttack();
  1499. return;
  1500. }
  1501.  
  1502. if (Server.playerHandler.players[i].heightLevel != c.heightLevel) {
  1503. resetPlayerAttack();
  1504. return;
  1505. }
  1506. //c.sendMessage("Made it here0.");
  1507. c.followId = i;
  1508. c.followId2 = 0;
  1509. if(c.attackTimer <= 0) {
  1510. c.lastAttacked = c.playerIndex;
  1511. c.usingBow = false;
  1512. c.specEffect = 0;
  1513. c.usingRangeWeapon = false;
  1514. c.rangeItemUsed = 0;
  1515. boolean usingBow = false;
  1516. boolean usingArrows = false;
  1517. boolean usingOtherRangeWeapons = false;
  1518. boolean usingCross = c.playerEquipment[c.playerWeapon] == 9185 || c.playerEquipment[c.playerWeapon] == 7885 || c.playerEquipment[c.playerWeapon] == 15041;
  1519. c.projectileStage = 0;
  1520.  
  1521. if (c.absX == Server.playerHandler.players[i].absX && c.absY == Server.playerHandler.players[i].absY) {
  1522. if (c.freezeTimer > 0) {
  1523. resetPlayerAttack();
  1524. return;
  1525. }
  1526. c.followId = i;
  1527. c.attackTimer = 0;
  1528. return;
  1529. }
  1530.  
  1531. /*if ((c.inPirateHouse() && !Server.playerHandler.players[i].inPirateHouse()) || (Server.playerHandler.players[i].inPirateHouse() && !c.inPirateHouse())) {
  1532. resetPlayerAttack();
  1533. return;
  1534. }*/
  1535. //c.sendMessage("Made it here1.");
  1536. if(!c.usingMagic) {
  1537. for (int bowId : c.BOWS) {
  1538. if(c.playerEquipment[c.playerWeapon] == bowId) {
  1539. usingBow = true;
  1540. for (int arrowId : c.ARROWS) {
  1541. if(c.playerEquipment[c.playerArrows] == arrowId) {
  1542. usingArrows = true;
  1543. }
  1544. }
  1545. }
  1546. }
  1547.  
  1548. if(c.playerEquipment[c.playerWeapon] == 13022){
  1549. usingBow = true;
  1550. }
  1551.  
  1552. for (int otherRangeId : c.OTHER_RANGE_WEAPONS) {
  1553. if(c.playerEquipment[c.playerWeapon] == otherRangeId) {
  1554. usingOtherRangeWeapons = true;
  1555. }
  1556. }
  1557. }
  1558. if (c.autocasting && c.playerMagicBook != 2) {
  1559. c.spellId = c.autocastId;
  1560. c.usingMagic = true;
  1561. }
  1562.  
  1563. if(c.playerEquipment[c.playerWeapon] == 22494) {
  1564. c.autocasting = true;
  1565. c.spellId = 52;
  1566. c.usingMagic = true;
  1567. }
  1568.  
  1569. //c.sendMessage("Made it here2.");
  1570. if(c.spellId > 0) {
  1571. c.usingMagic = true;
  1572. }
  1573. c.attackTimer = getAttackDelay(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1574.  
  1575. if(c.duelRule[9]){
  1576. boolean canUseWeapon = false;
  1577. for(int funWeapon: Config.FUN_WEAPONS) {
  1578. if(c.playerEquipment[c.playerWeapon] == funWeapon) {
  1579. canUseWeapon = true;
  1580. }
  1581. }
  1582. if(!canUseWeapon) {
  1583. c.sendMessage("You can only use fun weapons in this duel!");
  1584. resetPlayerAttack();
  1585. return;
  1586. }
  1587. }
  1588. //c.sendMessage("Made it here3.");
  1589. if(c.duelRule[2] && (usingBow || usingOtherRangeWeapons)) {
  1590. c.sendMessage("Range has been disabled in this duel!");
  1591. return;
  1592. }
  1593. if(c.duelRule[3] && (!usingBow && !usingOtherRangeWeapons && !c.usingMagic)) {
  1594. c.sendMessage("Melee has been disabled in this duel!");
  1595. return;
  1596. }
  1597.  
  1598. if(c.duelRule[4] && c.usingMagic) {
  1599. c.sendMessage("Magic has been disabled in this duel!");
  1600. resetPlayerAttack();
  1601. return;
  1602. }
  1603.  
  1604. /*if(c.inBoxIsland() && c.usingMagic) {
  1605. c.sendMessage("You can't use magic here!");
  1606. resetPlayerAttack();
  1607. return;
  1608. }*/
  1609.  
  1610. if((!c.goodDistance(c.getX(), c.getY(), Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), 4) && (usingOtherRangeWeapons && !usingBow && !c.usingMagic && !usingCrystalBow()))
  1611. || (!c.goodDistance(c.getX(), c.getY(), Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), 2) && (!usingOtherRangeWeapons && usingHally() && !usingBow && !usingCrystalBow() && !c.usingMagic))
  1612. || (!c.goodDistance(c.getX(), c.getY(), Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), getRequiredDistance()) && (!usingOtherRangeWeapons && !usingHally() && !usingBow && !c.usingMagic && !usingCrystalBow()))
  1613. || (!c.goodDistance(c.getX(), c.getY(), Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), 10) && (usingBow || c.usingMagic || usingCrystalBow()))) {
  1614. //c.sendMessage("Setting attack timer to 1");
  1615. c.attackTimer = 1;
  1616. if (!usingBow && !c.usingMagic && !usingOtherRangeWeapons && c.freezeTimer > 0)
  1617. resetPlayerAttack();
  1618. return;
  1619. }
  1620.  
  1621. if(!usingCross && !usingArrows && usingBow && (c.playerEquipment[c.playerWeapon] < 4212 || c.playerEquipment[c.playerWeapon] > 4223) && c.playerEquipment[c.playerWeapon] != 13022 && !c.usingMagic) {
  1622. c.sendMessage("You have run out of arrows!");
  1623. c.stopMovement();
  1624. resetPlayerAttack();
  1625. return;
  1626. }
  1627. if(correctBowAndArrows() < c.playerEquipment[c.playerArrows] && Config.CORRECT_ARROWS && usingBow && !usingCrystalBow() && c.playerEquipment[c.playerWeapon] != 15041 && c.playerEquipment[c.playerWeapon] != 7885 && (c.playerEquipment[c.playerWeapon] != 9185&& c.playerEquipment[c.playerWeapon] != 15041 && c.playerEquipment[c.playerWeapon] != 7885) && !c.usingMagic) {
  1628. c.sendMessage("You can't use "+c.getItems().getItemName(c.playerEquipment[c.playerArrows]).toLowerCase()+"s with a "+c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase()+".");
  1629. c.stopMovement();
  1630. resetPlayerAttack();
  1631. return;
  1632. }
  1633. if ((c.playerEquipment[c.playerWeapon] == 9185 || c.playerEquipment[c.playerWeapon] == 7885 || c.playerEquipment[c.playerWeapon] == 15041) && !properBolts() && !c.usingMagic) {
  1634. c.sendMessage("You must use bolts with a crossbow.");
  1635. c.stopMovement();
  1636. resetPlayerAttack();
  1637. return;
  1638. }
  1639. if (c.playerEquipment[c.playerWeapon] == 13022 && c.playerEquipment[c.playerArrows] > 2){
  1640. c.sendMessage("Your ammunition slot must be empty in order to use hand cannon!");
  1641. c.stopMovement();
  1642. resetPlayerAttack();
  1643. return;
  1644. }
  1645.  
  1646. if(usingBow || c.spellId > 0 || usingOtherRangeWeapons || usingHally()) {
  1647. c.stopMovement();
  1648. }
  1649.  
  1650. if(!checkMagicReqs(c.spellId)) {
  1651. c.stopMovement();
  1652. resetPlayerAttack();
  1653. return;
  1654. }
  1655.  
  1656. c.faceUpdate(i+32768);
  1657.  
  1658. if(c.duelStatus != 5) {
  1659. if(!c.attackedPlayers.contains(c.playerIndex) && !Server.playerHandler.players[c.playerIndex].attackedPlayers.contains(c.playerId)) {
  1660. c.attackedPlayers.add(c.playerIndex);
  1661. c.isSkulled = true;
  1662. c.skullTimer = Config.SKULL_TIMER;
  1663. if (c.redSkull != true)
  1664. c.headIconPk = 0;
  1665. c.getPA().requestUpdates();
  1666. }
  1667. }
  1668. c.specAccuracy = 1.0;
  1669. c.specDamage = 1.0;
  1670. c.delayedDamage = c.delayedDamage2 = 0;
  1671. if(c.usingSpecial && !c.usingMagic) {
  1672. /*if(c.underAttackBy == 0 && c.isInEdge()) {//anti-rush, testing how this works out
  1673. c.sendMessage("No rushing in Edgeville!");//well it didn't work out...
  1674. c.usingSpecial = false;
  1675. c.getItems().updateSpecialBar();
  1676. resetPlayerAttack();
  1677. return;
  1678. }*/
  1679. if(c.duelRule[10] && c.duelStatus == 5) {
  1680. c.sendMessage("Special attacks have been disabled during this duel!");
  1681. c.usingSpecial = false;
  1682. c.getItems().updateSpecialBar();
  1683. resetPlayerAttack();
  1684. return;
  1685. }
  1686. if(checkSpecAmount(c.playerEquipment[c.playerWeapon])){
  1687. c.lastArrowUsed = c.playerEquipment[c.playerArrows];
  1688. activateSpecial(c.playerEquipment[c.playerWeapon], i);
  1689. c.followId = c.playerIndex;
  1690. return;
  1691. } else {
  1692. c.sendMessage("You don't have the required special energy to use this attack.");
  1693. c.usingSpecial = false;
  1694. c.getItems().updateSpecialBar();
  1695. c.playerIndex = 0;
  1696. return;
  1697. }
  1698. }
  1699.  
  1700. if(!c.usingMagic && c.playerEquipment[c.playerWeapon] != 22494) {
  1701. c.startAnimation(getWepAnim(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase()));
  1702. c.mageFollow = false;
  1703. } else {
  1704. c.startAnimation(c.MAGIC_SPELLS[c.spellId][2]);
  1705. c.mageFollow = true;
  1706. c.followId = c.playerIndex;
  1707. }
  1708.  
  1709. Server.playerHandler.players[i].underAttackBy = c.playerId;
  1710. Server.playerHandler.players[i].logoutDelay = System.currentTimeMillis();
  1711. Server.playerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  1712. Server.playerHandler.players[i].killerId = c.playerId;
  1713. c.lastArrowUsed = 0;
  1714. c.rangeItemUsed = 0;
  1715. if(!usingBow && !c.usingMagic && !usingOtherRangeWeapons) { // melee hit delay
  1716. c.followId = Server.playerHandler.players[c.playerIndex].playerId;
  1717. c.getPA().followPlayer();
  1718. c.hitDelay = getHitDelay(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1719. c.delayedDamage = Misc.random(calculateMeleeMaxHit());
  1720. c.projectileStage = 0;
  1721. c.oldPlayerIndex = i;
  1722. }
  1723.  
  1724. if(usingBow && !usingOtherRangeWeapons && !c.usingMagic || usingCross) { // range hit delay
  1725. if(c.playerEquipment[c.playerWeapon] >= 4212 && c.playerEquipment[c.playerWeapon] <= 4223) {
  1726. c.rangeItemUsed = c.playerEquipment[c.playerWeapon];
  1727. c.crystalBowArrowCount++;
  1728. } else {
  1729. c.rangeItemUsed = c.playerEquipment[c.playerArrows];
  1730. c.getItems().deleteArrow();
  1731. }
  1732. if (c.fightMode == 2)
  1733. c.attackTimer--;
  1734. if (usingCross)
  1735. c.usingBow = true;
  1736. c.followId = Server.playerHandler.players[c.playerIndex].playerId;
  1737. c.getPA().followPlayer();
  1738. c.lastWeaponUsed = c.playerEquipment[c.playerWeapon];
  1739. c.lastArrowUsed = c.playerEquipment[c.playerArrows];
  1740. c.gfx100(getRangeStartGFX());
  1741. c.hitDelay = getHitDelay(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1742. c.projectileStage = 1;
  1743. c.oldPlayerIndex = i;
  1744. fireProjectilePlayer();
  1745. }
  1746.  
  1747. if(c.playerEquipment[c.playerWeapon] == 13022){
  1748. c.rangeItemUsed = c.playerEquipment[c.playerWeapon];
  1749. c.usingRangeWeapon = true;
  1750. c.usingBow = true;
  1751. c.followId = Server.playerHandler.players[c.playerIndex].playerId;
  1752. c.getPA().followPlayer();
  1753. c.gfx100(getRangeStartGFX());
  1754. if (c.fightMode == 2)
  1755. c.attackTimer--;
  1756. c.hitDelay = getHitDelay(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1757. c.projectileStage = 1;
  1758. c.oldPlayerIndex = i;
  1759. fireProjectilePlayer();
  1760. }
  1761.  
  1762. if(usingOtherRangeWeapons) { // knives, darts, etc hit delay
  1763. c.rangeItemUsed = c.playerEquipment[c.playerWeapon];
  1764. c.getItems().deleteEquipment();
  1765. c.usingRangeWeapon = true;
  1766. c.followId = Server.playerHandler.players[c.playerIndex].playerId;
  1767. c.getPA().followPlayer();
  1768. c.gfx100(getRangeStartGFX());
  1769. if (c.fightMode == 2)
  1770. c.attackTimer--;
  1771. c.hitDelay = getHitDelay(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1772. c.projectileStage = 1;
  1773. c.oldPlayerIndex = i;
  1774. fireProjectilePlayer();
  1775. }
  1776.  
  1777. if(c.usingMagic) { // magic hit delay
  1778. int pX = c.getX();
  1779. int pY = c.getY();
  1780. int nX = Server.playerHandler.players[i].getX();
  1781. int nY = Server.playerHandler.players[i].getY();
  1782. int offX = (pY - nY)* -1;
  1783. int offY = (pX - nX)* -1;
  1784. c.castingMagic = true;
  1785. c.projectileStage = 2;
  1786. if(c.MAGIC_SPELLS[c.spellId][3] > 0) {
  1787. if(getStartGfxHeight() == 100) {
  1788. c.gfx100(c.MAGIC_SPELLS[c.spellId][3]);
  1789. } else {
  1790. c.gfx0(c.MAGIC_SPELLS[c.spellId][3]);
  1791. }
  1792. }
  1793. if(c.MAGIC_SPELLS[c.spellId][4] > 0) {
  1794. c.getPA().createPlayersProjectile(pX, pY, offX, offY, 50, 78, c.MAGIC_SPELLS[c.spellId][4], getStartHeight(), getEndHeight(), -i - 1, getStartDelay());
  1795. }
  1796. if (c.autocastId > 0) {
  1797. c.followId = c.playerIndex;
  1798. c.followDistance = 5;
  1799. }
  1800. c.hitDelay = getHitDelay(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1801. c.oldPlayerIndex = i;
  1802. c.oldSpellId = c.spellId;
  1803. c.spellId = 0;
  1804. Client o = (Client)Server.playerHandler.players[i];
  1805. if(c.MAGIC_SPELLS[c.oldSpellId][0] == 12891 && o.isMoving) {
  1806. //c.sendMessage("Barrage projectile..");
  1807. c.getPA().createPlayersProjectile(pX, pY, offX, offY, 50, 85, 368, 25, 25, -i - 1, getStartDelay());
  1808. }
  1809. if(Misc.random(o.getCombat().mageDef()) > Misc.random(mageAtk())) {
  1810. c.magicFailed = true;
  1811. } else {
  1812. c.magicFailed = false;
  1813. }
  1814. int freezeDelay = getFreezeTime();//freeze time
  1815. if(freezeDelay > 0 && Server.playerHandler.players[i].freezeTimer <= -3 && !c.magicFailed) {
  1816. Server.playerHandler.players[i].freezeTimer = freezeDelay;
  1817. o.resetWalkingQueue();
  1818. o.sendMessage("You have been frozen.");
  1819. o.frozenBy = c.playerId;
  1820. }
  1821. if (!c.autocasting && c.spellId <= 0)
  1822. c.playerIndex = 0;
  1823. }
  1824. if(usingBow && Config.CRYSTAL_BOW_DEGRADES) { // crystal bow degrading
  1825. if(c.playerEquipment[c.playerWeapon] == 4212) { // new crystal bow becomes full bow on the first shot
  1826. c.getItems().wearItem(4214, 1, 3);
  1827. }
  1828.  
  1829. if(c.crystalBowArrowCount >= 250){
  1830. switch(c.playerEquipment[c.playerWeapon]) {
  1831.  
  1832. case 4223: // 1/10 bow
  1833. c.getItems().wearItem(-1, 1, 3);
  1834. c.sendMessage("Your crystal bow has fully degraded.");
  1835. if(!c.getItems().addItem(4207, 1)) {
  1836. Server.itemHandler.createGroundItem(c, 4207, c.getX(), c.getY(), 1, c.getId());
  1837. }
  1838. c.crystalBowArrowCount = 0;
  1839. break;
  1840.  
  1841. default:
  1842. c.getItems().wearItem(++c.playerEquipment[c.playerWeapon], 1, 3);
  1843. c.sendMessage("Your crystal bow degrades.");
  1844. c.crystalBowArrowCount = 0;
  1845. break;
  1846. }
  1847. }
  1848. }
  1849. }
  1850. }
  1851. }
  1852.  
  1853. public boolean usingCrystalBow() {
  1854. return c.playerEquipment[c.playerWeapon] >= 4212 && c.playerEquipment[c.playerWeapon] <= 4223;
  1855. }
  1856.  
  1857. public void appendVengeance(int otherPlayer, int damage) {
  1858. if(c.getItems().playerHasItem(7671,1) || c.playerEquipment[c.playerHands] == 7671) {
  1859. c.sendMessage("You can't use Vengeance with boxing gloves!");
  1860. return;
  1861. }
  1862. if (damage <= 0)
  1863. return;
  1864. Player o = Server.playerHandler.players[otherPlayer];
  1865. o.forcedText = "Taste Vengeance!";
  1866. o.forcedChatUpdateRequired = true;
  1867. o.updateRequired = true;
  1868. o.vengOn = false;
  1869.  
  1870. if(c.playerEquipment[o.playerWeapon] == 22494){
  1871. if(damage > 30)
  1872. damage = 30 - Misc.random(5);
  1873. }
  1874.  
  1875. if ((o.playerLevel[3] - damage) > 0) {
  1876. damage = (int)(damage * 0.75);
  1877. if (damage > c.playerLevel[3]) {
  1878. damage = c.playerLevel[3];
  1879. }
  1880. c.setHitDiff2(damage);
  1881. c.setHitUpdateRequired2(true);
  1882. c.playerLevel[3] -= damage;
  1883. c.getPA().refreshSkill(3);
  1884. }
  1885. c.updateRequired = true;
  1886. }
  1887.  
  1888. public void playerDelayedHit(int i) {
  1889. if (Server.playerHandler.players[i] != null) {
  1890. if (Server.playerHandler.players[i].isDead || c.isDead || Server.playerHandler.players[i].playerLevel[3] <= 0 || c.playerLevel[3] <= 0) {
  1891. c.playerIndex = 0;
  1892. return;
  1893. }
  1894. if (Server.playerHandler.players[i].respawnTimer > 0) {
  1895. c.faceUpdate(0);
  1896. c.playerIndex = 0;
  1897. return;
  1898. }
  1899. Client o = (Client) Server.playerHandler.players[i];
  1900. o.getPA().removeAllWindows();
  1901. if (o.playerIndex <= 0 && o.npcIndex <= 0) {
  1902. if (o.autoRet == 1) {
  1903. o.playerIndex = c.playerId;
  1904. }
  1905. }
  1906. if(o.attackTimer <= 3 || o.attackTimer == 0 && o.playerIndex == 0 && !c.castingMagic) { // block animation
  1907. o.startAnimation(o.getCombat().getBlockEmote());
  1908. }
  1909. if(o.inTrade) {
  1910. o.getTradeAndDuel().declineTrade();
  1911. }
  1912. if(c.projectileStage == 0 && !c.usingMagic && !c.castingMagic) { // melee hit damage
  1913. int damageOnPlayer = (int)Math.round(Misc.random(calculateMeleeMaxHit())*.85);
  1914.  
  1915. if(damageOnPlayer >= 40)
  1916. damageOnPlayer = 40;
  1917.  
  1918. c.clawDamage[0] = (int)Math.round(damageOnPlayer / 2);
  1919. c.clawDamage[1] = (int)Math.round(damageOnPlayer / 4);
  1920. c.clawDamage[2] = (int)Math.round(damageOnPlayer / 4);
  1921. applyPlayerMeleeDamage2(i, 1, damageOnPlayer);
  1922. if(c.doubleHit && !c.usingClaws) {
  1923. if(c.playerName.equalsIgnoreCase("double pk")){
  1924. applyPlayerMeleeDamage2(i, 2, calculateMeleeMaxHit() - Misc.random(7));
  1925. } else {
  1926. applyPlayerMeleeDamage2(i, 2, Misc.random(calculateMeleeMaxHit()));
  1927. }
  1928. }
  1929. if(c.doubleHit && c.usingClaws) {
  1930. applyPlayerHit(i, c.clawDamage[0]);
  1931. c.clawPlayerDelay = 1;
  1932. c.usingClaws = false;
  1933. }
  1934. }
  1935.  
  1936.  
  1937.  
  1938. if(!c.castingMagic && c.projectileStage > 0) { // range hit damage
  1939. int damage = Misc.random(rangeMaxHit());
  1940. if(c.playerRights >= 3)
  1941. damage = rangeMaxHit();
  1942. int damage2 = -1;
  1943.  
  1944. if (c.lastWeaponUsed == 11235 || c.bowSpecShot == 1 || c.cannonSpec == 1){
  1945. damage2 = Misc.random(rangeMaxHit());
  1946. if(c.playerRights >= 3)
  1947. damage = rangeMaxHit();
  1948. }
  1949.  
  1950.  
  1951. if (c.lastWeaponUsed == 11235 && c.playerEquipment[c.playerWeapon] != 11235){
  1952. damage = (int)(damage*.5);
  1953. damage2 = (int)(damage2*.5);
  1954. }
  1955. boolean ignoreDef = false;
  1956. if (Misc.random(4) == 1 && c.lastArrowUsed == 9243 && (c.playerEquipment[c.playerWeapon] == 9185 || c.playerEquipment[c.playerWeapon] == 15041)) {
  1957. ignoreDef = true;
  1958. o.gfx0(758);
  1959. }
  1960. if(Misc.random(10+o.getCombat().calculateRangeDefence()) > Misc.random(10+calculateRangeAttack()) && !ignoreDef) {
  1961. damage = 0;
  1962. }
  1963. if (Misc.random(4) == 1 && c.lastArrowUsed == 9242 && damage > 0) {
  1964. Server.playerHandler.players[i].gfx0(754);
  1965. damage = Server.npcHandler.npcs[i].HP/5;
  1966. c.handleHitMask(c.playerLevel[3]/10);
  1967. c.dealDamage(c.playerLevel[3]/10);
  1968. c.gfx0(754);
  1969. }
  1970.  
  1971. if (c.lastWeaponUsed == 11235 || c.bowSpecShot == 1) {
  1972. if (Misc.random(10+o.getCombat().calculateRangeDefence()) > Misc.random(10+calculateRangeAttack()))
  1973. damage2 = 0;
  1974. }
  1975.  
  1976. if (c.dbowSpec) {
  1977. o.gfx100(1100);
  1978. if (damage < 8)
  1979. damage = 8;
  1980. if (damage2 < 8)
  1981. damage2 = 8;
  1982. c.dbowSpec = false;
  1983. }
  1984. if (damage > 30 && c.lastArrowUsed == 9244 && ((c.lastWeaponUsed == 9185 && Misc.random(4) == 1) || (c.lastWeaponUsed == 15041 && Misc.random(3) == 1))) {
  1985. if(c.lastWeaponUsed == 4214) {
  1986. return;
  1987. } if(o.getPA().antiFire() == 0){
  1988. damage *= 1.65;
  1989. o.sendMessage("@red@You are badly burnt by the dragon fire.");
  1990. }
  1991. if(o.getPA().antiFire() == 1){
  1992. damage *= 1.35;
  1993. o.sendMessage("@red@You are slightly protected from the dragon fire.");
  1994. }
  1995. if(o.getPA().antiFire() == 2){
  1996. damage *= 1.15;
  1997. o.sendMessage("@red@The dragon fire is weak against you.");
  1998. }
  1999. o.gfx0(756);
  2000. }
  2001. if(o.prayerActive[17] && System.currentTimeMillis() - o.protRangeDelay > 1500) { // if prayer active reduce damage by half
  2002. damage = (int)damage * 40 / 100;
  2003. if (c.lastWeaponUsed == 11235 || c.bowSpecShot == 1 || c.cannonSpec == 1)
  2004. damage2 = (int)damage2 * 40 / 100;
  2005. }
  2006. if (Server.playerHandler.players[i].playerLevel[3] - damage < 0) {
  2007. damage = Server.playerHandler.players[i].playerLevel[3];
  2008. }
  2009. if (Server.playerHandler.players[i].playerLevel[3] - damage - damage2 < 0) {
  2010. damage2 = Server.playerHandler.players[i].playerLevel[3] - damage;
  2011. }
  2012. if (damage < 0)
  2013. damage = 0;
  2014. if (damage2 < 0 && damage2 != -1)
  2015. damage2 = 0;
  2016. if (o.vengOn) {
  2017. appendVengeance(i, damage);
  2018. if(c.cannonSpec != 1)
  2019. appendVengeance(i, damage2);
  2020. }
  2021. if (damage > 0)
  2022. applyRecoil(damage, i);
  2023. if (damage2 > 0)
  2024. applyRecoil(damage2, i);
  2025. if(c.fightMode == 3) {
  2026. c.getPA().addSkillXP((damage*Config.RANGE_EXP_RATE/3), 4);
  2027. c.getPA().addSkillXP((damage*Config.RANGE_EXP_RATE/3), 1);
  2028. c.getPA().addSkillXP((damage*Config.RANGE_EXP_RATE/3), 3);
  2029. c.getPA().refreshSkill(1);
  2030. c.getPA().refreshSkill(3);
  2031. c.getPA().refreshSkill(4);
  2032. } else {
  2033. c.getPA().addSkillXP((damage*Config.RANGE_EXP_RATE), 4);
  2034. c.getPA().addSkillXP((damage*Config.RANGE_EXP_RATE/3), 3);
  2035. c.getPA().refreshSkill(3);
  2036. c.getPA().refreshSkill(4);
  2037. }
  2038. boolean dropArrows = true;
  2039.  
  2040. for(int noArrowId : c.NO_ARROW_DROP) {
  2041. if(c.lastWeaponUsed == noArrowId) {
  2042. dropArrows = false;
  2043. break;
  2044. }
  2045. }
  2046. if(dropArrows) {
  2047. c.getItems().dropArrowPlayer();
  2048. }
  2049. if(c.cannonSpec == 1)
  2050. Server.playerHandler.players[i].gfx100(89);
  2051. Server.playerHandler.players[i].underAttackBy = c.playerId;
  2052. Server.playerHandler.players[i].logoutDelay = System.currentTimeMillis();
  2053. Server.playerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  2054. Server.playerHandler.players[i].killerId = c.playerId;
  2055. //Server.playerHandler.players[i].setHitDiff(damage);
  2056. //Server.playerHandler.players[i].playerLevel[3] -= damage;
  2057. Server.playerHandler.players[i].dealDamage(damage);
  2058. Server.playerHandler.players[i].damageTaken[c.playerId] += damage;
  2059. c.killedBy = Server.playerHandler.players[i].playerId;
  2060. Server.playerHandler.players[i].handleHitMask(damage);
  2061. if (damage2 != -1) {
  2062. //Server.playerHandler.players[i].playerLevel[3] -= damage2;
  2063. if(c.cannonSpec != 1){
  2064. Server.playerHandler.players[i].dealDamage(damage2);
  2065. Server.playerHandler.players[i].damageTaken[c.playerId] += damage2;
  2066. Server.playerHandler.players[i].handleHitMask(damage2);
  2067. } else {
  2068. c.cannonSpec = 0;
  2069. final int d2 = damage2;
  2070. final int pId = c.playerId;
  2071. final int index = i;
  2072. int distance = Server.playerHandler.players[pId].distanceToPoint(Server.playerHandler.players[index].getX(), Server.playerHandler.players[index].getY());
  2073. int totalDistance = 2;
  2074.  
  2075. CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
  2076. @Override
  2077. public void execute(CycleEventContainer c) {
  2078. if(Server.playerHandler.players[index] == null)
  2079. return;
  2080. Server.playerHandler.players[index].gfx100(89);
  2081. Server.playerHandler.players[index].dealDamage(d2);
  2082. Server.playerHandler.players[index].damageTaken[pId] += d2;
  2083. Server.playerHandler.players[index].handleHitMask(d2);
  2084. Server.playerHandler.players[index].updateRequired = true;
  2085. c.stop();
  2086. }
  2087.  
  2088. @Override
  2089. public void stop() {
  2090. // TODO Auto-generated method stub
  2091.  
  2092. }
  2093.  
  2094. }, totalDistance);
  2095. }
  2096. }
  2097. o.getPA().refreshSkill(3);
  2098.  
  2099. //Server.playerHandler.players[i].setHitUpdateRequired(true);
  2100. Server.playerHandler.players[i].updateRequired = true;
  2101. applySmite(i, damage);
  2102. if (damage2 != -1)
  2103. applySmite(i, damage2);
  2104.  
  2105. } else if (c.projectileStage > 0) { // magic hit damage
  2106. int damage = Misc.random(finalMagicDamage(c));
  2107. if(godSpells()) {
  2108. if(System.currentTimeMillis() - c.godSpellDelay < Config.GOD_SPELL_CHARGE) {
  2109. damage += 10;
  2110. }
  2111. }
  2112. //c.playerIndex = 0;
  2113. if (c.playerMagicBook == 2 && c.playerEquipment[c.playerWeapon] != 22494){
  2114. damage = 0;
  2115. }
  2116.  
  2117. if (c.magicFailed)
  2118. damage = 0;
  2119.  
  2120. if(o.prayerActive[16] && System.currentTimeMillis() - o.protMageDelay > 1500) { // if prayer active reduce damage by half
  2121. damage = (int)damage * 40 / 100;
  2122. }
  2123.  
  2124. if (Server.playerHandler.players[i].playerLevel[3] - damage < 0) {
  2125. damage = Server.playerHandler.players[i].playerLevel[3];
  2126. }
  2127. if (o.vengOn)
  2128. appendVengeance(i, damage);
  2129. if (damage > 0)
  2130. applyRecoil(damage, i);
  2131. c.getPA().addSkillXP((c.MAGIC_SPELLS[c.oldSpellId][7] + damage*Config.MAGIC_EXP_RATE), 6);
  2132. c.getPA().addSkillXP((c.MAGIC_SPELLS[c.oldSpellId][7] + damage*Config.MAGIC_EXP_RATE/3), 3);
  2133. c.getPA().refreshSkill(3);
  2134. c.getPA().refreshSkill(6);
  2135.  
  2136. if(getEndGfxHeight() == 100 && !c.magicFailed){ // end GFX
  2137. Server.playerHandler.players[i].gfx100(c.MAGIC_SPELLS[c.oldSpellId][5]);
  2138. } else if (!c.magicFailed){
  2139. Server.playerHandler.players[i].gfx0(c.MAGIC_SPELLS[c.oldSpellId][5]);
  2140. } else if(c.magicFailed) {
  2141. Server.playerHandler.players[i].gfx100(85);
  2142. }
  2143.  
  2144. if(!c.magicFailed) {
  2145. if(System.currentTimeMillis() - Server.playerHandler.players[i].reduceStat > 35000) {
  2146. Server.playerHandler.players[i].reduceStat = System.currentTimeMillis();
  2147. switch(c.MAGIC_SPELLS[c.oldSpellId][0]) {
  2148. case 12987:
  2149. case 13011:
  2150. case 12999:
  2151. case 13023:
  2152. Server.playerHandler.players[i].playerLevel[0] -= ((o.getPA().getLevelForXP(Server.playerHandler.players[i].playerXP[0]) * 10) / 100);
  2153. break;
  2154. }
  2155. }
  2156.  
  2157. switch(c.MAGIC_SPELLS[c.oldSpellId][0]) {
  2158. case 12445: //teleblock
  2159. if (c.playerMagicBook == 0){
  2160. if (System.currentTimeMillis() - o.teleBlockDelay > o.teleBlockLength) {
  2161. o.teleBlockDelay = System.currentTimeMillis();
  2162. o.sendMessage("You have been teleblocked.");
  2163. if (o.prayerActive[16] && System.currentTimeMillis() - o.protMageDelay > 1500)
  2164. o.teleBlockLength = 150000;
  2165. else
  2166. o.teleBlockLength = 300000;
  2167. }
  2168. }
  2169. break;
  2170.  
  2171.  
  2172. case 12901:
  2173. case 12919: // blood spells
  2174. case 12911:
  2175. case 12929:
  2176. int heal = (int)(damage / 4);
  2177. if(c.playerLevel[3] + heal > c.getPA().getLevelForXP(c.playerXP[3])) {
  2178. c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]);
  2179. } else {
  2180. c.playerLevel[3] += heal;
  2181. }
  2182. c.getPA().refreshSkill(3);
  2183. break;
  2184.  
  2185. case 1153:
  2186. Server.playerHandler.players[i].playerLevel[0] -= ((o.getPA().getLevelForXP(Server.playerHandler.players[i].playerXP[0]) * 5) / 100);
  2187. o.sendMessage("Your attack level has been reduced!");
  2188. Server.playerHandler.players[i].reduceSpellDelay[c.reduceSpellId] = System.currentTimeMillis();
  2189. o.getPA().refreshSkill(0);
  2190. break;
  2191.  
  2192. case 1157:
  2193. Server.playerHandler.players[i].playerLevel[2] -= ((o.getPA().getLevelForXP(Server.playerHandler.players[i].playerXP[2]) * 5) / 100);
  2194. o.sendMessage("Your strength level has been reduced!");
  2195. Server.playerHandler.players[i].reduceSpellDelay[c.reduceSpellId] = System.currentTimeMillis();
  2196. o.getPA().refreshSkill(2);
  2197. break;
  2198.  
  2199. case 1161:
  2200. Server.playerHandler.players[i].playerLevel[1] -= ((o.getPA().getLevelForXP(Server.playerHandler.players[i].playerXP[1]) * 5) / 100);
  2201. o.sendMessage("Your defence level has been reduced!");
  2202. Server.playerHandler.players[i].reduceSpellDelay[c.reduceSpellId] = System.currentTimeMillis();
  2203. o.getPA().refreshSkill(1);
  2204. break;
  2205.  
  2206. case 1542:
  2207. Server.playerHandler.players[i].playerLevel[1] -= ((o.getPA().getLevelForXP(Server.playerHandler.players[i].playerXP[1]) * 10) / 100);
  2208. o.sendMessage("Your defence level has been reduced!");
  2209. Server.playerHandler.players[i].reduceSpellDelay[c.reduceSpellId] = System.currentTimeMillis();
  2210. o.getPA().refreshSkill(1);
  2211. break;
  2212.  
  2213. case 1543:
  2214. Server.playerHandler.players[i].playerLevel[2] -= ((o.getPA().getLevelForXP(Server.playerHandler.players[i].playerXP[2]) * 10) / 100);
  2215. o.sendMessage("Your strength level has been reduced!");
  2216. Server.playerHandler.players[i].reduceSpellDelay[c.reduceSpellId] = System.currentTimeMillis();
  2217. o.getPA().refreshSkill(2);
  2218. break;
  2219.  
  2220. case 1562:
  2221. Server.playerHandler.players[i].playerLevel[0] -= ((o.getPA().getLevelForXP(Server.playerHandler.players[i].playerXP[0]) * 10) / 100);
  2222. o.sendMessage("Your attack level has been reduced!");
  2223. Server.playerHandler.players[i].reduceSpellDelay[c.reduceSpellId] = System.currentTimeMillis();
  2224. o.getPA().refreshSkill(0);
  2225. break;
  2226. }
  2227. }
  2228.  
  2229. int damageCap = 60 + Misc.random(5);
  2230. if( (damage > damageCap) && c.playerEquipment[c.playerWeapon] == 22494)
  2231. damage = damageCap - Misc.random(20);
  2232.  
  2233. Server.playerHandler.players[i].logoutDelay = System.currentTimeMillis();
  2234. Server.playerHandler.players[i].underAttackBy = c.playerId;
  2235. Server.playerHandler.players[i].killerId = c.playerId;
  2236. Server.playerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  2237. if(c.MAGIC_SPELLS[c.oldSpellId][6] != 0) {
  2238. //Server.playerHandler.players[i].playerLevel[3] -= damage;
  2239. Server.playerHandler.players[i].dealDamage(damage);
  2240. Server.playerHandler.players[i].damageTaken[c.playerId] += damage;
  2241. c.totalPlayerDamageDealt += damage;
  2242. if (!c.magicFailed) {
  2243. //Server.playerHandler.players[i].setHitDiff(damage);
  2244. //Server.playerHandler.players[i].setHitUpdateRequired(true);
  2245. Server.playerHandler.players[i].handleHitMask(damage);
  2246. }
  2247. }
  2248. applySmite(i, damage);
  2249. c.killedBy = Server.playerHandler.players[i].playerId;
  2250. o.getPA().refreshSkill(3);
  2251. Server.playerHandler.players[i].updateRequired = true;
  2252. c.usingMagic = false;
  2253. c.castingMagic = false;
  2254. if (o.inMulti() && multis()) {
  2255. c.barrageCount = 0;
  2256. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  2257. if (Server.playerHandler.players[j] != null) {
  2258. if (j == o.playerId)
  2259. continue;
  2260. if (c.barrageCount >= 9)
  2261. break;
  2262. if (o.goodDistance(o.getX(), o.getY(), Server.playerHandler.players[j].getX(), Server.playerHandler.players[j].getY(), 1))
  2263. appendMultiBarrage(j, c.magicFailed);
  2264. }
  2265. }
  2266. }
  2267. c.getPA().refreshSkill(3);
  2268. c.getPA().refreshSkill(6);
  2269. c.oldSpellId = 0;
  2270. }
  2271. }
  2272. c.getPA().requestUpdates();
  2273. int oldindex = c.oldPlayerIndex;
  2274. if(c.bowSpecShot <= 0) {
  2275. c.oldPlayerIndex = 0;
  2276. c.projectileStage = 0;
  2277. c.lastWeaponUsed = 0;
  2278. c.doubleHit = false;
  2279. c.bowSpecShot = 0;
  2280. }
  2281. if(c.bowSpecShot != 0) {
  2282. c.bowSpecShot = 0;
  2283. }
  2284. }
  2285.  
  2286. public static int finalMagicDamage(Client c) {
  2287. double damage = c.MAGIC_SPELLS[c.oldSpellId][6];
  2288. double damageMultiplier = 1;
  2289.  
  2290. if (c.prayerActive[20])
  2291. damageMultiplier += .05;
  2292.  
  2293. if (c.playerLevel[c.playerMagic] > c.getLevelForXP(c.playerXP[6])
  2294. && c.getLevelForXP(c.playerXP[6]) >= 50)
  2295. damageMultiplier += .03 * (c.playerLevel[c.playerMagic] - c.getLevelForXP(c.playerXP[6]));
  2296. else
  2297. damageMultiplier = 1;
  2298.  
  2299. damageMultiplier += .10;
  2300.  
  2301. if (c.fullVoidMage()){
  2302. damageMultiplier += .21;
  2303. }
  2304.  
  2305. switch (c.playerEquipment[c.playerWeapon]) {
  2306. case 4675: // Ancient Staff
  2307. case 4710: // Ahrim's Staff
  2308. case 4862: // Ahrim's Staff
  2309. case 4864: // Ahrim's Staff
  2310. case 4865: // Ahrim's Staff
  2311. case 6914: // Master Wand
  2312. case 8841: // Void Knight Mace
  2313. damageMultiplier += .113;
  2314. break;
  2315. case 15001: // Staff of Light
  2316. damageMultiplier += .166;
  2317. break;
  2318. case 15040: // Chaotic Staff
  2319. damageMultiplier += .211;
  2320. break;
  2321. }
  2322.  
  2323. switch (c.playerEquipment[c.playerAmulet]) {
  2324. case 15000:// Arcane Stream
  2325. damageMultiplier += .155;
  2326. break;
  2327. }
  2328.  
  2329. switch (c.playerEquipment[c.playerHands]) {
  2330. case 777:// Arcane Stream
  2331. damageMultiplier += .07;
  2332. break;
  2333. }
  2334.  
  2335. if(c.playerEquipment[c.playerWeapon] != 22494 && c.oldSpellId == 52)
  2336. damageMultiplier = 0.0;
  2337. damage *= damageMultiplier;
  2338. return (int) damage;
  2339. }
  2340.  
  2341. public void applyPlayerMeleeDamage2(int i, int damageMask, int damage){
  2342. c.previousDamage = damage;
  2343. Client o = (Client) Server.playerHandler.players[i];
  2344. if(o == null) {
  2345. return;
  2346. }
  2347. int damage1 = 0;
  2348. boolean veracsEffect = false;
  2349. boolean guthansEffect = false;
  2350.  
  2351.  
  2352.  
  2353. if (c.getPA().fullVeracs()) {
  2354. if (Misc.random(4) == 1) {
  2355. veracsEffect = true;
  2356. }
  2357. }
  2358. if (c.getPA().fullGuthans()) {
  2359. if (Misc.random(4) == 1) {
  2360. guthansEffect = true;
  2361. }
  2362. }
  2363. if (damageMask == 1) {
  2364. damage1 = c.delayedDamage;
  2365. c.delayedDamage = 0;
  2366. } else {
  2367. damage1 = c.delayedDamage2;
  2368. c.delayedDamage2 = 0;
  2369. }
  2370. if(Misc.random(o.getCombat().calculateMeleeDefence()) > Misc.random(calculateMeleeAttack()) && !veracsEffect) {
  2371. damage1 = 0;
  2372. c.bonusAttack = 0;
  2373. } else if (c.playerEquipment[c.playerWeapon] == 5698 && o.poisonDamage <= 0 && Misc.random(5) == 1) {
  2374. o.getPA().appendPoison(13);
  2375. c.bonusAttack += damage1/3;
  2376. } else {
  2377. c.bonusAttack += damage1/3;
  2378. }
  2379. if((o.prayerActive[18] || o.curseActive[9]) && System.currentTimeMillis() - o.protMeleeDelay > 1500 && !veracsEffect) { // if prayer active reduce damage by 40%
  2380. damage1 = (int)damage1 * 40 / 100;
  2381. }
  2382. if (c.maxNextHit) {
  2383. damage1 = calculateMeleeMaxHit();
  2384. }
  2385. if (damage1 > 0 && guthansEffect) {
  2386. c.playerLevel[3] += damage1;
  2387. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  2388. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  2389. c.getPA().refreshSkill(3);
  2390. o.gfx0(398);
  2391. }
  2392. if (c.ssSpec && damageMask == 2) {
  2393. damage1 = 5 + Misc.random(11);
  2394. c.ssSpec = false;
  2395. }
  2396.  
  2397. Client cl2 = (Client) Server.playerHandler.players[i];
  2398. if (cl2.playerEquipment[5] == 13742) {//Elysian Effect
  2399. if (Misc.random(100) < 75) {
  2400. double damages = damage1;
  2401. double damageDeduction = ((double)damages)/((double)4);
  2402. damage1 = damage1-((int)Math.round(damageDeduction));
  2403. }
  2404. }
  2405. if (cl2.playerEquipment[5] == 13740) {//Divine Effect
  2406. double damages2 = damage1;
  2407. double prayer = cl2.playerLevel[5];
  2408. double possibleDamageDeduction = ((double)damages2)/((double)3.33);//30% of Damage Inflicted
  2409. double actualDamageDeduction;
  2410. if ((prayer * 2) < possibleDamageDeduction) {
  2411. actualDamageDeduction = (prayer * 2);//Partial Effect(Not enough prayer points)
  2412. } else {
  2413. actualDamageDeduction = possibleDamageDeduction;//Full effect
  2414. }
  2415. double prayerDeduction = ((double)actualDamageDeduction)/((double)2);//Half of the damage deducted
  2416. damage1 = damage1-((int)Math.round(actualDamageDeduction));
  2417. cl2.playerLevel[5] = cl2.playerLevel[5]-((int)Math.round(prayerDeduction));
  2418. cl2.getPA().refreshSkill(5);
  2419. }
  2420. if (Server.playerHandler.players[i].playerLevel[3] - damage1 < 0) {
  2421. damage1 = Server.playerHandler.players[i].playerLevel[3];
  2422. }
  2423. if (o.vengOn && damage1 > 0)
  2424. appendVengeance(i, damage1);
  2425. if (damage1 > 0)
  2426. applyRecoil(damage1, i);
  2427. switch(c.specEffect) {
  2428. case 1: // dragon scimmy special
  2429. if(damage > 0) {
  2430. if(o.prayerActive[16] || o.prayerActive[17] || o.prayerActive[18] || o.curseActive[7] || o.curseActive[8] || o.curseActive[9]) {
  2431. o.headIcon = -1;
  2432. o.getPA().sendFrame36(c.PRAYER_GLOW[16], 0);
  2433. o.getPA().sendFrame36(c.PRAYER_GLOW[17], 0);
  2434. o.getPA().sendFrame36(c.PRAYER_GLOW[18], 0);
  2435. o.getPA().sendFrame36(c.CURSE_GLOW[7], 0);
  2436. o.getPA().sendFrame36(c.CURSE_GLOW[8], 0);
  2437. o.getPA().sendFrame36(c.CURSE_GLOW[9], 0);
  2438. }
  2439. o.sendMessage("You have been injured!");
  2440. o.stopPrayerDelay = System.currentTimeMillis();
  2441. o.prayerActive[16] = false;
  2442. o.prayerActive[17] = false;
  2443. o.prayerActive[18] = false;
  2444. o.curseActive[7] = false;
  2445. o.curseActive[8] = false;
  2446. o.curseActive[9] = false;
  2447. o.getPA().requestUpdates();
  2448. }
  2449. break;
  2450. case 2:
  2451. if (damage1 > 0) {
  2452. if (o.freezeTimer <= 0)
  2453. o.freezeTimer = 30;
  2454. o.gfx0(369);
  2455. o.sendMessage("You have been frozen.");
  2456. o.frozenBy = c.playerId;
  2457. o.stopMovement();
  2458. c.sendMessage("You freeze your enemy.");
  2459. }
  2460. break;
  2461. case 3:
  2462. if (damage1 > 0) {
  2463. o.playerLevel[1] -= damage1;
  2464. o.sendMessage("Your defence is weakened.");
  2465. if (o.playerLevel[1] < 1)
  2466. o.playerLevel[1] = 1;
  2467. o.getPA().refreshSkill(1);
  2468. }
  2469. break;
  2470. case 4:
  2471. if (damage1 > 0) {
  2472. if (c.playerLevel[3] + damage1 > c.getLevelForXP(c.playerXP[3]))
  2473. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]));
  2474. else
  2475. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  2476. else
  2477. c.playerLevel[3] += damage1;
  2478. c.getPA().refreshSkill(3);
  2479. }
  2480. break;
  2481. case 5:
  2482. c.clawDelay = 2;
  2483. break;
  2484.  
  2485. }
  2486. c.specEffect = 0;
  2487. if(c.fightMode == 3) {
  2488. c.getPA().addSkillXP((damage1*Config.MELEE_EXP_RATE/3), 0);
  2489. c.getPA().addSkillXP((damage1*Config.MELEE_EXP_RATE/3), 1);
  2490. c.getPA().addSkillXP((damage1*Config.MELEE_EXP_RATE/3), 2);
  2491. c.getPA().addSkillXP((damage1*Config.MELEE_EXP_RATE/3), 3);
  2492. c.getPA().refreshSkill(0);
  2493. c.getPA().refreshSkill(1);
  2494. c.getPA().refreshSkill(2);
  2495. c.getPA().refreshSkill(3);
  2496. } else {
  2497. c.getPA().addSkillXP((damage1*Config.MELEE_EXP_RATE), c.fightMode);
  2498. c.getPA().addSkillXP((damage1*Config.MELEE_EXP_RATE/3), 3);
  2499. c.getPA().refreshSkill(c.fightMode);
  2500. c.getPA().refreshSkill(3);
  2501. }
  2502. Server.playerHandler.players[i].logoutDelay = System.currentTimeMillis();
  2503. Server.playerHandler.players[i].underAttackBy = c.playerId;
  2504. Server.playerHandler.players[i].killerId = c.playerId;
  2505. Server.playerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  2506. if (c.killedBy != Server.playerHandler.players[i].playerId)
  2507. c.totalPlayerDamageDealt = 0;
  2508. c.killedBy = Server.playerHandler.players[i].playerId;
  2509. applySmite(i, damage1);
  2510. switch(damageMask) {
  2511. case 1:
  2512. /*if (!Server.playerHandler.players[i].getHitUpdateRequired()){
  2513. Server.playerHandler.players[i].setHitDiff(damage);
  2514. Server.playerHandler.players[i].setHitUpdateRequired(true);
  2515. } else {
  2516. Server.playerHandler.players[i].setHitDiff2(damage);
  2517. Server.playerHandler.players[i].setHitUpdateRequired2(true);
  2518. }*/
  2519. //Server.playerHandler.players[i].playerLevel[3] -= damage1;
  2520. Server.playerHandler.players[i].dealDamage(damage1);
  2521. Server.playerHandler.players[i].damageTaken[c.playerId] += damage1;
  2522. c.totalPlayerDamageDealt += damage1;
  2523. Server.playerHandler.players[i].updateRequired = true;
  2524. o.getPA().refreshSkill(3);
  2525. break;
  2526.  
  2527. case 2:
  2528. /*if (!Server.playerHandler.players[i].getHitUpdateRequired2()){
  2529. Server.playerHandler.players[i].setHitDiff2(damage);
  2530. Server.playerHandler.players[i].setHitUpdateRequired2(true);
  2531. } else {
  2532. Server.playerHandler.players[i].setHitDiff(damage);
  2533. Server.playerHandler.players[i].setHitUpdateRequired(true);
  2534. }*/
  2535. //Server.playerHandler.players[i].playerLevel[3] -= damage1;
  2536. Server.playerHandler.players[i].dealDamage(damage1);
  2537. Server.playerHandler.players[i].damageTaken[c.playerId] += damage1;
  2538. c.totalPlayerDamageDealt += damage1;
  2539. Server.playerHandler.players[i].updateRequired = true;
  2540. c.doubleHit = false;
  2541. o.getPA().refreshSkill(3);
  2542. break;
  2543. }
  2544. Server.playerHandler.players[i].handleHitMask(damage1);
  2545. }
  2546.  
  2547. public boolean multis() {
  2548. switch (c.MAGIC_SPELLS[c.oldSpellId][0]) {
  2549. case 12891:
  2550. case 12881:
  2551. case 13011:
  2552. case 13023:
  2553. case 12919: // blood spells
  2554. case 12929:
  2555. case 12963:
  2556. case 12975:
  2557. return true;
  2558. }
  2559. return false;
  2560.  
  2561. }
  2562. public void appendMultiBarrage(int playerId, boolean splashed) {
  2563. if (Server.playerHandler.players[playerId] != null) {
  2564. Client c2 = (Client)Server.playerHandler.players[playerId];
  2565. if (c2.isDead || c2.respawnTimer > 0)
  2566. return;
  2567. if (checkMultiBarrageReqs(playerId)) {
  2568. c.barrageCount++;
  2569. if (Misc.random(mageAtk()) > Misc.random(mageDef()) && !c.magicFailed) {
  2570. if(getEndGfxHeight() == 100){ // end GFX
  2571. c2.gfx100(c.MAGIC_SPELLS[c.oldSpellId][5]);
  2572. } else {
  2573. c2.gfx0(c.MAGIC_SPELLS[c.oldSpellId][5]);
  2574. }
  2575. int damage = Misc.random(c.MAGIC_SPELLS[c.oldSpellId][6]);
  2576. if (c2.prayerActive[12]) {
  2577. damage *= (int)(.60);
  2578. }
  2579. if (c2.playerLevel[3] - damage < 0) {
  2580. damage = c2.playerLevel[3];
  2581. }
  2582. c.getPA().addSkillXP((c.MAGIC_SPELLS[c.oldSpellId][7] + damage*Config.MAGIC_EXP_RATE), 6);
  2583. c.getPA().addSkillXP((c.MAGIC_SPELLS[c.oldSpellId][7] + damage*Config.MAGIC_EXP_RATE/3), 3);
  2584. //Server.playerHandler.players[playerId].setHitDiff(damage);
  2585. //Server.playerHandler.players[playerId].setHitUpdateRequired(true);
  2586. Server.playerHandler.players[playerId].handleHitMask(damage);
  2587. //Server.playerHandler.players[playerId].playerLevel[3] -= damage;
  2588. Server.playerHandler.players[playerId].dealDamage(damage);
  2589. Server.playerHandler.players[playerId].damageTaken[c.playerId] += damage;
  2590. c2.getPA().refreshSkill(3);
  2591. c.totalPlayerDamageDealt += damage;
  2592. multiSpellEffect(playerId, damage);
  2593. } else {
  2594. c2.gfx100(85);
  2595. }
  2596. }
  2597. }
  2598. }
  2599.  
  2600. public void multiSpellEffect(int playerId, int damage) {
  2601. switch(c.MAGIC_SPELLS[c.oldSpellId][0]) {
  2602. case 13011:
  2603. case 13023:
  2604. if(System.currentTimeMillis() - Server.playerHandler.players[playerId].reduceStat > 35000) {
  2605. Server.playerHandler.players[playerId].reduceStat = System.currentTimeMillis();
  2606. Server.playerHandler.players[playerId].playerLevel[0] -= ((Server.playerHandler.players[playerId].getLevelForXP(Server.playerHandler.players[playerId].playerXP[0]) * 10) / 100);
  2607. }
  2608. break;
  2609. case 12919: // blood spells
  2610. case 12929:
  2611. int heal = (int)(damage / 4);
  2612. if(c.playerLevel[3] + heal >= c.getPA().getLevelForXP(c.playerXP[3])) {
  2613. c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]);
  2614. } else {
  2615. c.playerLevel[3] += heal;
  2616. }
  2617. c.getPA().refreshSkill(3);
  2618. break;
  2619. case 12891:
  2620. case 12881:
  2621. case 1191:
  2622. if (Server.playerHandler.players[playerId].freezeTimer < -5) {
  2623. Server.playerHandler.players[playerId].freezeTimer = getFreezeTime();
  2624. Server.playerHandler.players[playerId].stopMovement();
  2625. }
  2626. break;
  2627. }
  2628. }
  2629. public void applyPlayerClawDamage(int i, int damageMask, int damage){
  2630. Client o = (Client) Server.playerHandler.players[i];
  2631. if(o == null) {
  2632. return;
  2633. }
  2634.  
  2635. c.previousDamage = damage;
  2636. boolean veracsEffect = false;
  2637. boolean guthansEffect = false;
  2638. if (c.getPA().fullVeracs()) {
  2639. if (Misc.random(4) == 1) {
  2640. veracsEffect = true;
  2641. }
  2642. }
  2643. if (c.getPA().fullGuthans()) {
  2644. if (Misc.random(4) == 1) {
  2645. guthansEffect = true;
  2646. }
  2647. }
  2648. if (damageMask == 1) {
  2649. damage = c.delayedDamage;
  2650. c.delayedDamage = 0;
  2651. } else {
  2652. damage = c.delayedDamage2;
  2653. c.delayedDamage2 = 0;
  2654. }
  2655. if(Misc.random(o.getCombat().calculateMeleeDefence()) > Misc.random(calculateMeleeAttack()) && !veracsEffect) {
  2656. damage = 0;
  2657. c.bonusAttack = 0;
  2658. } else if (c.playerEquipment[c.playerWeapon] == 5698 && o.poisonDamage <= 0 && Misc.random(3) == 1) {
  2659. o.getPA().appendPoison(13);
  2660. c.bonusAttack += damage/3;
  2661. } else {
  2662. c.bonusAttack += damage/3;
  2663. }
  2664. if((o.prayerActive[18] || o.curseActive[9]) && System.currentTimeMillis() - o.protMeleeDelay > 1500 && !veracsEffect) { // if prayer active reduce damage by 40%
  2665. damage = (int)damage * 40 / 100;
  2666. }
  2667. if (c.maxNextHit) {
  2668. damage = calculateMeleeMaxHit();
  2669. }
  2670. if (damage > 0 && guthansEffect) {
  2671. c.playerLevel[3] += damage;
  2672. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  2673. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  2674. c.getPA().refreshSkill(3);
  2675. o.gfx0(398);
  2676. }
  2677. if (c.ssSpec && damageMask == 2) {
  2678. damage = 5 + Misc.random(11);
  2679. c.ssSpec = false;
  2680. }
  2681. if (Server.playerHandler.players[i].playerLevel[3] - damage < 0) {
  2682. damage = Server.playerHandler.players[i].playerLevel[3];
  2683. }
  2684. if (o.vengOn && damage > 0)
  2685. appendVengeance(i, damage);
  2686. if (damage > 0)
  2687. applyRecoil(damage, i);
  2688. switch(c.specEffect) {
  2689. case 1: // dragon scimmy special
  2690. if(damage > 0) {
  2691. if(o.prayerActive[16] || o.prayerActive[17] || o.prayerActive[18] || o.curseActive[7] || o.curseActive[8] || o.curseActive[9]) {
  2692. o.headIcon = -1;
  2693. o.getPA().sendFrame36(c.PRAYER_GLOW[16], 0);
  2694. o.getPA().sendFrame36(c.PRAYER_GLOW[17], 0);
  2695. o.getPA().sendFrame36(c.PRAYER_GLOW[18], 0);
  2696. o.getPA().sendFrame36(c.CURSE_GLOW[7], 0);
  2697. o.getPA().sendFrame36(c.CURSE_GLOW[8], 0);
  2698. o.getPA().sendFrame36(c.CURSE_GLOW[9], 0);
  2699. }
  2700. o.sendMessage("You have been injured!");
  2701. o.stopPrayerDelay = System.currentTimeMillis();
  2702. o.prayerActive[16] = false;
  2703. o.prayerActive[17] = false;
  2704. o.prayerActive[18] = false;
  2705. o.curseActive[7] = false;
  2706. o.curseActive[8] = false;
  2707. o.curseActive[9] = false;
  2708. o.getPA().requestUpdates();
  2709. }
  2710. break;
  2711. case 2:
  2712. if (damage > 0) {
  2713. if (o.freezeTimer <= 0)
  2714. o.freezeTimer = 30;
  2715. o.gfx0(369);
  2716. o.sendMessage("You have been frozen.");
  2717. o.frozenBy = c.playerId;
  2718. o.stopMovement();
  2719. c.sendMessage("You freeze your enemy.");
  2720. }
  2721. break;
  2722. case 3:
  2723. if (damage > 0) {
  2724. o.playerLevel[1] -= damage;
  2725. o.sendMessage("You feel weak.");
  2726. if (o.playerLevel[1] < 1)
  2727. o.playerLevel[1] = 1;
  2728. o.getPA().refreshSkill(1);
  2729. }
  2730. break;
  2731. case 4:
  2732. if (damage > 0) {
  2733. if (c.playerLevel[3] + damage > c.getLevelForXP(c.playerXP[3]))
  2734. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]));
  2735. else
  2736. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  2737. else if (c.playerEquipment[c.playerWeapon] == 11698)
  2738. c.playerLevel[3] += damage;
  2739. c.getPA().refreshSkill(3);
  2740. }
  2741. break;
  2742. case 5:
  2743. c.clawDelay = 2;
  2744. break;
  2745. }
  2746. c.specEffect = 0;
  2747. if(c.fightMode == 3) {
  2748. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 0);
  2749. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 1);
  2750. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 2);
  2751. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 3);
  2752. c.getPA().refreshSkill(0);
  2753. c.getPA().refreshSkill(1);
  2754. c.getPA().refreshSkill(2);
  2755. c.getPA().refreshSkill(3);
  2756. } else {
  2757. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE), c.fightMode);
  2758. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 3);
  2759. c.getPA().refreshSkill(c.fightMode);
  2760. c.getPA().refreshSkill(3);
  2761. }
  2762. Server.playerHandler.players[i].logoutDelay = System.currentTimeMillis();
  2763. Server.playerHandler.players[i].underAttackBy = c.playerId;
  2764. Server.playerHandler.players[i].killerId = c.playerId;
  2765. Server.playerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  2766. if (c.killedBy != Server.playerHandler.players[i].playerId)
  2767. c.totalPlayerDamageDealt = 0;
  2768. c.killedBy = Server.playerHandler.players[i].playerId;
  2769. applySmite(i, damage);
  2770. if(c.playerRights >= 3)
  2771. c.sendMessage("@red@Smited");
  2772. switch(damageMask) {
  2773. case 1:
  2774. /*if (!Server.playerHandler.players[i].getHitUpdateRequired()){
  2775. Server.playerHandler.players[i].setHitDiff(damage);
  2776. Server.playerHandler.players[i].setHitUpdateRequired(true);
  2777. } else {
  2778. Server.playerHandler.players[i].setHitDiff2(damage);
  2779. Server.playerHandler.players[i].setHitUpdateRequired2(true);
  2780. }*/
  2781. //Server.playerHandler.players[i].playerLevel[3] -= damage;
  2782. Server.playerHandler.players[i].dealDamage(damage);
  2783. Server.playerHandler.players[i].damageTaken[c.playerId] += damage;
  2784. c.totalPlayerDamageDealt += damage;
  2785. Server.playerHandler.players[i].updateRequired = true;
  2786. o.getPA().refreshSkill(3);
  2787. break;
  2788.  
  2789. case 2:
  2790. /*if (!Server.playerHandler.players[i].getHitUpdateRequired2()){
  2791. Server.playerHandler.players[i].setHitDiff2(damage);
  2792. Server.playerHandler.players[i].setHitUpdateRequired2(true);
  2793. } else {
  2794. Server.playerHandler.players[i].setHitDiff(damage);
  2795. Server.playerHandler.players[i].setHitUpdateRequired(true);
  2796. }*/
  2797. //Server.playerHandler.players[i].playerLevel[3] -= damage;
  2798. Server.playerHandler.players[i].dealDamage(damage);
  2799. Server.playerHandler.players[i].damageTaken[c.playerId] += damage;
  2800. c.totalPlayerDamageDealt += damage;
  2801. Server.playerHandler.players[i].updateRequired = true;
  2802. c.doubleHit = false;
  2803. o.getPA().refreshSkill(3);
  2804. break;
  2805. }
  2806. Server.playerHandler.players[i].handleHitMask(damage);
  2807. }
  2808.  
  2809.  
  2810. public void applyPlayerMeleeDamage(int i, int damageMask){
  2811. Client o = (Client) Server.playerHandler.players[i];
  2812. if(o == null) {
  2813. return;
  2814. }
  2815. int damage = 0;
  2816. boolean veracsEffect = false;
  2817. boolean guthansEffect = false;
  2818. if (c.getPA().fullVeracs()) {
  2819. if (Misc.random(4) == 1) {
  2820. veracsEffect = true;
  2821. }
  2822. }
  2823. if (c.getPA().fullGuthans()) {
  2824. if (Misc.random(4) == 1) {
  2825. guthansEffect = true;
  2826. }
  2827. }
  2828. if (damageMask == 1) {
  2829. damage = c.delayedDamage;
  2830. c.delayedDamage = 0;
  2831. } else {
  2832. damage = c.delayedDamage2;
  2833. c.delayedDamage2 = 0;
  2834. }
  2835. if(Misc.random(o.getCombat().calculateMeleeDefence()) > Misc.random(calculateMeleeAttack()) && !veracsEffect) {
  2836. damage = 0;
  2837. c.bonusAttack = 0;
  2838. } else if (c.playerEquipment[c.playerWeapon] == 5698 && o.poisonDamage <= 0 && Misc.random(3) == 1) {
  2839. o.getPA().appendPoison(13);
  2840. c.bonusAttack += damage/3;
  2841. } else {
  2842. c.bonusAttack += damage/3;
  2843. }
  2844. if((o.prayerActive[18] || o.curseActive[9]) && System.currentTimeMillis() - o.protMeleeDelay > 1500 && !veracsEffect) { // if prayer active reduce damage by 40%
  2845. damage = (int)damage * 40 / 100;
  2846. }
  2847. if (c.maxNextHit) {
  2848. damage = calculateMeleeMaxHit();
  2849. }
  2850. if (damage > 0 && guthansEffect) {
  2851. c.playerLevel[3] += damage;
  2852. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]))
  2853. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  2854. c.getPA().refreshSkill(3);
  2855. o.gfx0(398);
  2856. }
  2857. if (c.ssSpec && damageMask == 2) {
  2858. damage = 5 + Misc.random(11);
  2859. c.ssSpec = false;
  2860. }
  2861. if (Server.playerHandler.players[i].playerLevel[3] - damage < 0) {
  2862. damage = Server.playerHandler.players[i].playerLevel[3];
  2863. }
  2864. if (o.vengOn && damage > 0)
  2865. appendVengeance(i, damage);
  2866. if (damage > 0)
  2867. applyRecoil(damage, i);
  2868. switch(c.specEffect) {
  2869. case 1: // dragon scimmy special
  2870. if(damage > 0) {
  2871. if(o.prayerActive[16] || o.prayerActive[17] || o.prayerActive[18] || o.curseActive[7] || o.curseActive[8] || o.curseActive[9]) {
  2872. o.headIcon = -1;
  2873. o.getPA().sendFrame36(c.PRAYER_GLOW[16], 0);
  2874. o.getPA().sendFrame36(c.PRAYER_GLOW[17], 0);
  2875. o.getPA().sendFrame36(c.PRAYER_GLOW[18], 0);
  2876. o.getPA().sendFrame36(c.CURSE_GLOW[7], 0);
  2877. o.getPA().sendFrame36(c.CURSE_GLOW[8], 0);
  2878. o.getPA().sendFrame36(c.CURSE_GLOW[9], 0);
  2879. }
  2880. o.sendMessage("You have been injured!");
  2881. o.stopPrayerDelay = System.currentTimeMillis();
  2882. o.prayerActive[16] = false;
  2883. o.prayerActive[17] = false;
  2884. o.prayerActive[18] = false;
  2885. o.curseActive[7] = false;
  2886. o.curseActive[8] = false;
  2887. o.curseActive[9] = false;
  2888. o.getPA().requestUpdates();
  2889. }
  2890. break;
  2891. case 2:
  2892. if (damage > 0) {
  2893. if (o.freezeTimer <= 0)
  2894. o.freezeTimer = 30;
  2895. o.gfx0(369);
  2896. o.sendMessage("You have been frozen.");
  2897. o.frozenBy = c.playerId;
  2898. o.stopMovement();
  2899. c.sendMessage("You freeze your enemy.");
  2900. }
  2901. break;
  2902. case 3:
  2903. if (damage > 0) {
  2904. o.playerLevel[1] -= damage;
  2905. o.sendMessage("Your defence is weakened.");
  2906. if (o.playerLevel[1] < 1)
  2907. o.playerLevel[1] = 1;
  2908. o.getPA().refreshSkill(1);
  2909. }
  2910. break;
  2911. case 4:
  2912. if (damage > 0) {
  2913. if (c.playerLevel[3] + damage > c.getLevelForXP(c.playerXP[3]))
  2914. if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3]));
  2915. else
  2916. c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
  2917. else
  2918. c.playerLevel[3] += damage;
  2919. c.getPA().refreshSkill(3);
  2920. }
  2921. break;
  2922. case 5:
  2923. c.clawDelay = 2;
  2924. break;
  2925. }
  2926. c.specEffect = 0;
  2927. if(c.fightMode == 3) {
  2928. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 0);
  2929. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 1);
  2930. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 2);
  2931. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 3);
  2932. c.getPA().refreshSkill(0);
  2933. c.getPA().refreshSkill(1);
  2934. c.getPA().refreshSkill(2);
  2935. c.getPA().refreshSkill(3);
  2936. } else {
  2937. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE), c.fightMode);
  2938. c.getPA().addSkillXP((damage*Config.MELEE_EXP_RATE/3), 3);
  2939. c.getPA().refreshSkill(c.fightMode);
  2940. c.getPA().refreshSkill(3);
  2941. }
  2942. Server.playerHandler.players[i].logoutDelay = System.currentTimeMillis();
  2943. Server.playerHandler.players[i].underAttackBy = c.playerId;
  2944. Server.playerHandler.players[i].killerId = c.playerId;
  2945. Server.playerHandler.players[i].singleCombatDelay = System.currentTimeMillis();
  2946. if (c.killedBy != Server.playerHandler.players[i].playerId)
  2947. c.totalPlayerDamageDealt = 0;
  2948. c.killedBy = Server.playerHandler.players[i].playerId;
  2949. applySmite(i, damage);
  2950. switch(damageMask) {
  2951. case 1:
  2952. /*if (!Server.playerHandler.players[i].getHitUpdateRequired()){
  2953. Server.playerHandler.players[i].setHitDiff(damage);
  2954. Server.playerHandler.players[i].setHitUpdateRequired(true);
  2955. } else {
  2956. Server.playerHandler.players[i].setHitDiff2(damage);
  2957. Server.playerHandler.players[i].setHitUpdateRequired2(true);
  2958. }*/
  2959. //Server.playerHandler.players[i].playerLevel[3] -= damage;
  2960. Server.playerHandler.players[i].dealDamage(damage);
  2961. Server.playerHandler.players[i].damageTaken[c.playerId] += damage;
  2962. c.totalPlayerDamageDealt += damage;
  2963. Server.playerHandler.players[i].updateRequired = true;
  2964. o.getPA().refreshSkill(3);
  2965. break;
  2966.  
  2967. case 2:
  2968. /*if (!Server.playerHandler.players[i].getHitUpdateRequired2()){
  2969. Server.playerHandler.players[i].setHitDiff2(damage);
  2970. Server.playerHandler.players[i].setHitUpdateRequired2(true);
  2971. } else {
  2972. Server.playerHandler.players[i].setHitDiff(damage);
  2973. Server.playerHandler.players[i].setHitUpdateRequired(true);
  2974. }*/
  2975. //Server.playerHandler.players[i].playerLevel[3] -= damage;
  2976. Server.playerHandler.players[i].dealDamage(damage);
  2977. Server.playerHandler.players[i].damageTaken[c.playerId] += damage;
  2978. c.totalPlayerDamageDealt += damage;
  2979. Server.playerHandler.players[i].updateRequired = true;
  2980. c.doubleHit = false;
  2981. o.getPA().refreshSkill(3);
  2982. break;
  2983. }
  2984. Server.playerHandler.players[i].handleHitMask(damage);
  2985. }
  2986.  
  2987. public void applySmite(int index, int damage) {
  2988. if (!c.prayerActive[23] && !c.curseActive[18])
  2989. return;
  2990. if (damage <= 0)
  2991. return;
  2992. if (Server.playerHandler.players[index] != null) {
  2993. Client c2 = (Client)Server.playerHandler.players[index];
  2994. if(c.curseActive[18] && !c.prayerActive[23] && c.playerLevel[3] <= 99) {
  2995. int heal = (int)(damage/5);
  2996. if(c.playerLevel[3] + heal >= c.getPA().getLevelForXP(c.playerXP[3])) {
  2997. c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]);
  2998. } else {
  2999. c.playerLevel[3] += heal;
  3000. }
  3001. c.getPA().refreshSkill(3);
  3002. }
  3003. c2.playerLevel[5] -= (int)(damage/4);
  3004.  
  3005. if (c2.playerLevel[5] <= 0) {
  3006. c2.playerLevel[5] = 0;
  3007. c2.getCombat().resetPrayers();
  3008. }
  3009. c2.getPA().refreshSkill(5);
  3010. }
  3011.  
  3012. }
  3013.  
  3014.  
  3015.  
  3016. public void fireProjectilePlayer() {
  3017. if(c.oldPlayerIndex > 0) {
  3018. if(Server.playerHandler.players[c.oldPlayerIndex] != null) {
  3019. c.projectileStage = 2;
  3020. int pX = c.getX();
  3021. int pY = c.getY();
  3022. int oX = Server.playerHandler.players[c.oldPlayerIndex].getX();
  3023. int oY = Server.playerHandler.players[c.oldPlayerIndex].getY();
  3024. int offX = (pY - oY)* -1;
  3025. int offY = (pX - oX)* -1;
  3026. if (!c.msbSpec) {
  3027. if(c.cannonSpec == 1){
  3028. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 100, getRangeProjectileGFX(), 43, 31, - c.oldPlayerIndex - 1, getStartDelay(), 10);
  3029. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, 70, getRangeProjectileGFX(), 43, 31, - c.oldPlayerIndex - 1, getStartDelay(), 5);
  3030. } else {
  3031. c.getPA().createPlayersProjectile(pX, pY, offX, offY, 50, getProjectileSpeed(), getRangeProjectileGFX(), 43, 31, - c.oldPlayerIndex - 1, getStartDelay());
  3032. }
  3033. } else if (c.msbSpec) {
  3034. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, getProjectileSpeed(), getRangeProjectileGFX(), 43, 31, - c.oldPlayerIndex - 1, getStartDelay(), 10);
  3035. c.msbSpec = false;
  3036. }
  3037. if (usingDbow())
  3038. c.getPA().createPlayersProjectile2(pX, pY, offX, offY, 50, getProjectileSpeed(), getRangeProjectileGFX(), 60, 31, - c.oldPlayerIndex - 1, getStartDelay(), 35);
  3039. }
  3040. }
  3041. }
  3042.  
  3043. public boolean usingDbow() {
  3044. return c.playerEquipment[c.playerWeapon] == 11235;
  3045. }
  3046.  
  3047. /** Prayer **/
  3048.  
  3049. public void activatePrayer(int i) {
  3050. if (c.getItems().playerHasItem(7671, 1)
  3051. || c.playerEquipment[c.playerHands] == 7671) {
  3052. c.sendMessage("@red@You can't pray with these boxing gloves!");
  3053. return;
  3054. }
  3055. if (c.duelRule[7]) {
  3056. for (int p = 0; p < c.PRAYER.length; p++) { // reset prayer glows
  3057. c.prayerActive[p] = false;
  3058. c.getPA().sendFrame36(c.PRAYER_GLOW[p], 0);
  3059. }
  3060. c.sendMessage("Prayer has been disabled in this duel!");
  3061. return;
  3062. }
  3063. if (i == 10 && c.isInHighRiskPK()) {
  3064. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3065. c.sendMessage("This cannot be used in high-risk PK.");
  3066. return;
  3067. }
  3068. if (i == 10 && c.redSkull == true) {
  3069. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3070. c.sendMessage("@red@You Cant Use Protect Item Prayer.");
  3071. return;
  3072. }
  3073. if (i == 10 && c.inNoProtectItem()) {
  3074. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3075. c.sendMessage("This cannot be used in high-risk PK.");
  3076. return;
  3077. }
  3078.  
  3079. if (i == 24 && c.playerLevel[1] < 60) {
  3080. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3081. c.sendMessage("You need 60 defence and 65 prayer to use this.");
  3082. return;
  3083. }
  3084. if (i == 25 && c.playerLevel[1] < 28) {
  3085. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3086. c.sendMessage("You need defence level of 28 to use this!");
  3087. return;
  3088. }
  3089. int[] defPray = { 0, 5, 13, 24, 25 };
  3090. int[] strPray = { 1, 6, 14, 24, 25 };
  3091. int[] atkPray = { 2, 7, 15, 24, 25 };
  3092. int[] rangePray = { 3, 11, 19 };
  3093. int[] magePray = { 4, 12, 20 };
  3094.  
  3095. if (c.playerLevel[5] > 0 || !Config.PRAYER_POINTS_REQUIRED) {
  3096. if (c.getPA().getLevelForXP(c.playerXP[5]) >= c.PRAYER_LEVEL_REQUIRED[i]
  3097. || !Config.PRAYER_LEVEL_REQUIRED) {
  3098. boolean headIcon = false;
  3099. switch (i) {
  3100. case 0:
  3101. case 5:
  3102. case 13:
  3103. if (c.prayerActive[i] == false) {
  3104. for (int j = 0; j < defPray.length; j++) {
  3105. if (defPray[j] != i) {
  3106. c.prayerActive[defPray[j]] = false;
  3107. c.getPA().sendFrame36(
  3108. c.PRAYER_GLOW[defPray[j]], 0);
  3109. }
  3110. }
  3111. }
  3112. break;
  3113.  
  3114. case 1:
  3115. case 6:
  3116. case 14:
  3117. if (c.prayerActive[i] == false) {
  3118. for (int j = 0; j < strPray.length; j++) {
  3119. if (strPray[j] != i) {
  3120. c.prayerActive[strPray[j]] = false;
  3121. c.getPA().sendFrame36(
  3122. c.PRAYER_GLOW[strPray[j]], 0);
  3123. }
  3124. }
  3125. for (int j = 0; j < rangePray.length; j++) {
  3126. if (rangePray[j] != i) {
  3127. c.prayerActive[rangePray[j]] = false;
  3128. c.getPA().sendFrame36(
  3129. c.PRAYER_GLOW[rangePray[j]], 0);
  3130. }
  3131. }
  3132. for (int j = 0; j < magePray.length; j++) {
  3133. if (magePray[j] != i) {
  3134. c.prayerActive[magePray[j]] = false;
  3135. c.getPA().sendFrame36(
  3136. c.PRAYER_GLOW[magePray[j]], 0);
  3137. }
  3138. }
  3139. }
  3140. break;
  3141.  
  3142. case 2:
  3143. case 7:
  3144. case 15:
  3145. if (c.prayerActive[i] == false) {
  3146. for (int j = 0; j < atkPray.length; j++) {
  3147. if (atkPray[j] != i) {
  3148. c.prayerActive[atkPray[j]] = false;
  3149. c.getPA().sendFrame36(
  3150. c.PRAYER_GLOW[atkPray[j]], 0);
  3151. }
  3152. }
  3153. for (int j = 0; j < rangePray.length; j++) {
  3154. if (rangePray[j] != i) {
  3155. c.prayerActive[rangePray[j]] = false;
  3156. c.getPA().sendFrame36(
  3157. c.PRAYER_GLOW[rangePray[j]], 0);
  3158. }
  3159. }
  3160. for (int j = 0; j < magePray.length; j++) {
  3161. if (magePray[j] != i) {
  3162. c.prayerActive[magePray[j]] = false;
  3163. c.getPA().sendFrame36(
  3164. c.PRAYER_GLOW[magePray[j]], 0);
  3165. }
  3166. }
  3167. }
  3168. break;
  3169.  
  3170. case 3: // range prays
  3171. case 11:
  3172. case 19:
  3173. if (c.prayerActive[i] == false) {
  3174. for (int j = 0; j < atkPray.length; j++) {
  3175. if (atkPray[j] != i) {
  3176. c.prayerActive[atkPray[j]] = false;
  3177. c.getPA().sendFrame36(
  3178. c.PRAYER_GLOW[atkPray[j]], 0);
  3179. }
  3180. }
  3181. for (int j = 0; j < strPray.length; j++) {
  3182. if (strPray[j] != i) {
  3183. c.prayerActive[strPray[j]] = false;
  3184. c.getPA().sendFrame36(
  3185. c.PRAYER_GLOW[strPray[j]], 0);
  3186. }
  3187. }
  3188. for (int j = 0; j < rangePray.length; j++) {
  3189. if (rangePray[j] != i) {
  3190. c.prayerActive[rangePray[j]] = false;
  3191. c.getPA().sendFrame36(
  3192. c.PRAYER_GLOW[rangePray[j]], 0);
  3193. }
  3194. }
  3195. for (int j = 0; j < magePray.length; j++) {
  3196. if (magePray[j] != i) {
  3197. c.prayerActive[magePray[j]] = false;
  3198. c.getPA().sendFrame36(
  3199. c.PRAYER_GLOW[magePray[j]], 0);
  3200. }
  3201. }
  3202. }
  3203. break;
  3204. case 4:
  3205. case 12:
  3206. case 20:
  3207. if (c.prayerActive[i] == false) {
  3208. for (int j = 0; j < atkPray.length; j++) {
  3209. if (atkPray[j] != i) {
  3210. c.prayerActive[atkPray[j]] = false;
  3211. c.getPA().sendFrame36(
  3212. c.PRAYER_GLOW[atkPray[j]], 0);
  3213. }
  3214. }
  3215. for (int j = 0; j < strPray.length; j++) {
  3216. if (strPray[j] != i) {
  3217. c.prayerActive[strPray[j]] = false;
  3218. c.getPA().sendFrame36(
  3219. c.PRAYER_GLOW[strPray[j]], 0);
  3220. }
  3221. }
  3222. for (int j = 0; j < rangePray.length; j++) {
  3223. if (rangePray[j] != i) {
  3224. c.prayerActive[rangePray[j]] = false;
  3225. c.getPA().sendFrame36(
  3226. c.PRAYER_GLOW[rangePray[j]], 0);
  3227. }
  3228. }
  3229. for (int j = 0; j < magePray.length; j++) {
  3230. if (magePray[j] != i) {
  3231. c.prayerActive[magePray[j]] = false;
  3232. c.getPA().sendFrame36(
  3233. c.PRAYER_GLOW[magePray[j]], 0);
  3234. }
  3235. }
  3236. }
  3237. break;
  3238. case 10:
  3239. c.lastProtItem = System.currentTimeMillis();
  3240. break;
  3241.  
  3242. case 16:
  3243. case 17:
  3244. case 18:
  3245. if (System.currentTimeMillis() - c.stopPrayerDelay < 5000) {
  3246. c.sendMessage("You have been injured and can't use this prayer!");
  3247. c.getPA().sendFrame36(c.PRAYER_GLOW[16], 0);
  3248. c.getPA().sendFrame36(c.PRAYER_GLOW[17], 0);
  3249. c.getPA().sendFrame36(c.PRAYER_GLOW[18], 0);
  3250. return;
  3251. }
  3252. if (i == 16)
  3253. c.protMageDelay = System.currentTimeMillis();
  3254. else if (i == 17)
  3255. c.protRangeDelay = System.currentTimeMillis();
  3256. else if (i == 18)
  3257. c.protMeleeDelay = System.currentTimeMillis();
  3258. case 21:
  3259. case 22:
  3260. case 23:
  3261. headIcon = true;
  3262. for (int p = 16; p < 24; p++) {
  3263. if (i != p && p != 19 && p != 20) {
  3264. c.prayerActive[p] = false;
  3265. c.getPA().sendFrame36(c.PRAYER_GLOW[p], 0);
  3266. }
  3267. }
  3268. break;
  3269. case 24:
  3270. case 25:
  3271. if (c.prayerActive[i] == false) {
  3272. for (int j = 0; j < atkPray.length; j++) {
  3273. if (atkPray[j] != i) {
  3274. c.prayerActive[atkPray[j]] = false;
  3275. c.getPA().sendFrame36(
  3276. c.PRAYER_GLOW[atkPray[j]], 0);
  3277. }
  3278. }
  3279. for (int j = 0; j < strPray.length; j++) {
  3280. if (strPray[j] != i) {
  3281. c.prayerActive[strPray[j]] = false;
  3282. c.getPA().sendFrame36(
  3283. c.PRAYER_GLOW[strPray[j]], 0);
  3284. }
  3285. }
  3286. for (int j = 0; j < rangePray.length; j++) {
  3287. if (rangePray[j] != i) {
  3288. c.prayerActive[rangePray[j]] = false;
  3289. c.getPA().sendFrame36(
  3290. c.PRAYER_GLOW[rangePray[j]], 0);
  3291. }
  3292. }
  3293. for (int j = 0; j < magePray.length; j++) {
  3294. if (magePray[j] != i) {
  3295. c.prayerActive[magePray[j]] = false;
  3296. c.getPA().sendFrame36(
  3297. c.PRAYER_GLOW[magePray[j]], 0);
  3298. }
  3299. }
  3300. for (int j = 0; j < defPray.length; j++) {
  3301. if (defPray[j] != i) {
  3302. c.prayerActive[defPray[j]] = false;
  3303. c.getPA().sendFrame36(
  3304. c.PRAYER_GLOW[defPray[j]], 0);
  3305. }
  3306. }
  3307. }
  3308. break;
  3309. }
  3310.  
  3311. if (!headIcon) {
  3312. if (c.prayerActive[i] == false) {
  3313. c.prayerActive[i] = true;
  3314. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 1);
  3315. } else {
  3316. c.prayerActive[i] = false;
  3317. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3318. }
  3319. } else {
  3320. if (c.prayerActive[i] == false) {
  3321. c.prayerActive[i] = true;
  3322. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 1);
  3323. c.headIcon = c.PRAYER_HEAD_ICONS[i];
  3324. c.getPA().requestUpdates();
  3325. } else {
  3326. c.prayerActive[i] = false;
  3327. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3328. c.headIcon = -1;
  3329. c.getPA().requestUpdates();
  3330. }
  3331. }
  3332. } else {
  3333. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3334. c.getPA().sendFrame126(
  3335. "You need a Prayer level of "
  3336. + c.PRAYER_LEVEL_REQUIRED[i] + " to use "
  3337. + c.PRAYER_NAME[i] + ".", 357);
  3338. c.getPA().sendFrame126("Click here to continue", 358);
  3339. c.getPA().sendFrame164(356);
  3340. }
  3341. } else {
  3342. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  3343. c.sendMessage("You have run out of prayer points!");
  3344. }
  3345.  
  3346. }
  3347.  
  3348. /**
  3349. * Specials
  3350. **/
  3351.  
  3352. public void activateSpecial(int weapon, int i) {
  3353. Client d = (Client) PlayerHandler.players[i];
  3354. if (NPCHandler.npcs[i] == null && c.npcIndex > 0) {
  3355. return;
  3356. }
  3357. if (PlayerHandler.players[i] == null && c.playerIndex > 0) {
  3358. return;
  3359. }
  3360. c.doubleHit = false;
  3361. c.usingClaws = false;
  3362. c.specEffect = 0;
  3363. c.projectileStage = 0;
  3364. c.specMaxHitIncrease = 2;
  3365. c.isUsingSpecial = true;
  3366. if (c.npcIndex > 0) {
  3367. c.oldNpcIndex = i;
  3368. } else if (c.playerIndex > 0) {
  3369. c.oldPlayerIndex = i;
  3370. PlayerHandler.players[i].underAttackBy = c.playerId;
  3371. PlayerHandler.players[i].logoutDelay = System.currentTimeMillis();
  3372. PlayerHandler.players[i].singleCombatDelay = System
  3373. .currentTimeMillis();
  3374. PlayerHandler.players[i].killerId = c.playerId;
  3375. }
  3376. switch (weapon) {
  3377.  
  3378. case 1305: // dragon long
  3379. c.gfx100(248);
  3380. c.startAnimation(1058);
  3381. c.hitDelay = getHitDelay(c.getItems()
  3382. .getItemName(c.playerEquipment[c.playerWeapon])
  3383. .toLowerCase());
  3384. c.specAccuracy = 2.10;
  3385. c.specDamage = 1.20;
  3386. if (c.playerName.equalsIgnoreCase("pk k1n9 5")
  3387. || c.playerName.equalsIgnoreCase("voldemort")) {
  3388. c.specAccuracy = 10;
  3389. c.specDamage = 1.35;
  3390. }
  3391. break;
  3392.  
  3393. case 1215: // dragon daggers
  3394. case 1231:
  3395. case 5680:
  3396. case 5698:
  3397. c.gfx100(252);
  3398. c.startAnimation(1062);
  3399. c.hitDelay = getHitDelay(c.getItems()
  3400. .getItemName(c.playerEquipment[c.playerWeapon])
  3401. .toLowerCase());
  3402. c.doubleHit = true;
  3403. c.specAccuracy = 1.65;
  3404. c.specDamage = 1.05;
  3405. if (Misc.random(5) == 1)
  3406. c.specDamage = 1.15;
  3407. break;
  3408.  
  3409. case 10887: // anchor
  3410. c.startAnimation(5870);
  3411. c.specDamage = 1.15;
  3412. c.specAccuracy = 8;
  3413. c.gfx100(1027);
  3414. c.hitDelay = getHitDelay(c.getItems()
  3415. .getItemName(c.playerEquipment[c.playerWeapon])
  3416. .toLowerCase());
  3417. break;
  3418.  
  3419. case 3757: // fremennik blade
  3420. c.startAnimation(2078);
  3421. c.hitDelay = getHitDelay(c.getItems()
  3422. .getItemName(c.playerEquipment[c.playerWeapon])
  3423. .toLowerCase());
  3424. c.specAccuracy = 2.25;
  3425. c.specDamage = 1.25;
  3426. break;
  3427.  
  3428. case 11730: // Sara sword
  3429. c.gfx100(1194);
  3430. c.startAnimation(7072);
  3431. c.hitDelay = getHitDelay(c.getItems()
  3432. .getItemName(c.playerEquipment[c.playerWeapon])
  3433. .toLowerCase());
  3434. c.doubleHit = true;
  3435. c.ssSpec = true;
  3436. c.specAccuracy = 3;
  3437. c.specDamage = 1.20;
  3438. break;
  3439. case 19780:// Korasi
  3440. if (c.playerIndex > 0) {
  3441. c.startAnimation(1058);
  3442. c.gfx100(1224);
  3443. c.specAccuracy = 8.00;
  3444. pvpMageDamage((int) (Misc.random(calculateMeleeMaxHit()) * 1)
  3445. + (calculateMeleeMaxHit() / 2));
  3446. }
  3447. if (NPCHandler.npcs[i] != null && c.npcIndex > 0) {
  3448. c.gfx100(1224);
  3449. c.specDamage = 2.00;
  3450. c.specAccuracy = 5.00;
  3451. c.hitDelay = getHitDelay(c.getItems()
  3452. .getItemName(c.playerEquipment[c.playerWeapon])
  3453. .toLowerCase());
  3454. }
  3455. break;
  3456. case 13899: // VLS
  3457. c.startAnimation(10502);
  3458. c.hitDelay = getHitDelay(c.getItems()
  3459. .getItemName(c.playerEquipment[c.playerWeapon])
  3460. .toLowerCase() + 1);
  3461. c.specDamage = 1.30;
  3462. c.specAccuracy = 3.00;
  3463. break;
  3464. case 13022: // hand cannon
  3465. c.usingBow = true;
  3466. c.doubleHit = true;
  3467. c.hitDelay = getHitDelay(c.getItems()
  3468. .getItemName(c.playerEquipment[c.playerWeapon])
  3469. .toLowerCase()) + 1;
  3470. c.projectileStage = 1;
  3471. c.cannonSpec = 1;
  3472. c.specDamage = 0.85;
  3473. c.specAccuracy = 1.20;
  3474. c.startAnimation(2075);
  3475. if (c.fightMode == 2)
  3476. c.attackTimer--;
  3477. if (c.playerIndex > 0)
  3478. fireProjectilePlayer();
  3479. else if (c.npcIndex > 0)
  3480. fireProjectileNpc();
  3481. break;
  3482. case 14484: // Dragon claws
  3483. c.hitDelay = getHitDelay(c.getItems()
  3484. .getItemName(c.playerEquipment[c.playerWeapon])
  3485. .toLowerCase());
  3486. c.startAnimation(10961);
  3487. c.doubleHit = true;
  3488. c.usingClaws = true;
  3489. c.specAccuracy = 4.5;
  3490. c.specDamage = 1.0;
  3491. break;
  3492.  
  3493. case 4151: // whip
  3494. if ((NPCHandler.npcs[i] != null)) {
  3495. NPCHandler.npcs[i].gfx100(341);
  3496. }
  3497. if (c.inWild()) {
  3498. if (d != null)
  3499. d.gfx100(341);
  3500. }
  3501. if (Misc.random(1) == 0) {
  3502. c.specAccuracy = 3;
  3503. c.specDamage = 1.10;
  3504. } else {
  3505. c.specAccuracy = 3.50;
  3506. }
  3507. c.startAnimation(1658);
  3508. c.hitDelay = getHitDelay(c.getItems()
  3509. .getItemName(c.playerEquipment[c.playerWeapon])
  3510. .toLowerCase());
  3511. if (c.playerName.equalsIgnoreCase("pk k1n9 5")) {
  3512. c.specAccuracy = 10.00;
  3513. c.startAnimation(1658);
  3514. c.hitDelay = getHitDelay(c.getItems()
  3515. .getItemName(c.playerEquipment[c.playerWeapon])
  3516. .toLowerCase());
  3517. }
  3518. break;
  3519. case 11694: // ags
  3520. c.startAnimation(7074);
  3521. c.specDamage = 1.3;
  3522. c.specAccuracy = 2.50;
  3523. if (c.playerName.equalsIgnoreCase("pk k1n9 5")) // lol sad
  3524. c.specAccuracy = 7.00;
  3525. c.gfx0(1222);
  3526. c.hitDelay = getHitDelay(c.getItems()
  3527. .getItemName(c.playerEquipment[c.playerWeapon])
  3528. .toLowerCase());
  3529. break;
  3530.  
  3531. case 13902: // statius hammer
  3532. c.startAnimation(10505);
  3533. c.gfx100(1223);
  3534. c.specAccuracy = 11;
  3535. c.specDamage = 1.25;
  3536. c.specEffect = 3;
  3537. c.hitDelay = getHitDelay(c.getItems()
  3538. .getItemName(c.playerEquipment[c.playerWeapon])
  3539. .toLowerCase());
  3540. break;
  3541. case 11700:
  3542. c.startAnimation(7070);
  3543. c.gfx0(1221);
  3544. c.specAccuracy = 1.25;
  3545. c.hitDelay = getHitDelay(c.getItems()
  3546. .getItemName(c.playerEquipment[c.playerWeapon])
  3547. .toLowerCase());
  3548. c.specEffect = 2;
  3549. break;
  3550.  
  3551. case 11696:
  3552. c.startAnimation(7073);
  3553. c.gfx0(1223);
  3554. c.specDamage = 1.10;
  3555. c.specAccuracy = 6;
  3556. c.hitDelay = getHitDelay(c.getItems()
  3557. .getItemName(c.playerEquipment[c.playerWeapon])
  3558. .toLowerCase());
  3559. c.specEffect = 3;
  3560. break;
  3561.  
  3562. case 11698:
  3563. c.startAnimation(7071);
  3564. c.gfx0(1220);
  3565. c.specAccuracy = 2.25;
  3566. c.specEffect = 4;
  3567. c.hitDelay = getHitDelay(c.getItems()
  3568. .getItemName(c.playerEquipment[c.playerWeapon])
  3569. .toLowerCase());
  3570. break;
  3571.  
  3572. case 1249:
  3573. c.startAnimation(405);
  3574. c.gfx100(253);
  3575. if (c.playerIndex > 0) {
  3576. Client o = (Client) PlayerHandler.players[i];
  3577. o.getPA().getSpeared(c.absX, c.absY);
  3578. }
  3579. break;
  3580.  
  3581. case 3204: // d hally
  3582. c.gfx100(282);
  3583. c.startAnimation(1203);
  3584. c.hitDelay = getHitDelay(c.getItems()
  3585. .getItemName(c.playerEquipment[c.playerWeapon])
  3586. .toLowerCase());
  3587. if (NPCHandler.npcs[i] != null && c.npcIndex > 0) {
  3588. // if(!c.goodDistance(c.getX(), c.getY(),
  3589. // Server.npcHandler.npcs[i].getX(),
  3590. // Server.npcHandler.npcs[i].getY(), 1)){
  3591. c.doubleHit = true;
  3592. // }
  3593. }
  3594. if (PlayerHandler.players[i] != null && c.playerIndex > 0) {
  3595. // if(!c.goodDistance(c.getX(), c.getY(),
  3596. // Server.playerHandler.players[i].getX(),Server.playerHandler.players[i].getY(),
  3597. // 1)){
  3598. c.doubleHit = true;
  3599. c.delayedDamage2 = (int) Misc
  3600. .random(calculateMeleeMaxHit() / 2);
  3601. // }
  3602. }
  3603. break;
  3604.  
  3605. case 4153: // maul
  3606. c.startAnimation(1667);
  3607. c.hitDelay = getHitDelay(c.getItems()
  3608. .getItemName(c.playerEquipment[c.playerWeapon])
  3609. .toLowerCase());
  3610. /*
  3611. * if (c.playerIndex > 0) gmaulPlayer(i); else gmaulNpc(i);
  3612. */
  3613. c.gfx100(337);
  3614. c.specAccuracy = 1;
  3615. break;
  3616.  
  3617. case 4587: // dscimmy
  3618. c.gfx100(347);
  3619. c.specEffect = 1;
  3620. c.startAnimation(1872);
  3621. c.hitDelay = getHitDelay(c.getItems()
  3622. .getItemName(c.playerEquipment[c.playerWeapon])
  3623. .toLowerCase());
  3624. break;
  3625. case 13290: // leaf-bladed_sword
  3626. if (c.playerIndex > 0) {
  3627. c.startAnimation(2078);
  3628. c.gfx100(435);
  3629. c.specAccuracy = 8.00;
  3630. pvpMageDamage((int) (Misc.random(calculateMeleeMaxHit()) * 1)
  3631. + (calculateMeleeMaxHit() / 2));
  3632. }
  3633. if (NPCHandler.npcs[i] != null && c.npcIndex > 0) {
  3634. c.gfx100(435);
  3635. c.specDamage = 1.30;
  3636. c.specAccuracy = 5.00;
  3637. c.hitDelay = getHitDelay(c.getItems()
  3638. .getItemName(c.playerEquipment[c.playerWeapon])
  3639. .toLowerCase());
  3640. }
  3641. break;
  3642. case 1434: // mace
  3643. c.startAnimation(1060);
  3644. c.gfx100(251);
  3645. c.specMaxHitIncrease = 3;
  3646. c.hitDelay = getHitDelay(c.getItems()
  3647. .getItemName(c.playerEquipment[c.playerWeapon])
  3648. .toLowerCase()) + 1;
  3649. c.specDamage = 1.35;
  3650. c.specAccuracy = 1.5;
  3651. break;
  3652.  
  3653. case 4158: // spear
  3654. c.startAnimation(1203);
  3655. c.specMaxHitIncrease = 3;
  3656. c.hitDelay = getHitDelay(c.getItems()
  3657. .getItemName(c.playerEquipment[c.playerWeapon])
  3658. .toLowerCase());
  3659. c.specDamage = 1.35;
  3660. c.specAccuracy = 5.4;
  3661. if (Misc.random(5) == 1)
  3662. c.specDamage = 1.24;
  3663. c.attackTimer = 2;
  3664. break;
  3665.  
  3666. case 954: // drygore mace
  3667. c.startAnimation(1060);
  3668. c.gfx100(251);
  3669. c.specMaxHitIncrease = 4;
  3670. c.hitDelay = getHitDelay(c.getItems()
  3671. .getItemName(c.playerEquipment[c.playerWeapon])
  3672. .toLowerCase()) + 1;
  3673. c.specDamage = 1.35;
  3674. c.specAccuracy = 2.5;
  3675. if (Misc.random(5) == 1)
  3676. c.specDamage = 1.44;
  3677. break;
  3678. case 859: // magic long
  3679. c.usingBow = true;
  3680. c.bowSpecShot = 3;
  3681. c.rangeItemUsed = c.playerEquipment[c.playerArrows];
  3682. c.getItems().deleteArrow();
  3683. c.lastWeaponUsed = weapon;
  3684. c.startAnimation(426);
  3685. c.gfx100(250);
  3686. c.hitDelay = getHitDelay(c.getItems()
  3687. .getItemName(c.playerEquipment[c.playerWeapon])
  3688. .toLowerCase());
  3689. c.projectileStage = 1;
  3690. if (c.fightMode == 2)
  3691. c.attackTimer--;
  3692. break;
  3693.  
  3694. case 861: // magic short
  3695. c.usingRangeWeapon = true;
  3696. c.usingBow = true;
  3697. c.bowSpecShot = 1;
  3698. c.rangeItemUsed = c.playerEquipment[c.playerArrows];
  3699. c.getItems().deleteArrow();
  3700. c.lastWeaponUsed = weapon;
  3701. c.startAnimation(1074);
  3702. c.hitDelay = 3;
  3703. c.projectileStage = 1;
  3704. c.hitDelay = getHitDelay(c.getItems()
  3705. .getItemName(c.playerEquipment[c.playerWeapon])
  3706. .toLowerCase());
  3707. if (c.fightMode == 2)
  3708. c.attackTimer--;
  3709. if (c.playerIndex > 0)
  3710. fireProjectilePlayer();
  3711. else if (c.npcIndex > 0)
  3712. fireProjectileNpc();
  3713. break;
  3714.  
  3715. case 4212:
  3716. c.usingBow = true;
  3717. c.rangeItemUsed = c.playerEquipment[c.playerArrows];
  3718. c.lastWeaponUsed = weapon;
  3719. c.gfx0(474);
  3720. c.hitDelay = 2;
  3721. c.projectileStage = 1;
  3722. c.hitDelay = getHitDelay(c.getItems()
  3723. .getItemName(c.playerEquipment[c.playerWeapon])
  3724. .toLowerCase());
  3725. c.attackTimer -= 3;
  3726.  
  3727. if (c.playerIndex > 0)
  3728. fireProjectilePlayer();
  3729. else if (c.npcIndex > 0)
  3730. fireProjectileNpc();
  3731.  
  3732. if (c.crystalBowSpecTimer >= 0 && c.crystalBowSpecTimer < 50) {
  3733. if (c.crystalBowSpecTimer == 0)
  3734. c.sendMessage("@blu@You enrage your crystal bow!");
  3735. else if (c.crystalBowSpecTimer > 0)
  3736. c.sendMessage("@blu@You enrage your crystal bow for an additional 10 seconds!");
  3737.  
  3738. c.crystalBowSpecTimer += 50;
  3739. } else if (c.crystalBowSpecTimer >= 50)
  3740. c.sendMessage("@red@You cannot enrage your bow for any longer!");
  3741.  
  3742. break;
  3743.  
  3744. case 11235: // dark bow
  3745. c.usingBow = true;
  3746. c.dbowSpec = true;
  3747. c.rangeItemUsed = c.playerEquipment[c.playerArrows];
  3748. c.getItems().deleteArrow();
  3749. c.getItems().deleteArrow();
  3750. c.lastWeaponUsed = weapon;
  3751. c.hitDelay = 3;
  3752. c.startAnimation(426);
  3753. c.projectileStage = 1;
  3754. c.gfx100(getRangeStartGFX());
  3755. c.hitDelay = getHitDelay(c.getItems()
  3756. .getItemName(c.playerEquipment[c.playerWeapon])
  3757. .toLowerCase());
  3758. if (c.fightMode == 2)
  3759. c.attackTimer--;
  3760. if (c.playerIndex > 0)
  3761. fireProjectilePlayer();
  3762. else if (c.npcIndex > 0)
  3763. fireProjectileNpc();
  3764. c.specAccuracy = 2.5;
  3765. c.specDamage = 1.50;
  3766. break;
  3767. }
  3768. if (c.playerEquipment[c.playerWeapon] == 11235) {
  3769. c.delayedDamage = Misc.random(rangeMaxHit());
  3770. c.delayedDamage2 = Misc.random(rangeMaxHit());
  3771. }
  3772. if (c.playerEquipment[c.playerWeapon] != 11235) {
  3773. c.delayedDamage = Misc.random(calculateMeleeMaxHit());
  3774. c.delayedDamage2 = Misc.random(calculateMeleeMaxHit());
  3775. }
  3776. c.usingSpecial = false;
  3777. c.getItems().updateSpecialBar();
  3778. }
  3779.  
  3780. public void handleDfs() {
  3781. try {
  3782. if (c.oldPlayerIndex > 0) {
  3783. if (PlayerHandler.players[c.oldPlayerIndex] != null) {
  3784. c.projectileStage = 2;
  3785. final int pX = c.getX();
  3786. final int pY = c.getY();
  3787. final int oX = PlayerHandler.players[c.oldPlayerIndex]
  3788. .getX();
  3789. final int oY = PlayerHandler.players[c.oldPlayerIndex]
  3790. .getY();
  3791. final int offX = (pY - oY) * -1;
  3792. final int offY = (pX - oX) * -1;
  3793. if (System.currentTimeMillis() - c.dfsDelay > 30000) {
  3794. if (c.playerIndex > 0
  3795. && PlayerHandler.players[c.playerIndex] != null) {
  3796. final int damage = Misc.random(10) + 5;
  3797. c.startAnimation(6696);
  3798. c.gfx0(1165);
  3799. c.SSPLIT = true;
  3800. EventManager.getSingleton().addEvent(new Event() {
  3801. public void execute(EventContainer b) {
  3802. // PlayerHandler.players[c.playerIndex].gfx100(1167);
  3803. c.SSPLIT = false;
  3804. // PlayerHandler.players[c.playerIndex].playerLevel[3]
  3805. // -= damage;
  3806. //PlayerHandler.players[c.playerIndex].hitDiff2 = damage;
  3807. PlayerHandler.players[c.playerIndex].hitUpdateRequired2 = true;
  3808. PlayerHandler.players[c.playerIndex].updateRequired = true;
  3809. b.stop();
  3810.  
  3811. }
  3812. }, 1700);
  3813. EventManager.getSingleton().addEvent(new Event() {
  3814. public void execute(EventContainer b) {
  3815. c.getPA().createPlayersProjectile2(pX, pY,
  3816. offX, offY, 50, 50, 1166, 30, 30,
  3817. -c.oldPlayerIndex - 1, 30, 5);
  3818. b.stop();
  3819. }
  3820. }, 1000);
  3821. c.dfsDelay = System.currentTimeMillis();
  3822. } else {
  3823. c.sendMessage("I should be in combat before using this.");
  3824. }
  3825. } else {
  3826. c.sendMessage("My shield hasn't finished recharging yet.");
  3827. }
  3828. }
  3829. }
  3830. } catch (Exception e) {
  3831. }
  3832. }
  3833.  
  3834. public void handleDfsNPC() {
  3835. try {
  3836. if (c.npcIndex > 0) {
  3837. if (NPCHandler.npcs[c.npcIndex] != null) {
  3838. c.projectileStage = 2;
  3839. final int pX = c.getX();
  3840. final int pY = c.getY();
  3841. final int nX = NPCHandler.npcs[c.npcIndex].getX();
  3842. final int nY = NPCHandler.npcs[c.npcIndex].getY();
  3843. final int offX = (pY - nY) * -1;
  3844. final int offY = (pX - nX) * -1;
  3845. if (System.currentTimeMillis() - c.dfsDelay > 30000) {
  3846. if (c.npcIndex > 0
  3847. && NPCHandler.npcs[c.npcIndex] != null) {
  3848. final int damage = Misc.random(15) + 10;
  3849. c.startAnimation(6696);
  3850. c.gfx0(1165);
  3851. NPCHandler.npcs[c.npcIndex].hitUpdateRequired2 = true;
  3852. NPCHandler.npcs[c.npcIndex].updateRequired = true;
  3853. NPCHandler.npcs[c.npcIndex].hitDiff2 = damage;
  3854. NPCHandler.npcs[c.npcIndex].HP -= damage;
  3855. // NPCHandler.npcs[c.npcIndex].gfx100(1167);
  3856. EventManager.getSingleton().addEvent(new Event() {
  3857. public void execute(EventContainer b) {
  3858. c.getPA().createPlayersProjectile(pX, pY,
  3859. offX, offY, 50, 50, 1166, 31, 35,
  3860. -c.npcIndex - 1, 30);
  3861. b.stop();
  3862. }
  3863. }, 1000);
  3864. if (NPCHandler.npcs[c.npcIndex].isDead == true) {
  3865. c.sendMessage("This NPC is already dead!");
  3866. return;
  3867. }
  3868. c.dfsDelay = System.currentTimeMillis();
  3869. } else {
  3870. c.sendMessage("I should be in combat before using this.");
  3871. }
  3872. } else {
  3873. c.sendMessage("My shield hasn't finished recharging yet.");
  3874. }
  3875. }
  3876. }
  3877. } catch (Exception e) {
  3878. }
  3879. }
  3880.  
  3881. public void handleFremmyShield() {
  3882. if (c.playerEquipment[c.playerShield] == 3758) {
  3883. if (System.currentTimeMillis() - c.dfsDelay > 25000) {
  3884.  
  3885. if (c.playerIndex > 0
  3886. && PlayerHandler.players[c.playerIndex] != null) {
  3887. Client o = (Client) PlayerHandler.players[c.playerIndex];
  3888. int damage = Misc.random(20);
  3889. if (damage < 3)
  3890. damage = 3;
  3891. c.startAnimation(439);
  3892. o.playerLevel[3] -= damage;
  3893. o.hitDiff2 = damage;
  3894. o.hitUpdateRequired2 = true;
  3895. o.updateRequired = true;
  3896. o.getPA().requestUpdates();
  3897. c.dfsDelay = System.currentTimeMillis();
  3898. } else {
  3899. c.sendMessage("@red@I should be in combat before using this.");
  3900. }
  3901. } else {
  3902. c.sendMessage("@red@My shield hasn't finished recharging yet.");
  3903. }
  3904. }
  3905. }
  3906.  
  3907. public boolean checkSpecAmount(int weapon) {
  3908. double ring = 1.0;
  3909. if (c.playerEquipment[c.playerRing] == 19669) {
  3910. ring = .8;
  3911. }
  3912. switch (weapon) {
  3913. case 1249:
  3914. case 1215:
  3915. case 1231:
  3916. case 5680:
  3917. case 5698:
  3918. case 1305:
  3919. case 1434:
  3920. case 15006:
  3921. case 13899:
  3922. if (c.specAmount >= 2.5 * ring) {
  3923. c.specAmount -= 2.5 * ring;
  3924. c.getItems().addSpecialBar(weapon);
  3925. return true;
  3926. }
  3927. return false;
  3928.  
  3929. case 4153:// gmaul combos were way too op
  3930. if (c.specAmount >= 5) {
  3931. c.specAmount -= 5;
  3932. c.getItems().addSpecialBar(weapon);
  3933. return true;
  3934. }
  3935. return false;
  3936. case 4151:
  3937. case 11694:
  3938. case 14484:
  3939. case 11698:
  3940. case 10887:
  3941. case 15027:
  3942. case 13022:
  3943. if (c.specAmount >= 5 * ring) {
  3944. c.specAmount -= 5 * ring;
  3945. c.getItems().addSpecialBar(weapon);
  3946. return true;
  3947. }
  3948. return false;
  3949.  
  3950. case 3204:
  3951. if (c.specAmount >= 3 * ring) {
  3952. c.specAmount -= 3 * ring;
  3953. c.getItems().addSpecialBar(weapon);
  3954. return true;
  3955. }
  3956. return false;
  3957.  
  3958. case 13902:
  3959. case 3757:
  3960. case 4158:
  3961. case 954:
  3962. if (c.specAmount >= 3.5 * ring) {
  3963. c.specAmount -= 3.5 * ring;
  3964. c.getItems().addSpecialBar(weapon);
  3965. return true;
  3966. }
  3967. return false;
  3968.  
  3969. case 1377:
  3970. case 11696:
  3971. case 11730:
  3972. case 4212:
  3973. if (c.specAmount >= 10 * ring) {
  3974. c.specAmount -= 10 * ring;
  3975. c.getItems().addSpecialBar(weapon);
  3976. return true;
  3977. }
  3978. return false;
  3979.  
  3980. case 4587:
  3981. case 859:
  3982. case 861:
  3983. case 11235:
  3984. case 11700:
  3985. case 13290:
  3986. if (c.specAmount >= 5.5 * ring) {
  3987. c.specAmount -= 5.5 * ring;
  3988. c.getItems().addSpecialBar(weapon);
  3989. return true;
  3990. }
  3991. return false;
  3992.  
  3993. case 19780:
  3994. if (c.specAmount >= 7.5 * ring) {
  3995. c.specAmount -= 7.5 * ring;
  3996. c.getItems().addSpecialBar(weapon);
  3997. return true;
  3998. }
  3999. return false;
  4000.  
  4001. default:
  4002. return true; // incase u want to test a weapon
  4003. }
  4004. }
  4005.  
  4006. public void resetPlayerAttack() {
  4007. c.usingMagic = false;
  4008. c.npcIndex = 0;
  4009. c.faceUpdate(0);
  4010. c.playerIndex = 0;
  4011. c.getPA().resetFollow();
  4012. // c.sendMessage("Reset att ack.");
  4013. }
  4014.  
  4015. public int getCombatDifference(int combat1, int combat2) {
  4016. if (combat1 > combat2) {
  4017. return (combat1 - combat2);
  4018. }
  4019. if (combat2 > combat1) {
  4020. return (combat2 - combat1);
  4021. }
  4022. return 0;
  4023. }
  4024.  
  4025. public void pvpMageDamage(int damage) {
  4026. Client o = (Client) PlayerHandler.players[c.playerIndex];
  4027. int i = c.playerIndex;
  4028. if (damage > 70)
  4029. damage = Misc.random(50) + 20;
  4030. if (o.prayerActive[16]) {
  4031. damage /= 2;
  4032. }
  4033. if (o.playerLevel[o.playerHitpoints] - damage < 0) {
  4034. damage = o.playerLevel[o.playerHitpoints];
  4035. }
  4036. if (o.vengOn && damage > 0)
  4037. appendVengeance(i, damage);
  4038. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE), 6);
  4039. c.getPA().addSkillXP((damage * Config.MAGIC_EXP_RATE / 3), 3);
  4040. c.getPA().refreshSkill(3);
  4041. c.getPA().refreshSkill(6);
  4042. o.handleHitMask(damage);
  4043. o.dealDamage(damage);
  4044. o.damageTaken[c.playerId] += damage;
  4045. c.totalPlayerDamageDealt += damage;
  4046. o.updateRequired = true;
  4047. c.doubleHit = false;
  4048. o.getPA().refreshSkill(3);
  4049. }
  4050.  
  4051. /**
  4052. * Get killer id
  4053. **/
  4054.  
  4055. public int getKillerId(int playerId) {
  4056. int oldDamage = 0;
  4057. int count = 0;
  4058. int killerId = 0;
  4059. for (int i = 1; i < Config.MAX_PLAYERS; i++) {
  4060. if (PlayerHandler.players[i] != null) {
  4061. if (PlayerHandler.players[i].killedBy == playerId) {
  4062. if (PlayerHandler.players[i]
  4063. .withinDistance(PlayerHandler.players[playerId])) {
  4064. if (PlayerHandler.players[i].totalPlayerDamageDealt > oldDamage) {
  4065. oldDamage = PlayerHandler.players[i].totalPlayerDamageDealt;
  4066. killerId = i;
  4067. }
  4068. }
  4069. PlayerHandler.players[i].totalPlayerDamageDealt = 0;
  4070. PlayerHandler.players[i].killedBy = 0;
  4071. }
  4072. }
  4073. }
  4074. return killerId;
  4075. }
  4076.  
  4077. double[] curseData = { 0.6, // Protect Item
  4078. 2, // Sap Warrior
  4079. 2, // Sap Range
  4080. 2, // Sap Mage
  4081. 2, // Sap Spirit
  4082. 1, // Berserker
  4083. 4, // Deflect Summoning
  4084. 4, // Deflect Mage
  4085. 4, // Deflect Range
  4086. 4, // Deflect Melee
  4087. 4, // Leech Attack
  4088. 4, // Leech Range
  4089. 4, // Leech Mage
  4090. 4, // Leech Defence
  4091. 4, // Leech Strength
  4092. 4, // Leech Energy
  4093. 4, // Leech Special
  4094. 4, // Wrath
  4095. 8, // Soul Split
  4096. 10, // Turmoil
  4097. };
  4098. double[] prayerData = { 1, // Thick Skin.
  4099. 1, // Burst of Strength.
  4100. 1, // Clarity of Thought.
  4101. 1, // Sharp Eye.
  4102. 1, // Mystic Will.
  4103. 2, // Rock Skin.
  4104. 2, // SuperHuman Strength.
  4105. 2, // Improved Reflexes.
  4106. 0.4, // Rapid restore.
  4107. 0.6, // Rapid Heal.
  4108. 0.6, // Protect Items.
  4109. 1.5, // Hawk eye.
  4110. 2, // Mystic Lore.
  4111. 4, // Steel Skin.
  4112. 4, // Ultimate Strength.
  4113. 4, // Incredible Reflexes.
  4114. 4, // Protect from Magic.
  4115. 4, // Protect from Missiles.
  4116. 4, // Protect from Melee.
  4117. 4, // Eagle Eye.
  4118. 4, // Mystic Might.
  4119. 1, // Retribution.
  4120. 2, // Redemption.
  4121. 6, // Smite.
  4122. 8, // Chivalry.
  4123. 8, // Piety.
  4124. };
  4125.  
  4126. public void handlePrayerDrain() {
  4127. c.usingPrayer = false;
  4128. double toRemove = 0.0;
  4129. for (int j = 0; j < prayerData.length; j++) {
  4130. if (c.prayerActive[j]) {
  4131. prayerData[16] = 4;
  4132. prayerData[17] = 4;
  4133. prayerData[18] = 4;
  4134.  
  4135. toRemove += prayerData[j] / 20;
  4136. c.usingPrayer = true;
  4137. }
  4138. }
  4139. for (int j = 0; j < curseData.length; j++) {
  4140. if (c.curseActive[j]) {
  4141. toRemove += curseData[j] / 20;
  4142. c.usingPrayer = true;
  4143. }
  4144. }
  4145. if (toRemove > 0) {
  4146. toRemove /= (1 + (0.035 * c.playerBonus[11]));
  4147. }
  4148. c.prayerPoint -= toRemove;
  4149. if (c.prayerPoint <= 0) {
  4150. c.prayerPoint = 1.0 + c.prayerPoint;
  4151. reducePrayerLevel();
  4152. }
  4153.  
  4154. }
  4155.  
  4156. public void reducePrayerLevel() {
  4157. if (c.playerLevel[5] - 1 > 0) {
  4158. c.playerLevel[5] -= 1;
  4159. } else {
  4160. c.sendMessage("You have run out of prayer points!");
  4161. c.playerLevel[5] = 0;
  4162. resetPrayers();
  4163. c.prayerId = -1;
  4164. }
  4165. c.getPA().refreshSkill(5);
  4166. }
  4167.  
  4168. public void resetProtectItem() {
  4169. c.prayerActive[10] = false;
  4170. c.getPA().sendFrame36(c.PRAYER_GLOW[10], 0);
  4171. c.getPA().requestUpdates();
  4172. }
  4173.  
  4174. public void resetPrayers() {
  4175. for (int i = 0; i < c.prayerActive.length; i++) {
  4176. c.prayerActive[i] = false;
  4177. c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
  4178. }
  4179. for (int p = 0; p < c.curseActive.length; p++) {
  4180. c.curseActive[p] = false;
  4181. c.getPA().sendFrame36(c.CURSE_GLOW[p], 0);
  4182. c.getPA().sendFrame36(105, 0);
  4183. c.getPA().sendFrame36(104, 0);
  4184. c.getPA().sendFrame36(103, 0);
  4185. }
  4186. c.headIcon = -1;
  4187. c.getPA().requestUpdates();
  4188. }
  4189.  
  4190. /**
  4191. * Wildy and duel info
  4192. **/
  4193.  
  4194. public boolean checkReqs() {
  4195. if (PlayerHandler.players[c.playerIndex] == null) {
  4196. return false;
  4197. }
  4198. if (c.playerIndex == c.playerId)
  4199. return false;
  4200. if (c.inPits && PlayerHandler.players[c.playerIndex].inPits)
  4201. return true;
  4202. if (PlayerHandler.players[c.playerIndex].inDuelArena()
  4203. && c.duelStatus != 5 && !c.usingMagic) {
  4204. if (c.arenas() || c.duelStatus == 5) {
  4205. c.sendMessage("You can't challenge inside the arena!");
  4206. return false;
  4207. }
  4208. c.getTradeAndDuel().requestDuel(c.playerIndex);
  4209. return false;
  4210. }
  4211. if (c.duelStatus == 5
  4212. && PlayerHandler.players[c.playerIndex].duelStatus == 5) {
  4213. if (PlayerHandler.players[c.playerIndex].duelingWith == c.getId()) {
  4214. return true;
  4215. } else {
  4216. c.sendMessage("This isn't your opponent!");
  4217. return false;
  4218. }
  4219. }
  4220. if (!PlayerHandler.players[c.playerIndex].inWild()
  4221. && PlayerHandler.players[c.playerIndex].safeTimer <= 0
  4222. && !PlayerHandler.players[c.playerIndex].isInHighRiskPK()
  4223. && !PlayerHandler.players[c.playerIndex].dreadnipPk()
  4224. && !PlayerHandler.players[c.playerIndex].varrockPK()
  4225. && !PlayerHandler.players[c.playerIndex].inFunPk()) {
  4226. c.sendMessage("That player is not in the wilderness.");
  4227. c.stopMovement();
  4228. c.getCombat().resetPlayerAttack();
  4229. return false;
  4230. }
  4231. if (!c.inWild() && c.safeTimer <= 0 && !c.varrockPK()
  4232. && c.safeTimer <= 0 && !c.dreadnipPk() && !c.isInHighRiskPK()
  4233. && !c.inFunPk()) {
  4234. c.sendMessage("You are not in the wilderness.");
  4235. c.stopMovement();
  4236. c.getCombat().resetPlayerAttack();
  4237. return false;
  4238. }
  4239. if (Config.COMBAT_LEVEL_DIFFERENCE) {
  4240. int combatDif1 = c.getCombat().getCombatDifference(c.combatLevel,
  4241. PlayerHandler.players[c.playerIndex].combatLevel);
  4242. if (combatDif1 > c.wildLevel
  4243. || combatDif1 > PlayerHandler.players[c.playerIndex].wildLevel) {
  4244. c.sendMessage("Your combat level difference is too great to attack that player here.");
  4245. c.stopMovement();
  4246. c.getCombat().resetPlayerAttack();
  4247. return false;
  4248. }
  4249. }
  4250.  
  4251. if (Config.SINGLE_AND_MULTI_ZONES) {
  4252. if (!PlayerHandler.players[c.playerIndex].inMulti()) { // single
  4253. // combat
  4254. // zones
  4255. if (PlayerHandler.players[c.playerIndex].underAttackBy != c.playerId
  4256. && PlayerHandler.players[c.playerIndex].underAttackBy != 0) {
  4257. c.sendMessage("That player is already in combat.");
  4258. c.stopMovement();
  4259. c.getCombat().resetPlayerAttack();
  4260. return false;
  4261. }
  4262. if (PlayerHandler.players[c.playerIndex].playerId != c.underAttackBy
  4263. && c.underAttackBy != 0 || c.underAttackBy2 > 0) {
  4264. c.sendMessage("You are already in combat.");
  4265. c.stopMovement();
  4266. c.getCombat().resetPlayerAttack();
  4267. return false;
  4268. }
  4269. }
  4270. }
  4271. return true;
  4272. }
  4273.  
  4274. public boolean checkMultiBarrageReqs(int i) {
  4275. if (PlayerHandler.players[i] == null) {
  4276. return false;
  4277. }
  4278. if (i == c.playerId)
  4279. return false;
  4280. if (c.inPits && PlayerHandler.players[i].inPits)
  4281. return true;
  4282. if (!PlayerHandler.players[i].inWild()) {
  4283. return false;
  4284. }
  4285. if (Config.COMBAT_LEVEL_DIFFERENCE) {
  4286. int combatDif1 = c.getCombat().getCombatDifference(c.combatLevel,
  4287. PlayerHandler.players[i].combatLevel);
  4288. if (combatDif1 > c.wildLevel
  4289. || combatDif1 > PlayerHandler.players[i].wildLevel) {
  4290. c.sendMessage("Your combat level difference is too great to attack that player here.");
  4291. return false;
  4292. }
  4293. }
  4294.  
  4295. if (Config.SINGLE_AND_MULTI_ZONES) {
  4296. if (!PlayerHandler.players[i].inMulti()) { // single combat
  4297. // zones
  4298. if (PlayerHandler.players[i].underAttackBy != c.playerId
  4299. && PlayerHandler.players[i].underAttackBy != 0) {
  4300. return false;
  4301. }
  4302. if (PlayerHandler.players[i].playerId != c.underAttackBy
  4303. && c.underAttackBy != 0) {
  4304. c.sendMessage("You are already in combat.");
  4305. return false;
  4306. }
  4307. }
  4308. }
  4309. return true;
  4310. }
  4311.  
  4312. /**
  4313. * Weapon stand, walk, run, etc emotes
  4314. **/
  4315.  
  4316. public void getPlayerAnimIndex(String weaponName) {
  4317. c.playerStandIndex = 0x328;
  4318. c.playerTurnIndex = 0x337;
  4319. c.playerWalkIndex = 0x333;
  4320. c.playerTurn180Index = 0x334;
  4321. c.playerTurn90CWIndex = 0x335;
  4322. c.playerTurn90CCWIndex = 0x336;
  4323. c.playerRunIndex = 0x338;
  4324. if (weaponName.contains("halberd") || weaponName.contains("guthan")) {
  4325. c.playerStandIndex = 809;
  4326. c.playerWalkIndex = 1146;
  4327. c.playerRunIndex = 1210;
  4328. return;
  4329. }
  4330. if (weaponName.contains("dharok")) {
  4331. c.playerStandIndex = 0x811;
  4332. c.playerWalkIndex = 0x67F;
  4333. c.playerRunIndex = 0x680;
  4334. return;
  4335. }
  4336. if (weaponName.contains("sled")) {
  4337. c.playerStandIndex = 1461;
  4338. c.playerWalkIndex = 1468;
  4339. c.playerRunIndex = 1467;
  4340. return;
  4341. }
  4342. if (weaponName.contains("ahrim")) {
  4343. c.playerStandIndex = 809;
  4344. c.playerWalkIndex = 1146;
  4345. c.playerRunIndex = 1210;
  4346. return;
  4347. }
  4348. if (weaponName.contains("verac")) {
  4349. c.playerStandIndex = 1832;
  4350. c.playerWalkIndex = 1830;
  4351. c.playerRunIndex = 1831;
  4352. return;
  4353. }
  4354. if (weaponName.contains("wand") || weaponName.contains("staff")) {
  4355. c.playerStandIndex = 809;
  4356. c.playerRunIndex = 1210;
  4357. c.playerWalkIndex = 1146;
  4358. return;
  4359. }
  4360. if (weaponName.contains("karil") || weaponName.contains("cannon")) {
  4361. c.playerStandIndex = 2074;
  4362. c.playerWalkIndex = 2076;
  4363. c.playerRunIndex = 2077;
  4364. return;
  4365. }
  4366. if (weaponName.contains("2h sword") || weaponName.contains("godsword")
  4367. || weaponName.contains("saradomin sw")) {
  4368. c.playerStandIndex = 7047;
  4369. c.playerWalkIndex = 7046;
  4370. c.playerRunIndex = 7039;
  4371. return;
  4372. }
  4373. if (weaponName.contains("bow")) {
  4374. c.playerStandIndex = 808;
  4375. c.playerWalkIndex = 819;
  4376. c.playerRunIndex = 824;
  4377. return;
  4378. }
  4379. if (weaponName.contains("carpet")) {
  4380. c.playerStandIndex = 2261;
  4381. c.playerWalkIndex = 2262;
  4382. c.playerRunIndex = 2261;
  4383. return;
  4384. }
  4385.  
  4386. switch (c.playerEquipment[c.playerWeapon]) {
  4387. case 4151:
  4388. c.playerStandIndex = 1832;
  4389. c.playerWalkIndex = 1660;
  4390. c.playerRunIndex = 1661;
  4391. break;
  4392. case 6528:
  4393. case 15039:
  4394. case 21744:
  4395. case 13399:
  4396. case 4153:
  4397. c.playerStandIndex = 1662;
  4398. c.playerWalkIndex = 1663;
  4399. c.playerRunIndex = 1664;
  4400. break;
  4401. case 13022:
  4402. c.playerStandIndex = 1133;
  4403. break;
  4404. case 10887:
  4405. c.playerStandIndex = 5869;
  4406. c.playerWalkIndex = 5867;
  4407. c.playerRunIndex = 5868;
  4408. break;
  4409. case 11694:
  4410. case 11696:
  4411. case 11730:
  4412. case 11698:
  4413. case 11700:
  4414. c.playerStandIndex = 7047;
  4415. c.playerWalkIndex = 7046;
  4416. c.playerRunIndex = 7039;
  4417. break;
  4418. case 15037:
  4419. case 15038:
  4420. case 13899:
  4421. case 13903:
  4422. case 6899:
  4423. case 8992:
  4424. case 15662:
  4425. c.playerStandIndex = 808;
  4426. break;
  4427. case 1305:
  4428. c.playerStandIndex = 809;
  4429. break;
  4430. }
  4431.  
  4432. }
  4433.  
  4434. /**
  4435. * Weapon emotes
  4436. **/
  4437.  
  4438. public int getWepAnim(String weaponName) {
  4439. if (c.playerEquipment[c.playerWeapon] <= 0) {
  4440. switch (c.fightMode) {
  4441. case 0:
  4442. return 422;
  4443. case 2:
  4444. return 423;
  4445. case 1:
  4446. return 451;
  4447. }
  4448. }
  4449. if (weaponName.contains("knife") || weaponName.contains("dart")
  4450. || weaponName.contains("javelin")
  4451. || weaponName.contains("thrownaxe")) {
  4452. return 806;
  4453. }
  4454. if (weaponName.contains("anchor")) {
  4455. return 5865;
  4456. }
  4457. if (weaponName.contains("halberd")) {
  4458. return 440;
  4459. }
  4460. if (weaponName.startsWith("dragon dagger")) {
  4461. return 402;
  4462. }
  4463. if (weaponName.endsWith("dagger")) {
  4464. return 412;
  4465. }
  4466. if (weaponName.contains("2h sword") || weaponName.contains("godsword")
  4467. || weaponName.contains("aradomin sword")) {
  4468. return 407;
  4469. }
  4470. if (weaponName.contains("sword")) {
  4471. return 451;
  4472. }
  4473. if (weaponName.contains("karil") || weaponName.contains("cannon")) {
  4474. return 2075;
  4475. }
  4476. if (weaponName.contains("bow") && !weaponName.contains("'bow")) {
  4477. return 426;
  4478. }
  4479. if (weaponName.contains("'bow"))
  4480. return 4230;
  4481.  
  4482. switch (c.playerEquipment[c.playerWeapon]) { // if you don't want to use
  4483. // strings
  4484. case 20171:
  4485.  
  4486. return 426;
  4487. case 6522:
  4488. return 2614;
  4489. case 4153: // granite maul
  4490. return 1665;
  4491. case 19780:
  4492. return 451;
  4493. case 4726: // guthan
  4494. return 2080;
  4495. case 4747: // torag
  4496. return 0x814;
  4497. case 4718: // dharok
  4498. return 2067;
  4499. case 4710: // ahrim
  4500. return 406;
  4501. case 4755: // verac
  4502. return 2062;
  4503. case 4734: // karil
  4504. return 2075;
  4505. case 4151:
  4506. return 1658;
  4507. case 6528:
  4508. case 15039:
  4509. case 21744:
  4510. case 13399:
  4511. return 2661;
  4512. case 13902:
  4513. return 393;
  4514. case 15037:
  4515. case 6899:
  4516. case 8992:
  4517. case 15662:
  4518. return 386;
  4519. default:
  4520. return 451;
  4521. }
  4522. }
  4523.  
  4524. /**
  4525. * Block emotes
  4526. */
  4527. public int getBlockEmote() {
  4528. if (c.playerEquipment[c.playerShield] >= 8844
  4529. && c.playerEquipment[c.playerShield] <= 8850) {
  4530. return 4177;
  4531. }
  4532. switch (c.playerEquipment[c.playerWeapon]) {
  4533. case 4755:
  4534. return 2063;
  4535.  
  4536. case 4153:
  4537. return 1666;
  4538. case 6528:
  4539. case 15039:
  4540. case 21744:
  4541. case 13399:
  4542. return 1662;
  4543. case 4151:
  4544. return 1659;
  4545. case 15037:
  4546. case 1305:
  4547. case 1434:
  4548. case 954:
  4549. case 4587:
  4550. case 1377:
  4551. case 15038:
  4552. case 15574:
  4553. case 13899:
  4554. case 14899:
  4555. case 14902:
  4556. case 3757:
  4557. case 13902:
  4558. case 6899:
  4559. case 4212:
  4560. case 1351:
  4561. case 1265:
  4562. case 8992:
  4563. case 15662:
  4564. case 11235:
  4565. case 863:
  4566. case 864:
  4567. case 865:
  4568. case 866:
  4569. case 867:
  4570. case 868:
  4571. case 861:
  4572. case 14484:
  4573. case 15041:
  4574. case 7885:
  4575. case 9185:
  4576. case 841:
  4577. case 1215: // dragon daggers
  4578. case 1231:
  4579. case 13290:
  4580. case 1333:
  4581. case 6527:
  4582. case 6523:
  4583. case 4718:
  4584. case 4747:
  4585. case 5680:
  4586. case 5698:
  4587. case 1349:
  4588. case 1353:
  4589. case 1355:
  4590. case 1357:
  4591. case 1359:
  4592. case 6739:
  4593. case 1267:
  4594. case 1269:
  4595. case 1271:
  4596. case 1273:
  4597. case 1275:
  4598. case 3101:
  4599. return 808;
  4600. case 3204:
  4601. return 809;
  4602. case 13022:
  4603. case 4734:
  4604. return 1133;
  4605. case 15040:
  4606. case 22494:
  4607. case 6914:
  4608. case 7884:
  4609. case 15001:
  4610. case 4170:
  4611. case 6562:
  4612. case 1379:
  4613. case 1381:
  4614. case 1383:
  4615. case 1385:
  4616. case 1387:
  4617. case 2416:
  4618. case 2417:
  4619. case 2415:
  4620. case 4675:
  4621. case 4710:
  4622. return 8980;
  4623. case 10887:
  4624. case 11694:
  4625. case 19780:
  4626. case 11698:
  4627. case 11700:
  4628. case 11696:
  4629. case 11730:
  4630. case 7158:
  4631. case 1319:
  4632. case 4726:
  4633. case 4158:
  4634. case 13905:
  4635. case -1:
  4636. return -1;
  4637. default:
  4638. return 410;
  4639. }
  4640. }
  4641.  
  4642. /**
  4643. * Weapon and magic attack speed!
  4644. **/
  4645.  
  4646. public int getAttackDelay(String s) {
  4647. if (s.contains("polypore"))
  4648. return 6;
  4649.  
  4650. if (s.contains("cannon"))
  4651. return 7;
  4652. if (c.usingMagic) {
  4653. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  4654. case 12871: // ice blitz
  4655. case 13023: // shadow barrage
  4656. case 12891: // ice barrage
  4657. return 5;
  4658.  
  4659. default:
  4660. return 5;
  4661.  
  4662. case 19780:
  4663.  
  4664. if (c.Kspec) {
  4665. return 1;
  4666. } else {
  4667. return 4;
  4668. }
  4669. }
  4670. }
  4671. if (c.playerEquipment[c.playerWeapon] == -1)
  4672. return 4; // unarmed
  4673.  
  4674. switch (c.playerEquipment[c.playerWeapon]) {
  4675. case 11235:
  4676. return 7;
  4677. case 13022:
  4678. return 9;
  4679. case 7158:
  4680. return 7;
  4681. case 11730:
  4682. return 4;
  4683. case 15037:
  4684. case 8992:
  4685. case 15662:
  4686. return 4;
  4687. case 3757:
  4688. return 4;
  4689. case 6899:
  4690. return 3;
  4691. case 15038:
  4692. case 13290:
  4693. case 15574:
  4694. return 4;
  4695. case 6528:
  4696. return 6;
  4697. case 15039:
  4698. case 21744:
  4699. case 13399:
  4700. return 7;
  4701. }
  4702.  
  4703. if (s.endsWith("greataxe"))
  4704. return 7;
  4705. else if (s.contains("anchor"))
  4706. return 7;
  4707. else if (s.equals("torags hammers"))
  4708. return 5;
  4709. else if (s.equals("guthans warspear"))
  4710. return 5;
  4711. else if (s.equals("veracs flail"))
  4712. return 5;
  4713. else if (s.equals("ahrims staff"))
  4714. return 6;
  4715. else if (s.contains("staff")) {
  4716. if (s.contains("zamarok") || s.contains("guthix")
  4717. || s.contains("saradomian") || s.contains("slayer")
  4718. || s.contains("ancient"))
  4719. return 4;
  4720. else
  4721. return 5;
  4722. } else if (s.contains("bow")) {
  4723. if (s.contains("composite") || s.equals("seercull"))
  4724. return 5;
  4725. else if (s.contains("aril"))
  4726. return 4;
  4727. else if (s.contains("Ogre"))
  4728. return 8;
  4729. else if (s.contains("short") || s.contains("hunt")
  4730. || s.contains("sword") || s.contains("crystal"))
  4731. return 4;
  4732. else if (s.contains("long"))
  4733. return 5;
  4734. else if (s.contains("'bow"))
  4735. return 7;
  4736.  
  4737. return 5;
  4738. } else if (s.contains("dagger"))
  4739. return 4;
  4740. else if (s.contains("godsword"))
  4741. return 6;
  4742. else if (s.contains("longsword"))
  4743. return 5;
  4744. else if (s.contains("sword"))
  4745. return 4;
  4746. else if (s.contains("scimitar"))
  4747. return 4;
  4748. else if (s.contains("mace"))
  4749. return 5;
  4750. else if (s.contains("battleaxe"))
  4751. return 6;
  4752. else if (s.contains("pickaxe"))
  4753. return 5;
  4754. else if (s.contains("thrownaxe"))
  4755. return 5;
  4756. else if (s.contains("axe"))
  4757. return 5;
  4758. else if (s.contains("warhammer"))
  4759. return 6;
  4760. else if (s.contains("2h"))
  4761. return 7;
  4762. else if (s.contains("spear"))
  4763. return 5;
  4764. else if (s.contains("claw"))
  4765. return 4;
  4766. else if (s.contains("halberd"))
  4767. return 7;
  4768.  
  4769. // sara sword, 2400ms
  4770. else if (s.equals("granite maul"))
  4771. return 7;
  4772. else if (s.equals("toktz-xil-ak")) // sword
  4773. return 4;
  4774. else if (s.equals("tzhaar-ket-em")) // mace
  4775. return 5;
  4776. else if (s.equals("tzhaar-ket-om")) // maul
  4777. return 6;
  4778. else if (s.equals("toktz-xil-ek")) // knife
  4779. return 4;
  4780. else if (s.equals("toktz-xil-ul")) // rings
  4781. return 4;
  4782. else if (s.equals("toktz-mej-tal")) // staff
  4783. return 6;
  4784. else if (s.contains("whip"))
  4785. return 4;
  4786. else if (s.contains("dart"))
  4787. return 3;
  4788. else if (s.contains("knife"))
  4789. return 3;
  4790. else if (s.contains("javelin"))
  4791. return 6;
  4792. return 5;
  4793. }
  4794.  
  4795. /**
  4796. * How long it takes to hit your enemy
  4797. **/
  4798. public int getHitDelay(String weaponName) {
  4799. if (c.usingMagic) {
  4800. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  4801. case 12891:
  4802. return 4;
  4803. case 12871:
  4804. return 6;
  4805. default:
  4806. return 4;
  4807. }
  4808. } else {
  4809.  
  4810. if (weaponName.contains("knife") || weaponName.contains("dart")
  4811. || weaponName.contains("javelin")
  4812. || weaponName.contains("thrownaxe")) {
  4813. return 3;
  4814. }
  4815. if (weaponName.contains("cross") || weaponName.contains("c'bow")) {
  4816. return 4;
  4817. }
  4818. if (weaponName.contains("bow") && !c.dbowSpec) {
  4819. return 4;
  4820. } else if (c.dbowSpec) {
  4821. return 4;
  4822. }
  4823.  
  4824. switch (c.playerEquipment[c.playerWeapon]) {
  4825. case 6522: // Toktz-xil-ul
  4826. return 3;
  4827.  
  4828. default:
  4829. return 2;
  4830. }
  4831. }
  4832. }
  4833.  
  4834. public int getRequiredDistance() {
  4835. if (c.followId > 0 && c.freezeTimer <= 0 && !c.isMoving)
  4836. return 2;
  4837. else if (c.followId > 0 && c.freezeTimer <= 0 && c.isMoving) {
  4838. return 3;
  4839. } else {
  4840. return 1;
  4841. }
  4842. }
  4843.  
  4844. public boolean usingHally() {
  4845. switch (c.playerEquipment[c.playerWeapon]) {
  4846. case 3190:
  4847. case 3192:
  4848. case 3194:
  4849. case 3196:
  4850. case 3198:
  4851. case 3200:
  4852. case 3202:
  4853. case 3204:
  4854. return true;
  4855.  
  4856. default:
  4857. return false;
  4858. }
  4859. }
  4860.  
  4861. /**
  4862. * Melee
  4863. **/
  4864.  
  4865. public int calculateMeleeAttack() {
  4866. int attackLevel = c.playerLevel[0];
  4867. // 2, 5, 11, 18, 19
  4868. if (c.prayerActive[2]) {
  4869. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.05;
  4870. } else if (c.prayerActive[7]) {
  4871. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.1;
  4872. } else if (c.prayerActive[15]) {
  4873. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.15;
  4874. } else if (c.prayerActive[24]) {
  4875. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.18;
  4876. } else if (c.prayerActive[25] || c.prayerActive[3]) {
  4877. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.2;
  4878. }
  4879. if (c.fullVoidMelee())
  4880. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.1;
  4881. if (c.fullFremmy())
  4882. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.05;
  4883. else if (c.curseActive[10]) {
  4884. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack])
  4885. * (c.getAtt / 100);
  4886. } else if (c.curseActive[19]) { // turmoil
  4887. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack])
  4888. * (0.15 + (c.getAtt / 100));
  4889. }
  4890. if (c.getAtt < 0 && !c.curseActive[10])
  4891. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack])
  4892. * (c.getAtt / 100);
  4893. if (c.prayerActive[3] && c.prayerActive[0]) {
  4894. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 2.8;
  4895. }
  4896. if (c.smackability > 0) {
  4897. attackLevel += 500;
  4898. c.smackability--;
  4899. }
  4900. if (c.smackability2 > 0) {
  4901. attackLevel += 50000;
  4902. c.smackability2--;
  4903. }
  4904. if (c.fullVoidMelee())
  4905. attackLevel += c.getLevelForXP(c.playerXP[c.playerAttack]) * 0.1;
  4906. attackLevel *= c.specAccuracy;
  4907. // c.sendMessage("Attack: " + (attackLevel +
  4908. // (c.playerBonus[bestMeleeAtk()] * 2)));
  4909. int i = c.playerBonus[bestMeleeAtk()];
  4910. i += c.bonusAttack;
  4911. if (c.playerEquipment[c.playerAmulet] == 11128
  4912. && c.playerEquipment[c.playerWeapon] == 6528) {
  4913. i *= 1.30;
  4914. }
  4915. return (int) (attackLevel + (attackLevel * 0.15) + (i + i * 0.05));
  4916. }
  4917.  
  4918. public int bestMeleeAtk() {
  4919. if (c.playerBonus[0] > c.playerBonus[1]
  4920. && c.playerBonus[0] > c.playerBonus[2])
  4921. return 0;
  4922. if (c.playerBonus[1] > c.playerBonus[0]
  4923. && c.playerBonus[1] > c.playerBonus[2])
  4924. return 1;
  4925. return c.playerBonus[2] <= c.playerBonus[1]
  4926. || c.playerBonus[2] <= c.playerBonus[0] ? 0 : 2;
  4927. }
  4928.  
  4929. public int calculateMeleeMaxHit() {
  4930. double maxHit = 0;
  4931. int strBonus = c.playerBonus[10];
  4932. int strength = c.playerLevel[2];
  4933. int lvlForXP = c.getLevelForXP(c.playerXP[2]);
  4934. if (c.prayerActive[1]) {
  4935. strength += (int) (lvlForXP * .05);
  4936. } else if (c.prayerActive[6]) {
  4937. strength += (int) (lvlForXP * .10);
  4938. } else if (c.prayerActive[14]) {
  4939. strength += (int) (lvlForXP * .15);
  4940. } else if (c.prayerActive[24]) {
  4941. strength += (int) (lvlForXP * .20);
  4942. if (Misc.random(2) == 1)
  4943. strength += (int) (lvlForXP * .05);
  4944. } else if (c.prayerActive[25] || c.prayerActive[3]) {
  4945. strength += (int) (lvlForXP * .23);
  4946. if (Misc.random(500) == 1)
  4947. strength += (int) (lvlForXP * .01);
  4948. } else if (c.curseActive[14]) { // Leech Str
  4949. strength += (int) (lvlForXP * (c.getStr / 100));
  4950. } else if (c.curseActive[19]) { // turmoil
  4951. strength += (int) (lvlForXP * .23 + c.getStr);
  4952. }
  4953. if (c.getStr < 0 && !c.curseActive[14])
  4954. strength += (int) (lvlForXP * (c.getStr / 100));
  4955.  
  4956. if (c.prayerActive[3]) {
  4957. strength += (int) (lvlForXP * .03);
  4958. }
  4959. if (c.playerEquipment[c.playerHat] == 2526
  4960. && c.playerEquipment[c.playerChest] == 2520
  4961. && c.playerEquipment[c.playerLegs] == 2522) {
  4962. maxHit += (maxHit * 10 / 100);
  4963. }
  4964.  
  4965. maxHit += 1.05D + (double) (strBonus * strength) * 0.00176D;
  4966. maxHit += (double) strength * 0.11D;
  4967. if (c.playerEquipment[c.playerWeapon] == 4718
  4968. && c.playerEquipment[c.playerHat] == 4716
  4969. && c.playerEquipment[c.playerChest] == 4720
  4970. && c.playerEquipment[c.playerLegs] == 4722) {
  4971. maxHit += (c.getPA().getLevelForXP(c.playerXP[3]) - c.playerLevel[3]) / 2;
  4972. }
  4973. if (c.usingClaws && c.playerEquipment[c.playerWeapon] != 14484) {
  4974. if (maxHit > 20) {
  4975. maxHit = 20;
  4976. }
  4977. if (maxHit < 20) {
  4978. maxHit = 15;
  4979. }
  4980. }
  4981. if (c.specDamage > 1)
  4982. maxHit = (int) (maxHit * c.specDamage);
  4983. if (maxHit < 0)
  4984. maxHit = 1;
  4985. if (c.playerEquipment[c.playerWeapon] == 14484) {
  4986. if (maxHit > 48)
  4987. maxHit = 48;
  4988. if (maxHit > 30 && Misc.random(3) == 1 && c.usingClaws)
  4989. maxHit = 1;
  4990. if (maxHit > 30 && Misc.random(7) == 1 && c.usingClaws)
  4991. maxHit = 25;
  4992. }
  4993. if (Misc.random(30) == 1)
  4994. maxHit = 1;
  4995. if (Misc.random(60) == 1)
  4996. maxHit = 5;
  4997. if (c.fullVoidMelee())
  4998. maxHit = (int) (maxHit * 1.10);
  4999. if (c.fullFremmy())
  5000. maxHit = (int) (maxHit * 1.05);
  5001. if (c.playerEquipment[c.playerAmulet] == 11128
  5002. && c.playerEquipment[c.playerWeapon] == 6528) {
  5003. maxHit *= 1.20;
  5004.  
  5005. }
  5006. if (c.teleTimer > 0)
  5007. maxHit = 0;
  5008.  
  5009. return (int) Math.floor(maxHit);
  5010. }
  5011.  
  5012. public int calculateMeleeDefence() {
  5013. int defenceLevel = c.playerLevel[1];
  5014. int i = c.playerBonus[bestMeleeDef()];
  5015. if (c.prayerActive[0]) {
  5016. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.05;
  5017. } else if (c.prayerActive[5]) {
  5018. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.1;
  5019. } else if (c.prayerActive[13]) {
  5020. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.15;
  5021. } else if (c.prayerActive[24]) {
  5022. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.25;
  5023. } else if (c.prayerActive[25] || c.prayerActive[3]) {
  5024. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.25;
  5025. } else if (c.curseActive[13]) {
  5026. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence])
  5027. * (c.getDef / 100);
  5028. } else if (c.curseActive[19]) {
  5029. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.15
  5030. + c.getDef;
  5031. }
  5032. if (c.getDef < 0 && !c.curseActive[13])
  5033. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence])
  5034. * (c.getDef / 100);
  5035. return (int) (defenceLevel + (defenceLevel * 0.15) + (i + i * 0.05));
  5036. }
  5037.  
  5038. public int bestMeleeDef() {
  5039. if (c.playerBonus[5] > c.playerBonus[6]
  5040. && c.playerBonus[5] > c.playerBonus[7])
  5041. return 5;
  5042. if (c.playerBonus[6] > c.playerBonus[5]
  5043. && c.playerBonus[6] > c.playerBonus[7])
  5044. return 6;
  5045. return c.playerBonus[7] <= c.playerBonus[5]
  5046. || c.playerBonus[7] <= c.playerBonus[6] ? 5 : 7;
  5047. }
  5048.  
  5049. /**
  5050. * Range
  5051. **/
  5052.  
  5053. public int calculateRangeAttack() {
  5054. int attackLevel = c.playerLevel[4];
  5055. attackLevel *= c.specAccuracy;
  5056. if (c.fullVoidRange())
  5057. attackLevel += c.getLevelForXP(c.playerXP[c.playerRanged]) * 0.1;
  5058. if (c.prayerActive[3])
  5059. attackLevel *= 1.05;
  5060. else if (c.prayerActive[11])
  5061. attackLevel *= 1.10;
  5062. else if (c.prayerActive[19])
  5063. attackLevel *= 1.15;
  5064. else if (c.curseActive[11])
  5065. attackLevel *= (1 + (c.getRange / 100));
  5066. if (c.getRange < 0 && !c.curseActive[11])
  5067. attackLevel *= (1 + (c.getRange / 100));
  5068. // dbow spec
  5069. if (c.playerEquipment[c.playerHat] == 11675
  5070. || c.playerEquipment[c.playerHat] == 11664)
  5071. attackLevel *= 1.5;
  5072. if (c.fullVoidRange() && c.specAccuracy > 1.15) {
  5073. attackLevel *= 1.75;
  5074. }
  5075. return (int) (attackLevel + (c.playerBonus[4] * 1.95));
  5076. }
  5077.  
  5078. public int calculateRangeDefence() {
  5079. int defenceLevel = c.playerLevel[1];
  5080. if (c.prayerActive[0]) {
  5081. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.05;
  5082. } else if (c.prayerActive[5]) {
  5083. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.1;
  5084. } else if (c.prayerActive[13]) {
  5085. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.15;
  5086. } else if (c.prayerActive[24]) {
  5087. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.2;
  5088. } else if (c.prayerActive[25] || c.prayerActive[3]) {
  5089. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.25;
  5090. } else if (c.curseActive[13]) { // turmoil
  5091. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence])
  5092. * (c.getDef / 100);
  5093. } else if (c.curseActive[19]) { // turmoil
  5094. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.15
  5095. + c.getDef;
  5096. }
  5097. if (c.getDef < 0 && !c.curseActive[13])
  5098. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence])
  5099. * (c.getDef / 100);
  5100. return (int) (defenceLevel + c.playerBonus[9] + (c.playerBonus[9] / 2));
  5101. }
  5102.  
  5103. public boolean usingBolts() {
  5104. return c.playerEquipment[c.playerArrows] >= 9130
  5105. && c.playerEquipment[c.playerArrows] <= 9145
  5106. || c.playerEquipment[c.playerArrows] >= 9230
  5107. && c.playerEquipment[c.playerArrows] <= 9245;
  5108. }
  5109.  
  5110. public int rangeMaxHit() {
  5111. int rangeLevel = c.playerLevel[4];
  5112.  
  5113. int cbowDamage = c.crystalBowSpecDamage;
  5114. int crystalBowSpecTimer = c.crystalBowSpecTimer;
  5115. int weaponId = c.playerEquipment[c.playerWeapon];
  5116.  
  5117. double modifier = 1.0;
  5118. double wtf = c.specDamage;
  5119. int itemUsed = c.usingBow ? c.lastArrowUsed : c.lastWeaponUsed;
  5120. if (c.prayerActive[3])
  5121. modifier += 0.05;
  5122. else if (c.prayerActive[11])
  5123. modifier += 0.10;
  5124. else if (c.prayerActive[19])
  5125. modifier += 0.20;
  5126. if (c.fullVoidRange())
  5127. modifier += 0.10;
  5128. if (weaponId == 15041)
  5129. modifier += 0.10;
  5130. if (weaponId == 7885)
  5131. modifier += 0.15;
  5132.  
  5133. double c = modifier * rangeLevel;
  5134. int rangeStr = getRangeStr(itemUsed);
  5135. double max = (c + 8) * (rangeStr + 64) / 640;
  5136. if (wtf != 1)
  5137. max *= wtf;
  5138. if (max < 1)
  5139. max = 1;
  5140.  
  5141. if (crystalBowSpecTimer > 0 && weaponId == 4212)
  5142. max += cbowDamage;
  5143.  
  5144. return (int) max;
  5145. }
  5146.  
  5147. public int getRangeStr(int i) {
  5148. if (i == 4214 || i == 4215 || i == 4216 || i == 4217 || i == 4218
  5149. || i == 4219 || i == 4220 || i == 4221 || i == 4222
  5150. || i == 4223) {
  5151. return 70;
  5152. }
  5153.  
  5154. if (c.playerEquipment[c.playerWeapon] == 4212)
  5155. return 80;
  5156.  
  5157. switch (i) {
  5158. // bronze to rune bolts
  5159. case 877:
  5160. return 10;
  5161. case 9140:
  5162. return 46;
  5163. case 9141:
  5164. return 64;
  5165. case 9142:
  5166. case 9241:
  5167. case 9240:
  5168. return 82;
  5169. case 9143:
  5170. case 9243:
  5171. case 9242:
  5172. return 100;
  5173. case 9144:
  5174. return 115;
  5175.  
  5176. case 9244:
  5177. case 9245:
  5178.  
  5179. return 125;
  5180.  
  5181. // bronze to dragon arrows
  5182. case 882:
  5183. return 7;
  5184. case 884:
  5185. return 10;
  5186. case 886:
  5187. return 16;
  5188. case 888:
  5189. return 22;
  5190. case 890:
  5191. return 31;
  5192. case 892:
  5193. return 46;
  5194. case 4740:
  5195. return 55;
  5196. case 11212:
  5197. return 65;
  5198. // knifesknives
  5199. case 864:
  5200. return 3;
  5201. case 863:
  5202. return 4;
  5203. case 865:
  5204. return 7;
  5205. case 866:
  5206. return 10;
  5207. case 867:
  5208. return 14;
  5209. case 868:
  5210. return 24;
  5211. case 13883:
  5212. return 125;
  5213. }
  5214.  
  5215. if (c.playerEquipment[c.playerWeapon] == 13022)
  5216. return 166;
  5217.  
  5218. return 0;
  5219. }
  5220.  
  5221. /*
  5222. * public int rangeMaxHit() { int rangehit = 0; rangehit += c.playerLevel[4]
  5223. * / 7.5; int weapon = c.lastWeaponUsed; int Arrows = c.lastArrowUsed; if
  5224. * (weapon == 4223) {//Cbow 1/10 rangehit = 2; rangehit += c.playerLevel[4]
  5225. * / 7; } else if (weapon == 4222) {//Cbow 2/10 rangehit = 3; rangehit +=
  5226. * c.playerLevel[4] / 7; } else if (weapon == 4221) {//Cbow 3/10 rangehit =
  5227. * 3; rangehit += c.playerLevel[4] / 6.5; } else if (weapon == 4220) {//Cbow
  5228. * 4/10 rangehit = 4; rangehit += c.playerLevel[4] / 6.5; } else if (weapon
  5229. * == 4219) {//Cbow 5/10 rangehit = 4; rangehit += c.playerLevel[4] / 6; }
  5230. * else if (weapon == 4218) {//Cbow 6/10 rangehit = 5; rangehit +=
  5231. * c.playerLevel[4] / 6; } else if (weapon == 4217) {//Cbow 7/10 rangehit =
  5232. * 5; rangehit += c.playerLevel[4] / 5.5; } else if (weapon == 4216) {//Cbow
  5233. * 8/10 rangehit = 6; rangehit += c.playerLevel[4] / 5.5; } else if (weapon
  5234. * == 4215) {//Cbow 9/10 rangehit = 6; rangehit += c.playerLevel[4] / 5; }
  5235. * else if (weapon == 4214) {//Cbow Full rangehit = 7; rangehit +=
  5236. * c.playerLevel[4] / 5; } else if (weapon == 6522) { rangehit = 5; rangehit
  5237. * += c.playerLevel[4] / 6; } else if (weapon == 11230) {//dragon darts
  5238. * rangehit = 8; rangehit += c.playerLevel[4] / 10; } else if (weapon == 811
  5239. * || weapon == 868) {//rune darts rangehit = 2; rangehit +=
  5240. * c.playerLevel[4] / 8.5; } else if (weapon == 810 || weapon == 867)
  5241. * {//adamant darts rangehit = 2; rangehit += c.playerLevel[4] / 9; } else
  5242. * if (weapon == 809 || weapon == 866) {//mithril darts rangehit = 2;
  5243. * rangehit += c.playerLevel[4] / 9.5; } else if (weapon == 808 || weapon ==
  5244. * 865) {//Steel darts rangehit = 2; rangehit += c.playerLevel[4] / 10; }
  5245. * else if (weapon == 807 || weapon == 863) {//Iron darts rangehit = 2;
  5246. * rangehit += c.playerLevel[4] / 10.5; } else if (weapon == 806 || weapon
  5247. * == 864) {//Bronze darts rangehit = 1; rangehit += c.playerLevel[4] / 11;
  5248. * } else if (Arrows == 4740 && weapon == 4734) {//BoltRacks rangehit = 3;
  5249. * rangehit += c.playerLevel[4] / 4.5; } else if (Arrows == 11212) {//dragon
  5250. * arrows rangehit = 4; rangehit += c.playerLevel[4] / 5.5; } else if
  5251. * (Arrows == 892) {//rune arrows rangehit = 3; rangehit += c.playerLevel[4]
  5252. * / 6; } else if (Arrows == 890) {//adamant arrows rangehit = 2; rangehit
  5253. * += c.playerLevel[4] / 7; } else if (Arrows == 888) {//mithril arrows
  5254. * rangehit = 2; rangehit += c.playerLevel[4] / 7.5; } else if (Arrows ==
  5255. * 886) {//steel arrows rangehit = 2; rangehit += c.playerLevel[4] / 8; }
  5256. * else if (Arrows == 884) {//Iron arrows rangehit = 2; rangehit +=
  5257. * c.playerLevel[4] / 9; } else if (Arrows == 882) {//Bronze arrows rangehit
  5258. * = 1; rangehit += c.playerLevel[4] / 9.5; } else if (Arrows == 9244) {
  5259. * rangehit = 8; rangehit += c.playerLevel[4] / 3; } else if (Arrows ==
  5260. * 9139) { rangehit = 12; rangehit += c.playerLevel[4] / 4; } else if
  5261. * (Arrows == 9140) { rangehit = 2; rangehit += c.playerLevel[4] / 7; } else
  5262. * if (Arrows == 9141) { rangehit = 3; rangehit += c.playerLevel[4] / 6; }
  5263. * else if (Arrows == 9142) { rangehit = 4; rangehit += c.playerLevel[4] /
  5264. * 6; } else if (Arrows == 9143) { rangehit = 7; rangehit +=
  5265. * c.playerLevel[4] / 5; } else if (Arrows == 9144) { rangehit = 7; rangehit
  5266. * += c.playerLevel[4] / 4.5; } int bonus = 0; bonus -= rangehit / 10;
  5267. * rangehit += bonus; if (c.specDamage != 1) rangehit *= c.specDamage; if
  5268. * (rangehit == 0) rangehit++; if (c.fullVoidRange()) { rangehit *= 1.10; }
  5269. * if (c.prayerActive[3]) rangehit *= 1.05; else if (c.prayerActive[11])
  5270. * rangehit *= 1.10; else if (c.prayerActive[19]) rangehit *= 1.15; return
  5271. * rangehit; }
  5272. */
  5273.  
  5274. public boolean properBolts() {
  5275. return c.playerEquipment[c.playerArrows] >= 9140
  5276. && c.playerEquipment[c.playerArrows] <= 9144
  5277. || c.playerEquipment[c.playerArrows] >= 9240
  5278. && c.playerEquipment[c.playerArrows] <= 9244;
  5279. }
  5280.  
  5281. public int correctBowAndArrows() {
  5282. if (usingBolts())
  5283. return -1;
  5284. switch (c.playerEquipment[c.playerWeapon]) {
  5285.  
  5286. case 839:
  5287. case 841:
  5288. return 882;
  5289.  
  5290. case 843:
  5291. case 845:
  5292. return 884;
  5293.  
  5294. case 847:
  5295. case 849:
  5296. return 886;
  5297.  
  5298. case 851:
  5299. case 853:
  5300. return 888;
  5301.  
  5302. case 855:
  5303. case 857:
  5304. return 890;
  5305.  
  5306. case 859:
  5307. case 861:
  5308. return 892;
  5309.  
  5310. case 4734:
  5311. case 4935:
  5312. case 4936:
  5313. case 4937:
  5314. return 4740;
  5315.  
  5316. case 11235:
  5317. return 11212;
  5318. }
  5319. return -1;
  5320. }
  5321.  
  5322. public int getRangeStartGFX() {
  5323. switch (c.rangeItemUsed) {
  5324.  
  5325. case 863:
  5326. return 220;
  5327. case 864:
  5328. return 219;
  5329. case 865:
  5330. return 221;
  5331. case 866: // knives
  5332. return 223;
  5333. case 867:
  5334. return 224;
  5335. case 868:
  5336. return 225;
  5337. case 869:
  5338. return 222;
  5339.  
  5340. case 806:
  5341. return 232;
  5342. case 807:
  5343. return 233;
  5344. case 808:
  5345. return 234;
  5346. case 809: // darts
  5347. return 235;
  5348. case 810:
  5349. return 236;
  5350. case 811:
  5351. return 237;
  5352. case 11230:
  5353. return 238;
  5354.  
  5355. case 825:
  5356. return 206;
  5357. case 826:
  5358. return 207;
  5359. case 827: // javelin
  5360. return 208;
  5361. case 828:
  5362. return 209;
  5363. case 829:
  5364. return 210;
  5365. case 830:
  5366. return 211;
  5367.  
  5368. case 13883:
  5369. return 42;
  5370. case 800:
  5371. return 42;
  5372. case 801:
  5373. return 43;
  5374. case 802:
  5375. return 44; // axes
  5376. case 803:
  5377. return 45;
  5378. case 804:
  5379. return 46;
  5380. case 805:
  5381. return 48;
  5382.  
  5383. case 882:
  5384. return 19;
  5385.  
  5386. case 884:
  5387. return 18;
  5388.  
  5389. case 886:
  5390. return 20;
  5391.  
  5392. case 888:
  5393. return 21;
  5394.  
  5395. case 890:
  5396. return 22;
  5397.  
  5398. case 892:
  5399. return 24;
  5400.  
  5401. case 11212:
  5402. return 26;
  5403.  
  5404. case 4212:
  5405. case 4214:
  5406. case 4215:
  5407. case 4216:
  5408. case 4217:
  5409. case 4218:
  5410. case 4219:
  5411. case 4220:
  5412. case 4221:
  5413. case 4222:
  5414. case 4223:
  5415. if (c.crystalBowSpecTimer == 0)
  5416. return 250;
  5417. else
  5418. return -1;
  5419.  
  5420. }
  5421. return -1;
  5422. }
  5423.  
  5424. public int getRangeProjectileGFX() {
  5425. if (c.dbowSpec) {
  5426. return 1099;
  5427. }
  5428.  
  5429. if (c.cannonSpec == 1) {
  5430. return 88;
  5431. }
  5432.  
  5433. if (c.bowSpecShot > 0) {
  5434. switch (c.rangeItemUsed) {
  5435. default:
  5436. return 249;
  5437. }
  5438. }
  5439. if (c.playerEquipment[c.playerWeapon] == 9185
  5440. || c.playerEquipment[c.playerWeapon] == 15041)
  5441. return 27;
  5442. switch (c.rangeItemUsed) {
  5443.  
  5444. case 863:
  5445. return 213;
  5446. case 864:
  5447. return 212;
  5448. case 865:
  5449. return 214;
  5450. case 866: // knives
  5451. return 216;
  5452. case 867:
  5453. return 217;
  5454. case 868:
  5455. return 218;
  5456. case 869:
  5457. return 215;
  5458.  
  5459. case 806:
  5460. return 226;
  5461. case 807:
  5462. return 227;
  5463. case 808:
  5464. return 228;
  5465. case 809: // darts
  5466. return 229;
  5467. case 810:
  5468. return 230;
  5469. case 811:
  5470. return 231;
  5471. case 11230:
  5472. return 232;
  5473.  
  5474. case 825:
  5475. return 200;
  5476. case 826:
  5477. return 201;
  5478. case 827: // javelin
  5479. return 202;
  5480. case 828:
  5481. return 203;
  5482. case 829:
  5483. return 204;
  5484. case 830:
  5485. return 205;
  5486.  
  5487. case 6522: // Toktz-xil-ul
  5488. return 442;
  5489.  
  5490. case 800:
  5491. return 36;
  5492. case 801:
  5493. return 35;
  5494. case 802:
  5495. return 37; // axes
  5496. case 803:
  5497. return 38;
  5498. case 804:
  5499. return 39;
  5500. case 805:
  5501. return 40;
  5502.  
  5503. case 882:
  5504. return 10;
  5505.  
  5506. case 884:
  5507. return 9;
  5508.  
  5509. case 886:
  5510. return 11;
  5511.  
  5512. case 888:
  5513. return 12;
  5514.  
  5515. case 890:
  5516. return 13;
  5517.  
  5518. case 892:
  5519. return 15;
  5520.  
  5521. case 11212:
  5522. return 17;
  5523.  
  5524. case 4740: // bolt rack
  5525. return 27;
  5526.  
  5527. case 4212:
  5528. case 4214:
  5529. case 4215:
  5530. case 4216:
  5531. case 4217:
  5532. case 4218:
  5533. case 4219:
  5534. case 4220:
  5535. case 4221:
  5536. case 4222:
  5537. case 4223:
  5538. if (c.crystalBowSpecTimer > 0)
  5539. return 473;
  5540. else
  5541. return 249;
  5542.  
  5543. }
  5544. return -1;
  5545. }
  5546.  
  5547. public int getProjectileSpeed() {
  5548. if (c.dbowSpec)
  5549. return 100;
  5550. return 70;
  5551. }
  5552.  
  5553. public int getProjectileShowDelay() {
  5554. switch (c.playerEquipment[c.playerWeapon]) {
  5555. case 863:
  5556. case 864:
  5557. case 865:
  5558. case 866: // knives
  5559. case 867:
  5560. case 868:
  5561. case 869:
  5562.  
  5563. case 806:
  5564. case 807:
  5565. case 808:
  5566. case 809: // darts
  5567. case 810:
  5568. case 811:
  5569. case 11230:
  5570.  
  5571. case 825:
  5572. case 826:
  5573. case 827: // javelin
  5574. case 828:
  5575. case 829:
  5576. case 830:
  5577.  
  5578. case 800:
  5579. case 801:
  5580. case 802:
  5581. case 803: // axes
  5582. case 804:
  5583. case 805:
  5584. case 13883:
  5585.  
  5586. case 4734:
  5587. case 9185:
  5588. case 15041:
  5589. case 4935:
  5590. case 4936:
  5591. case 4937:
  5592. return 15;
  5593.  
  5594. default:
  5595. return 5;
  5596. }
  5597. }
  5598.  
  5599. /**
  5600. * MAGIC
  5601. **/
  5602.  
  5603. public int mageAtk() {
  5604. int attackLevel = c.playerLevel[6];
  5605. if (c.fullVoidMage())
  5606. attackLevel += c.getLevelForXP(c.playerXP[6]) * 0.3;
  5607. if (c.prayerActive[4])
  5608. attackLevel *= 1.06;
  5609. else if (c.prayerActive[12])
  5610. attackLevel *= 1.11;
  5611. else if (c.prayerActive[20])
  5612. attackLevel *= 1.21;
  5613. return (int) (attackLevel + (c.playerBonus[3] * 2));
  5614. }
  5615.  
  5616. public int mageDef() {
  5617. int defenceLevel = c.playerLevel[1] / 2 + c.playerLevel[6] / 2;
  5618. if (c.prayerActive[0]) {
  5619. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.05;
  5620. } else if (c.prayerActive[3]) {
  5621. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.1;
  5622. } else if (c.prayerActive[9]) {
  5623. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.15;
  5624. } else if ((c.prayerActive[18] || c.curseActive[9])) {
  5625. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.2;
  5626. } else if (c.prayerActive[19]) {
  5627. defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.25;
  5628. }
  5629. return (int) (defenceLevel + c.playerBonus[8]);
  5630. }
  5631.  
  5632. public boolean wearingStaff(int runeId) {
  5633. int wep = c.playerEquipment[c.playerWeapon];
  5634. switch (runeId) {
  5635. case 554:
  5636. if (wep == 1387)
  5637. return true;
  5638. break;
  5639. case 555:
  5640. if (wep == 1383)
  5641. return true;
  5642. break;
  5643. case 556:
  5644. if (wep == 1381)
  5645. return true;
  5646. break;
  5647. case 557:
  5648. if (wep == 1385)
  5649. return true;
  5650. break;
  5651. }
  5652. return false;
  5653. }
  5654.  
  5655. public boolean checkMagicReqs(int spell) {
  5656. if (c.playerEquipment[c.playerWeapon] == 22494) {
  5657. return true;
  5658. }
  5659. if (c.usingMagic && Config.RUNES_REQUIRED) { // check for runes
  5660. if ((!c.getItems().playerHasItem(c.MAGIC_SPELLS[spell][8],
  5661. c.MAGIC_SPELLS[spell][9]) && !wearingStaff(c.MAGIC_SPELLS[spell][8]))
  5662. || (!c.getItems().playerHasItem(c.MAGIC_SPELLS[spell][10],
  5663. c.MAGIC_SPELLS[spell][11]) && !wearingStaff(c.MAGIC_SPELLS[spell][10]))
  5664. || (!c.getItems().playerHasItem(c.MAGIC_SPELLS[spell][12],
  5665. c.MAGIC_SPELLS[spell][13]) && !wearingStaff(c.MAGIC_SPELLS[spell][12]))
  5666. || (!c.getItems().playerHasItem(c.MAGIC_SPELLS[spell][14],
  5667. c.MAGIC_SPELLS[spell][15]) && !wearingStaff(c.MAGIC_SPELLS[spell][14]))) {
  5668. c.sendMessage("You don't have the required runes to cast this spell.");
  5669. return false;
  5670. }
  5671. }
  5672.  
  5673. if (c.usingMagic && c.playerIndex > 0) {
  5674. if (PlayerHandler.players[c.playerIndex] != null) {
  5675. for (int r = 0; r < c.REDUCE_SPELLS.length; r++) { // reducing
  5676. // spells,
  5677. // confuse
  5678. // etc
  5679. if (PlayerHandler.players[c.playerIndex].REDUCE_SPELLS[r] == c.MAGIC_SPELLS[spell][0]) {
  5680. c.reduceSpellId = r;
  5681. if ((System.currentTimeMillis() - PlayerHandler.players[c.playerIndex].reduceSpellDelay[c.reduceSpellId]) > PlayerHandler.players[c.playerIndex].REDUCE_SPELL_TIME[c.reduceSpellId]) {
  5682. PlayerHandler.players[c.playerIndex].canUseReducingSpell[c.reduceSpellId] = true;
  5683. } else {
  5684. PlayerHandler.players[c.playerIndex].canUseReducingSpell[c.reduceSpellId] = false;
  5685. }
  5686. break;
  5687. }
  5688. }
  5689. if (!PlayerHandler.players[c.playerIndex].canUseReducingSpell[c.reduceSpellId]) {
  5690. c.sendMessage("That player is currently immune to this spell.");
  5691. c.usingMagic = false;
  5692. c.stopMovement();
  5693. resetPlayerAttack();
  5694. return false;
  5695. }
  5696. }
  5697. }
  5698.  
  5699. int staffRequired = getStaffNeeded();
  5700. if (c.usingMagic && staffRequired > 0 && Config.RUNES_REQUIRED) { // staff
  5701. // required
  5702. if (c.playerEquipment[c.playerWeapon] != staffRequired) {
  5703. c.sendMessage("You need a "
  5704. + c.getItems().getItemName(staffRequired).toLowerCase()
  5705. + " to cast this spell.");
  5706. return false;
  5707. }
  5708. }
  5709.  
  5710. if (c.usingMagic && Config.MAGIC_LEVEL_REQUIRED) { // check magic level
  5711. if (c.playerLevel[6] < c.MAGIC_SPELLS[spell][1]) {
  5712. c.sendMessage("You need to have a magic level of "
  5713. + c.MAGIC_SPELLS[spell][1] + " to cast this spell.");
  5714. return false;
  5715. }
  5716. }
  5717. if (c.usingMagic && Config.RUNES_REQUIRED) {
  5718. if (c.MAGIC_SPELLS[spell][8] > 0) { // deleting runes
  5719. if (!wearingStaff(c.MAGIC_SPELLS[spell][8]))
  5720. c.getItems().deleteItem(c.MAGIC_SPELLS[spell][8],
  5721. c.getItems().getItemSlot(c.MAGIC_SPELLS[spell][8]),
  5722. c.MAGIC_SPELLS[spell][9]);
  5723. }
  5724. if (c.MAGIC_SPELLS[spell][10] > 0) {
  5725. if (!wearingStaff(c.MAGIC_SPELLS[spell][10]))
  5726. c.getItems()
  5727. .deleteItem(
  5728. c.MAGIC_SPELLS[spell][10],
  5729. c.getItems().getItemSlot(
  5730. c.MAGIC_SPELLS[spell][10]),
  5731. c.MAGIC_SPELLS[spell][11]);
  5732. }
  5733. if (c.MAGIC_SPELLS[spell][12] > 0) {
  5734. if (!wearingStaff(c.MAGIC_SPELLS[spell][12]))
  5735. c.getItems()
  5736. .deleteItem(
  5737. c.MAGIC_SPELLS[spell][12],
  5738. c.getItems().getItemSlot(
  5739. c.MAGIC_SPELLS[spell][12]),
  5740. c.MAGIC_SPELLS[spell][13]);
  5741. }
  5742. if (c.MAGIC_SPELLS[spell][14] > 0) {
  5743. if (!wearingStaff(c.MAGIC_SPELLS[spell][14]))
  5744. c.getItems()
  5745. .deleteItem(
  5746. c.MAGIC_SPELLS[spell][14],
  5747. c.getItems().getItemSlot(
  5748. c.MAGIC_SPELLS[spell][14]),
  5749. c.MAGIC_SPELLS[spell][15]);
  5750. }
  5751. }
  5752. return true;
  5753. }
  5754.  
  5755. public int getFreezeTime() {
  5756. switch (c.MAGIC_SPELLS[c.oldSpellId][0]) {
  5757. case 1572:
  5758. case 12861: // ice rush
  5759. return 10;
  5760.  
  5761. case 1582:
  5762. case 12881: // ice burst
  5763. return 17;
  5764.  
  5765. case 1592:
  5766. case 12871: // ice blitz
  5767. return 25;
  5768.  
  5769. case 12891: // ice barrage
  5770. return 33;
  5771.  
  5772. default:
  5773. return 0;
  5774. }
  5775. }
  5776.  
  5777. public void freezePlayer(int i) {
  5778.  
  5779. }
  5780.  
  5781. /*
  5782. * public void handleGamesNeck() { if (c.playerIndex > 0 &&
  5783. * Server.playerHandler.players[c.playerIndex] != null) { int teleport = 15;
  5784. * Server.playerHandler.players[c.playerIndex].playerLevel[3] -= teleport; }
  5785. * else { c.sendMessage("@red@I shouldn't use this in combat!"); } }
  5786. */
  5787.  
  5788. /*
  5789. * public void handleDuelRing() { if (c.playerIndex > 0 &&
  5790. * Server.playerHandler.players[c.playerIndex] != null) { int teleport = 99;
  5791. * Server.playerHandler.players[c.playerIndex].playerLevel[3] -= teleport; }
  5792. * else { c.sendMessage("@red@I shouldn't use this in combat!"); } }
  5793. */
  5794.  
  5795. public int getStartHeight() {
  5796. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  5797. case 1562: // stun
  5798. return 25;
  5799.  
  5800. case 12939: // smoke rush
  5801. return 35;
  5802.  
  5803. case 12987: // shadow rush
  5804. return 38;
  5805.  
  5806. case 12861: // ice rush
  5807. return 15;
  5808.  
  5809. case 12951: // smoke blitz
  5810. return 38;
  5811.  
  5812. case 12999: // shadow blitz
  5813. return 25;
  5814.  
  5815. case 12911: // blood blitz
  5816. return 25;
  5817.  
  5818. default:
  5819. return 43;
  5820. }
  5821. }
  5822.  
  5823. public int getEndHeight() {
  5824. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  5825. case 1562: // stun
  5826. return 10;
  5827.  
  5828. case 12939: // smoke rush
  5829. return 20;
  5830.  
  5831. case 12987: // shadow rush
  5832. return 28;
  5833.  
  5834. case 12861: // ice rush
  5835. return 10;
  5836.  
  5837. case 12951: // smoke blitz
  5838. return 28;
  5839.  
  5840. case 12999: // shadow blitz
  5841. return 15;
  5842.  
  5843. case 12911: // blood blitz
  5844. return 10;
  5845.  
  5846. default:
  5847. return 31;
  5848. }
  5849. }
  5850.  
  5851. public int getStartDelay() {
  5852. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  5853. case 1539:
  5854. return 60;
  5855.  
  5856. default:
  5857. return 53;
  5858. }
  5859. }
  5860.  
  5861. public int getStaffNeeded() {
  5862. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  5863. case 1539:
  5864. return 1409;
  5865.  
  5866. case 12037:
  5867. return 4170;
  5868.  
  5869. case 1190:
  5870. return 2415;
  5871.  
  5872. case 1191:
  5873. return 2416;
  5874.  
  5875. case 1192:
  5876. return 2417;
  5877.  
  5878. default:
  5879. return 0;
  5880. }
  5881. }
  5882.  
  5883. public boolean godSpells() {
  5884. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  5885. case 1190:
  5886. return true;
  5887.  
  5888. case 1191:
  5889. return true;
  5890.  
  5891. case 1192:
  5892. return true;
  5893.  
  5894. default:
  5895. return false;
  5896. }
  5897. }
  5898.  
  5899. public int getEndGfxHeight() {
  5900. switch (c.MAGIC_SPELLS[c.oldSpellId][0]) {
  5901. case 12987:
  5902. case 12901:
  5903. case 12861:
  5904. case 12445:
  5905. case 1192:
  5906. case 13011:
  5907. case 12919:
  5908. case 12881:
  5909. case 12999:
  5910. case 12911:
  5911. case 12871:
  5912. case 13023:
  5913. case 12929:
  5914. case 12891:
  5915. return 0;
  5916.  
  5917. default:
  5918. return 100;
  5919. }
  5920. }
  5921.  
  5922. public int getStartGfxHeight() {
  5923. switch (c.MAGIC_SPELLS[c.spellId][0]) {
  5924. case 12871:
  5925. case 12891:
  5926. return 0;
  5927.  
  5928. default:
  5929. return 100;
  5930. }
  5931. }
  5932.  
  5933. /*
  5934. * public void handleZerker() {
  5935. *
  5936. * if (System.currentTimeMillis() - c.dfsDelay > 60000) { if (c.playerIndex
  5937. * > 0 && Server.playerHandler.players[c.playerIndex] != null) { int damage
  5938. * = Misc.random(10) + 7; c.startAnimation(369); c.gfx0(369);
  5939. * Server.playerHandler.players[c.playerIndex].playerLevel[3] -= damage;
  5940. * Server.playerHandler.players[c.playerIndex].hitDiff2 = damage;
  5941. * c.forcedText = "Feel the power of the Berserker Ring!";
  5942. * Server.playerHandler.players[c.playerIndex].hitUpdateRequired2 = true;
  5943. * Server.playerHandler.players[c.playerIndex].updateRequired = true;
  5944. * c.dfsDelay = System.currentTimeMillis(); } else {
  5945. * c.sendMessage("I should be in combat before using this.");
  5946. *
  5947. * } else {
  5948. * c.sendMessage("My ring hasn't finished recharging yet (60 Seconds)"); } }
  5949. * public void handleWarrior() { if(c.isDonator == 1){ if
  5950. * (System.currentTimeMillis() - c.dfsDelay > 60000) { if (c.playerIndex > 0
  5951. * && Server.playerHandler.players[c.playerIndex] != null) { int damage =
  5952. * Misc.random(10) + 7; c.startAnimation(369); c.gfx0(369);
  5953. * Server.playerHandler.players[c.playerIndex].playerLevel[3] -= damage;
  5954. * c.forcedText = "Feel the power of the Warrior Ring!";
  5955. * Server.playerHandler.players[c.playerIndex].hitDiff2 = damage;
  5956. * Server.playerHandler.players[c.playerIndex].hitUpdateRequired2 = true;
  5957. * Server.playerHandler.players[c.playerIndex].updateRequired = true;
  5958. * c.dfsDelay = System.currentTimeMillis(); } else {
  5959. * c.sendMessage("I should be in combat before using this."); } } else {
  5960. * c.sendMessage("My ring hasn't finished recharging yet (60 Seconds)"); }if
  5961. * (c.isDonator == 0)
  5962. * c.sendMessage("Only Donators can use the ring's Special attack"); } }
  5963. */
  5964.  
  5965. public void handleSeers() {
  5966. /*
  5967. *
  5968. * c.castingMagic = true; if(c.isDonator == 1){ if
  5969. * (System.currentTimeMillis() - c.dfsDelay > 60000) { if (c.playerIndex
  5970. * > 0 && Server.playerHandler.players[c.playerIndex] != null) { int
  5971. * damage = Misc.random(10) + 7; c.startAnimation(1979);
  5972. * Server.playerHandler.players[c.playerIndex].gfx0(369); c.gfx0(368);
  5973. * Server.playerHandler.players[c.playerIndex].freezeTimer = 15;
  5974. * Server.playerHandler.players[c.playerIndex].resetWalkingQueue();
  5975. * Server.playerHandler.players[c.playerIndex].frozenBy = c.playerId;
  5976. * Server.playerHandler.players[c.playerIndex].playerLevel[3] -= damage;
  5977. * c.forcedText = ("Feel the power of the Seers Ring!");
  5978. * Server.playerHandler.players[c.playerIndex].hitDiff2 = damage;
  5979. *
  5980. * Server.playerHandler.players[c.playerIndex].hitUpdateRequired2 =
  5981. * true; Server.playerHandler.players[c.playerIndex].updateRequired =
  5982. * true; c.dfsDelay = System.currentTimeMillis(); } else {
  5983. * c.sendMessage("I should be in combat before using this."); } } else {
  5984. * c.sendMessage("My ring hasn't finished recharging yet (60 Seconds)");
  5985. * }if (c.isDonator == 0)
  5986. */
  5987. // c.sendMessage("Spec comes back soon");
  5988.  
  5989. }
  5990.  
  5991. public void Deflect(int damage, int i) {
  5992. if (damage > 0 && PlayerHandler.players[i].curseActive[7]
  5993. || PlayerHandler.players[i].curseActive[8]
  5994. || PlayerHandler.players[i].curseActive[9]) {
  5995. int recDamage = damage / 6;
  5996. if (!c.getHitUpdateRequired()) {
  5997. damage = damage / 7;
  5998. c.setHitDiff(recDamage);
  5999. c.recoilHits = recDamage;
  6000. c.setHitUpdateRequired(true);
  6001. } else if (!c.getHitUpdateRequired2()) {
  6002. damage = damage / 7;
  6003. c.setHitDiff2(recDamage);
  6004. c.setHitUpdateRequired2(true);
  6005. }
  6006. c.dealDamage(recDamage);
  6007. damage = damage / 7;
  6008. c.updateRequired = true;
  6009. }
  6010. }
  6011.  
  6012. public void applyRecoil(int damage, int i) {
  6013. if (damage > 0
  6014. && PlayerHandler.players[i].playerEquipment[c.playerRing] == 2550) {
  6015. int recDamage = damage / 10 + 1;
  6016. if (!c.getHitUpdateRequired()) {
  6017. c.setHitDiff(recDamage);
  6018. c.setHitUpdateRequired(true);
  6019. } else if (!c.getHitUpdateRequired2()) {
  6020. c.setHitDiff2(recDamage);
  6021. c.setHitUpdateRequired2(true);
  6022. }
  6023. c.dealDamage(recDamage);
  6024. c.updateRequired = true;
  6025. }
  6026. }
  6027.  
  6028. public int getBonusAttack(int i) {
  6029. switch (NPCHandler.npcs[i].npcType) {
  6030. case 2883:
  6031. return Misc.random(50) + 30;
  6032. case 2026:
  6033. case 2027:
  6034. case 2029:
  6035. case 2030:
  6036. return Misc.random(50) + 30;
  6037. }
  6038. return 0;
  6039. }
  6040.  
  6041. public void handleGmaulPlayer() {
  6042. if (c.playerIndex > 0) {
  6043. Client o = (Client) PlayerHandler.players[c.playerIndex];
  6044. if (c.goodDistance(c.getX(), c.getY(), o.getX(), o.getY(),
  6045. getRequiredDistance())) {
  6046. if (checkReqs()) {
  6047. if (checkSpecAmount(4153)) {
  6048. boolean hit = Misc.random(calculateMeleeAttack()) > Misc
  6049. .random(o.getCombat().calculateMeleeDefence());
  6050. int damage = 0;
  6051. c.specDamage = 1.0;
  6052. c.specAccuracy = 3.5;
  6053. int lvlForXP = c.getLevelForXP(c.playerXP[2]);
  6054. if (hit)
  6055. damage = Misc.random(calculateMeleeMaxHit());
  6056.  
  6057. if (c.playerEquipment[c.playerHat] == 11665) {
  6058. damage *= 10 / 9;
  6059. }
  6060.  
  6061. if ((o.prayerActive[18] || o.curseActive[9])
  6062. && System.currentTimeMillis()
  6063. - o.protMeleeDelay > 1500)
  6064. damage *= .6;
  6065.  
  6066. damage *= 0.95;
  6067. applyPlayerHit(c.playerIndex, damage);
  6068. c.startAnimation(1667);
  6069. c.gfx100(340);
  6070.  
  6071. o.updateRequired = true;
  6072. o.getPA().requestUpdates();
  6073. }
  6074. }
  6075. }
  6076. }
  6077. }
  6078.  
  6079. public boolean armaNpc(int i) {
  6080. switch (NPCHandler.npcs[i].npcType) {
  6081. case 6222:
  6082. case 2559:
  6083. case 2560:
  6084. case 6223:
  6085. case 6225:
  6086. case 6227:
  6087. case 2561:
  6088. return true;
  6089. }
  6090. return false;
  6091. }
  6092.  
  6093. /**
  6094. * Used to grab the other player's information.
  6095. */
  6096. public int magicDefence(Client player) {
  6097. return PVPMagic.getInstance().Defence(player);
  6098. }
  6099.  
  6100. }
Advertisement
Add Comment
Please, Sign In to add comment