Advertisement
Guest User

Hits

a guest
Apr 18th, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.08 KB | None | 0 0
  1. package com.zarketh.model.combat.additions;
  2.  
  3. import com.zarketh.content.Achievements;
  4. import com.zarketh.content.skills.prayer.PrayerHandler;
  5. import com.zarketh.model.combat.CombatEngine;
  6. import com.zarketh.model.combat.HitExecutor;
  7. import com.zarketh.model.combat.magic.MagicFormula;
  8. import com.zarketh.model.combat.magic.MagicHandler;
  9. import com.zarketh.model.combat.melee.MaxHit;
  10. import com.zarketh.model.combat.ranged.MaxHitRanged;
  11. import com.zarketh.model.combat.ranged.Ranged;
  12. import com.zarketh.model.entity.AnimationProcessor;
  13. import com.zarketh.model.entity.Entity;
  14. import com.zarketh.model.entity.Entity.CombatType;
  15. import com.zarketh.model.entity.npc.NPC;
  16. import com.zarketh.model.entity.npc.NPCAttacks;
  17. import com.zarketh.model.entity.player.Equipment;
  18. import com.zarketh.model.entity.player.Player;
  19. import com.zarketh.model.entity.player.PlayerConstants;
  20. import com.zarketh.util.Areas;
  21. import com.zarketh.util.Misc;
  22.  
  23. /**
  24. *
  25. * @author killamess/Rene/Lukas
  26. *
  27. */
  28. public class Hits {
  29.  
  30. public static final double[] specAccuracies = { 11696, 1.25, 11694, 1.35,
  31. 14484, 1.1, 1215, 1.4, 1231, 1.4, 5680, 1.4, 5698, 1.41 };
  32.  
  33. public static int bestAttackBonus(Player client) {
  34. if (client.getBonuses().bonus[0] > client.getBonuses().bonus[1]
  35. && client.getBonuses().bonus[0] > client.getBonuses().bonus[2])
  36. return 0;
  37. if (client.getBonuses().bonus[1] > client.getBonuses().bonus[0]
  38. && client.getBonuses().bonus[1] > client.getBonuses().bonus[2])
  39. return 1;
  40. else
  41. return client.getBonuses().bonus[2] > client.getBonuses().bonus[1]
  42. && client.getBonuses().bonus[2] > client.getBonuses().bonus[0] ? 2
  43. : 0;
  44. }
  45.  
  46. public static int bestDefenceBonus(Player client) {
  47. if (client.getBonuses().bonus[5] > client.getBonuses().bonus[6]
  48. && client.getBonuses().bonus[5] > client.getBonuses().bonus[7])
  49. return 5;
  50. if (client.getBonuses().bonus[6] > client.getBonuses().bonus[5]
  51. && client.getBonuses().bonus[6] > client.getBonuses().bonus[7])
  52. return 6;
  53. else
  54. return client.getBonuses().bonus[7] > client.getBonuses().bonus[5]
  55. && client.getBonuses().bonus[7] > client.getBonuses().bonus[6] ? 7
  56. : 5;
  57. }
  58.  
  59. public static boolean canHitMagic(Entity attacker, Entity victim,
  60. int spellId) {
  61.  
  62. return MagicFormula.canMagicAttack(attacker, victim);
  63.  
  64. }
  65.  
  66. public static double getAccuracy(int id) {
  67. for (short i = 0; i < specAccuracies.length; i = (short) (i + 2))
  68. if ((int) specAccuracies[i] == id)
  69. return specAccuracies[i + 1];
  70. return 1.1;
  71. }
  72.  
  73. public static int mageAtk(Player c) {
  74. int attackLevel = c.playerLevel[6];
  75. if (MagicHandler.hasVoid(c) || MagicHandler.hasEliteVoid(c))
  76. attackLevel = (int) (attackLevel + c.getLevelForXP(c.playerXP[6]) * 0.2D);
  77. if (c.getPrayerHandler().clicked[PrayerHandler.MYSTIC_WILL])
  78. attackLevel = (int) (attackLevel * 1.05D);
  79. else if (c.getPrayerHandler().clicked[PrayerHandler.MYSTIC_LORE])
  80. attackLevel = (int) (attackLevel * 1.1D);
  81. else if (c.getPrayerHandler().clicked[PrayerHandler.MYSTIC_MIGHT])
  82. attackLevel = (int) (attackLevel * 1.15D);
  83. else if (c.getPrayerHandler().clicked[PrayerHandler.LEECH_MAGIC])
  84. attackLevel = (int) (attackLevel * 1.10D);
  85.  
  86. return (int) (attackLevel + c.getBonuses().bonus[3] * 2.25D);
  87. }
  88.  
  89. public static int mageDef(Player c) {
  90. int defenceLevel = c.playerLevel[1] / 2 + c.playerLevel[6] / 2;
  91. if (c.getPrayerHandler().clicked[PrayerHandler.ROCK_SKIN])
  92. defenceLevel = (int) (defenceLevel + c
  93. .getLevelForXP(c.playerXP[PlayerConstants.DEFENCE]) * 0.05D);
  94. else if (c.getPrayerHandler().clicked[12])
  95. defenceLevel = (int) (defenceLevel + c
  96. .getLevelForXP(c.playerXP[PlayerConstants.DEFENCE]) * 0.1D);
  97. else if (c.getPrayerHandler().clicked[20])
  98. defenceLevel = (int) (defenceLevel + c
  99. .getLevelForXP(c.playerXP[PlayerConstants.DEFENCE]) * 0.15D);
  100.  
  101. return defenceLevel + c.getBonuses().bonus[8] + c.getBonuses().bonus[8]
  102. / 4;
  103. }
  104.  
  105. public static void runHitMelee(final Entity attacker, final Entity target,
  106. boolean special) {
  107.  
  108. if (attacker == null || target == null)
  109. return;
  110.  
  111. if (attacker instanceof Player && target instanceof Player)
  112. if (Areas.isAntiPJ(((Player) attacker).getPosition())
  113. && Areas.isAntiPJ(target.getPosition())) {
  114. final Player client = (Player) attacker;
  115. if (special && client.lastAttacked == target.getIndex()
  116. && client.hits < 3) {
  117. special = false;
  118. client.getActionSender().sendMessage(
  119. "You are in the anti-pj zone.");
  120. client.getActionSender()
  121. .sendMessage(
  122. "Therefor you cannot do a special attack during your first @blu@ 3 @red@ hits!");
  123. }
  124. }
  125. if (special)
  126. Achievements.getInstance().complete((Player) attacker, 17);
  127. int firstHit = 0;
  128. int secondHit = 0;
  129. if (attacker instanceof Player) {
  130. ((Player) attacker).dbowed = false;
  131. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11235
  132. && special) {
  133. final Player client = (Player) attacker;
  134. SpecialAttacks.handleDarkBow(client, attacker, target, 0);
  135. ((Player) attacker).dbowed = true;
  136.  
  137. }
  138. }
  139.  
  140. if (attacker instanceof Player) {
  141. if (((Player) attacker).dbowed)
  142. return;
  143.  
  144. if (CombatEngine.getCombatType(attacker) == CombatType.RANGE) {
  145. double i = 1;
  146. if (special)
  147. i = getAccuracy(((Player) attacker).playerEquipment[PlayerConstants.WEAPON]);
  148. if (Infliction.canHitWithRanged(attacker, target, i))
  149. firstHit = Misc.random((int) MaxHitRanged
  150. .calculateBaseDamage((Player) attacker, target,
  151. special));
  152. else
  153. secondHit = 0;
  154.  
  155. }
  156.  
  157. if (CombatEngine.getCombatType(attacker) == CombatType.MELEE) {
  158.  
  159. double i = 1;
  160. if (special)
  161. i = getAccuracy(((Player) attacker).playerEquipment[PlayerConstants.WEAPON]);
  162. if (Infliction.canHitWithMelee(attacker, target, i)) {
  163.  
  164. firstHit = Misc.random((int) MaxHit.calculateBaseDamage(
  165. (Player) attacker, special));
  166. if (firstHit >= 900)
  167. Achievements.getInstance().complete((Player) attacker,
  168. 92);
  169.  
  170. } else
  171. firstHit = 0;
  172. }
  173. if (CombatEngine.getCombatType(attacker) == CombatType.MAGIC)
  174. if (MagicFormula.canMagicAttack(attacker, target))
  175. firstHit = Misc.random(MagicFormula.maxMagicHit(
  176. (Player) attacker, target, 1, false));
  177. else
  178. firstHit = 0;
  179. }
  180.  
  181. if (attacker instanceof Player) {
  182.  
  183. if (target instanceof Player) {
  184.  
  185. if (((Player) attacker).playerHasGuthans()) {
  186. final Player client = (Player) attacker;
  187. BarrowsEffects.guthansEffect(client, attacker, target, 0);
  188. }
  189.  
  190. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 4151
  191. && special)
  192. SpecialAttacks.whipSpec((Player) attacker, (Player) target);
  193.  
  194. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 20171
  195. && special)
  196. ZaryteBow.getInstance().handleSpecial(attacker, target);
  197. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 15241
  198. && special) {
  199. final Player client = (Player) attacker;
  200. HandCannon.handCannon(client, attacker, target, true);
  201. }
  202.  
  203. if (((Player) attacker).playerHasAhrims()) {
  204. final Player client = (Player) attacker;
  205. BarrowsEffects.ahrimsEffect(client, attacker, target, 0);
  206. }
  207. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 3204
  208. && special) {
  209. final Player client = (Player) attacker;
  210. SpecialAttacks.handleHalberd(client, attacker, target,
  211. firstHit);
  212. }
  213. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 8872
  214. || ((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 8878
  215. && special) {
  216. final Player client = (Player) attacker;
  217. SpecialAttacks.handleBoneDagger(client, attacker, target,
  218. firstHit);
  219. }
  220.  
  221. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11700
  222. && special) {
  223. final Player client = (Player) attacker;
  224. SpecialAttacks
  225. .handleZgs(client, attacker, target, firstHit);
  226. }
  227. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11698
  228. && special) {
  229. final Player client = (Player) attacker;
  230. SpecialAttacks
  231. .handleSgs(client, attacker, target, firstHit);
  232. }
  233. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 1249
  234. && special
  235. || ((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 5730
  236. && special) {
  237. final Player client = (Player) attacker;
  238. firstHit = 0;
  239. SpecialAttacks.handleDragonSpear(client, attacker, target,
  240. firstHit);
  241. }
  242. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 859
  243. && special) {
  244. final Player client = (Player) attacker;
  245. SpecialAttacks.handleMagicLongBow(client, attacker, target,
  246. firstHit);
  247. }
  248. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11730
  249. && special) {
  250. final Player client = (Player) attacker;
  251. SpecialAttacks.handleSaraSword(client, attacker, target,
  252. firstHit);
  253. }
  254. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 6739
  255. && special) {
  256. final Player client = (Player) attacker;
  257. SpecialAttacks.handleDragonHatchet(client, attacker,
  258. target, firstHit);
  259. }
  260.  
  261. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 15259
  262. && special) {
  263. final Player client = (Player) attacker;
  264. SpecialAttacks.handleDragonPickaxe(client, attacker,
  265. target, firstHit);
  266. }
  267. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 4587
  268. && special) {
  269. final Player client = (Player) attacker;
  270. SpecialAttacks.handleDragonScimitarSpec(client, attacker,
  271. target, firstHit);
  272. }
  273.  
  274. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11698
  275. && special) {
  276. final Player client = (Player) attacker;
  277. SpecialAttacks
  278. .handleSgs(client, attacker, target, firstHit);
  279. }
  280.  
  281. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11696
  282. && special) {
  283. final Player client = (Player) attacker;
  284. SpecialAttacks
  285. .handleBgs(client, attacker, target, firstHit);
  286. }
  287. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 13879
  288. && special)
  289. Morrigan.morrigansJavelinSpecial(attacker, target, firstHit);
  290. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 10887
  291. && special) {
  292. final Player client = (Player) attacker;
  293. SpecialAttacks.handleAnchor(client, attacker, target,
  294. firstHit);
  295. }
  296.  
  297. if (((Player) target).playerEquipment[PlayerConstants.SHIELD] == 13740
  298. && ((Player) target).playerLevel[PlayerConstants.PRAYER] > 0)
  299. if (((Player) target).spiritHits > 0) {
  300. ((Player) target).getActionSender().sendMessage(
  301. "Your Divine spirit shield's protection will be useless for "
  302. + ((Player) target).spiritHits
  303. + " more hits!");
  304. ((Player) target).spiritHits--;
  305. } else {
  306. ((Player) target).getPrayerHandler().updatePrayer(
  307. (int) (firstHit * 0.3 / 2));
  308. firstHit = (int) (firstHit * 0.7);
  309. }
  310. if (((Player) target).playerEquipment[PlayerConstants.SHIELD] == 13742
  311. && Misc.random(9) >= 7)
  312. if (((Player) target).spiritHits > 0) {
  313. ((Player) target).getActionSender().sendMessage(
  314. "Your Elysian spirit shield's protection will be useless for "
  315. + ((Player) target).spiritHits
  316. + " more hits!");
  317. ((Player) target).spiritHits--;
  318. } else
  319. firstHit = (int) (firstHit * 0.75);
  320.  
  321. if (Ranged.isUsingRange((Player) attacker)) {
  322. if (((Player) target).getPrayerHandler().clicked[13]
  323. || ((Player) target).getPrayerHandler().clicked[34])
  324. firstHit = (int) (firstHit * 0.60);
  325. } else if (((Player) target).getPrayerHandler().clicked[14]
  326. || ((Player) target).getPrayerHandler().clicked[35])
  327. firstHit = (int) (firstHit * 0.60);
  328. if (((Player) target).solProtection)
  329. firstHit = (int) (firstHit * 0.5);
  330.  
  331. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 19784
  332. && special) {
  333. final Player client = (Player) attacker;
  334. KorasiSpecial.korasiSpecial(client, attacker, target, 0);
  335.  
  336. } else {
  337. boolean clawSpecer = false;
  338. if (attacker instanceof Player)
  339. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 14484
  340. && special)
  341. clawSpecer = true;
  342. if (!clawSpecer)
  343. HitExecutor.addNewHit(
  344. attacker,
  345. target,
  346. attacker.getCombatType(),
  347. firstHit,
  348. Ranged.isUsingRange((Player) attacker) ? Ranged
  349. .getHitDelay(attacker) : 1);
  350.  
  351. }
  352.  
  353. if (((Player) attacker).getPrayerHandler().clicked[17])
  354. ((Player) target).getPrayerHandler().updatePrayer(
  355. firstHit / 5);
  356.  
  357. if (Specials.doubleHit((Player) attacker) && special) {
  358.  
  359. if (Ranged.isUsingRange((Player) attacker))
  360. secondHit = Misc.random((int) MaxHitRanged
  361. .calculateBaseDamage((Player) attacker, target,
  362. special));
  363. else
  364. secondHit = Misc
  365. .random((int) MaxHit.calculateBaseDamage(
  366. (Player) attacker, special));
  367.  
  368. if (Ranged.isUsingRange((Player) attacker)) {
  369. if (((Player) target).getPrayerHandler().clicked[13]
  370. || ((Player) target).getPrayerHandler().clicked[34])
  371. secondHit = (int) (secondHit * 0.60);
  372. } else if (((Player) target).getPrayerHandler().clicked[14]
  373. || ((Player) target).getPrayerHandler().clicked[35])
  374. secondHit = (int) (secondHit * 0.60);
  375. if (CombatEngine.getCombatType(attacker) == CombatType.RANGE)
  376. if (Infliction.canHitWithRanged(attacker, target, 1))
  377. secondHit = Misc.random((int) MaxHitRanged
  378. .calculateBaseDamage((Player) attacker,
  379. target, special));
  380. else
  381. secondHit = 0;
  382. if (CombatEngine.getCombatType(attacker) == CombatType.MELEE)
  383. if (Infliction.canHitWithMelee(attacker, target, 1))
  384. secondHit = Misc.random((int) MaxHit
  385. .calculateBaseDamage((Player) attacker,
  386. special));
  387. else
  388. secondHit = 0;
  389. if (CombatEngine.getCombatType(attacker) == CombatType.MAGIC)
  390. if (MagicFormula.canMagicAttack(attacker, target))
  391. secondHit = Misc.random(MagicFormula.maxMagicHit(
  392. (Player) attacker, target, 1, false));
  393. else
  394. secondHit = 0;
  395. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 14484) {
  396. firstHit = Misc.random((int) MaxHit
  397. .calculateBaseDamage((Player) attacker, true));
  398. final int[] c2 = DragonClaws
  399. .getClawDamages((Player) attacker);
  400. for (int o = 0; o < 4; ++o)
  401. HitExecutor.addNewHit(attacker, target,
  402. CombatType.MELEE, c2[o], 0);
  403.  
  404. } else
  405. HitExecutor.addNewHit(
  406. attacker,
  407. target,
  408. attacker.getCombatType(),
  409. secondHit,
  410. Ranged.isUsingRange((Player) attacker) ? Ranged
  411. .getHitDelay(attacker) : 1);
  412.  
  413. }
  414.  
  415. if (((Player) attacker).getPrayerHandler().clicked[17])
  416. ((Player) target).getPrayerHandler().updatePrayer(
  417. secondHit / 5);
  418.  
  419. if (special)
  420. Specials.specialAttack((Player) attacker);
  421. else if (!((Player) attacker).animationLock)
  422. AnimationProcessor.createAnimation(attacker,
  423. Equipment.getAttackEmote((Player) attacker));
  424.  
  425. } else if (target instanceof NPC) {
  426. final int npcType = ((NPC) target).getDefinition().getType();
  427. if (Areas.isInPestControl(attacker.getPosition()))
  428. ((Player) attacker).setPestControlZeal(((Player) attacker)
  429. .getPestControlZeal() + firstHit);
  430. if (attacker instanceof Player)
  431. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 15241
  432. && special)
  433. HandCannon.handCannon((Player) attacker, attacker,
  434. target, true);
  435. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11730
  436. && special) {
  437. final Player client = (Player) attacker;
  438. SpecialAttacks.handleSaraSword(client, attacker, target,
  439. firstHit);
  440. }
  441. if (((Player) attacker).playerHasGuthans()) {
  442. final Player client = (Player) attacker;
  443. BarrowsEffects.guthansEffect(client, attacker, target,
  444. firstHit);
  445. }
  446. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11698
  447. && special) {
  448. final Player client = (Player) attacker;
  449. SpecialAttacks
  450. .handleSgs(client, attacker, target, firstHit);
  451. }
  452. if (npcType == 8349
  453. && ((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 6746)
  454. if (firstHit > 0)
  455. ((Player) attacker).tormentedDemonShield = 0;
  456. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 11696
  457. && special) {
  458. final Player client = (Player) attacker;
  459. SpecialAttacks
  460. .handleBgs(client, attacker, target, firstHit);
  461. }
  462.  
  463. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 10887
  464. && special) {
  465. final Player client = (Player) attacker;
  466. SpecialAttacks.handleAnchorNPC(client, attacker, target,
  467. firstHit);
  468. }
  469. if (((Player) attacker).playerEquipment[PlayerConstants.SHIELD] == 13740) {
  470. firstHit = (int) (firstHit * 0.7);
  471. ((Player) attacker).getPrayerHandler().updatePrayer(
  472. (int) (firstHit * 0.3 / 2));
  473. }
  474. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 13879
  475. && special)
  476. Morrigan.morrigansJavelinSpecial(attacker, target, firstHit);
  477. if (((Player) attacker).playerEquipment[PlayerConstants.SHIELD] == 13742
  478. && Misc.random(9) >= 7)
  479. firstHit = (int) (firstHit * 0.75);
  480. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 19784
  481. && special) {
  482. final Player client = (Player) attacker;
  483. KorasiSpecial.korasiNpc(client, attacker, target, 0);
  484. } else {
  485. boolean clawer = false;
  486. if (attacker instanceof Player) {
  487. final Player client = (Player) attacker;
  488. if (client.playerEquipment[PlayerConstants.WEAPON] == 14484
  489. && special)
  490. clawer = true;
  491. }
  492. if (!clawer)
  493. HitExecutor.addNewHit(
  494. attacker,
  495. target,
  496. attacker.getCombatType(),
  497. firstHit,
  498. Ranged.isUsingRange((Player) attacker) ? Ranged
  499. .getHitDelay(attacker) : 1);
  500. }
  501. if (Specials.doubleHit((Player) attacker) && special) {
  502. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] == 14484
  503. && special) {
  504. firstHit = Misc.random((int) MaxHit
  505. .calculateBaseDamage((Player) attacker, true));
  506. final int[] c2 = DragonClaws
  507. .getClawDamages((Player) attacker);
  508. for (int o = 0; o < 4; ++o)
  509. HitExecutor.addNewHit(attacker, target,
  510. CombatType.MELEE, c2[o], 0);
  511.  
  512. }
  513. if (CombatEngine.getCombatType(attacker) == CombatType.RANGE)
  514. if (Infliction.canHitWithRanged(attacker, target, 1))
  515. secondHit = Misc.random((int) MaxHitRanged
  516. .calculateBaseDamage((Player) attacker,
  517. target, special));
  518. else
  519. secondHit = 0;
  520. if (CombatEngine.getCombatType(attacker) == CombatType.MELEE)
  521. if (Infliction.canHitWithMelee(attacker, target, 1))
  522. secondHit = Misc.random((int) MaxHit
  523. .calculateBaseDamage((Player) attacker,
  524. special));
  525. else
  526. secondHit = 0;
  527. if (CombatEngine.getCombatType(attacker) == CombatType.MAGIC)
  528. if (MagicFormula.canMagicAttack(attacker, target))
  529. secondHit = Misc.random(MagicFormula.maxMagicHit(
  530. (Player) attacker, target, 1, false));
  531. else
  532. secondHit = 0;
  533. if (((Player) attacker).playerEquipment[PlayerConstants.WEAPON] != 14484)
  534. HitExecutor.addNewHit(
  535. attacker,
  536. target,
  537. attacker.getCombatType(),
  538. secondHit,
  539. Ranged.isUsingRange((Player) attacker) ? Ranged
  540. .getHitDelay(attacker) : 1);
  541. }
  542. if (special)
  543. Specials.specialAttack((Player) attacker);
  544. // else
  545. // Animation.createAnimation(attacker,
  546. // Equipment.getAttackEmote(((Player)attacker)));
  547. }
  548.  
  549. } else if (attacker instanceof NPC)
  550. if (target instanceof Player) {
  551. if (((Player) target).solProtection)
  552. firstHit = (int) (firstHit * 0.5);
  553. if (((Player) target).playerEquipment[PlayerConstants.WEAPON] == 3204
  554. && special) {
  555. final Player client = (Player) attacker;
  556. SpecialAttacks.handleHalberd(client, attacker, target,
  557. firstHit);
  558. }
  559. final NPC npc = (NPC) attacker;
  560. final int type = npc.getDefinition().getType();
  561. int maxDamage = 0;
  562.  
  563. if (NPCAttacks.npcArray[type][1] > 0)
  564. maxDamage = NPCAttacks.npcArray[type][1];
  565. else
  566. maxDamage = 1;
  567.  
  568. if (CombatEngine.getCombatType(attacker) == CombatType.RANGE) {
  569. if (((Player) target).getPrayerHandler().clicked[13]
  570. || ((Player) target).getPrayerHandler().clicked[34])
  571. maxDamage = 0;
  572. } else if (CombatEngine.getCombatType(attacker) == CombatType.MELEE) {
  573. if (((Player) target).getPrayerHandler().clicked[14]
  574. || ((Player) target).getPrayerHandler().clicked[35])
  575. maxDamage = 0;
  576. } else if (CombatEngine.getCombatType(attacker) == CombatType.MAGIC)
  577. if (((Player) target).getPrayerHandler().clicked[12]
  578. || ((Player) target).getPrayerHandler().clicked[33])
  579. maxDamage = 0;
  580. if (CombatEngine.getCombatType(attacker) == CombatType.RANGE)
  581. if (Infliction.canHitWithRanged(attacker, target, 1))
  582. firstHit = Misc.random(maxDamage);
  583. else
  584. firstHit = 0;
  585. if (CombatEngine.getCombatType(attacker) == CombatType.MELEE)
  586. if (Infliction.canHitWithMelee(attacker, target, 1))
  587. firstHit = Misc.random(maxDamage);
  588. else
  589. firstHit = 0;
  590. if (CombatEngine.getCombatType(attacker) == CombatType.MAGIC)
  591. if (MagicFormula.canMagicAttack(attacker, target))
  592. firstHit = Misc.random(maxDamage);
  593. else
  594. firstHit = 0;
  595. }
  596. if (attacker instanceof NPC)
  597. HitExecutor.addNewHit(attacker, target, attacker.getCombatType(),
  598. firstHit, 1);
  599.  
  600. if (attacker instanceof Player) {
  601.  
  602. final Player client = (Player) attacker;
  603. switch (client.combatMode) {
  604.  
  605. case 0:
  606. case 1:
  607. case 2:
  608. client.getActionAssistant().addSkillXP(
  609. firstHit , client.combatMode);
  610. client.getActionAssistant().addSkillXP(
  611. firstHit / 3, 3);
  612. client.getActionAssistant().addSkillXP(
  613. secondHit , client.combatMode);
  614. client.getActionAssistant().addSkillXP(
  615. secondHit / 3, 3);
  616.  
  617. break;
  618.  
  619. case 3:
  620. client.getActionAssistant().addSkillXP(
  621. firstHit / 3, 0);
  622. client.getActionAssistant().addSkillXP(
  623. firstHit / 3, 1);
  624. client.getActionAssistant().addSkillXP(
  625. firstHit / 3, 2);
  626. client.getActionAssistant().addSkillXP(
  627. firstHit / 3, 3);
  628. client.getActionAssistant().addSkillXP(
  629. secondHit / 3, 0);
  630. client.getActionAssistant().addSkillXP(
  631. secondHit / 3, 1);
  632. client.getActionAssistant().addSkillXP(
  633. secondHit / 3, 2);
  634. client.getActionAssistant().addSkillXP(
  635. secondHit / 3, 3);
  636. break;
  637.  
  638. case 4:
  639. case 5:
  640. client.getActionAssistant().addSkillXP(
  641. firstHit , 4);
  642. client.getActionAssistant().addSkillXP(
  643. firstHit / 3, 3);
  644. client.getActionAssistant().addSkillXP(
  645. secondHit , 4);
  646. client.getActionAssistant().addSkillXP(
  647. secondHit / 3, 3);
  648. break;
  649.  
  650. case 6:
  651. client.getActionAssistant().addSkillXP(
  652. firstHit / 2, 4);
  653. client.getActionAssistant().addSkillXP(
  654. firstHit / 2, 1);
  655. client.getActionAssistant().addSkillXP(
  656. firstHit / 3, 3);
  657. client.getActionAssistant().addSkillXP(
  658. secondHit / 2, 4);
  659. client.getActionAssistant().addSkillXP(
  660. secondHit / 2, 1);
  661. client.getActionAssistant().addSkillXP(
  662. secondHit / 3, 3);
  663. break;
  664.  
  665. default:
  666. System.out.println("Player[" + client.getUsername()
  667. + "] Invalid combatMode: " + client.combatMode
  668. + " File: Hits.java.");
  669. break;
  670. }
  671. }
  672.  
  673. }
  674.  
  675. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement