Cook.java (More locations can easily added with this setup)
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
public enum Cook {
VARROCK_EAST(new Position(3253, 3420, 0), new Position(3238, 3409, 0), new Area(3250, 3424, 3257, 3416), new Area(3235, 3416, 3241, 3402), new Area(3232, 3432, 3263, 3396)),
FALADOR(new Position(3012, 3355, 0), new Position(2989, 3365, 0), new Area(3009, 3358, 3021, 3353), new Area(2988, 3367, 2991, 3363), new Area(2969, 3379, 3022, 3352)),
;
private Position bankTile, entityTile;
private Area bankZone, cookZone, pathZone;
Cook(Position bankPos, Position entityPos, Area bankArea, Area cookArea, Area pathArea) {
this.bankTile = bankPos;
this.entityTile = entityPos;
this.bankZone = bankArea;
this.cookZone = cookArea;
this.pathZone = pathArea;
}
public Position getBankTile() {
return bankTile;
}
public Position getEntityTile() {
return entityTile;
}
public Area getBankZone() {
return bankZone;
}
public Area getCookZone() {
return cookZone;
}
public Area getPathZone() {
return pathZone;
}
}
Supply.java (More Supply types can be added using this setup )
public enum Supply {
RAW_SHRIMP("Raw shrimps","Shrimps"),
RAW_KARAMBWANJI("Raw karambwanji", "Karambwanji"),
RAW_SARDINE("Raw sardine", "Sardine"),
;
private String raw, cooked;
Supply(String raw, String cooked) {
this.raw = raw;
this.cooked = cooked;
}
public String getRaw() {
return raw;
}
public String getCooked() {
return cooked;
}
}
Sample Script : skeleton.java (Not the best but it gets the job done. Enjoy )
*Note: Code may not be correctly aligned thanks to the code button *
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.webwalk.INodeRouteFinder;
import org.osbot.rs07.event.WebWalkEvent;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.Condition;
import org.osbot.rs07.utility.ConditionalSleep;
import java.awt.*;
@ScriptManifest(name = "Script name here", author = "Your name here", version = 1.0, info = "About your script", logo = "")
public class Skeleton extends Script {
//Declare your variables here
private INodeRouteFinder finder;
private Area bankZone, cookZone, pathZone;
private Position bankTile, entityTile;
private String rawFood, cookedFood;
@Override
public void onStart() {
//Code here will execute before the loop is started
finder = INodeRouteFinder.createAdvanced(); //Create an advanced IRF to enable Osbot's human like webwalking paths. This will be used later
loadCookingPrepArea(Cook.VARROCK_EAST);
log(Cook.VARROCK_EAST);
loadCookingSupplies(Supply.RAW_SHRIMP);
log(Supply.RAW_SHRIMP);
}
@Override
public void onExit() {
//Code here will execute after the script ends
log("Script ended! Please leave feedback on the forums");
}
@Override
public int onLoop() throws InterruptedException {
if (bankZone.contains(myPlayer()) && (getInventory().contains(cookedFood) || getInventory().isEmpty())){
log("In bank zone");
if (!getBank().isOpen()){
getBank().open();
new ConditionalSleep(2400, random(600, 1200)) {
@Override
public boolean condition() throws InterruptedException {
return getBank().isOpen();
}
}.sleep();
} else {
if (getBank().depositAll()){
if (getBank().contains(rawFood)){
getBank().withdrawAll(rawFood);
new ConditionalSleep(3000, random(600, 1200)) {
@Override
public boolean condition() throws InterruptedException {
return getInventory().contains(rawFood);
}
}.sleep();
} else {
stop(false);
log("No supplies left..please stock up!");
}
}
}
}
if (!bankZone.contains(myPlayer()) && pathZone.contains(myPlayer()) && getInventory().contains(cookedFood) && !getInventory().contains(rawFood)){
log("In path zone");
WebWalkEvent toBankArea = new WebWalkEvent(finder, bankTile);
toBankArea.setBreakCondition(new Condition() {
@Override
public boolean evaluate() {
return bankZone.contains(myPlayer());
}
});
execute(toBankArea);
} else if (!cookZone.contains(myPlayer()) && pathZone.contains(myPlayer()) && getInventory().contains(rawFood) && !getInventory().contains(cookedFood)){
WebWalkEvent toCookPrepArea = new WebWalkEvent(finder, entityTile);
toCookPrepArea.setBreakCondition(new Condition() {
@Override
public boolean evaluate() {
return cookZone.contains(myPlayer());
}
});
execute(toCookPrepArea);
}
if (cookZone.contains(myPlayer())){
RS2Widget optionMenu = getWidgets().get(307, 2);
log("In cook zone");
if (!myPlayer().isAnimating()) {
if (getInventory().contains(rawFood)) {
RS2Object cook = getObjects().closest(rs2Object -> rs2Object.getName().equals("Range") && cookZone.contains(rs2Object));
if (cook != null) {
if (!getInventory().isItemSelected() && optionMenu == null) {
if (getInventory().interact("Use", rawFood)) {
new ConditionalSleep(3000, random(600, 900)) {
@Override
public boolean condition() throws InterruptedException {
return getInventory().isItemSelected();
}
}.sleep();
}
} else {
if (optionMenu != null){
if (optionMenu.isVisible()) {
if (optionMenu.interact("Cook All")) {
new ConditionalSleep(4000) {
@Override
public boolean condition() throws InterruptedException {
return myPlayer().isAnimating();
}
}.sleep();
}
}
} else {
if (cook.interact("Use")) {
new ConditionalSleep(3000) {
@Override
public boolean condition() throws InterruptedException {
return optionMenu != null;
}
}.sleep();
}
}
}
}
}
} else {
log("Sleeping");
sleep(1200);
}
}
return 600; //The amount of time in milliseconds before the loop starts over (600 ms is a basic game tick but it is best to randomize your ms)
}
@Override
public void onPaint(Graphics2D g) {
//This is where you will put your code for paint(s)
//For a great example on using the painter, please follow Explv's Paint tutorial on Osbot. I will link it at the end.
}
public void loadCookingPrepArea(Cook mode){
this.bankZone = mode.getBankZone();
this.cookZone = mode.getCookZone();
this.pathZone = mode.getPathZone();
this.bankTile = mode.getBankTile();
this.entityTile = mode.getEntityTile();
}
public void loadCookingSupplies(Supply mode){
this.rawFood = mode.getRaw();
this.cookedFood = mode.getCooked();
}
}