Advertisement
mrextremez

Equipment

Apr 22nd, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.36 KB | None | 0 0
  1. package com.zarketh.model.entity.player;
  2.  
  3. import com.zarketh.InstanceDistributor;
  4. import com.zarketh.content.minigames.DuelArena;
  5. import com.zarketh.content.misc.Dicing;
  6. import com.zarketh.model.Item;
  7. import com.zarketh.model.combat.CombatEngine;
  8. import com.zarketh.model.combat.additions.CombatMode;
  9. import com.zarketh.model.combat.additions.Specials;
  10. import com.zarketh.model.combat.magic.AutoCast;
  11. import com.zarketh.net.GamePacket.Type;
  12. import com.zarketh.net.GamePacketBuilder;
  13. import com.zarketh.util.Areas;
  14. import com.zarketh.world.PlayerManager;
  15.  
  16. /**
  17. *
  18. * @author Rene
  19. *
  20. */
  21. public class Equipment {
  22.  
  23. public static final int SLOT_HEAD = 0;
  24. public static final int SLOT_CAPE = 1;
  25. public static final int SLOT_AMULET = 2;
  26. public static final int SLOT_WEAPON = 3;
  27. public static final int SLOT_CHEST = 4;
  28. public static final int SLOT_SHIELD = 5;
  29. public static final int SLOT_LEGS = 7;
  30. public static final int SLOT_HANDS = 9;
  31. public static final int SLOT_FEET = 10;
  32. public static final int SLOT_RING = 12;
  33. public static final int SLOT_ARROWS = 13;
  34.  
  35. public static boolean basicId(int i) {
  36. String s = InstanceDistributor.getItemManager().getItemDefinition(i)
  37. .getName();
  38. s = s.replaceAll("_", " ");
  39. s = s.trim();
  40. return s.startsWith("Bronze") || s.startsWith("Iron")
  41. || s.startsWith("Steel") || s.startsWith("Black")
  42. || s.startsWith("Mithril") || s.startsWith("Adamant")
  43. || s.startsWith("Rune") || s.startsWith("Dragon")
  44. || s.startsWith("White");
  45. }
  46.  
  47. public static int getAttackEmote(Player client) {
  48. final int i = client.playerEquipment[PlayerConstants.WEAPON];
  49. String s = InstanceDistributor.getItemManager().getItemDefinition(i)
  50. .getName();
  51. s = s.replaceAll("_", " ");
  52. s = s.trim();
  53. if (s.equals("Unarmed"))
  54. if (client.combatMode == 0 || client.combatMode == 1)
  55. return 422;
  56. else if (client.combatMode == 2)
  57. return 423;
  58. if (s.contains("Staff") || s.contains("staff"))
  59. if (client.combatMode == 0 || client.combatMode == 1)
  60. return 393;
  61. else if (client.combatMode == 2)
  62. return 406;
  63. if (i == 15241)
  64. return 12175;
  65. if (i == 20671)
  66. return 386;
  67.  
  68. if (s.equals("Sovereign blade"))
  69. return 390;
  70. if (s.contains("Guthans warspear"))
  71. return 2080;
  72. if (s.contains("Dragon dagger"))
  73. return 402;
  74. if (s.contains("Karils crossbow"))
  75. return 2075;
  76. if (s.contains("shortbow") || s.contains("Shortbow"))
  77. return 426;
  78. if (s.contains("longbow") || s.contains("Longbow") && i != 20857)
  79. return 426;
  80. if (i == 20857)
  81. return 386;
  82. if (i == 10033)
  83. return 2779;
  84. if (s.contains("Seercull"))
  85. return 426;
  86. if (s.contains("Toktz-xil-ul"))
  87. return 2614;
  88. if (s.contains("thrownaxe"))
  89. return 806;
  90. if (s.contains("dart"))
  91. return 806;
  92. if (s.contains("javelin"))
  93. return 806;
  94. if (s.contains("knife"))
  95. return 806;
  96. if (s.contains("c'bow"))
  97. return 4230;
  98. if (s.contains("crossbow") || s.contains("Crossbow"))
  99. return 427;
  100. if (s.contains("bow") || s.contains("Bow"))
  101. return 426;
  102. if (s.contains("dagger") || s.contains("pickaxe"))
  103. if (client.combatMode == 0)
  104. return 412;
  105. else if (client.combatMode == 3)
  106. return 390;
  107. else if (client.combatMode == 2)
  108. return 402;
  109. if (i == 10887)
  110. return 5865;
  111. if (s.contains("2h") || s.contains("godsword")
  112. || s.equals("Saradomin sword"))
  113. if (client.combatMode == 0)
  114. return 7048;
  115. else if (client.combatMode == 1)
  116. return 7049;
  117. else
  118. return 7041;
  119. if (s.contains("sword") && !s.contains("2h") || s.contains("mace")
  120. || s.contains("longsword") && !s.contains("2h")
  121. || s.contains("scimitar"))
  122. if (client.combatMode == 3)
  123. return 412;
  124. else
  125. return 390;
  126. if (s.contains("greataxe") || s.contains("arok"))
  127. if (client.combatMode == 1)
  128. return 2066;
  129. else
  130. return 2067;
  131. if (s.contains("rapier"))
  132. return 386;
  133. if (s.contains("axe") && !s.contains("greataxe")
  134. && !s.contains("thrownaxe") || s.contains("battleaxe"))
  135. return 395;
  136. if (s.contains("halberd") || s.contains("spear")
  137. && !s.contains("Guthans"))
  138. return 440;
  139. if (s.contains("Tzhaar-ket-om") || s.contains("maul") && i != 4153)
  140. return 2661;
  141. if (s.contains("Barrelchest anchor"))
  142. return 2661;
  143. if (s.contains("Granite maul"))
  144. return 1665;
  145. if (s.contains("flail"))
  146. return 2062;
  147. if (s.contains("whip"))
  148. return 1658;
  149. else
  150. return s.contains("hammers") ? '\u0814' : 390;
  151. }
  152.  
  153. public static int getDefendAnimation(Player client) {
  154. final int weapon = client.playerEquipment[PlayerConstants.WEAPON];
  155. final int shield = client.playerEquipment[PlayerConstants.SHIELD];
  156. final int i = client.playerEquipment[PlayerConstants.WEAPON];
  157. String s = InstanceDistributor.getItemManager().getItemDefinition(i)
  158. .getName();
  159. s = s.replaceAll("_", " ");
  160. s = s.trim();
  161.  
  162. if (s.contains("2h") || s.contains("god"))
  163. return 7050;
  164.  
  165. switch (shield) {
  166. case 8850:
  167. case 8849:
  168. case 8848:
  169. case 8847:
  170. case 8846:
  171. case 8845:
  172. case 8844:
  173. return 4177;
  174. }
  175. switch (weapon) {
  176. case 10033:
  177. case 10034:
  178. return 3176;
  179. case 1307:
  180. case 1309:
  181. case 1311:
  182. case 1313:
  183. case 1315:
  184. case 1317:
  185. case 1319:
  186. return 410;
  187. case 10887:
  188. return 5866;
  189. case 4151:
  190. return 11974;
  191.  
  192. case 11694:
  193. case 11698:
  194. case 11700:
  195. case 11696:
  196. case 11730:
  197. return 7050;
  198. }
  199. if (shield > 0)
  200. return 1156;
  201. else
  202. return 404;
  203. }
  204.  
  205. public static int getRunEmote(Player client) {
  206. final int i = client.playerEquipment[PlayerConstants.WEAPON];
  207. String s = InstanceDistributor.getItemManager().getItemDefinition(i)
  208. .getName();
  209. s = s.replaceAll("_", " ");
  210. s = s.trim();
  211. if (i == 15241)
  212. return 12154;
  213. if (i == -1)
  214. return 824;
  215. if (i == 4718 || s.contains("great"))
  216. return 2563;
  217. if (i == 4755)
  218. return 1831;
  219. if (i == 4734)
  220. return 2077;
  221. if (i == 4747)
  222. return 824;
  223. if (i == 4726)
  224. return 1210;
  225. if (s.contains("bow"))
  226. return 824;
  227. if (s.contains("2h") || s.endsWith("godsword")
  228. || s.equals("Saradomin sword"))
  229. return 7039;
  230. if (s.contains("whip"))
  231. return 11976;
  232. if (s.contains("Spear"))
  233. return 1210;
  234. if (s.contains("halberd"))
  235. return 1210;
  236. if (i == 4153 || i == 8103)
  237. return 1664;
  238. if (i == 10887)
  239. return 5868;
  240. if (s.contains("Saradomin staff") || s.contains("Guthix staff")
  241. || s.contains("Zamorak staff"))
  242. return 824;
  243. if (s.contains("Staff") || s.contains("staff"))
  244. return 1210;
  245. else
  246. return i == 6528 || i == 18353 || i == 16407 || i == 16409
  247. || i == 16405 || i == 1319 || s.contains("maul")
  248. && i != 4153 ? '\u0A03' : 824;
  249. }
  250.  
  251. public static int getStandEmote(Player client) {
  252. final int i = client.playerEquipment[PlayerConstants.WEAPON];
  253. String s = InstanceDistributor.getItemManager().getItemDefinition(i)
  254. .getName();
  255. s = s.replaceAll("_", " ");
  256. s = s.trim();
  257.  
  258. if (i == 15241)
  259. return 12155;
  260. if (i == 4718 || s.contains("great"))
  261. return 2065;
  262. if (i == 4755)
  263. return 2061;
  264. if (i == 4734)
  265. return 2074;
  266. if (i == 4747)
  267. return 808;
  268. if (i == 4726)
  269. return 809;
  270. if (s.contains("bow"))
  271. return 808;
  272. if (s.contains("2h") || s.endsWith("godsword")
  273. || s.equals("Saradomin sword"))
  274. return 7047;
  275. if (s.contains("whip"))
  276. return 11973;
  277. if (s.endsWith("spear"))
  278. return 809;
  279. if (s.contains("halberd"))
  280. return 809;
  281. if (i == 18355)
  282. return 808;
  283. if (s.contains("Staff") || s.contains("staff") || s.endsWith("wand")
  284. && i != 18355)
  285. return 8980;
  286. if (i == 10887)
  287. return 5869;
  288. if (i == 4153)
  289. return 1662;
  290. if (i == 1305)
  291. return 809;
  292. if (s.contains("Saradomin staff") || s.contains("Guthix staff")
  293. || s.contains("Zamorak staff"))
  294. return 808;
  295.  
  296. else
  297. return i == 6528 || i == 18353 || i == 16407 || i == 16409
  298. || i == 16405 || i == 1319 || s.contains("maul")
  299. && i != 4153 ? '\u0811' : 808;
  300. }
  301.  
  302. public static int getWalkEmote(Player client) {
  303. final int i = client.playerEquipment[PlayerConstants.WEAPON];
  304. String s = InstanceDistributor.getItemManager().getItemDefinition(i)
  305. .getName();
  306. s = s.replaceAll("_", " ");
  307. s = s.trim();
  308. if (i == 15241)
  309. return 12154;
  310. if (i == -1)
  311. return 819;
  312. if (i == 4718)
  313. return 2064;
  314. if (i == 4755)
  315. return 2060;
  316. if (i == 4734)
  317. return 2076;
  318. if (i == 4747)
  319. return 819;
  320. if (i == 4726)
  321. return 1146;
  322. if (s.contains("bow"))
  323. return 819;
  324. if (s.contains("2h") || s.endsWith("godsword")
  325. || s.equals("Saradomin sword"))
  326. return 7046;
  327. if (s.contains("whip"))
  328. return 11975;
  329. if (s.contains("Spear"))
  330. return 1146;
  331. if (s.contains("halberd"))
  332. return 1146;
  333. if (i == 4153)
  334. return 1663;
  335. if (i == 10887)
  336. return 5867;
  337. if (s.contains("Saradomin staff") || s.contains("Guthix staff")
  338. || s.contains("Zamorak staff"))
  339. return 819;
  340. if (s.contains("Staff") || s.contains("staff"))
  341. return 1146;
  342. else
  343. return i == 6528 || i == 18353 || i == 16407 || i == 16409
  344. || i == 16405 || i == 1319 || s.contains("maul")
  345. && i != 4153 ? '\u0810' : 819;
  346.  
  347. }
  348.  
  349. public static int getWeaponSpeed(Player client) {
  350. final int i = client.playerEquipment[PlayerConstants.WEAPON];
  351. String s = InstanceDistributor.getItemManager().getItemDefinition(i)
  352. .getName();
  353. s = s.replaceAll("_", " ");
  354. s = s.trim();
  355. if (s.endsWith("greegree"))
  356. return 4;
  357. if (s.equals("Sovereign blade"))
  358. return 4;
  359. if (s.contains("claws"))
  360. return 5;
  361. if (s.contains("dagger") && basicId(i))
  362. return 4;
  363. if (s.contains("2h") || s.contains("god"))
  364. return 6;
  365. if (s.contains("sword") && !s.contains("longsword")
  366. && !s.contains("god") && basicId(i))
  367. return 5;
  368. if (s.contains("whip") || s.equals("Saradomin sword")
  369. || s.equals("Dragon scimitar"))
  370. return 4;
  371. if (s.contains("rapier"))
  372. return 4;
  373. if (s.contains("longsword") && basicId(i))
  374. return 5;
  375. if (s.contains("scimitar") && basicId(i))
  376. return 4;
  377. if (s.contains("mace") && basicId(i))
  378. return 5;
  379. if (s.contains("short") && basicId(i))
  380. return 3;
  381. if (s.contains("knife") || s.contains("dart") && basicId(i)
  382. || s.contains("thrownaxe") && basicId(i))
  383. if (client.combatMode == 4)
  384. return 3;
  385. else if (client.combatMode == 5)
  386. return 2;
  387. else if (client.combatMode == 6)
  388. return 4;
  389. if (i == 20857)
  390. return 2;
  391. if (i == 10887)
  392. return 6;
  393. if (i == 15241)
  394. return 11;
  395. if (s.contains("shortbow") || s.contains("Shortbow")
  396. || s.contains("Chinchompa") || s.equals("Seercull")
  397. || s.equals("Karil's crossbow") || s.equals("Toktz-xil-ul"))
  398. if (client.combatMode == 4)
  399. return 4;
  400. else if (client.combatMode == 5)
  401. return 3;
  402. else if (client.combatMode == 6)
  403. return 5;
  404. if (s.contains("Crossbow") || s.equals("Crystal bow full")
  405. || s.equals("New crystal bow") || s.contains("javelin")
  406. && basicId(i))
  407. if (client.combatMode == 4)
  408. return 7;
  409. else if (client.combatMode == 5)
  410. return 6;
  411. else if (client.combatMode == 6)
  412. return 8;
  413. if (s.contains("longbow") || s.contains("Longbow")
  414. || s.contains("c'bow"))
  415. if (client.combatMode == 4)
  416. return 6;
  417. else if (client.combatMode == 5)
  418. return 5;
  419. else if (client.combatMode == 6)
  420. return 7;
  421. if (s.contains("Dark") || s.contains("Longbow") || s.contains("c'bow"))
  422. if (client.combatMode == 4)
  423. return 8;
  424. else if (client.combatMode == 5)
  425. return 7;
  426. else if (client.combatMode == 6)
  427. return 9;
  428. if (s.contains("axe") && !s.contains("greataxe")
  429. && !s.contains("battleaxe") && !s.contains("pickaxe")
  430. && basicId(i))
  431. return 6;
  432. if (s.contains("battleaxe") && basicId(i))
  433. return 7;
  434. if (s.contains("warhammer") && basicId(i))
  435. return 7;
  436. if (s.contains("spear") && basicId(i))
  437. return 6;
  438. if (s.contains("halberd") && basicId(i))
  439. return 8;
  440. if (s.contains("pickaxe") && basicId(i))
  441. return 6;
  442. if (s.equals("Granite maul"))
  443. return 8;
  444. if (s.equals("Toktz-xil-ak"))
  445. return 5;
  446. if (s.equals("Tzharr-ket-em"))
  447. return 6;
  448. if (s.equals("Tzhaar-ket-om") || s.contains("maul"))
  449. return 8;
  450. if (s.equals("Toktz-xil-ek"))
  451. return 5;
  452. if (i == 4718)
  453. return 8;
  454. if (s.equals("Torags hammers"))
  455. return 6;
  456. if (s.equals("Guthans warspear"))
  457. return 6;
  458. if (s.equals("Veracs flail"))
  459. return 6;
  460. if (s.equals("Ahrims staff"))
  461. return 7;
  462. if (s.contains("staff") || s.contains("Staff"))
  463. return 5;
  464. if (s.contains("battlestaff") || s.contains("Battletaff"))
  465. return 6;
  466. if (s.equals("Toktz-mej-tal"))
  467. return 6;
  468. if (s.equals("Tzhaar-ket-em"))
  469. return 7;
  470.  
  471. if (s.equals("Unarmed") || i == -1)
  472. return 5;
  473. else
  474. // System.out.println("Item has no timer: " + s + ".");
  475. return 5;
  476. }
  477.  
  478. private final Player client;
  479.  
  480. public Equipment(Player client) {
  481. this.client = client;
  482. }
  483.  
  484. public void checkEquipmentLevel() {
  485. for (int i = 0; i < client.playerEquipment.length; i++) {
  486. final int j = client.playerEquipment[i];
  487. final int attackReq = EquipmentReq.attack(j);
  488. final int strenghtReq = EquipmentReq.strength(j);
  489. final int defenceReq = EquipmentReq.defence(j);
  490. final int magicReq = EquipmentReq.magic(j);
  491. final int rangedReq = EquipmentReq.ranged(j);
  492. if (attackReq > client
  493. .getLevelForXP(client.playerXP[PlayerConstants.ATTACK]))
  494. removeItem(client.playerEquipment[i], i);
  495. else if (strenghtReq > client
  496. .getLevelForXP(client.playerXP[PlayerConstants.STRENGTH]))
  497. removeItem(client.playerEquipment[i], i);
  498. else if (defenceReq > client
  499. .getLevelForXP(client.playerXP[PlayerConstants.DEFENCE]))
  500. removeItem(client.playerEquipment[i], i);
  501. else if (magicReq > client
  502. .getLevelForXP(client.playerXP[PlayerConstants.MAGIC]))
  503. removeItem(client.playerEquipment[i], i);
  504. else if (rangedReq > client
  505. .getLevelForXP(client.playerXP[PlayerConstants.RANGE_ATT]))
  506. removeItem(client.playerEquipment[i], i);
  507. }
  508. }
  509.  
  510. public void deleteEquipment(int id) {
  511. client.playerEquipment[id] = -1;
  512. client.playerEquipmentN[id] = 0;
  513. final GamePacketBuilder bldr = new GamePacketBuilder(34,
  514. Type.VARIABLE_SHORT);
  515. bldr.putShort(1688);
  516. bldr.put((byte) id);
  517. bldr.putShort(0);
  518. bldr.put((byte) 0);
  519. client.write(bldr.toPacket());
  520. client.getBonuses().calculateBonus();
  521. if (id == PlayerConstants.WEAPON)
  522. sendWeapon();
  523. client.isFullHelm = Item
  524. .isFullHelm(client.playerEquipment[PlayerConstants.HELM]);
  525. client.isFullMask = Item
  526. .isFullMask(client.playerEquipment[PlayerConstants.HELM]);
  527. client.isFullBody = Item
  528. .isPlate(client.playerEquipment[PlayerConstants.CHEST]);
  529. client.updateRequired = true;
  530. client.appearanceUpdateRequired = true;
  531. }
  532.  
  533. public void deleteRing() {
  534. setEquipment(-1, 0, PlayerConstants.RING);
  535. }
  536.  
  537. public boolean fullDharokEquipped() {
  538. return client.playerEquipment[PlayerConstants.HELM] == 4716
  539. && client.playerEquipment[PlayerConstants.CHEST] == 4720
  540. && client.playerEquipment[PlayerConstants.BOTTOMS] == 4722
  541. && client.playerEquipment[PlayerConstants.WEAPON] == 4718;
  542. }
  543.  
  544. public boolean fullGuthanEquipped() {
  545. return client.playerEquipment[PlayerConstants.HELM] == 4724
  546. && client.playerEquipment[PlayerConstants.CHEST] == 4728
  547. && client.playerEquipment[PlayerConstants.BOTTOMS] == 4730
  548. && client.playerEquipment[PlayerConstants.WEAPON] == 4726;
  549. }
  550.  
  551. public boolean fullKarilEquipped() {
  552. return client.playerEquipment[PlayerConstants.HELM] == 4732
  553. && client.playerEquipment[PlayerConstants.CHEST] == 4736
  554. && client.playerEquipment[PlayerConstants.BOTTOMS] == 4738
  555. && client.playerEquipment[PlayerConstants.WEAPON] == 4734;
  556. }
  557.  
  558. public boolean fullToragEquipped() {
  559. return client.playerEquipment[PlayerConstants.HELM] == 4745
  560. && client.playerEquipment[PlayerConstants.CHEST] == 4749
  561. && client.playerEquipment[PlayerConstants.BOTTOMS] == 4751
  562. && client.playerEquipment[PlayerConstants.WEAPON] == 4718;
  563. }
  564.  
  565. public int itemType(int item) {
  566. for (final int cape : Item.capes)
  567. if (item == cape)
  568. return PlayerConstants.CAPE;
  569. for (final int hat : Item.hats)
  570. if (item == hat
  571. || InstanceDistributor.getItemManager()
  572. .getItemDefinition(item).getName().contains("helm"))
  573. return PlayerConstants.HELM;
  574. for (final int boot : Item.boots)
  575. if (item == boot)
  576. return PlayerConstants.BOOTS;
  577. for (final int glove : Item.gloves)
  578. if (item == glove)
  579. return PlayerConstants.GLOVES;
  580. for (final int shield : Item.shields)
  581. if (item == shield)
  582. return PlayerConstants.SHIELD;
  583. for (final int amulet : Item.amulets)
  584. if (item == amulet)
  585. return PlayerConstants.AMULET;
  586. for (final int arrow : Item.arrows)
  587. if (item == arrow)
  588. return PlayerConstants.ARROWS;
  589. for (final int ring : Item.rings)
  590. if (item == ring)
  591. return PlayerConstants.RING;
  592. for (final int element : Item.body)
  593. if (item == element
  594. || InstanceDistributor.getItemManager()
  595. .getItemDefinition(item).getName()
  596. .contains("platebody"))
  597. return PlayerConstants.CHEST;
  598. for (final int leg : Item.legs)
  599. if (item == leg
  600. || InstanceDistributor.getItemManager()
  601. .getItemDefinition(item).getName().contains("legs"))
  602. return PlayerConstants.BOTTOMS;
  603. // Default
  604. return PlayerConstants.WEAPON;
  605. }
  606.  
  607. public void removeItem(int wearID, int slot) {
  608. if (client.hitpoints == 0 && client.isBusy())
  609. return;
  610.  
  611. if (client.getCastleWarsTeam() != null
  612. || Areas.isInCastleWarsLobby(client.getCoordinates())) {
  613. if (slot == Equipment.SLOT_HEAD || slot == Equipment.SLOT_CAPE) {
  614. client.getActionSender().sendMessage(
  615. "You cannot remove your team colors.");
  616. return;
  617. }
  618. if (!Areas.isInCastleWarsLobby(client.getCoordinates())) {
  619. final int weaponId = client.playerEquipment[PlayerConstants.WEAPON];
  620. if (weaponId == 4037 || weaponId == 4039) {
  621. client.getActionSender().sendMessage(
  622. "You cannot unequip the standard.");
  623. return;
  624. }
  625. }
  626. }
  627.  
  628. // CombatEngine.resetAttack(client, false);
  629.  
  630. if (client.getActionSender().addItem(client.playerEquipment[slot],
  631. client.playerEquipmentN[slot])) {
  632. client.playerEquipment[slot] = -1;
  633. client.playerEquipmentN[slot] = 0;
  634. final GamePacketBuilder bldr = new GamePacketBuilder(34,
  635. Type.VARIABLE_SHORT);
  636.  
  637. bldr.putShort(1688);
  638. bldr.put((byte) slot);
  639. bldr.putShort(0);
  640. bldr.put((byte) 0);
  641. client.write(bldr.toPacket());
  642. client.updateRequired = true;
  643. client.appearanceUpdateRequired = true;
  644.  
  645. client.getBonuses().calculateBonus();
  646.  
  647. if (slot == PlayerConstants.WEAPON) {
  648. Specials.turnOff(client);
  649. AutoCast.turnOff(client);
  650. CombatMode.setCombatMode(client, client.combatMode);
  651. sendWeapon();
  652. }
  653. setWeaponEmotes();
  654.  
  655. client.setStyleForWep(client);
  656. if (wearID == 20135 || wearID == 20139 || wearID == 20143
  657. || wearID == 20147 || wearID == 20159 || wearID == 20151
  658. || wearID == 20163 || wearID == 20155 || wearID == 20147)
  659. if (client.hitpoints > client.calculateMaxHP())
  660. client.restoreHP();
  661.  
  662. }
  663. if (slot == PlayerConstants.RING)
  664. client.setExpMode();
  665. client.isFullHelm = Item
  666. .isFullHelm(client.playerEquipment[PlayerConstants.HELM]);
  667. client.isFullMask = Item
  668. .isFullMask(client.playerEquipment[PlayerConstants.HELM]);
  669. client.isFullBody = Item
  670. .isPlate(client.playerEquipment[PlayerConstants.CHEST]);
  671. }
  672.  
  673. private void sendSpecialBar() {
  674. final int id = client.playerEquipment[PlayerConstants.WEAPON];
  675. switch (id) {
  676. case 20171: // Zaryte bow.
  677. client.getActionSender().sendFrame171(7549, 0);
  678. break;
  679. case 13899:
  680. case 13901:
  681. case 15241:
  682. case 13879: // m javalin
  683. case 13880: // m javalin
  684. case 13881: // m javalin
  685. case 13882: // m javalin
  686. case 13883: // m trownaxe
  687. client.getActionSender().sendFrame171(7599, 0);
  688. break;
  689.  
  690. case 4151: // Whip
  691. client.getActionSender().sendFrame171(12323, 0);
  692. break;
  693.  
  694. case 3204: // Dragon Hally
  695. client.getActionSender().sendFrame171(8493, 0);
  696. break;
  697.  
  698. case 861: // Magic Bow
  699. case 6724: // Seercull
  700. case 859: // magic longbow
  701. case 11235:
  702. client.getActionSender().sendFrame171(7549, 0);
  703. break;
  704.  
  705. case 7158: // Dragon 2h
  706. case 1305: // Dragon Long
  707. case 4587: // Dragon Scimmy
  708. case 11694:// ags
  709. case 10887:
  710. case 14484:
  711. case 19784:
  712. case 11696: // bgs
  713. case 11698: // sgs
  714. case 11700: // zgs
  715.  
  716. case 14632:
  717. case 11730: // ss
  718. case 13902:
  719. case 13904:
  720. case 15486:
  721. case 22207:
  722. case 22211:
  723. case 22213:
  724.  
  725. client.getActionSender().sendFrame171(7599, 0);
  726. break;
  727.  
  728. case 6739: // Dragon hatchet
  729. case 1377: // Dragon Battle
  730. case 15259: // dragon pickaxe
  731. client.getActionSender().sendFrame171(7499, 0);
  732. break;
  733.  
  734. case 5680:// d dagger (p+)
  735. case 1231: // d dagger (p)
  736. case 1215: // d dagger
  737. case 8872: // Bone Dagger
  738. case 5698: // Dragon Dagger
  739. case 8878:
  740. client.getActionSender().sendFrame171(7574, 0);
  741. break;
  742.  
  743. case 1434: // Dragon Mace
  744.  
  745. client.getActionSender().sendFrame171(7624, 0);
  746. break;
  747.  
  748. case 4153: // Granite Maul
  749. case 14679:
  750. client.getActionSender().sendFrame171(7474, 0);
  751. break;
  752.  
  753. case 1249: // Dragon Spear
  754. case 1263: // dragon spear (p)
  755. case 11716: // zamorakian spear
  756. case 13905: // vesta spear
  757. case 13907:
  758. case 5730:
  759.  
  760. client.getActionSender().sendFrame171(7674, 0);
  761. break;
  762.  
  763. default:
  764. client.getActionSender().sendFrame171(12323, 1);
  765. client.getActionSender().sendFrame171(8493, 1);
  766. client.getActionSender().sendFrame171(7549, 1);
  767. client.getActionSender().sendFrame171(7599, 1);
  768. client.getActionSender().sendFrame171(7499, 1);
  769. client.getActionSender().sendFrame171(7574, 1);
  770. client.getActionSender().sendFrame171(7624, 1);
  771. client.getActionSender().sendFrame171(7474, 1);
  772. client.getActionSender().sendFrame171(7674, 1);
  773. break;
  774. }
  775. }
  776.  
  777. public void sendWeapon() {
  778. final int weapon = client.playerEquipment[PlayerConstants.WEAPON];
  779. String s = InstanceDistributor.getItemManager()
  780. .getItemDefinition(weapon).getName();
  781. final int id = InstanceDistributor.getItemManager()
  782. .getItemDefinition(weapon).getId();
  783. if (id <= 1)
  784. s = "Unarmed";
  785. if (s.equals("Unarmed")) {
  786. client.getActionSender().sendSidebar(0, 5855);
  787. client.getActionSender().sendString(s, 5857);
  788. } else if (s.endsWith("whip")) {
  789. client.getActionSender().sendSidebar(0, 12290);
  790. client.getActionSender().sendFrame246(12291, 200, weapon);
  791. client.getActionSender().sendString(s, 12293);
  792. } else if (s.endsWith("Scythe")) {
  793. client.getActionSender().sendSidebar(0, 776);
  794. client.getActionSender().sendFrame246(12291, 200, weapon);
  795. client.getActionSender().sendString(s, 778);
  796. } else if (s.endsWith("bow") || s.startsWith("Crystal bow")
  797. || s.startsWith("Seercull") || id == 20171) {
  798. client.getActionSender().sendSidebar(0, 1764);
  799. client.getActionSender().sendFrame246(1765, 200, weapon);
  800. client.getActionSender().sendString(s, 1767);
  801. } else if (s.startsWith("Staff") && id != 15486 && id != 22207
  802. && id != 22211 && id != 22213 || s.endsWith("staff")
  803. && id != 15486 || s.endsWith("wand")) {
  804. client.getActionSender().sendSidebar(0, 328);
  805. client.getActionSender().sendFrame246(329, 200, weapon);
  806. client.getActionSender().sendString(s, 331);
  807. } else if (s.endsWith("dart") || s.endsWith("knife")
  808. || s.endsWith("javelin") && id != 13879
  809. || s.contains("thrownaxe") || s.contains("chinchompa")
  810. || s.contains("Chinchompa")) { // Of dqe string eindigt met
  811. // thrownaxe en het ID is anders
  812. // dan 13879, de andere worden
  813. // niet meegenomen:P, maar ik
  814. // had net
  815. client.getActionSender().sendSidebar(0, 4446);
  816. client.getActionSender().sendFrame246(4447, 200, weapon);
  817. client.getActionSender().sendString(s, 4449);
  818. } else if (s.contains("dagger")) {
  819. client.getActionSender().sendSidebar(0, 2276);
  820. client.getActionSender().sendFrame246(2277, 200, weapon);
  821. client.getActionSender().sendString(s, 2279);
  822. } else if (s.endsWith("pickaxe") && id != 15259) {
  823. client.getActionSender().sendSidebar(0, 5570);
  824. client.getActionSender().sendFrame246(5571, 200, weapon);
  825. client.getActionSender().sendString(s, 5573);
  826. } else if (s.endsWith("axe") || s.endsWith("battleaxe")) {
  827. client.getActionSender().sendSidebar(0, 1698);
  828. client.getActionSender().sendFrame246(1699, 200, weapon);
  829. client.getActionSender().sendString(s, 1701);
  830. } else if (s.endsWith("halberd")) {
  831. client.getActionSender().sendSidebar(0, 8460);
  832. client.getActionSender().sendFrame246(8461, 200, weapon);
  833. client.getActionSender().sendString(s, 8463);
  834. } else if (s.contains("spear")) {
  835. client.getActionSender().sendSidebar(0, 4679);
  836. client.getActionSender().sendFrame246(4680, 200, weapon);
  837. client.getActionSender().sendString(s, 4682);
  838. } else if (s.contains("maul")) {
  839. client.getActionSender().sendSidebar(0, 425);
  840. client.getActionSender().sendFrame246(426, 200, weapon);
  841. client.getActionSender().sendString(s, 428);
  842. } else if (s.endsWith("mace") && id != 14679) {
  843. client.getActionSender().sendSidebar(0, 3796);
  844. client.getActionSender().sendFrame246(3797, 200, weapon);
  845. client.getActionSender().sendString(s, 3799);
  846.  
  847. } else if (s.endsWith("spear")) {
  848. client.getActionSender().sendSidebar(0, 7762);
  849. client.getActionSender().sendFrame246(7763, 200, weapon);
  850. client.getActionSender().sendString(s, 7764);
  851. } else {
  852. client.getActionSender().sendSidebar(0, 2423);
  853. client.getActionSender().sendFrame246(2424, 200, weapon);
  854. client.getActionSender().sendString(s, 2426);
  855. }
  856. sendSpecialBar();
  857.  
  858. setWeaponEmotes();
  859.  
  860. client.getBonuses().calculateBonus();
  861. }
  862.  
  863. public void setEquipment(int wearID, int amount, int targetSlot) {
  864. final GamePacketBuilder bldr = new GamePacketBuilder(34,
  865. Type.VARIABLE_SHORT);
  866. bldr.putShort(1688);
  867. bldr.put((byte) targetSlot);
  868. bldr.putShort(wearID + 1);
  869. if (amount > 254) {
  870. bldr.put((byte) 255);
  871. bldr.putInt(amount);
  872. } else
  873. bldr.put((byte) amount); // amount
  874. client.write(bldr.toPacket());
  875.  
  876. client.playerEquipment[targetSlot] = wearID;
  877. client.playerEquipmentN[targetSlot] = amount;
  878. client.updateRequired = true;
  879. client.appearanceUpdateRequired = true;
  880. }
  881.  
  882. public void setWeaponEmotes() {
  883. client.standEmote = getStandEmote(client);
  884. client.walkEmote = getWalkEmote(client);
  885. client.runEmote = getRunEmote(client);
  886. }
  887.  
  888. public boolean twoHanded(int i) {
  889. if (InstanceDistributor.getItemManager().getItemDefinition(i) == null)
  890. return false;
  891. final String s = InstanceDistributor.getItemManager()
  892. .getItemDefinition(i).getName();
  893. final int j = InstanceDistributor.getItemManager().getItemDefinition(i)
  894. .getId();
  895. s.replaceAll("_", " ");
  896. s.trim();
  897.  
  898. if (j == 13902 || j == 13926)
  899. return false;
  900.  
  901. if (s.contains("2h"))
  902. return true;
  903. if (s.contains("zaryte") || i == 20171)
  904. return true;
  905. if (s.contains("cannon"))
  906. return true;
  907. if (s.contains("barrlechest"))
  908. return true;
  909. if (s.contains("spear"))
  910. return true;
  911. if (s.contains("hammers"))
  912. return true;
  913. if (s.contains("flail"))
  914. return true;
  915. if (s.contains("maul"))
  916. return true;
  917. if (s.contains("claws"))
  918. return true;
  919. if (s.contains("great"))
  920. return true;
  921. if (s.endsWith("longbow"))
  922. return true;
  923. if (s.equals("Seercull"))
  924. return true;
  925. if (s.endsWith("shortbow"))
  926. return true;
  927. if (s.endsWith("Longbow"))
  928. return true;
  929. if (s.endsWith("Shortbow"))
  930. return true;
  931. if (s.endsWith("bow") && !s.startsWith("Rune")
  932. && !s.startsWith("Chaotic"))
  933. return true;
  934. if (s.endsWith("godsword"))
  935. return true;
  936. if (s.endsWith("Dark bow"))
  937. return true;
  938. if (s.endsWith("halberd"))
  939. return true;
  940. if (s.equals("Granite maul"))
  941. return true;
  942. if (s.equals("Karils crossbow"))
  943. return true;
  944. if (s.equals("Torags hammers"))
  945. return true;
  946. if (s.equals("Veracs flail"))
  947. return true;
  948. if (s.equals("Dharoks greataxe"))
  949. return true;
  950. if (s.equals("Guthans warspear"))
  951. return true;
  952. if (s.equals("Saradomin sword"))
  953. return true;
  954. switch (j) {
  955. case 13902:
  956. return true;
  957. case 10887:
  958. case 13929:
  959. return true;
  960.  
  961. }
  962. return s.equals("Tzhaar-ket-om");
  963.  
  964. }
  965.  
  966. public boolean wearingRecoil() {
  967. return client.playerEquipment[PlayerConstants.RING] == 2550;
  968. }
  969.  
  970. public void wearItem(int wearID, int slot) {
  971. if (client.hitpoints == 0 && client.isBusy())
  972. return;
  973. int j = itemType(wearID);
  974. if (wearID != 4153)
  975. CombatEngine.resetAttack(client, false);
  976. if (wearID > 15085 && wearID < 15102)
  977. if (client.isInClan()) {
  978. Dicing.getInstance().useDice(client, wearID, true, 0);
  979. return;
  980. } else {
  981. client.getActionSender().sendMessage(
  982. "You must be in a clan chat to do that.");
  983. return;
  984. }
  985. if (wearID == 20771)
  986. if (client.completionist() == false) {
  987. client.getActionSender()
  988. .sendMessage(
  989. "You need to have mastered every skill and completed every quest to equip this item.");
  990. return;
  991. }
  992. final int attackReq = EquipmentReq.attack(wearID);
  993. final int strenghtReq = EquipmentReq.strength(wearID);
  994. final int defenceReq = EquipmentReq.defence(wearID);
  995. final int magicReq = EquipmentReq.magic(wearID);
  996. final int rangedReq = EquipmentReq.ranged(wearID);
  997. final int prayerReq = EquipmentReq.prayer(wearID);
  998. final int hitpointsReq = EquipmentReq.hitpoints(wearID);
  999. int slayerReq = 0;
  1000. if (wearID == 21371)
  1001. slayerReq = 80;
  1002. if (attackReq > client
  1003. .getLevelForXP(client.playerXP[PlayerConstants.ATTACK])) {
  1004. client.getActionSender().sendMessage(
  1005. new StringBuilder().append("You need ").append(attackReq)
  1006. .append(" Attack to equip this item.").toString());
  1007. return;
  1008. }
  1009. if (strenghtReq > client
  1010. .getLevelForXP(client.playerXP[PlayerConstants.STRENGTH])) {
  1011. client.getActionSender()
  1012. .sendMessage(
  1013. new StringBuilder().append("You need ")
  1014. .append(strenghtReq)
  1015. .append(" Strength to equip this item.")
  1016. .toString());
  1017. return;
  1018. }
  1019. if (defenceReq > client
  1020. .getLevelForXP(client.playerXP[PlayerConstants.DEFENCE])) {
  1021. client.getActionSender().sendMessage(
  1022. new StringBuilder().append("You need ").append(defenceReq)
  1023. .append(" Defence to equip this item.").toString());
  1024. return;
  1025. }
  1026. if (magicReq > client
  1027. .getLevelForXP(client.playerXP[PlayerConstants.MAGIC])) {
  1028. client.getActionSender().sendMessage(
  1029. new StringBuilder().append("You need ").append(magicReq)
  1030. .append(" Magic to equip this item.").toString());
  1031. return;
  1032. }
  1033. if (rangedReq > client
  1034. .getLevelForXP(client.playerXP[PlayerConstants.RANGE_ATT])) {
  1035. client.getActionSender().sendMessage(
  1036. new StringBuilder().append("You need ").append(rangedReq)
  1037. .append(" Ranged to equip this item.").toString());
  1038. return;
  1039. }
  1040. if (prayerReq > client
  1041. .getLevelForXP(client.playerXP[PlayerConstants.PRAYER])) {
  1042. client.getActionSender().sendMessage(
  1043. new StringBuilder().append("You need ").append(prayerReq)
  1044. .append(" Prayer to equip this item.").toString());
  1045. return;
  1046. }
  1047. if (hitpointsReq > client
  1048. .getLevelForXP(client.playerXP[PlayerConstants.HITPOINTS])) {
  1049. client.getActionSender().sendMessage(
  1050. new StringBuilder().append("You need ")
  1051. .append(hitpointsReq)
  1052. .append(" Hitpoints to equip this item.")
  1053. .toString());
  1054. return;
  1055. }
  1056.  
  1057. if (slayerReq > client
  1058. .getLevelForXP(client.playerXP[PlayerConstants.SLAYER])) {
  1059. client.getActionSender().sendMessage(
  1060. "You need 80 slayer to wear this item.");
  1061. return;
  1062. }
  1063. if (twoHanded(wearID) && client.getActionAssistant().freeSlots() < 1
  1064. && client.playerEquipment[PlayerConstants.SHIELD] > 0) {
  1065. client.getActionSender().sendMessage(
  1066. "Not enough space in your inventory.");
  1067. return;
  1068. }
  1069.  
  1070. if (slot > -1 && slot < 28 && client.playerItems[slot] == wearID + 1) {
  1071. client.getActionSender().sendItemReset(3214);
  1072. int k3 = client.playerItemsN[slot];
  1073. if (k3 < 1)
  1074. return;
  1075.  
  1076. if (client.getCastleWarsTeam() != null
  1077. || Areas.isInCastleWarsLobby(client.getCoordinates())) {
  1078. if (j == Equipment.SLOT_HEAD || j == Equipment.SLOT_CAPE) {
  1079. client.getActionSender().sendMessage(
  1080. "You cannot remove your team colors.");
  1081. return;
  1082. }
  1083. if (!Areas.isInCastleWarsLobby(client.getCoordinates())) {
  1084. final int weaponId = client.playerEquipment[PlayerConstants.WEAPON];
  1085. if (weaponId == 4037 || weaponId == 4039) {
  1086. client.getActionSender().sendMessage(
  1087. "You cannot unequip the standard.");
  1088. return;
  1089. }
  1090. }
  1091. }
  1092. if (PlayerManager.getDuelOpponent(client) != null)
  1093. if (!DuelArena.getInstance().checkEquipment(wearID, j, client)) {
  1094. client.getActionSender().sendMessage(
  1095. "You are not permitted to wear this item!");
  1096. return;
  1097. }
  1098.  
  1099. if (slot >= 0 && wearID >= 0) {
  1100. client.getActionAssistant().deleteItem(wearID, slot, k3);
  1101. if (client.playerEquipment[j] != wearID
  1102. && client.playerEquipment[j] >= 0) {
  1103. client.getActionSender().sendInventoryItem(
  1104. client.playerEquipment[j],
  1105. client.playerEquipmentN[j], slot);
  1106. client.getActionSender().sendItemReset(3214);
  1107. } else if (Item.itemStackable[wearID]
  1108. && client.playerEquipment[j] == wearID)
  1109. k3 = client.playerEquipmentN[j] + k3;
  1110. else if (client.playerEquipment[j] >= 0) {
  1111. client.getActionSender().sendInventoryItem(
  1112. client.playerEquipment[j],
  1113. client.playerEquipmentN[j], slot);
  1114. client.getActionSender().sendItemReset(3214);
  1115. }
  1116. }
  1117. setEquipment(wearID, k3, j);
  1118. client.playerEquipment[j] = wearID;
  1119. client.playerEquipmentN[j] = k3;
  1120.  
  1121. if (j == PlayerConstants.WEAPON && twoHanded(wearID))
  1122. removeItem(client.playerEquipment[PlayerConstants.SHIELD],
  1123. PlayerConstants.SHIELD);
  1124.  
  1125. if (j == PlayerConstants.SHIELD
  1126. && twoHanded(client.playerEquipment[PlayerConstants.WEAPON]))
  1127. removeItem(client.playerEquipment[PlayerConstants.WEAPON],
  1128. PlayerConstants.WEAPON);
  1129.  
  1130. if (j == PlayerConstants.WEAPON) {
  1131. Specials.turnOff(client);
  1132. AutoCast.turnOff(client);
  1133. sendWeapon();
  1134. client.combatMode = CombatMode.setCombatMode(client,
  1135. client.combatMode);
  1136. }
  1137. if (j == PlayerConstants.RING)
  1138. client.setExpMode();
  1139. switch (wearID) {
  1140. case 14641:
  1141. case 15434:
  1142. case 15432:
  1143. case 14642:
  1144. case 14645:
  1145. case 15433:
  1146. case 15435:
  1147. case 15474:
  1148. j = SLOT_CAPE;
  1149. break;
  1150. case 15815:
  1151. case 17361:
  1152. case 15818:
  1153. case 17355:
  1154. slot = SLOT_SHIELD;
  1155. break;
  1156. case 15924:
  1157. case 16711:
  1158. case 15902:
  1159. case 16755:
  1160. case 15921:
  1161. case 16705:
  1162. case 16056:
  1163. case 17061:
  1164. case 16067:
  1165. j = SLOT_HEAD;
  1166. break;
  1167. case 15935:
  1168. case 16206:
  1169. case 16667:
  1170. case 16689:
  1171. case 15807:
  1172. case 16865:
  1173. case 15932:
  1174. case 16203:
  1175. case 16661:
  1176. case 16683:
  1177. case 17339:
  1178. j = SLOT_LEGS;
  1179. break;
  1180. case 15954:
  1181. case 15965:
  1182. case 15976:
  1183. case 15987:
  1184. case 16462:
  1185. case 16517:
  1186. case 16572:
  1187. case 16627:
  1188. case 15957:
  1189. case 15979:
  1190. case 15990:
  1191. case 16477:
  1192. case 16532:
  1193. case 16587:
  1194. case 16642:
  1195. j = SLOT_ARROWS;
  1196. break;
  1197. case 15946:
  1198. case 16293:
  1199. case 16195:
  1200. case 17171:
  1201. case 15943:
  1202. case 16287:
  1203. j = SLOT_HANDS;
  1204. break;
  1205. case 16023:
  1206. case 16090:
  1207. case 16733:
  1208. case 17259:
  1209. case 15847:
  1210. case 17237:
  1211. case 16020:
  1212. case 16087:
  1213. case 16727:
  1214. case 17253:
  1215. case 16078:
  1216. case 17193:
  1217. j = SLOT_CHEST;
  1218. break;
  1219. case 16272:
  1220. case 16359:
  1221. case 15796:
  1222. case 16931:
  1223. case 16269:
  1224. case 16353:
  1225. case 16012:
  1226. case 16115:
  1227. case 17215:
  1228. case 17317:
  1229. j = SLOT_FEET;
  1230. break;
  1231. }
  1232.  
  1233. if (client.hitpoints > client.calculateMaxHP())
  1234. client.restoreHP();
  1235. client.isFullHelm = Item
  1236. .isFullHelm(client.playerEquipment[PlayerConstants.HELM]);
  1237. client.isFullMask = Item
  1238. .isFullMask(client.playerEquipment[PlayerConstants.HELM]);
  1239. client.isFullBody = Item
  1240. .isPlate(client.playerEquipment[PlayerConstants.CHEST]);
  1241. client.getBonuses().calculateBonus();
  1242. client.updateRequired = true;
  1243. client.appearanceUpdateRequired = true;
  1244. client.setStyleForWep(client);
  1245. }
  1246. }
  1247.  
  1248. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement