SRL Archive - General Botting Help

Fishing bot (catherby) help


stevlockholmes

2015-03-01 00:21:25

How would a procedure for selecting the fishing spot work?

I only want to fish lobsters, so how would I get the script to only target lobster fishing spots?

Thanks.

I figure you have to do something with SPS and select the area array in which the fishing spot would be found, then call it to search for the fishing spot within that area, but i'm just not sure how to type it all out in code. The farthest I can get is not much xD


procedure findFishingHole();
begin
//Some code here to allow the bot to find the caging spot, and only the caging spot, along with some anti ban?
end.

Ross

2015-03-01 00:44:53

Not sure if you have yet, but read through The Mayor's tutorial thoroughly. In this case I believe you would be differentiating the two based on mouseover text.

stevlockholmes

2015-03-01 00:49:01

I have read through the majority of his tutorial, not sure, I must be missing something. Any hints on how I could at least start the procedure?

KeepBotting

2015-03-01 00:55:17

We don't know which game you want to do this for, so I'll write this as if it's RS3 (you've got a camelCased procedure name and Lape-style hanging parenthesis so it seems like a good guess)

You don't have to do anything with SPS unless you're not already in the area you wish to be for fishing. SPS is for walking and walking only.

To actually find a fishing spot, this is how I'd do it: (adapted a bit from my script skeleton)


function find():T2DPointArray;
begin
if (not isLoggedIn()) then
exit();

if tabBackpack.isFull() then
exit();

{ideally you'd have some sort of location check here,
especially if your script walks around in other places}

writeLn('Detecting fishing spots');
if findColorsTolerance(fishTpa, <color>, mainScreen.getBounds(), <tolerance>, <cts2 values>) then
begin
fishTpa.sortFromPoint(mainScreen.playerPoint); //sort it from .playerPoint or .centerPoint
//so we can determine which spot is clocest to us
writeLn('Preliminary TPA length: ' + toStr(length(fishTpa)) + '');

smartImage.debugTpa(fishTpa); //Debug it
result := fishTpa.split(30, 30); //split to ATPA, I can't remember the correct
//side length for fishing spots but it's probably
//closer to 10, 10 or 15, 15
end;

writeDebug('Preliminary ATPA length: ' + toStr(length(result)) + '');

if (length(result) < 1) then //If we end up with nothing after all this hard work :(
begin
writeLn('*** FATAL ERROR: No fishing spots found!');
terminateScript();
end;
end;

This function will return you a nicely sorted ATPA of all the fishing spots in the area. <color>, <tolerance>, and <cts2 values> are the CTS2 colors of the fishing spots themselves. Get them from ACA (take a look at YoHoJo's tutorial if you don't know what ACA is or how to use it).

***

So now we have our nicely sorted ATPA, courtesy of find(). But what do we do with it and how?

Let's write up another function to take the data from find() and turn it into something useful (a clicked fishing spot)


function fish():boolean;
var
tpa:TPointArray;
finalAtpa:T2DPointArray;
i, h:integer;
begin
if (not isLoggedIn()) then
exit;

result := false; //Seems like a good idea

finalAtpa := find(); //fish() calls find()
//find() finds, fish() fishes. :D

h := high(finalAtpa); //Set the high (the last value) of find()'s ATPA to an integer

for i := 0 to h do //for..to..do loop #1, to get the points we're going to click
insert(finalAtpa[i].centerPoint, tpa); //return center points of every TPA in the ATPA
//and store them in _yet another_ TPA

//tpa.centerPoint() is actually a custom function
//which I will explain later.

tpa.sortFromPoint(mainScreen.playerPoint); //Sort them, we already sorted it back in find()
//But this is a new TPA and it can't hurt.
//Again you can use .playerPoint or .centerPoint

for i := 0 to h do //for..to..do loop #2, for actually clicking
begin
mouseRandom(tpa[i].randRange(-3, 3), MOUSE_MOVE); //Move the mouse, with a bit of randomness
if isMouseOverText(['Fishing spot', 'ishing spo', 'ng sp']) then //Unsure of the exact text - this should be
if didClick(true) then //the text that appears when you hover your mouse
begin //over a fishing spot

smartImage.clearArea(mainScreen.getBounds()); //Clear off our debug from before
minimap.waitFlagExists(10000); //Wait until we've stopped moving (this is a custom procedure, see below)
minimap.waitPlayerMoving(); //Just to be sure we've stopped moving
exit(true); //Assign a result to the function and quit, we're done
end;
end;
end;

Depending on which option you want to click (I'm out of practise with RS3 and thus can't remember if the 'Cage' option requires a rightclick or not) you may have to fastClick(MOUSE_RIGHT); and chooseOption.select('age'); or something.

I mentioned custom functions twice in the above code, here they are: you'll need both of these to make the previous functions work

function TPointArray.centerPoint():TPoint;

function TPointArray.centerPoint():TPoint;
var
tmp:TPointArray;
begin
if (length(self) < 1) then
exit();

tmp := self;
tmp.sortFromPoint(self.getMiddle());
result := tmp[0];
end;

and procedure TRSMinimap.waitFlagExists(timeout:integer);

procedure TRSMinimap.waitFlagExists(timeout:integer); //waits up to timeout for the flag to be gone
var
t:TTimeMarker;
begin
if (not isLoggedIn()) then
exit();

if tabBackpack.isFull() then
exit();

if (not (self.isFlagPresent())) then
begin
writeLn('Flag not present, unable to wait while flag exists');
exit();
end;

t.start();

while (t.getTime() < timeout) do
begin
writeLn('Waiting while the flag exists');
wait(randomRange(250, 500));

if (not (self.isFlagPresent())) then
exit();
end;
end;

***

Throw that all together and you can click anything like a boss.

Let me know (quote my post so I get a notification) if you've any other questions :)