-
Posts
2314 -
Joined
-
Last visited
-
Days Won
6 -
Feedback
100%
Everything posted by Explv
-
WalkingEvent walkingEvent = new WalkingEvent(position); walkingEvent.setMinDistanceThreshold(0); execute(walkingEvent);
-
Titled Border https://docs.oracle.com/javase/7/docs/api/javax/swing/border/TitledBorder.html
-
No problem
-
You can use "Explv's Location Assistant" in the Other section, and just copy-paste your path, it will show on screen.
-
Maybe the door is not called "Door". Or the area you passed does not contain the door.
-
Yes there are 6 different zoom levels, with each increasing zoom level the map is loaded from an increasing number of images. At zoom level 8, the map is ~50,000 images, and the images are loaded dynamically, so it only loads the images that you can see in the current position.
-
A simple walking script, select your destination and hit start! Price: $1 Purchase Link: https://osbot.org/forum/store/product/675-explvs-walker/ CLI: No preset location: java -jar "/path/to/osbot.jar" -login OSBotUser:OSBotPassword -bot RSUser:RSPassword:RSPin -script 819:none With coordinates (they can be obtained using my map https://explv.github.io/) java -jar "/path/to/osbot.jar" -login OSBotUser:OSBotPassword -bot RSUser:RSPassword:RSPin -script 819:x.y.z Using location name: java -jar "/path/to/osbot.jar" -login OSBotUser:OSBotPassword -bot RSUser:RSPassword:RSPin -script 819:LOCATION_NAME List of currently supported CLI location names:
- 344 replies
-
- 31
-
-
-
I think you should try and clean up your code a bit. Generally if your code is cleaner, it is easier to spot bugs / optimisations. Here is how you could clean up this class for example. You have two different halls each with the same properties, but different values. So you should probably create an enum to store this information: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; public enum Hall { // TODO: Define these EAST (null, null, null), WEST (null, null, null); final Area HALL_AREA, FIGHT_AREA; final Position[] FIGHT_POS; Hall(final Area HALL_AREA, final Area FIGHT_AREA, final Position[] FIGHT_POS){ this.HALL_AREA = HALL_AREA; this.FIGHT_AREA = FIGHT_AREA; this.FIGHT_POS = FIGHT_POS; } public static Hall getHall(Position playerPosition){ return Hall.EAST.HALL_AREA.contains(playerPosition) ? Hall.EAST : Hall.WEST.HALL_AREA.contains(playerPosition) ? Hall.WEST : null; } public static boolean inFightArea(Position playerPosition){ return EAST.FIGHT_AREA.contains(playerPosition) || WEST.FIGHT_AREA.contains(playerPosition); } public static Area getFightArea(Position playerPosition){ Hall hall = getHall(playerPosition); return hall != null ? hall.FIGHT_AREA : null; } } Seeing as you are sleeping at the end of the execute method, why not just change the return type of execute to an int, and perform the sleep in onLoop. Also I am guessing you have that state() method in every class, so you might as well just put this method into the base Node class: import org.osbot.rs07.script.Script; public abstract class Node { protected final Script S; private final String STATUS; public Node(final Script S, final String STATUS){ this.S = S; this.STATUS = STATUS; } public String status(){ return STATUS; } public abstract boolean validate() throws InterruptedException; public abstract int execute() throws InterruptedException; } Once I cleaned stuff up the code looks like: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.script.Script; import org.osbot.rs07.input.mouse.MiniMapTileDestination; import org.osbot.rs07.utility.ConditionalSleep; public class PickRoom extends Node { public PickRoom(final Script S) { super(S, "Choosing Fight Room"); } public boolean validate() throws InterruptedException { return !Hall.inFightArea(S.myPosition()) && hasFood(); } private boolean hasFood() { return S.getInventory().contains(Constants.FOOD); } public int execute() throws InterruptedException { final Area FIGHT_AREA = Hall.getFightArea(S.myPosition()); if (!canReachFightArea(FIGHT_AREA)) openFightAreaDoor(FIGHT_AREA); else walkInsideFightArea(); return (250 + Script.random(750)); } private boolean canReachFightArea(final Area FIGHT_AREA){ return S.getMap().canReach(FIGHT_AREA.getRandomPosition()); } private void openFightAreaDoor(final Area FIGHT_AREA){ if(S.getDoorHandler().handleNextObstacle(FIGHT_AREA)){ new ConditionalSleep(5_000) { @Override public boolean condition() throws InterruptedException { return S.getMap().canReach(FIGHT_AREA.getRandomPosition()); } }.sleep(); } } /** * * S.getLocalWalker().walk(getFightPos()); * S.walk.walkPath(getFightPos()); * For some reason these wouldn't walk into the room because * the tile I was trying to walk to was too close to my character */ private void walkInsideFightArea(){ Hall hall = Hall.getHall(S.myPosition()); if(hall != null) { S.getMouse().click(new MiniMapTileDestination(S.getBot(), hall.FIGHT_POS[0]), false); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return Hall.inFightArea(S.myPosition()); } }.sleep(); } } }
-
For that you would do something like: g.fill(npc.getModel().getBoundingBox(npc.getGridX(), npc.getGridY(), npc.getZ())); Note: use g.fill to create a filled in rectangle, or g.draw if you just want the outline.
-
@Override public void onPaint(Graphics2D g){ g.setColor(Color.RED); g.fill(new MiniMapTileDestination(getBot(), npc.getPosition()).getBoundingBox().getBounds2D()); }
-
You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.utility.ConditionalSleep; public class DoorHelper { private final Script S; public DoorHelper(final Script S){ this.S = S; } public RS2Object getDoor(Area doorArea){ //noinspection unchecked return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj)); } public boolean doorIsClosed(RS2Object door){ return door.hasAction("Open"); } public void openDoor(RS2Object door){ if(door != null && doorIsClosed(door)){ door.interact("Open"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return !doorIsClosed(door); } }.sleep(); } } }
-
Got it to work by doing this. Thanks dude
-
Just tried: Platform.runLater(() -> ClassName.launch(ClassName.class)); But no dice, I will try your full solution now, thanks man
-
Edit: Nevermind, got the error now: Caused by: java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = pool-1-thread-2 I am having issues with launching a JavaFX application from the onStart method in Script. There is no issue with the application itself, as it works perfectly fine when called from the main method in the same class. I am launching the application using the following code, it produces "error in script onStart()", but no useful message: @Override public void onStart(){ ClassName.launch(ClassName.class); } Thanks
-
I am just using lambda expressions as it shortens your code significantly: http://tutorials.jenkov.com/java/lambda-expressions.html This: getObjects().filter(obj -> obj.getId() == ID && AREA.contains(obj)); Is equivalent to: getObjects().filter(new Filter<RS2Object>() { @Override public boolean match(RS2Object obj) { return obj.getId() == ID && AREA.contains(obj); } });
-
You are passing it a position right walking.walk(position);
-
Are you sure that line is the one causing the error? There isn't anything obviously wrong with it.
-
Client can't find program to open with, java doesn't work
Explv replied to drwolfstud's topic in Resolved
No problem -
Client can't find program to open with, java doesn't work
Explv replied to drwolfstud's topic in Resolved
Try this: http://osbot.org/forum/topic/87717-fixing-osbot-not-starting/ -
if(getMap().canReach(STAIR_AREA.getRandomPosition())){ walker.walk(STAIR_AREA.getRandomPosition(), true); } else{ doorHandler.handleNextObstacle(STAIR_AREA)); }
-
Sure, I will pm you
-
The simplest way to create any quest script is to use configs. When you perform some activity during a quest, a value in the configs will change. You can use these values to determine your progress in the quest, and then perform the relevant action. To see the configs, go into the Settings -> Options -> Debug -> Configs You will then see a list of numbers on your screen: The number of the left is the config ID, and the number on the right, is its current value. The value on the right will update at various points in the quest. Lets say for example, the config ID is 200, before you start the quest the value would be 200 : 0. After you talk to the cook, the config might be 200 : 20. Once you know the config value you need, you can then setup a switch in your onLoop like this: switch(getConfigs().get(200)){ case 0: talkToCook(); break; case 20: walkToCows(); break; }
-
I recommend that you learn how to do these basic Swing tasks without a GUI builder, before using a GUI builder Just create two JList<String> intialised with DefaultListModel<String> and then use model.addElement and model.remove: String[] friends = { "Noob1", "Noob2", "Noob3", "Noob4" }; DefaultListModel<String> friendsModel = new DefaultListModel<>(); for(String friend : friends){ friendsModel.addElement(friend); } JList<String> friendsList = new JList<>(friendsModel); DefaultListModel<String> foesModel = new DefaultListModel<>(); JList<String> foesList = new JList<>(foesModel); JButton addFoe = new JButton("> Foes >"); addFoe.addActionListener(e -> { for(int i : friendsList.getSelectedIndices()) foesModel.addElement(friendsModel.remove(i)); }); JButton addFriend = new JButton("< Friends <"); addFriend.addActionListener(e -> { for(int i : foesList.getSelectedIndices()) friendsModel.addElement(foesModel.remove(i)); });
-
This can be done in a shorter way: RS2Object[] objects = getObjects().filter(obj -> obj.getId() == ID && AREA.contains(obj)); Usually what you want to do is find the closest object, for example to find the closest Willow tree in a specified Area: RS2Object willowTree = getObjects().closest(obj -> obj.getName().equals("Willow") && AREA.contains(obj));
-
You can do this, but this example is incorrect, the argument is not a String. It should be: @Override public void onMessage(Message message){ if(e.getType() == Message.MessageType.GAME && e.getMessage().equals("A magical force stops you from moving")){ // do something } }