House Posted September 22, 2016 Share Posted September 22, 2016 (edited) What is this? A class which manages timers for delayed actions in a script with a fancy name including SIMULATOR! Why is it useful? Ease of implementation. Flaws? It can only be treated as one timer at a time and can not track multiple delays at a time unless the code is expanded. This is pretty meh but its useful and maybe someone will find it useful when they start out scripting. In tasks such as smithing or other highly afk tasks i think that reaction time to notice inventory completion is important to simulate human like behavior to reduce bans. This sort of "anti-ban" if they even do anything helps break patterns that could be detectable, then again if you have a shitty method to interact with things in the world then it won't save you.Also note that humans are not as random as you think they are and everyone has habits! [updated using suggestions by @PolishCivil] public class HHumanSimulator { //Default time in seconds to wait. private static final int default_min_reaction_time = 5; private static final int default_max_reaction_time = 15; //While active the script will be idle. private static boolean active = false; //Time is saved in milliseconds in here every time a new simulation start. private static long start_time; //The randomly generated wait time in milliseconds in stored here. private static long current_reaction_time; //Check if you can do the task. public static boolean check() { if (!active) { start_time = System.currentTimeMillis(); current_reaction_time = randomReactionTime(default_min_reaction_time, default_max_reaction_time); active = true; } if (System.currentTimeMillis() - start_time > current_reaction_time) active = false; return !active; } //Same as above however this method lets you add your own custom times rather than default. public static boolean check(int new_min_reaction_time, int new_max_reaction_time) { if (!active) { start_time = System.currentTimeMillis(); current_reaction_time = randomReactionTime(new_min_reaction_time, new_max_reaction_time); active = true; } if (System.currentTimeMillis() - start_time > current_reaction_time) active = false; return !active; } //Same as above however lets you set a % chance for it to trigger or not. public static boolean check(int new_min_reaction_time, int new_max_reaction_time, int trigger_chance) { if (!active && trigger(trigger_chance)) { start_time = System.currentTimeMillis(); current_reaction_time = randomReactionTime(new_min_reaction_time, new_max_reaction_time); active = true; } if (System.currentTimeMillis() - start_time > current_reaction_time) active = false; return !active; } //Returns a boolean based on a % chance. private static boolean trigger(int chance) { int rand = ThreadLocalRandom.current().nextInt(101); return rand <= chance; } //Returns the time left till simulation is done. public static long debugTimeLeft() { return current_reaction_time - (System.currentTimeMillis() - start_time); } //Generates a random long between two values. private static long randomReactionTime(int min, int max) { int random_reaction_time = ThreadLocalRandom.current().nextInt((max - min) + 1) + min; return random_reaction_time * 1000L; } } Example Usage: if (!inventory.contains(gold_bar_id)) { if (HHumanSimulator.check(5, 15, 50)) GoldSmither.setState(State.BANK); return; } Edited September 30, 2016 by House 1 Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted September 22, 2016 Share Posted September 22, 2016 Nice! I'm sure some people can make use of this Quote Link to comment Share on other sites More sharing options...
Dog_ Posted September 22, 2016 Share Posted September 22, 2016 why Quote Link to comment Share on other sites More sharing options...
Abuse Posted September 23, 2016 Share Posted September 23, 2016 (edited) Seeing that you have to place poll(5, 15); inside of a loop for it to properly work, it seems like a lot of code per action just to execute a random wait. Edited September 23, 2016 by Abuse 1 Quote Link to comment Share on other sites More sharing options...
House Posted September 23, 2016 Author Share Posted September 23, 2016 Seeing that you have to place poll(5, 15); inside of a loop for it to properly work, it seems like a lot of code per action just to execute a random wait. The point is its straight forward. Quote Link to comment Share on other sites More sharing options...
PolishCivil Posted September 23, 2016 Share Posted September 23, 2016 The point is its straight forward. Change this: HHumanSimulator.poll(5, 15); HHumanSimulator.reactionSimulationDone(); To this HHumanSimulator.check(5, 15); And it will be 3x better. 1 Quote Link to comment Share on other sites More sharing options...