Nym Posted April 1, 2017 Posted April 1, 2017 Hey can anyone help me here I made a simple script and when I start to the script it doesnt start. package core; import org.osbot.rs07.api.Objects; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import static core.PestControl.State.*; @ScriptManifest(version = 0, info = "Pest Control :D", logo = "", author = "Nimmogel", name = "Pest Control") public class PestControl extends Script { final State state = getState(); Area onBoatArea = new Area(2637, 2647, 2641, 2641); Area pcArea = new Area(2623, 2622, 2689, 2561); Area killArea = new Area(2627, 2596, 2640, 2587); Area outsideBoat = new Area(2644, 2646, 2644, 2642); String[] pestControlMonsters = {"Brawler","Defiler","Ravager","Shifter","Spinner","Torcher"}; public void onStart() throws InterruptedException { log("Pest Control has started :D"); } public enum State { ATTACK, ONBOAT, BOAT, WALKTOSPOT } private State getState() { if (!pcArea.contains(myPlayer()) && !onBoatArea.contains(myPlayer())) { return BOAT; } if (onBoatArea.contains(myPlayer())) { return ONBOAT; } if (pcArea.contains(myPlayer()) && !killArea.contains(myPlayer())) { return WALKTOSPOT; } if (killArea.contains(myPlayer())) { return ATTACK; } return null; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case ATTACK: NPC monster = npcs.closest(pestControlMonsters); log("atack monsters"); if (monster != null) { if (monster.isVisible()) { if (monster.interact("Attack")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return !myPlayer().isAnimating(); } }.sleep(); } } } break; case ONBOAT: log("onBoat"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return pcArea.contains(myPlayer()); } }.sleep(); break; case BOAT: RS2Object plank = new Objects().closest("Gangplank"); log("boat case"); if (plank != null) { if (plank.isVisible()) { if (plank.interact("Cross")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return onBoatArea.contains(myPlayer()); } }.sleep(); } } } else { getWalking().walk(outsideBoat); sleep(random(650,900)); } break; case WALKTOSPOT: log("walking to kill area"); getWalking().webWalk(killArea); sleep(random(650,900)); break; } return 120; } @Override public void onExit() { log("Thanks for running my Pest Control"); } }
Stimpack Posted April 1, 2017 Posted April 1, 2017 (edited) final State state = getState(); try putting that (getState() part) in onStart also dont make it final Edited April 1, 2017 by Stimpack
Nym Posted April 1, 2017 Author Posted April 1, 2017 (edited) 5 minutes ago, Stimpack said: final State state = getState(); try putting that (getState() part) in onStart also dont make it final oh no, that part is not used, i just forgot to delete it edit - took out now scripts starts but my script doesnt do anything and uses a shit ton of cpu and mem Edited April 1, 2017 by Nimmogel
Booleans YAY Posted April 1, 2017 Posted April 1, 2017 (edited) You should use what I do. private enum BotState { BANKING, LOOTING } private BotState getState() { return getInventory.isFull ? BotState.BANKING : BotState.LOOTING; } then just call the getState() in the switch. Read some of my script releases for demo on this. Becomes a little cleaner and easy to read for everyone. Edited April 1, 2017 by Booleans YAY
Stimpack Posted April 1, 2017 Posted April 1, 2017 last i remember pest control areas change every time u join a game
Reveance Posted April 1, 2017 Posted April 1, 2017 new Objects().closest("Gangplank"); I suppose should be: getObjects().closest("Gangplank");
Nym Posted April 1, 2017 Author Posted April 1, 2017 Found the issue, just simple stuff, used to a differen't api. Sorry and thanks for the help