Advertisement
Guest User

Itemdef

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