I have encountered another problem, and I would really appreciate some guidance on where to look if anyone could help --
The script currently works to AFK Ammonite Crabs but doesn't perform the antiban properly, and sometimes doesn't recognize that it is still in combat and will use the function I assume that the antiban might have something to do with my use of
Code:
while MainScreen.InCombat() do
begin
while Self.WaitCombat() do
Self.DoAB();
but I'm not exactly sure how to fix it?
For the ResetAggro function, I've tried increasing
Code:
WaitUntil(not MainScreen.InCombat, 35000, 3 * ONE_DAY);
in
Code:
function TScript.WaitCombat: Boolean;
begin
if MainScreen.InCombat then
WaitUntil(not MainScreen.InCombat, 35000, 3 * ONE_DAY);
end;
but still get the same result?
Full script code is below:
Simba Code:
program CrabKiller;
{$DEFINE SRL_USE_REMOTEINPUT}
{$I SRL-F/osr.simba}
var
RSW: TRSWalker;
AGGROEAST: TPoint := [1520, 319];
RESETEAST: TPoint := [1365, 372];
AGGROWEST: TPoint := [1457, 316];
RESETWEST: TPoint := [1351, 397];
AGGRO := AGGROEAST;
RESET := RESETEAST;
const
PNAME = '';
PPASS = '';
PPIN = '';
MAXRUNTIME = 100;
type
TScript = record
ABTimeMod: Int32;
ShutdownTime: Int64;
end;
var
Bot: TScript;
procedure TScript.WriteMsg(Message: String);
begin
WriteLn('[Bot]: ', Message);
end;
procedure TScript.DeclarePlayers();
begin
Login.AddPlayer(PNAME, PPASS, PPIN, []);
end;
(* Some homegrown anti-ban *)
procedure TMouse.RandomMovement();
var
S: Int32;
begin
S := Self.Speed;
Self.Speed := 4;
Self.Move(Box(Mouse.Position, 75, 75), True,);
Self.Speed := S;
end;
procedure TScript.DoLoseFocus();
begin
Antiban.LoseFocus(SRL.NormalRange(3700, 500));
end;
(* Setup our antiban *)
procedure TScript.SetupAntiban();
begin
Antiban.Skills += ERSSKILL.STRENGTH;
Antiban.Skills += ERSSKILL.AGILITY;
Antiban.AddTask((ONE_MINUTE * 1) * Self.ABTimeMod, @ Antiban.SmallRandomMouse);
Antiban.AddTask((ONE_MINUTE * 4) * Self.ABTimeMod, @ Self.DoLoseFocus);
Antiban.AddTask((ONE_MINUTE * 5) * Self.ABTimeMod, @ Antiban.HoverMSPlayers);
Antiban.AddTask((ONE_MINUTE * 6) * Self.ABTimeMod, @ Antiban.HoverMSItems);
Antiban.AddTask((ONE_MINUTE * 6) * Self.ABTimeMod, @ Antiban.HoverMSNPCs);
Antiban.AddTask((ONE_MINUTE * 7) * Self.ABTimeMod, @ Antiban.RandomRotate);
Antiban.AddTask((ONE_MINUTE * 15) * Self.ABTimeMod, @ Antiban.HoverSkills);
Antiban.AddBreak(ONE_MINUTE * 18, ONE_SECOND * 40, 0.2, 0.0);
end;
procedure TScript.DoAB();
begin
Antiban.DoAntiban();
Antiban.DismissRandom();
end;
function TRSMainScreen.InCombat: Boolean;
begin
Result := (Self.FindHitsplats <> []);
end;
function AtTile(Tile: TPoint; Distance: Int32 = 15): Boolean;
begin
Result := RSW.GetMyPos.DistanceTo(Tile) <= Distance;
end;
function TScript.WaitCombat: Boolean;
begin
if MainScreen.InCombat then
WaitUntil(not MainScreen.InCombat, 35000, 3 * ONE_DAY);
end;
procedure TScript.GetAggro();
begin
Self.WriteMsg('Returning to Crabs');
Minimap.EnableRun();
RSW.WebWalk(AGGRO, 0, 0.2);
end;
procedure TScript.ResetAggro();
begin
Self.WriteMsg('Resetting Aggro');
RSW.WebWalk(RESET, 10, 0.2);
end;
procedure TScript.Init();
begin
RSW.EnableRunAtEnergy := 85;
MM2MS.ZoomLevel := Options.GetZoomLevel();
Mouse.Speed := Random(19, 24);
Self.ABTimeMod := 1;
Self.ShutdownTime := (MAXRUNTIME * 60000) + Random(- (MAXRUNTIME * 6000), (MAXRUNTIME * 6000));
DeclarePlayers();
Self.SetupAntiban();
RSW.Setup('world');
end;
procedure TScript.Run();
begin
if RSClient.IsLoggedIn then
repeat
while MainScreen.InCombat() do
begin
while Self.WaitCombat() do
Self.DoAB();
end;
if not MainScreen.InCombat() then
begin
Self.ResetAggro();
Self.GetAggro();
end;
until (getTimeRunning() > Self.ShutdownTime);
Logout.ClickLogout();
TerminateScript('Time to shutdown');
end;
begin
RSClient.Image.Clear(Mainscreen.Bounds);
ClearDebug;
Bot.Init();
Bot.Run();
end.
Any guidance would be very much appreciated. I'm hoping to get this in a state where it's good enough to share it in the public scripts as there's not too many combat scripts there at the moment :-)
Cheers