Advertisement
Guest User

Combat Tasks

a guest
Mar 25th, 2020
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.86 KB | None | 0 0
  1. package testground;
  2.  
  3. import org.osbot.rs07.api.Inventory;
  4. import org.osbot.rs07.api.map.Area;
  5. import org.osbot.rs07.api.model.Player;
  6. import org.osbot.rs07.script.Script;
  7. import org.osbot.rs07.script.ScriptManifest;
  8. import org.osbot.rs07.api.map.constants.Banks;
  9.  
  10. @ScriptManifest(author = "LKSim", info = "..", logo = "",
  11. name = "KING's perfect Frogs", version = 1.0)
  12.  
  13. public class Executable extends Script{
  14.    
  15.     private Tasks bot = new Tasks();
  16.     private State currentState = State.IDLE;
  17.     final String Food_Type = "Tuna";
  18.     final int Food_Amount = 5;
  19.     final String Loot_Name = "Big bones"; // Change
  20.    
  21.     //MONSTER NAMES
  22.     final String TARGET_NAME = "Giant frog"; //Change
  23.    
  24.     //BANKS
  25.     final Area DRAYNOR_BANK = new Area (3092,3240,3095,3246);
  26.     final int DRAYNOR_BANK_BOOTH_ID = 10355;
  27.     final Area LUM_UPPER_BANK = Banks.LUMBRIDGE_UPPER;
  28.     final int LUM_UPPER_BANK_BOOTH_ID = 18491;
  29.     final Area TARGET_BANK = LUM_UPPER_BANK; //Change
  30.     final int BANK_BOOTH_ID = LUM_UPPER_BANK_BOOTH_ID; //Change
  31.    
  32.     //MONSTER AREAS
  33.     final Area LUM_CHICKS_NORTH = new Area(3171,3290,3183,3301);
  34.     final Area LUM_COWS_NORTH = new Area(3193,3286,3210,3301);
  35.     final Area LUM_FROGS_SOUTH = new Area(3193,3166,3208,3197);
  36.     final Area TARGET_AREA = LUM_FROGS_SOUTH; //Change
  37.  
  38.     //PAINT
  39.  
  40.    
  41.     @Override
  42.     public void onStart() {
  43.         log("It has begun");
  44.         bot.exchangeContext(getBot());
  45.     }
  46.     @Override
  47.     public void onExit() {
  48.         log("It has ended");
  49.     }
  50.    
  51.     private enum State{
  52.         IDLE, HEAL, BANK, TRAVEL, ATTACK, LOOT
  53.     };
  54.  
  55.     @Override
  56.     public int onLoop() throws InterruptedException {
  57.         //Player player = myPlayer();
  58.         Inventory inven = getInventory();
  59.        
  60.         switch (currentState) {
  61.         case HEAL:
  62.             log("You are currently in the HEAL state");
  63.             bot.eatFood(Food_Type);
  64.             currentState = getState();
  65.             break;
  66.        
  67.         case BANK:
  68.             log("You are in the BANK state");
  69.             bot.goToTargetArea(TARGET_BANK);
  70.             bot.bankItems(TARGET_BANK, BANK_BOOTH_ID, Food_Type, Food_Amount);
  71.             currentState = getState();
  72.             break;
  73.            
  74.         case TRAVEL:
  75.             log("You are currently in the TRAVEL state");
  76.             bot.goToTargetArea(TARGET_AREA);
  77.             currentState = getState();
  78.             break;
  79.        
  80.         case ATTACK:
  81.             log("You are currently in the ATTACK state");
  82.             bot.attackBestTargetableNPC(TARGET_NAME, TARGET_AREA);
  83.             currentState = getState(); 
  84.             break;
  85.            
  86.         case LOOT:
  87.             log("You are currently in the LOOT state");
  88.             if (!inven.isFull()) {
  89.                 bot.lootClosest(Loot_Name, TARGET_AREA);
  90.                 currentState = getState(); 
  91.             } else {
  92.                 currentState = State.ATTACK;
  93.             }
  94.             break;
  95.            
  96.         case IDLE:
  97.             //log("You are currently in the IDLE state");
  98.             currentState = getState();
  99.             break;
  100.         }
  101.         return random(100,200);
  102.     }
  103.  
  104.     private State getState() throws InterruptedException{
  105.         Player player = myPlayer();
  106.         Inventory inven = getInventory();
  107.         if (bot.needToEat(Food_Type) && bot.isUnNoted(Food_Type)) {
  108.             log("You need to heal");
  109.             return State.HEAL;
  110.         } else if (!bot.inTargetArea(TARGET_BANK)
  111.                 && !bot.isUnNoted(Food_Type) && bot.getHpPercent() < 65) {
  112.             log("You need to bank");
  113.             return State.BANK;
  114.         } else if (!bot.inTargetArea(TARGET_AREA) && !bot.needToEat(Food_Type)) {
  115.             log("You are going to travel");
  116.             return State.TRAVEL;
  117.         } else if (bot.inTargetArea(TARGET_AREA)){
  118.             if (!player.isUnderAttack()) {
  119.                 sleep(3000);
  120.                 if (bot.lootExists(Loot_Name,TARGET_AREA)) {
  121.                     return State.LOOT;
  122.                 } else {
  123.                     return State.ATTACK;       
  124.                 }
  125.             } else if (inven.isFull()) {
  126.                 if (inven.contains(Food_Type)) {
  127.                     bot.dropItem(Food_Type);
  128.                     return State.IDLE;
  129.                 } else {
  130.                     //sleep(3000);
  131.                     log("Your Inventory is full, let's bank!");
  132.                     //sleep(3000);
  133.                     return State.BANK;
  134.                 }
  135.             } else if (!inven.isFull() && !player.isUnderAttack()) {
  136.                 return State.LOOT;
  137.             } else {
  138.                 return State.IDLE;
  139.             }
  140.         }else {
  141.             return State.IDLE;
  142.         }  
  143.     }  
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement