Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.97 KB | None | 0 0
  1. import org.osbot.rs07.api.Dialogues;
  2. import org.osbot.rs07.api.Inventory;
  3. import org.osbot.rs07.api.Walking;
  4. import org.osbot.rs07.api.map.Area;
  5. import org.osbot.rs07.api.map.Position;
  6. import org.osbot.rs07.api.map.constants.Banks;
  7. import org.osbot.rs07.api.model.NPC;
  8. import org.osbot.rs07.api.model.RS2Object;
  9. import org.osbot.rs07.api.ui.RS2Widget;
  10. import org.osbot.rs07.script.MethodProvider;
  11.  
  12. public class BarbarianActions {
  13.    
  14.     /**
  15.      * Run Method for Barbarian Fishing
  16.      * @param m
  17.      */
  18.      public static void run(MethodProvider m) {
  19.          Inventory inventory = m.getInventory();
  20.          String tool = BarbarianActions.tool();
  21.          
  22.          
  23.              BarbarianActions.Start(m);
  24.              
  25.        
  26.          
  27.          if (m.dialogues.isPendingContinuation()) {
  28.              BarbarianActions.inDialogue(m);
  29.          } else {
  30.              if (!inventory.isFull() && !m.myPlayer().isAnimating() && inventory.contains(tool)) {
  31.                  BarbarianActions.isIdle(m);
  32.              }
  33.              
  34.             if (m.inventory.isFull()) {
  35.                 if (inventory.isFull() && Global.fireEnable == true && inventory.contains("Raw trout", "Raw salmon")) {
  36.                     BarbarianActions.fireEnabled(m);
  37.                 } else {
  38.                 if (Global.bank == true) {
  39.                 BarbarianActions.enableBank(m);;
  40.             } else {
  41.                 if (Global.cooking == false) {
  42.                 BarbarianActions.drop(m);
  43.                 }
  44.             }
  45.             }
  46.          }
  47.         }
  48.          
  49.          
  50.          }
  51.      /**
  52.       * Type of Fishing
  53.       * @return
  54.       */
  55.         public static String type() {
  56.             String fishtype = null;
  57.             if (Global.fishingType == Global.Fishing.NET) {
  58.                 fishtype = "Small Net";
  59.             } else {
  60.                 if (Global.fishingType == Global.Fishing.FROD) {
  61.                     fishtype = "Bait";
  62.                 } else {
  63.                     if (Global.fishingType == Global.Fishing.FFROD) {
  64.                         fishtype = "Lure";
  65.                     }
  66.                 }
  67.                
  68.             }
  69.             return fishtype;
  70.         }
  71.        
  72.         /**
  73.          * Tool used to fish with
  74.          * @return
  75.          */
  76.         public static String tool() {
  77.             String tool = null;
  78.             if (Global.fishingType == Global.Fishing.NET) {
  79.                 tool = "Small fishing Net";
  80.             } else {
  81.                 if (Global.fishingType == Global.Fishing.FROD) {
  82.                     tool = "Fishing rod";
  83.                 } else {
  84.                     if (Global.fishingType == Global.Fishing.FFROD) {
  85.                         tool = "Fly fishing rod";
  86.                     }}}
  87.             return tool;
  88.         }
  89.      
  90.          
  91.      /**
  92.       * fireEnabled Method
  93.       * @param m
  94.       */
  95.      public static void fireEnabled (MethodProvider m) {
  96.          Inventory inventory = m.getInventory();
  97.             RS2Object fire = m.getObjects().closest("Fire");
  98.             RS2Widget w = m.getWidgets().get(270, 14);
  99.            
  100.         if (Global.cooking == true) {
  101.             if (inventory.isFull() && !m.myPlayer().isAnimating()) {
  102.                 BarbarianActions.isIdle(m);
  103.              }
  104.         } else {
  105.            
  106.          if (inventory.isFull()) {
  107.              //if inventory item is selected click on fire
  108.                 if(inventory.isItemSelected() && Global.cooking == false){
  109.                     fire.interact("Use");
  110.                     m.logger.info("Cooking fish");
  111.                    
  112.                 } else {
  113.                    
  114.                     //otherwise click on raw shrimps / raw anchovies
  115.                     inventory.interact("Use", "Raw trout", "Raw salmon");
  116.                 }
  117.              if (w != null) {
  118.                  w.interact();
  119.                  Global.cooking = true;
  120.              }
  121.          }
  122.      }
  123.      }
  124.      
  125.      /**
  126.       * Dropping Method
  127.       * @param m
  128.       */
  129.      public static void drop(MethodProvider m) {
  130.         Inventory inventory = m.getInventory();
  131.         m.bot.getLogger().info("Dropping Fish.");
  132.         if (m.inventory.isFull()) {
  133.         inventory.dropAll("Raw trout", "Raw salmon", "Burnt fish", "Trout", "Salmon");
  134.             }    
  135.         }
  136.      
  137.  
  138.      /**
  139.       * Full inventory Method
  140.       * @param m
  141.       */
  142.       public static void fullInventory(MethodProvider m) {
  143.             Inventory inventory = m.getInventory();
  144.             RS2Object bank = m.getObjects().closest("Bank booth");
  145.             Area b = new Area(3092, 3246, 3097, 3240);
  146.             Walking walking = m.getWalking();
  147.             //if bank is enabled, go to bank and bank
  148.             if (Global.bank == true) {
  149.                 if (m.bank.isOpen() && inventory.isFull()) {
  150.                     m.bank.depositAll("Raw shrimps", "Raw anchovies", "Raw herring", "Raw sardine");   
  151.                 } else {
  152.                     if (!b.contains(m.myPosition())){
  153.                         walking.walk(new Position(3092, 3244, 0));
  154.                     } else {
  155.                         if (bank.hasAction("Bank")) {
  156.                             bank.interact("Bank");
  157.                             m.bot.getLogger().info("Banking");
  158.                         }
  159.                     }
  160.                 }
  161.             }
  162.            
  163.             else {
  164.             //else drop all fish and continue fishing
  165.             m.bot.getLogger().info("Dropping Fish.");
  166.             inventory.dropAll("Burnt shrimp", "Raw shrimps", "Burnt fish", "Shrimps", "Anchovies", "Raw anchovies", "Raw herring", "Raw sardine");
  167.         }
  168.       }
  169.      
  170.       public static void hasTool(MethodProvider m) {
  171.                 String fishtype = BarbarianActions.type();
  172.                 Inventory inventory = m.getInventory();
  173.                 NPC fish = m.getNpcs().closest("Rod Fishing spot");
  174.                
  175.                 if (inventory.isFull()) {
  176.                    
  177.                 } else {
  178.                    
  179.                     fish.interact(fishtype);
  180.                     Global.isFishing = true;
  181.                     m.bot.getLogger().info("Fishing");
  182.                     }
  183.             }
  184.      
  185.       /**
  186.        * In dialogue Method
  187.        * @param m
  188.        */
  189.       public static void inDialogue(MethodProvider m) {
  190.             Dialogues dialogue = m.getDialogues();
  191.                 dialogue.clickContinue();
  192.                 Global.isFishing = false;
  193.                 Global.cooking = false;
  194.                 m.bot.getLogger().info("Continuing Dialogue");
  195.       }
  196.      
  197.      
  198.       /**
  199.        * Idle Method
  200.        * @param m
  201.        */
  202.       public static void isIdle(MethodProvider m) {
  203.           Global.isFishing = false;
  204.           Global.cooking = false;
  205.       }
  206.      
  207.     public static void Start(MethodProvider m) {
  208.             Area fishSpot = new Area(new int[][]{{ 3107, 3436 }, { 3110, 3436 },{ 3110, 3430 },{ 3104, 3426 },{ 3104, 3424 },{ 3102, 3424 },{ 3101, 3424 },{ 3101, 3435 },{ 3101, 3436 }});
  209.             Inventory inventory = m.getInventory();
  210.             Walking walking = m.getWalking();
  211.             String tool = BarbarianActions.tool();
  212.             Area bank = new Area(3090, 3499, 3098, 3488);
  213.    
  214.             if (fishSpot.contains(m.myPosition()) && inventory.isFull() && !inventory.contains("Raw trout") && !inventory.contains("Raw salmon")) {
  215.                 Global.cooking = false;
  216.             }
  217.            
  218.             if (bank.contains(m.myPosition()) &&  inventory.isFull() && inventory.contains(tool) && inventory.contains("Feather") && inventory.contains("Raw salmon") && inventory.contains("Raw trout")) {
  219.                 BarbarianActions.inBank(m);
  220.             } else {
  221.            
  222.             if (fishSpot.contains(m.myPosition()) && inventory.contains(tool) && Global.isFishing == false && inventory.contains("Feather") || fishSpot.contains(m.myPosition()) && inventory.contains(tool) && Global.isFishing == false && inventory.contains("Fishing bait")){
  223.                 BarbarianActions.hasTool(m);
  224.             } else {
  225.        
  226.             if (!inventory.contains(tool)) {
  227.                 walking.webWalk(new Position(3093, 3492, 0));
  228.             } else {
  229.             if (!fishSpot.contains(m.myPosition())) {
  230.                 walking.webWalk(new Position(3107, 3433, 0));
  231.                 }
  232.             }
  233.             }
  234.             }
  235.            
  236.            
  237.            
  238.           }
  239.    
  240.     public static void enableBank(MethodProvider m) {
  241.         Area fishSpot = new Area(new int[][]{{ 3107, 3436 }, { 3110, 3436 },{ 3110, 3430 },{ 3104, 3426 },{ 3104, 3424 },{ 3102, 3424 },{ 3101, 3424 },{ 3101, 3435 },{ 3101, 3436 }});
  242.         Inventory inventory = m.getInventory();
  243.         Walking walking = m.getWalking();
  244.         if (fishSpot.contains(m.myPosition()) && inventory.contains("Raw trout") && inventory.contains("Raw salmon") ) {
  245.             walking.webWalk(new Position(3093, 3493, 0));
  246.         }
  247.     }
  248.    
  249.     public static void inBank(MethodProvider m) {
  250.         Area BANKZ = new Area(3090, 3499, 3098, 3488);
  251.         Inventory inventory = m.getInventory();
  252. //      Walking walking = m.getWalking();
  253. //      String tool = BarbarianActions.tool();
  254.         RS2Object bank = m.getObjects().closest("Bank booth");
  255.        
  256.        
  257.        
  258.             if (m.bank.isOpen() && inventory.isFull()) {
  259.                 m.bank.depositAll("Raw trout", "Raw salmon");  
  260.             } else {
  261.                 if (BANKZ.contains(m.myPosition())){
  262.                     if (bank.hasAction("Bank")) {
  263.                         bank.interact("Bank");
  264.                         m.bot.getLogger().info("Banking");
  265.                     }
  266.                 }
  267.             }
  268.         }
  269.    
  270.     public static void Banking(MethodProvider m) {
  271.         Area fishSpot = new Area(new int[][]{{ 3107, 3436 }, { 3110, 3436 },{ 3110, 3430 },{ 3104, 3426 },{ 3104, 3424 },{ 3102, 3424 },{ 3101, 3424 },{ 3101, 3435 },{ 3101, 3436 }});
  272.         Inventory inventory = m.getInventory();
  273.         Walking walking = m.getWalking();
  274.         String tool = BarbarianActions.tool();
  275.         Area BANK = Banks.EDGEVILLE;
  276.         RS2Object bank = m.getObjects().closest("Bank booth");
  277.        
  278.         if (fishSpot.contains(m.myPosition()) && inventory.contains("Raw trout", "Raw salmon")) {
  279.             walking.walk(new Position(3093, 3493, 0));
  280.         }
  281.        
  282.         if (!inventory.isFull() && inventory.contains(tool) && Global.isFishing == false && inventory.contains("Feather") || !inventory.isFull() && inventory.contains(tool) && Global.isFishing == false && inventory.contains("Fishing bait")){
  283.             walking.webWalk(new Position(3107, 3433, 0));
  284.         } else {
  285.        
  286.         if (inventory.contains(tool) && inventory.isFull()) {
  287.             if (m.bank.isOpen() && inventory.isFull()) {
  288.                 m.bank.depositAll("Raw trout", "Raw salmon");  
  289.             } else {
  290.                 if (!BANK.contains(m.myPosition())){
  291.                     walking.walk(new Position(3093, 3493, 0));
  292.                 } else {
  293.                     if (bank.hasAction("Bank")) {
  294.                         bank.interact("Bank");
  295.                         m.bot.getLogger().info("Banking");
  296.                     }
  297.                 }
  298.             }
  299.         }
  300.     }
  301.  
  302.    
  303.    
  304.    
  305.    
  306.     }
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement