Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Spoiler for How to create a Config Plugin:
- 1. Create a new project
- 2. Add scape-editor.jar as a library to that project
- 3. Define a class like this
- Code:
- package plugin;
- import scape.editor.api.io.RSBuffer;
- import scape.editor.gui.plugin.Plugin;
- import scape.editor.gui.plugin.extension.config.NpcDefinitionExtension;
- @Plugin(name="OSDC Npc Definition Plugin", authors = "Nshusa", version = 1.0)
- public class NpcDefinitionPlugin extends NpcDefinitionExtension {
- @Override
- protected String fileName() {
- return "npc.dat";
- }
- @Override
- protected void decode(int currentIndex, RSBuffer buffer) {
- id = currentIndex;
- while(true) {
- int opcode = buffer.readUByte();
- if (opcode == 0) {
- return;
- } else if (opcode == 1) {
- int len = buffer.readUByte();
- modelId = new int[len];
- for (int i = 0; i < len; i++) {
- modelId[i] = buffer.readUShort();
- }
- } else if (opcode == 2) {
- name = buffer.readString();
- } else if (opcode == 12) {
- size = buffer.readUByte();
- } else if (opcode == 13) {
- standingAnimation = buffer.readUShort();
- } else if (opcode == 14) {
- walkingAnimation = buffer.readUShort();
- } else if (opcode == 15) {
- buffer.readUShort();
- } else if (opcode == 16) {
- buffer.readUShort();
- } else if (opcode == 17) {
- walkingAnimation = buffer.readUShort();
- halfTurnAnimation = buffer.readUShort();
- quarterClockwiseTurnAnimation = buffer.readUShort();
- quarterAnticlockwiseTurnAnimation = buffer.readUShort();
- if (halfTurnAnimation == 65535) {
- halfTurnAnimation = walkingAnimation;
- }
- if (quarterClockwiseTurnAnimation == 65535) {
- quarterClockwiseTurnAnimation = walkingAnimation;
- }
- if (quarterAnticlockwiseTurnAnimation == 65535) {
- quarterAnticlockwiseTurnAnimation = walkingAnimation;
- }
- } else if (opcode >= 30 && opcode < 35) {
- if (actions == null) {
- actions = new String[5];
- }
- actions[opcode - 30] = buffer.readString();
- if (actions[opcode - 30].equalsIgnoreCase("Hidden")) {
- actions[opcode - 30] = null;
- }
- } else if (opcode == 40) {
- int len = buffer.readUByte();
- recolorOriginal = new int[len];
- recolorTarget = new int[len];
- for (int i = 0; i < len; i++) {
- recolorOriginal[i] = buffer.readUShort();
- recolorTarget[i] = buffer.readUShort();
- }
- } else if (opcode == 41) {
- int len = buffer.readUByte();
- for (int i = 0; i < len; i++) {
- buffer.readUShort(); // textures
- buffer.readUShort();
- }
- } else if (opcode == 60) {
- int len = buffer.readUByte();
- additionalModels = new int[len];
- for (int i = 0; i < len; i++) {
- additionalModels[i] = buffer.readUShort();
- }
- } else if (opcode == 93) {
- aBoolean87 = false;
- } else if (opcode == 95)
- combatLevel = buffer.readUShort();
- else if (opcode == 97)
- scaleXZ = buffer.readUShort();
- else if (opcode == 98)
- scaleY = buffer.readUShort();
- else if (opcode == 99)
- aBoolean93 = true;
- else if (opcode == 100)
- lightModifier = buffer.readByte();
- else if (opcode == 101)
- shadowModifier = buffer.readByte();
- else if (opcode == 102)
- headIcon = buffer.readUShort();
- else if (opcode == 103)
- rotation = buffer.readUShort();
- else if (opcode == 106 || opcode == 118) {
- varbit = buffer.readUShort();
- if (varbit == 65535) {
- varbit = -1;
- }
- varp = buffer.readUShort();
- if (varp == 65535) {
- varp = -1;
- }
- int value = -1;
- if (opcode == 118) {
- value = buffer.readUShort();
- }
- int len = buffer.readUByte();
- morphisms = new int[len + 2];
- for (int i = 0; i <= len; i++) {
- morphisms[i] = buffer.readUShort();
- if (morphisms[i] == 65535) {
- morphisms[i] = -1;
- }
- }
- morphisms[len + 1] = value;
- } else if (opcode == 109) {
- aBoolean84 = false;
- } else if (opcode == 107 || opcode == 111) {
- } else {
- System.out.println(String.format("npc def invalid opcode: %d", opcode));
- }
- }
- }
- public int id = -1;
- public int quarterAnticlockwiseTurnAnimation = -1;
- public int varbit = -1;
- public int halfTurnAnimation = -1;
- public int varp = -1;
- public int combatLevel = -1;
- public final int anInt64 = 1834;
- public String name;
- public String actions[];
- public int walkingAnimation = -1;
- public int size = 1;
- public int[] recolorTarget;
- public int[] additionalModels;
- public int headIcon = -1;
- public int[] recolorOriginal;
- public int standingAnimation = -1;
- public long interfaceType = -1L;
- public int rotation = 32;
- public int quarterClockwiseTurnAnimation = -1;
- public boolean aBoolean84 = true;
- public int lightModifier;
- public int scaleY = 128;
- public boolean aBoolean87 = true;
- public int morphisms[];
- public int scaleXZ = 128;
- public int shadowModifier;
- public boolean aBoolean93;
- public int[] modelId;
- public int interfaceZoom = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement