Jump to content

Reveance

Members
  • Posts

    108
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by Reveance

  1. 17 minutes ago, mskod said:

     

    So if i use:

    gRandom(50,10,0,100)

    50 - mean

    10 - stdDeviation

    0 - min number

    100 - max number

     

    Will i get random numbers from 0 - 100, but mainly they will be from 40-60?

    You switched one param as mean is the second one, but correct :P... so gRandom(10, 50, 0, 100). This will result in the heigest chance to roll between 40 and 60. 99.7% of the values will lie between 20 and 80.

    It might be easier to use gRandomBetween though, this automatically calculates the mean and deviation so that the above example would be equivalent to gRandomBetween(20, 80) with the difference of having a cap between 20, 80 instead of 0, 100

    • Like 1
  2. 9 minutes ago, Vilius said:

    Thats the whole point of having super classes, that they have their own custom methods. What you can do is overload the methods to have diff params depending on the entities super class.

    Correct, however overloading his method won't work in this case since he'll first need to cast to whatever more specific object it is first, before calling the method, in order for that to work.

    I think the easiest solution, especially as you only have like 3 or 4 instances to check, would be to use instanceof. I doubt you'd want something fancier in this case...

  3. Entity is an interface...so you could easily check what object you're dealing with:

    entity instanceof Player
    entity instanceof RS2Object

    But why are you getting entities in the first place? Why not use the Players, Objects classes to get the entities you want instead?

  4. It doesn't click because you're wasting your index on moving to the slot :P then the next loop it will come in the first else again, moving to the next...but the first if statement never gets executed...
     

    for (i = 0; i < 28; i++) {
    	if (InventorySlotDestination.getSlot(i).contains(getMouse().getPosition())) {
    		//...never gets in here, because this is the next slot...why would the mouse already be there?
    	} else {
    		//...always executes this to move to the next
    	}
    }

    so basically you want something like

    for (i = 0; i < 28; i++) {
    	if (!InventorySlotDestination.getSlot(i).contains(getMouse().getPosition())) {
    		Rectangle rect = InventorySlotDestination.getSlot(i);
    		if (getMouse().move(rect.x + (rect.width / 2), rect.y + (rect.height / 2))) {
    			sleep(random(100, 125));
    		}
    	}
    
    	if (InventorySlotDestination.getSlot(i).contains(getMouse().getPosition())) {
    		if (getMouse().click(false)) {
    			// i++; this one isn't necessary unless you want to skip
    			// items
    			sleep(random(100, 125));
    		}
    	}
    }

    But anyways, as Stimpack already said, it's easier to let the osbot api do all that for you by using 

    getMouse().click(getInventory().getMouseDestination(i))
  5. gRandom is broken, if you want to use a random with normal distribution you can use 

    But yeah, gRandom uses normal distribution which is one random distribution that very simplified basically gives more chance to numbers around the center (mean) and the deviation says how wide the field of more chance is :p. Normal random uses uniform distribution which means there's an even chance for every number

     

    • Like 2
  6. The most important thing to understand with threads is that they run concurrently. Imagine you have a program that has a GUI with a button in it. If the button is pressed and you'd execute some heavy calculation (or wait for something) in the same thread (the GUI is running on and being repainted in) ... the whole application would go unresponsive. By using another thread to do the calculation it will keep responsive. It's generally much better to work with Runnables instead of threads as it's much more flexible. Also look up ExecutorService to run them properly.

    • Like 1
  7. Yes, if you want to communicate with multiple accounts you should have one server application that is using ServerSocket, like Token said. You can then use Socket to connect to that server application (hosted on some server) in which you wanna have logic that can relay a message to the client you want. E.g. Client1 -> Server -> Client2. I'd probably use some small framework though, that already handles all connections etc. otherwise it's pretty time consuming to write. You could use kryonet for this in which you want to send with TCP, or you can use another protocol entirely, called websocket (which is especially useful if you ever want to build a webinterface around it): https://github.com/TooTallNate/Java-WebSocket

    • Like 1
  8. 50 minutes ago, Imateamcape said:

    Read my last post back. Conceded the integer point because I thought that was a reasonable argument, though a lot of the remainder of the code is extra.

    Ah okay, I thought you were only talking about casting the ints since you only mentioned the integer methods and because tbh what else is there? :"D The only thing left then is the min max check

    • Like 1
  9. 13 minutes ago, Imateamcape said:

    This was what I already had, only added in a couple more methods. All of Most of the extra work that you currently have is unnecessary.

    Edit: I'd be willing to concede the integer methods (note: wrote this in 2 minutes like i said in my post), though the vast majority of your code is extra.

    It's not really unnecessary though...your between methods return integers outside of the min and max values specified. But tbh I think I just don't really understand why you posted it in the first place then

  10. 51 minutes ago, Imateamcape said:

    Random r = new Random();

    public double gRandom(double mean, double standardDeviation) {

                return r.nextGaussian()*standardDev + mean; //Regarding the 68-95-99.7 rule, r.nextGaussian() does all of that work for you. All you need is the shift.

    }

    public int gRandomInt(int mean, int standardDeviation) {

           return (int)gRandom(mean, standardDeviation);

    }

    public double gRandomBetween(double min, double max) {

             return gRandom((max+min)/2.0, (max-min)/6.0);

             //Puts the mean between the max and the min, will only get values within 99.7% of the distribution

    }

    public int gRandomBetweenInt(int min, int max) {

           return (int)gRandomBetween(min, max);

    }

    If I've made a mistake in any of these, someone correct me because I wrote these in like a few minutes, but these should work.

    I wouldn't recommend using that code since basically all the important stuff from the class I posted is stripped off...

    Your command regarding the 68-95-99.7 rule doesn't make sense, since the rule is only used for capping the value, which your method does not do. In theory you could get an infinite wait with your method which you do not want in regards to botting. 

    Then the way in which you convert to int by casting is horrible in this scenario...since casting a double to an int is always rounding down, so 5.9 will become 5. This means you will have a more likely chance to get min and you'll almost never get max since it has to be exactly max as a double. 

  11. 6 minutes ago, Alek said:

    If you didn't set a conditional sleep recheck time, the docs said it was centered around 25 ms. It was actually always at 20 ms and the sleep time which you set was randomized. Sometimes the sleep times you defined would go negative, therefore not sleeping at all. It was actually an issue I discovered with low cpu + grand exchange. 

    Awesome, you might have fixed a whole lot with that discovery :D

    • Like 1
  12. This is a class containing the 'what would have been' gRandom's replacement that was mostly created by @Alek following my bug report. I figured I'd share it as a snippet so it's easier to find in case people need it, since Alek just announced a new release in which it is deprecated because of it not functioning correctly and too many dependencies on it to fix.

    Code:

     
    
    import java.util.Random;
    
    public class RandomUtil {
    
    	private Random random;
    
    	public RandomUtil() {
    		this(new Random());
    	}
    
    	public RandomUtil(Random random) {
    		super();
    		this.random = random;
    	}
    
    	/**
    	 * Generates a random integer with normal distribution using the supplied
    	 * deviation and mean with a cap based on the 68–95–99.7 rule
    	 * 
    	 * @param stdDeviation
    	 * @param mean
    	 * @return integer A random integer with normal distribution using the
    	 *         supplied deviation and mean capped based on the 68–95–99.7 rule
    	 */
    	public int gRandom(int stdDeviation, int mean) {
    		return Math.toIntExact(Math.round(gRandom((double) stdDeviation, (double) mean)));
    	}
    
    	/**
    	 * Generates a random integer with normal distribution using the supplied
    	 * deviation and mean with a custom cap
    	 * 
    	 * @param stdDeviation
    	 * @param mean
    	 * @param minCap
    	 * @param maxCap
    	 * @return integer A random integer with normal distribution using the
    	 *         supplied deviation and mean capped by supplied values
    	 */
    	public int gRandom(int stdDeviation, int mean, int minCap, int maxCap) {
    		return Math.toIntExact(
    				Math.round(gRandom((double) stdDeviation, (double) mean, (double) minCap, (double) maxCap)));
    	}
    
    	/**
    	 * Generates a random double with normal distribution using the supplied
    	 * deviation and mean with a custom cap
    	 * 
    	 * @param stdDeviation
    	 * @param mean
    	 * @param minCap
    	 * @param maxCap
    	 * @return double A random double with normal distribution using the
    	 *         supplied deviation and mean capped by supplied values
    	 */
    	public double gRandom(double stdDeviation, double mean, double minCap, double maxCap) {
    		double result;
    		do {
    			result = random.nextGaussian() * stdDeviation + mean;
    		} while (result < minCap || result > maxCap);
    
    		return result;
    	}
    
    	/**
    	 * Generates a random double with normal distribution using the supplied
    	 * deviation and mean with a cap based on the 68–95–99.7 rule
    	 * 
    	 * @param stdDeviation
    	 * @param mean
    	 * @return double A random double with normal distribution using the
    	 *         supplied deviation and mean capped based on the 68–95–99.7 rule
    	 */
    	public double gRandom(double stdDeviation, double mean) {
    		double max = stdDeviation * 3; // 68–95–99.7 rule
    
    		double result;
    		do {
    			result = random.nextGaussian() * stdDeviation + mean;
    		} while (Math.abs(result - mean) > max);
    
    		return result;
    	}
    
    	/**
    	 * Returns a random integer based on normal distribution between two
    	 * integers
    	 * 
    	 * @param min
    	 *            Minimum integer (inclusive)
    	 * @param max
    	 *            Maximum integer (inclusive)
    	 * @return An integer between min and max (inclusive)
    	 */
    	public int gRandomBetween(int min, int max) {
    		return Math.toIntExact(Math.round(gRandomBetween((double) min, (double) max)));
    	}
    
    	/**
    	 * Returns a random double based on normal distribution between two doubles
    	 * 
    	 * @param min
    	 *            The minimum double (inclusive)
    	 * @param max
    	 *            The maximum double (inclusive)
    	 * @return A double between min and max (inclusive)
    	 */
    	public double gRandomBetween(double min, double max) {
    		if (max - min == 0) {
    			return 0;
    		} else if (max - min < 0) {
    			min += (max - (max = min));
    		}
    
    		double deviation = (max - min) / 6d;
    		double mean = (max - min) / 2d + min;
    
    		return gRandom(deviation, mean);
    	}
    
    	public Random getRandom() {
    		return random;
    	}
    
    	public void setRandom(Random random) {
    		this.random = random;
    	}
    
    }

     

    Usage:

    RandomUtil randomUtil = new RandomUtil();
    
    randomUtil.gRandomBetween(200, 800);
    // Is the same as
    randomUtil.gRandom(100, 500);

    • Like 2
  13. 32 minutes ago, Final said:

    That's because that API method is more of a 'helper method', it's a method containing specific logic for a specific task, that method more than likely has overlooked logic. In addition, it's not going to be repeatedly checked by looping through the same conditions because you only call it once and that'd just add more complexity to the method itself. Chances are it relies upon each action actually occurring such as successfully opening the Grand Exchange or not.

    You should design your logic in such a way that if something was to fail, it wouldn't matter since it'd just attempt this task again without it conflicting with future tasks which rely on it's success.

    Obviously low-cpu means clicking methods are likely to fail, because destinations are dynamically changing in real-time, let's say you are running and your target NPC is moving, you are going to have a hard time interacting with it because the screen location of that NPC is constantly changing. Some methods such as this rely on Runescape visually, as opposed to a stored value within Runescape.

    Yeah alright, that's true and I do try to design my logic in such ways .. but I was hoping I could still use some api methods :'D I mean it doesn't do too much and if it fails it's still quite easy to manage that. But I suppose that there's indeed something overlooked...will just wait until that thread gets updated for now :p

  14. 12 minutes ago, Final said:

    This is more of a logic issue if anything, it seems you guys may be over complicating it. Never had an issue with the low CPU mode.

    Idk, it might be in this case...but 

    That is literally one method call to the API displaying the same behaviour. Is there a way to execute something on the game thread? I don't think Script#paint runs on the game thread does it?

  15. 6 minutes ago, The Undefeated said:

    That's actually Task-based, not States right?

    I made my own ghetto buy Method for temp use, is not that hard to do.

     

    :gnome:

     

     Script is working so gonna take my time to clean up all. Maybe I'll switch to Task-based instead of States. 

     

    Sorry yeah I think Task-based is correct. I believe they also used to call it Node-based or sth a while back

  16. 1 hour ago, The Undefeated said:

    I'll try on improving that. But I'm pretty sure it will take too many if else statements in my script.

     

     

    What Apaec said :p the way I do this is by making some state based classes that have a condition and an execute method which are evaluated and if true, run, in the script loop, then doing it like pretty much like this:

    BankWalker
    condition -> !inventory.contains("Coins") && !Banks.LUMBRIDGE_UPPER.contains(script.myPosition())
    execute -> script.getWalking().webWalk(Banks.LUMBRIDGE_UPPER);
    
    BankOpener
    condition -> !inventory.contains("Coins") && Banks.LUMBRIDGE_UPPER.contains(script.myPosition()) && !bank.isOpen()
    execute -> bank.open(); sleep until open
    
    BankHandler
    condition -> bank.isOpen() && bank.contains("Coins")
    execute -> bank.withdrawAll("Coins");
    
    ScriptStopper -> bank.isOpen() && !bank.contains("Coins") && !inventory.contains("Coins")
    execute -> script.stop(false);

    That way you can also easily add other 'States' that take priority over others and I believe it's generally less error prone

    But even though this might be the cause in this case, the GrandExchange#buyItem does also have some issues that are almost identical to this in terms of repetition and weird behaviour :p

  17. I have to leave a review here since I recently came back to OSBot and this is the first script I bought :P...this script has come a long way since late 2014 when I bought it (sorry for never replying back on your request back then :\)! Great job on this Apaec :) it hasn't gotten stuck once since I started using it a few weeks ago, pretty much flawless :) ty!

    • Like 1
  18. 1 minute ago, The Undefeated said:

    Isn't there an option when ConditionalSleep reaches timeout it will repeat method x and checks again if the condition is true in a loop?

     

    You're already in your script loop, so I think the best thing to do would be to make solid conditions for that step to be executed, and if the timeout expires and it didn't get the sleep condition to true, you should return and the next iteration of the script loop would go to that method again since the conditions for that 'task' are still true as it didn't finish it. But for this it would also be better to add a failsave :P so it doesn't keep continuing the whole time

  19. 11 minutes ago, Slut said:

    It honestly doesn't end up in an infinite loop ever, I've ran scripts for over 24 hours with that banking method and it doesn't get stuck, also I suck at utilizing the onLoop's loop. To your dismay I use those sort of loops to retry all my actions that could have a miss-click or something of the sort.

    But it could, because there's no timeout and that's not something you really want :p The ConditionalSleep has the same behaviour, is well tested and adds a timeout.

    But anyways OT: I doubt it has something to do with the conditional sleeps and stuff, since I think we can expect the API to use those aswell... there's all sorts of weird stuff happening when low CPU, but maybe Apaec has the pointed the right direction? Could it be that when low FPS, the thread that handles the conditions gets called multiple times causing multiple things to queue up of the same thing in the eventexecutor or sth?

  20. I have no proof however injection or reflection isn't that hard to detect, so it can really only be an improvement in that aspect... Also I doubt that they'd put all the time in developing such a system (creating and maintaining it) aside their injection, without it being a (substantial) improvement in terms of detectability. But I suppose it mostly depends on what you want to do with it; botting an important account -> you can't really lose by botting it on mirror mode compared to the other methods. The only thing is that it's more resource hungry and it seems to have troubles with some stuff. Should Jagex ever get a more absolute id of the client (I heard they do know if you're playing on modified client) then at least you are on a different ID as most of the gold farmers, who generally don't want to waste resources on the chance of that to come true :P

  21. Mirror mode is definitely no standard Java reflection but yeah, I don't think OSBot supports that. But mirror mode is safer than reflection or injection anyways, so why the specific need for reflection?

×
×
  • Create New...