Z3b3e33 0 Share Posted November 8, 2020 Hi guys, Basically I am trying to decide a "random" combat level (between 15 and 30) for my bots to get to. I'd like to select a number from random between 15 and 30 for each bot to level atk/str/def up to. Is there a good way to generate one and store it for the bots lifespan? Thanks -Z Link to comment Share on other sites More sharing options...
Pixel_Life 24 Share Posted November 8, 2020 The script would need to support a 'stop condition' to logout at the given combat level. This wouldn't be something the client would do. Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted November 8, 2020 Sure. Simply assign a value to a variable at script launch that you can refer to as the script progresses. Iirc there's a method in the Calculations class for getting a random value in a range. In regards to what Pixel stated above, you can just return -1 in your loop cycle if a condition is met to stop the program. Link to comment Share on other sites More sharing options...
Pixel_Life 24 Share Posted November 8, 2020 https://dreambot.org/javadocs/org/dreambot/api/methods/Calculations.html#random-int-int- public class TestScript extends AbstractScript { int stopAtLevel; @Override public void onStart() { //On script start generate a random number between 15 to 30 stopAtLevel = Calculations.random(15, 30); } @Override public int onLoop() { //Do your stuff here if (Players.localPlayer().getLevel() >= stopAtLevel) { //return -1 will stop the script from looping //however you probably want to add more checks like to make sure you're not in combat etc. and then logout with Tabs.logout(); return -1; } return 1000; } } Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted November 8, 2020 1 hour ago, Pixel_Life said: https://dreambot.org/javadocs/org/dreambot/api/methods/Calculations.html#random-int-int- public class TestScript extends AbstractScript { int stopAtLevel; @Override public void onStart() { //On script start generate a random number between 15 to 30 stopAtLevel = Calculations.random(15, 30); } @Override public int onLoop() { //Do your stuff here if (Players.localPlayer().getLevel() >= stopAtLevel) { //return -1 will stop the script from looping //however you probably want to add more checks like to make sure you're not in combat etc. and then logout with Tabs.logout(); return -1; } return 1000; } } Link to comment Share on other sites More sharing options...
Just Chill 26 Share Posted November 9, 2020 Maybe I'm missing the point of the post but it seems like you want to persist the random level over multiple sessions, but I don't really understand why? Are you trying to put everything for the accounts in one script or something? If not just use the above suggestions. If you need to persist variable(s), you could store variables in an external file and read it from there. Or you could use the first few letters of the account name and parse them into integers ranging from 15-30, for example: a=15, b=16, ... p=30, q=15, ... 0=15, 1=16, ... Account Name: dr3ambot Attack Level: d = 18 Strength Level: r = 16 Defence Level: 3 = 18 This only works if your accounts generally have random-ish names. This is just one way to solve your problem if it does need to be solved. Link to comment Share on other sites More sharing options...
una_maquina 35 Share Posted November 11, 2020 On 11/9/2020 at 8:05 AM, Just Chill said: Maybe I'm missing the point of the post but it seems like you want to persist the random level over multiple sessions, but I don't really understand why? Are you trying to put everything for the accounts in one script or something? If not just use the above suggestions. If you need to persist variable(s), you could store variables in an external file and read it from there. Or you could use the first few letters of the account name and parse them into integers ranging from 15-30, for example: a=15, b=16, ... p=30, q=15, ... 0=15, 1=16, ... Account Name: dr3ambot Attack Level: d = 18 Strength Level: r = 16 Defence Level: 3 = 18 This only works if your accounts generally have random-ish names. This is just one way to solve your problem if it does need to be solved. Yes, he wants to first get random int variables (which is ez), then store it inside a file and then with every boot, he wants the script to read from the file and have permanent variables, always available. I don't know how to do it in Java syntax though. It's pretty cool stuff, it's good for antiban, as every bot would train to different stats. Link to comment Share on other sites More sharing options...
Z3b3e33 0 Author Share Posted March 10, 2021 Thanks for your replies all of you. I have not made a basic JSON I/O class and generated them with that. The purpose of persisting the levels over multiple sessions is because the script is an AIO account prepper script for a client that has reached the 3000+ lines of code and the levels had to be reffered to over multiple sessions, especially in the accept() of a task. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.