diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..4487f0b07
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+production/*
diff --git a/.idea/09HDscape.iml b/.idea/09HDscape.iml
index ff22e2cfd..1b7dd94b9 100644
--- a/.idea/09HDscape.iml
+++ b/.idea/09HDscape.iml
@@ -175,5 +175,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/09HDscape-server/data/eco/grand_exchange_db.emp b/09HDscape-server/data/eco/grand_exchange_db.emp
index 6c5e146ee..dfacbcb3f 100644
Binary files a/09HDscape-server/data/eco/grand_exchange_db.emp and b/09HDscape-server/data/eco/grand_exchange_db.emp differ
diff --git a/09HDscape-server/data/libs/json-simple-1.1.jar b/09HDscape-server/data/libs/json-simple-1.1.jar
new file mode 100644
index 000000000..f395f4147
Binary files /dev/null and b/09HDscape-server/data/libs/json-simple-1.1.jar differ
diff --git a/09HDscape-server/data/players/.keepDirAlive b/09HDscape-server/data/players/.keepDirAlive
new file mode 100644
index 000000000..e69de29bb
diff --git a/09HDscape-server/src/org/crandor/cache/def/impl/CS2Mapping.java b/09HDscape-server/src/org/crandor/cache/def/impl/CS2Mapping.java
index f2667e9a5..a0c8ead56 100644
--- a/09HDscape-server/src/org/crandor/cache/def/impl/CS2Mapping.java
+++ b/09HDscape-server/src/org/crandor/cache/def/impl/CS2Mapping.java
@@ -80,7 +80,7 @@ public final class CS2Mapping {
if (mapping.map == null) {
continue;
}
- bw.append("Script - " + i + " [");
+ bw.append("ScriptAPI - " + i + " [");
for (int index : mapping.map.keySet()) {
bw.append(mapping.map.get(index) + ": " + index + " ");
}
diff --git a/09HDscape-server/src/org/crandor/game/content/global/tutorial/CharacterDesign.java b/09HDscape-server/src/org/crandor/game/content/global/tutorial/CharacterDesign.java
index 4c6cf000c..a9ea94d03 100644
--- a/09HDscape-server/src/org/crandor/game/content/global/tutorial/CharacterDesign.java
+++ b/09HDscape-server/src/org/crandor/game/content/global/tutorial/CharacterDesign.java
@@ -336,19 +336,19 @@ public final class CharacterDesign {
return val;
}
- //Male head ids : Script - 701 [0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 91: 10 92: 11 93: 12 94: 13 95: 14 96: 15 97: 16 261: 17 262: 18 263: 19 264: 20 265: 21 266: 22 267: 23 268: 24 ]
- //Female head ids: Script - 689 [45: 1 46: 2 47: 3 48: 4 49: 5 50: 6 51: 7 52: 8 53: 9 54: 10 135: 11 136: 12 137: 13 138: 14 139: 15 140: 16 141: 17 142: 318 143: 19 144: 20 145: 21 146: 22 269: 23 270: 24 271: 25 272: 26 273: 27 274: 28 275: 29 276: 30 277: 31 278: 32 279: 33 280: 34 ]
- //Male jaw ids: Script - 703 [10: 1 11: 2 12: 3 13: 4 14: 5 15: 6 16: 7 17: 8 98: 9 99: 10 100: 11 101: 12 102: 13 103: 14 104: 15 305: 16 306: 17 307: 18 308: 19 ]
- //Male torso ids: Script - 1128 [19: 1 20: 2 21: 3 22: 4 23: 5 24: 6 25: 7 111: 8 112: 9 113: 10 114: 11 115: 12 116: 13 ]
- //Female torso ids: Script - 1129 [57: 1 58: 2 59: 3 60: 4 153: 5 154: 6 155: 7 156: 8 157: 9 158: 10 ]
- //Male arm ids: Script - 1130 [27: 1 28: 2 29: 3 30: 4 31: 5 105: 6 106: 7 107: 8 108: 9 109: 10 110: 11 ]
- //Female arm ids: Script - 1131 [62: 1 63: 2 64: 3 65: 4 147: 5 148: 6 149: 7 150: 8 151: 9 152: 10 ]
- //Male hand ids: Script - 1132 [34: 1 84: 2 117: 3 118: 4 119: 5 120: 6 121: 7 122: 8 123: 9 124: 10 125: 11 126: 12 ]
- //Female hand ids: Script - 1133 [68: 1 127: 2 159: 3 160: 4 161: 5 162: 6 163: 7 164: 8 165: 9 166: 10 167: 11 168: 12 ]
- //Male leg ids: Script - 1134 [37: 1 38: 2 39: 3 40: 4 85: 5 86: 6 87: 7 88: 8 89: 9 90: 10 ]
- //Female leg ids: Script - 1135 [71: 1 72: 2 73: 3 74: 4 75: 5 76: 6 77: 7 128: 8 129: 9 130: 10 131: 11 132: 12 133: 13 134: 14 ]
- //Male feet ids: Script - 1136 [43: 1 ]
- //Female feet ids: Script - 1137 [80: 1 ]
+ //Male head ids : ScriptAPI - 701 [0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 91: 10 92: 11 93: 12 94: 13 95: 14 96: 15 97: 16 261: 17 262: 18 263: 19 264: 20 265: 21 266: 22 267: 23 268: 24 ]
+ //Female head ids: ScriptAPI - 689 [45: 1 46: 2 47: 3 48: 4 49: 5 50: 6 51: 7 52: 8 53: 9 54: 10 135: 11 136: 12 137: 13 138: 14 139: 15 140: 16 141: 17 142: 318 143: 19 144: 20 145: 21 146: 22 269: 23 270: 24 271: 25 272: 26 273: 27 274: 28 275: 29 276: 30 277: 31 278: 32 279: 33 280: 34 ]
+ //Male jaw ids: ScriptAPI - 703 [10: 1 11: 2 12: 3 13: 4 14: 5 15: 6 16: 7 17: 8 98: 9 99: 10 100: 11 101: 12 102: 13 103: 14 104: 15 305: 16 306: 17 307: 18 308: 19 ]
+ //Male torso ids: ScriptAPI - 1128 [19: 1 20: 2 21: 3 22: 4 23: 5 24: 6 25: 7 111: 8 112: 9 113: 10 114: 11 115: 12 116: 13 ]
+ //Female torso ids: ScriptAPI - 1129 [57: 1 58: 2 59: 3 60: 4 153: 5 154: 6 155: 7 156: 8 157: 9 158: 10 ]
+ //Male arm ids: ScriptAPI - 1130 [27: 1 28: 2 29: 3 30: 4 31: 5 105: 6 106: 7 107: 8 108: 9 109: 10 110: 11 ]
+ //Female arm ids: ScriptAPI - 1131 [62: 1 63: 2 64: 3 65: 4 147: 5 148: 6 149: 7 150: 8 151: 9 152: 10 ]
+ //Male hand ids: ScriptAPI - 1132 [34: 1 84: 2 117: 3 118: 4 119: 5 120: 6 121: 7 122: 8 123: 9 124: 10 125: 11 126: 12 ]
+ //Female hand ids: ScriptAPI - 1133 [68: 1 127: 2 159: 3 160: 4 161: 5 162: 6 163: 7 164: 8 165: 9 166: 10 167: 11 168: 12 ]
+ //Male leg ids: ScriptAPI - 1134 [37: 1 38: 2 39: 3 40: 4 85: 5 86: 6 87: 7 88: 8 89: 9 90: 10 ]
+ //Female leg ids: ScriptAPI - 1135 [71: 1 72: 2 73: 3 74: 4 75: 5 76: 6 77: 7 128: 8 129: 9 130: 10 131: 11 132: 12 133: 13 134: 14 ]
+ //Male feet ids: ScriptAPI - 1136 [43: 1 ]
+ //Female feet ids: ScriptAPI - 1137 [80: 1 ]
}
diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java b/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java
index 0b30fc11f..a17372a06 100644
--- a/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java
+++ b/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java
@@ -248,7 +248,6 @@ public class Player extends Entity {
*/
private final HunterManager hunterManager = new HunterManager(this);
-
/**
* The treasure trail manager.
*/
@@ -274,7 +273,6 @@ public class Player extends Entity {
*/
private final IronmanManager ironmanManager = new IronmanManager(this);
-
/**
* The logout plugins.
*/
diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java
index bca2e58d2..23385fcb0 100644
--- a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java
+++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/AIPlayer.java
@@ -5,9 +5,13 @@ import org.crandor.game.interaction.DestinationFlag;
import org.crandor.game.interaction.MovementPulse;
import org.crandor.game.node.entity.Entity;
import org.crandor.game.node.entity.player.Player;
+import org.crandor.game.node.entity.player.ai.general.ScriptAPI;
+import org.crandor.game.node.entity.player.ai.general.scriptrepository.Script;
import org.crandor.game.node.entity.player.info.PlayerDetails;
+import org.crandor.game.system.task.Pulse;
import org.crandor.game.world.map.Location;
import org.crandor.tools.StringUtils;
+import plugin.skill.thieving.ThievingOptionPlugin;
import java.util.HashMap;
import java.util.Map;
@@ -52,7 +56,12 @@ public class AIPlayer extends Player {
* The player controlling this AIP.
*/
private Player controler;
-
+
+ /**
+ * The scriptAPI the bot will perform
+ */
+ private ScriptAPI scriptAPI;
+
/**
* Constructs a new {@code AIPlayer} {@code Object}.
* @param name The name of the AIP.
@@ -66,6 +75,7 @@ public class AIPlayer extends Player {
super.getDetails().setSession(ArtificialSession.getSingleton());
this.username = StringUtils.formatDisplayName(name);
this.uid = currentUID++;
+ this.scriptAPI = new ScriptAPI();
}
@Override
@@ -133,6 +143,26 @@ public class AIPlayer extends Player {
this.setAttribute("dead", true);
}
+ public void runScript(Script script)
+ {
+ if (!this.getPulseManager().hasPulseRunning())
+ {
+ getPulseManager().run(new Pulse() {
+ @Override
+ public boolean pulse() {
+ return false;
+ }
+
+ @Override
+ public boolean update() {
+ super.update();
+ script.runLoop();
+ return true;
+ }
+ });
+ }
+ }
+
/**
* Gets the UID.
* @return the UID.
@@ -192,5 +222,4 @@ public class AIPlayer extends Player {
public void setControler(Player controler) {
this.controler = controler;
}
-
}
\ No newline at end of file
diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/GeneralBotCreator.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/GeneralBotCreator.java
new file mode 100644
index 000000000..8311a6ecc
--- /dev/null
+++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/GeneralBotCreator.java
@@ -0,0 +1,35 @@
+package org.crandor.game.node.entity.player.ai.general;
+
+import org.crandor.game.node.entity.player.ai.AIPBuilder;
+import org.crandor.game.node.entity.player.ai.AIPlayer;
+import org.crandor.game.node.entity.player.ai.general.scriptrepository.Script;
+import org.crandor.game.system.task.Pulse;
+import org.crandor.game.world.GameWorld;
+import org.crandor.game.world.map.Location;
+import org.crandor.game.world.repository.Repository;
+
+public class GeneralBotCreator {
+
+ public GeneralBotCreator(String botName, Location loc, Script botScript)
+ {
+ AIPlayer bot = AIPBuilder.create(botName, loc);
+ Repository.getPlayers().add(bot);
+ bot.init();
+ botScript.setPlayer(bot);
+
+ GameWorld.submit(new Pulse(1, bot) {
+ int ticks = 0;
+ @Override
+ public boolean pulse() {
+ if (ticks ++ == 5000)
+ {
+ AIPlayer.deregister(bot.getUid());
+ return true;
+ }
+
+ bot.runScript(botScript);
+ return false;
+ }
+ });
+ }
+}
diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/ScriptAPI.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/ScriptAPI.java
new file mode 100644
index 000000000..f4e54af64
--- /dev/null
+++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/ScriptAPI.java
@@ -0,0 +1,49 @@
+package org.crandor.game.node.entity.player.ai.general;
+
+import org.crandor.game.node.entity.npc.NPC;
+import org.crandor.game.node.entity.player.Player;
+import org.crandor.game.node.object.GameObject;
+import org.crandor.game.world.map.Location;
+import org.crandor.game.world.map.RegionManager;
+import org.crandor.game.world.map.RegionPlane;
+import org.crandor.game.world.map.path.Pathfinder;
+
+public class ScriptAPI {
+
+ public double distance(Location l1, Location l2) {
+ return Pathfinder.find(l1, l2).getPoints().size();
+ }
+
+ public NPC getNearestNPC(Location loc, String npcName) {
+ NPC npc = null;
+ double minDistance = Double.MAX_VALUE;
+ for (RegionPlane p : RegionManager.forId(loc.getRegionId()).getPlanes()) {
+ for (NPC n : p.getNpcs()) {
+ if (n != null) {
+ if (n.getName().equals(npcName) && distance(loc, n.getLocation()) < minDistance) {
+ npc = n;
+ }
+ }
+ }
+ }
+
+ System.out.println("Returning " + npc.getName());
+ return npc;
+ }
+
+ public GameObject getNearestGameObject(Location loc, int objectId) {
+ GameObject nearestObject = null;
+ double minDistance = Double.MAX_VALUE;
+ for (GameObject[] o : RegionManager.forId(loc.getRegionId()).getPlanes()[0].getObjects()) {
+ for (GameObject obj : o) {
+ if (obj != null) {
+ if (distance(loc, obj.getLocation()) < minDistance) {
+ nearestObject = obj;
+ }
+ }
+ }
+ }
+
+ return nearestObject;
+ }
+}
diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/scriptrepository/ManThiever.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/scriptrepository/ManThiever.java
new file mode 100644
index 000000000..2f3cdd986
--- /dev/null
+++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/scriptrepository/ManThiever.java
@@ -0,0 +1,12 @@
+package org.crandor.game.node.entity.player.ai.general.scriptrepository;
+
+import org.crandor.game.node.entity.player.Player;
+import plugin.skill.thieving.ThievingOptionPlugin;
+
+public class ManThiever extends Script {
+
+ @Override
+ public void runLoop() {
+ new ThievingOptionPlugin().handle(me, scriptAPI.getNearestNPC(me.getLocation(), "Man"), "pickpocket");
+ }
+}
diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/scriptrepository/Script.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/scriptrepository/Script.java
new file mode 100644
index 000000000..534575d34
--- /dev/null
+++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/general/scriptrepository/Script.java
@@ -0,0 +1,16 @@
+package org.crandor.game.node.entity.player.ai.general.scriptrepository;
+
+import org.crandor.game.node.entity.player.Player;
+import org.crandor.game.node.entity.player.ai.general.ScriptAPI;
+
+public abstract class Script {
+ public Player me;
+ public ScriptAPI scriptAPI = new ScriptAPI();
+
+ public void setPlayer(Player me)
+ {
+ this.me = me;
+ }
+
+ public abstract void runLoop();
+}
diff --git a/09HDscape-server/src/org/crandor/game/system/script/ScriptCompiler.java b/09HDscape-server/src/org/crandor/game/system/script/ScriptCompiler.java
index bbf05eb0e..0c597b219 100644
--- a/09HDscape-server/src/org/crandor/game/system/script/ScriptCompiler.java
+++ b/09HDscape-server/src/org/crandor/game/system/script/ScriptCompiler.java
@@ -137,7 +137,7 @@ public final class ScriptCompiler {
line = rawScript.poll();
if (line == null) {
br.close();
- throw new ScriptException("Script " + file.getName() + " is empty!", -1);
+ throw new ScriptException("ScriptAPI " + file.getName() + " is empty!", -1);
}
br.close();
ScriptContext context = parseScript(line, rawScript, new ScriptEntry(null, null, null, false), null);
diff --git a/09HDscape-server/src/org/crandor/game/system/script/ScriptContext.java b/09HDscape-server/src/org/crandor/game/system/script/ScriptContext.java
index 13d613994..9fa2e7dd7 100644
--- a/09HDscape-server/src/org/crandor/game/system/script/ScriptContext.java
+++ b/09HDscape-server/src/org/crandor/game/system/script/ScriptContext.java
@@ -1,7 +1,7 @@
package org.crandor.game.system.script;
/**
- * Script context, this can be a condition or an instruction.
+ * ScriptAPI context, this can be a condition or an instruction.
* @author Emperor
*/
public abstract class ScriptContext {
diff --git a/09HDscape-server/src/org/crandor/game/system/script/context/InvItemCondition.java b/09HDscape-server/src/org/crandor/game/system/script/context/InvItemCondition.java
index 2bccc833a..36b9b1f94 100644
--- a/09HDscape-server/src/org/crandor/game/system/script/context/InvItemCondition.java
+++ b/09HDscape-server/src/org/crandor/game/system/script/context/InvItemCondition.java
@@ -7,7 +7,7 @@ import org.crandor.game.system.script.ScriptContext;
import java.util.Arrays;
/**
- * Script condition for checking if a player has an item in the inventory.
+ * ScriptAPI condition for checking if a player has an item in the inventory.
* @author Emperor
*/
public final class InvItemCondition extends ScriptContext {
diff --git a/09HDscape-server/src/org/crandor/game/system/script/context/WGuildTokenCondition.java b/09HDscape-server/src/org/crandor/game/system/script/context/WGuildTokenCondition.java
index a4e1facd9..e6b0e2e59 100644
--- a/09HDscape-server/src/org/crandor/game/system/script/context/WGuildTokenCondition.java
+++ b/09HDscape-server/src/org/crandor/game/system/script/context/WGuildTokenCondition.java
@@ -4,7 +4,7 @@ import org.crandor.game.node.entity.player.Player;
import org.crandor.game.system.script.ScriptContext;
/**
- * Script condition for checking if a player has warrior guild tokens.
+ * ScriptAPI condition for checking if a player has warrior guild tokens.
* @author 'Vexia
*/
public final class WGuildTokenCondition extends ScriptContext {
diff --git a/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java b/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java
index d26f223ed..5de848e44 100644
--- a/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java
+++ b/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java
@@ -1,6 +1,5 @@
package org.crandor.net.packet.out;
-import com.oracle.jrockit.jfr.DataType;
import org.crandor.net.packet.IoBuffer;
import org.crandor.net.packet.OutgoingPacket;
import org.crandor.net.packet.context.CSConfigContext;
diff --git a/09HDscape-server/src/plugin/command/AIPCommandPlugin.java b/09HDscape-server/src/plugin/command/AIPCommandPlugin.java
index 2534a5663..bbec35221 100644
--- a/09HDscape-server/src/plugin/command/AIPCommandPlugin.java
+++ b/09HDscape-server/src/plugin/command/AIPCommandPlugin.java
@@ -4,6 +4,8 @@ import org.crandor.game.interaction.Interaction;
import org.crandor.game.node.entity.player.Player;
import org.crandor.game.node.entity.player.ai.AIPBuilder;
import org.crandor.game.node.entity.player.ai.AIPlayer;
+import org.crandor.game.node.entity.player.ai.general.GeneralBotCreator;
+import org.crandor.game.node.entity.player.ai.general.scriptrepository.ManThiever;
import org.crandor.game.node.entity.player.ai.pvp.PVPAIPActions;
import org.crandor.game.node.entity.player.ai.pvp.PVPAIPBuilderUtils;
import org.crandor.game.node.entity.player.ai.resource.ResourceAIPActions;
@@ -25,6 +27,7 @@ import java.util.List;
/**
* Handles the AIPlayer commands.
+ * These commands are for bots
* @author Emperor
*/
@InitializablePlugin
@@ -176,6 +179,14 @@ public final class AIPCommandPlugin extends CommandPlugin {
case "pvpfight":
PVPAIPActions.syncBotThread(player);
return true;
+
+ /*
+ Start regular bots
+ */
+ case "manthiev":
+ new GeneralBotCreator("Bot", player.getLocation(), new ManThiever());
+ break;
+
}
return false;
}