├── .gitignore ├── README.md ├── lib └── commons-codec-1.7.jar ├── src ├── condition │ ├── Character.java │ ├── Condition.java │ └── Location.java ├── npc │ ├── NPC.java │ └── NPCMessage.java ├── packet │ └── Reader.java ├── player │ └── Player.java └── server │ ├── NPCScriptGenerator.java │ └── instruction │ ├── Instruction.java │ ├── Mesos.java │ └── Warp.java └── start.bat /.gitignore: -------------------------------------------------------------------------------- 1 | /nbproject/private/ 2 | /build/ 3 | /dist/ 4 | /nbproject/* 5 | build.xml 6 | manifest.mf 7 | .DS_Store 8 | /test/ 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NpcScriptGenerator 2 | ###### MapleStory NPC Script Generator 楓之谷私服的NPC代碼產生器 3 | 4 | - 使用SnowSniffer聽取封包並自動產生NPC代碼 5 | https://github.com/anhtanh95/snowsniffer 6 | - 封包log檔請跟編譯後的jar檔放一起,名稱可以自行在編譯時定義。 7 | - 雙擊start後即可執行,並會自動讀取封包檔案產出NPC的Script。 8 | -------------------------------------------------------------------------------- /lib/commons-codec-1.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/s884812/NpcScriptGenerator/77d8a6a5fb9549312a753a45b6cb3e8d0b92ba79/lib/commons-codec-1.7.jar -------------------------------------------------------------------------------- /src/condition/Character.java: -------------------------------------------------------------------------------- 1 | package condition; 2 | 3 | /** 4 | * 5 | * @author XxOsirisxX 6 | */ 7 | public class Character extends Condition { 8 | 9 | private int level; 10 | private int mesos; 11 | 12 | public int getLevel() { 13 | return level; 14 | } 15 | 16 | public void setLevel(int level) { 17 | this.level = level; 18 | } 19 | 20 | public int getMesos() { 21 | return mesos; 22 | } 23 | 24 | public void setMesos(int mesos) { 25 | this.mesos = mesos; 26 | } 27 | 28 | 29 | } -------------------------------------------------------------------------------- /src/condition/Condition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package condition; 7 | 8 | /** 9 | * 10 | * @author s884812 11 | */ 12 | public class Condition { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/condition/Location.java: -------------------------------------------------------------------------------- 1 | package condition; 2 | 3 | /** 4 | * 5 | * @author XxOsirisxX 6 | */ 7 | public class Location extends Condition { 8 | 9 | private int mapId; 10 | private short xposition; 11 | private short yposition; 12 | 13 | public int getMapId() { 14 | return mapId; 15 | } 16 | 17 | public void setMapId(int mapId) { 18 | this.mapId = mapId; 19 | } 20 | 21 | public short getXposition() { 22 | return xposition; 23 | } 24 | 25 | public void setXposition(short xposition) { 26 | this.xposition = xposition; 27 | } 28 | 29 | public short getYposition() { 30 | return yposition; 31 | } 32 | 33 | public void setYposition(short yposition) { 34 | this.yposition = yposition; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/npc/NPC.java: -------------------------------------------------------------------------------- 1 | package npc; 2 | 3 | import condition.Condition; 4 | import condition.Location; 5 | import java.util.LinkedHashMap; 6 | import java.util.LinkedList; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.Map.Entry; 10 | import player.Player; 11 | import server.instruction.Instruction; 12 | 13 | /** 14 | * 15 | * @author XxOsirisxX 16 | */ 17 | public class NPC { 18 | 19 | private static int messageChainId = 0; 20 | private final int id; 21 | private Map> messages; 22 | 23 | public NPC(int id) { 24 | this.id = id; 25 | } 26 | 27 | public void applyConversation(int flow, Player player, int messageType, String message, byte messageButtons, int selectedOption, List instructions) { 28 | if (messages == null) { 29 | messages = new LinkedHashMap>(); 30 | } 31 | if (flow == 0) { 32 | messageChainId++; 33 | } 34 | NPCMessage newMessage = new NPCMessage(messageChainId, player, messageType, message, messageButtons, selectedOption, instructions, null); 35 | List actualMessages = new LinkedList(); 36 | if (messages.get(flow) != null) { 37 | boolean repeated = false; 38 | for (NPCMessage m : messages.get(flow)) { 39 | if (m.getMessage().equals(newMessage.getMessage())) { 40 | repeated = true; 41 | break; 42 | } 43 | } 44 | if (repeated) { 45 | return; 46 | } 47 | 48 | actualMessages = messages.get(flow); 49 | byte conditionType = 0; 50 | for (int i = 0; i < messages.get(flow).size(); i++) { 51 | List oldCondition; 52 | NPCMessage storedMessage = messages.get(flow).get(i); 53 | if (storedMessage.getConditions() != null) { 54 | oldCondition = storedMessage.getConditions(); 55 | } else { 56 | oldCondition = new LinkedList(); 57 | } 58 | if (storedMessage.getPlayer().getMapId() != player.getMapId()) { 59 | conditionType |= 1; 60 | boolean repeatedCondition = false; 61 | if (storedMessage.getConditions() != null) { 62 | for (Condition c : storedMessage.getConditions()) { 63 | if (c instanceof Location) { 64 | repeatedCondition = true; 65 | break; 66 | } 67 | } 68 | } 69 | if (repeatedCondition) { 70 | continue; 71 | } 72 | Location location = new Location(); 73 | location.setMapId(storedMessage.getPlayer().getMapId()); 74 | oldCondition.add(location); 75 | storedMessage.setConditions(oldCondition); 76 | } 77 | } 78 | List newCondition = new LinkedList(); 79 | if ((conditionType & 0x01) == 0x01) { 80 | Location location = new Location(); 81 | location.setMapId(player.getMapId()); 82 | newCondition.add(location); 83 | newMessage.setConditions(newCondition); 84 | } 85 | } 86 | actualMessages.add(newMessage); 87 | messages.put(flow, actualMessages); 88 | } 89 | 90 | public void adjustConditions() { 91 | for (Entry allMessages : messages.entrySet()) { 92 | List npcMessages = (List) allMessages.getValue(); 93 | List npcMessages2 = (List) allMessages.getValue(); 94 | for (NPCMessage message : npcMessages) { 95 | if (message.getConditions() != null) { 96 | int uniqueId = 0; 97 | Condition locationCondition = null; 98 | for (Condition conditions : message.getConditions()) { 99 | if (conditions instanceof Location) { 100 | uniqueId = message.getMessageChainId(); 101 | locationCondition = conditions; 102 | } 103 | } 104 | if (uniqueId > 0) { 105 | 106 | for (List msg : messages.values()) { 107 | for (NPCMessage messagex : msg) { 108 | if (messagex.getMessageChainId() == uniqueId) { 109 | if (messagex.getConditions() == null) { 110 | messagex.setConditions(message.getConditions()); 111 | } else { 112 | List conditions = messagex.getConditions(); 113 | boolean ignore = false; 114 | for (Condition all : conditions) { 115 | if (all instanceof Location) { 116 | ignore = true; 117 | break; 118 | } 119 | } 120 | if (ignore) { 121 | continue; 122 | } 123 | conditions.add(locationCondition); 124 | messagex.setConditions(conditions); 125 | } 126 | } 127 | } 128 | } 129 | } 130 | } 131 | } 132 | } 133 | } 134 | 135 | public int getId() { 136 | return id; 137 | } 138 | 139 | public Map> getMessages() { 140 | return messages; 141 | } 142 | 143 | } -------------------------------------------------------------------------------- /src/npc/NPCMessage.java: -------------------------------------------------------------------------------- 1 | package npc; 2 | 3 | import condition.Condition; 4 | import java.util.List; 5 | import player.Player; 6 | import server.instruction.Instruction; 7 | 8 | /** 9 | * 10 | * @author XxOsirisxX 11 | */ 12 | public class NPCMessage { 13 | 14 | private int messageChainId; 15 | private int messageType; 16 | private int selectedOption; 17 | private byte messageButtons; 18 | private String message; 19 | private List instructions; 20 | private List conditions; 21 | private Player player; 22 | 23 | public NPCMessage(int messageChainId, Player player, int messageType, String message, byte messageButtons, int selectedOption, List instructions, List conditions) { 24 | this.messageChainId = messageChainId; 25 | this.player = player; 26 | this.messageType = messageType; 27 | this.message = message; 28 | this.messageButtons = messageButtons; 29 | this.instructions = instructions; 30 | this.selectedOption = selectedOption; 31 | this.conditions = conditions; 32 | } 33 | 34 | public Player getPlayer() { 35 | return player; 36 | } 37 | 38 | public void setPlayer(Player player) { 39 | this.player = player; 40 | } 41 | 42 | public int getMessageType() { 43 | return messageType; 44 | } 45 | 46 | public void setMessageType(int messageType) { 47 | this.messageType = messageType; 48 | } 49 | 50 | public byte getMessageButtons() { 51 | return messageButtons; 52 | } 53 | 54 | public void setMessageButtons(byte messageButtons) { 55 | this.messageButtons = messageButtons; 56 | } 57 | 58 | public String getMessage() { 59 | return message; 60 | } 61 | 62 | public void setMessage(String message) { 63 | this.message = message; 64 | } 65 | 66 | public int getSelectedOption() { 67 | return selectedOption; 68 | } 69 | 70 | public void setSelectedOption(int selectedOption) { 71 | this.selectedOption = selectedOption; 72 | } 73 | 74 | public List getInstructions() { 75 | return instructions; 76 | } 77 | 78 | public void setInstructions(List instructions) { 79 | this.instructions = instructions; 80 | } 81 | 82 | public List getConditions() { 83 | return conditions; 84 | } 85 | 86 | public void setConditions(List conditions) { 87 | this.conditions = conditions; 88 | } 89 | 90 | public int getMessageChainId() { 91 | return messageChainId; 92 | } 93 | 94 | public void setMessageChainId(int messageChainId) { 95 | this.messageChainId = messageChainId; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/packet/Reader.java: -------------------------------------------------------------------------------- 1 | package packet; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import org.apache.commons.codec.DecoderException; 5 | import org.apache.commons.codec.binary.Hex; 6 | 7 | /** 8 | * 9 | * @author XxOsirisxX 10 | */ 11 | public class Reader { 12 | 13 | private StringBuilder packetString; 14 | 15 | public Reader(String packetString) { 16 | this.packetString = new StringBuilder(packetString.replace(" ", "")); 17 | } 18 | 19 | public byte readByte() { 20 | return Byte.parseByte(readString(0, 2), 16); 21 | } 22 | 23 | public short readShort() { 24 | return Short.parseShort(readString(2, 4) + readString(0, 2), 16); 25 | } 26 | 27 | public int readInt() { 28 | return (int) Long.parseLong(readString(6, 8) + readString(4, 6) + readString(2, 4) + readString(0, 2), 16); 29 | } 30 | 31 | public long readLong() { 32 | return Long.parseLong(readString(14, 16) + readString(12, 14) + readString(10, 12) + readString(8, 10) + readString(6, 8) + readString(4, 6) + readString(2, 4) + readString(0, 2), 16); 33 | } 34 | 35 | public String readMapleString() throws DecoderException, UnsupportedEncodingException { 36 | short messageLenght = readShort(); 37 | return new String(Hex.decodeHex(readString(0, messageLenght * 2).toCharArray()), "UTF8"); 38 | } 39 | 40 | public void skip(int pairs) { 41 | readString(0, pairs * 2); 42 | } 43 | 44 | private String readString(int start, int end) { 45 | String data = packetString.substring(start, end); 46 | packetString = packetString.delete(start, end); 47 | return data; 48 | } 49 | } -------------------------------------------------------------------------------- /src/player/Player.java: -------------------------------------------------------------------------------- 1 | package player; 2 | 3 | /** 4 | * 5 | * @author XxOsirisxX 6 | */ 7 | public class Player { 8 | 9 | private int channel; 10 | private int mapId; 11 | 12 | public int getMapId() { 13 | return mapId; 14 | } 15 | 16 | public void setMapId(int mapId) { 17 | this.mapId = mapId; 18 | } 19 | 20 | public int getChannel() { 21 | return channel; 22 | } 23 | 24 | public void setChannel(int channel) { 25 | this.channel = channel; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/server/NPCScriptGenerator.java: -------------------------------------------------------------------------------- 1 | package server; 2 | 3 | import condition.Condition; 4 | import condition.Location; 5 | import npc.NPCMessage; 6 | import npc.NPC; 7 | import java.io.BufferedReader; 8 | import java.io.BufferedWriter; 9 | import java.io.FileReader; 10 | import java.io.FileWriter; 11 | import java.io.IOException; 12 | import java.util.LinkedHashMap; 13 | import java.util.LinkedList; 14 | import java.util.List; 15 | import java.util.Map; 16 | import org.apache.commons.codec.DecoderException; 17 | import packet.Reader; 18 | import player.Player; 19 | import server.instruction.Instruction; 20 | import server.instruction.Mesos; 21 | import server.instruction.Warp; 22 | 23 | /** 24 | * 25 | * @author XxOsirisxX 26 | */ 27 | public class NPCScriptGenerator { 28 | 29 | private Player player; 30 | private Map npcs; 31 | private int npcMessageFlow; 32 | private int currentNpcId; 33 | private boolean npcTalk; 34 | private boolean npcMoreTalk; 35 | private boolean readNpc; 36 | private boolean readPlayer; 37 | private int instructionType = -1; 38 | private int selectedOption = -1; 39 | 40 | public static void main(String[] args) { 41 | new NPCScriptGenerator().start(); 42 | } 43 | 44 | private void start() { 45 | initiate(); 46 | String filename = "dkpackets.txt"; 47 | Reader read; 48 | try (BufferedReader br = new BufferedReader(new FileReader(filename))) { 49 | String line; 50 | restartAttributes(); 51 | List instructions = new LinkedList(); 52 | 53 | while ((line = br.readLine()) != null) { 54 | if (line.contains("Sent")) { 55 | if (line.contains("NPC_TALK ")) { 56 | npcTalk = true; 57 | npcMessageFlow = 0; 58 | } else if (line.contains("NPC_TALK_MORE ") && npcTalk) { 59 | npcMoreTalk = true; 60 | } 61 | continue; 62 | } 63 | if (readPlayer) { 64 | boolean playerLoggedIn = line.length() > 200; 65 | read = new Reader(line); 66 | read.skip(2); 67 | int channel = read.readInt(); 68 | int mapId; 69 | if (!playerLoggedIn) { 70 | read.skip(5); 71 | mapId = read.readInt(); 72 | } else { 73 | read.skip(109); 74 | mapId = read.readInt(); 75 | } 76 | player = new Player(); 77 | player.setMapId(mapId); 78 | player.setChannel(channel + 1); 79 | readPlayer = false; 80 | } 81 | if (npcMoreTalk) { 82 | read = new Reader(line); 83 | read.skip(2); 84 | byte previousMessageType = read.readByte(); 85 | npcTalk = read.readByte() == 1; 86 | switch (previousMessageType) { 87 | case 0x02: //Text 88 | String textInput = read.readMapleString(); 89 | break; 90 | case 0x03: //Numbers 91 | case 0x04: //Options 92 | int selection = read.readInt(); 93 | selectedOption = selection; 94 | break; 95 | } 96 | npcMoreTalk = false; 97 | } else { 98 | if (instructionType > -1) { 99 | read = new Reader(line); 100 | switch (instructionType) { 101 | case 0x00: //WARP 102 | read.skip(11); 103 | int mapId = read.readInt(); 104 | byte spawnPoint = read.readByte(); 105 | Warp warp = new Warp(); 106 | warp.setMapId(mapId); 107 | warp.setSpawnPoint(spawnPoint); 108 | instructions.add(warp); 109 | applyDummyConversation(instructions); 110 | instructions = new LinkedList(); 111 | restartAttributes(); 112 | break; 113 | case 0x01: //SHOW_STATUS_INFO 114 | byte type = read.readByte(); 115 | if (type == 5) { //Mesos 116 | int amount = read.readInt(); 117 | Mesos mesos = new Mesos(); 118 | mesos.setAmount(amount); 119 | instructions.add(mesos); 120 | } else if (type == 0) { //Inventory - Mesos Included 121 | 122 | } 123 | break; 124 | } 125 | instructionType = -1; 126 | continue; 127 | } 128 | if (!npcTalk) { 129 | if (line.contains("Received")) { 130 | if (line.contains("WARP_TO_MAP ")) { 131 | readPlayer = true; 132 | } 133 | continue; 134 | } 135 | } 136 | if (npcTalk) { 137 | if (line.contains("Received")) { 138 | if (line.contains("NPC_TALK ")) { 139 | readNpc = true; 140 | } else if (line.contains("WARP_TO_MAP ")) { 141 | instructionType = 0; 142 | } else if (line.contains("SHOW_STATUS_INFO ")) { 143 | instructionType = 1; 144 | } else if (line.contains("OPEN_NPC_SHOP ")) { 145 | restartAttributes(); 146 | } else if (line.contains("UPDATE_SKILLS")) { 147 | restartAttributes(); 148 | } else if (line.contains("OPEN_STORAGE")) { 149 | restartAttributes(); 150 | } 151 | continue; 152 | } 153 | 154 | if (readNpc) { 155 | read = new Reader(line); 156 | read.skip(3); 157 | int npcId = read.readInt(); 158 | byte messageType = read.readByte(); 159 | read.skip(1); 160 | String message = read.readMapleString(); 161 | byte messageButtons = 0; 162 | if (messageType == 0) { 163 | messageButtons |= read.readByte() << 1; //Previous 164 | messageButtons |= read.readByte(); //Next 165 | } 166 | currentNpcId = npcId; 167 | NPC npc; 168 | if (npcs.containsKey(npcId)) { 169 | npc = npcs.get(npcId); 170 | } else { 171 | npc = new NPC(npcId); 172 | } 173 | npc.applyConversation(npcMessageFlow, player, messageType, message, messageButtons, selectedOption, instructions); 174 | npcs.put(npcId, npc); 175 | npcMessageFlow++; 176 | instructions = new LinkedList(); 177 | readNpc = false; 178 | } 179 | } 180 | } 181 | } 182 | adjustCondition(); 183 | generateScripts(); 184 | } catch (IOException ioe) { 185 | System.err.println("Error while reading the file " + filename + "."); 186 | } catch (DecoderException de) { 187 | System.err.println("Error while trying to decode string in file " + filename + "."); 188 | } 189 | } 190 | 191 | private void adjustCondition() { 192 | for (NPC npc : npcs.values()) { 193 | npc.adjustConditions(); 194 | } 195 | } 196 | 197 | private void initiate() { 198 | npcs = new LinkedHashMap(); 199 | } 200 | 201 | private void restartAttributes() { 202 | npcMessageFlow = 0; 203 | currentNpcId = 0; 204 | npcTalk = false; 205 | npcMoreTalk = false; 206 | readNpc = false; 207 | instructionType = -1; 208 | selectedOption = -1; 209 | readPlayer = false; 210 | } 211 | 212 | private void generateScripts() { 213 | for (NPC npc : npcs.values()) { 214 | String filename = npc.getId() + ".txt"; 215 | try (final BufferedWriter bw = new BufferedWriter(new FileWriter(filename))) { 216 | 217 | StringBuilder sb = new StringBuilder(); 218 | sb.append("status = -1;\r\n\r\n"); 219 | sb.append("function start() {\r\n\t"); 220 | for (int n = 0; n < npc.getMessages().get(0).size(); n++) { 221 | List conditions = npc.getMessages().get(0).get(n).getConditions(); 222 | int conditionSize = 0; 223 | if (npc.getMessages().get(0).get(n).getConditions() != null) { 224 | conditionSize = conditions.size(); 225 | sb.append(getScriptConditions(conditions)); 226 | } 227 | sb.append(getScriptMessageType(npc.getMessages().get(0).get(n))); 228 | for (int x = 0; x < conditionSize; x++) { 229 | sb.append("\t}\r\n"); 230 | } 231 | } 232 | if (npc.getMessages().size() == 1) { 233 | sb.append("\tcm.dispose();\r\n"); 234 | } 235 | sb.append("}\r\n\r\n"); 236 | if (npc.getMessages().size() > 1) { 237 | sb.append("function action(mode, type, selection) {\r\n"); 238 | sb.append("\tstatus++;\r\n"); 239 | sb.append("\tif ((mode == 0 && type == 4) || mode == -1) {\r\n"); 240 | sb.append("\t\tcm.dispose();\r\n"); 241 | sb.append("\t\treturn;\r\n"); 242 | sb.append("\t}\r\n"); 243 | sb.append("\tif (mode == 0 && type == 0) {\r\n"); 244 | sb.append("\t\tstatus -= 2;\r\n"); 245 | sb.append("\t}\r\n"); 246 | for (int i = 1; i < npc.getMessages().size(); i++) { 247 | if (i > 1) { 248 | sb.append(" else if (status == ").append(i - 1).append(") {\r\n\t"); 249 | } else { 250 | sb.append("\tif (status == ").append(i - 1).append(") {\r\n\t"); 251 | } 252 | for (int n = 0; n < npc.getMessages().get(i).size(); n++) { 253 | NPCMessage data = npc.getMessages().get(i).get(n); 254 | if (data.getConditions() != null) { 255 | sb.append(getScriptConditions(data.getConditions())); 256 | } 257 | sb.append(getScriptOptions(data.getSelectedOption())); 258 | sb.append("\t"); 259 | if (data.getSelectedOption() > -1) { 260 | sb.append("\t\t"); 261 | } 262 | sb.append(getScriptInstructions(data.getInstructions())); 263 | sb.append(getScriptMessageType(data)); 264 | if (data.getSelectedOption() > -1) { 265 | sb.append("\t\t}\r\n"); 266 | } 267 | if (data.getConditions() != null) { 268 | for (int x = 0; x < data.getConditions().size(); x++) { 269 | sb.append("\t\t}\r\n"); 270 | } 271 | } 272 | } 273 | sb.append("\t}"); 274 | } 275 | sb.append("\r\n"); 276 | sb.append("}"); 277 | } 278 | bw.append(sb); 279 | bw.close(); 280 | } catch (IOException ioe) { 281 | System.err.println("Error while writing the file " + filename + "."); 282 | } 283 | } 284 | } 285 | 286 | private void applyDummyConversation(List instructions) { 287 | NPC npc; 288 | if (npcs.containsKey(currentNpcId)) { 289 | npc = npcs.get(currentNpcId); 290 | } else { 291 | npc = new NPC(currentNpcId); 292 | } 293 | npc.applyConversation(npcMessageFlow, player, -1, "", (byte) 0, -1, instructions); 294 | } 295 | 296 | private StringBuilder getScriptConditions(List conditions) { 297 | StringBuilder ret = new StringBuilder(); 298 | for (Condition condition : conditions) { 299 | if (condition instanceof Location) { 300 | Location location = (Location) condition; 301 | ret.append("\tif (cm.getMapId() == ").append(location.getMapId()).append(") {\r\n"); 302 | } 303 | } 304 | return ret; 305 | } 306 | 307 | private StringBuilder getScriptOptions(int selectedOption) { 308 | StringBuilder ret = new StringBuilder(); 309 | if (selectedOption > -1) { 310 | ret.append("\tif (selection == ").append(selectedOption).append(") {\r\n"); 311 | } 312 | return ret; 313 | } 314 | 315 | private StringBuilder getScriptInstructions(List instructions) { 316 | StringBuilder ret = new StringBuilder(); 317 | for (Instruction instruction : instructions) { 318 | if (instruction instanceof Mesos) { 319 | Mesos mesos = (Mesos) instruction; 320 | ret.append("\t\tcm.gainMesos(").append(mesos.getAmount()).append(");\r\n"); 321 | } else if (instruction instanceof Warp) { 322 | Warp warp = (Warp) instruction; 323 | ret.append("\t\tcm.warp(").append(warp.getMapId()).append(", ").append(warp.getSpawnPoint()).append(");\r\n"); 324 | } 325 | if (instruction.isDispose()) { 326 | ret.append("\t\tcm.dispose();\r\n"); 327 | } 328 | } 329 | return ret; 330 | } 331 | 332 | private StringBuilder getScriptMessageType(NPCMessage message) { 333 | StringBuilder ret = new StringBuilder(); 334 | switch (message.getMessageType()) { 335 | case 0x00: //Next | Prev | OK 336 | switch (message.getMessageButtons()) { 337 | case 0x00: //OK 338 | ret.append("cm.sendOk(\"").append(message.getMessage()).append("\");\r\n"); 339 | break; 340 | case 0x01: //Next 341 | ret.append("cm.sendNext(\"").append(message.getMessage()).append("\");\r\n"); 342 | break; 343 | case 0x02: //Previous 344 | ret.append("cm.sendPrev(\"").append(message.getMessage()).append("\");\r\n"); 345 | break; 346 | case 0x03: //Next | Previous 347 | ret.append("cm.sendNextPrev(\"").append(message.getMessage()).append("\");\r\n"); 348 | break; 349 | } 350 | break; 351 | case 0x01: //Yes | No 352 | ret.append("cm.sendYesNo(\"").append(message.getMessage()).append("\");\r\n"); 353 | break; 354 | case 0x02: //Text 355 | ret.append("cm.sendGetText(\"").append(message.getMessage()).append("\");\r\n"); 356 | break; 357 | case 0x03: //Numbers 358 | ret.append("cm.sendGetNumber(\"").append(message.getMessage()).append("\");\r\n"); 359 | break; 360 | case 0x04: //Options 361 | ret.append("cm.sendSimple(\"").append(message.getMessage()).append("\");\r\n"); 362 | break; 363 | case 0x07: //Style 364 | ret.append("cm.sendStyle(\"").append(message.getMessage()).append("\");\r\n"); 365 | break; 366 | case 0x0C: //Accept | Decline 367 | ret.append("cm.sendAcceptDecline(\"").append(message.getMessage()).append("\");\r\n"); 368 | break; 369 | case 0x0E: //Locations 370 | ret.append("cm.sendPlaces();\r\n"); 371 | break; 372 | } 373 | return ret; 374 | } 375 | } -------------------------------------------------------------------------------- /src/server/instruction/Instruction.java: -------------------------------------------------------------------------------- 1 | package server.instruction; 2 | 3 | /** 4 | * 5 | * @author XxOsirisxX 6 | */ 7 | public abstract class Instruction { 8 | 9 | private boolean dispose; 10 | 11 | public Instruction(boolean dispose) { 12 | this.dispose = dispose; 13 | } 14 | 15 | public boolean isDispose() { 16 | return dispose; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /src/server/instruction/Mesos.java: -------------------------------------------------------------------------------- 1 | package server.instruction; 2 | 3 | /** 4 | * 5 | * @author XxOsirisxX 6 | */ 7 | public class Mesos extends Instruction { 8 | 9 | private int amount; 10 | 11 | public Mesos() { 12 | super(false); 13 | } 14 | 15 | public int getAmount() { 16 | return amount; 17 | } 18 | 19 | public void setAmount(int amount) { 20 | this.amount = amount; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /src/server/instruction/Warp.java: -------------------------------------------------------------------------------- 1 | package server.instruction; 2 | 3 | /** 4 | * 5 | * @author XxOsirisxX 6 | */ 7 | public class Warp extends Instruction { 8 | 9 | private int mapId; 10 | private short spawnPoint; 11 | 12 | public Warp() { 13 | super(true); 14 | } 15 | 16 | public int getMapId() { 17 | return mapId; 18 | } 19 | 20 | public void setMapId(int mapId) { 21 | this.mapId = mapId; 22 | } 23 | 24 | public short getSpawnPoint() { 25 | return spawnPoint; 26 | } 27 | 28 | public void setSpawnPoint(short spawnPoint) { 29 | this.spawnPoint = spawnPoint; 30 | } 31 | } -------------------------------------------------------------------------------- /start.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set CLASSPATH=.;dist\*;lib\* 3 | java -server server.NPCScriptGenerator 4 | pause 5 | --------------------------------------------------------------------------------