Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package testground;
- //import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import org.osbot.rs07.api.Inventory;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.model.Entity;
- //import org.osbot.rs07.api.map.Position;
- import org.osbot.rs07.api.model.GroundItem;
- import org.osbot.rs07.api.model.Item;
- import org.osbot.rs07.api.model.NPC;
- import org.osbot.rs07.api.model.Player;
- import org.osbot.rs07.api.ui.Skill;
- import org.osbot.rs07.script.MethodProvider;
- public class Tasks extends MethodProvider{
- //returns your HP Percentage
- public int getHpPercent() {
- double staticHP = getSkills().getStatic(Skill.HITPOINTS);
- double dynamicHP = getSkills().getDynamic(Skill.HITPOINTS);
- int hpPercent = (int)(100*(dynamicHP/staticHP));
- //log("Your HP Percent is " + hpPercent);
- return hpPercent;
- }
- //returns you current HP
- public int getHP() {
- int dynamicHP = getSkills().getDynamic(Skill.HITPOINTS);
- //log("Your Current HP is " + dynamicHP);
- return dynamicHP;
- }
- //returns your max HP
- public int maxHP() {
- int staticHP = getSkills().getStatic(Skill.HITPOINTS);
- //log("Your Current HP is " + staticHP);
- return staticHP;
- }
- // Tells if you need to Eat Food
- public boolean needToEat(String Food_Type) {
- if (getHP() < maxHP() - (foodRestore(Food_Type) + random(1,4))) {
- return true;
- }else {;
- return false;
- }
- }
- //gets an array of items in inventory printed to log
- public void itemName() {
- Item[] item = getInventory().getItems();
- int itemLength = item.length;
- //look at each item in the list, getName and getID
- for (int i=0; i < itemLength; i++) {
- String itemName = item[i].getName();
- int itemID = item[i].getId();
- log("Your number " + i+ "item is " + itemName);
- log("It's ID is " + itemID);
- }
- return;
- }
- //Handles eating
- public void eatFood(String Food_Type) throws InterruptedException{
- Inventory inven = getInventory();
- if(isUnNoted(Food_Type) == true){
- if (getHP() < maxHP() - (foodRestore(Food_Type) + random(1,4))
- ||getHpPercent() < random(45,65) ) {
- if(inven.getSelectedItemName() == null) {
- int foodID = inven.getItem(Food_Type).getUnnotedId();
- inven.getItem(foodID).interact("Eat");
- log("That was a tasty " + Food_Type);
- sleep(random(200,400));
- }else {
- inven.deselectItem();
- }
- }else {
- log("You don't need to eat");
- }
- }else {
- log("You're out of Food");
- }
- }
- //Takes in your Food_Type as a string and returns how much it heals
- private int foodRestore(String Food_Type) {
- String[] three = {"Shrimps","Cooked chicken","Cooked meat", "Bread"}; // index 0
- String[] seven = {"Cod","Trout"}; // 1
- String[] eight = {"Pike"}; // 2
- String[] nine = {"Salmon"}; // 3
- String[] ten = {"Tuna"}; // 4
- String[] eleven = {"Jug of wine","Rainbow fish", "Stew",
- "Summer pie","Half a sumer pie"}; // 5
- String[] twelve = {"Lobster"}; // 6
- String[] thirteen = {"Bass"}; // 7
- String[] fourteen = {"Swordfish","Potato with butter"}; // 8
- String[] fifteen = {}; // 9
- String[] sixteen = {"Monkfish"}; // 10
- String[] seventeen = {}; // 11
- String[] eighteen = {"Cooked karambwan"}; // 12
- String[] nineteen = {"Curry","Ugthanki kebab"}; // 13
- String[] twenty = {"Shark","Mushroom potato"}; // 14
- if(Arrays.asList(twenty).contains(Food_Type)) {
- //log("Your food will heal 20");
- return 20;
- }
- else if(Arrays.asList(twelve).contains(Food_Type)) {
- //log("Your food will heal 12");
- return 12;
- }
- else if(Arrays.asList(sixteen).contains(Food_Type)) {
- //log("Your food will heal 16");
- return 16;
- }
- else if(Arrays.asList(fourteen).contains(Food_Type)) {
- //log("Your food will heal 14");
- return 14;
- }
- else if(Arrays.asList(eighteen).contains(Food_Type)) {
- //log("Your food will heal 18");
- return 18;
- }
- else if(Arrays.asList(thirteen).contains(Food_Type)) {
- //log("Your food will heal 13");
- return 13;
- }
- else if(Arrays.asList(three).contains(Food_Type)) {
- //log("Your food will heal 3");
- return 3;
- }
- else if(Arrays.asList(ten).contains(Food_Type)) {
- //log("Your food will heal 10");
- return 10;
- }
- else if(Arrays.asList(seven).contains(Food_Type)) {
- //log("Your food will heal 7");
- return 7;
- }
- else if(Arrays.asList(eight).contains(Food_Type)) {
- //log("Your food will heal 8");
- return 8;
- }
- else if(Arrays.asList(nine).contains(Food_Type)) {
- //log("Your food will heal 9");
- return 9;
- }
- else if(Arrays.asList(eleven).contains(Food_Type)) {
- //log("Your food will heal 11");
- return 11;
- }
- else if(Arrays.asList(nineteen).contains(Food_Type)) {
- //log("Your food will heal 19");
- return 19;
- }
- else if(Arrays.asList(fifteen).contains(Food_Type)) {
- //log("Your food will heal 15");
- return 15;
- }
- else if(Arrays.asList(seventeen).contains(Food_Type)) {
- //log("Your food will heal 17");
- return 17;
- }else {
- int staticHP = getSkills().getStatic(Skill.HITPOINTS);
- log("Your Food_Type was not found");
- return staticHP + 100;
- }
- }
- //Checks to see if inventory contains un-noted item
- public boolean isUnNoted(String Item_Name) {
- Inventory inven = getInventory();
- int unnotedID;
- if (inven.contains(Item_Name)){
- unnotedID = inven.getItem(Item_Name).getUnnotedId();
- //log(unnotedID);
- if (inven.contains(unnotedID)) {
- //log(Item_Name + " is in inventory and not all are noted");
- return true;
- }else {
- //log(Item_Name + " is in inventory and all is noted");
- return false;
- }
- }else {
- //log("Item is not in your inventory");
- return false;
- }
- }
- //Checks to see if something can be attacked
- //PROBABLY USELESS
- public boolean canAttack(String Target_Name,
- Area Target_Area) {
- NPC target;
- List<NPC> targetList;
- final Area TARGET_AREA = Target_Area;
- int count = 0;
- targetList = getNpcs().getAll();
- for (int i=0; i < targetList.size(); i++) {
- if (targetList.get(i).getName().equals(Target_Name)
- && TARGET_AREA.contains(targetList.get(i))
- && !targetList.get(i).isHitBarVisible()
- && !targetList.get(i).isUnderAttack()
- && targetList.get(i).getHealthPercent() > 0) {
- target = targetList.get(i);
- log(target + " " + i + " has been acquired.");
- count++;
- }
- }
- if (count > 0) {
- return true;
- } else {
- return false;
- }
- }
- //Checks for and Attacks best Targetable NPC
- @SuppressWarnings("unchecked")
- public void attackBestTargetableNPC(String Target_Name,
- Area Target_Area) throws InterruptedException{
- NPC target;
- Player player = myPlayer();
- //List<NPC> targetList;
- //List<NPC> attackableTargets = new ArrayList<NPC>();
- final Area TARGET_AREA = Target_Area;
- if (!TARGET_AREA.contains(player)) {
- getWalking().webWalk(TARGET_AREA);
- }
- if (!player.isInteracting(player.getInteracting())
- && !player.isMoving()) {
- target = npcs.getAll().stream().filter(n -> n.getName().equals(Target_Name)
- && TARGET_AREA.contains(n) && !n.isHitBarVisible() && !n.isUnderAttack()
- && n.getHealthPercent() > 0).findFirst().get();
- } else {
- target = npcs.closest(n -> n.getName().equals(Target_Name)
- && player.isInteracting(n));
- }
- if(target != null && target.isVisible()) {
- if (!player.isAnimating() && !player.isMoving()
- && !player.isUnderAttack()) {
- target.interact("Attack");
- sleep(random(1000,1500));
- }
- } else {
- getCamera().toEntity(target);
- }
- }
- //Does Loot Exist?
- public boolean lootExists(String Item_Name, Area Target_Area) {
- final Area TARGET_AREA = Target_Area;
- Player player = myPlayer();
- Area playerArea = player.getArea(3);
- @SuppressWarnings("unchecked")
- GroundItem loot = groundItems.closest(l -> l.getName().equals(Item_Name)
- && TARGET_AREA.contains(l) && playerArea.contains(l));
- if(loot != null && loot.exists()) {
- return true;
- } else {
- return false;
- }
- }
- //Looting
- public void lootClosest(String Item_Name,
- Area Target_Area) throws InterruptedException{
- Player player = myPlayer();
- Inventory inven = getInventory();
- final Area TARGET_AREA = Target_Area;
- Area playerArea = player.getArea(7);
- @SuppressWarnings("unchecked")
- GroundItem loot = groundItems.closest(l -> l.getName().equals(Item_Name) && playerArea.contains(l));
- if(!inven.isFull() && TARGET_AREA.contains(player)) {
- if (loot != null && loot.exists() &&loot.isVisible()) {
- loot.interact("Take");
- sleep(random(500,1000));
- }
- } else getCamera().toEntity(loot);
- }
- //Do Banking
- public void bankItems(Area Target_Bank, int Bank_Booth_ID, String Food_Type, int Food_Amount) throws InterruptedException {
- Player player = myPlayer();
- Entity bankbooth = objects.closest(Bank_Booth_ID);
- if (Target_Bank.contains(player)) {
- if(bank.isOpen()) {
- sleep(3000);
- bank.depositAll();
- sleep(3000);
- bank.depositAll();
- sleep (3000);
- bank.withdraw(Food_Type, Food_Amount);
- } else if (bankbooth != null) {
- if(bankbooth.isVisible()) {
- bankbooth.interact("Bank");
- sleep (3000);
- bank.depositAll();
- sleep (3000);
- bank.depositAll();
- sleep (3000);
- bank.withdraw(Food_Type, Food_Amount);
- } else {
- getCamera().toEntity(bankbooth);
- bankbooth.interact("Bank");
- sleep (3000);
- bank.depositAll();
- sleep (3000);
- bank.depositAll();
- sleep (3000);
- bank.withdraw(Food_Type, Food_Amount);
- }
- } else {
- getWalking().webWalk(Target_Bank);
- }
- }
- }
- // Is player in Specified Area?
- public boolean inTargetArea(Area Target_Area){
- Player player = myPlayer();
- if (Target_Area.contains(player)) {
- return true;
- }else {
- return false;
- }
- }
- //Go to Specified Area
- public void goToTargetArea(Area Target_Area) {
- if(!inTargetArea(Target_Area)) {
- getWalking().webWalk(Target_Area);
- } else {
- log("You're already in the right area");
- }
- }
- public void dropItem(String Item_Name) throws InterruptedException{
- Inventory inven = getInventory();
- if(inven.getSelectedItemName() == null) {
- int foodID = inven.getItem(Item_Name).getUnnotedId();
- inven.getItem(foodID).interact("Drop");
- sleep(random(200,400));
- }else {
- inven.deselectItem();
- }
- }
- }
Add Comment
Please, Sign In to add comment