yammouni
2012-02-21 23:20:02
i found this script that worked on rs bot, is there any way to make it compatible to simba ?
/* Script By Henry11200 */
/* Walking by Garrett */
/* Save as HenrysWineGrabber.java */
import org.rsbot.bot.Bot;
import org.rsbot.bot.input.Mouse;
import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.event.listeners.ServerMessageListener;
import org.rsbot.script.*;
import org.rsbot.script.Bank;
import org.rsbot.script.wrappers.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Map;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ScriptManifest(authors = { "Henry11200" }, category = "Magic", name = "Henry's Wine Grabber", version = 0.1, description = "Start script and set settings in GUI")
public class HenrysWineGrabber extends Script implements PaintListener, ServerMessageListener {
private final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
public RSTile[] To1 = {new RSTile(2946, 3368), new RSTile(2946, 3374), new RSTile(2952, 3379), new RSTile(2959, 3383),
new RSTile(2966, 3388), new RSTile(2966, 3396), new RSTile(2966, 3402), new RSTile(2966, 3408),
new RSTile(2961, 3414), new RSTile(2956, 3419), new RSTile(2952, 3425), new RSTile(2948, 3432),
new RSTile(2948, 3438), new RSTile(2949, 3444), new RSTile(2949, 3448), new RSTile(2949, 3454),
new RSTile(2949, 3461), new RSTile(2949, 3467), new RSTile(2949, 3473), new RSTile(2946, 3480),
new RSTile(2946, 3486), new RSTile(2946, 3492), new RSTile(2939, 3496), new RSTile(2938, 3502),
new RSTile(2941, 3507), new RSTile(2941, 3513), new RSTile(2942, 3517)};
RSTile[] To2 = {new RSTile(2945, 3369), new RSTile(2949, 3376), new RSTile(2957, 3383), new RSTile(2966, 3389),
new RSTile(2966, 3396), new RSTile(2965, 3402), new RSTile(2963, 3407), new RSTile(2960, 3413),
new RSTile(2957, 3417), new RSTile(2954, 3422), new RSTile(2952, 3428), new RSTile(2948, 3434),
new RSTile(2947, 3440), new RSTile(2947, 3447), new RSTile(2945, 3454), new RSTile(2945, 3461),
new RSTile(2944, 3467), new RSTile(2944, 3474), new RSTile(2944, 3481), new RSTile(2944, 3489),
new RSTile(2942, 3496), new RSTile(2941, 3502), new RSTile(2941, 3509), new RSTile(2942, 3516),
new RSTile(2934, 3515)};
RSTile[] Run = {new RSTile(2934, 3516), new RSTile(2941, 3510), new RSTile(2941, 3501), new RSTile(2942, 3494)};
public RSTile InSide = new RSTile(2932,3515);
final RSTile BankTile = new RSTile(2945,3368);
final TheWalker theWalker = new TheWalker();
final int[] Not = {563,555};
public int count = 0;
public boolean Spell = false;
final int Wine = 245;
int Table = 595;
public int mx = -1;
public int my = -1;
final int Law = 563;
final int Water = 555;
public long startTime = System.currentTimeMillis();
public int startEXP;
public int startLvl;
String status = "Starting Up";
String antib = "OFF";
String ttt = "OFF";
public void onRepaint(Graphics g) {
long millis = System.currentTimeMillis() - startTime;
long hours = millis / (1000 * 60 * 60);
millis -= hours * (1000 * 60 * 60);
long minutes = millis / (1000 * 60);
millis -= minutes * (1000 * 60);
long seconds = millis / 1000;
Mouse m = Bot.getClient().getMouse();
//Settings
g.setColor( new Color(70, 234, 40, 150));
g.fillRect(459, 322, 60, 16);
g.setColor(new Color(0, 0, 0));
g.drawRect(459, 322, 60, 16);
g.setColor( new Color(70, 234, 40, 200));
g.drawRect(460, 323, 58, 14);
g.setColor( new Color(70, 234, 40, 100));
g.fillRect(459, 322, 60, 8);
g.setColor(new Color(255, 255, 255));
g.drawString("Settings", 464,334);
//About
g.setColor( new Color(70, 234, 40, 150));
g.fillRect(398, 322, 60, 16);
g.setColor(new Color(0, 0, 0));
g.drawRect(398, 322, 60, 16);
g.setColor( new Color(70, 234, 40, 200));
g.drawRect(399, 323, 58, 14);
g.setColor( new Color(70, 234, 40, 100));
g.fillRect(398, 322, 60, 8);
g.setColor(new Color(255, 255, 255));
g.drawString("About", 402,334);
//Status
g.setColor( new Color(70, 234, 40, 150));
g.fillRect(337, 322, 60, 16);
g.setColor(new Color(0, 0, 0));
g.drawRect(337, 322, 60, 16);
g.setColor( new Color(70, 234, 40, 200));
g.drawRect(338, 323, 58, 14);
g.setColor( new Color(70, 234, 40, 100));
g.fillRect(337, 322, 60, 8);
g.setColor(new Color(255, 255, 255));
g.drawString("Status", 341,334);
//Time Ran
g.setColor( new Color(70, 234, 40, 150));
g.fillRect(226, 322, 110, 16);
g.setColor(new Color(0, 0, 0));
g.drawRect(226, 322, 110, 16);
g.setColor( new Color(70, 234, 40, 200));
g.drawRect(227, 323, 108, 14);
g.setColor( new Color(70, 234, 40, 100));
g.fillRect(226, 322, 110, 8);
g.setColor(new Color(255, 255, 255));
g.drawString(
hours
+"h "
+minutes
+"min"
+seconds
+"sec", 234,334);
if(m.x >= 337 && m.x < 397 && m.y >= 321 && m.y < 337) {
g.setColor( new Color(70, 234, 40, 150));
g.fillRect(337, 175, 182, 147);
g.setColor(new Color(0, 0, 0));
g.drawRect(337, 175, 182, 147);
g.setColor(new Color(255, 255, 255));
g.drawString("Lvl's gained "+ (startLvl - skills.getCurrentSkillLevel(STAT_MAGIC)), 360,197);
g.setColor(new Color(255, 255, 255, 255));
g.drawString("EXP gained "+ (skills.getCurrentSkillExp(STAT_MAGIC) - startEXP), 360,230);
g.setColor(new Color(255, 255, 255));
g.drawString("Status: "+status, 360,263);
g.setColor(new Color(255, 255, 255));
g.drawString("Wine Grabbed: "+count, 360,296);
}
if(m.x >= 397 && m.x < 459 && m.y >= 321 && m.y < 337) {
g.setColor( new Color(70, 234, 40, 150));
g.fillRect(337, 175, 182, 147);
g.setColor(new Color(0, 0, 0));
g.drawRect(337, 175, 182, 147);
g.setColor(new Color(255, 255, 255));
g.drawString("Henry's Wine Grabber v"+ properties.version(), 365,197);
g.setColor(new Color(255, 255, 255));
g.drawString("Made by Henry11200 ", 375,263);
}
if(m.x >= 459 && m.x < 519 && m.y >= 321 && m.y < 337) {
if(Tele) {ttt = "ON";}
if(!Tele) {ttt = "OFF";}
g.setColor( new Color(70, 234, 40, 150));
g.fillRect(337, 175, 182, 147);
g.setColor(new Color(0, 0, 0));
g.drawRect(337, 175, 182, 147);
g.setColor(new Color(255, 255, 255));
g.drawString("Teleporting is "+ttt, 360,230);
if(antiban == true) {antib = "ON";}
if(antiban == false) {antib = "OFF";}
g.drawString("Antiban is " +antib, 360,263);
}
}
public boolean onStart(final Map<String, String> args) {
startEXP = skills.getCurrentSkillExp(STAT_MAGIC);
startLvl = skills.getCurrentSkillLevel(STAT_MAGIC);
new GUI();
while (!guidone) {
status = "GUI settings";
wait(1000);
}
no = Integer.valueOf(noo);
setCameraAltitude(true);
return true;
}
public static boolean guidone = false;
public static boolean antiban;
public static boolean Tele = false;
public static int no;
public static String noo;
@SuppressWarnings("serial")
class GUI extends JFrame implements ActionListener {
private JLabel descLabel = new JLabel("Start in falafor bank or at the Zamorak church.");
private JLabel descLabel1 = new JLabel("Have law runes in your inventory, air staff equiped");
private JLabel descLabel2 = new JLabel("and if you want to teleport some water runes.");
private JLabel descLabel3 = new JLabel("It can withdraw law runes and water runes.");
private JLabel descLabel4 = new JLabel("Have them in your bank where scipt can see them.");
private JLabel DL = new JLabel("How many runes you want to withdraw when out. 0 means all.");
private JButton startScript = new JButton("Start script");
private JPanel mainPanel = new JPanel();
private JTabbedPane tabs = new JTabbedPane();
private JCheckBox antibanBox = new JCheckBox("Use antiban");
private JCheckBox teleBox = new JCheckBox("Use Teleport");
private JTextField Many = new JTextField(5);;
public GUI() {
super(properties.name() + " v" + properties.version() + " - By Henry11200");
mainPanel.setLayout(new FlowLayout());
startScript.setActionCommand("start");
startScript.addActionListener(this);
mainPanel.add(descLabel);
mainPanel.add(descLabel1);
mainPanel.add(descLabel2);
mainPanel.add(descLabel3);
mainPanel.add(descLabel4);
mainPanel.add(DL);
mainPanel.add(Many);
Many.setText("0");
mainPanel.add(antibanBox);
mainPanel.add(teleBox);
mainPanel.add(startScript);
tabs.addTab("Settings", mainPanel);
add(tabs);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setPreferredSize(new Dimension(350, 220));
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("start")) {
HenrysWineGrabber.antiban = antibanBox.isSelected();
HenrysWineGrabber.Tele = teleBox.isSelected();
HenrysWineGrabber.guidone = true;
HenrysWineGrabber.noo = Many.getText();
dispose();
return;
}
}
}
public RSTile[] To(){
int randNo = random(0,2);
if(randNo == 0){
return To1;
}
if(randNo == 1){
return To2;
}
return To1;
}
public void ClickSpell(){
castSpell(44);
Spell = true;
}
public void GrabWine(){
if(!Spell){
ClickSpell();
}
if(Spell){
while(!WineCheck()){
status = "Waiting for Wine";
if(antiban) antiBan();
wait(random(200,400));
if(!Bot.getClient().isSpellSelected()){
return;
}
if(getMyPlayer().isInCombat()){
runAway();
return;
}
}
if(WineCheck()){
if(ClickedWine()){
while(getMyPlayer().getAnimation() != -1){
wait(random(200,500));
}
count++;
Spell = false;
}
}
}
}
/* Old Function, too slow */
public boolean GetWine(){
if(WineCheck()){
ClickSpell();
wait(random(200,500));
}
if(Spell){
if(WineCheck()){
if(ClickedWine()){
while(getMyPlayer().getAnimation() != -1){
wait(random(200,500));
}
Spell = false;
return true;
}
}
}
if(!Spell){
ClickSpell();
GetWine();
return true;
}
wait(random(200,500));
return false;
}
/* end old */
public boolean ClickedWine(){
status = "Grabbing Wine";
if(!Bot.getClient().isSpellSelected()){
ClickSpell();
wait(random(200,500));
}
RSItemTile WWW = getGroundItemByID(Wine);
if (WWW != null) {
RSTile tile = getGroundItemByID(Wine);
RSObject wine = getObjectAt(tile);
try {
if(WineCheck()){
mx = wine.getLocation().getScreenLocation().x + random(1,3);
my = wine.getLocation().getScreenLocation().y - random(9,11);
moveMouse(mx, my);
wait(random(50,150));
clickMouse(true);
}
else{return false;}
}catch(Exception e) {}
return true;
}
return false;
}
public boolean WineCheck(){
RSItemTile WWW = getGroundItemByID(Wine);
if (WWW != null) {
return true;
}
return false;
}
public boolean atLocation(){
if(distanceTo(InSide) < 4){
return true;
}
return false;
}
public boolean Walk(RSTile[] path) {
if(!getMyPlayer().isMoving() || distanceTo(getDestination()) <= 5)
return theWalker.walkTo(path, true);
return false;
}
public void BankIt(){
status = "Getting to bank";
if(Tele && getInventoryCountID(Water) > 0 && distanceTo(new RSTile(2965,3380)) > 26){
castSpell(46);
while(getMyPlayer().getAnimation() != -1){
wait(random(200,500));
}
wait(random(800,1500));
}
if(Walk(reversePath(To()))){
wait(random(100,300));
while(distanceTo(BankTile) < 5){
if(bank.open()){
status = "Banking";
wait(random(100,300));
bank.depositAllExcept(Not);
wait(random(100,300));
if(getInventoryCountID(Law) < 28){
bank.withdraw(Law,no);
wait(random(100,300));
}
if(getInventoryCountID(Water) < 1 && Tele){
bank.withdraw(Water,no);
wait(random(100,300));
}
bank.close();
return;
}
}
}
}
public void runAway(){
status = "Running from Mages";
setRun(true);
wait(random(300,500));
Walk(Run);
wait(random(300,900));
Walk(reversePath(Run));
wait(random(300,900));
}
public int loop() {
if(canContinue()){
clickContinue();
}
if(getInventoryCountID(Water) < 1 && Tele && atLocation()){
stopScript();
}
if(getInventoryCountID(Law) < 1 && atLocation()){
stopScript();
}
if(getMyPlayer().isInCombat()){
runAway();
return random(100,400);
}
if(isInventoryFull()){
BankIt();
return random(100,400);
}
if(!atLocation() && !isInventoryFull()){
if(Walk(To())){
walkTileMM(InSide);
return random(100,400);
}
}
GrabWine();
/* Old Method stuff
if(!WineCheck() && atLocation() && !isInventoryFull() && !Reloaded){
antiBan();
return random(300,600);
}
if(WineCheck() && atLocation() && !isInventoryFull() && !Reloaded)
{
if(!GetWine()){
return 1;
}
return random(200,300);
}*/
return random(200,300);
}
public void serverMessageRecieved(final ServerMessageEvent e) {
final String messageEvent = e.getMessage();
if (messageEvent.contains("oo late")) {
count–;
}
}
public int antiBan() {
final int ranNo = random(0, 55);
int angle;
switch (ranNo) {
case 3:
moveMouse(random(0, 700), random(0, 500));
return random(200, 400);
case 4:
moveMouse(random(0, 450), random(0, 400));
return random(200, 400);
}
return random(200, 450);
}
public int getInventoryCountID(final int… itemIDs) {
int total = 0;
for (final RSItem item : getInventoryItems()) {
if (item == null) {
continue;
}
for (final int ID : itemIDs) {
if (item.getID() == ID) {
total += item.getStackSize();
}
}
}
return total;
}
@Override
public void onFinish() {
}
public int speed = 10;
public void getMouseSpeed(final int speed) {
this.speed = speed;
getMouseSpeed();
}
protected int getMouseSpeed() {
return speed;
}
public class TheWalker {
Methods methods = new Methods();
Thread walker = null;
RSTile[] path = null;
public void drawMap(final Graphics g) {
if (walker != null && walker.isAlive()) {
Point myTile = tileToMinimap(getMyPlayer().getLocation());
Point center = new Point(myTile.x + 2, myTile.y + 2);
g.drawOval(center.x - 70, center.y - 70, 140, 140);
if (path == null) return;
for (int i = 0; i < path.length; i++) {
final RSTile tile = path;
final Point p = tileToMinimap(tile);
if (p.x != -1 && p.y != -1) {
g.setColor(Color.BLACK);
g.fillRect(p.x + 1, p.y + 1, 3, 3);
if (i > 0) {
final Point p1 = tileToMinimap(path);
g.setColor(Color.ORANGE);
if (p1.x != -1 && p1.y != -1)
g.drawLine(p.x + 2, p.y + 2, p1.x + 2, p1.y + 2);
}
}
}
Point tile = tileToMinimap(nextTile(path));
g.setColor(Color.RED);
if (tile.x != -1 && tile.y != -1) {
g.fillRect(tile.x + 1, tile.y + 1, 3, 3);
}
g.setColor(Color.BLACK);
}
}
public boolean walkTo(final RSTile[] path, final boolean waitUntilDest) {
Walker walkto = new Walker(path, 3, 10000);
walker = new Thread(walkto);
walker.start();
waitToMove(random(800, 1200));
if (waitUntilDest) {
while (walker.isAlive()) {
methods.wait(random(300, 600));
}
return walkto.done;
} else return true;
}
public Point tileToMM(RSTile tile) {
return new Point(tileToMinimap(tile).x + 2, tileToMinimap(tile).y + 2);
}
public boolean tileOnMM(RSTile tile) {
return pointOnMM(tileToMM(tile));
}
public boolean pointOnMM(Point point) {
Point myTile = tileToMM(getMyPlayer().getLocation());
Point center = new Point(myTile.x, myTile.y);
return (center.distance(point) < 70) ? true : false;
}
public RSTile getClosestTileOnMap(final RSTile tile) {
if (isLoggedIn() && !tileOnMM(tile)) {
try {
final RSTile loc = getMyPlayer().getLocation();
final RSTile walk = new RSTile((loc.getX() + tile.getX()) / 2, (loc.getY() + tile.getY()) / 2);
return tileOnMM(walk) ? walk : getClosestTileOnMap(walk);
} catch (final Exception e) { }
}
return tile;
}
public RSTile nextTile(RSTile[] path) {
for (int i = path.length - 1; i >= 0; i–) {
if (tileOnMM(path)) {
return path;
}
}
return getClosestTileOnMap(path[0]);
}
public class Walker implements Runnable {
RSTile tile = null;
boolean done = false;
boolean stop = false;
int movementTimer = 10000;
int distanceTo = 3;
Walker(final RSTile[] userpath) {
this.tile = userpath[userpath.length - 1];
path = userpath;
}
Walker(final RSTile[] userpath, final int distanceTo, final int movementTimer) {
this.tile = userpath[userpath.length - 1];
this.movementTimer = movementTimer;
this.distanceTo = distanceTo;
path = userpath;
}
public void run() {
long timer = System.currentTimeMillis();
RSTile lastTile = getMyPlayer().getLocation();
int randomReturn = random(5, 8);
while (distanceTo(tile) > distanceTo && !stop) {
if (!getMyPlayer().isMoving() || getDestination() == null || distanceTo(getDestination()) < randomReturn) {
RSTile nextTile = nextTile(path);
if (getDestination() != null && distanceBetween(getDestination(), nextTile) <= distanceTo) {
continue;
}
getMouseSpeed(random(6 , 8 ));
walkTileMM(nextTile);
getMouseSpeed(random(8 , 10 ));
waitToMove(random(800, 1200));
randomReturn = random(5, 8);
}
final RSTile myLoc = getMyPlayer().getLocation();
if (myLoc != lastTile) {
if (distanceBetween(myLoc, lastTile) > 30) {
stop = true;
}
timer = System.currentTimeMillis();
lastTile = myLoc;
}
if (System.currentTimeMillis() - timer > movementTimer) {
stop = true;
}
methods.wait(random(20, 40));
}
if (distanceTo(tile) <= distanceTo) {
done = true;
}
}
}
}
}