I recently started botting a few days ago and wanted to get into coding scripts. my plan for this one is to wind strike to level 11 confuse to level 33 then alc. everything works except the last part where I walk to the demon on top of the wizards tower and I'm not sure why, I have been trying to fix it for about an hour but I cant find anything wrong with it. sorry for sloppy code this is my first time using java
package core;
import org.osbot.rs07.api.Magic;
import org.osbot.rs07.api.Skills;
import java.util.LinkedHashMap;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.InteractableObject;
import java.util.stream.Stream;
import java.util.Map;
import org.osbot.rs07.script.MethodProvider;
@ScriptManifest(author = "jason", info = "Casts magic on the demon", name = "Demon_splasher", version = 0, logo = "")
public class demon_splash extends Script { private static final String DEMON_NAME = "Lesser demon";
Position pos = new Position(3110,3161,2);
Position runeshoppos = new Position(3252,3401,0);
Position bankpos = new Position(3253,3420,0);
@Override
public void onStart() {
log("Script started");
}
private void attackdemon() throws InterruptedException {
}
private void withdrawgold() throws InterruptedException {
NPC banker = getNpcs().closest("banker");
if (banker != null && banker.interact("bank")) {
sleep(random(2000, 4000));
if(getBank().isOpen()) {
getBank().withdraw("coins", 20000);
}
getKeyboard().pressKey(KeyEvent.VK_ESCAPE);
sleep(random(2000, 4000));
}
}
private void interactWithShopkeeperAndBuymindRunes() throws InterruptedException {
// Interact with the shopkeeper (replace "Aubury" with the actual NPC name)
NPC aubury = getNpcs().closest("Aubury");
if (aubury != null && aubury.interact("Trade")) {
sleep(random(2000, 4000));
if(getStore().isOpen()) {
getStore().buy("mind rune", 1000);
}
getKeyboard().pressKey(KeyEvent.VK_ESCAPE);
sleep(random(2000, 4000));
}
}
private void interactWithShopkeeperAndBuyairRunes() throws InterruptedException {
// Interact with the shopkeeper (replace "Aubury" with the actual NPC name)
NPC aubury = getNpcs().closest("Aubury");
if (aubury != null && aubury.interact("Trade")) {
sleep(random(2000, 4000));
if(getStore().isOpen()) {
getStore().buy("air rune", 1000);
}
getKeyboard().pressKey(KeyEvent.VK_ESCAPE);
sleep(random(2000, 4000));
}
}
///////////////////////WALK_TO_VARROCK_MAGIC_SHOP///////////
private boolean should_Walk_To_magic_shop() {
Position currentPlayerTile = myPosition();
return !pos.equals(currentPlayerTile);
}
private void walk_To_magicshop(Position runeshoppos) throws InterruptedException {
if (getWalking().webWalk(runeshoppos)) {
new ConditionalSleep(2000, 5000) {
@Override
public boolean condition() throws InterruptedException {
return !runeshoppos.equals(myPosition());
}
}.sleep();
}
}
///////////////////////WALK_TO_VARROCK_MAGIC_SHOP//////////////////////^^^
////////////////////////WALK TO DEMON////////////////////////////
private boolean shouldWalkToPos() {
Position currentPlayerTile = myPosition();
return !pos.equals(currentPlayerTile);
}
private void walkToPos(Position pos) throws InterruptedException {
if (getWalking().webWalk(pos)) {
new ConditionalSleep(2000, 5000) {
@Override
public boolean condition() throws InterruptedException {
return !pos.equals(myPosition());
}
}.sleep();
}
}
////////////////////////////WALK TO DEMON///////////////////////////^^^
////////////////////////WALK TO BANK////////////////////////////
private boolean shouldwalkbank() {
Position currentPlayerTile = myPosition();
return !pos.equals(currentPlayerTile);
}
private void walkTobankPos(Position bankpos) throws InterruptedException {
if (getWalking().webWalk(bankpos)) {
new ConditionalSleep(2000, 5000) {
@Override
public boolean condition() throws InterruptedException {
return !bankpos.equals(myPosition());
}
}.sleep();
}
}
////////////////////////////WALK TO BANK///////////////////////////^^^
@Override
public int onLoop() throws InterruptedException {
int Magic_Level = getSkills().getDynamic(Skill.MAGIC);
switch (Magic_Level) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
if (getInventory().getAmount("airrune")>=1000 && getInventory().getAmount("mindrune")>=1000){
if (shouldWalkToPos()) {
walkToPos(pos);
}
}else {
if (getInventory().getAmount("airrune") == 0){
if (getInventory().getAmount("coins")<20000){
if (shouldwalkbank()) {
walkTobankPos(bankpos);
withdrawgold();
}
}
if (should_Walk_To_magic_shop()) {
walk_To_magicshop(runeshoppos);
}
interactWithShopkeeperAndBuyairRunes();
} else if (getInventory().getAmount("mindrune")==0) {
if (getInventory().getAmount("coins")<20000){
if (shouldwalkbank()) {
walkTobankPos(bankpos);
withdrawgold();
}
}
if (should_Walk_To_magic_shop()) {
walk_To_magicshop(runeshoppos);
}
interactWithShopkeeperAndBuymindRunes();
}
}
break;
}
return 300;
}
@Override
public void onExit() {
log("Thanks using demon_splasher!");
}
@Override
public void onPaint(Graphics2D g) {
}
}