Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.02 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. import org.rsbot.script.Script;
  4. import org.rsbot.script.ScriptManifest;
  5. import org.rsbot.script.wrappers.RSObject;
  6. import org.rsbot.script.wrappers.RSTile;
  7. import org.rsbot.script.wrappers.RSArea;
  8. import org.rsbot.script.wrappers.RSTilePath;
  9. import org.rsbot.event.listeners.PaintListener;
  10.  
  11. @ScriptManifest(authors = { "Creations" }, keywords = { "KEYWORDS" }, name = "CFungy", version = 1.0, description = "Picks Fungus.")
  12.  
  13. public class CFungus extends Script implements PaintListener {
  14.    
  15.     RSTile bankToGate[] = { new RSTile(3509, 3480), new RSTile(3506, 3480),
  16.             new RSTile(3503, 3480), new RSTile(3500, 3481),
  17.             new RSTile(3497, 3481), new RSTile(3494, 3481),
  18.             new RSTile(3491, 3481), new RSTile(3488, 3480),
  19.             new RSTile(3486, 3479), new RSTile(3484, 3478),
  20.             new RSTile(3481, 3477), new RSTile(3478, 3477),
  21.             new RSTile(3475, 3476), new RSTile(3472, 3475),
  22.             new RSTile(3469, 3474), new RSTile(3466, 3473),
  23.             new RSTile(3464, 3472), new RSTile(3462, 3470),
  24.             new RSTile(3459, 3469), new RSTile(3457, 3467),
  25.             new RSTile(3454, 3467), new RSTile(3451, 3466),
  26.             new RSTile(3448, 3465), new RSTile(3446, 3463),
  27.             new RSTile(3444, 3461), new RSTile(3444, 3458),
  28.             new RSTile(3443, 3458) };
  29.         RSTile PathToDoor[] = { new RSTile(3217, 3219), new RSTile(3223, 3219),
  30.             new RSTile(3230, 3219), new RSTile(3232, 3215),
  31.             new RSTile(3236, 3211), new RSTile(3241, 3207),
  32.             new RSTile(3243, 3207) };
  33.     RSTile[] barToBank = { new RSTile(3494, 3475), new RSTile(3494, 3479),
  34.             new RSTile(3497, 3480), new RSTile(3500, 3480),
  35.             new RSTile(3503, 3480), new RSTile(3506, 3480),
  36.             new RSTile(3510, 3480), new RSTile(3512, 3480),
  37.             new RSTile(3512, 3478) };
  38.     RSTile teletoChurch[] = { new RSTile(3217, 3219),
  39.             new RSTile(3223, 3219), new RSTile(3230, 3219),
  40.             new RSTile(3232, 3215), new RSTile(3236, 3211),
  41.             new RSTile(3241, 3207), new RSTile(3243, 3207) };
  42.    
  43.     RSTile gateToFungus =  new RSTile(3436, 3453);
  44.    
  45.     public int[] gate = {3506, 3507};
  46.     public int fungusLog = 3509;
  47.     public int log = 3508;
  48.     public int fungusID = 2383;
  49.     int k;
  50.     int w;
  51.    
  52.     RSArea atBank = new RSArea(3512, 3483, 3511, 3477);//NE SW
  53.     RSArea atGate = new RSArea(3445, 3459, 3442, 3458);//NE SW
  54.     RSArea atPastGate = new RSArea(3444, 3457, 3442, 3456);//NE SW
  55.     RSArea atFungusLog = new RSArea(3436, 3453, 3436, 3453);//NE SW
  56.    
  57.    
  58.     public int nextenergy;
  59.  
  60.     @Override
  61.     public void onRepaint(Graphics arg0) {
  62.         // TODO Auto-generated method stub
  63.        
  64.     }
  65.    
  66.     public enum State {
  67.         walkToGate, openGate, walkToFungus, bloom, pickFungus, toBank, atBank
  68.     }
  69.    
  70.     private State getState() {
  71.         if (!inventory.isFull()) {
  72.             if (atLocation()) {
  73.                 if (logPresent()) {
  74.                     return State.pickFungus;
  75.                 } else {
  76.                     return State.bloom;
  77.                 }
  78.             } else {
  79.                 if (atGate(false)) {
  80.                     return State.openGate;
  81.                 }
  82.                 return State.walkToFungus;
  83.             }
  84.         } else {
  85.             if (atBank()) {
  86.                 if (atGate(true)) {
  87.                     return State.openGate;
  88.                 }
  89.                 return State.toBank;
  90.             } else {
  91.                 return State.atBank;
  92.             }
  93.         }
  94.     }
  95.    
  96.     private boolean atBank() {
  97.         // TODO Auto-generated method stub
  98.         return false;
  99.     }
  100.  
  101.     /**
  102.      * Determines if we are at the gate or not.
  103.      *
  104.      * @param toBank true if direction is to bank
  105.      * @return true if at gate, false if not
  106.      */
  107.     private boolean atGate(final boolean toBank) {
  108.         if (toBank) {
  109.             if (getMyPlayer().getLocation().getY() > 3458) {
  110.                 RSObject g = objects.getNearest(gate);
  111.                 if (g != null) {  
  112.                     return calc.distanceTo(g) < 6;
  113.                 }
  114.             }
  115.         } else {
  116.             if (getMyPlayer().getLocation().getY() >= 3458) {
  117.                 RSObject g = objects.getNearest(gate);
  118.                 if (g != null) {  
  119.                     return calc.distanceTo(g) < 6;
  120.                 }
  121.             }
  122.         }
  123.         return false;
  124.     }
  125.  
  126.     private boolean logPresent() {
  127.         return objects.getNearest(fungusLog) != null;
  128.     }
  129.        
  130.     private boolean atLocation() {
  131.         return atFungusLog.contains(getMyPlayer().getLocation());
  132.     }
  133.  
  134.    
  135.     private boolean walkThePath(RSTile[] path){
  136.         int w = random(4,6);
  137.         int k = random(2,4);
  138.         int b = k;
  139.         int t = w;
  140.         boolean D=false;
  141.         try{
  142.             RSTilePath pathToWalk = walking.newTilePath(path);
  143.             RSTile next = pathToWalk.getNext();
  144.             RSTile start = pathToWalk.getStart();
  145.             if ((walking.getDestination() == null||calc.distanceTo(walking.getDestination()) < t ||calc.distanceBetween(next,walking.getDestination()) > b)) {
  146.                 if(!walking.walkTileMM(next)){
  147.                     if(walking.walkTileMM(start)){
  148.                         sleep(412,565);
  149.                         D=true;
  150.                     }else{
  151.                         walkToTile(walking.getClosestTileOnMap(next));
  152.                         sleep(random(1000,2000));
  153.                     }
  154.                 }else{
  155.                     sleep(299,565);
  156.                     D=true;
  157.                 }
  158.             }
  159.             return D;
  160.         }catch(Exception e ){ log("Caught a Exception in pathToWalk. Saved the script from stopping!"); sleep(554,789); }
  161.         return D;
  162.     }
  163.    
  164.     private boolean walkToTile(RSTile tile){
  165.         int q = k;
  166.         int i = w;
  167.         boolean D = false;
  168.         try{
  169.             if ((walking.getDestination() == null||(calc.distanceTo(walking.getDestination()) < q &&calc.distanceBetween(tile,walking.getDestination()) > i))) {
  170.                 if(calc.tileOnScreen(tile)){
  171.                     if(walking.walkTileOnScreen(tile))
  172.                         D = true;
  173.                 }else if(calc.tileOnMap(tile)){
  174.                     if(walking.walkTileMM(tile))
  175.                         D = true;
  176.                 }else{
  177.                     if(walkToTile(walking.getClosestTileOnMap(tile)))
  178.                         D = true;
  179.                 }
  180.                 sleep(random(1000,2000));
  181.             }
  182.         return D;
  183.         }catch(Exception e){ log("Caught an Exception in walkToTile. Saved the script from stopping!"); sleep(554,789); }
  184.         return D;
  185.     }
  186.    
  187.  
  188.     public int loop() {
  189.         switch(getState()) {
  190.         case walkToGate:
  191.             walkThePath(bankToGate);
  192.             break;
  193.         case openGate:
  194.             objects.getNearest(gate).doAction("Open");
  195.             break;
  196.            
  197.         case walkToFungus:
  198.             walking.walkTileMM(gateToFungus, 0, 0);
  199.             break;
  200.  
  201.         case bloom:
  202.             game.openTab(5);
  203.             sleep(100);
  204.             interfaces.get(387).getComponent(17).doAction("Bloom");
  205.             sleep(2600);
  206.        
  207.             break;
  208.  
  209.         case pickFungus:
  210.             objects.getNearest(fungusLog).doAction(
  211.                     "Pick Fungi");
  212.             break;
  213.                
  214.     case waiting:
  215.         sleep(random(300,600));
  216.         break;
  217.     }
  218.         return 590;
  219.     }
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement