Everything posted by omni4life
-
Issue with localWaler.walkPath
That makes for way cleaner code, thank you . I'm basically entirely new to Java and more or less coding in general so I'm learning as I run here. I think I've implemented what you're suggesting however I'm still having some issues with my walking. I now successfully walk to the bank, however, once I get there it doesn't change state from WALK2BANK to BANK and I'm not entirely sure why. I'm almost certain is has something to do with my bankArea.contains(myPlayer()) however I can't work out what exactly. This is my updated code. Any insight is more than welcome from anyone . Also, apologies for spamming this forum over the last few days. I'm quite eager to learn to script however my lack of background is showing though. 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.model.GroundItem; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(name = "Willow Cutter", author = "Omni", version = 1.0, info = "A simple Willow Cutter for Barbarian Assault", logo = "") public class OmniCutter extends Script { public static String status; private Position[] barbWillows = new Position[] { new Position(2536, 3573, 0), new Position(2522, 3571, 0), new Position(2519, 3581, 0), }; private Position[] bankPos = new Position[] { new Position(2519, 3579, 0), new Position(2527, 3571, 0), new Position(2529, 3571, 0), new Position(2531, 3571, 0), new Position(2533, 3573, 0), new Position(2535, 3574, 0), }; Area bankArea = new Area( new Position[] { new Position(2536, 3573, 0), new Position(2536, 3574, 0), new Position(2535, 3574, 0), new Position(2535, 3573, 0), new Position(2535, 3572, 0), new Position(2536, 3572, 0), }); private int bankChest = 19051; @Override public void onStart() { status = "OmniCutter is beginning."; } private enum State { CUT, BANK, SLEEP, WALK2TREE, WALK2BANK, NESTGRAB }; private State getState() { Entity tree = objects.closest("Willow"); GroundItem nest = groundItems.closest("Birds Nest"); if (inventory.isFull()) { return State.WALK2BANK; } if (myPlayer().isAnimating()) { return State.SLEEP; } if (tree != null && !myPlayer().isAnimating()) { return State.CUT; } if (inventory.isEmptyExcept("Hatchet")) { return State.WALK2TREE; } if (nest != null && nest.exists()) { return State.NESTGRAB; } if (inventory.isFull() && bankArea.contains(myPlayer())) { return State.BANK; } return State.SLEEP; } @Override public void onExit() { log("OmniCutter is exiting. Thank you for running."); } @Override public int onLoop() throws InterruptedException { switch (getState()) { case CUT: Entity tree = objects.closest("Willow"); if (!inventory.isFull() && !myPlayer().isAnimating() && !myPlayer().isMoving()) { camera.toEntity(tree); tree.interact("Chop Down"); status = "Clicking Willow"; sleep(random(2500, 3000)); } break; case BANK: if (inventory.isFull() && bankArea.contains(myPlayer())) { status = "Banking"; Entity chest = objects.closest(true, bankChest); if (!bank.isOpen()) { if (chest != null) { if (chest.isVisible()) { if (!myPlayer().isMoving()) { chest.interact("Use"); sleep(random(1000, 1500)); } } } else { camera.toEntity(chest); } } else if (getInventory().contains( "Bronze axe, Iron axe, Steel axe, Black axe, Mithril axe, Adamant axe, Rune axe, Dragon axe")) { bank.depositAllExcept( "Bronze axe, Iron axe, Steel axe, Black axe, Mithril axe, Adamant axe, Rune axe, Dragon axe"); } else { bank.depositAll(); sleep(random(200, 300)); } } break; case WALK2TREE: status = "Returning to Willows"; localWalker.walkPath(barbWillows); break; case WALK2BANK: status = "Walking to bank"; localWalker.walkPath(bankPos); break; case NESTGRAB: GroundItem nest = groundItems.closest("Birds Nest"); if (nest != null && nest.exists()) { nest.interact("Take"); } break; case SLEEP: status = "Sleeping"; sleep(random(200, 300)); break; } return random(500, 800); } @Override public void onPaint(Graphics2D g) { g.drawString("Status: " + status, 4, 333); // This is where you will put your code for paint(s) } }
-
Issue with localWaler.walkPath
Hey guys, I'm currently just throwing together a quick Willow Cutter for Barbarian Assault. At present it cuts fine, RETURNS from the bank fine but it won't WALK to the bank. This is my banking case: Variable from start of script (private Position[] bankPos = { new Position(2535, 3574, 0) }; ) case BANK: if (inventory.isFull()) { localWalker.walkPath(bankPos); status = "Banking"; Entity chest = objects.closest(true, bankChest); if (!bank.isOpen()) { if (chest != null) { if (chest.isVisible()) { if (!myPlayer().isMoving()) { chest.interact("Use"); sleep(random(1000, 1500)); } } } else { camera.toEntity(chest); } } else if (getInventory().contains( "Bronze axe, Iron axe, Steel axe, Black axe, Mithril axe, Adamant axe, Rune axe, Dragon axe")) { bank.depositAllExcept( "Bronze axe, Iron axe, Steel axe, Black axe, Mithril axe, Adamant axe, Rune axe, Dragon axe"); } else { bank.depositAll(); } } break; When I manually override and walk my character to the bank chest within the building, it begins to walk perfectly fine and interacts with the chest and banks properly and walks back to the willows without any issues, however, it just won't walk to the chest under its own power. I'm not too sure what I'm not seeing that's causing this issue. It enters the 'banking' state in the paint. Any and all advice is most welcome. -Omni. (Complete code in case it is required) import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(name = "Willow Cutter", author = "Omni", version = 1.0, info = "A simple Willow Cutter for Barbarian Assault", logo = "") public class OmniCutter extends Script { public static String status; private Position[] barbWillows = { new Position(2518, 3576, 0) }; private Position[] bankPos = { new Position(2535, 3574, 0) }; private int bankChest = 19051; @Override public void onStart() { status = "OmniCutter is beginning."; } private enum State { CUT, BANK, SLEEP, WALK2TREE, NESTGRAB }; private State getState() { Entity tree = objects.closest("Willow"); if (inventory.isFull()) { return State.BANK; } else { if (myPlayer().isAnimating()) { return State.SLEEP; } else { if (tree != null && !myPlayer().isAnimating()) { return State.CUT; } else { if (inventory.isEmptyExcept("Hatchet")) { return State.WALK2TREE; } else { GroundItem nest = groundItems.closest("Birds Nest"); if (nest != null && nest.exists()) { return State.NESTGRAB; } else { return State.SLEEP; } } } } } } @Override public void onExit() { log("OmniCutter is exiting. Thank you for running."); } @Override public int onLoop() throws InterruptedException { switch (getState()) { case CUT: Entity tree = objects.closest("Willow"); if (!inventory.isFull() && !myPlayer().isAnimating() && !myPlayer().isMoving()) { camera.toEntity(tree); tree.interact("Chop Down"); status = "Clicking Willow"; sleep(random(2500, 3000)); } break; case BANK: if (inventory.isFull()) { localWalker.walkPath(bankPos); status = "Banking"; Entity chest = objects.closest(true, bankChest); if (!bank.isOpen()) { if (chest != null) { if (chest.isVisible()) { if (!myPlayer().isMoving()) { chest.interact("Use"); sleep(random(1000, 1500)); } } } else { camera.toEntity(chest); } } else if (getInventory().contains( "Bronze axe, Iron axe, Steel axe, Black axe, Mithril axe, Adamant axe, Rune axe, Dragon axe")) { bank.depositAllExcept( "Bronze axe, Iron axe, Steel axe, Black axe, Mithril axe, Adamant axe, Rune axe, Dragon axe"); } else { bank.depositAll(); } } break; case WALK2TREE: status = "Returning to Willows"; localWalker.walkPath(barbWillows); break; case NESTGRAB: GroundItem nest = groundItems.closest("Birds Nest"); if (nest != null && nest.exists()) { nest.interact("Take"); } case SLEEP: status = "Sleeping"; sleep(random(200, 300)); break; } return random(500, 800); } @Override public void onPaint(Graphics2D g) { g.drawString("Status: " + status, 4, 333); // This is where you will put your code for paint(s) } }
-
Creating a simple kill/loot script
You can definitely do all of those things, but it's a learning curve. You should familiarise yourself with the API which is, in essence, a list of OSBot's built in functions so that you don't have to create them yourself. You can find the API here. The xp/hr, time run and items gained etc tracker is all part of what is called the 'paint'. If you want to learn to create a paint, I highly suggest the tutorial that was written by Pug. It can be found here. That will run you through how to do most of what you want to know for that part. As for the others, there are built in functions for most of it that you can use. I would love to be more helpful but I'm still very much learning myself, however, if you have any general questions I'm always happy to do what I can to lend a hand. My advise on how to begin would be start by creating a script that attacks Men and loots their bones/drops of your choice. That's a fairly simple script that would be manageable for anyone beginning to learn I believe and removes the complexities of eating and similar. As you begin to feel more comfortable, just add new elements such as eating and change the target NPC from Men to something like Lessor Demons (anything that can't immediately kill you if there's an error with the script).
-
First Script Issues, Wont enter Mining State
I'll definitely toy around with that and your dropping during null ore idea tomorrow when I get home. I really appreciate you and everyone else taking the time to answer simple questions for me, it's hugely helpful in wrapping my head around Java and the api
-
First Script Issues, Wont enter Mining State
I'd actually quite like to implement that, is there a way to limit the Entity = objects.clostest and set it within a limit of two tiles. I found in the API Entity Area(int x1, int y1, int x2, int y2), would I utilise that and set a square that contains the two rocks that I want to target? I'm not totally sure how to utilise it so I'd love any input anyone has.
-
First Script Issues, Wont enter Mining State
Thanks heaps, I'll use that to neaten it up . I don't suppose you have any ideas regarding why it isn't executing properly? Sometimes it also gets stuck on 'starting script' status and doesn't proceed until I manually mine an ore at which point, it stops mining and is stuck in the 'dropping' state. The strange thing is, I think it may be tied to my paint. Prior to its addition, it actually all worked okay so perhaps I inadvertently tweaked something.
-
First Script Issues, Wont enter Mining State
On that note, if I change the dropping method from is.Full to .isEmptyExcept, the script breaks again. It gets stuck in the 'dropping' status and doesn't mine still. Even when I change it to is.Full, it mines a full inventory successfully and drops the full load, but then doesn't resume. Also, one (hopefully) last question for anyone reading: Is there a limit radius command in OSBot? I'm mining in the middle of two rocks and I want it to wait if those two are exhausted until they respawn. Instead, it runs off to a very nearby rock, but it takes longer than waiting. Is there a command similar to "Entity rock = objects.closest" that is sort of a "Entity rock = objects.within2tiles" Do you have any advise about that? I honestly can't see where I've gone wrong. This is my updated code. 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 java.awt.*; import java.util.concurrent.TimeUnit; @ScriptManifest(author = "Omni", info = "Iron Powerminer", name = "Omni Miner", version = 1.0, logo = "") public class OmniMiner extends Script { private int [] targetRock = {13710}; private long timeBegan; private long timeRan; private int xpGained; private int xpPerHour; private int currentXP; private int currentLevel; private int beginningXP; private double nextLevelXP; private long timeTNL; private double xpTillNextLevel; private int OreMined = 0; final int[] XP_TABLE = { 0, 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431, 200000000 }; // DEBUG STATUS public static String status; // Paint Variables private final Color color1 = new Color(0, 102, 102); private final Color color2 = new Color(0, 0, 0); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font("Arial", 1, 14); private final Font font2 = new Font("Arial", 1, 10); @Override public void onStart() { log("Omni Miner has begun. Please report any bugs to me via the forums"); status = "script starting"; timeBegan = System.currentTimeMillis(); beginningXP = skills.getExperience(Skill.MINING); timeTNL = 0; } private enum State { MINE, DROP, SLEEP }; private State getState() { Entity rock = objects.closest(targetRock); // Dropping state if(!inventory.isEmptyExcept(1269)){ return State.DROP; }else{ if(myPlayer().isAnimating()){ return State.SLEEP; }else{ if(rock != null){ return State.MINE; }else{ return State.SLEEP; } } } } @Override public int onLoop() throws InterruptedException { switch (getState()) { case MINE: Entity rock = objects.closest(targetRock); if ((!inventory.isEmpty()) && !myPlayer().isAnimating()) { rock.interact("Mine"); status = "Mining"; sleep(random(4000,4500)); } break; case DROP: inventory.dropAllExcept(1265, 1269); status = "Dropping"; sleep(random(200,300)); break; case SLEEP: sleep(random(200, 300)); status = "Sleeping"; break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running Omni Miner."); } @Override public void onPaint(Graphics2D g) { currentXP = skills.getExperience(Skill.MINING); currentLevel = skills.getStatic(Skill.MINING); xpGained = currentXP - beginningXP; xpPerHour = (int)( xpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D)); nextLevelXP = XP_TABLE[currentLevel + 1]; xpTillNextLevel = nextLevelXP - currentXP; OreMined = xpGained / 35; if (xpGained >= 1) { timeTNL = (long) ((xpTillNextLevel / xpPerHour) * 3600000); } timeRan = System.currentTimeMillis() - this.timeBegan; g.setColor(color1); g.fillRect(7, 458, 325, 16); g.setColor(color2); g.setStroke(stroke1); g.drawRect(7, 458, 325, 16); g.setColor(color1); g.fillRect(325, 345, 170, 129); g.setColor(color2); g.drawRect(325, 345, 170, 129); g.setFont(font1); g.drawString("Omni Miner V 1.0" , 329, 362); g.setFont(font2); g.drawString("Time Running: " + ft(timeRan), 329, 375); g.setFont(font2); g.drawString("Experience Gained: " + xpGained, 329, 387); g.setFont(font2); g.drawString("TTL: " + ft(timeTNL), 329,399); g.setFont(font2); g.drawString("Ores mined: " + OreMined, 329, 411); g.setFont(font2); g.drawString("Status: " + status, 329, 423); } private String ft(long duration) { String res = ""; long days = TimeUnit.MILLISECONDS.toDays(duration); long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration)); long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration)); long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration)); if (days == 0) { res = (hours + ":" + minutes + ":" + seconds); } else { res = (days + ":" + hours + ":" + minutes + ":" + seconds); } return res; } }
-
First Script Issues, Wont enter Mining State
That fixed it up perfectly, thank you very much. I'll keep toying around with it to get it perfect but I really appreciate the help
-
First Script Issues, Wont enter Mining State
I really appreciate you taking the time to help me. I made the changes you suggested, however, the Mine case still isn't running for whatever reason. I don't suppose you have any other ideas? If not, thanks for all your help anyway. My getState is now: private State getState() { Entity rock = objects.closest(targetRock); // Dropping state if (!myPlayer().isAnimating() && !inventory.isEmptyExcept(1269)) return State.DROP; // Check if mining already if (myPlayer().isAnimating()) return State.SLEEP; // Mining State if (rock != null && !myPlayer().isAnimating()) return State.MINE; else return State.SLEEP; } I put an else return State.Sleep in there because it was throwing me an error telling me it wanted a return null after return State.Mine without it.
-
First Script Issues, Wont enter Mining State
Hey guys, I'm just toying around with OSBot's API and Java in general trying to get a feel for everything. I don't have a huge amount of experience coding, only in MATLAB. I wrote this script last night with the help of Apaec's tutorial, however, it won't interact with the rocks. It drops perfectly fine, it just won't mine. On the paint, it is almost always on the "dropping" status until I manually override and mine, at which point it changes to "sleeping" as opposed to mining. All in all, I'm very confused and I'd love a second set of eyes to help my chase down my problem Sincerely, -Omni. import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; import java.util.concurrent.TimeUnit; @ScriptManifest(author = "Omni", info = "Iron Powerminer", name = "Omni Miner", version = 1.0, logo = "") public class OmniMiner extends Script { private int [] targetRock = {13458, 13456}; private int oreMined = 0; private long timeBegan; private long timeRan; // DEBUG STATUS public static String status; // Paint Variables private final Color color1 = new Color(0, 102, 102); private final Color color2 = new Color(0, 0, 0); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font("Arial", 1, 14); private final Font font2 = new Font("Arial", 1, 10); @Override public void onStart() { log("Omni Miner has begun. Please report any bugs to me via the forums"); status = "script starting"; timeBegan = System.currentTimeMillis(); } private enum State { MINE, DROP, SLEEP }; private State getState() { Entity rock = objects.closest(targetRock); // Dropping state if (!myPlayer().isAnimating() && !inventory.isEmptyExcept(1269)) return State.DROP; // Check if mining already if (myPlayer().isAnimating()) return State.SLEEP; // Mining State if (rock != null && !myPlayer().isAnimating()) return State.MINE; return State.SLEEP; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case MINE: Entity rock = objects.closest(targetRock); if (!inventory.isEmpty() && !myPlayer().isAnimating()) { rock.interact("Mine"); status = "Mining"; } break; case DROP: inventory.dropAllExcept(1265, 1269); status = "Dropping"; sleep(random(200,300)); break; case SLEEP: sleep(random(200, 300)); status = "Sleeping"; break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running Omni Miner."); } @Override public void onPaint(Graphics2D g) { timeRan = System.currentTimeMillis() - this.timeBegan; g.setColor(color1); g.fillRect(7, 458, 325, 16); g.setColor(color2); g.setStroke(stroke1); g.drawRect(7, 458, 325, 16); g.setColor(color1); g.fillRect(325, 345, 170, 129); g.setColor(color2); g.drawRect(325, 345, 170, 129); g.setFont(font1); g.drawString("Omni Miner V 1.01" , 329, 362); g.setFont(font2); g.drawString("Time Running: " + ft(timeRan), 329, 375); g.setFont(font2); g.drawString("Experience Gained:", 329, 387); g.setFont(font2); g.drawString("Ores mined: ", 329, 399); g.setFont(font2); g.drawString("Status: " + status, 329, 411); } private String ft(long duration) { String res = ""; long days = TimeUnit.MILLISECONDS.toDays(duration); long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration)); long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration)); long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration)); if (days == 0) { res = (hours + ":" + minutes + ":" + seconds); } else { res = (days + ":" + hours + ":" + minutes + ":" + seconds); } return res; } }
-
👑 Perfect Czar Free Trials & Demos 👑 MOST POPULAR 👑 HIGHEST QUALITY 👑 MOST TOTAL USERS 👑 LOWEST BAN-RATES 👑 24/7 SUPPORT 👑 SINCE 2015 👑 MANY SKILLS 👑 MOST VIEWS 👑 MOST REPLIES 👑
Hey Czar, I'd love a trail of Perfect Fisher. I'm struggling to find a good fisher and if yours works at Catherby, you'll have my money. My member number is 86484 if that makes your life easier.
-
how to execute my osbot.jar?
The client is a Java file and isn't run like an .exe file. Instead, you will need to download the Java Runtime Environment (select the appropriate version for your operating system). Once you have downloaded the JRE, you will be able to click on "osbot 2.3.94.jar" and it will act in the same way as an .exe file.