mirror of
https://github.com/bdnugget/IdleRSC.git
synced 2026-11-07 07:57:27 +00:00
Small bug fixes
* Ignore exceptions when loading the account properties file, handle with smaller error checking. (there is already a fallback process). * mudclient move sleep counter below other bot paint elements to prevent overlap * Slow down multiple bot loading. * Copy hashes.properties from the jar to assets folder (if missing) * Fix fatigue alignment in the client Clean up autologin code * This implementation uses timers (checking system time) instead of controller.sleep() which may have been causing bugs for very long sleep times when client could not connect. This is also much cleaner and safer in edge cases. Waiting for autologin time has been slightly shortened.
This commit is contained in:
1 parent
7e063a2979
commit
1448d5f086
9 files changed
+60
-72
No files matched your search
@@ -60,3 +60,5 @@ pages:
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
|
||||
# TODO - upload readme and doc to wiki https://gitlab.com/open-runescape-classic/idlersc/-/wikis/pages
|
||||
@@ -420,8 +420,9 @@ public class Main {
|
||||
log("WindowListener started.");
|
||||
|
||||
// give everything a nice synchronization break juuuuuuuuuuuuuust in case...
|
||||
Thread.sleep(800);
|
||||
Thread.sleep(1000);
|
||||
|
||||
controller.login();
|
||||
// start up our listener threads
|
||||
log("Initializing LoginListener...");
|
||||
loginListener = new Thread(new LoginListener(controller));
|
||||
@@ -444,6 +445,7 @@ public class Main {
|
||||
DrawCallback.setNextRefresh( // was 25k
|
||||
System.currentTimeMillis() + 25000L + (long) (Math.random() * 10000));
|
||||
}
|
||||
|
||||
// System.out.println("Next screen refresh at: " + DrawCallback.getNextRefresh());
|
||||
while (true) {
|
||||
if (isRunning()) {
|
||||
@@ -711,6 +713,10 @@ public class Main {
|
||||
resetXpButton.addActionListener(e -> DrawCallback.resetXpCounter());
|
||||
showIdButton.addActionListener(e -> controller.toggleViewId());
|
||||
takeScreenshotButton.addActionListener(e -> controller.takeScreenshot(""));
|
||||
autoLoginCheckbox.addActionListener(
|
||||
e -> {
|
||||
if (autoLoginCheckbox.isSelected()) controller.login();
|
||||
});
|
||||
graphicsCheckbox.addActionListener(
|
||||
e -> {
|
||||
if (controller != null) {
|
||||
|
||||
@@ -162,8 +162,11 @@ public class CLIParser {
|
||||
p.getProperty("help", "").replace(" ", "").toLowerCase().contains("true"));
|
||||
parseResult.setVersion(
|
||||
p.getProperty("version", "").replace(" ", "").toLowerCase().contains("true"));
|
||||
} catch (final Throwable t) {
|
||||
System.out.println("Error loading account " + parseResult.getUsername() + ": " + t);
|
||||
} catch (Exception ignore) {
|
||||
if (!accountName.equalsIgnoreCase("username") && !accountName.isEmpty()) {
|
||||
System.out.println("Error loading account - " + accountName);
|
||||
System.out.println(accountName + ".properties file does not exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class DrawCallback {
|
||||
y += 14;
|
||||
if (c.isAuthentic()) { // hidden on coleslaw so that submenu ON, Npc Kill counts ON can show
|
||||
// Kill counter at that screen location! Uranium will still get fatigue.
|
||||
c.drawString("Fatigue: " + fatigue + "@red@%", 7, y, 0xFFFFFF, 1);
|
||||
c.drawString("Fatigue: " + fatigue + "@red@%", 7, 202, 0xFFFFFF, 1);
|
||||
}
|
||||
y += 14;
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ public class SleepCallback {
|
||||
private static boolean checkAssetFiles() {
|
||||
File sleepDirectory = new File("assets" + File.separator + "sleep");
|
||||
File[] sleepFilelist = sleepDirectory.listFiles();
|
||||
String[] fileNames = {"dictionary.txt", "model.txt"};
|
||||
String[] fileNames = {"dictionary.txt", "model.txt", "hashes.properties"};
|
||||
if (sleepFilelist != null) {
|
||||
if (sleepFilelist.length != 2) return false;
|
||||
String[] sleepNames = new String[sleepFilelist.length];
|
||||
@@ -390,6 +390,16 @@ public class SleepCallback {
|
||||
"/assets/sleep/model.txt",
|
||||
"." + File.separator + "assets" + File.separator + "sleep" + File.separator + "model.txt",
|
||||
SleepCallback.class);
|
||||
copyResource(
|
||||
"/assets/sleep/hashes.properties",
|
||||
"."
|
||||
+ File.separator
|
||||
+ "assets"
|
||||
+ File.separator
|
||||
+ "sleep"
|
||||
+ File.separator
|
||||
+ "hashes.properties",
|
||||
SleepCallback.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
|
||||
@@ -11,7 +11,8 @@ import controller.Controller;
|
||||
* @author Dvorak
|
||||
*/
|
||||
public class LoginListener implements Runnable {
|
||||
private static long loginCount = 0;
|
||||
private static double loginCount = 0;
|
||||
private static double sleepTime = 0.0;
|
||||
private final Controller controller;
|
||||
|
||||
public LoginListener(Controller _controller) {
|
||||
@@ -25,65 +26,32 @@ public class LoginListener implements Runnable {
|
||||
|
||||
if (Main.isAutoLogin()) {
|
||||
if (!controller.isLoggedIn()) {
|
||||
controller.log("Logged out! Logging back in...");
|
||||
controller.login();
|
||||
controller.sleep(640);
|
||||
/*
|
||||
* Math.random returns value between 0.0 and 1.0
|
||||
*
|
||||
* <p>for the following: (Math.random() * (30000)) + 30000; thus Max Sleep was 60
|
||||
* seconds and Min Sleep was 30 seconds
|
||||
*
|
||||
* <p>This MIGHT be causing connection issues with extended downtimes and large bot
|
||||
* counts on one computer.
|
||||
*
|
||||
* <p>Suggested Values calculated with Excel Spreadsheet, Available from Kaila at
|
||||
* request. Suggested change: Math.random() * 30000) + (((i * 15)/(i + 60)) * 30000) +
|
||||
* 30000
|
||||
*
|
||||
* <p>bot will slowly ramp up to 5 min delays after several hrs of no reconnect, anding
|
||||
* the cycle after 12-14 hrs and repeating
|
||||
*
|
||||
* <p>First 5 tries - Original Behavior, Min Sleep is 30 seconds and Max Sleep is 60
|
||||
* seconds After 6 tries (After 2.5 to 5 mins) - Min Sleep is 57 seconds and Max Sleep
|
||||
* is 87 seconds (0.95 to 1.45 mins each cycle) After 15 tries (After 11 to 18 mins) -
|
||||
* Min Sleep is 90 seconds and Max Sleep is 120 seconds (1.5 to 2 mins each cycle) After
|
||||
* 30 tries (After 33.5 to 48 mins) - Min Sleep is 130 seconds and Max Sleep is 160
|
||||
* seconds (2.1 to 2.7 mins each cycle) After 60 tries (After 1.5 hrs to 2 hrs) - Min
|
||||
* Sleep is 180 seconds and Max Sleep is 210 seconds (3 to 3.5 mins each cycle) After
|
||||
* 120 tries (After 4.6 hrs to 5.5 hrs) - Min Sleep is 230 seconds and Max Sleep is 260
|
||||
* seconds (3.8 to 4.3 mins each cycle) After 240 tries (After 12.2 hrs to 14 hrs) - Min
|
||||
* Sleep is 270 seconds and Max Sleep is 300 seconds (4.5 to 5 mins each cycle)
|
||||
*
|
||||
* <p>then it resets timer and repeats ramping up cycle...
|
||||
*
|
||||
* <p>~ Kaila ~
|
||||
*/
|
||||
if (!controller.isLoggedIn()) {
|
||||
int i = (int) loginCount;
|
||||
int sleepTime = (int) ((Math.random() * 20000) + 60000);
|
||||
if (loginCount > 10) {
|
||||
sleepTime = sleepTime + (((i * 30) / (i + 60)) * 30000);
|
||||
}
|
||||
int sleepTimeInSeconds = sleepTime / 1000;
|
||||
controller.log(
|
||||
"Looks like we could not login... trying again in "
|
||||
+ sleepTimeInSeconds
|
||||
+ " seconds...",
|
||||
"cya");
|
||||
controller.sleep(sleepTime);
|
||||
if (System.currentTimeMillis() > sleepTime) {
|
||||
controller.log("Logged out! Logging back in...");
|
||||
controller.login();
|
||||
loginCount++;
|
||||
} else loginCount = 0;
|
||||
}
|
||||
controller.sleep(640);
|
||||
// calc the next login time
|
||||
if (loginCount > 10)
|
||||
sleepTime =
|
||||
System.currentTimeMillis() + (((loginCount * 30) / (loginCount + 60)) * 20000);
|
||||
else
|
||||
sleepTime =
|
||||
System.currentTimeMillis() + ((Math.random() * 20000 * loginCount) + 20000);
|
||||
if (!controller.isLoggedIn()) {
|
||||
controller.log(
|
||||
"Looks like we could not login... trying again in "
|
||||
+ (int) ((sleepTime - System.currentTimeMillis()) / 1000)
|
||||
+ " seconds...",
|
||||
"cya");
|
||||
}
|
||||
}
|
||||
} else if (loginCount != 0) loginCount = 0;
|
||||
}
|
||||
|
||||
if (controller.getMoveCharacter()) {
|
||||
if (!controller.isAuthentic() && controller.getMoveCharacter()) {
|
||||
moveCharacter();
|
||||
controller.charactedMoved();
|
||||
}
|
||||
if (controller.isLoggedIn() && loginCount > 0) {
|
||||
loginCount = 0;
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@@ -677,7 +677,7 @@ public class AIOFighter extends IdleScript {
|
||||
else if (message.equals("I can't get a clear shot from here")) {
|
||||
c.setStatus("@red@Walking to NPC to get a shot...");
|
||||
c.walktoNPCAsync(currentAttackingNpc);
|
||||
c.sleep(1280);
|
||||
c.sleep(2400);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -561,8 +561,7 @@ public final class K_NoBank_TavChaos extends K_kailaScript {
|
||||
c.walkTo(377, 520);
|
||||
// check for needing more newts here
|
||||
doHerblawLoop();
|
||||
if (startUp
|
||||
|| (getNewtSecCount() == 0 && c.getInventoryItemCount(ItemId.EYE_OF_NEWT.getId()) > 5)) {
|
||||
if (startUp || (getNewtSecCount() == 0)) {
|
||||
c.atObject(376, 520);
|
||||
c.sleep(1280);
|
||||
c.walkTo(376, 3347);
|
||||
|
||||
@@ -16,31 +16,31 @@
|
||||
TIMEOUT /t 1 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 1st Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 2nd Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 3rd Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 4th Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 5th Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 6th Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 7th Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 8th Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 9th Bot
|
||||
TIMEOUT /t 2 > NUL
|
||||
TIMEOUT /t 5 > NUL
|
||||
start javaw -jar IdleRSC.jar --auto-start --account "name"
|
||||
echo Launched 10th Bot
|
||||
TIMEOUT /t 5
|
||||
Reference in new issue
Block a user