Tringy
2022-02-15 21:00:15
Hey team,
I'm relatively new to scripting (and unfortunately have been using more of other people's scripts than my own) but nevertheless I am trying to put something together outside of Flight's tutorial on making your own first script :p
I'm currently attempting to make a script that will AFK Ammonite Crabs for me and I think I have a lot of the bones of the script done (hopefully), but the error I am running into right now is that the walker does not want to work for me.
Runtime error: "MatchTemplateMask: Cache is empty" at line 283, column 30 in file "C:\Simba 1.4\Includes\SRL-F\osr\walker\walker.simba"
Which highlights the code " Matrix := MatchTemplateMask(Cache, Sample.ToMatrix, TM_CCOEFF_NORMED);"
What am I doing wrong here? I've put my script below in case there's something wrong with the script, or anyone spots anything else obvious I have done wrong (because I can't get the script to run)
Thanks in advance!
I'm relatively new to scripting (and unfortunately have been using more of other people's scripts than my own) but nevertheless I am trying to put something together outside of Flight's tutorial on making your own first script :p
I'm currently attempting to make a script that will AFK Ammonite Crabs for me and I think I have a lot of the bones of the script done (hopefully), but the error I am running into right now is that the walker does not want to work for me.
Runtime error: "MatchTemplateMask: Cache is empty" at line 283, column 30 in file "C:\Simba 1.4\Includes\SRL-F\osr\walker\walker.simba"
Which highlights the code " Matrix := MatchTemplateMask(Cache, Sample.ToMatrix, TM_CCOEFF_NORMED);"
What am I doing wrong here? I've put my script below in case there's something wrong with the script, or anyone spots anything else obvious I have done wrong (because I can't get the script to run)
program CrabKiller;
{$DEFINE SRL_USE_REMOTEINPUT}
{$I SRL-F/osr.simba}
var
RSW: TRSWalker;
AGGRO: TPoint := [1457, 316];
RESET: TPoint := [1351, 397];
Const
(* Player settings *)
PNAME = ''; // Player name
PPASS = ''; // Player password
PPIN = ''; // Player pin (not needed here as we use the deositbox)
MAXRUNTIME = 100;
Type
TScript = record
RSW : TRSWalker;
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;
// Interval Antiban method
Antiban.AddTask(ONE_SECOND*10, @Mouse.RandomMovement);
Antiban.AddTask(ONE_MINUTE*2, @Self.DoLoseFocus);
Antiban.AddTask(ONE_MINUTE*4, @Antiban.HoverMSPlayers);
Antiban.AddTask(ONE_MINUTE*7, @Antiban.RandomRotate);
Antiban.AddTask(ONE_MINUTE*9, @Antiban.HoverSkills);
Antiban.AddBreak(ONE_MINUTE*18, ONE_SECOND*40, 0.2, 0.0);
end;
procedure TScript.DoAB();
begin
Antiban.DismissRandom();
if Antiban.DoAntiban() then
if (not RSClient.IsLoggedIn) then
Login.LoginPlayer();
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, 10000, -1);
end;
procedure TScript.GetAggro();
begin
while RSClient.IsLoggedIn do
begin
if not AtTile(AGGRO) and not MainScreen.InCombat() then
Self.WriteMsg('Returning to Crabs');
Minimap.EnableRun();
RSW.WebWalk(AGGRO, 0, 0.2);
end;
end;
procedure TScript.ResetAggro();
begin
while RSClient.IsLoggedIn do
begin
if not MainScreen.InCombat() then
Wait(Random(100, 5000));
RSW.WebWalk(RESET, 10, 0.2);
end;
end;
procedure TScript.Init();
begin
DeclarePlayers();
SetupAntiban();
RSW.Setup('world');
RSW.ScreenWalk := False; // True for walking via the mainscreen
RSW.EnableRunAtEnergy := 85;
MM2MS.ZoomLevel := Options.GetZoomLevel();
Mouse.Speed := 20;
end;
procedure TScript.Run();
begin
while RSClient.IsLoggedIn do
begin
if AtTile(AGGRO) and not MainScreen.InCombat() then
Self.ResetAggro();
Self.GetAggro();
end;
Self.WaitCombat();
Self.DoAB();
if (getTimeRunning() > Self.ShutdownTime) then
begin
Logout.ClickLogout();
TerminateScript('Time to shutdown');
Exit;
end;
end;
begin
RSClient.Image.Clear(Mainscreen.Bounds);
Bot.Init();
Bot.Run();
end.Thanks in advance!