Created
January 16, 2013 23:06
-
-
Save TheBatScripts/4551850 to your computer and use it in GitHub Desktop.
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.Polygon; | |
| import java.awt.Toolkit; | |
| import java.awt.datatransfer.Clipboard; | |
| import java.awt.datatransfer.StringSelection; | |
| import java.awt.event.KeyEvent; | |
| import org.tribot.api.EGW; | |
| import org.tribot.api.General; | |
| import org.tribot.script.Script; | |
| import org.tribot.script.ScriptManifest; | |
| import org.tribot.script.interfaces.KeyActions; | |
| import org.tribot.script.interfaces.Painting; | |
| @ScriptManifest(authors = { "TheBat" }, category = "Tools", name = "ZoneMaker(EGW)") | |
| public class EGWZoning extends Script implements Painting, KeyActions{ | |
| Polygon poly = new Polygon(); | |
| Point ptmm = new Point(); | |
| private boolean unLocked = false; | |
| @Override | |
| public void onPaint(Graphics g) { | |
| //Convert the points to a new polygon that will hold points on the minimap | |
| Polygon drawMe = new Polygon(); | |
| for(int i = 0; i < poly.npoints; i++){ | |
| Point pt = EGW.posToMM(poly.xpoints[i], poly.ypoints[i]); | |
| drawMe.addPoint(pt.x,pt.y); | |
| } | |
| if(unLocked) g.setColor(new Color(175,0,0,75)); | |
| else g.setColor(new Color(0,0,175,75)); | |
| g.fillPolygon(drawMe); | |
| if(unLocked)g.setColor(new Color(100,0,0)); | |
| else g.setColor(new Color(0,0,100)); | |
| g.drawPolygon(drawMe); | |
| for(int i = 0; i < drawMe.npoints; i++){ | |
| g.drawOval(drawMe.xpoints[i]-1, drawMe.ypoints[i]-1, 2, 2); | |
| } | |
| g.setColor(Color.GREEN); | |
| g.fillRect(ptmm.x-1, ptmm.y-1, 2, 2); | |
| } | |
| public boolean onStart(){ | |
| return true; | |
| } | |
| public int loop(){ | |
| return 100; | |
| } | |
| public void onStop(){ | |
| } | |
| @Override | |
| public void run() { | |
| if(onStart()){ | |
| while(!Thread.interrupted() && loop()>=0){} | |
| onStop(); | |
| }else println("Script failed to start!"); | |
| } | |
| @Override | |
| public void keyPressed(int key, boolean isBot) { | |
| if(key == KeyEvent.VK_CONTROL){ | |
| if(unLocked){ | |
| Point pt = EGW.MMToPos(ptmm); | |
| poly.addPoint(pt.x, pt.y); | |
| ptmm = new Point(); | |
| unLocked = false; | |
| }else{ | |
| unLocked = true; | |
| ptmm = EGW.posToMM(EGW.getPosition()); | |
| } | |
| }else if(key == KeyEvent.VK_ALT){ | |
| poly = new Polygon(); | |
| }else if(key == KeyEvent.VK_SHIFT){ | |
| StringBuilder butts = new StringBuilder(); | |
| butts.append("new int[]{"); | |
| for(int i = 0; i < poly.npoints-1; i++){ | |
| butts.append(poly.xpoints[i] + ", "); | |
| } | |
| butts.append(poly.xpoints[poly.npoints-1] + "}, new int[]{"); | |
| for(int i = 0; i < poly.npoints-1; i++){ | |
| butts.append(poly.ypoints[i] + ", "); | |
| } | |
| butts.append(poly.ypoints[poly.npoints-1] + "}, " + poly.npoints); | |
| Toolkit toolkit = Toolkit.getDefaultToolkit(); | |
| Clipboard clipboard = toolkit.getSystemClipboard(); | |
| StringSelection strSel = new StringSelection(butts.toString()); | |
| clipboard.setContents(strSel, null); | |
| General.println("Copied!"); | |
| }else if(key == KeyEvent.VK_HOME){ | |
| if(unLocked)ptmm.y--; | |
| }else if(key == KeyEvent.VK_END){ | |
| if(unLocked)ptmm.y++; | |
| }else if(key == KeyEvent.VK_DELETE){ | |
| if(unLocked)ptmm.x--; | |
| }else if(key == KeyEvent.VK_PAGE_DOWN){ | |
| if(unLocked)ptmm.x++; | |
| } | |
| } | |
| public void keyReleased(int arg0, boolean arg1) {} | |
| public void keyTyped(int arg0, boolean arg1) {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment