Created
June 9, 2012 15:09
-
-
Save TheBatScripts/2901367 to your computer and use it in GitHub Desktop.
Drill Demon
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.colour.DTMs; | |
| import org.tribot.api.colour.types.ColourPoint; | |
| import org.tribot.api.colour.types.DTM; | |
| import org.tribot.api.colour.types.DTMPoint; | |
| import org.tribot.api.colour.types.DTMSubPoint; | |
| import org.tribot.api.colour.types.Tolerance; | |
| import org.tribot.api.input.Keyboard; | |
| import org.tribot.api.input.Mouse; | |
| import org.tribot.api.togl.ScreenModels; | |
| import org.tribot.api.togl.Text; | |
| import org.tribot.api.togl.types.ScreenModel; | |
| import org.tribot.script.Script; | |
| import org.tribot.script.ScriptManifest; | |
| import org.tribot.script.interfaces.Painting; | |
| @ScriptManifest (authors = { "TheBat" }, category = "Randoms", name = "DrillDemon") | |
| public class DrillDemon extends Script implements Painting{ | |
| final Rectangle VIEWPORT = new Rectangle(3, 3, 513, 334); | |
| final Rectangle CHATBOX = new Rectangle(3, 338, 513, 140); | |
| DTMPoint CHAT_DTM_PT = new DTMPoint(new Color(72, 117, 26), new Tolerance(10, 10, 10)); | |
| DTMSubPoint [] CHAT_DTM_PTS = { new DTMSubPoint(new ColourPoint(new Point(-1, 7), new Color( 27, 66, 9)), new Tolerance(10, 10, 10),1)}; | |
| DTM dtmChatAdv = new DTM(CHAT_DTM_PT, CHAT_DTM_PTS); | |
| final long demon = 1132837409L, mat = 1936004062L; | |
| HashMap<String,Long> models = new HashMap<String,Long>(); | |
| String [] types = {"jog","starjumps","pushups","situps"}; | |
| long [] signs = {1862962707L,1042468844L,1860340846L,2877688137L}; | |
| String type = ""; | |
| String status = "Finding type"; | |
| long CUR_ID = 0L; | |
| ScreenModel player; | |
| private int loop() { | |
| if(!stillIn())return -1; | |
| if (status.equals("Finding demon")){ | |
| do{ | |
| if(DTMs.find(dtmChatAdv, CHATBOX.x, CHATBOX.y, CHATBOX.x+CHATBOX.width, CHATBOX.y+CHATBOX.height).length < 1){ | |
| int k = -1; | |
| ScreenModel [] demonM = null; | |
| while(k < 0){ | |
| try{ | |
| Keyboard.pressKey((char)KeyEvent.VK_DOWN); | |
| Keyboard.pressKey((char)KeyEvent.VK_RIGHT); | |
| while((demonM = ScreenModels.find(demon)).length < 0 || !VIEWPORT.contains(demonM[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(demonM[0].base_point,1); | |
| k = 0; | |
| while(k <= 10 && DTMs.find(dtmChatAdv, CHATBOX.x, CHATBOX.y, CHATBOX.x+CHATBOX.width, CHATBOX.y+CHATBOX.height).length < 1){ | |
| sleep(75,125); | |
| k++; | |
| } | |
| } | |
| 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); | |
| status = "Finding type"; | |
| return 100; | |
| } | |
| if (status.equals("Finding type")){ | |
| type = pullType(Text.lineToString(Text.findCharsInArea(CHATBOX.x, CHATBOX.y, CHATBOX.width, CHATBOX.height, true), 0)); | |
| if(type.equals("")){ | |
| status = "Finding demon"; | |
| }else{ | |
| status = "Finding mat"; | |
| } | |
| return 100; | |
| } | |
| if (status.equals("Finding mat")){ | |
| Mouse.clickBox(531, 12, 554, 37, 1); | |
| Keyboard.pressKey((char)KeyEvent.VK_UP); | |
| sleep(800,900); | |
| Keyboard.releaseKey((char)KeyEvent.VK_UP); | |
| long id = models.get(type); | |
| int k = -1; | |
| ScreenModel [] signM = null; | |
| while(k < 0){ | |
| try{ | |
| signM = ScreenModels.find(id); | |
| k = 3; | |
| }catch(Exception e){ | |
| k = -1; | |
| } | |
| } | |
| Mouse.click(findClosest(signM[0].base_point, new long []{mat}).base_point,1); | |
| sleep(3075,4325); | |
| k = 0; | |
| while(k <= 40 && getPlayer().id != player.id){ | |
| sleep(125,225); | |
| k++; | |
| } | |
| status = "Finding type"; | |
| } | |
| return 100; | |
| } | |
| private boolean stillIn() { | |
| int k = -1; | |
| ScreenModel [] matM = null; | |
| while(k < 0){ | |
| try{ | |
| matM = ScreenModels.find(mat); | |
| k = 3; | |
| }catch(Exception e){ | |
| k = -1; | |
| } | |
| } | |
| return matM.length > 0; | |
| } | |
| private String pullType(String str) { | |
| for(int i = 0; i < types.length; i++){ | |
| if(str.contains(types [i])){ | |
| return types [i]; | |
| } | |
| } | |
| return ""; | |
| } | |
| private ScreenModel getPlayer() { | |
| int k = -1; | |
| ScreenModel ply = null; | |
| while(k < 0){ | |
| try{ | |
| ScreenModel [] allMods = ScreenModels.getAll(); | |
| if(allMods.length > 0 && allMods[0] != null)ply = allMods[0]; | |
| else continue; | |
| for(int i = 0; i < allMods.length; i++){ | |
| ScreenModel test = allMods[i]; | |
| if(test != null && test.id != 3397519456L){ | |
| if(Point.distance(test.base_point.x, test.base_point.y, VIEWPORT.getCenterX(), VIEWPORT.getCenterY())< | |
| Point.distance(ply.base_point.x, ply.base_point.y, VIEWPORT.getCenterX(), VIEWPORT.getCenterY())){ | |
| if(VIEWPORT.contains(test.base_point))ply = test; | |
| } | |
| } | |
| } | |
| k = 3; | |
| }catch(NullPointerException e){ | |
| k = -1; | |
| } | |
| } | |
| CUR_ID = ply.id; | |
| return ply; | |
| } | |
| private void buildList() { | |
| for(int i = 0; i < types.length; i++){ | |
| models.put(types[i], signs[i]); | |
| } | |
| } | |
| public void run() { | |
| if(onStart()){ | |
| while(!Thread.interrupted() && loop()>=0){} | |
| onStop(); | |
| }else println("Script failed to start!"); | |
| } | |
| private ScreenModel findClosest(Point pt, long[] ids) { | |
| int k = -1; | |
| ScreenModel out = null; | |
| while(k < 0){ | |
| try{ | |
| ScreenModel [] allMods = ScreenModels.find(ids); | |
| if(allMods.length > 0 && allMods[0] != null)out = allMods[0]; | |
| else continue; | |
| for(int i = 0; i < allMods.length; i++){ | |
| ScreenModel test = allMods[i]; | |
| if(test != null){ | |
| if(Point.distance(test.base_point.x, test.base_point.y, pt.x, pt.y)< | |
| Point.distance(out.base_point.x, out.base_point.y, pt.x, pt.y)){ | |
| if(VIEWPORT.contains(test.base_point))out = test; | |
| } | |
| } | |
| } | |
| if(out != null)k = 3; | |
| }catch(NullPointerException e){ | |
| k = -1; | |
| } | |
| } | |
| return out; | |
| } | |
| private boolean onStart() { | |
| buildList(); | |
| player = getPlayer(); | |
| return true; | |
| } | |
| private void onStop() {} | |
| @Override | |
| public void onPaint(Graphics g) { | |
| g.setColor(Color.RED); | |
| g.drawString(status, 11, 380); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment