Everything posted by Athylus
-
Function variables
If I understand correctly you want to make a function that grabs the item by name and then call another function inside of there to click on a random spot. In that case I'd go for single responsibility. So you make two functions, each is responsible for only one thing. First off your code is more readable and second you can reuse the random click on any rectangle. Edit: Alek makes a fair point. If you look at it from a lower level then it is more expensive. Correct me if I'm wrong, but your program would have to jump to the other function by accessing the pointer that refers to memory where your method is placed. How the inner workings of Java handle that is still a mystery to me, but looking at it from an assembly perspective there are definitely some more instructions happening. The question is, will it make or break your program on a multi-threaded 3 GHz processor?
-
Area on another Z plane
Setplane is working, thanks! I thought that setting that Z coordinate would be enough. Great!
-
Area on another Z plane
Hey all, currently debugging some Area code. Position[] possArr = {new Position(x1, y1, 1), new Position(x2, y2, 1) etc ...}; Area areaPoly = new Area(posArr); @Override public void onPaint(Graphics2D g) { List<Position> posList = areaPoly.getPositions(); g.setColor(Color.BLACK); boolean bool = areaPoly.contains(myPlayer()); g.drawString(Boolean.toString(bool), 10, 20); for (Position pos : posList) { g.draw(pos.getPolygon(getBot())); } } The area is being drawn but on the z=0 plane. My boolean displays true on the 0 plane, but false on same spot on the 1 plane. Any workarounds?
-
what are the best scripts to use to start a goldfarm?
Minimal requirements and resources needed. I see many yew cutters for example... You can get the requirements in about 5 hours estimated (I'm just pulling that out of my ass, it might be more). That leaves you perhaps another 24-48 hours to bot if you are lucky. Good luck.
-
Exchanging Context null pointers
Thanks FrostBug! I thought onStart would be called automatically. So I called it after exchange context and it's working just fine now.
-
Exchanging Context null pointers
Hey all! Still working on my quest bot. I have a main class script: private QuestInstance restlessGhost = new RestlessGhost(107); @SuppressWarnings("deprecation") @Override public void onStart() throws InterruptedException { //cooksAssistant.exchangeContext(getBot()); restlessGhost.exchangeContext(getBot()); } @Override public int onLoop() { //log("Main loop"); //log(getConfigs().get(107)); switch(state) { case RESTLESS_GHOST: ((RestlessGhost)restlessGhost).onLoop(); break; default: break; } return 250; } Then there is my abstract QuestInstance class: public abstract class QuestInstance extends MethodProvider { ... protected final void speakNPC(String name, String[] options) { NPC npc = getNpcs().closest(name); if (npc != null) { if (!getMap().canReach(npc)) { if (getDoorHandler().handleNextObstacle(npc)) { new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return (!myPlayer().isMoving()); } }.sleep(); } } else { if (npc.interact("Talk-to")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getDialogues().inDialogue(); } }.sleep(); } if (getDialogues().inDialogue()) { log("Speaking to aereck..."); try { getDialogues().completeDialogue(options); } catch (InterruptedException e) { //e.printStackTrace(); } } } } } } Now my restless ghost class: public class RestlessGhost extends QuestInstance { ... String[] dialogueStart = new String[2]; public void onStart() { me = getPlayers().myPlayer(); dialogueStart[0] = "Who's Saradomin?"; dialogueStart[1] = "Ok, let me help then."; } ... private void startQuest() { speakNPC("Father Aereck", dialogueStart); } } Getting a null pointer on my speakNPC function. What is causing this? If I use the exact same function in a single class script it works just fine.
-
Open Source Tutorial Island Script
Thanks a lot! What does the exchangeContext method do?
-
List of potential sites I can sell gold to?
Cool that you're doing this, keep going! I have personally sold small amounts of cash to gold4rs. From 50M to 200M stacks. Great service. They respond with haste and are quick to make a deal. I went first and got cash on my paypal. Mind you this was roughly a year ago.
-
Multiple classes
Great, it's working! I actually passed my own main class as Script type. Thanks.
-
Multiple classes
In the process of making a quest bot. Using multiple classes to keep control of my code. Now I am making a method to grab an item in one of my classes, but I cannot call getCamera().toEntity(e);. I am guessing because I am not extending Script, since I have all the imports. If I am correct you are only allowed to extend Script in your main class. Is there a work around? All the imports are used listed on this page: https://osbot.org/api/org/osbot/rs07/api/Camera.html
-
Combat script overflowing
Great! Thanks d0zza & co. It's working now.
-
Combat script overflowing
Not sure what is happening here. My RAM is filling up and processor usage is skyrocketing. What is going wrong here? public class Combat extends Script { private Player me; private boolean changeToAttack = true; private boolean changeToDefence = true; private enum State { ATTACK, EAT } private State getState() { if (getSkills().getDynamic(Skill.HITPOINTS) < 4) { return State.EAT; } else if (!getCombat().isFighting()) { return State.ATTACK; } else { return null; } } @Override public void onStart() { log("Welcome!"); me = getPlayers().myPlayer(); } @Override public void onExit() { } @Override public int onLoop() throws InterruptedException { switch(getState()) { case ATTACK: Attack(); break; case EAT: Eat(); break; default: break; } return 225; } private void Eat() { // TODO Auto-generated method stub } private void Attack() { /* if (changeToAttack) { if (getSkills().getStatic(Skill.STRENGTH) > 9) { if (getWidgets().interact(548, 48, null)) { if (getWidgets().interact(593, 3, null)) { changeToAttack = false; } } } } if (changeToDefence) { if (getSkills().getStatic(Skill.STRENGTH) > 9 && getSkills().getStatic(Skill.ATTACK) > 9) { if (getWidgets().interact(548, 48, null)) { if (getWidgets().interact(593, 15, null)) { changeToDefence = false; } } } } */ @SuppressWarnings("unchecked") NPC monster = getNpcs().closest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return npc != null && npc.getName().equals("Chicken") && npc.exists() && getMap().canReach(npc) && npc.getHealthPercent() > 0 && npc.getInteracting() == null; } }); if (monster.isVisible()) { if (monster.hasAction("Attack")) { if (monster.interact("Attack")) { try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } } } } @Override public void onPaint(Graphics2D g) { /* List<Position> areaList = choppingArea.getPositions(); g.setColor(Color.GREEN); for (int i = 0; i < areaList.size(); i++) { g.draw(areaList.get(i).getPolygon(getBot())); } */ } }
- Threading paint before OnLoop
-
Threading paint before OnLoop
Quick question on multithreading. My script uses a GUI which has two options: What tree type to cut and another dropbown menu for how big of an area you want to cut in. Now when the area size if being adjusted I want to paint it, while the main scriptloop has not started yet. How can I implement such a function?
- SWT GUI
-
SWT GUI
There is a problem with my GUI. I am trying to use SWT for this. I made a separate class next to my main one called GUI, in it I have a SWT GUI which has a combo box and a start script button. import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.graphics.Point; public class GUI { public String treeName; public static String errorMessage; protected Shell shell; /** * Launch the application. * @param args */ public static void main(String[] args) { try { GUI window = new GUI(); window.open(); } catch (Exception e) { errorMessage = "Error"; } } /** * Open the window. */ public void open() { Display display = Display.getDefault(); createContents(); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } /** * Create contents of the window. */ protected void createContents() { shell = new Shell(); shell.setMinimumSize(new Point(136, 40)); shell.setSize(272, 240); shell.setText("SWT Application"); shell.setLayout(null); Combo combo = new Combo(shell, SWT.READ_ONLY); combo.setBounds(66, 44, 128, 23); combo.setItems(new String[] {"Tree", "Oak", "Willow", "Maple", "Yew", "Magic"}); combo.select(0); Button btnNewButton = new Button(shell, SWT.NONE); btnNewButton.setBounds(66, 108, 128, 54); btnNewButton.setText("Start script"); btnNewButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { treeName = combo.getText(); shell.close(); } }); } } In my main: public void onStart() { GUI gui = new GUI(); } It's not even showing up! The logger is giving me some error messages. Uncaught exception! java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite at Main.onStart(Main.java:26) at org.osbot.rs07.event.ScriptExecutor.IiIiiiiiIiIi(yl:197) at org.osbot.rs07.event.ScriptExecutor.start(yl:28) at org.osbot.Lb.run(vf:245) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Composite at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 7 more [INFO][Bot #1][02/05 05:34:10 PM]: Terminating script Skeleton... [INFO][Bot #1][02/05 05:34:10 PM]: Script Skeleton has exited! Is it possible to make SWT work with OSBot?
-
A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec
Thank you.
-
A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec
But you still make a new object of the steal stall every time you go through the loop, which is a lot. Is not better to do something like this (memory wise)? So you create the object once and use that same object. After all, it's not going to change or move. private Entity teaStall; boolean success = false; public final int onLoop() throws InterruptedException { if (success == false) { teaStall = getObjects().closest("Tea stall"); success = true; } if (teastall == null) { success false; } }
-
A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec
Is it not better to make a instance variable to hold the stall object? And only try to acquire that stall object under certain conditions?
-
Selling Bonds! - OSBot's #1 Bond Seller!
Great service, bought two bonds. He is fast and a kind dude. Definitely recommend.
-
Scrub's Auto Fighter
Very nice script. It sometimes randomly clicks the lunge option when I use my dlong though. Not sure what causes that.
-
Not sure if keeper...
It's obvious who's the dominant one in this relationship. o.O
- I'm back
-
I'm back
Thanks Maldesto. Hello kMix, I appreciate your advice but the way of the warrior is the only one for me. Not saying kickboxing makes me a warrior, but I also meditate and I will start taking ninjutsu classes again. In which I will learn to defend myself in real life situations but it's not limited to that. You also learn how to fight with a katana, a staff, a stick, how to disarm guns and knives as well. Cool shit man, you should try it.
-
Do you report fellow botters?
No, it woud be hypocricy to the max.