- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.RenderingHints;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.IOException;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.Iterator;
- import javax.imageio.ImageIO;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Game.Tab;
- import com.rarebot.script.methods.Methods;
- import com.rarebot.script.methods.Skills;
- import com.rarebot.script.util.Filter;
- import com.rarebot.script.wrappers.RSNPC;
- @ScriptManifest(authors = { "Gripps" }, keywords = {"combat"}, name = "GYak Killer", description =
- "Kills yaks! 40-50K exp per hour! Special Attack support", version = 1.0)
- public class GYakKiller extends Script implements PaintListener, MouseListener {
- /**
- * Paint Variables
- */
- public boolean showPaint = true;
- private long startTime = 0;
- private int startExpHP;
- private int startLevelHP;
- private int startExpStr;
- private int startLevelStr;
- private int startExpAtt;
- private int startLevelAtt;
- private int startExpDef;
- private int startLevelDef;
- private int expToLvlHP;
- private int expToLvlStr;
- private int expToLvlAtt;
- private int expToLvlDef;
- final Object lock = new Object();
- final ArrayList<Particle> particles = new ArrayList<Particle>();
- public static final Color TRANS_BLACK = new Color(0, 0, 0, 180),
- LIGHT_TRANS_RED = new Color(255, 0, 0, 150);
- final Color MOUSE_COLOR = (Color.WHITE);
- final Color MOUSE_BORDER_COLOR = (Color.RED);
- final Color MOUSE_CENTER_COLOR = (Color.BLACK);
- boolean pressed = false;
- int absoluteY = 0;
- String status;
- public int yakHair = 10814;
- /**
- * End Paint Variables
- */
- public int[] yakID = {5529}, foodID = {373};
- RSNPC curYak = null;
- private enum State {
- UNKNOWN, ANTIBAN, ATTACK, EAT, CAMERATOYAK, SPEC
- }
- public State getState() {
- RSNPC yak = npcs.getNearest(yakID);
- try {
- if (players.getMyPlayer().getHPPercent() >= 30) {
- if (!players.getMyPlayer().isInCombat()) {
- if (yak != null) {
- if (yak.isOnScreen()) {
- return State.ATTACK;
- } else {
- return State.CAMERATOYAK;
- }
- }
- }
- } else {
- if (inventory.containsOneOf(foodID)) {
- return State.EAT;
- }
- }
- } catch (Exception e) {
- return State.UNKNOWN;
- }
- return State.ANTIBAN;
- }
- public boolean onStart() {
- startTime = System.currentTimeMillis();
- startExpHP = skills.getCurrentExp(Skills.CONSTITUTION);
- startExpStr = skills.getCurrentExp(Skills.STRENGTH);
- startExpAtt = skills.getCurrentExp(Skills.ATTACK);
- startExpDef = skills.getCurrentExp(Skills.DEFENSE);
- startLevelHP = skills.getCurrentLevel(Skills.CONSTITUTION);
- startLevelStr = skills.getCurrentLevel(Skills.STRENGTH);
- startLevelAtt = skills.getCurrentLevel(Skills.ATTACK);
- startLevelDef = skills.getCurrentLevel(Skills.DEFENSE);
- return true;
- }
- public void dropYakHair() {
- if (inventory.containsOneOf(yakHair)) {
- inventory.dropAllExcept(foodID);
- }
- }
- private void drawMouse1(Graphics g) {
- Point p = mouse.getLocation();
- ((Graphics2D) g).setRenderingHints(new RenderingHints
- (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
- Graphics2D line1 = (Graphics2D) g.create();
- Graphics2D line2 = (Graphics2D) g.create();
- Graphics2D arc1 = (Graphics2D) g.create();
- Graphics2D arc2 = (Graphics2D) g.create();
- final int outerSize = 20;
- final int innerSize = 20;
- line1.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2
- * Math.PI / 180.0, p.x, p.y);
- line2.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d)
- * 2 * Math.PI / 180.0, p.x, p.y);
- arc1.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2
- * Math.PI / 180.0, p.x, p.y);
- arc2.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d)
- * 2 * Math.PI / 180.0, p.x, p.y);
- line1.setColor(Color.WHITE);
- line1.drawLine(p.x, p.y, p.x, p.y + 7);
- line1.drawLine(p.x, p.y, p.x, p.y - 7);
- line2.setColor(Color.WHITE);
- line2.drawLine(p.x, p.y, p.x - 7, p.y);
- line2.drawLine(p.x, p.y, p.x + 7, p.y);
- arc1.setColor(Color.BLACK);
- arc1.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, 100, 75);
- arc2.setColor(Color.RED);
- arc2.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, -100, 75);
- arc2.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, 100, 75);
- arc1.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, -100, 75);
- }
- @Override
- public int loop() {
- RSNPC yak = npcs.getNearest(yakID);
- mouse.setSpeed(0);
- dropYakHair();
- switch(getState()) {
- case ATTACK:
- fightYaks();
- break;
- case CAMERATOYAK:
- status = "Camera to Yak";
- camera.turnTo(yak);
- Methods.sleep(Methods.random(500, 750));
- break;
- case EAT:
- status = "Eating Food";
- inventory.getItem(foodID).interact("Eat");
- break;
- case ANTIBAN:
- int b = random(1, 43);
- switch (b) {
- case 1:
- status = "Moving mouse";
- mouse.moveSlightly();
- sleep(200, 600);
- mouse.moveRandomly(150, 350);
- break;
- case 2:
- status = "Camera";
- camera.setAngle(random(30, 70));
- sleep(400, 1200);
- break;
- case 3:
- status = "Mouse AFK";
- mouse.moveOffScreen();
- sleep(random(600, random(1200, 2000)));
- break;
- case 4:
- status = "Checking Exp";
- game.openTab(Tab.STATS);
- skills.doHover(Skills.INTERFACE_COOKING);
- sleep(random(1250, 2000));
- game.openTab(Tab.INVENTORY);
- break;
- case 5:
- status = "Opening CC";
- clanChat.openInformation();
- Methods.sleep(1500);
- clanChat.closeInformation();
- Methods.sleep(300);
- game.openTab(Tab.INVENTORY);
- break;
- case 6:
- status = "Camera";
- camera.setAngle(random(20, 90));
- sleep(400, 800);
- break;
- case 7:
- status = "Pitch";
- camera.setPitch(1250);
- Methods.sleep(Methods.random(300, 1000));
- camera.setCompass('n');
- break;
- case 8:
- status = "Randomly";
- mouse.moveRandomly(Methods.random(1500, 2000));
- break;
- case 9:
- status = "Moving Camera";
- camera.moveRandomly(Methods.random(800, 1200));
- break;
- case 10:
- status = "Randomly";
- camera.moveRandomly(Methods.random(1000, 2000));
- status = "Pitch";
- camera.setPitch(true);
- case 11:
- status = "Moving Mouse";
- mouse.moveSlightly();
- mouse.moveRandomly(1500);
- break;
- case 12:
- if (inventory.containsOneOf(foodID)) {
- inventory.getItem(foodID).interact("Examine");
- }
- break;
- case 13:
- quests.openTab();
- Methods.sleep(450);
- break;
- case 14:
- camera.moveRandomly(1500);
- break;
- }
- default:
- break;
- }
- return 1000;
- }
- private int fightYaks() {
- RSNPC newYak = npcs.getNearest(new Filter<RSNPC>(){
- public boolean accept(RSNPC in) {
- if (in == null)
- return false;
- if (!in.getName().contains("Yak"))
- return false;
- if (in.isDead())
- return false;
- if (in.getInteracting() != null && !in.getInteracting().equals
- (getMyPlayer()))
- return false;
- return true;
- }
- });
- if (newYak != null) {
- if (combat.getSpecialBarEnergy() == 100 && !combat.isSpecialEnabled()) {
- game.openTab(Tab.ATTACK);
- Methods.sleep(300);
- status = "Enabling Special";
- combat.setSpecialAttack(true);
- Methods.sleep(500);
- game.openTab(Tab.INVENTORY);
- }
- if (!players.getMyPlayer().isInCombat()) {
- if (newYak.isOnScreen()) {
- status = "Attacking";
- newYak.interact("Attack "+newYak.getName());
- curYak = newYak;
- } else {
- status = "Walking to Yak";
- walking.walkTileMM(newYak.getLocation());
- }
- }
- }
- return 1;
- }
- public void onFinish() {
- }
- //START: Code generated using Enfilade's Easel
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(0, 0, 0, 178);
- private final Color color2 = new Color(255, 255, 255, 185);
- private final Color color3 = new Color(255, 255, 255, 125);
- private final Color color4 = new Color(255, 255, 255);
- private final Color color5 = new Color(0, 0, 0);
- private final Font font1 = new Font("Arial", 1, 11);
- private final Font font2 = new Font("Arial", 1, 13);
- private final Image background = getImage("http://i.imgur.com/RLF7x.png");
- private final Image logo = getImage("http://i.imgur.com/v2dHY.png");
- private final Image clock = getImage("http://i.imgur.com/rGZ8G.png");
- private final Image strengthIcon = getImage("http://i.imgur.com/TgWK1.png");
- private final Image hpIcon = getImage("http://i.imgur.com/gMlfE.png");
- private final Image info = getImage("http://www.tmssoftware.com/site/img/info.png");
- private final Image defenseIcon = getImage("http://i.imgur.com/Bcmb4.png");
- private final Image attackIcon = getImage("http://i.imgur.com/uz9Yb.png");
- private final Image show = getImage("http://i.imgur.com/17ysO.png");
- private final Rectangle hideRect = new Rectangle(402, 315, 60, 25);
- @Override
- public void mouseClicked(MouseEvent e) {
- Point p = e.getPoint();
- if (hideRect.contains(e.getPoint())) {
- showPaint = !showPaint;
- }
- }
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- //HP
- int levelGainHP = (skills.getMaxLevel(Skills.CONSTITUTION) - startLevelHP);
- int expGainHP = (int) (skills.getCurrentExp(Skills.CONSTITUTION) - startExpHP);
- int currLvlHP = (int) (skills.getCurrentLevel(Skills.CONSTITUTION));
- int expToLvlHP = skills.getExpToNextLevel(Skills.CONSTITUTION);
- double xpPHHP = 0;
- xpPHHP = (int) ((expGainHP) * 3600000D / (System.currentTimeMillis() - startTime));
- //Str
- int levelGainStr = (skills.getMaxLevel(Skills.STRENGTH) - startLevelStr);
- int expGainStr = (int) (skills.getCurrentExp(Skills.STRENGTH) - startExpStr);
- int currLvlStr = (int) (skills.getCurrentLevel(Skills.STRENGTH));
- int expToLvlStr = skills.getExpToNextLevel(Skills.STRENGTH);
- int strBar = (int) (skills.getPercentToNextLevel(Skills.STRENGTH) * 2.33);
- double xpPHSTR = 0;
- xpPHSTR = (int) ((expGainStr) * 3600000D / (System.currentTimeMillis() -
- startTime));
- Point p = mouse.getLocation();
- //Att
- int levelGainAtt = (skills.getMaxLevel(Skills.ATTACK) - startLevelAtt);
- int expGainAtt = (int) (skills.getCurrentExp(Skills.ATTACK) - startExpAtt);
- int currLvlAtt = (int) (skills.getCurrentLevel(Skills.ATTACK));
- int expToLvlAtt = skills.getExpToNextLevel(Skills.ATTACK);
- int attBar = (int) (skills.getPercentToNextLevel(Skills.ATTACK) * 2.33);
- double xpPHAtt = 0;
- xpPHAtt = (int) ((expGainAtt) * 3600000D / (System.currentTimeMillis() -
- startTime));
- //Def
- int levelGainDef = (skills.getMaxLevel(Skills.DEFENSE) - startLevelDef);
- int expGainDef = (int) (skills.getCurrentExp(Skills.DEFENSE) - startExpDef);
- int currLvlDef = (int) (skills.getCurrentLevel(Skills.DEFENSE));
- int expToLvlDef = skills.getExpToNextLevel(Skills.DEFENSE);
- int defBar = (int) (skills.getPercentToNextLevel(Skills.DEFENSE) * 2.33);
- double xpPHDef = 0;
- xpPHDef = (int) ((expGainDef) * 3600000D / (System.currentTimeMillis() -
- startTime));
- int x = p.x;
- int y = p.y;
- int color = random(0, 3);
- if (mouse.isPressed()) {
- synchronized (lock) {
- for (int i = 0; i < 100; i++, particles.add(new Particle(x, y,
- color)))
- ;
- }
- }
- synchronized (lock) {
- Iterator<Particle> piter = particles.iterator();
- while (piter.hasNext()) {
- Particle part = piter.next();
- if (!part.handle(g)) {
- piter.remove();
- }
- }
- }
- //HP
- float timeTNLhourHP = 0;
- timeTNLhourHP = (float) skills.getExpToNextLevel(Skills.CONSTITUTION)
- / (float) xpPHHP;
- float timeTNLminHP = timeTNLhourHP * 60;
- float timeTNLsecHP = timeTNLminHP * 60;
- float estimatedHourHP = timeTNLsecHP / 3600;
- float tempminutesHP = timeTNLsecHP % 3600;
- float estimatedMinutesHP = tempminutesHP / 60;
- float estimatedSecondsHP = tempminutesHP % 60;
- //Str
- float timeTNLhourStr = 0;
- timeTNLhourStr = (float) skills.getExpToNextLevel(Skills.STRENGTH)
- / (float) xpPHSTR;
- float timeTNLminStr = timeTNLhourStr * 60;
- float timeTNLsecStr = timeTNLminStr * 60;
- float estimatedHourStr = timeTNLsecStr / 3600;
- float tempminutesStr = timeTNLsecStr % 3600;
- float estimatedMinutesStr = tempminutesStr / 60;
- float estimatedSecondsStr = tempminutesStr % 60;
- //Att
- float timeTNLhourAtt = 0;
- timeTNLhourAtt = (float) skills.getExpToNextLevel(Skills.ATTACK)
- / (float) xpPHAtt;
- float timeTNLminAtt = timeTNLhourAtt * 60;
- float timeTNLsecAtt = timeTNLminAtt * 60;
- float estimatedHourAtt = timeTNLsecAtt / 3600;
- float tempminutesAtt = timeTNLsecAtt % 3600;
- float estimatedMinutesAtt = tempminutesAtt / 60;
- float estimatedSecondsAtt = tempminutesAtt % 60;
- //Def
- float timeTNLhourDef = 0;
- timeTNLhourDef = (float) skills.getExpToNextLevel(Skills.DEFENSE)
- / (float) xpPHDef;
- float timeTNLminDef = timeTNLhourDef * 60;
- float timeTNLsecDef = timeTNLminDef * 60;
- float estimatedHourDef = timeTNLsecDef / 3600;
- float tempminutesDef = timeTNLsecDef % 3600;
- float estimatedMinutesDef = tempminutesDef / 60;
- float estimatedSecondsDef = tempminutesDef % 60;
- if (showPaint) {
- g.drawImage(background, 1, 230, null);
- if (expGainStr > 0) {
- g.setColor(color1);
- g.fillRect(102, 309, 233, 18); // Red
- g.setColor(color2);
- g.fillRect(102, 309, strBar, 18); // Green
- g.setColor(color3);
- g.fillRect(102, 309, 233, 8); // White
- } if (expGainAtt > 0) {
- g.setColor(color1);
- g.fillRect(102, 309, 233, 18); // Red
- g.setColor(color2);
- g.fillRect(102, 309, attBar, 18); // Green
- g.setColor(color3);
- g.fillRect(102, 309, 233, 8); // White
- } if (expGainDef > 0) {
- g.setColor(color1);
- g.fillRect(102, 309, 233, 18); // Red
- g.setColor(color2);
- g.fillRect(102, 309, defBar, 18); // Green
- g.setColor(color3);
- g.fillRect(102, 309, 233, 8); // White
- }
- g.drawImage(logo, 105, 330, null);
- g.drawImage(clock, 12, 432, null);
- g.setFont(font1);
- g.setColor(color4);
- g.drawString("Time Running: "+ hours + ":" + minutes + ":" + seconds, 54, 463);
- if (expGainStr > 0) {
- g.drawImage(strengthIcon, 52, 361, null);
- g.drawString("Experience Gained: " + expGainStr, 93, 380);
- g.drawString("Experience/Hour: " + xpPHSTR, 93, 397);
- g.drawString("Experience to Level: " + expToLvlStr, 93, 414);
- g.drawString("Time to Level: " + (int) estimatedHourStr + ":"
- + (int) estimatedMinutesStr + ":" + (int) estimatedSecondsStr, 93,
- 431);
- } if (expGainHP > 0) {
- g.drawImage(hpIcon, 311, 372, null);
- g.drawString("Experience Gained HP: " + expGainHP, 345, 380);
- g.drawString("Experience/Hour HP: " + xpPHHP, 345, 397);
- g.drawString("Experience to Level HP: " +expToLvlHP, 345, 414);
- g.drawString("Time to Level HP: " + (int) estimatedHourHP + ":"
- + (int) estimatedMinutesHP + ":" + (int) estimatedSecondsHP, 345,
- 431);
- } if (expGainAtt > 0) {
- g.drawImage(attackIcon, 52, 361, null);
- g.drawString("Experience Gained: " + expGainAtt, 93, 380);
- g.drawString("Experience/Hour: " + xpPHAtt, 93, 397);
- g.drawString("Experience to Level: " + expToLvlAtt, 93, 414);
- g.drawString("Time to Level: " + (int) estimatedHourAtt + ":"
- + (int) estimatedMinutesAtt + ":" + (int)
- estimatedSecondsAtt, 93, 431);
- } if (expGainDef > 0) {
- g.drawImage(defenseIcon, 57, 375, null);
- g.drawString("Experience Gained: " + expGainDef, 93, 380);
- g.drawString("Experience/Hour: " + xpPHDef, 93, 397);
- g.drawString("Experience to Level: " + expToLvlDef, 93, 414);
- g.drawString("Time to Level: " + (int) estimatedHourDef + ":"
- + (int) estimatedMinutesDef + ":" + (int)
- estimatedSecondsDef, 93, 431);
- }
- g.setFont(font2);
- g.drawString("Status: " +status, 340, 465);
- g.drawImage(info, 312, 452, null);
- drawMouse1(g);
- } else {
- g.drawImage(show, 1, 230, null);
- drawMouse1(g);
- }
- }
- //END: Code generated using Enfilade's Easel
- private static class Particle {
- private double posX;
- private double posY;
- private double movX;
- private double movY;
- private int alpha = 255, color = -1;
- java.util.Random generator = new java.util.Random();
- Particle(int pos_x, int pos_y, int color) {
- posX = (double) pos_x;
- posY = (double) pos_y;
- movX = ((double) generator.nextInt(40) - 20) / 16;
- movY = ((double) generator.nextInt(40) - 20) / 16;
- this.color = color;
- }
- public boolean handle(Graphics page) {
- alpha -= random(1, 7);
- if (alpha <= 0)
- return false;
- switch (color) {
- case 0:
- page.setColor(new Color(0, 0, 0, alpha));
- break;
- case 1:
- page.setColor(new Color(255, 0, 0, alpha));
- break;
- case 2:
- page.setColor(new Color(255, 255, 255, alpha));
- break;
- }
- page.drawLine((int) posX, (int) posY, (int) posX, (int) posY);
- posX += movX;
- posY += movY;
- return true;
- }
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- }