Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.45 KB | None | 0 0
  1. package com.rs.cache.loaders;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.HashMap;
  6. import java.util.List;
  7.  
  8. import com.alex.io.OutputStream;
  9. import com.alex.utils.Constants;
  10. import com.rs.cache.Cache;
  11. import com.rs.game.item.Item;
  12. import com.rs.game.player.Equipment;
  13. import com.rs.game.player.Skills;
  14. import com.rs.io.InputStream;
  15. import com.rs.utils.ItemExamines;
  16. import com.rs.utils.Utils;
  17.  
  18. @SuppressWarnings("unused")
  19. public final class ItemDefinitions {//old
  20.  
  21. public static final ItemDefinitions[] itemsDefinitions;
  22.  
  23. static { // that's why this is here
  24. itemsDefinitions = new ItemDefinitions[Utils.getItemDefinitionsSize()];
  25. }
  26.  
  27. public int id;
  28. public boolean loaded;
  29.  
  30. public int modelId;
  31. public String name;
  32.  
  33. // model size information
  34. public int modelZoom;
  35. public int modelRotation1;
  36. public int modelRotation2;
  37. public int modelOffset1;
  38. public int modelOffset2;
  39.  
  40. // extra information
  41. public int stackable;
  42. public int value;
  43. public boolean membersOnly;
  44.  
  45. // wearing model information
  46. public int maleEquip1;
  47. public int femaleEquip1;
  48. public int maleEquip2;
  49. public int femaleEquip2;
  50.  
  51. // options
  52. public String[] groundOptions;
  53. public String[] inventoryOptions;
  54.  
  55. // model information
  56. public int[] originalModelColors;
  57. public int[] modifiedModelColors;
  58. public short[] originalTextureColors;
  59. public short[] modifiedTextureColors;
  60. public byte[] unknownArray1;
  61. public byte[] unknownArray3;
  62. public int[] unknownArray2;
  63. // extra information, not used for newer items
  64. public boolean unnoted;
  65.  
  66. public int maleEquipModelId3;
  67. public int femaleEquipModelId3;
  68. public int unknownInt1;
  69. public int unknownInt2;
  70. public int unknownInt3;
  71. public int unknownInt4;
  72. public int unknownInt5;
  73. public int unknownInt6;
  74. public int certId;
  75. public int certTemplateId;
  76. public int[] stackIds;
  77. public int[] stackAmounts;
  78. public int unknownInt7;
  79. public int unknownInt8;
  80. public int unknownInt9;
  81. public int unknownInt10;
  82. public int unknownInt11;
  83. public int teamId;
  84. public int lendId;
  85. public int lendTemplateId;
  86. public int unknownInt12;
  87. public int unknownInt13;
  88. public int unknownInt14;
  89. public int unknownInt15;
  90. public int unknownInt16;
  91. public int unknownInt17;
  92. public int unknownInt18;
  93. public int unknownInt19;
  94. public int unknownInt20;
  95. public int unknownInt21;
  96. public int unknownInt22;
  97. public int unknownInt23;
  98. public int equipSlot;
  99. public int equipType;
  100. public int equipType2;
  101.  
  102. // extra added
  103. public boolean noted;
  104. public boolean lended;
  105.  
  106. public HashMap<Integer, Object> clientScriptData;
  107. public HashMap<Integer, Integer> itemRequiriments;
  108. public int[] unknownArray5;
  109. public int[] unknownArray4;
  110. public byte[] unknownArray6;
  111.  
  112. public byte[] encode() {
  113. OutputStream stream = new OutputStream();
  114.  
  115. stream.writeByte(1);
  116. stream.writeBigSmart(modelId);
  117.  
  118. if (!name.equals("null") && certTemplateId == -1) {
  119. stream.writeByte(2);
  120. stream.writeString(name);
  121. }
  122.  
  123. if (modelZoom != 2000) {
  124. stream.writeByte(4);
  125. stream.writeShort(modelZoom);
  126. }
  127.  
  128. if (modelRotation1 != 0) {
  129. stream.writeByte(5);
  130. stream.writeShort(modelRotation1);
  131. }
  132.  
  133. if (modelRotation2 != 0) {
  134. stream.writeByte(6);
  135. stream.writeShort(modelRotation2);
  136. }
  137.  
  138. if (modelOffset1 != 0) {
  139. stream.writeByte(7);
  140. int value = modelOffset1 >>= 0;
  141. if (value < 0) {
  142. value += 65536;
  143. }
  144. stream.writeShort(value);
  145. }
  146.  
  147. if (modelOffset2 != 0) {
  148. stream.writeByte(8);
  149. int value = modelOffset2 >>= 0;
  150. if (value < 0) {
  151. value += 65536;
  152. }
  153. stream.writeShort(value);
  154. }
  155.  
  156. if (stackable == 1 && certTemplateId == -1) {
  157. stream.writeByte(11);
  158. }
  159.  
  160. if (value != 1 && lendTemplateId == -1) {
  161. stream.writeByte(12);
  162. stream.writeInt(value);
  163. }
  164.  
  165. if (equipSlot != -1) {
  166. stream.writeByte(13);
  167. stream.writeByte(equipSlot);
  168. }
  169.  
  170. if (equipType != -1) {
  171. stream.writeByte(14);
  172. stream.writeByte(equipType);
  173. }
  174.  
  175. if (membersOnly && certTemplateId == -1) {
  176. stream.writeByte(16);
  177. }
  178.  
  179. if (maleEquip1 != -1) {
  180. stream.writeByte(23);
  181. stream.writeBigSmart(maleEquip1);
  182. }
  183.  
  184. if (maleEquip2 != -1) {
  185. stream.writeByte(24);
  186. stream.writeBigSmart(maleEquip2);
  187. }
  188.  
  189. if (femaleEquip1 != -1) {
  190. stream.writeByte(25);
  191. stream.writeBigSmart(femaleEquip1);
  192. }
  193.  
  194. if (femaleEquip2 != -1) {
  195. stream.writeByte(26);
  196. stream.writeBigSmart(femaleEquip2);
  197. }
  198.  
  199. for (int index = 0; index < groundOptions.length; index++) {
  200. if (groundOptions[index] == null
  201. || (index == 2 && groundOptions[index].equals("take"))) {
  202. continue;
  203. }
  204. stream.writeByte(30 + index);
  205. stream.writeString(groundOptions[index]);
  206. }
  207.  
  208. for (int index = 0; index < inventoryOptions.length; index++) {
  209. if (inventoryOptions[index] == null
  210. || (index == 4 && inventoryOptions[index].equals("drop"))) {
  211. continue;
  212. }
  213. stream.writeByte(35 + index);
  214. stream.writeString(inventoryOptions[index]);
  215. }
  216.  
  217. if (originalModelColors != null && modifiedModelColors != null) {
  218. stream.writeByte(40);
  219. stream.writeByte(originalModelColors.length);
  220. for (int index = 0; index < originalModelColors.length; index++) {
  221. stream.writeShort(originalModelColors[index]);
  222. stream.writeShort(modifiedModelColors[index]);
  223. }
  224. }
  225.  
  226. if (originalTextureColors != null && modifiedTextureColors != null) {
  227. stream.writeByte(41);
  228. stream.writeByte(originalTextureColors.length);
  229. for (int index = 0; index < originalTextureColors.length; index++) {
  230. stream.writeShort(originalTextureColors[index]);
  231. stream.writeShort(modifiedTextureColors[index]);
  232. }
  233. }
  234.  
  235. if (unknownArray1 != null) {
  236. stream.writeByte(42);
  237. stream.writeByte(unknownArray1.length);
  238. for (int index = 0; index < unknownArray1.length; index++) {
  239. stream.writeByte(unknownArray1[index]);
  240. }
  241. }
  242.  
  243. // if (hasNameColor) {
  244. // stream.writeByte(43);
  245. // stream.writeInt(nameColor);
  246. // }
  247.  
  248. if (unnoted) {
  249. stream.writeByte(65);
  250. }
  251.  
  252. if (maleEquipModelId3 != -1) {
  253. stream.writeByte(78);
  254. stream.writeBigSmart(maleEquipModelId3);
  255. }
  256.  
  257. if (femaleEquipModelId3 != -1) {
  258. stream.writeByte(79);
  259. stream.writeBigSmart(femaleEquipModelId3);
  260. }
  261.  
  262. if (unknownInt1 != 0) {
  263. stream.writeByte(90);
  264. stream.writeBigSmart(unknownInt1);
  265. }
  266. if (unknownInt2 != 0) {
  267. stream.writeByte(91);
  268. stream.writeBigSmart(unknownInt2);
  269. }
  270. if (unknownInt3 != 0) {
  271. stream.writeByte(92);
  272. stream.writeBigSmart(unknownInt3);
  273. }
  274. if (unknownInt4 != 0) {
  275. stream.writeByte(93);
  276. stream.writeBigSmart(unknownInt4);
  277. }
  278. if (unknownInt5 != 0) {
  279. stream.writeByte(95);
  280. stream.writeBigSmart(unknownInt5);
  281. }
  282. if (unknownInt6 != 0) {
  283. stream.writeByte(96);
  284. stream.writeBigSmart(unknownInt6);
  285. }
  286.  
  287. if (certId != -1) {
  288. stream.writeByte(97);
  289. stream.writeShort(certId);
  290. }
  291.  
  292. if (certTemplateId != -1) {
  293. stream.writeByte(98);
  294. stream.writeShort(certTemplateId);
  295. }
  296.  
  297. if (stackIds != null && stackAmounts != null) {
  298. for (int index = 0; index < stackIds.length; index++) {
  299. if (stackIds[index] == 0 && stackAmounts[index] == 0) {
  300. continue;
  301. }
  302. stream.writeByte(100 + index);
  303. stream.writeShort(stackIds[index]);
  304. stream.writeShort(stackAmounts[index]);
  305. }
  306. }
  307.  
  308. if (unknownInt7 != 128) {
  309. stream.writeByte(110);
  310. stream.writeShort(unknownInt7);
  311. }
  312. if (unknownInt8 != 128) {
  313. stream.writeByte(111);
  314. stream.writeShort(unknownInt8);
  315. }
  316. if (unknownInt9 != 128) {
  317. stream.writeByte(112);
  318. stream.writeShort(unknownInt9);
  319. }
  320. if (unknownInt10 != 0) {
  321. stream.writeByte(113);
  322. stream.writeByte(unknownInt10);
  323. }
  324. if (unknownInt11 != 0) {
  325. stream.writeByte(114);
  326. stream.writeByte(unknownInt11);
  327. }
  328.  
  329. if (teamId != 0) {
  330. stream.writeByte(115);
  331. stream.writeByte(teamId);
  332. }
  333.  
  334. if (lendId != -1) {
  335. stream.writeByte(121);
  336. stream.writeShort(lendId);
  337. }
  338.  
  339. if (lendTemplateId != -1) {
  340. stream.writeByte(122);
  341. stream.writeShort(lendTemplateId);
  342. }
  343. if (unknownInt12 != 0 && unknownInt13 != 0 && unknownInt14 != 0) {
  344. stream.writeByte(125);
  345. stream.writeByte(unknownInt12);
  346. stream.writeByte(unknownInt13);
  347. stream.writeByte(unknownInt14);
  348. }
  349. if (unknownInt15 != 0 && unknownInt16 != 0 && unknownInt17 != 0) {
  350. stream.writeByte(126);
  351. stream.writeByte(unknownInt15);
  352. stream.writeByte(unknownInt16);
  353. stream.writeByte(unknownInt17);
  354. }
  355. if (unknownInt18 != 0 && unknownInt19 != 0) {
  356. stream.writeByte(127);
  357. stream.writeByte(unknownInt18);
  358. stream.writeShort(unknownInt19);
  359. }
  360. if (unknownInt20 != 0 && unknownInt21 != 0) {
  361. stream.writeByte(128);
  362. stream.writeByte(unknownInt20);
  363. stream.writeShort(unknownInt21);
  364. }
  365. if (unknownInt20 != 0 && unknownInt21 != 0) {
  366. stream.writeByte(129);
  367. stream.writeByte(unknownInt20);
  368. stream.writeShort(unknownInt21);
  369. }
  370. if (unknownInt22 != 0 && unknownInt23 != 0) {
  371. stream.writeByte(130);
  372. stream.writeByte(unknownInt22);
  373. stream.writeShort(unknownInt23);
  374. }
  375.  
  376. if (unknownArray2 != null) {
  377. stream.writeByte(132);
  378. stream.writeByte(unknownArray2.length);
  379. for (int index = 0; index < unknownArray2.length; index++) {
  380. stream.writeShort(unknownArray2[index]);
  381. }
  382. }
  383.  
  384. // if (anInt7938 != 0) {
  385. // stream.writeByte(134);
  386. // stream.writeByte(anInt7938);
  387. // }
  388. // if (bindId != -1) {
  389. // stream.writeByte(139);
  390. // stream.writeShort(bindLink);
  391. // }
  392. // if (bindTemplate != -1) {
  393. // stream.writeByte(140);
  394. // stream.writeShort(bindTemplate);
  395. // }
  396.  
  397. if (unknownArray4 != null) {
  398. for (int index = 0; index < unknownArray4.length; index++) {
  399. if (unknownArray4[index] == -1) {
  400. continue;
  401. }
  402. stream.writeByte(142 + index);
  403. stream.writeShort(unknownArray4[index]);
  404. }
  405. }
  406. if (unknownArray5 != null) {
  407. for (int index = 0; index < unknownArray5.length; index++) {
  408. if (unknownArray5[index] == -1) {
  409. continue;
  410. }
  411. stream.writeByte(150 + index);
  412. stream.writeShort(unknownArray5[index]);
  413. }
  414. }
  415.  
  416. // if (aBool8089) {
  417. // stream.writeByte(157);
  418. // }
  419. // if (shardLink != -1) {
  420. // stream.writeByte(161);
  421. // stream.writeShort(shardLink);
  422. // }
  423. // if (shardTemplate != -1) {
  424. // stream.writeByte(162);
  425. // stream.writeShort(shardTemplate);
  426. // }
  427. // if (shardCombineAmount != 0) {
  428. // stream.writeByte(163);
  429. // stream.writeShort(shardCombineAmount);
  430. // }
  431. // if (!shardName.equals("null") || shardName != null) {
  432. // stream.writeByte(164);
  433. // stream.writeString(shardName);
  434. // }
  435. if (stackable == 2)
  436. stream.writeByte(165);
  437.  
  438. if (clientScriptData != null) {
  439. stream.writeByte(249);
  440. stream.writeByte(clientScriptData.size());
  441. for (int key : clientScriptData.keySet()) {
  442. Object value = clientScriptData.get(key);
  443. stream.writeByte(value instanceof String ? 1 : 0);
  444. stream.write24BitInt(key);
  445. if (value instanceof String) {
  446. stream.writeString((String) value);
  447. } else {
  448. stream.writeInt((Integer) value);
  449. }
  450. }
  451. }
  452. // end
  453. stream.writeByte(0);
  454.  
  455. byte[] data = new byte[stream.getOffset()];
  456. stream.setOffset(0);
  457. stream.getBytes(data, 0, data.length);
  458. return data;
  459. }
  460.  
  461.  
  462. public void write() {
  463. byte[] data = this.encode();
  464. Cache.getStore().getIndexes()[19].putFile(this.id >>> 8, 0xff & this.id, data);
  465. }
  466.  
  467. public static final ItemDefinitions getItemDefinitions(int itemId) {
  468. if (itemId < 0 || itemId >= itemsDefinitions.length)
  469. itemId = 0;
  470. ItemDefinitions def = itemsDefinitions[itemId];
  471. if (def == null)
  472. itemsDefinitions[itemId] = def = new ItemDefinitions(itemId);
  473. return def;
  474. }
  475.  
  476. public static final void clearItemsDefinitions() {
  477. for (int i = 0; i < itemsDefinitions.length; i++)
  478. itemsDefinitions[i] = null;
  479. }
  480.  
  481. public ItemDefinitions(int id) {
  482. this.id = id;
  483. setDefaultsVariableValues();
  484. setDefaultOptions();
  485. loadItemDefinitions();
  486. }
  487.  
  488. public boolean isLoaded() {
  489. return loaded;
  490. }
  491.  
  492. public final void loadItemDefinitions() {
  493. byte[] data = Cache.STORE.getIndexes()[Constants.ITEM_DEFINITIONS_INDEX].getFile(getArchiveId(), getFileId());
  494. if (data == null) {
  495. // System.out.println("Failed loading Item " + id+".");
  496. return;
  497. }
  498. readOpcodeValues(new InputStream(data));
  499. if (certTemplateId != -1)
  500. toNote();
  501. if (lendTemplateId != -1)
  502. toLend();
  503. if (unknownValue1 != -1)
  504. toBind();
  505. loaded = true;
  506. }
  507.  
  508.  
  509.  
  510. public void toNote() {
  511. // ItemDefinitions noteItem; //certTemplateId
  512. ItemDefinitions realItem = getItemDefinitions(certId);
  513. membersOnly = realItem.membersOnly;
  514. value = realItem.value;
  515. name = realItem.name;
  516. stackable = 1;
  517. noted = true;
  518. }
  519.  
  520. public void toBind() {
  521. // ItemDefinitions lendItem; //lendTemplateId
  522. ItemDefinitions realItem = getItemDefinitions(unknownValue2);
  523. originalModelColors = realItem.originalModelColors;
  524. maleEquipModelId3 = realItem.maleEquipModelId3;
  525. femaleEquipModelId3 = realItem.femaleEquipModelId3;
  526. teamId = realItem.teamId;
  527. value = 0;
  528. membersOnly = realItem.membersOnly;
  529. name = realItem.name;
  530. inventoryOptions = new String[5];
  531. groundOptions = realItem.groundOptions;
  532. if (realItem.inventoryOptions != null)
  533. for (int optionIndex = 0; optionIndex < 4; optionIndex++)
  534. inventoryOptions[optionIndex] = realItem.inventoryOptions[optionIndex];
  535. inventoryOptions[4] = "Discard";
  536. maleEquip1 = realItem.maleEquip1;
  537. maleEquip2 = realItem.maleEquip2;
  538. femaleEquip1 = realItem.femaleEquip1;
  539. femaleEquip2 = realItem.femaleEquip2;
  540. clientScriptData = realItem.clientScriptData;
  541. equipSlot = realItem.equipSlot;
  542. equipType = realItem.equipType;
  543. }
  544.  
  545. public void toLend() {
  546. // ItemDefinitions lendItem; //lendTemplateId
  547. ItemDefinitions realItem = getItemDefinitions(lendId);
  548. originalModelColors = realItem.originalModelColors;
  549. maleEquipModelId3 = realItem.maleEquipModelId3;
  550. femaleEquipModelId3 = realItem.femaleEquipModelId3;
  551. teamId = realItem.teamId;
  552. value = 0;
  553. membersOnly = realItem.membersOnly;
  554. name = realItem.name;
  555. inventoryOptions = new String[5];
  556. groundOptions = realItem.groundOptions;
  557. if (realItem.inventoryOptions != null)
  558. for (int optionIndex = 0; optionIndex < 4; optionIndex++)
  559. inventoryOptions[optionIndex] = realItem.inventoryOptions[optionIndex];
  560. inventoryOptions[4] = "Discard";
  561. maleEquip1 = realItem.maleEquip1;
  562. maleEquip2 = realItem.maleEquip2;
  563. femaleEquip1 = realItem.femaleEquip1;
  564. femaleEquip2 = realItem.femaleEquip2;
  565. clientScriptData = realItem.clientScriptData;
  566. equipSlot = realItem.equipSlot;
  567. equipType = realItem.equipType;
  568. lended = true;
  569. }
  570.  
  571. public int getArchiveId() {
  572. return getId() >>> 8;
  573. }
  574.  
  575. public int getFileId() {
  576. return 0xff & getId();
  577. }
  578.  
  579. public boolean isDestroyItem() {
  580. if (inventoryOptions == null)
  581. return false;
  582. for (String option : inventoryOptions) {
  583. if (option == null)
  584. continue;
  585. if (option.equalsIgnoreCase("destroy"))
  586. return true;
  587. }
  588. return false;
  589. }
  590.  
  591. public boolean containsOption(int i, String option) {
  592. if (inventoryOptions == null || inventoryOptions[i] == null
  593. || inventoryOptions.length <= i)
  594. return false;
  595. return inventoryOptions[i].equals(option);
  596. }
  597.  
  598. public boolean containsOption(String option) {
  599. if (inventoryOptions == null)
  600. return false;
  601. for (String o : inventoryOptions) {
  602. if (o == null || !o.equals(option))
  603. continue;
  604. return true;
  605. }
  606. return false;
  607. }
  608.  
  609. public boolean isWearItem() {
  610. return equipSlot != -1;
  611. }
  612.  
  613. public boolean isWearItem(boolean male) {
  614. if (equipSlot < Equipment.SLOT_RING
  615. && (male ? getMaleWornModelId1() == -1
  616. : getFemaleWornModelId1() == -1))
  617. return false;
  618. return equipSlot != -1;
  619. }
  620.  
  621. public boolean hasSpecialBar() {
  622. if (clientScriptData == null)
  623. return false;
  624. Object specialBar = clientScriptData.get(686);
  625. if (specialBar != null && specialBar instanceof Integer)
  626. return (Integer) specialBar == 1;
  627. return false;
  628. }
  629.  
  630. public int getAttackSpeed() {
  631. if (clientScriptData == null)
  632. return 4;
  633. Object attackSpeed = clientScriptData.get(14);
  634. if (attackSpeed != null && attackSpeed instanceof Integer)
  635. return (int) attackSpeed;
  636. return 4;
  637. }
  638.  
  639. public int getStabAttack() {
  640. if (clientScriptData == null)
  641. return 0;
  642. Object value = clientScriptData.get(0);
  643. if (value != null && value instanceof Integer)
  644. return (int) value;
  645. return 0;
  646. }
  647.  
  648. public int getSlashAttack() {
  649. if (clientScriptData == null)
  650. return 0;
  651. Object value = clientScriptData.get(1);
  652. if (value != null && value instanceof Integer)
  653. return (int) value;
  654. return 0;
  655. }
  656.  
  657. public int getCrushAttack() {
  658. if (clientScriptData == null)
  659. return 0;
  660. Object value = clientScriptData.get(2);
  661. if (value != null && value instanceof Integer)
  662. return (int) value;
  663. return 0;
  664. }
  665.  
  666. public int getMagicAttack() {
  667. if (clientScriptData == null)
  668. return 0;
  669. Object value = clientScriptData.get(3);
  670. if (value != null && value instanceof Integer)
  671. return (int) value;
  672. return 0;
  673. }
  674.  
  675. public int getRangeAttack() {
  676. if (clientScriptData == null)
  677. return 0;
  678. Object value = clientScriptData.get(4);
  679. if (value != null && value instanceof Integer)
  680. return (int) value;
  681. return 0;
  682. }
  683.  
  684. public int getStabDef() {
  685. if (clientScriptData == null)
  686. return 0;
  687. Object value = clientScriptData.get(5);
  688. if (value != null && value instanceof Integer)
  689. return (int) value;
  690. return 0;
  691. }
  692.  
  693. public int getSlashDef() {
  694. if (clientScriptData == null)
  695. return 0;
  696. Object value = clientScriptData.get(6);
  697. if (value != null && value instanceof Integer)
  698. return (int) value;
  699. return 0;
  700. }
  701.  
  702. public int getCrushDef() {
  703. if (clientScriptData == null)
  704. return 0;
  705. Object value = clientScriptData.get(7);
  706. if (value != null && value instanceof Integer)
  707. return (int) value;
  708. return 0;
  709. }
  710.  
  711. public int getMagicDef() {
  712. if (clientScriptData == null)
  713. return 0;
  714. Object value = clientScriptData.get(8);
  715. if (value != null && value instanceof Integer)
  716. return (int) value;
  717. return 0;
  718. }
  719.  
  720. public int getRangeDef() {
  721. if (clientScriptData == null)
  722. return 0;
  723. Object value = clientScriptData.get(9);
  724. if (value != null && value instanceof Integer)
  725. return (int) value;
  726. return 0;
  727. }
  728.  
  729. public int getSummoningDef() {
  730. if (clientScriptData == null)
  731. return 0;
  732. Object value = clientScriptData.get(417);
  733. if (value != null && value instanceof Integer)
  734. return (int) value;
  735. return 0;
  736. }
  737.  
  738. public int getAbsorveMeleeBonus() {
  739. if (clientScriptData == null)
  740. return 0;
  741. Object value = clientScriptData.get(967);
  742. if (value != null && value instanceof Integer)
  743. return (int) value;
  744. return 0;
  745. }
  746.  
  747. public int getAbsorveMageBonus() {
  748. if (clientScriptData == null)
  749. return 0;
  750. Object value = clientScriptData.get(969);
  751. if (value != null && value instanceof Integer)
  752. return (int) value;
  753. return 0;
  754. }
  755.  
  756. public int getAbsorveRangeBonus() {
  757. if (clientScriptData == null)
  758. return 0;
  759. Object value = clientScriptData.get(968);
  760. if (value != null && value instanceof Integer)
  761. return (int) value;
  762. return 0;
  763. }
  764.  
  765. public int getStrengthBonus() {
  766. if (clientScriptData == null)
  767. return 0;
  768. Object value = clientScriptData.get(641);
  769. if (value != null && value instanceof Integer)
  770. return (int) value / 10;
  771. return 0;
  772. }
  773.  
  774. public int getRangedStrBonus() {
  775. if (clientScriptData == null)
  776. return 0;
  777. Object value = clientScriptData.get(643);
  778. if (value != null && value instanceof Integer)
  779. return (int) value / 10;
  780. return 0;
  781. }
  782.  
  783. public int getMagicDamage() {
  784. if (clientScriptData == null)
  785. return 0;
  786. Object value = clientScriptData.get(685);
  787. if (value != null && value instanceof Integer)
  788. return (int) value;
  789. return 0;
  790. }
  791.  
  792. public int getPrayerBonus() {
  793. if (clientScriptData == null)
  794. return 0;
  795. Object value = clientScriptData.get(11);
  796. if (value != null && value instanceof Integer)
  797. return (int) value;
  798. return 0;
  799. }
  800.  
  801.  
  802. public int getRenderAnimId() {
  803. if (clientScriptData == null)
  804. return 1426;
  805. Object animId = clientScriptData.get(644);
  806. if (animId != null && animId instanceof Integer)
  807. return (Integer) animId;
  808. return 1426;
  809. }
  810.  
  811. public int getModelZoom() {
  812. return modelZoom;
  813. }
  814.  
  815. public int getModelOffset1() {
  816. return modelOffset1;
  817. }
  818.  
  819. public int getModelOffset2() {
  820. return modelOffset2;
  821. }
  822.  
  823. public int getQuestId() {
  824. if (clientScriptData == null)
  825. return -1;
  826. Object questId = clientScriptData.get(861);
  827. if (questId != null && questId instanceof Integer)
  828. return (Integer) questId;
  829. return -1;
  830. }
  831.  
  832. public List<Item> getCreateItemRequirements() {
  833. if (clientScriptData == null)
  834. return null;
  835. List<Item> items = new ArrayList<Item>();
  836. int requiredId = -1;
  837. int requiredAmount = -1;
  838. for (int key : clientScriptData.keySet()) {
  839. Object value = clientScriptData.get(key);
  840. if (value instanceof String)
  841. continue;
  842. if (key >= 538 && key <= 770) {
  843. if (key % 2 == 0)
  844. requiredId = (Integer) value;
  845. else
  846. requiredAmount = (Integer) value;
  847. if (requiredId != -1 && requiredAmount != -1) {
  848. items.add(new Item(requiredId, requiredAmount));
  849. requiredId = -1;
  850. requiredAmount = -1;
  851. }
  852. }
  853. }
  854. return items;
  855. }
  856.  
  857. public HashMap<Integer, Object> getClientScriptData() {
  858. return clientScriptData;
  859. }
  860.  
  861. public HashMap<Integer, Integer> getWearingSkillRequiriments() {
  862. if (clientScriptData == null)
  863. return null;
  864. if (itemRequiriments == null) {
  865. HashMap<Integer, Integer> skills = new HashMap<Integer, Integer>();
  866. for (int i = 0; i < 10; i++) {
  867. Integer skill = (Integer) clientScriptData.get(749 + (i * 2));
  868. if (skill != null) {
  869. Integer level = (Integer) clientScriptData.get(750 + (i * 2));
  870. if (level != null)
  871. skills.put(skill, level);
  872. }
  873. }
  874. Integer maxedSkill = (Integer) clientScriptData.get(277);
  875. if (maxedSkill != null)
  876. skills.put(maxedSkill, getId() == 19709 ? 120 : 99);
  877. itemRequiriments = skills;
  878. if (getId() == 7462)
  879. itemRequiriments.put(Skills.DEFENCE, 40);
  880. else if (getId() == 19784 || getId() == 22401 || getId() == 19780) { // Korasi
  881. itemRequiriments.put(Skills.ATTACK, 78);
  882. itemRequiriments.put(Skills.STRENGTH, 78);
  883. } else if (getId() == 20822 || getId() == 20823 || getId() == 20824
  884. || getId() == 20825 || getId() == 20826)
  885. itemRequiriments.put(Skills.DEFENCE, 99);
  886. else if (name.equals("Dragon defender")) {
  887. itemRequiriments.put(Skills.ATTACK, 60);
  888. itemRequiriments.put(Skills.DEFENCE, 60);
  889. }
  890. }
  891. return itemRequiriments;
  892. }
  893.  
  894. public void setDefaultOptions() {
  895. groundOptions = new String[] { null, null, "take", null, null };
  896. inventoryOptions = new String[] { null, null, null, null, "drop" };
  897. }
  898.  
  899. public void setDefaultsVariableValues() {
  900. name = "null";
  901. maleEquip1 = -1;
  902. maleEquip2 = -1;
  903. femaleEquip1 = -1;
  904. femaleEquip2 = -1;
  905. modelZoom = 2000;
  906. lendId = -1;
  907. lendTemplateId = -1;
  908. certId = -1;
  909. certTemplateId = -1;
  910. unknownInt9 = 128;
  911. value = 1;
  912. maleEquipModelId3 = -1;
  913. femaleEquipModelId3 = -1;
  914. unknownValue1 = -1;
  915. unknownValue2 = -1;
  916. teamId = -1;
  917. equipSlot = -1;
  918. equipLookHideSlot2 = -1;
  919. equipType = -1;
  920. }
  921.  
  922. public final void readValues(InputStream stream, int opcode) {
  923. if (opcode == 1)
  924. modelId = stream.readBigSmart();
  925. else if (opcode == 2)
  926. name = stream.readString();
  927. else if (opcode == 4)
  928. modelZoom = stream.readUnsignedShort();
  929. else if (opcode == 5)
  930. modelRotation1 = stream.readUnsignedShort();
  931. else if (opcode == 6)
  932. modelRotation2 = stream.readUnsignedShort();
  933. else if (opcode == 7) {
  934. modelOffset1 = stream.readUnsignedShort();
  935. if (modelOffset1 > 32767)
  936. modelOffset1 -= 65536;
  937. modelOffset1 <<= 0;
  938. } else if (opcode == 8) {
  939. modelOffset2 = stream.readUnsignedShort();
  940. if (modelOffset2 > 32767)
  941. modelOffset2 -= 65536;
  942. modelOffset2 <<= 0;
  943. } else if (opcode == 11)
  944. stackable = 1;
  945. else if (opcode == 12)
  946. value = stream.readInt();
  947. else if (opcode == 13) {
  948. equipSlot = stream.readUnsignedByte();
  949. } else if (opcode == 14) {
  950. equipType = stream.readUnsignedByte();
  951. } else if (opcode == 16)
  952. membersOnly = true;
  953. else if (opcode == 18) { // added
  954. stream.readUnsignedShort();
  955. } else if (opcode == 23)
  956. maleEquip1 = stream.readBigSmart();
  957. else if (opcode == 24)
  958. maleEquip2 = stream.readBigSmart();
  959. else if (opcode == 25)
  960. femaleEquip1 = stream.readBigSmart();
  961. else if (opcode == 26)
  962. femaleEquip2 = stream.readBigSmart();
  963. else if (opcode == 27)
  964. equipLookHideSlot2 = stream.readUnsignedByte();
  965. else if (opcode >= 30 && opcode < 35)
  966. groundOptions[opcode - 30] = stream.readString();
  967. else if (opcode >= 35 && opcode < 40)
  968. inventoryOptions[opcode - 35] = stream.readString();
  969. else if (opcode == 40) {
  970. int length = stream.readUnsignedByte();
  971. originalModelColors = new int[length];
  972. modifiedModelColors = new int[length];
  973. for (int index = 0; index < length; index++) {
  974. originalModelColors[index] = stream.readUnsignedShort();
  975. modifiedModelColors[index] = stream.readUnsignedShort();
  976. }
  977. } else if (opcode == 41) {
  978. int length = stream.readUnsignedByte();
  979. originalTextureColors = new short[length];
  980. modifiedTextureColors = new short[length];
  981. for (int index = 0; index < length; index++) {
  982. originalTextureColors[index] = (short) stream
  983. .readUnsignedShort();
  984. modifiedTextureColors[index] = (short) stream
  985. .readUnsignedShort();
  986. }
  987. } else if (opcode == 42) {
  988. int length = stream.readUnsignedByte();
  989. unknownArray1 = new byte[length];
  990. for (int index = 0; index < length; index++)
  991. unknownArray1[index] = (byte) stream.readByte();
  992. } else if (opcode == 44) {
  993. int length = stream.readUnsignedShort();
  994. int arraySize = 0;
  995. for (int modifier = 0; modifier > 0; modifier++) {
  996. arraySize++;
  997. unknownArray3 = new byte[arraySize];
  998. byte offset = 0;
  999. for (int index = 0; index < arraySize; index++) {
  1000. if ((length & 1 << index) > 0) {
  1001. unknownArray3[index] = offset;
  1002. } else {
  1003. unknownArray3[index] = -1;
  1004. }
  1005. }
  1006. }
  1007. } else if (45 == opcode) {
  1008. int i_97_ =(short) stream.readUnsignedShort();
  1009. int i_98_ = 0;
  1010. for (int i_99_ = i_97_; i_99_ > 0; i_99_ >>= 1)
  1011. i_98_++;
  1012. unknownArray6 = new byte[i_98_];
  1013. byte i_100_ = 0;
  1014. for (int i_101_ = 0; i_101_ < i_98_; i_101_++) {
  1015. if ((i_97_ & 1 << i_101_) > 0) {
  1016. unknownArray6[i_101_] = i_100_;
  1017. i_100_++;
  1018. } else
  1019. unknownArray6[i_101_] = (byte) -1;
  1020. }
  1021. } else if (opcode == 65)
  1022. unnoted = true;
  1023. else if (opcode == 78)
  1024. maleEquipModelId3 = stream.readBigSmart();
  1025. else if (opcode == 79)
  1026. femaleEquipModelId3 = stream.readBigSmart();
  1027. else if (opcode == 90)
  1028. unknownInt1 = stream.readBigSmart();
  1029. else if (opcode == 91)
  1030. unknownInt2 = stream.readBigSmart();
  1031. else if (opcode == 92)
  1032. unknownInt3 = stream.readBigSmart();
  1033. else if (opcode == 93)
  1034. unknownInt4 = stream.readBigSmart();
  1035. else if (opcode == 95)
  1036. unknownInt5 = stream.readUnsignedShort();
  1037. else if (opcode == 96)
  1038. unknownInt6 = stream.readUnsignedByte();
  1039. else if (opcode == 97)
  1040. certId = stream.readUnsignedShort();
  1041. else if (opcode == 98)
  1042. certTemplateId = stream.readUnsignedShort();
  1043. else if (opcode >= 100 && opcode < 110) {
  1044. if (stackIds == null) {
  1045. stackIds = new int[10];
  1046. stackAmounts = new int[10];
  1047. }
  1048. stackIds[opcode - 100] = stream.readUnsignedShort();
  1049. stackAmounts[opcode - 100] = stream.readUnsignedShort();
  1050. } else if (opcode == 110)
  1051. unknownInt7 = stream.readUnsignedShort();
  1052. else if (opcode == 111)
  1053. unknownInt8 = stream.readUnsignedShort();
  1054. else if (opcode == 112)
  1055. unknownInt9 = stream.readUnsignedShort();
  1056. else if (opcode == 113)
  1057. unknownInt10 = stream.readByte();
  1058. else if (opcode == 114)
  1059. unknownInt11 = stream.readByte() * 5;
  1060. else if (opcode == 115)
  1061. teamId = stream.readUnsignedByte();
  1062. else if (opcode == 121)
  1063. lendId = stream.readUnsignedShort();
  1064. else if (opcode == 122)
  1065. lendTemplateId = stream.readUnsignedShort();
  1066. else if (opcode == 125) {
  1067. unknownInt12 = stream.readByte() << 0;
  1068. unknownInt13 = stream.readByte() << 0;
  1069. unknownInt14 = stream.readByte() << 0;
  1070. } else if (opcode == 126) {
  1071. unknownInt15 = stream.readByte() << 0;
  1072. unknownInt16 = stream.readByte() << 0;
  1073. unknownInt17 = stream.readByte() << 0;
  1074. } else if (opcode == 127) {
  1075. unknownInt18 = stream.readUnsignedByte();
  1076. unknownInt19 = stream.readUnsignedShort();
  1077. } else if (opcode == 128) {
  1078. unknownInt20 = stream.readUnsignedByte();
  1079. unknownInt21 = stream.readUnsignedShort();
  1080. } else if (opcode == 129) {
  1081. unknownInt20 = stream.readUnsignedByte();
  1082. unknownInt21 = stream.readUnsignedShort();
  1083. } else if (opcode == 130) {
  1084. unknownInt22 = stream.readUnsignedByte();
  1085. unknownInt23 = stream.readUnsignedShort();
  1086. } else if (opcode == 132) {
  1087. int length = stream.readUnsignedByte();
  1088. unknownArray2 = new int[length];
  1089. for (int index = 0; index < length; index++)
  1090. unknownArray2[index] = stream.readUnsignedShort();
  1091. } else if (opcode == 134) {
  1092. int unknownValue = stream.readUnsignedByte();
  1093. } else if (opcode == 139) {
  1094. unknownValue2 = stream.readUnsignedShort();
  1095. } else if (opcode == 140) {
  1096. unknownValue1 = stream.readUnsignedShort();
  1097. } else if (opcode >= 142 && opcode < 147) {
  1098. if (unknownArray4 == null) {
  1099. unknownArray4 = new int[6];
  1100. Arrays.fill(unknownArray4, -1);
  1101. }
  1102. unknownArray4[opcode - 142] = stream.readUnsignedShort();
  1103. } else if (opcode >= 150 && opcode < 155) {
  1104. if (null == unknownArray5) {
  1105. unknownArray5 = new int[5];
  1106. Arrays.fill(unknownArray5, -1);
  1107. }
  1108. unknownArray5[opcode - 150] = stream.readUnsignedShort();
  1109. } else if (opcode == 142) {
  1110. stream.readByte();
  1111. stream.readByte();
  1112. } else if (opcode == 144) {
  1113. stream.readByte();
  1114. stream.readByte();
  1115. stream.readByte();
  1116. } else if (opcode == 151) {
  1117. stream.readByte();
  1118. stream.readByte();
  1119. } else if (opcode == 249) {
  1120. int length = stream.readUnsignedByte();
  1121. if (clientScriptData == null)
  1122. clientScriptData = new HashMap<Integer, Object>(length);
  1123. for (int index = 0; index < length; index++) {
  1124. boolean stringInstance = stream.readUnsignedByte() == 1;
  1125. int key = stream.read24BitInt();
  1126. Object value = stringInstance ? stream.readString() : stream
  1127. .readInt();
  1128. clientScriptData.put(key, value);
  1129. }
  1130. } else
  1131. throw new RuntimeException("MISSING OPCODE " + opcode
  1132. + " FOR ITEM " + getId());
  1133. }
  1134.  
  1135. public static ItemDefinitions forName(String name) {
  1136. for (ItemDefinitions definition : itemsDefinitions) {
  1137. if (definition.name.equalsIgnoreCase(name)) {
  1138. return definition;
  1139. }
  1140. }
  1141. return null;
  1142. }
  1143.  
  1144. public String getExamine() {
  1145. return ItemExamines.getExamine(new Item(id));
  1146. }
  1147.  
  1148.  
  1149. public void setValue(int value) {
  1150. this.value = value;
  1151. }
  1152.  
  1153.  
  1154. public int unknownValue1;
  1155. public int unknownValue2;
  1156.  
  1157. public final void readOpcodeValues(InputStream stream) {
  1158. while (true) {
  1159. int opcode = stream.readUnsignedByte();
  1160. if (opcode == 0)
  1161. break;
  1162. readValues(stream, opcode);
  1163. }
  1164. }
  1165.  
  1166. public String getName() {
  1167. return name;
  1168. }
  1169.  
  1170. public int getFemaleWornModelId1() {
  1171. return femaleEquip1;
  1172. }
  1173.  
  1174. public int getFemaleWornModelId2() {
  1175. return femaleEquip2;
  1176. }
  1177.  
  1178. public int getFemaleWornModelId3() {
  1179. return femaleEquipModelId3;
  1180. }
  1181.  
  1182. public int getMaleWornModelId1() {
  1183. return maleEquip1;
  1184. }
  1185.  
  1186. public int getMaleWornModelId2() {
  1187. return maleEquip2;
  1188. }
  1189.  
  1190. public int getMaleWornModelId3() {
  1191. return maleEquipModelId3;
  1192. }
  1193.  
  1194. public boolean isOverSized() {
  1195. return modelZoom > 6000;
  1196. }
  1197.  
  1198. public boolean isLended() {
  1199. return lended;
  1200. }
  1201.  
  1202. public boolean isMembersOnly() {
  1203. return membersOnly;
  1204. }
  1205.  
  1206. public boolean isStackable() {
  1207. return stackable == 1;
  1208. }
  1209.  
  1210. public boolean isNoted() {
  1211. return noted;
  1212. }
  1213.  
  1214. public int getLendId() {
  1215. return lendId;
  1216. }
  1217.  
  1218. public int getCertId() {
  1219. return certId;
  1220. }
  1221.  
  1222. public int getValue() {
  1223. return value;
  1224. }
  1225.  
  1226. public int getId() {
  1227. return id;
  1228. }
  1229.  
  1230. public int getEquipSlot() {
  1231. return equipSlot;
  1232. }
  1233.  
  1234. public int getEquipType() {
  1235. return equipType;
  1236. }
  1237. public int equipLookHideSlot2;
  1238. public int getEquipType2() {
  1239. return equipLookHideSlot2;
  1240. }
  1241. public int getEquipLookHideSlot2() {
  1242. return equipLookHideSlot2;
  1243. }
  1244.  
  1245. public void setStackable(int newValue) {
  1246. this.stackable = newValue;
  1247. }
  1248.  
  1249.  
  1250. public long getbValue() {
  1251. return value;
  1252. }
  1253. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement