ruler
2007-07-03 01:54:20
Well, genodemon has been buggin me to bring back UBI.* So i coded that stuff needed to do it.* Now he wants me to do the SCAR code when he is the scripter….
Anyone want to code this?
connect to socket 3000, send strings and parse results.
UBI in it new form runs on top of iBot is able to use everything from the iBot api.
/*
* Commands:
* getx
* gety
* doweb int int
* dowalk int int
* dobank
* mousemove int int
* mouseclickr int int
* mouseclickl int int
*/
Anyone want to code this?
connect to socket 3000, send strings and parse results.
UBI in it new form runs on top of iBot is able to use everything from the iBot api.
/*
* Commands:
* getx
* gety
* doweb int int
* dowalk int int
* dobank
* mousemove int int
* mouseclickr int int
* mouseclickl int int
*/
package impsoft.nexus.bots.ubi;
import impsoft.nexus.bots.color.ColorBot;
import impsoft.nexus.bots.color.scriptable.ColorScript;
import impsoft.nexus.bots.reflection.objects.AryanPath;
import impsoft.nexus.bots.reflection.structures.AryanTile;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class UbiScript extends ColorScript {
public static String[] commands = new String[] { "" };
public final static int PORT = 3000;
public UbiScript(ColorBot b) {
super(b);
}
/*
* Commands:
* getx
* gety
* doweb int int
* dowalk int int
* dobank
* mousemove int int
* mouseclickr int int
* mouseclickl int int
*/
public void script() throws InterruptedException, Exception {
log("UBI START");
ServerSocket server = new ServerSocket(PORT);
while (true) {
Socket aSocket = server.accept();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(
aSocket.getInputStream()));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
aSocket.getOutputStream()));
while (true) {
String packet = in.readLine();
debug("Packet Recieved: '" + packet + "'");
try {
if (packet.contains("get")) {
if (packet.equals("getx")) {
out.write(getLocation().x);
} else if (packet.equals("gety")) {
out.write(getLocation().y);
}
} else if (packet.contains("do")) {
if (packet.contains("web")) {
String firstSpace = packet.substring(packet
.indexOf(" ") + 1);
String secondSpace = firstSpace
.substring(packet.indexOf(" ") + 1);
int x = Integer.parseInt(firstSpace.trim());
int y = Integer.parseInt(secondSpace.trim());
theWorldMap.walkTo(new AryanTile(x, y));
} else if (packet.contains("walk")) {
String firstSpace = packet.substring(packet
.indexOf(" ") + 1);
String secondSpace = firstSpace
.substring(packet.indexOf(" ") + 1);
int x = Integer.parseInt(firstSpace.trim());
int y = Integer.parseInt(secondSpace.trim());
new AryanPath(new AryanTile(x, y), this)
.walkToEnd();
} else if (packet.contains("bank")) {
theWorldMap.walkToBank();
}
} else if (packet.contains("mouse")) {
String firstSpace = packet.substring(packet
.indexOf(" ") + 1);
String secondSpace = firstSpace
.substring(packet.indexOf(" ") + 1);
int x = Integer.parseInt(firstSpace.trim());
int y = Integer.parseInt(secondSpace.trim());
if(packet.contains("move")){
mouseMove(x, y);
}else if(packet.contains("clickr")){
mouseClickRight(x, y);
}else if(packet.contains("clickl")){
mouseClickLeft(x, y);
}
out.write("done");
}
} catch (IOException ioe) {
throw ioe;
} catch (InterruptedException e) {
throw e;
} catch (Throwable t) {
log("Exception in processing packet");
exception(t);
}
}
} catch (IOException ioe) {
log("Lost Connection");
return;
}
}
}
}