Advertisement
Guest User

Itemdef | Vulcan

a guest
Feb 15th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.13 KB | None | 0 0
  1. public final class ItemDef
  2. {
  3.  
  4. public static void nullLoader()
  5. {
  6. mruNodes2 = null;
  7. mruNodes1 = null;
  8. streamIndices = null;
  9. cache = null;
  10. stream = null;
  11. }
  12.  
  13. public boolean method192(int j)
  14. {
  15. int k = anInt175;
  16. int l = anInt166;
  17. if(j == 1)
  18. {
  19. k = anInt197;
  20. l = anInt173;
  21. }
  22. if(k == -1)
  23. return true;
  24. boolean flag = true;
  25. if(!Model.method463(k))
  26. flag = false;
  27. if(l != -1 && !Model.method463(l))
  28. flag = false;
  29. return flag;
  30. }
  31.  
  32. public static void unpackConfig(StreamLoader streamLoader)
  33. {
  34. stream = new Stream(streamLoader.getDataForName("obj.dat"));
  35. Stream stream = new Stream(streamLoader.getDataForName("obj.idx"));
  36. totalItems = stream.readUnsignedWord();
  37. streamIndices = new int[totalItems];
  38. int i = 2;
  39. for(int j = 0; j < totalItems; j++)
  40. {
  41. streamIndices[j] = i;
  42. i += stream.readUnsignedWord();
  43. }
  44.  
  45. cache = new ItemDef[10];
  46. for(int k = 0; k < 10; k++)
  47. cache[k] = new ItemDef();
  48.  
  49. }
  50.  
  51. public Model method194(int j)
  52. {
  53. int k = anInt175;
  54. int l = anInt166;
  55. if(j == 1)
  56. {
  57. k = anInt197;
  58. l = anInt173;
  59. }
  60. if(k == -1)
  61. return null;
  62. Model model = Model.method462(k);
  63. if(l != -1)
  64. {
  65. Model model_1 = Model.method462(l);
  66. Model aclass30_sub2_sub4_sub6s[] = {
  67. model, model_1
  68. };
  69. model = new Model(2, aclass30_sub2_sub4_sub6s);
  70. }
  71. if(modifiedModelColors != null)
  72. {
  73. for(int i1 = 0; i1 < modifiedModelColors.length; i1++)
  74. model.method476(modifiedModelColors[i1], originalModelColors[i1]);
  75.  
  76. }
  77. return model;
  78. }
  79.  
  80. public boolean method195(int j)
  81. {
  82. int k = anInt165;
  83. int l = anInt188;
  84. int i1 = anInt185;
  85. if(j == 1)
  86. {
  87. k = anInt200;
  88. l = anInt164;
  89. i1 = anInt162;
  90. }
  91. if(k == -1)
  92. return true;
  93. boolean flag = true;
  94. if(!Model.method463(k))
  95. flag = false;
  96. if(l != -1 && !Model.method463(l))
  97. flag = false;
  98. if(i1 != -1 && !Model.method463(i1))
  99. flag = false;
  100. return flag;
  101. }
  102.  
  103. public Model method196(int i)
  104. {
  105. int j = anInt165;
  106. int k = anInt188;
  107. int l = anInt185;
  108. if(i == 1)
  109. {
  110. j = anInt200;
  111. k = anInt164;
  112. l = anInt162;
  113. }
  114. if(j == -1)
  115. return null;
  116. Model model = Model.method462(j);
  117. if(k != -1)
  118. if(l != -1)
  119. {
  120. Model model_1 = Model.method462(k);
  121. Model model_3 = Model.method462(l);
  122. Model aclass30_sub2_sub4_sub6_1s[] = {
  123. model, model_1, model_3
  124. };
  125. model = new Model(3, aclass30_sub2_sub4_sub6_1s);
  126. } else
  127. {
  128. Model model_2 = Model.method462(k);
  129. Model aclass30_sub2_sub4_sub6s[] = {
  130. model, model_2
  131. };
  132. model = new Model(2, aclass30_sub2_sub4_sub6s);
  133. }
  134. if(i == 0 && aByte205 != 0)
  135. model.method475(0, aByte205, 0);
  136. if(i == 1 && aByte154 != 0)
  137. model.method475(0, aByte154, 0);
  138. if(modifiedModelColors != null)
  139. {
  140. for(int i1 = 0; i1 < modifiedModelColors.length; i1++)
  141. model.method476(modifiedModelColors[i1], originalModelColors[i1]);
  142.  
  143. }
  144. return model;
  145. }
  146.  
  147. private void setDefaults()
  148. {
  149. modelID = 0;
  150. name = null;
  151. description = null;
  152. modifiedModelColors = null;
  153. originalModelColors = null;
  154. modelZoom = 2000;
  155. modelRotation1 = 0;
  156. modelRotation2 = 0;
  157. anInt204 = 0;
  158. modelOffset1 = 0;
  159. modelOffset2 = 0;
  160. stackable = false;
  161. value = 1;
  162. membersObject = false;
  163. groundActions = null;
  164. actions = null;
  165. anInt165 = -1;
  166. anInt188 = -1;
  167. aByte205 = 0;
  168. anInt200 = -1;
  169. anInt164 = -1;
  170. aByte154 = 0;
  171. anInt185 = -1;
  172. anInt162 = -1;
  173. anInt175 = -1;
  174. anInt166 = -1;
  175. anInt197 = -1;
  176. anInt173 = -1;
  177. stackIDs = null;
  178. stackAmounts = null;
  179. certID = -1;
  180. certTemplateID = -1;
  181. anInt167 = 128;
  182. anInt192 = 128;
  183. anInt191 = 128;
  184. anInt196 = 0;
  185. anInt184 = 0;
  186. team = 0;
  187. }
  188.  
  189. public static ItemDef forID(int i)
  190. {
  191. for(int j = 0; j < 10; j++)
  192. if(cache[j].id == i)
  193. return cache[j];
  194.  
  195. cacheIndex = (cacheIndex + 1) % 10;
  196. ItemDef itemDef = cache[cacheIndex];
  197. stream.currentOffset = streamIndices[i];
  198. itemDef.id = i;
  199. itemDef.setDefaults();
  200. itemDef.readValues(stream);
  201. if(itemDef.certTemplateID != -1)
  202. itemDef.toNote();
  203. if(!isMembers && itemDef.membersObject)
  204. {
  205. itemDef.name = "Members Object";
  206. itemDef.description = "Login to a members' server to use this object.".getBytes();
  207. itemDef.groundActions = null;
  208. itemDef.actions = null;
  209. itemDef.team = 0;
  210. }
  211. return itemDef;
  212. }
  213.  
  214. private void toNote()
  215. {
  216. ItemDef itemDef = forID(certTemplateID);
  217. modelID = itemDef.modelID;
  218. modelZoom = itemDef.modelZoom;
  219. modelRotation1 = itemDef.modelRotation1;
  220. modelRotation2 = itemDef.modelRotation2;
  221.  
  222. anInt204 = itemDef.anInt204;
  223. modelOffset1 = itemDef.modelOffset1;
  224. modelOffset2 = itemDef.modelOffset2;
  225. modifiedModelColors = itemDef.modifiedModelColors;
  226. originalModelColors = itemDef.originalModelColors;
  227. ItemDef itemDef_1 = forID(certID);
  228. name = itemDef_1.name;
  229. membersObject = itemDef_1.membersObject;
  230. value = itemDef_1.value;
  231. String s = "a";
  232. char c = itemDef_1.name.charAt(0);
  233. if(c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
  234. s = "an";
  235. description = ("Swap this note at any bank for " + s + " " + itemDef_1.name + ".").getBytes();
  236. stackable = true;
  237. }
  238.  
  239. public static Sprite getSprite(int i, int j, int k)
  240. {
  241. if(k == 0)
  242. {
  243. Sprite sprite = (Sprite) mruNodes1.insertFromCache(i);
  244. if(sprite != null && sprite.anInt1445 != j && sprite.anInt1445 != -1)
  245. {
  246. sprite.unlink();
  247. sprite = null;
  248. }
  249. if(sprite != null)
  250. return sprite;
  251. }
  252. ItemDef itemDef = forID(i);
  253. if(itemDef.stackIDs == null)
  254. j = -1;
  255. if(j > 1)
  256. {
  257. int i1 = -1;
  258. for(int j1 = 0; j1 < 10; j1++)
  259. if(j >= itemDef.stackAmounts[j1] && itemDef.stackAmounts[j1] != 0)
  260. i1 = itemDef.stackIDs[j1];
  261.  
  262. if(i1 != -1)
  263. itemDef = forID(i1);
  264. }
  265. Model model = itemDef.method201(1);
  266. if(model == null)
  267. return null;
  268. Sprite sprite = null;
  269. if(itemDef.certTemplateID != -1)
  270. {
  271. sprite = getSprite(itemDef.certID, 10, -1);
  272. if(sprite == null)
  273. return null;
  274. }
  275. Sprite sprite2 = new Sprite(32, 32);
  276. int k1 = Texture.textureInt1;
  277. int l1 = Texture.textureInt2;
  278. int ai[] = Texture.anIntArray1472;
  279. int ai1[] = DrawingArea.pixels;
  280. int i2 = DrawingArea.width;
  281. int j2 = DrawingArea.height;
  282. int k2 = DrawingArea.topX;
  283. int l2 = DrawingArea.bottomX;
  284. int i3 = DrawingArea.topY;
  285. int j3 = DrawingArea.bottomY;
  286. Texture.aBoolean1464 = false;
  287. DrawingArea.initDrawingArea(32, 32, sprite2.myPixels);
  288. DrawingArea.method336(32, 0, 0, 0, 32);
  289. Texture.method364();
  290. int k3 = itemDef.modelZoom;
  291. if(k == -1)
  292. k3 = (int)((double)k3 * 1.5D);
  293. if(k > 0)
  294. k3 = (int)((double)k3 * 1.04D);
  295. int l3 = Texture.anIntArray1470[itemDef.modelRotation1] * k3 >> 16;
  296. int i4 = Texture.anIntArray1471[itemDef.modelRotation1] * k3 >> 16;
  297. model.method482(itemDef.modelRotation2, itemDef.anInt204, itemDef.modelRotation1, itemDef.modelOffset1, l3 + model.modelHeight / 2 + itemDef.modelOffset2, i4 + itemDef.modelOffset2);
  298. for(int i5 = 31; i5 >= 0; i5--)
  299. {
  300. for(int j4 = 31; j4 >= 0; j4--)
  301. if(sprite2.myPixels[i5 + j4 * 32] == 0)
  302. if(i5 > 0 && sprite2.myPixels[(i5 - 1) + j4 * 32] > 1)
  303. sprite2.myPixels[i5 + j4 * 32] = 1;
  304. else
  305. if(j4 > 0 && sprite2.myPixels[i5 + (j4 - 1) * 32] > 1)
  306. sprite2.myPixels[i5 + j4 * 32] = 1;
  307. else
  308. if(i5 < 31 && sprite2.myPixels[i5 + 1 + j4 * 32] > 1)
  309. sprite2.myPixels[i5 + j4 * 32] = 1;
  310. else
  311. if(j4 < 31 && sprite2.myPixels[i5 + (j4 + 1) * 32] > 1)
  312. sprite2.myPixels[i5 + j4 * 32] = 1;
  313.  
  314. }
  315.  
  316. if(k > 0)
  317. {
  318. for(int j5 = 31; j5 >= 0; j5--)
  319. {
  320. for(int k4 = 31; k4 >= 0; k4--)
  321. if(sprite2.myPixels[j5 + k4 * 32] == 0)
  322. if(j5 > 0 && sprite2.myPixels[(j5 - 1) + k4 * 32] == 1)
  323. sprite2.myPixels[j5 + k4 * 32] = k;
  324. else
  325. if(k4 > 0 && sprite2.myPixels[j5 + (k4 - 1) * 32] == 1)
  326. sprite2.myPixels[j5 + k4 * 32] = k;
  327. else
  328. if(j5 < 31 && sprite2.myPixels[j5 + 1 + k4 * 32] == 1)
  329. sprite2.myPixels[j5 + k4 * 32] = k;
  330. else
  331. if(k4 < 31 && sprite2.myPixels[j5 + (k4 + 1) * 32] == 1)
  332. sprite2.myPixels[j5 + k4 * 32] = k;
  333.  
  334. }
  335.  
  336. } else
  337. if(k == 0)
  338. {
  339. for(int k5 = 31; k5 >= 0; k5--)
  340. {
  341. for(int l4 = 31; l4 >= 0; l4--)
  342. if(sprite2.myPixels[k5 + l4 * 32] == 0 && k5 > 0 && l4 > 0 && sprite2.myPixels[(k5 - 1) + (l4 - 1) * 32] > 0)
  343. sprite2.myPixels[k5 + l4 * 32] = 0x302020;
  344.  
  345. }
  346.  
  347. }
  348. if(itemDef.certTemplateID != -1)
  349. {
  350. int l5 = sprite.anInt1444;
  351. int j6 = sprite.anInt1445;
  352. sprite.anInt1444 = 32;
  353. sprite.anInt1445 = 32;
  354. sprite.drawSprite(0, 0);
  355. sprite.anInt1444 = l5;
  356. sprite.anInt1445 = j6;
  357. }
  358. if(k == 0)
  359. mruNodes1.removeFromCache(sprite2, i);
  360. DrawingArea.initDrawingArea(j2, i2, ai1);
  361. DrawingArea.setDrawingArea(j3, k2, l2, i3);
  362. Texture.textureInt1 = k1;
  363. Texture.textureInt2 = l1;
  364. Texture.anIntArray1472 = ai;
  365. Texture.aBoolean1464 = true;
  366. if(itemDef.stackable)
  367. sprite2.anInt1444 = 33;
  368. else
  369. sprite2.anInt1444 = 32;
  370. sprite2.anInt1445 = j;
  371. return sprite2;
  372. }
  373.  
  374. public Model method201(int i)
  375. {
  376. if(stackIDs != null && i > 1)
  377. {
  378. int j = -1;
  379. for(int k = 0; k < 10; k++)
  380. if(i >= stackAmounts[k] && stackAmounts[k] != 0)
  381. j = stackIDs[k];
  382.  
  383. if(j != -1)
  384. return forID(j).method201(1);
  385. }
  386. Model model = (Model) mruNodes2.insertFromCache(id);
  387. if(model != null)
  388. return model;
  389. model = Model.method462(modelID);
  390. if(model == null)
  391. return null;
  392. if(anInt167 != 128 || anInt192 != 128 || anInt191 != 128)
  393. model.method478(anInt167, anInt191, anInt192);
  394. if(modifiedModelColors != null)
  395. {
  396. for(int l = 0; l < modifiedModelColors.length; l++)
  397. model.method476(modifiedModelColors[l], originalModelColors[l]);
  398.  
  399. }
  400. model.method479(64 + anInt196, 768 + anInt184, -50, -10, -50, true);
  401. model.aBoolean1659 = true;
  402. mruNodes2.removeFromCache(model, id);
  403. return model;
  404. }
  405.  
  406. public Model method202(int i)
  407. {
  408. if(stackIDs != null && i > 1)
  409. {
  410. int j = -1;
  411. for(int k = 0; k < 10; k++)
  412. if(i >= stackAmounts[k] && stackAmounts[k] != 0)
  413. j = stackIDs[k];
  414.  
  415. if(j != -1)
  416. return forID(j).method202(1);
  417. }
  418. Model model = Model.method462(modelID);
  419. if(model == null)
  420. return null;
  421. if(modifiedModelColors != null)
  422. {
  423. for(int l = 0; l < modifiedModelColors.length; l++)
  424. model.method476(modifiedModelColors[l], originalModelColors[l]);
  425.  
  426. }
  427. return model;
  428. }
  429.  
  430. private void readValues(Stream stream)
  431. {
  432. do
  433. {
  434. int i = stream.readUnsignedByte();
  435. if(i == 0)
  436. return;
  437. if(i == 1)
  438. modelID = stream.readUnsignedWord();
  439. else
  440. if(i == 2)
  441. name = stream.readString();
  442. else
  443. if(i == 3)
  444. description = stream.readBytes();
  445. else
  446. if(i == 4)
  447. modelZoom = stream.readUnsignedWord();
  448. else
  449. if(i == 5)
  450. modelRotation1 = stream.readUnsignedWord();
  451. else
  452. if(i == 6)
  453. modelRotation2 = stream.readUnsignedWord();
  454. else
  455. if(i == 7)
  456. {
  457. modelOffset1 = stream.readUnsignedWord();
  458. if(modelOffset1 > 32767)
  459. modelOffset1 -= 0x10000;
  460. } else
  461. if(i == 8)
  462. {
  463. modelOffset2 = stream.readUnsignedWord();
  464. if(modelOffset2 > 32767)
  465. modelOffset2 -= 0x10000;
  466. } else
  467. if(i == 10)
  468. stream.readUnsignedWord();
  469. else
  470. if(i == 11)
  471. stackable = true;
  472. else
  473. if(i == 12)
  474. value = stream.readDWord();
  475. else
  476. if(i == 16)
  477. membersObject = true;
  478. else
  479. if(i == 23)
  480. {
  481. anInt165 = stream.readUnsignedWord();
  482. aByte205 = stream.readSignedByte();
  483. } else
  484. if(i == 24)
  485. anInt188 = stream.readUnsignedWord();
  486. else
  487. if(i == 25)
  488. {
  489. anInt200 = stream.readUnsignedWord();
  490. aByte154 = stream.readSignedByte();
  491. } else
  492. if(i == 26)
  493. anInt164 = stream.readUnsignedWord();
  494. else
  495. if(i >= 30 && i < 35)
  496. {
  497. if(groundActions == null)
  498. groundActions = new String[5];
  499. groundActions[i - 30] = stream.readString();
  500. if(groundActions[i - 30].equalsIgnoreCase("hidden"))
  501. groundActions[i - 30] = null;
  502. } else
  503. if(i >= 35 && i < 40)
  504. {
  505. if(actions == null)
  506. actions = new String[5];
  507. actions[i - 35] = stream.readString();
  508. } else
  509. if(i == 40)
  510. {
  511. int j = stream.readUnsignedByte();
  512. modifiedModelColors = new int[j];
  513. originalModelColors = new int[j];
  514. for(int k = 0; k < j; k++)
  515. {
  516. modifiedModelColors[k] = stream.readUnsignedWord();
  517. originalModelColors[k] = stream.readUnsignedWord();
  518. }
  519.  
  520. } else
  521. if(i == 78)
  522. anInt185 = stream.readUnsignedWord();
  523. else
  524. if(i == 79)
  525. anInt162 = stream.readUnsignedWord();
  526. else
  527. if(i == 90)
  528. anInt175 = stream.readUnsignedWord();
  529. else
  530. if(i == 91)
  531. anInt197 = stream.readUnsignedWord();
  532. else
  533. if(i == 92)
  534. anInt166 = stream.readUnsignedWord();
  535. else
  536. if(i == 93)
  537. anInt173 = stream.readUnsignedWord();
  538. else
  539. if(i == 95)
  540. anInt204 = stream.readUnsignedWord();
  541. else
  542. if(i == 97)
  543. certID = stream.readUnsignedWord();
  544. else
  545. if(i == 98)
  546. certTemplateID = stream.readUnsignedWord();
  547. else
  548. if(i >= 100 && i < 110)
  549. {
  550. if(stackIDs == null)
  551. {
  552. stackIDs = new int[10];
  553. stackAmounts = new int[10];
  554. }
  555. stackIDs[i - 100] = stream.readUnsignedWord();
  556. stackAmounts[i - 100] = stream.readUnsignedWord();
  557. } else
  558. if(i == 110)
  559. anInt167 = stream.readUnsignedWord();
  560. else
  561. if(i == 111)
  562. anInt192 = stream.readUnsignedWord();
  563. else
  564. if(i == 112)
  565. anInt191 = stream.readUnsignedWord();
  566. else
  567. if(i == 113)
  568. anInt196 = stream.readSignedByte();
  569. else
  570. if(i == 114)
  571. anInt184 = stream.readSignedByte() * 5;
  572. else
  573. if(i == 115)
  574. team = stream.readUnsignedByte();
  575. } while(true);
  576. }
  577.  
  578. private ItemDef()
  579. {
  580. id = -1;
  581. }
  582.  
  583. private byte aByte154;
  584. public int value;
  585. private int[] modifiedModelColors;
  586. public int id;
  587. static MRUNodes mruNodes1 = new MRUNodes(100);
  588. public static MRUNodes mruNodes2 = new MRUNodes(50);
  589. private int[] originalModelColors;
  590. public boolean membersObject;
  591. private int anInt162;
  592. private int certTemplateID;
  593. private int anInt164;
  594. private int anInt165;
  595. private int anInt166;
  596. private int anInt167;
  597. public String groundActions[];
  598. private int modelOffset1;
  599. public String name;
  600. private static ItemDef[] cache;
  601. private int anInt173;
  602. private int modelID;
  603. private int anInt175;
  604. public boolean stackable;
  605. public byte description[];
  606. private int certID;
  607. private static int cacheIndex;
  608. public int modelZoom;
  609. public static boolean isMembers = true;
  610. private static Stream stream;
  611. private int anInt184;
  612. private int anInt185;
  613. private int anInt188;
  614. public String actions[];
  615. public int modelRotation1;
  616. private int anInt191;
  617. private int anInt192;
  618. private int[] stackIDs;
  619. private int modelOffset2;
  620. private static int[] streamIndices;
  621. private int anInt196;
  622. private int anInt197;
  623. public int modelRotation2;
  624. private int anInt200;
  625. private int[] stackAmounts;
  626. public int team;
  627. public static int totalItems;
  628. private int anInt204;
  629. private byte aByte205;
  630.  
  631. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement