SRL Archive - OSR Help

Hmm cant get this to work properly .. crazed man clicking ...lol


sm0k3

2013-03-09 00:52:14

ok so ive pretty much just thrown this together at high speed so im not suprised im having problems realy

but i just cant figure it out ,

its a tar collecter altho at the moment it just runs around in circles and im sure its an easy fix but im knackered and just cant find the problem…

just hoping someone could have a quick look and see where im going wrong as far as i can tell its getting stuck when clicking the red dots on minimap as this is a far as it gets .. takes a few steps along sps path then just runs around manically clicking the mini-map ,, probably shouldnt run it for to long if u test it tho …



program TarCollect;
//The walking code was generated with the path generator for SPS version 2.5.8 by Cynic
// Gota giv him credit due ... ;)

// Made By: Sm0k3
{$DEFINE SMART}
{$i SRL/srl.simba}
{$i sps/sps.simba}



Cons
DEBUGS = True;
totalrun = 2; // total times you want it to run




var
truns, TarBMP: integer;
Status, CurrTask: string;
tarPath: TPointArray;

procedure DeclarePlayers;
begin
HowManyPlayers:=1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer:=0;
with Players[0] do
begin
Name:='';
Pass:='';
BoxRewards:=[''];
LampSkill:=SKILL_PRAYER;
Pin:='';
Active:=true;
end;
end;


procedure WalkToClosest;
var
i: TPointArray;
begin
writeln('Walking');
i := GetMiniMapDots('red'); //Populate the 'i' point array with all the NPC dots
SortTPAFrom(i, Point(MMCX, MMCY)); //Now sort the 'i' array starting from the center of the MM
Mouse(i[0].X,i[0].Y,2,2,mouse_left);
wait(300);
end;

procedure DoCollect;
var
xe,ye: integer;
aFound: Extended;
begin
WalkToClosest;
wait(300);
FindBitmapToleranceIn(tarBMP, xe, ye, MSX1, MSY1, MSX2-90, MSY2-90, 5);
wait(200);
MMouse(xe,ye,2,1);
if ( IsUpText('tar') = True ) then
begin
writeln('found tar ;)')
ClickMouse(xe,ye,1);
end;
end;

procedure DontActLikeAbot;
begin
DoCollect;
end;

procedure WalkLoop;
var
i: integer;
begin
i := 0;
while not ( i = 6 ) do
begin
SPS_BlindWalk(tarPath[i]);
wait(400);
DoCollect;
i := i + 1;
end;
i := 0;
end;

procedure SetupScript;
begin
SRL_SIXHOURFIX := TRUE;
SMART_FIXSPEED := TRUE;
SetupSRL;
DeclarePlayers;
LoginPlayer;
Wait(774+ Random(277));
ClickNorth(SRL_ANGLE_HIGH);
SRL_Procs[SRL_Antiban] := @DontActLikeAbot;
SRL_Procs[srl_OnRandomCall] := @DontActLikeAbot;
SPS_Setup(RUNESCAPE_SURFACE,['11_9']);
SPS_AnyAngle := True;
tarPath :=[Point(4464,3814),Point(4445,3847),Point(4478,3899),Point(4518,3940),Point(4583,3930),Point(4576,3878),Point(4517,3855)];
end;

procedure MainLoop;
begin
while ( CurrTask = 'WalkLoop' ) Do
begin
WalkLoop;
if ( truns = totalrun ) then CurrTask := 'STOP';
end;

end;

begin
tarBMP := BitmapFromString(33, 27, 'meJytVu1Kw0AQjD5BhQqVSmmxWC' +
'yGhPaPCFIRxPd/I0cGh2F3m8QPmB+BbGZudvbu0j+/9WO4bJoSox+' +
'O4nB6J/92ew9sNnfAarUGlstb4F9UJLHbPUiFQlIB2qfXX5MTlNjv' +
'HyVEfoBatHN8+fgpMwkJSrRt53bYNFeZyI9PFoubUoJGsgok+Mkw+' +
'UXTEOwDPgkSIi/TR/18fu0qnBaCYeGtFkkjQSKQ5wEDZrOrcyNNfg' +
'WqZYu2ZPYsCCxMCCpBgjxBxQlLfg0YwKat133mlwSKXWKKBYD21bF' +
'SgmwKN/TKvciOS6A/rGGjJOFZo0B2JMGHsP7QGQVxTsJ3nDeNz4C6' +
'F/g1sZJgWZ5hjm6WcC8+otLSeaVBcgkm4vyqz70Sf0hc6ehUDC5CH' +
'KzX1h7YGqR1dT94BfDnxKniLga2Ht+6C6Us5HuB9aVESJxdCmdImb' +
'JLqD7sRMKPlxx9dhHOwCCB4uACNwWg6fX+h7hzf8qt4bcSQH6g6w7' +
'ZwkC+2QjgSQFf9/I3PxAscIYH8p14CWqD5z2OzofjrsToz4NUPGhY' +
'wIM2lySOp/oPYYpKPkPK4fkLyr/BifyftPeMVg==');
SetupScript;
CurrTask := 'WalkLoop';
while ( truns <= totalrun ) do
begin
MainLoop;
truns := truns + 1;
end;
CurrTask := 'NONE';
FreeBitmap(tarBMP);
end.

Element17

2013-03-09 01:56:08

First off your sps points are wrong. They are way to big, try making a custom map and redo your path. That should fix most of your problems.

sm0k3

2013-03-09 11:59:02

right so it no longerr clicks madly … and can now kind of find swamp tar
but why isnt this if statement working correctly , what identifier is expected??


procedure DoPickup(xs,ys: integer);
begin
MMouse(xs,ys, 0, 0);
if ( IsUpTextMultiCustom(['Take','Tar']) = True ) then
writeln('found tar');
ClickMouse(xs, ys, 0);
wait(300);
ChooseOptionMultiEx(['Take'],'',ClickLeft);
else
writeln('not Tar?');
end;

Runehack123

2013-03-09 12:04:54

Edited your code and included some comments:

procedure DoPickup(xs,ys: integer);
begin
MMouse(xs,ys, 0, 0); //use e.g. MMouse(xs,ys, 4, 4); since random movement better
if IsUpTextMultiCustom(['Take','Tar']) then // If statement is if that statement is true
begin //here
writeln('found tar');
ClickMouse(xs, ys, 0);
wait(300); //random wait better e.g. Wait(RandomRange(200,400));
ChooseOptionMultiEx(['Take'],'',ClickLeft);
end // and here
else
writeln('not Tar?');
end;

Element17

2013-03-09 13:26:44

 ClickMouse2(True); 
Use this instead of clickmouse it is bad.

sm0k3

2013-03-09 14:29:59

hmm i also agree to use clickmouse2 ,, forgot all about it altho the reason clickmouse had no randomness to it
is swamp tars not very big and altho yes people miss miss click i because of this , i couldnt get it to click it at all even whith clickmouse(xe,ye,1,1); was just miss clicking and leaving the tar behind


im also having anouther problem to
issues correctly finding and verifying that an object is tar or not

ie first search for tar
this is hard enough as the tar has almost same colours as its surroundings
ive currently tried Bitmap finding [ not sure why this didnt work it just never found the tar at all ]
dtm finding is the way im currently trying an this works kind of i can find tar but i find trees and goblins all the time aswell so hmm needs work

then verify the uptext , currently i make use of if IsUpTextMultiCustom(['Take','Tar'])
and ive also tried it as if IsUpTextMultiCustom(['ake','ar']) and this seems to return true even id the uptext is
cut down tree or somthing …


procedure DoPickup(xs,ys: integer);
begin
MMouse(xs,ys, 0, 0); //use e.g. MMouse(xs,ys, 4, 4); since random movement better
if IsUpTextMultiCustom(['Take','Tar']) then // If statement is if that statement is true
begin //here
writeln('found tar');
ClickMouse2(mouse_right);
wait(300); //random wait better e.g. Wait(RandomRange(200,400));
ChooseOptionMultiEx(['Take'],'',ClickLeft);
end // and here
else
writeln('not Tar?');
end;

procedure DoCollect;
var
xe, ye: integer;
aFound: extended;
begin
while (IsMoving = True) do
begin
wait(100);
end;
if (IsMoving = False) then
begin
writeln('looking');
wait(900);
try
FindDTMRotated(TarDTM, xe, ye, MSX1, MSY1, MSX2, MSY2, 0, 180,5,aFound);
DoPickup(xe, ye);
except
writeln('couldnt Find any Tar :0');
finally
writeln('Ill Keep Searching :)');
end;
end;
end;

sm0k3

2013-03-09 17:12:04

Update Sorry for the double post but heres the whole script ..
no where near finished yet , im cant see where this is trying to look when searching for the objects , this little red dot thats Simbas cursor always seems to sit just off the side of the Main Screen ,,, still responds to sps tho
i expect the cursor to jump around the mainscreen a bit checking the uptexts along the way alltho this is probably more due to lack of colours , well i have included DTM BMP an color searches in here altho the Pickup proceedure only uses DTM the other 2 just debug to screen to show it script is seeing anything
the debug onto smart does show the colors have been found i think thats the debug thats showing correctly,,,
i think im just breaking my script more and more as i go as it now runs around semi ok altho its has a random sense of direction but now dosent check the uptexts at all


program TarCollect;
{$DEFINE SMART8}
{$i SRL/srl.simba}
{$i sps/sps.simba}
{$i SRL/SRL/misc/smartgraphics.simba}

const
DEBUGSMART = True;
DEBUGS = True;
totalrun = 2;

var
truns, TarBMP, TarDTM: integer;
Status, CurrTask: string;
TarPath1, TarPath2, TarINSCREEN, TarCpoints: TPointArray;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
BoxRewards := [''];
LampSkill := SKILL_PRAYER;
Pin := '';
Active := true;
end;
end;

procedure WalkToClosest;
var
i: TPointArray;
begin
writeln('Walking');
try
i := GetMiniMapDots('red');
SortTPAFrom(i, Point(MMCX, MMCY));
Mouse(i[0].X + 2, i[0].Y + 2, 2, 0, mouse_left);
wait(2000);
except
writeln('No Tar Spots Here :0');
finally
writeln('continuing to search');
end
end;

procedure DoPickup(xs,ys: integer);
begin
MMouse(xs,ys, 0, 0); //use e.g. MMouse(xs,ys, 4, 4); since random movement better
if IsUpTextMultiCustom(['Take','Tar']) then // If statement is if that statement is true
begin //here
writeln('found tar');
ClickMouse2(mouse_right);
wait(300); //random wait better e.g. Wait(RandomRange(200,400));
ChooseOptionMultiEx(['Take'],'',ClickLeft);
end // and here
else
writeln('not Tar?');
end;

procedure DoCollect;
var
xe, ye: integer;
aFound: extended;
Dbox,Ebox: TPoint;
DTMbox: TBox;
begin
while (IsMoving = True) do
begin
wait(100);
end;
if (IsMoving = False) then
begin
writeln('looking');
wait(900);
FindBitmapsSpiralTolerance(TarBMP,MSCx,MSCy,TarINSCREEN,MSX1,MSY1,MSX2,MSY2,16);
//if ( DEBUGSMART = True ) then SMART_DebugTPA(False,TarINSCREEN);
try
FindDTMRotated(TarDTM, xe, ye, MSX1, MSY1, MSX2, MSY2, 0, 360,5,aFound);
FindColorsSpiralTolerance(MSCx,MSCy,TarCpoints,2697514,MSX1,MSY1,MSX2,MSY2,5);
SMART_DebugTPA(True,TarCpoints);
Dbox := IntToPoint(xe,ye);
Ebox := IntToPoint(xe+4,ye+4);
PointToBox(Dbox,Ebox);
if ( DEBUGSMART = True ) then SMART_DrawBoxMS(False,False,DTMbox,clRed);
DoPickup(xe, ye);
except
writeln('couldnt Find any Tar :0');
finally
writeln('Ill Keep Searching :)');
end;
end;
end;

procedure DontActLikeAbot;
begin
DoCollect;
end;

procedure WalkLoop;
var
i, mypath: integer;
mypathrand: TPointArray;
begin
mypath := random(2);
if (mypath = 1) then
mypathrand := TarPath1;
if (mypath = 2) then
mypathrand := TarPath2;
for i := 0 to High(mypathrand) do
begin
SPS_BlindWalk(mypathrand[i]);
WalkToClosest;
DoCollect;
end;
end;

procedure SetupScript;
begin
SRL_SIXHOURFIX := TRUE;
SMART_FIXSPEED := TRUE;
SetupSRL;
DeclarePlayers;
LoginPlayer;
Wait(774 + Random(277));
ClickNorth(SRL_ANGLE_HIGH);
SRL_Procs[SRL_Antiban] := @ DontActLikeAbot;
SPS_Setup(RUNESCAPE_SURFACE, ['11_9']);
SPS_AnyAngle := True;
TarPath1 := [Point(4588, 3892), Point(4555, 3880), Point(4532, 3866), Point(4509, 3840), Point(4482, 3842), Point(4445, 3859)];
TarPath2 := [Point(4585, 3886), Point(4554, 3879), Point(4531, 3861), Point(4505, 3842), Point(4494, 3866), Point(4497, 3898)];
end;

procedure MainLoop;
begin
while (CurrTask = 'WalkLoop') do
begin
WalkLoop;
if (truns = totalrun) then
CurrTask := 'STOP';
end;
end;

begin
TarDTM := DTMFromString('mWAAAAHicY2FgYJjOxMDQD8SdQDwNiJcxMjCsBeKlQDwHiOVkZRm0tTTBWFVFmYEbqAeojIEFiNmBmBUNgwAAqKoG1g==');
TarBmp := BitmapFromString(14, 11, 'meJx1kFkKg0AQRK8RgyESjdEszY' +
'gLip/i/a9kSWERZkZ4DC6vq3va1sWIOfH5/h55YfrlYc41rajqN4m' +
'aiBLU+OyZ/4GSWZ6mN2l49fpizjCw7XoInJOn+oJLcg1HhdMPIwqf' +
'5Ut7uGdZaMJhPmFJ9ProRRmoe3SlzCHjNHPg0/0fwETgPvDxZQMBbV5s');
SetupScript;
CurrTask := 'WalkLoop';
while (truns <= totalrun) do
begin
MainLoop;
truns := truns + 1;
end;
CurrTask := 'NONE';
FreeBitmap(tarBMP);
end.

Element17

2013-03-10 01:10:21

Have you tired using ACA to get your color of the tar?