Hi
I just made my first script, I used it for like an hour or two with breaks, next day it was banned.
I wanted to ask what are the most obvious things I screwed up in the script.
For context, the account was created ~ 2years ago, it was about 300 total and f2p, I did play manually on it till this point (2 years ago) It was fishing trouts in lumbridge. I used built in breaks ~ 15-50 min of botting with 5-20 min breaks.
Used stealth client, on mac with java17 in case it makes any difference
My thoughts are that I probably should avoid some parts of api, and somehow implement my own mouse movement patterns, but dunno whether it is valid ideas.
Let's ignore the code quality I am not java dev ;-;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.model.NPC;
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.util.Arrays;
import java.util.stream.IntStream;
@ScriptManifest(author = "Nzb", info = "Lumbridge trout fisher", logo = "", name = "Lumbridge Fisher", version = 1)
public class Fisher extends Script {
static final String[] SUPPORTED_FISHES = {"Raw trout", "Raw salmon"};
private final Area fishArea = new Area(3238, 3255, 3242, 3235);
@Override
public void onStart() throws InterruptedException {
checkPreconditions();
setUpInventory();
log(getInventory().getSlotBoundingBox(0));
}
@Override
public int onLoop() throws InterruptedException {
if (!fishArea.contains(myPlayer())) {
walkToFishingSpot();
} else {
fishTrouts();
}
return 0;
}
private void walkToFishingSpot() {
if (getWalking().webWalk(fishArea)) {
new ConditionalSleep(random(1542, 2534), random(5129, 7412)) {
@Override
public boolean condition() {
return fishArea.contains(myPlayer());
}
}.sleep();
}
}
private void fishTrouts() throws InterruptedException {
if (getInventory().isFull()) {
sleep(random(500, 6000));
dropFish();
}
if (!myPlayer().isAnimating()) {
NPC fishingSpot = getNpcs().closest("Rod Fishing Spot");
fishingSpot.interact("lure");
getMouse().moveOutsideScreen();
sleep(random(2421, 6521));
}
}
private void dropFish() throws InterruptedException {
int[] slotsWithFish = IntStream.rangeClosed(0, 25).toArray();
if (getSettings().isShiftDropActive()) getKeyboard().pressKey(16);
for (int slotId : slotsWithFish) {
log(slotId);
Item item = getInventory().getItemInSlot(slotId);
if (item != null) {
log(item.getName());
if (Arrays.asList(SUPPORTED_FISHES).contains(item.getName())) {
if (getSettings().isShiftDropActive()) {
item.interact();
}
}
sleep(random(1052, 1370));
}
}
if (getSettings().isShiftDropActive()) getKeyboard().releaseKey(16);
}
private void checkPreconditions() {
if (!getInventory().containsAll("Feather", "Fly fishing rod")) {
stop();
}
}
private void setUpInventory() {
int featherPosition = getInventory().getSlot("Feather");
int rodPosition = getInventory().getSlot("Fly fishing rod");
if (featherPosition != 26 & rodPosition != 27) {
moveItemInSlot(featherPosition, 26);
moveItemInSlot(rodPosition, 27);
}
}
private void moveItemInSlot(int startSlot, final int endSlot) {
if (getInventory().isItemSelected()) {
getInventory().deselectItem();
}
getMouse().continualClick(getInventory().getMouseDestination(startSlot), new Condition() {
@Override
public boolean evaluate() {
getMouse().move(getInventory().getMouseDestination(endSlot), true);
return getInventory().getMouseDestination(endSlot).getBoundingBox().contains(getMouse().getPosition());
}
});
}
}