Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.33 KB | None | 0 0
  1. Spoiler for How to create a Config Plugin:
  2.  
  3. 1. Create a new project
  4. 2. Add scape-editor.jar as a library to that project
  5. 3. Define a class like this
  6.  
  7. Code:
  8. package plugin;
  9.  
  10. import scape.editor.api.io.RSBuffer;
  11. import scape.editor.gui.plugin.Plugin;
  12. import scape.editor.gui.plugin.extension.config.NpcDefinitionExtension;
  13.  
  14. @Plugin(name="OSDC Npc Definition Plugin", authors = "Nshusa", version = 1.0)
  15. public class NpcDefinitionPlugin extends NpcDefinitionExtension {
  16.  
  17. @Override
  18. protected String fileName() {
  19. return "npc.dat";
  20. }
  21.  
  22. @Override
  23. protected void decode(int currentIndex, RSBuffer buffer) {
  24. id = currentIndex;
  25. while(true) {
  26. int opcode = buffer.readUByte();
  27. if (opcode == 0) {
  28. return;
  29. } else if (opcode == 1) {
  30. int len = buffer.readUByte();
  31. modelId = new int[len];
  32. for (int i = 0; i < len; i++) {
  33. modelId[i] = buffer.readUShort();
  34. }
  35. } else if (opcode == 2) {
  36. name = buffer.readString();
  37. } else if (opcode == 12) {
  38. size = buffer.readUByte();
  39. } else if (opcode == 13) {
  40. standingAnimation = buffer.readUShort();
  41. } else if (opcode == 14) {
  42. walkingAnimation = buffer.readUShort();
  43. } else if (opcode == 15) {
  44. buffer.readUShort();
  45. } else if (opcode == 16) {
  46. buffer.readUShort();
  47. } else if (opcode == 17) {
  48. walkingAnimation = buffer.readUShort();
  49. halfTurnAnimation = buffer.readUShort();
  50. quarterClockwiseTurnAnimation = buffer.readUShort();
  51. quarterAnticlockwiseTurnAnimation = buffer.readUShort();
  52. if (halfTurnAnimation == 65535) {
  53. halfTurnAnimation = walkingAnimation;
  54. }
  55. if (quarterClockwiseTurnAnimation == 65535) {
  56. quarterClockwiseTurnAnimation = walkingAnimation;
  57. }
  58. if (quarterAnticlockwiseTurnAnimation == 65535) {
  59. quarterAnticlockwiseTurnAnimation = walkingAnimation;
  60. }
  61. } else if (opcode >= 30 && opcode < 35) {
  62. if (actions == null) {
  63. actions = new String[5];
  64. }
  65.  
  66. actions[opcode - 30] = buffer.readString();
  67.  
  68. if (actions[opcode - 30].equalsIgnoreCase("Hidden")) {
  69. actions[opcode - 30] = null;
  70. }
  71. } else if (opcode == 40) {
  72. int len = buffer.readUByte();
  73. recolorOriginal = new int[len];
  74. recolorTarget = new int[len];
  75. for (int i = 0; i < len; i++) {
  76. recolorOriginal[i] = buffer.readUShort();
  77. recolorTarget[i] = buffer.readUShort();
  78. }
  79.  
  80. } else if (opcode == 41) {
  81. int len = buffer.readUByte();
  82.  
  83. for (int i = 0; i < len; i++) {
  84. buffer.readUShort(); // textures
  85. buffer.readUShort();
  86. }
  87. } else if (opcode == 60) {
  88. int len = buffer.readUByte();
  89. additionalModels = new int[len];
  90. for (int i = 0; i < len; i++) {
  91. additionalModels[i] = buffer.readUShort();
  92. }
  93. } else if (opcode == 93) {
  94. aBoolean87 = false;
  95. } else if (opcode == 95)
  96. combatLevel = buffer.readUShort();
  97. else if (opcode == 97)
  98. scaleXZ = buffer.readUShort();
  99. else if (opcode == 98)
  100. scaleY = buffer.readUShort();
  101. else if (opcode == 99)
  102. aBoolean93 = true;
  103. else if (opcode == 100)
  104. lightModifier = buffer.readByte();
  105. else if (opcode == 101)
  106. shadowModifier = buffer.readByte();
  107. else if (opcode == 102)
  108. headIcon = buffer.readUShort();
  109. else if (opcode == 103)
  110. rotation = buffer.readUShort();
  111. else if (opcode == 106 || opcode == 118) {
  112. varbit = buffer.readUShort();
  113.  
  114. if (varbit == 65535) {
  115. varbit = -1;
  116. }
  117.  
  118. varp = buffer.readUShort();
  119.  
  120. if (varp == 65535) {
  121. varp = -1;
  122. }
  123.  
  124. int value = -1;
  125.  
  126. if (opcode == 118) {
  127. value = buffer.readUShort();
  128. }
  129.  
  130. int len = buffer.readUByte();
  131. morphisms = new int[len + 2];
  132. for (int i = 0; i <= len; i++) {
  133. morphisms[i] = buffer.readUShort();
  134. if (morphisms[i] == 65535) {
  135. morphisms[i] = -1;
  136. }
  137. }
  138. morphisms[len + 1] = value;
  139. } else if (opcode == 109) {
  140. aBoolean84 = false;
  141. } else if (opcode == 107 || opcode == 111) {
  142.  
  143. } else {
  144. System.out.println(String.format("npc def invalid opcode: %d", opcode));
  145. }
  146. }
  147. }
  148.  
  149. public int id = -1;
  150. public int quarterAnticlockwiseTurnAnimation = -1;
  151. public int varbit = -1;
  152. public int halfTurnAnimation = -1;
  153. public int varp = -1;
  154. public int combatLevel = -1;
  155. public final int anInt64 = 1834;
  156. public String name;
  157. public String actions[];
  158. public int walkingAnimation = -1;
  159. public int size = 1;
  160. public int[] recolorTarget;
  161. public int[] additionalModels;
  162. public int headIcon = -1;
  163. public int[] recolorOriginal;
  164. public int standingAnimation = -1;
  165. public long interfaceType = -1L;
  166. public int rotation = 32;
  167. public int quarterClockwiseTurnAnimation = -1;
  168. public boolean aBoolean84 = true;
  169. public int lightModifier;
  170. public int scaleY = 128;
  171. public boolean aBoolean87 = true;
  172. public int morphisms[];
  173. public int scaleXZ = 128;
  174. public int shadowModifier;
  175. public boolean aBoolean93;
  176. public int[] modelId;
  177. public int interfaceZoom = 0;
  178.  
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement