Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.util.ArrayList;
- import org.veloxbot.api.ActiveScript;
- import org.veloxbot.api.Manifest;
- import org.veloxbot.api.Validatable;
- import org.veloxbot.api.methods.Bank;
- import org.veloxbot.api.methods.Bank.Slot;
- import org.veloxbot.api.methods.Game;
- import org.veloxbot.api.methods.Inventory;
- import org.veloxbot.api.methods.Keyboard;
- import org.veloxbot.api.methods.Log;
- import org.veloxbot.api.methods.Magic;
- import org.veloxbot.api.methods.Menu;
- import org.veloxbot.api.methods.Mouse;
- import org.veloxbot.api.methods.OCR;
- import org.veloxbot.api.utils.Random;
- import org.veloxbot.api.wrappers.DTM;
- @Manifest(authors = { "Nissan Nut", "Velox" },
- name = "Nissan's Superheater",
- version = 0.2,
- description= "Basic Superheater.")
- /**
- * Simple Superheater Script
- * 11/10/2012 Dev Started
- * @author Tanner (Nissan Nut)
- */
- public class Superheater extends ActiveScript{
- private ArrayList<Strategy> tasks = new ArrayList<Strategy>();
- private SuperheaterUI UI = new SuperheaterUI();
- private boolean antiban = true;
- private int widthdraw = 0, angle, mouseSpeed, heats = 0, startExp, exp;
- private long START_TIME;
- private String status;
- private DTM ore, ore2, bar;
- private final DTM NATURE_RUNE = DTM.fromString("17_123_20_5/103_99_98_-11_-5_5/74_71_71_-2_10_5/147_140_140_9_-3_5"),
- COAL = DTM.fromString("38_38_29_5/92_74_52_-12_2_5/92_74_52_-3_8_5/38_38_29_8_5_5/105_84_59_10_-5_5"),
- IRON_ORE = DTM.fromString("54_32_24_5/86_69_48_-13_3_5/94_76_53_-3_10_5/54_32_24_7_6_5/103_82_57_10_-4_5"),
- MITHRIL_ORE = DTM.fromString("54_55_81_5/100_81_57_-11_3_5/90_72_51_-5_10_5/46_46_69_7_5_5/109_87_61_11_-6_5"),
- ADAMANTITE_ORE = DTM.fromString("64_74_64_5/98_79_56_-11_2_5/92_74_52_-5_11_5/62_71_62_8_6_5/109_87_61_11_-5_5"),
- RUNITE_ORE = DTM.fromString("71_85_92_5/87_70_49_-15_3_5/98_79_56_-5_10_5/55_66_71_7_5_5/105_84_59_9_-6_5"),
- GOLD_ORE = DTM.fromString("190_151_28_5/98_79_56_-11_2_5/87_70_49_-7_10_5/172_137_25_7_6_5/100_81_57_11_-4_5"),
- SILVER_ORE = DTM.fromString("126_127_132_5/95_76_52_-11_4_5/91_72_50_-3_11_5/103_82_57_12_-4_1"),
- COPPER_ORE = DTM.fromString("189_108_57_5/97_77_54_-10_1_5/91_72_50_-4_7_5/105_84_58_10_-6_5"),
- TIN_ORE = DTM.fromString("105_101_101_5/82_65_45_-14_4_5/97_77_54_-3_10_5/99_79_55_12_-4_5"),
- BRONZE_BAR = DTM.fromString("79_59_35_5/59_45_26_-8_-2_5/33_25_14_-13_5_5/81_61_36_-1_6_5"),
- IRON_BAR = DTM.fromString("83_80_80_5/39_38_38_-14_5_5/26_25_25_-14_11_5/86_82_82_-1_7_5"),
- STEEL_BAR = DTM.fromString("128_123_123_5/99_95_94_-8_1_5/39_38_38_-15_11_5/132_127_126_-1_8_5"),
- MITHRIL_BAR = DTM.fromString("66_66_99_5/49_50_74_-8_-3_5/28_29_43_-10_5_5/67_68_101_0_4_5"),
- ADAMANT_BAR = DTM.fromString("72_83_72_5/53_62_54_-7_1_5/28_33_29_-13_6_5/72_83_72_-1_7_5"),
- RUNE_BAR = DTM.fromString("81_97_105_5/62_75_81_-7_1_5/37_45_48_-11_7_5/82_99_107_0_6_5"),
- SILVER_BAR = DTM.fromString("165_165_172_5/128_128_134_-9_-1_5/75_75_79_-15_3_5/168_168_176_-1_6_5"),
- GOLD_BAR = DTM.fromString("207_165_29_5/159_126_22_-8_-2_5/90_72_13_-11_4_5/212_169_30_0_6_5");
- @Override
- public boolean onStart(){
- Log.log(this.manifest.name() + " v" + this.manifest.version() + " by " + this.manifest.authors()[0] + " + " + this.manifest.authors()[1]);
- status = "Start-up";
- UI.setVisible(true);
- while (UI.isVisible())
- sleep(10);
- switch (UI.list.getSelectedIndex()){
- case 0:
- ore = TIN_ORE;
- ore2 = COPPER_ORE;
- bar = BRONZE_BAR;
- widthdraw = 13;
- break;
- case 1:
- ore = IRON_ORE;
- bar = IRON_BAR;
- break;
- case 2:
- ore = IRON_ORE;
- ore2 = COAL;
- bar = STEEL_BAR;
- widthdraw = 9;
- break;
- case 3:
- ore = SILVER_ORE;
- bar = SILVER_BAR;
- break;
- case 4:
- ore = GOLD_ORE;
- bar = GOLD_BAR;
- break;
- case 5:
- ore = MITHRIL_ORE;
- ore2 = COAL;
- bar = MITHRIL_BAR;
- widthdraw = 6;
- break;
- case 6:
- ore = ADAMANTITE_ORE;
- ore2 = COAL;
- bar = ADAMANT_BAR;
- widthdraw = 5;
- break;
- case 7:
- ore = RUNITE_ORE;
- ore2 = COAL;
- bar = RUNE_BAR;
- widthdraw = 4;
- }
- if (UI.boxNorth.isSelected())
- angle = 0;
- else if (UI.boxEast.isSelected())
- angle = 90;
- else if (UI.boxSouth.isSelected())
- angle = 180;
- else if (UI.boxWest.isSelected())
- angle = 270;
- mouseSpeed = UI.slider.getValue();
- tasks.add(new Banking());
- tasks.add(new Superheat());
- START_TIME = System.currentTimeMillis();
- return UI.start;
- }
- @Override
- public long loop() {
- if (antiban)
- Mouse.setMultiplier(Random.nextDouble(mouseSpeed - 1, mouseSpeed + 1)*.1);
- for(Strategy s : tasks){
- if (s.validate()){
- s.run();
- Log.log(s.getStatus());
- }
- }
- return 15;
- }
- @Override
- public void onRepaint(Graphics G){
- Graphics2D g = (Graphics2D) G;
- g.setColor(Color.BLACK);
- g.fillRect(0, 0, 765, 50);
- g.setColor(Color.WHITE);
- g.drawString("Nissan's Superheater... Runtime: " + toString(getRuntime()) + "... Approx heats: " + heats, 15, 20);
- g.drawString("Please post and describe all bugs on the forums, script is in testing stages, all feedback is appreciated.", 15, 40);
- }
- /**
- * Credits to Velox
- * @param angle
- * @param distance
- * @return the point
- */
- public static Point getPointNearPlayer(final int angle, final int distance) {
- final double rads = Math.toRadians(angle + 90 - Game.getCompassAngle());
- return new Point((int) (Game.VIEWPORT_CENTER.x - distance * Math.cos(rads)), (int) (Game.VIEWPORT_CENTER.y - distance * Math.sin(rads)));
- }
- private class Banking extends Strategy{
- final Rectangle BOUNDS = new Rectangle(23, 135, 472, 208);
- public void run(){
- for (int i = 0; i < 5 && !Bank.isOpen(); i++){
- i++;
- final Point LOCATION = getPointNearPlayer(angle + Random.nextInt(-5, 5), 30 + Random.nextInt(-2, 2));
- Mouse.click(LOCATION, false);
- sleep(750, 1500);
- Menu.clickIndex(0);
- sleep(1500, 2000);
- }
- deposit(bar);
- sleep(500, 800);
- withdrawTemp(ore, widthdraw);
- if (ore2 != null){
- withdrawTemp(ore2, 0);
- sleep(1000, 1500);
- }
- if (new Failsafe().validate()){
- new Failsafe().run();
- }
- Bank.close();
- }
- private void deposit(DTM bar) {
- Inventory.Slot s = Inventory.getSlotWith(bar);
- if (s != null){
- Mouse.click(new Point((int) s.getBounds().getCenterX(), (int) s.getBounds().getCenterY()), false);
- sleep(1000, 1500);
- if (Menu.isOpen()){
- Menu.clickIndex(5);
- }
- }
- }
- @Override
- public boolean validate() {
- if (Game.Tab.INVENTORY.isOpen())
- return Inventory.getCount(bar) >= widthdraw || Inventory.getCount() == 1;
- return false;
- }
- @Override
- public String getStatus() {
- return "Banking";
- }
- public Bank.Slot[] getSlotsWithDTM(final DTM d){
- ArrayList<Bank.Slot> slots = new ArrayList<Bank.Slot>();
- for (Point p : d.getAll(BOUNDS)){
- for (Bank.Slot s : Bank.Slot.values()){
- if (s.getBounds().contains(p)){
- slots.add(s);
- }
- }
- }
- return (Slot[]) slots.toArray();
- }
- public Bank.Slot getSlotWithDTM(final DTM d){
- for (Point p : d.getAll(BOUNDS)){
- for (Bank.Slot s : Bank.Slot.values()){
- if (s.getBounds().contains(p)){
- return s;
- }
- }
- }
- return null;
- }
- public void withdrawTemp(final DTM d, final Integer num){
- Slot s = getSlotWithDTM(d);
- if (s != null){
- Mouse.click(s.getBounds(), false);
- sleep(1250, 1750);
- }
- if (num == 0){
- Menu.clickIndex(Random.nextInt(5, 6));
- } else{
- Menu.clickIndex(4);
- sleep(1250, 1750);
- Keyboard.sendString(num.toString());
- }
- }
- public void withdraw(final DTM d, final Integer num){
- Slot s = getSlotWithDTM(d);
- if (s != null){
- Mouse.click(s.getBounds(), false);
- sleep(1250, 1750);
- }
- if (num == 0){
- Menu.interact("Withdraw-All");
- } else{
- if (!Menu.interact("Withdraw-" + num)){
- Menu.interact("Withdraw-X", true);
- sleep(1250, 1750);
- Keyboard.sendString(num.toString());
- }
- }
- }
- private class Failsafe extends Strategy{
- @Override
- public boolean validate() {
- return !((Inventory.getCount(ore) == widthdraw || widthdraw == 0) && Inventory.isFull());
- }
- @Override
- public void run() {
- deposit(ore);
- if (ore2 != null)
- deposit(ore2);
- }
- @Override
- public String getStatus() {
- return "Checking Inventory";
- }
- }
- }
- private class Superheat extends Strategy{
- private final DTM SUPERHEAT_ITEM = DTM.fromString("232_117_45_5/250_180_71_-7_13_5/236_125_119_3_13_5");
- private final DTM MAGIC = DTM.fromString("26_54_97_3/19_19_19_-1_-13_3/10_24_60_11_-14_3/46_59_75_17_-1_3");
- private final DTM MAGIC_SELECTED = DTM.fromString("24_50_121_3/50_50_50_-3_-13_3/50_50_50_17_-12_3/54_26_85_16_0_3");
- private final DTM SKILLS = DTM.fromString("180_144_42_3/201_151_42_0_19_3/32_101_50_13_17_3/99_114_132_13_2_3/18_18_18_7_6_3");
- private final DTM SKILLS_SELECTED = DTM.fromString("201_151_42_3/201_151_42_0_18_3/32_101_50_14_15_3/101_112_126_14_0_3/20_184_253_23_-8_3/69_69_69_-8_21_3");
- private String status = "Superheating";
- private ArrayList<Strategy> tasks = new ArrayList<Strategy>();
- public void run(){
- this.tasks.add(new Heat());
- this.tasks.add(new ClickOre());
- for(Strategy s : this.tasks){
- if (s.validate()){
- s.run();
- status = s.getStatus();
- }
- }
- }
- @Override
- public boolean validate() {
- if (Game.Tab.INVENTORY.isOpen())
- return Inventory.getCount(bar) <= widthdraw;
- return true;
- }
- @Override
- public String getStatus() {
- return status;
- }
- private class ClickOre extends Strategy{
- @Override
- public boolean validate() {
- return Game.Tab.INVENTORY.isOpen();
- }
- @Override
- public void run() {
- String s = OCR.getUptext();
- if (s.contains("Cast") || s.contains("Super") || s.contains("Item")){
- Inventory.Slot s1 = Inventory.getSlotWith(ore);
- if (s1 != null){
- s1.click(true);
- heats++;
- sleep(500, 1000);
- } else if (Inventory.getCount(bar) >= widthdraw){
- Mouse.click(Magic.BOUNDS, true);
- new Banking().run();
- }
- } else {
- Game.Tab.MAGIC.open(false);
- sleep(250, 750);
- }
- }
- @Override
- public String getStatus() {
- return "Clicked Superheat";
- }
- }
- private class Heat extends Strategy{
- @Override
- public boolean validate() {
- return Game.Tab.MAGIC.isOpen();
- }
- @Override
- public void run() {
- Point p = SUPERHEAT_ITEM.getFirst(Magic.BOUNDS);
- if (p != null){
- Mouse.click(p, true);
- }else{
- Point p3 = MAGIC.getFirst(Magic.BOUNDS);
- if (p3 != null){
- Mouse.click(p3, true);
- sleep(250, 500);
- }
- Point p4 = SKILLS.getFirst(Magic.BOUNDS);
- if (p4!= null)
- Mouse.click(p4, true);
- }
- sleep(250, 750);
- }
- @Override
- public String getStatus() {
- return "Clicking Superheat";
- }
- }
- }
- abstract class Strategy implements Validatable{
- public Strategy() {}
- public abstract void run();
- public abstract String getStatus();
- }
- private Long getRuntime(){
- return System.currentTimeMillis() - START_TIME;
- }
- /**
- * Converts milliseconds to readable time in a string.
- * @param ms The time in milliseconds.
- * @return the time as a string <tt>0:0:0</tt>
- */
- public static String toString(final Long ms){
- long s = ms/1000;
- long sec = s % 60;
- long min = (s % 3600) / 60;
- long hrs = s / 3600;
- return hrs + ":" + min + ":" + sec;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment