Not too familiar with JSON, but really cba trying to hardcode all the definitions:
Code:
{"animations":{"death":836,"attack":422},"size":1,"lifepoints":150,"weakness":"Fire","id":1,"poisonous":false,"attackable":true,"magic":1,"level":6,"defence":3,"description":"One of RuneScape's many citizens.","name":"Man","ranged":1,"areas":["RuneScape Surface"],"attack":3,"aggressive":false,"members":false}
Was going to try and do something like this to extract the information and then make my own binary file:
Code:
public static void init() throws IOException {
File folder = new File("./data/");
definitions = new NPCDefinition[16733];
for (File file : folder.listFiles()) {
int id = Integer.valueOf(file.getName().replace(".txt", ""));
NPCDefinition definition = new NPCDefinition();
definition.id = id;
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = reader.readLine().toLowerCase();
if (line.contains("\"death\":")) {
String[] start = line.split("\"death\":");
String[] end = line.split(",\"attack\":");
String value = line.substring((line.length() - start[1].length()), end[0].length());
if (value.length() > 5) {
value = value.split("},\"size\":")[0];
}
if (value.length() <= 5) {
definition.deathAnimation = Integer.valueOf(value);
}
}
if (line.contains("\"attack\":")) {
try {
String[] start = line.split("\"attack\":");
String[] end = line.split("},\"size\":");
String value = line.substring(start[0].length() + 9, end[0].length());
if (value.length() > 5) {
value = value.split("},\"slayercat\":")[0];
}
if (value.length() > 5) {
value = value.split("},\"slayerlevel\":")[0];
}
if (value.length() <= 5) {
definition.attackAnimation = Integer.valueOf(value);
}
} catch (Exception exception) {}
}
}
}
But realized that it would take forever to get that to extract all the information perfectly and some definitions might not even be loaded correctly.
My question is: is the definition (from the bestiary dump) written in JSON or does anyone know with what library I can easily read it?
Note: Not all the files are the same: i.e this is another one:
Code:
{"animations":{"death":13772},"size":2,"lifepoints":500,"weakness":"None","id":9929,"poisonous":false,"attackable":true,"magic":1,"level":2,"defence":1,"description":"It's got a cold stare.","name":"Plane-freezer Lakhrahnaz","ranged":1,"areas":[],"attack":1,"aggressive":true,"members":false}