Jump to content

Psychotechno

Members
  • Posts

    21
  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by Psychotechno

  1. Noob question incoming When programming my bot to interact with the grand Exchange, I noticed that some snippets use the getGrandExchange() method in the MethodProvider, for example: getGrandExchange().isOpen() And sometimes people don't use the MethodProvider, so they use GrandExchange class directly, like so: if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_BUY) { status = "Pending offer"; }else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_BUY) { status = "Offer completed - Collecting"; } What is the difference between the two? The same applies with Inventory class & getInventory(), Bank class & getBank() etc.... I guess this question could be phrased more generally: What is the difference between using methodProvider get-functions or interacting with the classes directly?
  2. Hey fellow scripters! I'm a bit new to OSbot scripting, and I've been searching in the forums on how to best interact with the GE. I found a few API's/snippets. Is there a go-to/defacto best way to interact with the GE? Or do all these snippets/API's have their merits? And what do you guys recommend? I simply need to sell some items I botted at market price. Kindest regards, psycho
  3. Whooooops, my bad: WebWalkEvent dungeonWalk = new WebWalkEvent(DUNGEON); dungeonWalk.setEnergyThreshold(101); execute(dungeonWalk); It doesn't turn on run at first, but after two clicks in the minimap it does turn on run again (Even though energy is much lower than 100%, ideally I don't want to turn it on at all during the WebWalk).
  4. This doesn't work for me.... When I put in something like this: WebWalkEvent dungeonWalk = new WebWalkEvent(DUNGEON); dungeonWalk.setEnergyThreshold(; ; "In Desired area"; It still enables run somewhere in the middle of the webwalk. Any help would be appreciated.
  5. Hey Apa! To address point 3 (I think I've met all the conditions but you never know), I added an else-clause that webwalks the entire way to the destination dungeon. This is a backup after all else fails; so I think it will never be executed but you never know. To address point 5; do you mean that I should initialize the walkpath as a field somewhere (Like i did with for example the variables NEAR_DUNGEON and TELESPOT?) With the comment about instantiating the arraylist, do you mean instantiating it in a oneliner? So simply add the positions to the new ArrayList constructor? Point 6: Any example where I did not do this? Thanks again for all the feedback Script is really improving because of it. ~Pscyho
  6. EDIT 4: Got it! Does take a lot of checks though, since I am basically walking in three blocks I need to check a lot of conditions, for the bot to know in which "Section" it currently is. Could maybe simplify somehow but at the moment I don't see how haha. Only posted walker function since onloop did not change. I think readers can skip edit 1, 2 and 3 and refer to this block, as this is the final version... Sorry for the SPAM haha kept getting new ideas just after my edits . private void dungeonWalker() { //Player is not near teleport spotm not on it's way to dungeon, and not already in dungeon so walk to telespot. if(!TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition()) && myPlayer().getY() < 9700){ getWalking().webWalk(TELESPOT); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("Webwalker finished"); //Player is not near dungeon and at telespot (Because of previous if) so Walk near dungeon. }else if(TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition())){ List<Position> telespot_neardungeon = new ArrayList<>(); telespot_neardungeon.add(new Position(3086, 3488, 0)); telespot_neardungeon.add(new Position(3093, 3479, 0)); telespot_neardungeon.add(new Position(3094, 3470, 0)); getWalking().walkPath(telespot_neardungeon); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("Near Dungeon"); //Player is near dungeon but not yet in desired area, so webWalk the rest of the route }else if(NEAR_DUNGEON.contains(myPosition()) && !DUNGEON.contains(myPosition())){ getWalking().webWalk(DUNGEON); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("In desired Area"); } //Player is in dungeon but not yet in desired area (Maybe cuz webwalk broke in previous onLoop), so webWalk the rest of the route else if (myPosition().getY() > 9700){ //Player is in dungeon, so continue webwalk. getWalking().webWalk(DUNGEON); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("In desired Area"); } }
  7. I thought about using walkPath's, But ended up using WalkingEvents because there I can set the setMinDistanceThreshold(1); for some added randomization. If I were to use walkPaths; the both would walk the same path time after time which I believe is very bot-like. Trying to randomize the script as much as possible. Will PM you once done!! EDIT1: This is a better try, but I'm still not sure if it's perfect; @Override public int onLoop() throws InterruptedException { dungeonWalker(); log("One iteration of onLoop finished"); return random(350, 550); } private void dungeonWalker() { //Player is not near teleport spot and not on it's way to dungeon, so Webwalk to telespot if(!TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition())){ getWalking().webWalk(TELESPOT); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("Webwalker finished"); //Player is not near dungeon and at telespot (Because of previous if) so Walk near dungeon. }else if(!NEAR_DUNGEON.contains(myPosition())){ //Can executing a walkPath be seen as a "Single game interaction?" //If not, how do i build "in between" checks as the walkPath is a single function call? List<Position> telespot_neardungeon = new ArrayList<>(); telespot_neardungeon.add(new Position(3086, 3488, 0)); telespot_neardungeon.add(new Position(3093, 3479, 0)); telespot_neardungeon.add(new Position(3094, 3470, 0)); getWalking().walkPath(telespot_neardungeon); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("Near Dungeon"); //Player should be near dungeon because of previous block }else if(!DUNGEON.contains(myPosition())){ //Same holds for walkPath. Say WalkPath fails and onLoop executes again. In that case the previous if block //else if(!NEAR_DUNGEON.contains(myPosition())) will execute because my player is not near the dungeon anymore but further along the road, //And script will get stuck. getWalking().webWalk(DUNGEON); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("In desired area"); stop(true); } }
  8. I can affirm that this happens; bot seems a bit buggy. When I run varrock (& Draynor) rooftop sometimes the bot does multiple "human idles" (Like 4 or 5) in a row. Eventually it continues, but I don't think this is planned behavior as it slows down the script alot. After some investigation it seems to happen if the bot can't "see" the next obstacle. It does turn the screen in the end, but as mentioned it sometimes take like 4 or 5 "human idle" periods. Hope this helps. If you need any additional info to debug i'd be happy to help!
  9. Hey boss - Thanks again for the elaborate response. Really do appreciate it!! Completely get it now. I'm going to rewrite the entire script so I execute exactly one game action per onLoop. Shouldn't be too hard now I get the design paradigm =). One question remains: what about walking paths? For example this function; private void poolWalker() { log("Starting poolWalker"); WalkingEvent ferox_1 = new WalkingEvent(new Position(3148, 3629, 0)); ferox_1.setMinDistanceThreshold(2); execute(ferox_1); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); WalkingEvent ferox_2 = new WalkingEvent(new Position(3138, 3629, 0)); ferox_2.setMinDistanceThreshold(2); execute(ferox_2); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); WalkingEvent ferox_3 = new WalkingEvent(new Position(3134, 3636, 0)); ferox_3.setMinDistanceThreshold(2); execute(ferox_3); Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500)); log("Finished poolWalker"); } How does one check if previous movement was successful?? I could make Areas of each position and see if the player position contains the "previous" area coordinates (So for example; before executing the ferox_3 WalkingEvent check if playerPosition is somewhere in area of ferox_2 coords). But that seems a bit cumbersome...
  10. Dear Apa, I'm a bit further along my scripting journey now and managed to implement a working script. Previously you told me that I should be "Executing a single game interaction per iteration of onLoop". I indeed see that a lot else-if constructs are used, to ensure that only one if-statement is executed per onLoop. I did not adhere to this principle, and instead of using else-if's i'm simply using some sequential if's to check. It does work, but I'm not sure my script is "In a state to retry" If a function fails; Take for example my bank function; private void bank() throws InterruptedException { if (!FEROXENCLAVE_TELESPOT.contains(myPosition())) { getEquipment().interact(EquipmentSlot.RING, "Ferox Enclave"); Sleep.sleepUntil(() -> FEROXENCLAVE_TELESPOT.contains(myPosition()), random(2500, 3000)); log("Teleported to Ferox enclave"); } if (!FEROXENCLAVE_POOLS.contains(myPosition())) { poolWalker(); } RS2Object refreshmentPool = getObjects().closest("Pool of Refreshment"); if (refreshmentPool != null) { refreshmentPool.interact("Drink"); Sleep.sleepUntil(() -> myPlayer().isAnimating(), random(2500, 3500)); log("Succesfully drank refreshments... Sweet"); } if (!FEROXENCLAVE_BANK.contains(myPosition())) { bankWalker(); } if (!getBank().isOpen()) { boolean isGloryEmpty = gloryChecker(); boolean isDuelingEmpty = duelingChecker(); getBank().open(); log("Bank was opened"); getBank().depositAll(); log("Stuff was deposited"); getBank().withdraw("Salmon", 3); log("Salmon was withdrawn"); if (gloryChecker()) { getBank().withdraw("Amulet of glory(4)", 1); log("Glory empty, so withdraw a new one"); } if (isDuelingEmpty) { getBank().withdraw("Ring of dueling(8)", 1); log("ROD empty, so withdraw a new one"); } getBank().close(); if (isGloryEmpty) { getInventory().getItem("Amulet of glory(4)").interact("Wear"); log("Equipped new amulet of glory"); getBank().open(); getBank().deposit("Amulet of glory", 1); getBank().close(); } if (isDuelingEmpty) { getInventory().getItem("Ring of dueling(8)").interact("Wear"); log("Equipped new ring of dueling"); } } if (!EDGEVILLE_TELESPOT.contains(myPosition())) { getEquipment().interact(EquipmentSlot.AMULET, "Edgeville"); } } I am doing some checks to see if the script advances, but only with sequential if statements. Now, say for example the poolWalker function fails. Then probably the script will get stuck further along the line, for example when trying to open the bank. Is this why I see so many if-elseif-elseif constructs in people's scripts? Since, if one if evaluates to true in an if-elseif-elseif, the other "if"s won't be executed, and hence the onLoop progresses to the next action? If that's the case I think I finally get what you mean Also, finally; do you ideally want to execute exactly *one* action per onloop iteration? For example, in the code above, I open the bank, deposit, withdraw etc all in one go... Is that bad practice too? Thanks in advance
  11. This does not work, the If statement will never get executed because the trapdoor does not have actions "Open" and "Climb-down" at the same time. anyways, thx for the snippet, Will use the .exists() function to check.
  12. I've been thinking about what you said about your design pattern, but I'm unsure how to implement such a thing. How can I make sure only one interaction happens per OnLoop execution? Only thing I can think of is to store all my compound actions inside some data structure outside onloop and call them one by one in onLoop, only moving on to the next one when the previous one succeeds. Is that what you mean? Again, appreciate the response =) Thanks
  13. How do you guys feel about the following solution? Just thinking aloud here, am using OnMessage to do some checks; public final class RandomWalker extends Script { private boolean door_open; private boolean climbed_down; private void setDoor_open(boolean door_open) { this.door_open = door_open; } private void setClimbed_down(boolean climbed_down) { this.climbed_down = climbed_down; } @Override public void onStart() throws InterruptedException { log("This will be printed to the logger when the script starts"); } @Override public void onExit() throws InterruptedException { log("This will be printed to the logger when the script exits"); } @Override public int onLoop() throws InterruptedException { RS2Object trapdoor = getObjects().closest("Trapdoor"); if (trapdoor != null && trapdoor.interact("Open")) { Sleep.sleepUntil(() -> this.door_open, 3000); RS2Object open_trapdoor = getObjects().closest("Trapdoor"); open_trapdoor.interact("Climb-down"); }else if(trapdoor != null && trapdoor.interact("Climb-down")){ trapdoor.interact("Climb-down"); } Sleep.sleepUntil(() -> this.climbed_down, 3000); List<Position> path = new ArrayList<>(); path.add(new Position(3097, 9876, 0)); path.add(new Position(3095, 9888, 0)); path.add(new Position(3096, 9902, 0)); getWalking().walkPath(path); return 0; } @Override //Use this to get bot messages public void onMessage(Message message) { log("A message arrived in the chatbox: " + message.getMessage()); if(message.getMessage().equals("The trapdoor opens...")){ setDoor_open(true); log("Set door open var to true."); }else if (message.getMessage().equals("You climb down through the trapdoor...")){ setClimbed_down(true); log("Set climbed down var to true"); } } } I'm using the onMessage to check if the trapdoor was opened, and to see if the climb-down was succesful. Also, I conditional sleep before climbing down, until I receive the message that the trapdoor is open. BTW, I'm using @Explv Conditional sleep class implementation because it keeps my code nice 'n tidy =). In general, do you guys ever use onMessage to see if an action was completed successfully? Or is checking if a position changed or smth like that always better? Since there are some downsides to the onMessage approach however, as I need fields and setters to transfer information between onMessage and onLoop, so I think Khal's solution is better. BTW @Khaleesi, I'm not sure myPosition().getZ() != prevPos.getZ() Will work in my case, since the dungeon I'm entering through the trapdoor has the same z-coordinate as the surface somehow. Also, won't RS2Object trapDoor = getObjects().closest("Trapdoor"); if (trapDoor != null) { if (trapDoor.hasAction("Open")) { if (trapDoor.interact("Open")) { new ConditionalSleep(7000) { @Override public boolean condition() { return trapDoor.hasAction("Climb-down"); } }.sleep(); } This snippet of code generate the same problem I experienced before? Since the closed trapDoor has another Object ID than the open trapdoor, return trapDoor.hasAction("Climb-down"); will always return False right? Thanks for the respones guys, appreciate it
  14. Thanks for the response Apa! I was assuming that one onLoop call would be a whole execution of the script (Say smithing 1 inventory of bars, Onloop call: bank - smith bars - bank. Next Onloop call: bank-smith bars - bank, and so on. If I get what you're saying, every call to onLoop is one single game interaction? Does this also apply to simpler game interactions, like walkpaths? (Assuming they don't fail too often?) You're saying: "It seems that the particular object you are interacting with changes after interacting with it - this is not the case for all objects, but appears to be the case here." The object id in the debugger of OSbot indeed changes when opening and closing the trapdoor, so I guess that's something I should look out for. Probably could also even check this with code? I was also thinking about adding a conditional sleep until trapdoor is open. But I'm not sure how to achieve such a thing; I tried to Conditional sleep untill my character was no longer animating (from opening the trapdoor) but am not sure if this is the right way to go; as in are there better ways to conditional sleep or is conditional sleeping on character animation generally a good way to go? hope you don't mind the questions, am new and willing to learn! Thx
  15. Thank you bro-beans! Knew I was overlooking something. For future readers; here is a solution in code; RS2Object closed_trapdoor = getObjects().closest("Trapdoor"); if (closed_trapdoor != null && closed_trapdoor.interact("Open")) { log("If was executed"); MethodProvider.sleep(7000); log("Sleep was executed"); RS2Object open_trapdoor = getObjects().closest("Trapdoor"); open_trapdoor.interact("Climb-down"); log("Tried to climb-down"); }
  16. Dear forum, I'm quite new to scripting and even though I'm decent in JAVA, it's been a while and I am not sure about the following behavior. I am trying to open a trap door and climb down. To that end, I'm using the following code: @Override public int onLoop() throws InterruptedException { RS2Object trapdoor = getObjects().closest("Trapdoor"); if (trapdoor != null && trapdoor.interact("Open")) { log("If was executed"); MethodProvider.sleep(7000); log("Sleep was executed"); trapdoor.interact("Climb-down"); log("Tried to climb-down"); } return 0; } It doesn't matter if I put the trapdoor.interact("Climb-down"); inside or outside the if-statement - it never seems to execute. Even though all my log messages are printed to the bot log! Opening the trapdoor goes perfectly every time. Can somebody explain to me why this is happening? Also, what would be a more "fool-proof" way of opening/climbing down a trapdoor? I was maybe thinking of adding a conditional sleep, or some kind of check to see whether the "climb down" action was successful but so far I haven't been able to come up with an elegant solution. But first I need to understand why such a simple behavior causes problems Any help is greatly appreciated
  17. Hey Khaleesi, Any chance I could get a trial? Cheers!
×
×
  • Create New...