Advertisement
Atex_

Action.java - Construction bot

Mar 6th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.26 KB | None | 0 0
  1. import java.awt.Point;
  2.  
  3. import org.parabot.environment.api.utils.Time;
  4. import org.parabot.environment.scripts.framework.SleepCondition;
  5. import org.parabot.environment.scripts.framework.Strategy;
  6. import org.rev317.min.api.methods.Game;
  7. import org.rev317.min.api.methods.Inventory;
  8. import org.rev317.min.api.methods.Players;
  9. import org.rev317.min.api.methods.SceneObjects;
  10. import org.rev317.min.api.wrappers.SceneObject;
  11. import org.rev317.min.api.methods.Skill;
  12. import org.parabot.environment.input.Mouse;
  13.  
  14.  
  15. public class Action implements Strategy {
  16.     boolean location = false; //true = inside; false = outside
  17.     Banking banker = new Banking();
  18.     boolean doneBuilding=true;
  19.     final Mouse mouse = Mouse.getInstance();
  20.     public static int rank = 0; // 0: level 1-25; 1: level 26-53; 2: level 54-99
  21.     public static boolean done = false;
  22.     Point enter = new Point(263,415);
  23.     Point buildCapeRack = new Point(99,77);
  24.     Point buildArmChair = new Point(100, 215);
  25.     int idChairSpace=13585;
  26.     int idEmptyChairSpace=15410;
  27.     int idCapeRack=18766;
  28.     int idEmptyCapeRack=18810;
  29.     int iObject;
  30.     int iEmptyObject;
  31.    
  32.     @Override
  33.     public boolean activate() {
  34.         return true;
  35.     }
  36.     @Override
  37.     public void execute() {
  38.         while(done) {
  39.             Main.status = "Out of planks!";//Script crashes because of this, which is good I guess?
  40.         }
  41.         int conLevel = Skill.getCurrentLevel(24);
  42.         //if(conLevel < 26) Low levels not yet supported
  43.         if(conLevel < 54) { //Build Oak armchair
  44.             rank = 1;
  45.         } else if(conLevel > 53) { //Build Oak cape rack
  46.             rank = 2;
  47.         }
  48.         if(rank == 1) {
  49.             iObject=idChairSpace;
  50.             iEmptyObject=idEmptyChairSpace;
  51.         } else if(rank == 2) {
  52.             iObject=idCapeRack;
  53.             iEmptyObject=idEmptyCapeRack;
  54.         }
  55.         SceneObject oEmptyObject = SceneObjects.getClosest(iEmptyObject);
  56.         SceneObject oObject = SceneObjects.getClosest(iObject);
  57.         SceneObject portalOutside = SceneObjects.getClosest(15477);
  58.         SceneObject portalInside = SceneObjects.getClosest(13405);
  59.        
  60.         if(portalOutside != null && !doneBuilding) { //Player is outside > going inside
  61.             Main.status = "Entering house";
  62.             portalOutside.interact(0);
  63.             Time.sleep(new SleepCondition() {
  64.                 @Override
  65.                 public boolean isValid() {
  66.                     return Game.getOpenBackDialogId() == 2469;
  67.                 }
  68.             },3000);
  69.             Time.sleep(2000);
  70.             if(Game.getOpenBackDialogId() == 2469) {
  71.                 mouse.click(enter, true);
  72.             }
  73.         }
  74.         if(portalInside != null && doneBuilding) { //Player is inside + done building > going outside
  75.             Main.status = "Exiting house";
  76.             portalInside.interact(0);
  77.             Time.sleep(new SleepCondition() {
  78.                 @Override
  79.                 public boolean isValid() {
  80.                     return Game.getOpenInterfaceId() != -1;
  81.                 }
  82.             },1000);
  83.             Time.sleep(new SleepCondition() {
  84.                 @Override
  85.                 public boolean isValid() {
  86.                     return Game.getOpenInterfaceId() != 28640;
  87.                 }
  88.             },1000);
  89.         }
  90.         if(portalOutside != null && doneBuilding) { //Player is outside + done building > getting planks
  91.             Main.status = "Banking";
  92.             banker.bank();
  93.             doneBuilding = false;
  94.         }
  95.         if(portalInside != null && !doneBuilding && oEmptyObject != null) { //Player is inside + not done building + empty object > build object
  96.             if(Inventory.getCount() < 5) {
  97.                 doneBuilding = true;
  98.                 Time.sleep(1000);
  99.             } else {
  100.                 oEmptyObject.interact(4);
  101.                 Time.sleep(new SleepCondition() {
  102.                     @Override
  103.                     public boolean isValid() {
  104.                         return Game.getOpenInterfaceId() == 38272;
  105.                     }
  106.                 },2000);
  107.                 Time.sleep(1000);
  108.                 if(Game.getOpenInterfaceId() == 38272) {
  109.                     if(rank==1) {
  110.                         mouse.click(buildArmChair);
  111.                     } else if(rank == 2) {
  112.                         mouse.click(buildCapeRack);
  113.                     }
  114.                    
  115.                 }
  116.                 Time.sleep(new SleepCondition() {
  117.                     @Override
  118.                     public boolean isValid() {
  119.                         return Players.getMyPlayer().getAnimation() != -1;
  120.                     }
  121.                 },1000);
  122.                 Main.status = "Building";
  123.             }
  124.         }
  125.         if(portalInside != null && !doneBuilding && oObject != null) { //Player is inside + not done building + object > remove object
  126.             if(Inventory.getCount() < 5) {
  127.                 doneBuilding = true;
  128.                 Time.sleep(1000);
  129.             } else {
  130.                 Time.sleep(1000);
  131.                 oObject.interact(4);
  132.                 Time.sleep(new SleepCondition() {
  133.                     @Override
  134.                     public boolean isValid() {
  135.                         return Players.getMyPlayer().getAnimation() != -1;
  136.                     }
  137.                 },1000);
  138.             }
  139.         }
  140.     }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement