Antiban¶
Methods to handle antiban.
TAntiban¶
Main record to handle the built-in WaspLib antiban.
Antiban.AddTask¶
procedure TAntiban.AddTask(method: TAntibanMethod; interval: Double; randomness: Double = 0.2);
Schedule a antiban task. An antiban task can be any procedure but they should be short actions that won’t break your main script.
method is a pointer to the task you want to perform. WaspLib includes a couple of them but you may make your own if you want.
interval is the aproximate interval of time that has to pass for the antiban
task to occur and it will be repeated everytime that the interval has passed
and the antiban is checked with Antiban.DoAntiban.
This task will only occur when TAntiban.DoAntiban is called.
Example:
Antiban.AddTask(@Antiban.HoverSkills, 15 * ONE_MINUTE); //Every 15 minutes the script will run Antiban.HoverSkills().
Antiban.AddBreak¶
procedure TAntiban.AddBreak(interval, length: Double; randomness: Double = 0.2; logoutChance: Double = 0.33);
Schedule a break. Breaks can be of short or medium length and should be shorter than any sleep breaks.
interval is the aproximate interval of time that has to pass for the break to
occur and it will be repeated everytime that interval passes and the antiban is
checked either with Antiban.DoBreak or Antiban.DoAntiban.
length, randomness and logoutChance are the same as Antiban.AddSleep.
This break will only occur when Antiban.DoAntiban is called.
Example:
Antiban.AddBreak(30 * ONE_MINUTE, 5 * ONE_MINUTE); //Every 30 minutes the script will take a 5 minute break, subject to variance from the randomness variable.
Antiban.AddSleep¶
procedure TAntiban.AddSleep(time: String; length: Double; randomness: Double = 0.1; logoutChance: Double = 0.5);
Schedule a sleep break. A sleep break is a large break, it can be any length but it’s usually the several hours and also the largest one/ones.
time is the aproximate time you want the break to occur and should be written
in a “bare” time format (00:00:00) which is a 24H format.
length is how long we will sleep for in milliseconds.
randomness is self explanatory, gives variance to the time our script will
sleep at and it’s length too.
One thing to keep in mind is that randomness only affects time past time.
In other words, you will never sleep before time.
logoutChance is the probability of logging out for the sleep break or to
simply afk and logout from inactivity.
This sleep break will only occur when Antiban.DoAntiban is called and our sleep break is due.
Example:
Antiban.AddSleep('01:30:45', 8 * ONE_HOUR, 0.1, 0.8); //At 01:30:45 on our computer time the script will take a break for 8 hours, subject to variance from the randomness variable.
Antiban Callbacks¶
TAntiban has the following callbacks to handle specific antiban events (Task/Break/Sleep):
OnStartTask, OnFinishTask: procedure(task: PAntibanTask) of object;
OnStartBreak, OnFinishBreak: procedure(task: PBreakTask) of object;
OnStartSleep, OnFinishSleep: procedure(task: PSleepTask) of object;
OnBreaking: procedure(task: PBreakTask; var countdown: TCountdown) of object;
OnSleeping: procedure(task: PSleepTask; var countdown: TCountdown) of object;
Their names are self explanatory when you understand them but:
OnStartcallbacks are ran only once per event at the start.OnFinishcallbacks are ran only once per event at the end.OnBreakingcallbacks are ran every 5 seconds during aBreakevent.OnSleepingcallbacks are ran every 5 minutes during aSleepevent.
The usage of these is up to your creativity and they can be very useful for things like:
Letting you know an event has started or finished. This can be useful if you need to go to a safe place before you go on a break for example.
Doing misc tasks during breaks or sleeps, for example, you could have a script occasionally hover stats during a break. Or login and do stuff during sleeps. You could for example, have a timer on your script for farm runs and login during a break or sleep to do the farm run and log back out.
Example usage from Wasp Wintertodt which walks you to safety before breaks and sleeps:
procedure TWintertodt.SafeBreak(task: PBreakTask);
begin
if not RSClient.IsLoggedIn() then
Exit;
if not Self.HallTiles.Contains(Map.Position()) then
Map.Walker.WebWalk(Self.HallTiles.RandomPoint(), 8, 0.2);
end;
procedure TWintertodt.SafeSleep(task: PSleepTask);
begin
if not RSClient.IsLoggedIn() then
Exit;
if not Self.HallTiles.Contains(Map.Position()) then
Map.Walker.WebWalk(Self.HallTiles.RandomPoint(), 8, 0.2);
end;
procedure TWintertodt.Init();
begin
//...
//...
Antiban.OnStartBreak := @Self.SafeBreak;
Antiban.OnStartSleep := @Self.SafeSleep;
//...
Self.HallTiles := [6508, 34490, 6532, 34514];
//...
end;
With the code above accounts will always walk to safety at the start of breaks and sleeps if they are logged in.
Antiban.TakeBreak¶
procedure TAntiban.TakeBreak(var task: TBreakTask);
Internal function used by Antiban.DoAntiban and is responsible for
performing the specified break task.
In other words, this is what makes the script take the break.
Antiban.TakeSleep¶
procedure TAntiban.TakeSleep(var task: TSleepTask);
Internal function used by Antiban.DoAntiban and is responsible for
performing the specified sleep task.
In other words, this is what makes the script take the sleep break.
Antiban.DoTask¶
function TAntiban.DoTask(): Boolean;
Checks for scheduled antiban tasks, if any is due it will do it.
You should only call this when taking doing an antiban task won’t break your script.
Returns true if a task was performed.
Example:
Antiban.DoTask();
Antiban.DoBreak¶
function TAntiban.DoBreak(): Boolean;
Checks for scheduled breaks, if any is due it will take it.
You should only call this when taking a break won’t break your script.
Returns true if a break was taken.
Example:
Antiban.DoBreak();
Antiban.DoSleep¶
function TAntiban.DoSleep(): Boolean;
Checks for scheduled sleep breaks, if any is due it will take it.
You should only call this when taking a sleep break won’t break your script.
Returns true if a sleep break was taken.
Example:
Antiban.DoSleep();
Antiban.DoAntiban¶
function TAntiban.DoAntiban(checkTasks, checkBreaks, checkSleeps: Boolean = True): Boolean;
This should be called in your script when antiban sleeps, breaks or tasks won’t break your script.
When this is called, the setup sleep breaks, breaks and tasks will be checked, if enough time has passed to perform any of them (subject to the parameters you pass in too), they will be performed, otherwise, nothing will happen.
Example:
Antiban.AddTask(15 * ONE_MINUTE, @Antiban.HoverSkills);
while True do //Infinite loop
Antiban.DoAntiban(); //Antiban.HoverSkills will be called every time 15 minutes passed when this is called.
Antiban.TimeUntilBreak¶
function TAntiban.TimeUntilBreak(constref task: TBreakTask; fmt: String = TIME_FORMAL): String;
Returns a string of how much time is left until the specified break task
should be taken.
Useful to show information to users.
Antiban.TimeUntilSleep¶
function TAntiban.TimeUntilSleep(constref task: TSleepTask; fmt: String = TIME_FORMAL): String;
Returns a string of how much time is left until the specified sleep break task
should be taken.
Useful to show information to users.
Antiban.SimulateBreaks¶
procedure TAntiban.SimulateBreaks(bottingDays: UInt64 = 1000);
Performs a simulation of bottingDays amount of days with the currently setup
breaks and prints the results.
Example
Antiban.AddBreak(30 * ONE_MINUTE, 5 * ONE_MINUTE);
Antiban.SimulateBreaks();
Antiban variable¶
Global TAntiban variable.