Xx pk xX
Members-
Posts
12 -
Joined
-
Last visited
-
Feedback
100%
Profile Information
-
Gender
Male
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Xx pk xX's Achievements
Newbie (1/10)
5
Reputation
-
You pointed me to right direction, thanks For other people that are interested in that: client.accessor.getScaleZ() ^^ gets perfectly camera Z between 181 and 1448 independently on Camera Pitch and Yaw
-
Hello, is there a way to find out current camera zoom? I can't find anything useful in API for that. I could use widget from Settings Tab, however, I would prefer something without opening Settings tab. Cheers
-
Usually I'm using getInventory().dropAll(itemNames); And it's a lot faster than 45 seconds. Also make sure you have Shift drop enabled in RS settings (settings -> controls -> enable Shift click to drop items).
-
It's getting better and better Adding camera movement: //NPC frog = getNpcs().closest(killArea,"Giant frog","Big frog"); //it's better to use filter here with all conditions that you want for finding frog. //in your code before it would only return frog with correct frog name, however, it might return // you a frog that was already under attack/frog which has hit bar visible. NPC frog = npcs.closest(npc -> (npc.getName().equals("Giant frog") || npc.getName().equals("Big frog")) && !npc.isUnderAttack() && !npc.isHitBarVisible()); { if (frog != null) { //make sure to check if frog is not null if (!frog.isOnScreen()) { if (camera.toEntity(frog)) { //move camera to Frog if it is not on the screen //do something if camera was moved to frog - it should be on screen now } } //if (frog != null && !frog.isUnderAttack() && !frog.isHitBarVisible() && frog.isOnScreen()) { log("DIE! FROG! DIE!"); if (frog.interact("Attack")) { //add a condition to make sure you will call ConditionalSleep only if frog was interacted new ConditionalSleep(5000) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } } } And about logging out when you don't have any Tunas anymore, it's quite simple if (getBank().getAmount("Tuna") == 0) //checks if there is 0 Tunas in bank (you can check for any number, e.g. "< 10" ///less than 10 { log("not enough tuna in bank"); getBank().close(); stop(true); // true to log out, false to stay logged in and just stop script }
-
[Beginner] Trying to run simple miner, it wont even start?
Xx pk xX replied to t0r3's topic in Scripting Help
miningArea has only 2 tiles? Following condition probably won't run - my guess is that player is not in mining area. else if(miningArea.contains(myPosition())){ Just make mining area bigger. Also make sure that copperRocks id's are correct. Then it should run ? -
[Beginner] Trying to run simple miner, it wont even start?
Xx pk xX replied to t0r3's topic in Scripting Help
Also following line private RS2Object copperRocks = getObjects().closest(7484,7453); Should be in your mining() method. private void mining() throws InterruptedException { RS2Object copperRocks = getObjects().closest(7484,7453); if(copperRocks != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ log("Interacting with copperRocks"); copperRocks.interact("Mine"); log("Sleeping a bit before 'going afk'"); sleep(random(1000,1400)); log("Moving mouse outside of screen,'going afk'"); getMouse().moveOutsideScreen(); } } ^^ now it will try to find copperRocks obj always when you run mining() method, not only at start of the script. -
From API: public boolean exists() Checks whether this Entity still exists or not. Returns: Whether this Entity still exists or not. So for example you could call NPC fishingSpot = getNpcs().closest("Fishing spot"); First of all you need to check if it's not null. Calling exists() on null object will throw NullPointerException. Then you can do some actions. However, after running some actions, e.g. interact, wait while animating etc. that fishing spot might "disappear" from RS, so calling if if(fishingSpot.exists()) returns true if the fishingSpot still exists in RS. So as @zwaffel said. Once you know it is not null, you are certain that object is stored in your memory. But as time pass, it will still be in your memory, but it might not exist in RS anymore. That's why you can always use exists() method as well to check that out.
-
If you want to add it to your script, just use: public boolean walkExact(Position position) { WalkingEvent event = new WalkingEvent(position); event.setMinDistanceThreshold(0); return execute(event).hasFinished(); } example of usage: walkExact(tile1); //or if (walkExact(tile1)) { //do Something }
-
Of course you could use something like this for quests if (getDialogues().isPendingOption()) getDialogues().completeDialogue("Option you want to click"); and for the rest: NPC fishingSpot = getNpcs().closest("Fishing spot"); if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving()) { log("Interacting with fishingSpot"); if (fishingSpot.interact("Net")) { //I'm not sure about exact conditions for fishing, but this should work while ((myPlayer().isMoving() || myPlayer().isAnimating()) && fishingSpot.exists()) { //if you want to click continue while you are fishing, then put this condition here if (getDialogues().isPendingContinuation()) { log("Leveled up, clicking continue"); //you don't need if condition here if there is no action you want to do after clicking continue getDialogues().clickContinue(); //but you can do something like this if (getDialogues().clickContinue() && fishingSpot.exists()) { //click fish again after clicking dialog fishingSpot.interact("Net"); } } sleep(MethodProvider.random(50, 500)); } } }
-
while (getDialogues().isPendingContinuation() || getDialogues().isPendingOption()) { getDialogues().clickContinue(); getDialogues().completeDialogue("Option you want to click if there are more options", "another options to click", "another option..."); } If you want to just click continue (e.g. you don't have to choose an option while talking to a NPC), and you are expecting only "Click here to continue" then: while (getDialogues().isPendingContinuation()) { if (getDialogues().clickContinue()) { //click fishing spot again } } Put above code somewhere where you are using sleep condition while your player is fishing (e.g. after/before checking your player.isAnimating() method) For bank depositing just use getBank.deposit methods. I believe widgets are used in banking methods like deposit, withdraw, etc, but you don't need to worry about that. Just use OSBot banking API, and you should be fine (unless you need something really special that's not covered in API).
-
Here's what I'm using to click on exact Position that I want: /**Clicks on exact Position you set in screenClickPos parameter using screen instead of minimap. * If position is not visible on screen, it will walk first to desired position using walking.walk(..) * and then it clicks on screen exact tile. * * @param screenClickPos - Position where you want to walk * @param destPrecision - presition - when should method return - e.g. setting it to 0, will return once player * gets to desired position. Setting to to 2, it will return once you are 2 tiles away (while bot still walking) * @param rightClick - right click mouse instead of left click, and then choose an action from menu * @param rightClickAction - action in menu to click if rightClick is set to true. Can be null if rightClick is set to false * * @return true if bot walked where you wanted (including destPrecision parameter functionality), or false if it for some reason * fail to walk where you wanted **/ public boolean clickExactPosOnScreen(Position screenClickPos, int destPrecision, boolean rightClick, String rightClickAction) { if (!screenClickPos.isVisible(bot)) { walking.walk(screenClickPos); } Point p = centroid(screenClickPos.getPolygon(bot)); if (p!= null && getMouse().click((int) p.getX(), (int) p.getY(), rightClick)) { if (rightClick) Timing.waitCondition(() -> menu.isOpen(), 2000); if (rightClick && menu.isOpen()) { if (!menu.selectAction(rightClickAction)) return false; } //will wait for about 5 seconds until bot gets to the desired position. You can change //it to return sooner if !myPlayer().isMoving() or whatever else you might need new ConditionalLoop(getBot(), 50) { //will wait for about 5 seconds until bot gets to the desired position. You can change //it to check if !myPlayer().isMoving() to return sooner if you want @Override public boolean condition() { return myPosition().distance(screenClickPos) > destPrecision; }; @Override public int loop() { return 100; } }.start(); } if (myPosition().distance(screenClickPos) <= destPrecision) { return true; } return false; } public Point centroid(Polygon polygon) { int centroidX = 0, centroidY = 0; int[] xPoints = polygon.xpoints; int[] yPoints = polygon.ypoints; ArrayList<Point> knots = new ArrayList<Point>(); for(int i = 0; i < xPoints.length; i++) { knots.add(new Point(xPoints[i], yPoints[i])); } for(Point knot : knots) { centroidX += knot.getX(); centroidY += knot.getY(); } return new Point(centroidX / knots.size(), centroidY / knots.size()); } Example of usage: if (clickExactPosOnScreen(walkPosition, 0, true, "Walk here")) { //do someththing } Or in your case, this should be enough (without right mouse click) if (clickExactPosOnScreen(walkPosition, 0, false, null)) { //do someththing } It was tested before, and worked without any problems. However, I just did a few small changes, so let me know if there's a problem with it, and I will fix it. If someone knows about a simpler method to click on EXACT position in OSBot API, please let us know In my experience "setMinDistanceThreshold (0);" does not always click on EXACT tile, idk why.
-
Sorry for some grammar "features" Just a few fast suggestions : import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.util.Arrays; @ScriptManifest(name = "Frogkiller", logo = "", version = 1, author = "Imthabawse", info = "Slaughters frogs for gains!") public class FrogKiller extends Script { //Change to FrogKiller private String[] frogName = { "Giant frog", "Big frog" }; //words "Tuna", "Lobster", "Swordfish" were used in 2 different places/lines - it's better to make a variable for them to avoid duplicitions in code //a lot of duplicitions will make it harder to make changes in the code or to fix bugs in bigger projects private String[] foodNames = { "Tuna", "Lobster", "Swordfish" }; private void killFrog() { if (!myPlayer().isAnimating() && !myPlayer().isMoving() && !myPlayer().isUnderAttack()) { NPC giantFrog = getNpcs().closest(npc -> Arrays.asList(frogName).contains(npc.getName()) && !npc.isHitBarVisible() && !npc.isUnderAttack()); //No need to check again for "if (!myPlayer().isAnimating() && !myPlayer().isMoving() && !myPlayer().isUnderAttack())", you can remove those 3 conditions after finding frog if (giantFrog != null) { log("Condition met.. found targets!"); //targets are found ONLY if giantFrog is not NULL, not before if (giantFrog.interact("Attack")) //check IF giant frog was Attacked succesfully, and then use ConditionalSleep { log("Slaughter time!"); new ConditionalSleep(5000, 1000) { @Override public boolean condition() { return !myPlayer().isUnderAttack() && !myPlayer().isMoving() && !myPlayer().isAnimating(); } }.sleep(); } } } } private void bank() { } private void eatFood() { if(myPlayer().getHealthPercent() < 44) { log("Damn frogs fked me up.. let's eat!"); if (getInventory().contains(foodNames)) //this is uselles call without a condition (IF condition in this case). { if (getInventory().interact("Eat", foodNames)) { //you could put a ConditionalSleep here, maybe attack frog again after eating or something like that } } else //else in this case means inventory does not contain food { log("No food stopping script.."); stop(); } } } private Area killArea = new Area(3187, 3183, 3213, 3157); @Override public void onStart() { log("Let's kill some frogs!"); } @Override public int onLoop() { if(!killArea.contains(myPlayer())) { log("Not in kill area.. lets get there and slaughter more frogs!"); getWalking().webWalk(killArea); }else { if (killArea.contains(myPlayer())) { killFrog(); eatFood(); } } return 1200; } } In Java, you should use following Naming Conventions: for Class name you should use "FrogKiller", with capital "K" (change file name to "FrogKiller" as well if you want to use/compile it) same goes for variable names, e.g. you should use "giantFrog", instead of "giantfrog" First 3 "if" conditions in your "killFrog()" method can be combined to following one line: if (!myPlayer().isAnimating() && !myPlayer().isMoving() && !myPlayer().isUnderAttack()) && operator in a Java condition (and a lot other programming languages) means AND You could use || operator as well, which means OR. However, probably you don't need it yet in your script. Line below is an example of getting a NPC with more conditions in a single call. NPC giantFrog = getNpcs().closest(npc -> Arrays.asList(frogName).contains(npc.getName()) && !npc.isHitBarVisible()); ^^ could contain a lot more conditions that you might want to use for whatever reason, e.g. npc.isUnderAttack() && npc.hasAction("Attack") && //some other conditions I will not go into depth with following condition, however, shortly it means that it will return only NPC with name that is in "frogName" array. Arrays.asList(frogName).contains(npc.getName()) One last thing - you might noticed that I'm putting "{" in new lines. That's the way I'm usually using those "Special brackets" (No idea what's their name) while programming, because in my opinion code is then easier to read. However, standards accept both ways - "{" in new line, or same as you did - in the end of the line before. Hopefully this paragraph make sense lol. I didn't try code in the top of my reply, but is should work. However looks good, for a first working script, keep up good work.