Jump to content

TheScrub

Members
  • Posts

    1130
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by TheScrub

  1. TheScrub

    Search Bank

    i like to use a while loop for sleeps but i don't like to use it in snippets obviously you can add sleeps...
  2. TheScrub

    Search Bank

    tested search and bankIsOpen import org.osbot.script.Script; import org.osbot.script.rs2.ColorPicker; import org.osbot.script.rs2.ui.RS2InterfaceChild; public class Bank { Script script; public boolean bankIsOpen() { if (script.client.getInterface(12) != null) { RS2InterfaceChild searchbutton = script.client.getInterface(12) .getChild(20); if (searchbutton != null && searchbutton.isVisible()) { return true; } } return false; } public static void searchBank(String item) throws InterruptedException { RS2InterfaceChild button = Context.script.client.getInterface(12) .getChild(20); if (button != null) { button.interact("Search"); } ColorPicker text = new ColorPicker(Context.script.bot); if (text.colorAt(260, 431).getBlue() > 0 && text.colorAt(294, 403).getBlue() == 0) { Context.script.client.typeString(item); } } public static void depositInventory() throws InterruptedException { RS2InterfaceChild button = Context.script.client.getInterface(12) .getChild(22); if (button != null) { button.interact("Deposit inventory"); } } public static void depositWornItems() throws InterruptedException { RS2InterfaceChild button = Context.script.client.getInterface(12) .getChild(24); if (button != null) { button.interact("Deposit worn items"); } } private static Rectangle returnRectangle(int minX, int minY, int maxX, int maxY) { int height = maxY - minY; int width = maxX - minX; Rectangle r = new Rectangle(minX, minY, width, height); return r; } private static Point centrePointOfRectangle(int minX, int minY, int maxX, int maxY) { int centreGapY = (maxY - minY) / 2; int centreGapX = (maxX - minX) / 2; int Y = minY + centreGapY; int X = minX + centreGapX; Point centre = new Point(X, Y); return centre; } /* * only works for the first top four slots of the bank * you will need the brightness to be on the right colour * any other withdrawing can be done using the select option method * */ public static void withdrawOne(int green, int red, int blue) throws InterruptedException { ColorPicker bankitem = new ColorPicker(Context.script.bot); Point slot1 = (centrePointOfRectangle(74, 73, 102, 97)); Point slot2 = (centrePointOfRectangle(122, 73, 147, 97)); Point slot3 = (centrePointOfRectangle(170, 73, 192, 97)); Point slot4 = (centrePointOfRectangle(218, 73, 237, 97)); Point row[] = { slot1, slot2, slot3, slot4 }; for (Point p : row) { if (bankitem.colorAt(p.x, p.y).getRed() == red && bankitem.colorAt(p.x, p.y).getBlue() == blue && bankitem.colorAt(p.x, p.y).getGreen() == green) { Context.script.client .moveMouse( new RectangleDestination(new Rectangle( returnRectangle(p.x - 22, p.y - 22, p.x + 22, p.y + 22))), true); if (returnRectangle(p.x - 22, p.y - 22, p.x + 22, p.y + 22) .contains( Context.script.client.getMousePosition() .getLocation())) { Context.script.client.clickMouse(false); } } } } public static void logColours() throws InterruptedException { ColorPicker bankitem = new ColorPicker(Context.script.bot); if (Context.script.client.getInterface(12) != null) { RS2InterfaceChild searchbutton = Context.script.client .getInterface(12).getChild(20); if (searchbutton != null && searchbutton.isVisible()) { Point slot1 = (centrePointOfRectangle(74, 73, 102, 97)); Point slot2 = (centrePointOfRectangle(122, 73, 147, 97)); Point slot3 = (centrePointOfRectangle(170, 73, 192, 97)); Point slot4 = (centrePointOfRectangle(218, 73, 237, 97)); Point row[] = { slot1, slot2, slot3, slot4 }; for (Point p : row) { Context.script.log(" " + "Red " + bankitem.colorAt(p.x, p.y).getRed()); Context.script.log("Blue: " + bankitem.colorAt(p.x, p.y).getBlue()); Context.script.log("Green: " + bankitem.colorAt(p.x, p.y).getGreen()); } } } } }
  3. TheScrub

    Teamspeak

    Name:OSBot TeamSpeak Address:ts101.light-speed.com:8064
  4. thanks i didn't know they updated the bank api to get item by name if you check my older snippets... thanks though!
  5. TheScrub

    2 new av's

    Thank you will give good feedback
  6. this method is useful for stuff like withdrawing ring of duelings so u can have an array of strings and it will search the bank and find the first one if not it will find the second third fourth fifth etc... or potions private String getBankItem(String items[]) { String item; if (client.getBank().isOpen()) { Item[] bankitems = client.getBank().getItems(); if (items.length > 0 && items != null) { for (String correctItem : items) { for (int i = 0; i < bankitems.length; i++) { if (bankitems[i].getName().contains(correctItem)) { item = correctItem; return item; } } } } } return null; }
  7. and also this is the snippet section some one please move to this to another section of the forums!
  8. link to an open source work of my mine http://osbot.org/forum/topic/12097-rfd-bank-soft-clay-open-source/
  9. thanks i just wrote it for a single thing only used it once or twice thanks i will update the thread with ur revision of the code!
  10. so i'm making a script with a combat location in an odd shapped room and a rectangle won't work so i deiced to make a little class to for a polygon area -edit was rewritten by guy below me. import java.awt.Polygon; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.Entity; public class PolygonArea { Polygon polygon; PolygonArea(Position... positions) { polygon = new Polygon(); addPositions(positions); } public boolean containsEntity(Entity e) { return polygon.contains(e.getX(), e.getY()); } public static void addPositions(Position... positions) { for (Position pos : positions) { polygon.addPoint(pos.getX(), pos.getY()); } } } How to use PolygonArea polygonArea = new PolygonArea(positionsArray); Check for entities in the area with this (NPC, Player, GroundItems, etc): if (polygonArea.containsEntity(entity)) { //do method } i still need to make a method to return the center of the polygon but i will touch on that later
  11. whoops basic math error lol thanks for the pickup!
  12. yer i have that on mine didn't update not many people post on my snippets will update in 2 mins
  13. this is useful for a mouse destination it's so you don't have to do maths because some people are bad at math /* * @param minX this is the top left hand corner of the rectangle * @param minY this is the top left hand corner of the rectangle * @param maxX this is the bottom right hand corner of the rectangle * @param maxY this is the bottom right hand corner of the rectangle */ private Rectangle returnRectangle(int minX, int minY, int maxX, int maxY){ int height = maxY-minY; int width = maxX-minX; Rectangle r = new Rectangle(minX, minY, width, height); return r; } use: MouseDestination md = new RectangleDestination(returnRectangle(20,30,40,50)); this will do the math for the height and width..... so the width and height in this example would return: width:20 height:20
  14. upgrading this to a full working api class by the end of the week,
  15. lol so true haha you know it!
  16. Still needs more Weapons please post the infomation in this order "Name",Item ID,SpecPercent (the spec percent it uses)
  17. import org.osbot.script.Script; public class Spec_Attacks { Script script = Context.script; enum SpecWeapon { DragonDagger("Dragon dagger", 1215, 25), DragonScim("Dragon scimitar", 4587, 55), Whip("Abyssal whip", 4151, 50), Magic_Shortbow( "Magic shortbow", 861, 55), DragonDaggerP("Dragon dagger(p)", 1231, 25), DragonBattleaxe("Dragon battleaxe", 1377, 100); private final int id; private final int specpercent; private final String name; SpecWeapon(String name, int id, int specpercent) { this.name = name; this.id = id; this.specpercent = specpercent; } public String getName() { return name; } public int getId() { return id; } public int getSpecPercent() { return specpercent; } } public static int possibleSpecsForSpecBar(SpecWeapon Spec) { int remanningspec = Context.script.combat.getSpecialPercentage(); double d = remanningspec / Spec.getSpecPercent(); long l = Math.round(d); String s = String.valueOf(l); int specsforafullbar = Integer.parseInt(s); return specsforafullbar; } public static void SwitchWeaponTo(String name, Integer timeout) throws InterruptedException { String g[] = { "Wear", "Wield" }; long t = System.currentTimeMillis(); if (!Context.script.equipmentTab.isWieldingWeapon(name)) { for (String option : g) { Context.script.client.getInventory().interactWithName(name, option); } while (!Context.script.equipmentTab.isWieldingWeapon(name) && System.currentTimeMillis() - t < timeout) { Context.script.sleep(50); } } } } import org.osbot.script.Script; public class Context extends Script { public static Script script; } use in your script you will need to do this i'm using the context class as i got several class's that use api methods so it's easier. @Override public void onStart() { Context.script=this; } the first parameter is the name of the weapon or could have an Armour wouldn't matter and the 2nd parameter is for the dynamic sleep type thing in the spec attacks class i like 3000ms before it will retry if (Spec_Attacks.possibleSpecsForSpecBar(SpecWeapon.DragonDagger)>0){ Spec_Attacks.SwitchWeaponTo(SpecWeapon.DragonDagger.getName(), 3000); }
  18. Are you using a setting to determine which barrows brother is the tunnel?
  19. Persian dick as always Peter: If you want to start scripting and learn some java i will link you to some of the basics: Java Keywords: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html Wikipedia is best for the keywords as it gives a definition: http://en.wikipedia.org/wiki/List_of_Java_keywords Java parentheses: http://beginwithjava.blogspot.com.au/2008/07/parens-and-brackets-and-braces-oh-my.html explains the brackets you speak of.. Osbot API: www.osbot.org/api What is an API? http://en.wikipedia.org/wiki/Application_programming_interface Usefully java class's for scripting: http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html http://docs.oracle.com/javase/7/docs/api/java/lang/System.html Important for GUI'S! (User friendly is apart of scripting whether you like it or not) http://www.eclipse.org/windowbuilder/ And of course their is the osbot snippet section http://osbot.org/forum/forum/156-snippets/
  20. thats the parameter for people to understand ik what u mean should be item_name no caps i have String s in my parameter's i renamed it for people to understand
  21. Accredit me if you use it please i release these out of my own time! this will return the data type of an ArrayList<String> from the text file we could do this for an int or pretty much any other type of object public ArrayList<String> readConfigSettings(String Path, int LineLimt) throws Throwable { BufferedReader br = new BufferedReader(new FileReader(new File(Path))); ArrayList<String> lines = new ArrayList<String>(); for (int i = 0; i < LineLimt; i++) { lines.add(i, br.readLine().toString()); } br.close(); return lines; } in use... using the file we produced using my other snippet on writing script settings.. ArrayList<String> settings = readConfigSettings((System.getProperty("user.home")+ File.separator + "OSBot" + File.separator + "data"+ File.separator + "settings.txt"),3); String option_one = settings.get(0); // the array starts at 0 String option_two = settings.get(1); int option_three = Integer.parseInt(settings.get(2));
  22. Hey if you use this method and release the script leave an accreditation i release these snippets for the community... first we need to create a void like soo with a file name and the settings you want to it to save to an ".txt" file public void writeConfigSettings(String FileName,String... settings) throws IOException { Constructing the file writer and the exact name,location of the file // thanks to lackofchesee from TS3 for the path name! FileWriter f = new FileWriter(System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "data" + File.separator + FileName +".txt"); // writing to an exact path to the osbot data folder also constructing a FileWriter Running the settings though a for loop to get a single setting then writing it to the file and spacing it on a line below this will be needed to read the text in my reading settings file for (String setting : settings) { // running though the strings f.write(setting + System.getProperty("line.separator")); } just closing the FileWriter stream of output f.close(); // closing the stream } public void writeConfigSettings(String FileName,String... settings) throws IOException { // thanks to lackofchesee from TS3 for the path name! FileWriter f = new FileWriter(System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "data" + File.separator + FileName+".txt"); // writing to an exact path for (String setting : settings) { // running though the strings f.write(setting + System.getProperty("line.separator")); } f.close(); // closing the stream } in use String selected_herbs[] ={"Ranarr","Guam"}; writeConfigSettings("Settings",selected_herbs); this will save a .txt file in the data folder that will look like this called "Settings" Ranarr Guam
  23. TheScrub

    Get Time

    havet tested in the morning public String getTime(){ Date d = new Date(); int Hour = d.getHours(); int Min= d. getMinutes(); String realMin= null; String realHour = null; String aSide = null; if (Min <10){ realMin="0"+Min; } if (Hour >12){ aSide="PM"; int i = d.getHours()-12; realHour = ""+i; } if (Hour <12){ aSide="AM"; } if (Min >9){ realMin = ""+Min; } String time =realHour+":"+realMin+" "+aSide; return time; //unfinished }
  24. TheScrub

    Screen Shot

    Was bored soo w/ee Ideas on how to use Have a area on your paint and call the method if a mouse action. Display the image instead of writing on a jframe or jpanel etc. many more ways! public void takePicture() throws AWTException { Robot r = new Robot(); BufferedImage screenShot = r.createScreenCapture(new Rectangle( Toolkit.getDefaultToolkit().getScreenSize())); Date d = new Date(); int currentHour = d.getHours(); // deprecated methods i don't know the new ones int currentMin = d.getMinutes(); // same as the Hour String format = null; if (currentHour >11){ format="PM"; } if (currentHour <12){ format="AM"; } try { ImageIO.write(screenShot, "JPG", new File("Script_Name"+currentHour+"_"+currentMin+format+".jpg")); } catch (IOException e) { e.printStackTrace(); } }
  25. http://osbot.org/forum/topic/11091-banking-with-names/
×
×
  • Create New...