Created
August 10, 2012 21:39
-
-
Save TheBatScripts/3318257 to your computer and use it in GitHub Desktop.
sandwhich lady
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package scripts; | |
| import java.awt.Color; | |
| import java.awt.Graphics; | |
| import java.awt.Point; | |
| import java.awt.Rectangle; | |
| import java.awt.event.KeyEvent; | |
| import java.util.HashMap; | |
| import org.tribot.api.DTMs; | |
| import org.tribot.api.ScreenModels; | |
| import org.tribot.api.Text; | |
| import org.tribot.api.input.Keyboard; | |
| import org.tribot.api.input.Mouse; | |
| import org.tribot.api.types.ScreenModel; | |
| import org.tribot.api.types.colour.ColourPoint; | |
| import org.tribot.api.types.colour.DTM; | |
| import org.tribot.api.types.colour.DTMPoint; | |
| import org.tribot.api.types.colour.DTMSubPoint; | |
| import org.tribot.api.types.colour.Tolerance; | |
| import org.tribot.script.Script; | |
| import org.tribot.script.ScriptManifest; | |
| import org.tribot.script.interfaces.Painting; | |
| @ScriptManifest (authors = { "TheBat" }, category = "Randoms", name = "SandwichLady") | |
| public class SandwichLady extends Script implements Painting{ | |
| final Rectangle VIEWPORT = new Rectangle(3, 3, 513, 334); | |
| final Rectangle CHATBOX = new Rectangle(3, 338, 513, 140); | |
| final long lady = 196729904L, baguette = 1921350542L, portal = 2112519705L; | |
| HashMap<String,Long> models = new HashMap<String,Long>(); | |
| DTMPoint CHAT_DTM_PT = new DTMPoint(new Color(72, 117, 26), new Tolerance(20, 20, 20)); | |
| DTMSubPoint [] CHAT_DTM_PTS = { new DTMSubPoint(new ColourPoint(new Point(1, 7), new Color( 27, 66, 9)), new Tolerance(20, 20, 20),1)}; | |
| DTM dtmChatAdv = new DTM(CHAT_DTM_PT, CHAT_DTM_PTS); | |
| String type = ""; | |
| String [] sandwichesS = {"roll","squaresandwich","baguette","pie","doughnut","chocolatebar","trianglesandwich"}; | |
| long [] sandwichesL = {3930049076L,4008080172L,1921350542L,1294162568L,942276007L,1064858434L,84227012L}; | |
| @Override | |
| public void run() { | |
| buildList(); | |
| while(ScreenModels.find(baguette).length < 1){ | |
| chatLoop(); | |
| } | |
| while(ScreenModels.find(baguette).length > 0){ | |
| choose(type); | |
| } | |
| do{ | |
| Mouse.clickBox(225,462,293,473,1); | |
| sleep(775,925); | |
| }while(DTMs.find(dtmChatAdv, CHATBOX.x, CHATBOX.y, CHATBOX.x+CHATBOX.width, CHATBOX.y+CHATBOX.height).length > 0); | |
| Mouse.click(ScreenModels.find(portal)[0].base_point, 1); | |
| } | |
| private void chatLoop() { | |
| do{ | |
| if(DTMs.find(dtmChatAdv, CHATBOX.x, CHATBOX.y, CHATBOX.x+CHATBOX.width, CHATBOX.y+CHATBOX.height).length < 1){ | |
| int k = -1; | |
| ScreenModel [] ladyM = null; | |
| while(k < 0){ | |
| try{ | |
| Keyboard.pressKey((char)KeyEvent.VK_DOWN); | |
| Keyboard.pressKey((char)KeyEvent.VK_RIGHT); | |
| while((ladyM = ScreenModels.find(lady)).length < 0 || !VIEWPORT.contains(ladyM[0].base_point)){ | |
| sleep(75,125); | |
| } | |
| Keyboard.releaseKey((char)KeyEvent.VK_RIGHT); | |
| Keyboard.releaseKey((char)KeyEvent.VK_DOWN); | |
| k = 3; | |
| }catch(Exception e){ | |
| k = -1; | |
| } | |
| } | |
| Mouse.click(ladyM[0].base_point,1); | |
| while(DTMs.find(dtmChatAdv, CHATBOX.x, CHATBOX.y, CHATBOX.x+CHATBOX.width, CHATBOX.y+CHATBOX.height).length < 1){ | |
| sleep(75,125); | |
| } | |
| } | |
| type = pullType(Text.lineToString(Text.findCharsInArea(CHATBOX.x, CHATBOX.y, CHATBOX.width, CHATBOX.height, true), 0)); | |
| Mouse.clickBox(225,462,293,473,1); | |
| sleep(775,925); | |
| }while(DTMs.find(dtmChatAdv, CHATBOX.x, CHATBOX.y, CHATBOX.x+CHATBOX.width, CHATBOX.y+CHATBOX.height).length > 0); | |
| } | |
| private String pullType(String str) { | |
| for(int i = 0; i < sandwichesS.length; i++){ | |
| if(str.contains(sandwichesS [i])){ | |
| return sandwichesS [i]; | |
| } | |
| } | |
| return ""; | |
| } | |
| private void buildList() { | |
| for(int i = 0; i < sandwichesS.length; i++){ | |
| models.put(sandwichesS[i], sandwichesL[i]); | |
| } | |
| } | |
| public void onPaint(Graphics g) { | |
| int R = 0; | |
| int G = 0; | |
| int B = 0; | |
| for(int j = 0; j < sandwichesL.length; j++){ | |
| ScreenModel draw = ScreenModels.find(sandwichesL[j])[0]; | |
| g.setColor(new Color(R,G,B,100)); | |
| Point pt = modelOffSet(draw.base_point); | |
| g.fillRect(pt.x+50, pt.y+50, 50, 50); | |
| g.setColor(Color.RED); | |
| g.drawString(sandwichesS[j].charAt(0)+"", pt.x+75, pt.y+75); | |
| R+=20; | |
| G+=20; | |
| B+=20; | |
| } | |
| } | |
| private Point modelOffSet(Point bPt) { | |
| return new Point(bPt.x + (int)(.125*(bPt.x-62)),bPt.y); | |
| } | |
| private void choose(String san) { | |
| ScreenModel pick = ScreenModels.find(models.get(san))[0]; | |
| Point pt = modelOffSet(pick.base_point); | |
| Mouse.clickBox(pt.x, pt.y, pt.x+50, pt.y+50, 1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment