Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 30.60 KB | None | 0 0
  1. package chopper.script;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5. import java.awt.GradientPaint;
  6. import java.awt.Graphics2D;
  7. import java.awt.Point;
  8. import java.awt.Polygon;
  9. import java.awt.Rectangle;
  10. import java.awt.RenderingHints;
  11. import java.awt.event.ActionEvent;
  12. import java.awt.event.ActionListener;
  13. import java.text.DecimalFormat;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. import java.util.Random;
  17.  
  18. import javax.swing.Box;
  19. import javax.swing.BoxLayout;
  20. import javax.swing.DefaultComboBoxModel;
  21. import javax.swing.JButton;
  22. import javax.swing.JCheckBox;
  23. import javax.swing.JComboBox;
  24. import javax.swing.JFrame;
  25. import javax.swing.JLabel;
  26. import javax.swing.JPanel;
  27. import javax.swing.SwingUtilities;
  28.  
  29. import org.vinsert.bot.script.Script;
  30. import org.vinsert.bot.script.ScriptContext;
  31. import org.vinsert.bot.script.ScriptManifest;
  32. import org.vinsert.bot.script.api.Area;
  33. import org.vinsert.bot.script.api.GameObject;
  34. import org.vinsert.bot.script.api.GroundItem;
  35. import org.vinsert.bot.script.api.Item;
  36. import org.vinsert.bot.script.api.Model;
  37. import org.vinsert.bot.script.api.Path;
  38. import org.vinsert.bot.script.api.Player;
  39. import org.vinsert.bot.script.api.Tile;
  40. import org.vinsert.bot.script.api.Widget;
  41. import org.vinsert.bot.script.api.generic.Filters;
  42. import org.vinsert.bot.script.api.tools.Game;
  43. import org.vinsert.bot.script.api.tools.Game.Tabs;
  44. import org.vinsert.bot.script.api.tools.Inventory;
  45. import org.vinsert.bot.script.api.tools.Navigation.NavigationPolicy;
  46. import org.vinsert.bot.script.api.tools.Skills;
  47. import org.vinsert.bot.util.Filter;
  48. import org.vinsert.bot.util.Perspective;
  49. import org.vinsert.bot.util.Vec3;
  50.  
  51. import chopper.misc.Condition;
  52. import chopper.misc.Miscellaneous;
  53.  
  54. //public static final String COMPILED_DIR = System.clearProperty("user.home") + File.separator + "workspace" + File.separator + "vInsert Scripts" + File.separator + "bin";
  55.  
  56. @ScriptManifest(name = "Chopper", authors = { "infor42" }, description = "infor's AIO Chopper", version = 2.1)
  57. public class Chopper extends Script {
  58.  
  59.     private Player me;
  60.     private Miscellaneous misc;
  61.     private ScriptContext ctx;
  62.    
  63.     private final double MOUSESPEED = 0.8D;
  64.     public final int[] axes = new int[] { 1360, 1351, 1352, 1349, 1350, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 3063, 6740 };
  65.     public final int[] ents = new int[] { 1740, 1731, 1735, 1736, 1739, 1737, 1734 };
  66.     public final int[] nests = new int[] { 5071, 5072, 5073, 5074, 5075, 5070, 7413, 5076, 304 };
  67.  
  68.     public boolean isStarted = false;
  69.     public boolean chopping = false;
  70.     public boolean moved = false;
  71.     public boolean powerChop = false;
  72.  
  73.  
  74.     public int bankBooth;
  75.     public int[] treeID;
  76.     public int treeItemId;
  77.     public double treeXP;
  78.     public Path[] paths = new Path[2];
  79.     public Path runPath;
  80.     public Tile treeLoc1;
  81.     public Tile treeLoc2;
  82.     public Tile bankLoc;
  83.     public Area bankArea;
  84.     public Area treeArea;
  85.     public Area treeArea1;
  86.     public Area treeArea2;
  87.  
  88.     public GameObject tree;
  89.  
  90.  
  91.     //#### paint variables ####
  92.     private String status;
  93.     private long lastAntiBan;
  94.     private long antiBanInterval;
  95.     private long startTime;
  96.     private long antibanCountDown;
  97.     private long runningTime;
  98.     private String formattedTime;
  99.  
  100.     private String fTimeTillLevel = "00:00:00";
  101.     private long timeTillLevel = 0L;
  102.     private double percentToLevel = 0.0D;
  103.     private double expPerHour = 0.0D;
  104.     private double progressBar = 0.0D;
  105.     private int logsInInventory;
  106.     private int logsCut = 0;
  107.     private int logsTillLevel;
  108.     private int startingExp;
  109.     private int expGained = 0;
  110.     private Color color1 = new Color(63, 44, 242, 173);
  111.     private Color color2 = new Color(204, 204, 204);
  112.     private DecimalFormat percents = new DecimalFormat("###.##");
  113.     private DecimalFormat doubles = new DecimalFormat("#");
  114.  
  115.  
  116.     public String treeToCut;
  117.     public String location;
  118.     public boolean waitingForGui;
  119.     public Gui gui;
  120.  
  121.  
  122.     @Override
  123.     public void close() {
  124.         log("Stopping Script");
  125.         this.isStarted = false;
  126.         this.getContext().getBot().popScript();
  127.     }
  128.  
  129.     @Override
  130.     public boolean init() {
  131.         this.waitingForGui = true;
  132.         SwingUtilities.invokeLater(new Runnable() {
  133.             public void run() {
  134.                 try {
  135.                     gui = new Gui(2.0);
  136.                 } catch (Exception e) {
  137.                     e.printStackTrace();
  138.                 }
  139.             }
  140.         });
  141.         while(this.waitingForGui) {
  142.             if(status == null) {
  143.                 status = "Waiting for Gui";
  144.                 log(status);
  145.             }
  146.             sleep(1000);
  147.         }
  148.         initVariables();       
  149.  
  150.         this.ctx = this.getContext();
  151.         this.misc = new Miscellaneous(ctx);
  152.         this.me = this.players.getLocalPlayer();
  153.         this.isStarted = true;
  154.        
  155.         this.lastAntiBan = 0L;
  156.         this.antiBanInterval = (new Random().nextInt(40) + 10 * 1000L);
  157.         this.startTime = 0L;
  158.         this.antibanCountDown = (this.antiBanInterval / 1000L);
  159.         this.runningTime = 0L;
  160.         this.formattedTime = "00:00:00";
  161.  
  162.         this.logsInInventory = inventory.getCount(false, this.treeItemId);
  163.         this.startingExp = skills.getExperience(Skills.WOODCUTTING);       
  164.  
  165.         mouse.setSpeed(MOUSESPEED);
  166.         camera.adjustPitch(100);
  167.         misc.waitFor(new Condition() {
  168.             @Override
  169.             public boolean validate() {
  170.                 Chopper.this.camera.adjustPitch(100);
  171.                 return false;
  172.             }
  173.  
  174.         }, 1000L);
  175.         return this.isStarted;
  176.     }
  177.  
  178.     @Override
  179.     public int pulse() {
  180.         this.runFromCombat();
  181.         this.pickUpNest();     
  182.         if(!this.me.isAnimating()) {
  183.             this.chopping = false;
  184.         } else {
  185.             chopping = true;
  186.         }
  187.  
  188.         if(inventory.isFull() && !bankArea.contains(me) && !me.isMoving()) {
  189.             if(powerChop) {
  190.                 this.dropAllExcept(new Filter<Item>() {
  191.                     public boolean accept(Item i) {
  192.                         return misc.contains(axes, i.getId());
  193.                     }
  194.                 });
  195.             } else {
  196.                 if(this.treeArea.contains(me)) {
  197.                     this.paths[0].reset();
  198.                 }
  199.                 if(me.getLocation().distanceTo(bankLoc) >= 15) {
  200.                     this.walkToBank();
  201.                 } else if(me.getLocation().distanceTo(bankLoc) < 15) {
  202.                     navigation.navigate(bankLoc, NavigationPolicy.MINIMAP);
  203.                 }
  204.             }
  205.         }
  206.         if(!this.treeArea.contains(this.me.getLocation()) && !me.isMoving() && !inventory.isFull()) {
  207.             if(this.bankArea.contains(me)) {
  208.                 this.paths[1].reset();
  209.             }
  210.             if(me.getLocation().distanceTo(treeLoc1) >= 15 && inventory.freeSpace() >= 27 && this.bankArea.contains(me)) {
  211.                 this.walkToTrees();
  212.             } else if(me.getLocation().distanceTo(treeLoc1) < 15) {
  213.                 navigation.navigate(treeLoc1, NavigationPolicy.MINIMAP);
  214.             }
  215.         }
  216.         if(inventory.freeSpace() <= 27 && this.bankArea.contains(me) && !this.me.isMoving()) {
  217.             this.bank();
  218.         }
  219.         if(!inventory.isFull() && this.treeArea.contains(this.me.getLocation()) && !this.me.isAnimating() && !this.chopping) {
  220.             if(chop() && me.isAnimating()) {
  221.                 this.moveMouseOffScreen();
  222.                 sleep(1000, 1200);
  223.             }
  224.  
  225.         }
  226.         this.antiBan();
  227.         return random(200, 300);
  228.     }
  229.  
  230.     public void walkToOtherTree() {
  231.         if(this.treeArea1.contains(me.getLocation())) {
  232.             this.navigation.navigate(this.treeLoc2, NavigationPolicy.MINIMAP);
  233.         } else if(this.treeArea2.contains(me.getLocation())) {
  234.             this.navigation.navigate(this.treeLoc1, NavigationPolicy.MINIMAP);
  235.         }
  236.     }
  237.  
  238.     public boolean chop() {
  239.         if(me.isAnimating() || me.isMoving()) {
  240.             return false;
  241.         }
  242.  
  243.         if(!this.chopping) {
  244.             this.tree = this.getTree(this.treeID);
  245.             if(!misc.contains(this.treeID, tree.getId()) || !treeArea.contains(tree)) {
  246.                 tree = null;
  247.             }
  248.         }
  249.  
  250.         if(tree != null && misc.isVisible(tree) && !me.isAnimating()) {
  251.             this.status = "Chopping Tree";
  252.             misc.interact(tree, "Chop");
  253.             if(menu.getChoices().contains("Use")) {
  254.                 game.openTab(Game.Tabs.INVENTORY);
  255.                 misc.interact(tree, "Chop");
  256.             }
  257.             this.chopping = true;
  258.             this.moved = false;
  259.             return this.chopping;
  260.         }
  261.  
  262.         if(tree == null && !me.isAnimating() && !this.chopping && !this.moved) {
  263.             this.status = "Waiting for tree";
  264.             this.walkToOtherTree();
  265.             this.moved = true;
  266.         } else if(tree != null && !misc.isVisible(tree) && !me.isAnimating() && !this.chopping){
  267.             this.status = "Tree found";
  268.             this.walkToOtherTree();
  269.             misc.waitFor(new Condition() {
  270.                 public boolean validate() {
  271.                     camera.rotateToObject(tree);
  272.                     camera.adjustPitch(100);
  273.                     return true;
  274.                 }
  275.             }, 1000L);
  276.             this.moved = false;
  277.         }
  278.         return this.chopping;
  279.     }
  280.  
  281.     private GameObject getTree(final int[] treeID) {
  282.         return objects.getNearest(new Filter<GameObject>() {
  283.             @Override
  284.             public boolean accept(GameObject obj) {
  285.                 return misc.contains(treeID, obj.getId());
  286.             }
  287.         });
  288.     }
  289.  
  290.     public boolean walkToBank() {
  291.         this.status = "Walking to bank";
  292.         this.navigation.navigate(this.paths[0], 2, NavigationPolicy.MINIMAP);
  293.         sleep(1000, 2000);
  294.         return inventory.isFull();
  295.     }
  296.  
  297.     public boolean walkToTrees() {
  298.         this.status = "Walking to trees";
  299.         this.navigation.navigate(this.paths[1], 2, NavigationPolicy.MINIMAP);
  300.         sleep(1000, 2000);
  301.         return !inventory.isFull();
  302.     }
  303.  
  304.     public void dropAllExcept(final Filter<Item> toKeep) {
  305.         mouse.setSpeed(.5);
  306.         if(!widgets.get(Inventory.INVENTORY_ID, 0).isValid()) {
  307.             game.openTab(Game.Tabs.INVENTORY);
  308.         }
  309.         Filter<Item> toDrop = new Filter<Item>() {
  310.             public boolean accept(Item i) {
  311.                 return !toKeep.accept(i);
  312.             }
  313.         };     
  314.         List<Item> items = getItems(toDrop);
  315.         while(items.size() > 0) {
  316.             for(Item i : items) {
  317.                 inventory.dropItem(i);
  318.             }
  319.             items = getItems(toDrop);
  320.         }
  321.         mouse.setSpeed(MOUSESPEED);
  322.     }
  323.    
  324.     public List<Item> getItems(Filter<Item> filter) {
  325.         Widget inventory = widgets.get(Inventory.INVENTORY_ID, 0);
  326.         List<Item> items = new ArrayList<>();
  327.         if (inventory == null) return items;
  328.  
  329.         int[] ids = inventory.getSlotContents();
  330.         int[] stacks = inventory.getSlotSizes();
  331.         if (ids == null || stacks == null) return null;
  332.  
  333.         for (int i = 0; i < ids.length; i++) {
  334.             if(ids[i] != 0 && stacks[i] != 0) {
  335.                 Item item = new Item(ctx, ids[i], stacks[i]);
  336.                 if (filter == null || filter.accept(item)) {
  337.                     items.add(item);
  338.                 }
  339.             }
  340.         }
  341.         return items;
  342.     }
  343.    
  344.     public boolean bank() {
  345.         GameObject bankBooth = objects.getNearest(new Filter<GameObject>() {
  346.             public boolean accept(GameObject element) {
  347.                 return element.getId() == Chopper.this.bankBooth;
  348.             }
  349.         });
  350.         camera.rotateToObject(bankBooth);
  351.         if(camera.isVisible(bankBooth) && !bank.isOpen()) {
  352.             misc.interact(bankBooth, "Bank");
  353.             if(menu.getChoices().contains("Use")) {
  354.                 game.openTab(Tabs.INVENTORY);
  355.                 misc.interact(bankBooth, "Bank");
  356.             }
  357.             sleep(900, 1100);          
  358.         }
  359.         if(bank.isOpen()) {
  360.             mouse.setSpeed(.6);
  361.             bank.depositAllExcept(new Filter<Item>() {
  362.                 public boolean accept(Item item) {
  363.                     return misc.contains(axes, item.getId());
  364.                 }
  365.             });
  366.             mouse.setSpeed(MOUSESPEED);
  367.         }
  368.         this.logsInInventory = 0;
  369.         return inventory.freeSpace() >= 27;
  370.     }
  371.  
  372.     public void runFromCombat() {
  373.         if(me.isInCombat()) {
  374.             log("Running from combat");
  375.             misc.waitFor(new Condition() {
  376.                 public boolean validate() {
  377.                     navigation.navigate(runPath, 2, NavigationPolicy.MINIMAP);
  378.                     return !me.isInCombat();
  379.                 }
  380.             }, 20000L);
  381.             navigation.navigate(this.treeLoc1, NavigationPolicy.MINIMAP);
  382.         }      
  383.     }
  384.  
  385.     public void pickUpNest() {
  386.         List<GroundItem> nests = groundItems.getAll(new Filter<GroundItem>() {
  387.             public boolean accept(GroundItem gi) {
  388.                 return misc.contains(Chopper.this.nests, gi.getId()) && treeArea.contains(gi);
  389.             }
  390.         });
  391.         for(GroundItem nest : nests) {         
  392.             if(nest != null && !inventory.isFull() && treeArea.contains(nest)) {
  393.                 pickup(nest);          
  394.                 sleep(500, 1000);
  395.                 if(inventory.contains(Filters.itemId(nest.getId()+1))) {
  396.                     int slot = inventory.getSlot(new Item(ctx, nest.getId()+1, 1));
  397.                     inventory.interact(slot, "Search");
  398.                 }
  399.                 sleep(1000, 1500);
  400.             }
  401.         }
  402.        
  403.     }
  404.    
  405.     public void pickup(GroundItem item) {
  406.         Tile loc = item.getLocation();
  407.         Rectangle bounds = loc.getPolygon(ctx).getBounds();
  408.         Point p = new Point(bounds.x + bounds.width/2, bounds.y + bounds.height/2);
  409.         mouse.move(p.x, p.y);
  410.         if(menu.getChoices().contains("Take")) {
  411.             mouse.click();
  412.         }
  413.     }
  414.  
  415.     public void antiBan() {
  416.         if ((System.currentTimeMillis() > this.lastAntiBan + this.antiBanInterval) && (!this.me.isMoving())) {
  417.             int r = new java.util.Random().nextInt(12) +1;
  418.             this.antiBanInterval = (random(10, 50) * 1000L);
  419.             this.lastAntiBan = System.currentTimeMillis();
  420.             this.antibanCountDown = (this.antiBanInterval / 1000L);
  421.             if(this.chopping && me.isAnimating() && !this.me.isMoving() && treeArea.contains(me)) {
  422.                 switch (r) {
  423.                 case 1:
  424.                     this.status = "Antiban: Check Exp";
  425.                     this.game.openTab(Game.Tabs.STATS);
  426.                     if(widgets.get(320, 144) != null) {
  427.                         mouse.move(widgets.get(320, 144).getClickPoint().x, widgets.get(320, 144).getClickPoint().y);
  428.                         sleep(3500, 5500);
  429.                     }
  430.                     this.game.openTab(Game.Tabs.INVENTORY);
  431.                     this.mouseMovement();
  432.                     break;
  433.                 case 2:
  434.                     this.status = "Antiban: Mouse movement";
  435.                     this.mouseMovement();
  436.                     break;
  437.                 case 3:
  438.                     this.mouseShake();
  439.                     break;
  440.                 case 4:
  441.                     List<Player> visiblePlayers = this.players.getPlayers(new Filter<Player>() {
  442.                         public boolean accept(Player p) {
  443.                             return camera.isVisible(p);
  444.                         }
  445.                     });
  446.                     Player toInspect = visiblePlayers.get(random(visiblePlayers.size()));
  447.                     if ((camera.isVisible(toInspect)) && (!toInspect.getName().equalsIgnoreCase(this.me.getName()))) {
  448.                         this.status = "Antiban: Inspect Player";
  449.                         mouse.move(toInspect.hullPoint(toInspect.hull()).x, toInspect.hullPoint(toInspect.hull()).y);
  450.                         mouse.click(true);
  451.                         sleep(1200, 1800);
  452.                         this.mouseMovement();
  453.                     } else {
  454.                         this.status = "Antiban: Skip";
  455.                     }
  456.                     break;
  457.                 case 5:
  458.                     this.status = "Antiban: Check Exp";
  459.                     this.game.openTab(Game.Tabs.STATS);
  460.                     if(widgets.get(320, 144) != null) {
  461.                         mouse.move(widgets.get(320, 144).getClickPoint().x, (widgets.get(320, 144).getClickPoint().y));
  462.                         sleep(3500, 5500);
  463.                     }
  464.                     this.game.openTab(Game.Tabs.INVENTORY);
  465.                     this.mouseMovement();
  466.                     break;
  467.                 case 6:
  468.                     this.status = "Antiban: Camera Angle";
  469.                     camera.rotateAngleTo(random(10, 175));
  470.                     break;
  471.                 case 7:
  472.                     this.status = "Antiban: Camera Angle";
  473.                     camera.rotateAngleTo(random(10, 175));
  474.                     break;
  475.                 case 11:
  476.                     this.status = "Antiban: Mouse Offscreen";
  477.                     moveMouseOffScreen();
  478.                     break;
  479.                 case 12:
  480.                     this.status = "Antiban: Mouse movement";
  481.                     this.mouseMovement();
  482.                     break;
  483.                 default:
  484.                     this.status = "Antiban: Skip";
  485.                 }
  486.             }
  487.         }
  488.     }
  489.  
  490.     public void moveMouseOffScreen() {
  491.         switch (random(0,3)) {
  492.         case 0:
  493.             mouse.move(-10, random(1, 510));
  494.             break;
  495.         case 1:
  496.             mouse.move(770, random(1, 510));
  497.             break;
  498.         case 2:
  499.             mouse.move(random(1, 760), 510);
  500.         }
  501.     }
  502.  
  503.     public void mouseMovement() {
  504.         mouse.move(random(7, 750), random(7, 400));
  505.     }
  506.  
  507.     public void mouseShake() {
  508.         this.status = "Antiban: Mouse Shake";
  509.         for (int i = 0; i < random(4, 7); i++)
  510.             mouse.move(random(10, 490), random(10, 250));
  511.     }
  512.  
  513.     //########## Paint & GUI methods ##########//
  514.  
  515.     public void updateTimeData()
  516.     {
  517.         if (System.currentTimeMillis() >= this.startTime + 1000L) {
  518.             this.runningTime += 1L;
  519.             if (this.antibanCountDown > 0L) {
  520.                 this.antibanCountDown -= 1L;
  521.             }
  522.             this.startTime = System.currentTimeMillis();
  523.         }
  524.         int mins = 0; int hours = 0; int seconds = 0;
  525.         seconds = (int)this.runningTime;
  526.         mins = seconds / 60;
  527.         hours = mins / 60;
  528.  
  529.         seconds -= mins * 60;
  530.         mins -= hours * 60;
  531.  
  532.         DecimalFormat format = new DecimalFormat("00");
  533.  
  534.         this.formattedTime = (format.format(hours) + ":" + format.format(mins) + ":" + format.format(seconds));
  535.     }
  536.  
  537.     public String formatClock(int s) {
  538.         int mins = 0; int hours = 0; int seconds = 0;
  539.         seconds = s;
  540.         mins = seconds / 60;
  541.         hours = mins / 60;
  542.  
  543.         seconds -= mins * 60;
  544.         mins -= hours * 60;
  545.  
  546.         DecimalFormat format = new DecimalFormat("00");
  547.  
  548.         return format.format(hours) + ":" + format.format(mins) + ":" + format.format(seconds);
  549.     }
  550.  
  551.     public void updatePaintData() {
  552.         updateTimeData();
  553.         if (inventory.getCount(false, this.treeItemId) > this.logsInInventory) {
  554.             this.logsCut++;
  555.             this.logsInInventory = inventory.getCount(false, this.treeItemId);
  556.         }
  557.         int myExp = this.skills.getExperience(Skills.WOODCUTTING);
  558.         int expOfCurrent = Skills.EXPERIENCE_TABLE[skills.getLevel(Skills.WOODCUTTING)];
  559.         int expOfNext = Skills.EXPERIENCE_TABLE[skills.getLevel(Skills.WOODCUTTING) + 1];
  560.         int expTillNext = skills.getExperienceToNextLevel(Skills.WOODCUTTING);
  561.  
  562.         this.expGained = (myExp - this.startingExp);
  563.         this.logsTillLevel = (int)((expTillNext) / this.treeXP) + 1;
  564.         this.percentToLevel = (double)(myExp - expOfCurrent) / (expOfNext - expOfCurrent) * 100.0D;
  565.         this.expPerHour = (this.expGained / (this.runningTime / 3600.0D));
  566.         this.progressBar = (this.percentToLevel * 0.01D * 512.0D);
  567.         this.timeTillLevel = (long) ((expTillNext / this.expPerHour * 3600.0D));
  568.         this.fTimeTillLevel = formatClock((int)this.timeTillLevel);
  569.     }
  570.  
  571.  
  572.     @Override
  573.     public void render(Graphics2D g) {
  574.         updatePaintData();
  575.         g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);    
  576.         if ((tree != null) && this.treeArea.contains(tree.getLocation()) && this.treeArea.contains(me)) {
  577.             this.drawTree(g, tree, this.color1);
  578.         }      
  579.  
  580.         this.drawCursor(g, mouse.getPosition());
  581.  
  582.         Rectangle r = new Rectangle(5, 322, 511, 15);
  583.         GradientPaint p = new GradientPaint(r.getLocation().x, r.getLocation().y, new Color(0x336A96), r.getLocation().x, (float) (r.getLocation().y + r.getHeight() +9), Color.black);
  584.         g.setColor(new Color(201, 201, 201));
  585.         g.fill(r);
  586.         g.setPaint(p);
  587.         g.fillRect(r.getLocation().x, r.getLocation().y, (int)this.progressBar, (int) r.getHeight());
  588.         g.setColor(Color.black);
  589.         g.drawRect(4, 321, 512, 16);
  590.         g.drawString(this.percents.format(this.percentToLevel) + "% to " + (skills.getLevel(Skills.WOODCUTTING) + 1), 240, 335);
  591.  
  592.         g.setColor(this.color2);
  593.         g.drawString("Time: ", 8, 256);
  594.         g.drawString("Status: ", 8, 270);
  595.         g.drawString("Logs Cut: ", 8, 284);
  596.         g.drawString("Experience: ", 8, 298);
  597.         g.drawString("Exp/Hour: ", 8, 312);
  598.         g.setColor(Color.white);
  599.         g.drawString(this.formattedTime, 43, 256);
  600.         g.drawString(this.status, 49, 270);
  601.         g.drawString(this.logsCut + " | " + this.logsTillLevel, 65, 284);
  602.         g.drawString(""+this.expGained, 80, 298);
  603.         g.drawString(this.doubles.format(this.expPerHour) + " | " + this.fTimeTillLevel, 70, 312);
  604.     }
  605.  
  606.     public void drawCursor(Graphics2D g, Point p) {
  607.         g.setColor(Color.white);
  608.         g.drawLine(p.x + 15, p.y, p.x - 15, p.y);
  609.         g.drawLine(p.x, p.y - 15, p.x, p.y +15);
  610.     }
  611.    
  612. //  public void drawGroundItem(Graphics2D g) {
  613. //      for(GroundItem obj : groundItems.getAll(null, this.treeArea)) {
  614. //          if (!Perspective.on_screen(getContext().getClient(), obj.getLocation()))
  615. //              continue;
  616. //          Point point = Perspective.trans_tile_screen(getContext().getClient(), obj.getLocation(), 0.5, 0.5, 1);
  617. //          g.setColor(Color.GREEN);
  618. //          g.fillOval(point.x - 2, point.y - 2, 4, 4);
  619. //          g.setColor(Color.WHITE);
  620. //          g.drawString(""+obj.getId(), point.x +15, point.y +15);
  621. //      }
  622. //  }
  623.    
  624. //  public void drawTile(Graphics2D g) {
  625. //      for(Tile t : pa.getTiles()) {
  626. //          if (!Perspective.on_screen(getContext().getClient(), t))
  627. //              continue;
  628. //          Point point = Perspective.trans_tile_screen(getContext().getClient(), t, 0.5, 0.5, 1);
  629. //          g.setColor(Color.GREEN);
  630. //          g.fillOval(point.x - 2, point.y - 2, 4, 4);
  631. //          g.setColor(Color.WHITE);
  632. //          g.drawString(""+t.toString(), point.x +5, point.y +5);
  633. //      }
  634. //      g.drawString("" + pa.contains(me), 20, 40);
  635. //  }
  636.  
  637.     public void drawTree(Graphics2D graphics, GameObject obj, Color color) {
  638.         Model model = obj.getModel();
  639.         if ((model == null) || (!model.isValid())) {
  640.             return;
  641.         }
  642.  
  643.         Vec3[][] vectors = model.getVectors();
  644.  
  645.         graphics.setColor(color);
  646.  
  647.         int gx = obj.getLocation().getGx();
  648.         int gy = obj.getLocation().getGy();
  649.         for (Vec3[] points : vectors) {
  650.             Vec3 pa = points[0];
  651.             Vec3 pb = points[1];
  652.             Vec3 pc = points[2];
  653.  
  654.             Point a = Perspective.trans_tile_cam(getContext().getClient(), gx + (int)pa.x, gy + (int)pc.x, 0 - (int)pb.x);
  655.             Point b = Perspective.trans_tile_cam(getContext().getClient(), gx + (int)pa.y, gy + (int)pc.y, 0 - (int)pb.y);
  656.             Point c = Perspective.trans_tile_cam(getContext().getClient(), gx + (int)pa.z, gy + (int)pc.z, 0 - (int)pb.z);
  657.  
  658.             if ((a.x >= 0) && (b.x >= 0) && (c.x >= 0)) {
  659.                 Polygon poly = new Polygon(new int[] { a.x, b.x, c.x }, new int[] { a.y, b.y, c.y }, 3);
  660.                
  661.                 graphics.drawPolygon(poly);
  662.             }
  663.         }
  664.     }
  665.    
  666.     private class Gui extends JFrame implements ActionListener {
  667.  
  668.         private static final long serialVersionUID = 1L;
  669.         private JComboBox<String> locationBox;
  670.         private JComboBox<String> treeBox;
  671.         private String[] trees = { "Willows", "Maples", "Yews", "Tower Magics", "Magics" };
  672.         private String[] locations = { "Seers", "Draynor", "Catherby" };
  673.         private JButton start;
  674.         private JButton cancel;
  675.         private JLabel locationLabel;
  676.         private JLabel treeLabel;
  677.         private JCheckBox powerChop;
  678.  
  679.  
  680.         @SuppressWarnings({ "rawtypes", "unchecked" })
  681.         public Gui(double ver) {
  682.             super("Chopper " + ver);
  683.             this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  684.             JPanel contentPane = (JPanel)this.getContentPane();
  685.             contentPane.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
  686.  
  687.             JPanel row1 = new JPanel();
  688.             JPanel row2 = new JPanel();
  689.  
  690.             row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS));
  691.             row2.setLayout(new BoxLayout(row2, BoxLayout.X_AXIS));
  692.  
  693.             locationLabel = new JLabel("Location:");
  694.             treeLabel = new JLabel("Tree:");
  695.  
  696.             locationBox = new JComboBox<>();
  697.             locationBox.setModel(new DefaultComboBoxModel(locations));
  698.             locationBox.setMaximumSize(new Dimension(locationBox.getPreferredSize().width + 50, locationBox.getPreferredSize().height));
  699.             locationBox.addActionListener(this);
  700.  
  701.             treeBox = new JComboBox<>();
  702.             treeBox.setModel(new DefaultComboBoxModel(trees));
  703.             treeBox.setMaximumSize(new Dimension(treeBox.getPreferredSize().width + 50, treeBox.getPreferredSize().height));
  704.            
  705.             powerChop = new JCheckBox("Power Chop");
  706.             powerChop.setSelected(false);
  707.             powerChop.addActionListener(this);
  708.  
  709.             start = new JButton("Start");
  710.             start.addActionListener(this);
  711.             cancel = new JButton("Cancel");
  712.             cancel.addActionListener(this);
  713.  
  714.             row1.add(Box.createHorizontalStrut(10));
  715.             row1.add(locationLabel);
  716.             row1.add(Box.createHorizontalStrut(5));
  717.             row1.add(locationBox);
  718.             row1.add(Box.createHorizontalStrut(10));
  719.             row1.add(treeLabel);
  720.             row1.add(Box.createHorizontalStrut(5));
  721.             row1.add(treeBox);
  722.             row1.add(Box.createHorizontalStrut(10));
  723.             row2.add(start);
  724.             row2.add(Box.createHorizontalStrut(10));
  725.             row2.add(cancel);
  726.             row2.add(Box.createHorizontalStrut(10));
  727.             row2.add(powerChop);
  728.  
  729.             contentPane.add(row1);
  730.             contentPane.add(Box.createVerticalStrut(30));
  731.             contentPane.add(row2);
  732.             contentPane.add(Box.createVerticalStrut(10));
  733.             this.pack();
  734.             this.setResizable(false);
  735.             this.setLocationRelativeTo(null);
  736.             this.pack();
  737.             this.setLocationRelativeTo(Chopper.this.getContext().getBot().getWindow().getFrame());
  738.             this.setVisible(true);
  739.         }
  740.  
  741.         @Override
  742.         public void actionPerformed(ActionEvent e) {
  743.             Chopper.this.powerChop = this.powerChop.isSelected();
  744.             if(e.getSource().equals(this.start)) {
  745.                 Chopper.this.treeToCut = treeBox.getSelectedItem().toString();
  746.                 Chopper.this.location = locationBox.getSelectedItem().toString();
  747.                 Chopper.this.waitingForGui = false;
  748.                 this.setVisible(false);
  749.             } else if(e.getSource().equals(this.locationBox)) {
  750.                 switch(this.locationBox.getSelectedItem().toString()) {
  751.                 case "Seers":
  752.                     treeBox.removeAllItems();
  753.                     treeBox.addItem("Willows");
  754.                     treeBox.addItem("Maples");
  755.                     treeBox.addItem("Yews");
  756.                     treeBox.addItem("Tower Magics");
  757.                     treeBox.addItem("Magics");
  758.                     break;
  759.                 case "Draynor":
  760.                     treeBox.removeAllItems();
  761.                     treeBox.addItem("Willows");
  762.                     break;
  763.                 case "Catherby":
  764.                     treeBox.removeAllItems();
  765.                     treeBox.addItem("Yews");
  766.                     break;
  767.                 }
  768.             } else if(e.getSource().equals(cancel)) {
  769.                 Chopper.this.close();
  770.                 this.dispose();
  771.             }
  772.         }
  773.     }
  774.    
  775.     public void initVariables() {
  776.         if(this.treeToCut == null || this.location == null) {
  777.             log("Tree and location were not selected");
  778.             this.close();
  779.         }
  780.        
  781.         log("Starting Script: cutting " + this.treeToCut + " at " + this.location);
  782.  
  783.         if(treeToCut.equals("Yews")) {
  784.             this.treeID = new int[1];
  785.             this.treeID[0] = 1309;
  786.             this.treeItemId = 1516;
  787.             this.treeXP = 175;
  788.  
  789.             if(location.equalsIgnoreCase("Seers")) {
  790.                 this.bankBooth = 25808;
  791.                 this.bankLoc = new Tile(2725, 3492);
  792.                 this.bankArea = new Area(new Tile(2721, 3490), new Tile(2730, 3493));
  793.                 this.treeArea = new Area(new Tile(3082, 3226), new Tile(3091, 3239));
  794.                 this.treeLoc1 = new Tile(2714, 3462);
  795.                 this.treeLoc2 = new Tile(2707, 3462);              
  796.                 this.treeArea = new Area(new Tile(2704, 3459), new Tile(2716, 3467));
  797.                 this.treeArea1 = new Area(new Tile(2711, 3459), new Tile(2716, 3464));
  798.                 this.treeArea2 = new Area(new Tile(2704, 3459), new Tile(2709, 3466));
  799.                 this.runPath = new Path(new Tile(2717, 3462), new Tile(2728, 3464));
  800.                 this.paths[0] = new Path(new Tile(2720, 3467), new Tile(2726, 3477), new Tile(2725, 3491));
  801.                 this.paths[1] = new Path(new Tile(2720, 3484), new Tile(2718, 3470), new Tile(2713, 3463));
  802.             }
  803.            
  804.             if(location.equalsIgnoreCase("Catherby")) {
  805.                 this.bankBooth = 2213;
  806.                 this.bankLoc = new Tile(2810, 3440);
  807.                 this.bankArea = new Area(new Tile(2806, 3438), new Tile(2812, 3441));
  808.                 this.treeArea = new Area(new Tile(2754, 3426), new Tile(2773, 3440));
  809.                 this.treeArea1 = this.treeArea;
  810.                 this.treeArea2 = this.treeArea;
  811.                 this.treeLoc1 = new Tile(2763, 3434);
  812.                 this.treeLoc2 = new Tile(2758, 3431);
  813.                 this.runPath = new Path(new Tile(2751, 3419));
  814.                 this.paths[0] = new Path(new Tile(2769, 3432), new Tile(2781, 3432), new Tile(2795, 3433), new Tile(2807, 3433), new Tile(2810, 3440));
  815.                 this.paths[1] = new Path(new Tile(2800, 3432), new Tile(2788, 3432), new Tile(2775, 3433), new Tile(2763, 3430));
  816.             }
  817.         }
  818.         if(treeToCut.equalsIgnoreCase("Tower Magics")) {
  819.             this.treeID = new int[1];
  820.             this.treeID[0] = 1306;
  821.             this.treeItemId = 1514;    
  822.             this.treeXP = 200;
  823.  
  824.             this.bankBooth = 25808;
  825.             this.bankLoc = new Tile(2725, 3492);
  826.             this.bankArea = new Area(new Tile(2721, 3490), new Tile(2730, 3493));
  827.             this.treeArea = new Area(new Tile(3082, 3226), new Tile(3091, 3239));
  828.             this.treeLoc1 = new Tile(2703, 3398);
  829.             this.treeLoc2 = this.treeLoc1;             
  830.             this.treeArea = new Area(new Tile(2697, 3394), new Tile(2706, 3464));
  831.             this.treeArea1 = this.treeArea;
  832.             this.treeArea2 = this.treeArea;
  833.             this.runPath = new Path(new Tile(2701, 3387));
  834.             this.paths[0] = new Path(new Tile(2715, 3399), new Tile(2716, 3412), new Tile(2707, 3424), new Tile(2709, 3437), new Tile(2712, 3450), new Tile(2721, 3459), new Tile(2720, 3467), new Tile(2726, 3477), new Tile(2725, 3491));
  835.             this.paths[1] = new Path(new Tile(2720, 3484), new Tile(2718, 3470), new Tile(2719, 3457), new Tile(2710, 3450), new Tile(2710, 3437), new Tile(2717, 3426), new Tile(2716, 3413), new Tile(2716, 3400), new Tile(2708, 3391), new Tile(2702, 3398));
  836.         }
  837.         if(treeToCut.equalsIgnoreCase("Magics")) {
  838.             this.treeID = new int[1];
  839.             this.treeID[0] = 1306;
  840.             this.treeItemId = 1514;    
  841.             this.treeXP = 200;
  842.            
  843.             if(location.equalsIgnoreCase("Seers")) {
  844.                 this.bankBooth = 25808;
  845.                 this.bankLoc = new Tile(2725, 3492);
  846.                 this.bankArea = new Area(new Tile(2721, 3490), new Tile(2730, 3493));
  847.                 this.treeArea = new Area(new Tile(3082, 3226), new Tile(3091, 3239));
  848.                 this.treeArea = new Area(new Tile(2688, 3422), new Tile(2698, 3430));
  849.                 this.treeArea1 = this.treeArea;
  850.                 this.treeArea2 = this.treeArea;
  851.                 this.treeLoc1 = new Tile(2694, 3424);
  852.                 this.treeLoc2 = new Tile(2692, 3426);
  853.                 this.runPath = new Path(new Tile(2711, 2422));
  854.                 this.paths[0] = new Path(new Tile(2707, 3432), new Tile(2708, 3444), new Tile(2715, 3454), new Tile(2721, 3462), new Tile(2724, 3475), new Tile(2724, 3484), new Tile(2725, 3490));
  855.                 this.paths[1] = new Path(new Tile(2720, 3484), new Tile(2718, 3470), new Tile(2719, 3457), new Tile(2711, 3450), new Tile(2708, 3437), new Tile(2703, 3429), new Tile(2694, 3425));
  856.             }
  857.         }
  858.         if(this.treeToCut.equalsIgnoreCase("Willows")) {
  859.             this.treeID = new int[4];
  860.             this.treeID[0] = 1308;
  861.             this.treeID[1] = 5551;
  862.             this.treeID[2] = 5552;
  863.             this.treeID[3] = 5553;
  864.             this.treeItemId = 1520;
  865.             this.treeXP = 67.5;
  866.            
  867.             if(this.location.equalsIgnoreCase("Seers")) {
  868.                 this.bankBooth = 25808;
  869.                 this.bankLoc = new Tile(2725, 3492);
  870.                 this.bankArea = new Area(new Tile(2721, 3490), new Tile(2730, 3493));
  871.                 this.treeArea = new Area(new Tile(2703, 3504), new Tile(2714, 3517));
  872.                 this.treeArea1 = this.treeArea;
  873.                 this.treeArea2 = this.treeArea;
  874.                 this.treeLoc1 = new Tile(2708, 3508);
  875.                 this.treeLoc2 = this.treeLoc1;
  876.                 this.runPath = new Path(new Tile(2702, 3498));
  877.                 this.paths[0] = new Path(new Tile(2716, 3498), new Tile (2726, 3492));
  878.                 this.paths[1] = new Path(new Tile(2717, 3497), new Tile(2709, 3508));
  879.             }
  880.            
  881.             if(this.location.equalsIgnoreCase("Draynor")) {
  882.                 this.bankBooth = 2213;
  883.                 this.bankLoc = new Tile(3093, 3243);
  884.                 this.bankArea = new Area(new Tile(3092, 3240), new Tile(3097, 3246));
  885.                 this.treeArea = new Area(new Tile(3082, 3226), new Tile(3091, 3239));
  886.                 this.treeArea1 = this.treeArea;
  887.                 this.treeArea2 = this.treeArea;
  888.                 this.treeLoc1 = new Tile(3089, 3230);
  889.                 this.treeLoc2 = new Tile(3090, 3230);
  890.                 this.runPath = new Path(new Tile(3100, 3234));
  891.                 this.paths[0] = new Path(new Tile(3093, 3242));
  892.                 this.paths[1] = new Path(this.treeLoc1);
  893.             }
  894.         }
  895.         if(treeToCut.equalsIgnoreCase("Maples")) {
  896.             this.treeID = new int[1];
  897.             this.treeID[0] = 1307;
  898.             this.treeItemId = 1518;
  899.             this.treeXP = 100;
  900.            
  901.             if(this.location.equalsIgnoreCase("Seers")) {
  902.                 this.bankBooth = 25808;
  903.                 this.bankLoc = new Tile(2725, 3492);
  904.                 this.bankArea = new Area(new Tile(2721, 3490), new Tile(2730, 3493));
  905.                 this.treeArea = new Area(new Tile(2677, 3520), new Tile(2687, 3531));
  906.                 this.treeArea1 = this.treeArea;
  907.                 this.treeArea2 = this.treeArea;
  908.                 this.treeLoc1 = new Tile(2682, 3525);
  909.                 this.treeLoc2 = this.treeLoc1;
  910.                 this.runPath = new Path(new Tile(2675, 3521));
  911.                 this.paths[0] = new Path(new Tile(2686, 3517), new Tile(2694, 3510), new Tile(2702, 3508), new Tile(2714, 3507), new Tile(2716, 3498), new Tile(2726, 3492));
  912.                 this.paths[1] = new Path(new Tile(2718, 3500), new Tile(2707, 3508), new Tile(2694, 3511), new Tile(2685, 3518), new Tile(2683, 3525));
  913.             }
  914.         }
  915.     }
  916. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement