diff --git a/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java b/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java
index 53cd758dd..893f6dbb0 100644
--- a/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java
+++ b/Server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java
@@ -31,540 +31,521 @@ import org.crandor.tools.StringUtils;
/**
* Represents an Artificial Intelligent Player.
+ *
* @author Emperor
*/
public class AIPlayer extends Player {
- /**
- * The current UID.
- */
- private static int currentUID = 0x1;
+ /**
+ * The current UID.
+ */
+ private static int currentUID = 0x1;
- /**
- * The active Artificial intelligent players mapping.
- */
- private static final Map botMapping = new HashMap<>();
+ /**
+ * The active Artificial intelligent players mapping.
+ */
+ private static final Map botMapping = new HashMap<>();
- /**
- * The aip control dialogue.
- */
- private static final AIPControlDialogue CONTROL_DIAL = new AIPControlDialogue();
+ /**
+ * The aip control dialogue.
+ */
+ private static final AIPControlDialogue CONTROL_DIAL = new AIPControlDialogue();
- /**
- * A line of data from namesandarmor.txt that will be used to generate the appearance
- * Data in format:
- * //name:cblevel:helmet:cape:neck:weapon:chest:shield:unknown:legs:unknown:gloves:boots:
- */
- private static String OSRScopyLine;
+ /**
+ * A line of data from namesandarmor.txt that will be used to generate the appearance
+ * Data in format:
+ * //name:cblevel:helmet:cape:neck:weapon:chest:shield:unknown:legs:unknown:gloves:boots:
+ */
+ private static String OSRScopyLine;
- /**
- * The AIP's UID.
- */
- private final int uid;
+ /**
+ * The AIP's UID.
+ */
+ private final int uid;
- /**
- * The start location of the AIP.
- */
- private final Location startLocation;
+ /**
+ * The start location of the AIP.
+ */
+ private final Location startLocation;
- /**
- * The username.
- */
- private String username;
+ /**
+ * The username.
+ */
+ private String username;
- /**
- * The player controlling this AIP.
- */
- private Player controler;
+ /**
+ * The player controlling this AIP.
+ */
+ private Player controler;
- /**
- * Constructs a new {@code AIPlayer} {@code Object}.
- *
- * @param l The location.
- */
- public AIPlayer(Location l) {
- this(retrieveRandomName(), l, null);
- }
+ /**
+ * Constructs a new {@code AIPlayer} {@code Object}.
+ *
+ * @param l The location.
+ */
+ public AIPlayer(Location l) {
+ this(retrieveRandomName(), l, null);
+ }
- public AIPlayer(String fileName, Location l) {
- this(retrieveRandomName(fileName), l, null);
- }
+ public AIPlayer(String fileName, Location l) {
+ this(retrieveRandomName(fileName), l, null);
+ }
- @SuppressWarnings("deprecation")
- private AIPlayer(String name, Location l, String ignored) {
- super(new PlayerDetails("/aip" + (currentUID + 1) + ":" + name));
- super.setLocation(startLocation = l);
- super.artificial = true;
- super.getDetails().setSession(ArtificialSession.getSingleton());
- Repository.getPlayers().add(this);
- this.username = StringUtils.formatDisplayName(name + (currentUID + 1));
- this.uid = currentUID++;
- this.updateRandomValues();
- this.init();
- }
+ @SuppressWarnings("deprecation")
+ private AIPlayer(String name, Location l, String ignored) {
+ super(new PlayerDetails("/aip" + (currentUID + 1) + ":" + name));
+ super.setLocation(startLocation = l);
+ super.artificial = true;
+ super.getDetails().setSession(ArtificialSession.getSingleton());
+ Repository.getPlayers().add(this);
+ this.username = StringUtils.formatDisplayName(name + (currentUID + 1));
+ this.uid = currentUID++;
+ this.updateRandomValues();
+ this.init();
+ }
- /**
- * Generates bot stats/equipment/etc based on OSRScopyLine
- */
- public void updateRandomValues() {
- this.getAppearance().setGender(RandomFunction.random(5) == 1 ? Gender.FEMALE : Gender.MALE);
+ /**
+ * Generates bot stats/equipment/etc based on OSRScopyLine
+ */
+ public void updateRandomValues() {
+ this.getAppearance().setGender(RandomFunction.random(5) == 1 ? Gender.FEMALE : Gender.MALE);
- setLevels();
- giveArmor();
+ setLevels();
+ giveArmor();
- this.setDirection(Direction.values()[new Random().nextInt(Direction.values().length)]); //Random facing dir
- this.getSkills().updateCombatLevel();
- this.getAppearance().sync();
- }
+ this.setDirection(Direction.values()[new Random().nextInt(Direction.values().length)]); //Random facing dir
+ this.getSkills().updateCombatLevel();
+ this.getAppearance().sync();
+ }
- private void setLevels() {
- //Create realistic player stats
- int maxLevel = RandomFunction.random(1, Math.min(parseOSRS(1), 99));
- for (int i = 0; i < Skills.NUM_SKILLS; i++) {
- this.getSkills().setStaticLevel(i, RandomFunction.linearDecreaseRand(maxLevel));
- }
- int combatLevelsLeft = parseOSRS(1);
- int hitpoints = Math.max(RandomFunction.random(10, Math.min(maxLevel, combatLevelsLeft*4)), 10);
- combatLevelsLeft -= 0.25*hitpoints;
- int prayer = combatLevelsLeft > 0 ? RandomFunction.random(Math.min(maxLevel, combatLevelsLeft*8)) : 1;
- combatLevelsLeft -= 0.125*prayer;
- int defence = combatLevelsLeft > 0 ? RandomFunction.random(Math.min(maxLevel, combatLevelsLeft*4)) : 1;
- combatLevelsLeft -= 0.25*defence;
+ private void setLevels() {
+ //Create realistic player stats
+ int maxLevel = RandomFunction.random(1, Math.min(parseOSRS(1), 99));
+ for (int i = 0; i < Skills.NUM_SKILLS; i++) {
+ this.getSkills().setStaticLevel(i, RandomFunction.linearDecreaseRand(maxLevel));
+ }
+ int combatLevelsLeft = parseOSRS(1);
+ int hitpoints = Math.max(RandomFunction.random(10, Math.min(maxLevel, combatLevelsLeft * 4)), 10);
+ combatLevelsLeft -= 0.25 * hitpoints;
+ int prayer = combatLevelsLeft > 0 ? RandomFunction.random(Math.min(maxLevel, combatLevelsLeft * 8)) : 1;
+ combatLevelsLeft -= 0.125 * prayer;
+ int defence = combatLevelsLeft > 0 ? RandomFunction.random(Math.min(maxLevel, combatLevelsLeft * 4)) : 1;
+ combatLevelsLeft -= 0.25 * defence;
- combatLevelsLeft = Math.min(combatLevelsLeft, 199);
+ combatLevelsLeft = Math.min(combatLevelsLeft, 199);
- int attack = combatLevelsLeft > 0 ? RandomFunction.normalRandDist(Math.min(maxLevel, combatLevelsLeft*3)) : 1;
- int strength = combatLevelsLeft > 0 ? combatLevelsLeft*3 - attack : 1;
+ int attack = combatLevelsLeft > 0 ? RandomFunction.normalRandDist(Math.min(maxLevel, combatLevelsLeft * 3)) : 1;
+ int strength = combatLevelsLeft > 0 ? combatLevelsLeft * 3 - attack : 1;
- this.getSkills().setStaticLevel(Skills.HITPOINTS, hitpoints);
- this.getSkills().setStaticLevel(Skills.PRAYER, prayer);
- this.getSkills().setStaticLevel(Skills.DEFENCE, defence);
- this.getSkills().setStaticLevel(Skills.ATTACK, attack);
- this.getSkills().setStaticLevel(Skills.STRENGTH, strength);
- this.getSkills().setStaticLevel(Skills.RANGE, combatLevelsLeft/2);
- this.getSkills().setStaticLevel(Skills.MAGIC, combatLevelsLeft/2);
- }
+ this.getSkills().setStaticLevel(Skills.HITPOINTS, hitpoints);
+ this.getSkills().setStaticLevel(Skills.PRAYER, prayer);
+ this.getSkills().setStaticLevel(Skills.DEFENCE, defence);
+ this.getSkills().setStaticLevel(Skills.ATTACK, attack);
+ this.getSkills().setStaticLevel(Skills.STRENGTH, strength);
+ this.getSkills().setStaticLevel(Skills.RANGE, combatLevelsLeft / 2);
+ this.getSkills().setStaticLevel(Skills.MAGIC, combatLevelsLeft / 2);
+ }
- private void giveArmor() {
- //name:cblevel:helmet2:cape3:neck4:weapon5:chest6:shield7:unknown8:legs9:unknown10:gloves11:boots12:
- //sicriona:103:1163: 1023: 1725 :1333: 1127 :1201 :0: 1079 :0: 2922: 1061:0:
- equipIfExists(new Item(parseOSRS(2)), EquipmentContainer.SLOT_HAT);
- equipIfExists(new Item(parseOSRS(3)), EquipmentContainer.SLOT_CAPE);
- equipIfExists(new Item(parseOSRS(4)), EquipmentContainer.SLOT_AMULET);
- equipIfExists(new Item(parseOSRS(5)), EquipmentContainer.SLOT_WEAPON);
- equipIfExists(new Item(parseOSRS(6)), EquipmentContainer.SLOT_CHEST);
- equipIfExists(new Item(parseOSRS(7)), EquipmentContainer.SLOT_SHIELD);
- equipIfExists(new Item(parseOSRS(9)), EquipmentContainer.SLOT_LEGS);
- equipIfExists(new Item(parseOSRS(11)), EquipmentContainer.SLOT_HANDS);
- equipIfExists(new Item(parseOSRS(12)), EquipmentContainer.SLOT_FEET);
- }
+ private void giveArmor() {
+ //name:cblevel:helmet2:cape3:neck4:weapon5:chest6:shield7:unknown8:legs9:unknown10:gloves11:boots12:
+ //sicriona:103:1163: 1023: 1725 :1333: 1127 :1201 :0: 1079 :0: 2922: 1061:0:
+ equipIfExists(new Item(parseOSRS(2)), EquipmentContainer.SLOT_HAT);
+ equipIfExists(new Item(parseOSRS(3)), EquipmentContainer.SLOT_CAPE);
+ equipIfExists(new Item(parseOSRS(4)), EquipmentContainer.SLOT_AMULET);
+ equipIfExists(new Item(parseOSRS(5)), EquipmentContainer.SLOT_WEAPON);
+ equipIfExists(new Item(parseOSRS(6)), EquipmentContainer.SLOT_CHEST);
+ equipIfExists(new Item(parseOSRS(7)), EquipmentContainer.SLOT_SHIELD);
+ equipIfExists(new Item(parseOSRS(9)), EquipmentContainer.SLOT_LEGS);
+ equipIfExists(new Item(parseOSRS(11)), EquipmentContainer.SLOT_HANDS);
+ equipIfExists(new Item(parseOSRS(12)), EquipmentContainer.SLOT_FEET);
+ }
- private int parseOSRS(int index) {
- return Integer.parseInt(OSRScopyLine.split(":")[index]);
- }
+ private int parseOSRS(int index) {
+ return Integer.parseInt(OSRScopyLine.split(":")[index]);
+ }
- private void equipIfExists(Item e, int slot) {
- if (e.getId() != 0)
- getEquipment().replace(e, slot);
- }
+ private void equipIfExists(Item e, int slot) {
+ if (e.getName().equalsIgnoreCase("null")) {
+ return;
+ }
+ if (e.getId() != 0)
+ getEquipment().replace(e, slot);
+ }
- /**
- * Get a bot content
- */
- public static void updateRandomOSRScopyLine(String fileName) {
- Random rand = new Random();
- int n = 0;
- try {
- for (Scanner sc = new Scanner(new File("./data/botdata/" + fileName)); sc.hasNext(); ) {
- ++n;
- String line = sc.nextLine();
- if (rand.nextInt(n) == 0) { //Chance of overwriting line is lower and lower
- OSRScopyLine = line;
- if (line.length() < 3) //probably an empty line
- {
- System.out.println("Something went wrong reading line [" + line + "] from /data/botdata/" + fileName);
- updateRandomOSRScopyLine(fileName);
- }
- }
- }
- } catch (FileNotFoundException e) {
- System.out.println("Missing " + fileName);
- e.printStackTrace();
- }
- }
+ /**
+ * Get a bot content
+ */
+ public static void updateRandomOSRScopyLine(String fileName) {
+ Random rand = new Random();
+ int n = 0;
+ try {
+ for (Scanner sc = new Scanner(new File("./data/botdata/" + fileName)); sc.hasNext(); ) {
+ ++n;
+ String line = sc.nextLine();
+ if (rand.nextInt(n) == 0) { //Chance of overwriting line is lower and lower
+ OSRScopyLine = line;
+ if (line.length() < 3) //probably an empty line
+ {
+ System.out.println("Something went wrong reading line [" + line + "] from /data/botdata/" + fileName);
+ updateRandomOSRScopyLine(fileName);
+ }
+ }
+ }
+ } catch (FileNotFoundException e) {
+ System.out.println("Missing " + fileName);
+ e.printStackTrace();
+ }
+ }
- private static String retrieveRandomName(String fileName) {
- updateRandomOSRScopyLine(fileName);
- return OSRScopyLine.split(":")[0];
- }
+ private static String retrieveRandomName(String fileName) {
+ updateRandomOSRScopyLine(fileName);
+ return OSRScopyLine.split(":")[0];
+ }
- private static String retrieveRandomName() {
- return retrieveRandomName("namesandarmor.txt");
- }
+ private static String retrieveRandomName() {
+ return retrieveRandomName("namesandarmor.txt");
+ }
- @Override
- public void init() {
- getProperties().setSpawnLocation(startLocation);
- getInterfaceManager().openDefaultTabs();
- getSession().setObject(this);
- botMapping.put(uid, this);
- super.init();
- getSettings().setRunToggled(true);
+ @Override
+ public void init() {
+ getProperties().setSpawnLocation(startLocation);
+ getInterfaceManager().openDefaultTabs();
+ getSession().setObject(this);
+ botMapping.put(uid, this);
+ super.init();
+ getSettings().setRunToggled(true);
CharacterDesign.randomize(this, false);
- getInteraction().set(new Option("Control", 7).setHandler(new OptionHandler() {
- @Override
- public Plugin