Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2019
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.15 KB | None | 0 0
  1. /** Object **/
  2.  
  3. public void readValues(Buffer stream) { int flag = -1;
  4. do {
  5. int type = stream.readUnsignedByte();
  6. if (type == 0)
  7. break;
  8. if (type == 1) {
  9. int len = stream.readUnsignedByte();
  10. if (len > 0) {
  11. if (modelIds == null || lowMemory) {
  12. modelTypes = new int[len];
  13. modelIds = new int[len];
  14. for (int k1 = 0; k1 < len; k1++) {
  15. modelIds[k1] = stream.readUShort();
  16. modelTypes[k1] = stream.readUnsignedByte();
  17. }
  18. } else {
  19. stream.currentPosition += len * 3;
  20. }
  21. }
  22. } else if (type == 2)
  23. name = stream.readString();
  24. else if (type == 3)
  25. description = stream.readString();
  26. else if (type == 5) {
  27. int len = stream.readUnsignedByte();
  28. if (len > 0) {
  29. if (modelIds == null || lowMemory) {
  30. modelTypes = null;
  31. modelIds = new int[len];
  32. for (int l1 = 0; l1 < len; l1++)
  33. modelIds[l1] = stream.readUShort();
  34. } else {
  35. stream.currentPosition += len * 2;
  36. }
  37. }
  38. } else if (type == 14)
  39. objectSizeX = stream.readUnsignedByte();
  40. else if (type == 15)
  41. objectSizeY = stream.readUnsignedByte();
  42. else if (type == 17)
  43. solid = false;
  44. else if (type == 18)
  45. impenetrable = false;
  46. else if (type == 19)
  47. isInteractive = (stream.readUnsignedByte() == 1);
  48. else if (type == 21)
  49. contouredGround = true;
  50. else if (type == 22)
  51. delayShading = false;
  52. else if (type == 23)
  53. occludes = true;
  54. else if (type == 24) {
  55. animation = stream.readUShort();
  56. if (animation == 65535)
  57. animation = -1;
  58. } else if (type == 28)
  59. decorDisplacement = stream.readUnsignedByte();
  60. else if (type == 29)
  61. ambientLighting = stream.readSignedByte();
  62. else if (type == 39)
  63. lightDiffusion = stream.readSignedByte() ;
  64. else if (type >= 30 && type < 35) {
  65. if (interactions == null)
  66. interactions = new String[5];
  67. interactions[type - 30] = stream.readString();
  68. if (interactions[type - 30].equalsIgnoreCase("hidden"))
  69. interactions[type - 30] = null;
  70. } else if (type == 40) {
  71. int i1 = stream.readUnsignedByte();
  72. modifiedModelColors = new int[i1];
  73. originalModelColors = new int[i1];
  74. for (int i2 = 0; i2 < i1; i2++) {
  75. modifiedModelColors[i2] = stream.readUShort();
  76. originalModelColors[i2] = stream.readUShort();
  77. }
  78. } else if (type == 41) {
  79. int j2 = stream.readUnsignedByte();
  80. modifiedTexture = new short[j2];
  81. originalTexture = new short[j2];
  82. for (int k = 0; k < j2; k++) {
  83. modifiedTexture[k] = (short) stream.readUShort();
  84. originalTexture[k] = (short) stream.readUShort();
  85. }
  86. }
  87.  
  88. else if (type == 62)
  89. inverted = true;
  90. else if (type == 64)
  91. castsShadow = false;
  92. else if (type == 65)
  93. scaleX = stream.readUShort();
  94. else if (type == 66)
  95. scaleY = stream.readUShort();
  96. else if (type == 67)
  97. scaleZ = stream.readUShort();
  98. else if (type == 68)
  99. mapscene = stream.readUShort();
  100. else if (type == 69)
  101. surroundings = stream.readUnsignedByte();
  102. else if (type == 70)
  103. translateX = stream.readShort();
  104. else if (type == 71)
  105. translateY = stream.readShort();
  106. else if (type == 72)
  107. translateZ = stream.readShort();
  108. else if (type == 73)
  109. obstructsGround = true;
  110. else if (type == 74)
  111. hollow = true;
  112. else if (type == 75)
  113. supportItems = stream.readUnsignedByte();
  114. else if (type == 78) {
  115. ambientsound = stream.readUShort(); // ambient sound id
  116. stream.readUnsignedByte();
  117. } else if (type == 79) {
  118. stream.readUShort();
  119. stream.readUShort();
  120. stream.readUnsignedByte();
  121. int len = stream.readUnsignedByte();
  122.  
  123. for (int i = 0; i < len; i++) {
  124. stream.readUShort();
  125. }
  126. } else if (type == 81) {
  127. stream.readUnsignedByte();
  128. } else if (type == 60) {
  129. minimapFunction = stream.readUShort();
  130. } else if (type == 77 || type == 92) {
  131. varp = stream.readUShort();
  132.  
  133. if (varp == 0xFFFF) {
  134. varp = -1;
  135. }
  136.  
  137. varbit = stream.readUShort();
  138.  
  139. if (varbit == 0xFFFF) {
  140. varbit = -1;
  141. }
  142.  
  143. int value = -1;
  144.  
  145. if (type == 92) {
  146. value = stream.readUShort();
  147.  
  148. if (value == 0xFFFF) {
  149. value = -1;
  150. }
  151. }
  152.  
  153. int len = stream.readUnsignedByte();
  154.  
  155. morphisms = new int[len + 2];
  156. for (int i = 0; i <= len; ++i) {
  157. morphisms[i] = stream.readUShort();
  158. if (morphisms[i] == 0xFFFF) {
  159. morphisms[i] = -1;
  160. }
  161. }
  162. morphisms[len + 1] = value;
  163. }
  164. } while (true);
  165. if (flag == -1 && name != "null" && name != null) {
  166. isInteractive = modelIds != null
  167. && (modelTypes == null || modelTypes[0] == 10);
  168. if (interactions != null)
  169. isInteractive = true;
  170. }
  171. if (hollow) {
  172. solid = false;
  173. impenetrable = false;
  174. }
  175. if (supportItems == -1)
  176. supportItems = solid ? 1 : 0;
  177. }
  178.  
  179.  
  180.  
  181. /** NPC **/
  182.  
  183.  
  184. public void readValues(Buffer stream) {
  185. do {
  186. int opCode = stream.readUnsignedByte();
  187. if (opCode == 0)
  188. return;
  189. if (opCode == 1) {
  190. int j = stream.readUnsignedByte();
  191. modelId = new int[j];
  192. for (int j1 = 0; j1 < j; j1++)
  193. modelId[j1] = stream.readUShort();
  194.  
  195. } else if (opCode == 2)
  196. name = stream.readString();
  197. else if (opCode == 3)
  198. description = stream.readBytes();
  199. else if (opCode == 12)
  200. size = stream.readSignedByte();
  201. else if (opCode == 13)
  202. standAnim = stream.readUShort();
  203. else if (opCode == 14)
  204. walkAnim = stream.readUShort();
  205. else if (opCode == 17) {
  206. walkAnim = stream.readUShort();
  207. turn180AnimIndex = stream.readUShort();
  208. turn90CWAnimIndex = stream.readUShort();
  209. turn90CCWAnimIndex = stream.readUShort();
  210. } else if (opCode >= 30 && opCode < 40) {
  211. if (actions == null)
  212. actions = new String[5];
  213. actions[opCode - 30] = stream.readString();
  214. if (actions[opCode - 30].equalsIgnoreCase("hidden"))
  215. actions[opCode - 30] = null;
  216. } else if (opCode == 40) {
  217. int colours = stream.readUnsignedByte();
  218. recolourOriginal = new int[colours];
  219. recolourTarget = new int[colours];
  220. for (int k1 = 0; k1 < colours; k1++) {
  221. recolourOriginal[k1] = stream.readUShort();
  222. recolourTarget[k1] = stream.readUShort();
  223. }
  224.  
  225. } else if (opCode == 60) {
  226. int additionalModelLen = stream.readUnsignedByte();
  227. additionalModels = new int[additionalModelLen];
  228. for (int l1 = 0; l1 < additionalModelLen; l1++)
  229. additionalModels[l1] = stream.readUShort();
  230.  
  231. } else if (opCode == 90)
  232. stream.readUShort();
  233. else if (opCode == 91)
  234. stream.readUShort();
  235. else if (opCode == 92)
  236. stream.readUShort();
  237. else if (opCode == 93)
  238. drawMinimapDot = false;
  239. else if (opCode == 95)
  240. combatLevel = stream.readUShort();
  241. else if (opCode == 97)
  242. scaleXZ = stream.readUShort();
  243. else if (opCode == 98)
  244. scaleY = stream.readUShort();
  245. else if (opCode == 99)
  246. priorityRender = true;
  247. else if (opCode == 100)
  248. lightModifier = stream.readSignedByte();
  249. else if (opCode == 101)
  250. shadowModifier = stream.readSignedByte() * 5;
  251. else if (opCode == 102)
  252. headIcon = stream.readUShort();
  253. else if (opCode == 103)
  254. degreesToTurn = stream.readUShort();
  255. else if (opCode == 106) {
  256. varBitID = stream.readUShort();
  257. if (varBitID == 65535)
  258. varBitID = -1;
  259. settingId = stream.readUShort();
  260. if (settingId == 65535)
  261. settingId = -1;
  262. int value = -1;
  263.  
  264. if (opCode == 118) {
  265. value = stream.readUShort();
  266. }
  267. int childCount = stream.readUnsignedByte();
  268. childrenIDs = new int[childCount + 2];
  269. for (int i2 = 0; i2 <= childCount; i2++) {
  270. childrenIDs[i2] = stream.readUShort();
  271. if (childrenIDs[i2] == 65535)
  272. childrenIDs[i2] = -1;
  273. }
  274. childrenIDs[childCount + 1] = value;
  275.  
  276. } else if (opCode == 109)
  277. clickable = false;
  278. else if (opCode == 107 || opCode == 111) {
  279. aBoolean84 = false;
  280. } else {
  281. System.out.println(String.format("npc def invalid opcode: %d", opCode));
  282. }
  283. } while (true);
  284. }
  285.  
  286. /** Items **/
  287.  
  288. public void readValues(Buffer buffer) {
  289. do {
  290. int opCode = buffer.readUnsignedByte();
  291. if (opCode == 0)
  292. return;
  293. if (opCode == 1)
  294. inventory_model = buffer.readUShort();
  295. else if (opCode == 2)
  296. name = buffer.readString();
  297. else if (opCode == 3)
  298. description = buffer.readString();
  299. else if (opCode == 4)
  300. model_zoom = buffer.readUShort();
  301. else if (opCode == 5)
  302. rotation_y = buffer.readUShort();
  303. else if (opCode == 6)
  304. rotation_x = buffer.readUShort();
  305. else if (opCode == 7) {
  306. translate_x = buffer.readUShort();
  307. if (translate_x > 32767)
  308. translate_x -= 0x10000;
  309. } else if (opCode == 8) {
  310. translate_yz = buffer.readUShort();
  311. if (translate_yz > 32767)
  312. translate_yz -= 0x10000;
  313. } else if (opCode == 10)
  314. buffer.readUShort();
  315. else if (opCode == 11)
  316. stackable = true;
  317. else if (opCode == 12) {
  318. value = buffer.readInt();
  319. } else if (opCode == 16)
  320. is_members_only = true;
  321. else if (opCode == 23) {
  322. equipped_model_male_1 = buffer.readUShort();
  323. equipped_model_male_translation_y = buffer.readSignedByte();
  324. } else if (opCode == 24)
  325. equipped_model_male_2 = buffer.readUShort();
  326. else if (opCode == 25) {
  327. equipped_model_female_1 = buffer.readUShort();
  328. equipped_model_female_translation_y = buffer.readSignedByte();
  329. } else if (opCode == 26)
  330. equipped_model_female_2 = buffer.readUShort();
  331. else if (opCode >= 30 && opCode < 35) {
  332. if (groundActions == null)
  333. groundActions = new String[5];
  334. groundActions[opCode - 30] = buffer.readString();
  335. if (groundActions[opCode - 30].equalsIgnoreCase("hidden"))
  336. groundActions[opCode - 30] = null;
  337. } else if (opCode >= 35 && opCode < 40) {
  338. if (actions == null)
  339. actions = new String[5];
  340. actions[opCode - 35] = buffer.readString();
  341. } else if (opCode == 40) {
  342. int j = buffer.readUnsignedByte();
  343. original_model_colours = new int[j];
  344. modified_model_colours = new int[j];
  345. for (int k = 0; k < j; k++) {
  346. modified_model_colours[k] = buffer.readUShort();
  347. original_model_colours[k] = buffer.readUShort();
  348. }
  349. } else if (opCode == 41) {
  350. int j = buffer.readUnsignedByte();
  351. textureToReplace = new int[j];
  352. textureToReplaceWith = new int[j];
  353. for (int k = 0; k < j; k++) {
  354. textureToReplace[k] = buffer.readUShort();
  355. textureToReplaceWith[k] = buffer.readUShort();
  356. }
  357. } else if (opCode == 78)
  358. equipped_model_male_3 = buffer.readUShort();
  359. else if (opCode == 42)
  360. shiftClickIndex = buffer.readUShort();
  361. else if (opCode == 65)
  362. searchable = true;
  363. else if (opCode == 79)
  364. equipped_model_female_3 = buffer.readUShort();
  365. else if (opCode == 90)
  366. equipped_model_male_dialogue_1 = buffer.readUShort();
  367. else if (opCode == 91)
  368. equipped_model_female_dialogue_1 = buffer.readUShort();
  369. else if (opCode == 92)
  370. equipped_model_male_dialogue_2 = buffer.readUShort();
  371. else if (opCode == 93)
  372. equipped_model_female_dialogue_2 = buffer.readUShort();
  373. else if (opCode == 95)
  374. rotation_z = buffer.readUShort();
  375. else if (opCode == 97)
  376. unnoted_item_id = buffer.readUShort();
  377. else if (opCode == 98)
  378. noted_item_id = buffer.readUShort();
  379. else if (opCode >= 100 && opCode < 110) {
  380.  
  381. if (stack_variant_id == null) {
  382. stack_variant_id = new int[10];
  383. stack_variant_size = new int[10];
  384. }
  385. stack_variant_id[opCode - 100] = buffer.readUShort();
  386. stack_variant_size[opCode - 100] = buffer.readUShort();
  387. } else if (opCode == 110)
  388. model_scale_x = buffer.readUShort();
  389. else if (opCode == 111)
  390. model_scale_y = buffer.readUShort();
  391. else if (opCode == 112)
  392. model_scale_z = buffer.readUShort();
  393. else if (opCode == 113)
  394. ambient = buffer.readSignedByte();
  395. else if (opCode == 114)
  396. contrast = buffer.readSignedByte();
  397. else if (opCode == 115)
  398. team = buffer.readUnsignedByte();
  399. else if (opCode == 139) {
  400. unnoted_item_id = buffer.readUShort(); // un-noted id
  401. } else if (opCode == 140) {
  402. noted_item_id = buffer.readUShort(); // noted id
  403. } else if (opCode == 148) {
  404. placeHolderId = buffer.readUShort(); // placeholder id
  405. } else if (opCode == 149) {
  406. placeHolderTemplate = buffer.readUShort(); // placeholder template
  407. }
  408. } while (true);
  409. }
  410.  
  411. /** Animation **/
  412. private void decode(Buffer buffer) {
  413. while(true) {
  414. final int opcode = buffer.readUByte();
  415.  
  416. if (opcode == 0) {
  417. break;
  418. } else if (opcode == 1) {
  419. frameCount = buffer.readUShort();
  420. primaryFrames = new int[frameCount];
  421. secondaryFrames = new int[frameCount];
  422. durations = new int[frameCount];
  423.  
  424. for (int i = 0; i < frameCount; i++) {
  425. durations[i] = buffer.readUShort();
  426. }
  427.  
  428. for (int i = 0; i < frameCount; i++) {
  429. primaryFrames[i] = buffer.readUShort();
  430. secondaryFrames[i] = -1;
  431. }
  432.  
  433. for (int i = 0; i < frameCount; i++) {
  434. primaryFrames[i] += buffer.readUShort() << 16;
  435. }
  436. } else if (opcode == 2) {
  437. loopOffset = buffer.readUShort();
  438. } else if (opcode == 3) {
  439. int len = buffer.readUByte();
  440. interleaveOrder = new int[len + 1];
  441. for (int i = 0; i < len; i++) {
  442. interleaveOrder[i] = buffer.readUByte();
  443. }
  444. interleaveOrder[len] = 9999999;
  445. } else if (opcode == 4) {
  446. stretches = true;
  447. } else if (opcode == 5) {
  448. forcedPriority = buffer.readUByte();
  449. } else if (opcode == 6) {
  450. playerOffhand = buffer.readUShort();
  451. } else if (opcode == 7) {
  452. playerMainhand = buffer.readUShort();
  453. } else if (opcode == 8) {
  454. maximumLoops = buffer.readUByte();
  455. } else if (opcode == 9) {
  456. animatingPrecedence = buffer.readUByte();
  457. } else if (opcode == 10) {
  458. priority = buffer.readUByte();
  459. } else if (opcode == 11) {
  460. replayMode = buffer.readUByte();
  461. } else if (opcode == 12) {
  462. int len = buffer.readUByte();
  463.  
  464. for (int i = 0; i < len; i++) {
  465. buffer.readUShort();
  466. }
  467.  
  468. for (int i = 0; i < len; i++) {
  469. buffer.readUShort();
  470. }
  471. } else if (opcode == 13) {
  472. int len = buffer.readUByte();
  473.  
  474. for (int i = 0; i < len; i++) {
  475. buffer.readTriByte();
  476. }
  477. }
  478. }
  479.  
  480. if (frameCount == 0) {
  481. frameCount = 1;
  482. primaryFrames = new int[1];
  483. primaryFrames[0] = -1;
  484. secondaryFrames = new int[1];
  485. secondaryFrames[0] = -1;
  486. durations = new int[1];
  487. durations[0] = -1;
  488. }
  489.  
  490. if (animatingPrecedence == -1) {
  491. animatingPrecedence = (interleaveOrder == null) ? 0 : 2;
  492. }
  493.  
  494. if (priority == -1) {
  495. priority = (interleaveOrder == null) ? 0 : 2;
  496. }
  497. }
  498.  
  499.  
  500. /**
  501. * Dumps animations
  502. */
  503. private void decode(Buffer buffer) {
  504. while(true) {
  505. final int opcode = buffer.readUByte();
  506.  
  507. if (opcode == 0) {
  508. break;
  509. } else if (opcode == 1) {
  510. frameCount = buffer.readUShort();
  511. primaryFrames = new int[frameCount];
  512. secondaryFrames = new int[frameCount];
  513. durations = new int[frameCount];
  514.  
  515. for (int i = 0; i < frameCount; i++) {
  516. durations[i] = buffer.readUShort();
  517. }
  518.  
  519. for (int i = 0; i < frameCount; i++) {
  520. primaryFrames[i] = buffer.readUShort();
  521. secondaryFrames[i] = -1;
  522. }
  523.  
  524. for (int i = 0; i < frameCount; i++) {
  525. primaryFrames[i] += buffer.readUShort() << 16;
  526. }
  527. } else if (opcode == 2) {
  528. loopOffset = buffer.readUShort();
  529. } else if (opcode == 3) {
  530. int len = buffer.readUByte();
  531. interleaveOrder = new int[len + 1];
  532. for (int i = 0; i < len; i++) {
  533. interleaveOrder[i] = buffer.readUByte();
  534. }
  535. interleaveOrder[len] = 9999999;
  536. } else if (opcode == 4) {
  537. stretches = true;
  538. } else if (opcode == 5) {
  539. forcedPriority = buffer.readUByte();
  540. } else if (opcode == 6) {
  541. playerOffhand = buffer.readUShort();
  542. } else if (opcode == 7) {
  543. playerMainhand = buffer.readUShort();
  544. } else if (opcode == 8) {
  545. maximumLoops = buffer.readUByte();
  546. } else if (opcode == 9) {
  547. animatingPrecedence = buffer.readUByte();
  548. } else if (opcode == 10) {
  549. priority = buffer.readUByte();
  550. } else if (opcode == 11) {
  551. replayMode = buffer.readUByte();
  552. } else if (opcode == 12) {
  553. int len = buffer.readUByte();
  554.  
  555. for (int i = 0; i < len; i++) {
  556. buffer.readUShort();
  557. }
  558.  
  559. for (int i = 0; i < len; i++) {
  560. buffer.readUShort();
  561. }
  562. } else if (opcode == 13) {
  563. int len = buffer.readUByte();
  564.  
  565. for (int i = 0; i < len; i++) {
  566. buffer.readTriByte();
  567. }
  568. }
  569. }
  570.  
  571. if (frameCount == 0) {
  572. frameCount = 1;
  573. primaryFrames = new int[1];
  574. primaryFrames[0] = -1;
  575. secondaryFrames = new int[1];
  576. secondaryFrames[0] = -1;
  577. durations = new int[1];
  578. durations[0] = -1;
  579. }
  580.  
  581. if (animatingPrecedence == -1) {
  582. animatingPrecedence = (interleaveOrder == null) ? 0 : 2;
  583. }
  584.  
  585. if (priority == -1) {
  586. priority = (interleaveOrder == null) ? 0 : 2;
  587. }
  588. }
  589.  
  590.  
  591. /*Floor / Underlay (Zion)*
  592.  
  593. private void readValuesUnderlay(ByteBuffer buffer) {
  594. for (;;) {
  595. int opcode = buffer.get();
  596. if (opcode == 0) {
  597. break;
  598. } else if (opcode == 1) {
  599. rgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
  600. } else {
  601. System.out.println("Error unrecognised underlay code: " + opcode);
  602. }
  603. }
  604. }
  605.  
  606. private void readValuesOverlay(ByteBuffer buffer) {
  607. for (;;) {
  608. int opcode = buffer.get();
  609. if (opcode == 0) {
  610. break;
  611. } else if (opcode == 1) {
  612. rgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
  613. } else if (opcode == 2) {
  614. texture = buffer.get() & 0xff;
  615. } else if (opcode == 5) {
  616. occlude = false;
  617. } else if (opcode == 7) {
  618. anotherRgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
  619. } else {
  620. System.out.println("Error unrecognised overlay code: " + opcode);
  621. }
  622. }
  623. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement