I can write to you, know that the problem exists, but I can not own power or correction. I would like to write in a small area to move the script will not be attacked when there is no cow to walk around to find the target range set me please help me modify
Thank you
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
@ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0, logo = "")
public class main extends Script {
@Override
public void onStart() {
log("Welcome to Simple Tea Thiever by Apaec.");
log("If you experience any issues while running this script please report them to me on the forums.");
log("Enjoy the script, gain some thieving levels!.");
}
private enum State {
WALK, WAIT
};
private State getState() {
Area COWPEN = new Area(422, 62,51, 332);
NPC cow = npcs.closest("Cow");
if(cow.isUnderAttack() && cow.getHealth()<8 )
return State.WALK;
return State.WAIT;
}
@Override
public int onLoop() throws InterruptedException {
switch (getState()) {
case WALK:
NPC cow = npcs.closest("Cow");
if(cow.isUnderAttack() )
{
localWalker.walk(COWPEN.getRandomPosition(0));//will get a random area in the cow pen to run off to, then will kill cows that aren't under attack, or keep doing this until it finds one.
//}
}
break;
case WAIT:
sleep(random(500, 700));
break;
}
return random(200, 300);
}
@Override
public void onExit() {
log("Thanks for running my Tea Thiever!");
}
@Override
public void onPaint(Graphics2D g) {
}
}