Purpose: This is a method that loads NPC defense bonuses through a configuration file. Note: I do not yet have this actually working in combat yet but I will soon and I will release it. This is to make certain NPC's harder to kill than others. E.G. A level 10 can hit the same on jad as he can on a regular man, This will will stop that.
Difficulty: 2/10
Base: Secret =D
Knowledge: C & P and bits of Java
Classes Modified: NPC.java
Step 1:
In bin > data > npcs > create a new file and name it "NPCDef.cfg".
Step 2:
Go into NPC.java and paste this method:
Code:
public int unpackBonuses(int npcId) throws Exception {
int bonuse = 0;
BufferedReader in = new BufferedReader(new FileReader("./data/npcs/npcdef.cfg"));
String[] NPCDef;
String input;
while ((input = in.readLine()) != null) {
NPCDef = null;
if (!input.startsWith("/") && input.contains("=")) {
NPCDef = input.split("=");
if (NPCDef[0].startsWith("" + npcId)) {
bonuse = Integer.parseInt(NPCDef[1]);
}
}
}
return bonuse;
}
Step 3:
Paste this in you NPCDef.cfg:
Code:
//npcType=DefBonuse
Step 4:
For example you want a man to have 15 def bonuse, You would put:
In you're CFG file.
How this method works is, It will identify the NPC's Id and return the bonuse as an Int.
Please comment!