SRL Archive - First Scripts

Lumbridge River Fish And Bank [NEED HELP]


MasterXehanort

2014-12-11 18:49:16

This script is a Lumbridge River fisher and banker. The script:
  • Walk to the fishing spots
  • Finds the fishing bubbles
  • Fishes until a full inventory
  • Walks to the bank
  • Deposits
  • Starts over.

  • Has antiban
  • Uses ACA, TPA, and ATPA to find fishing spot
  • 40k fishing xp/hr
  • Banks 53.8k xp/hr worth of fish!
  • for ironmen/women needing 99 fishing and cooking

Credits To:
  • @The Mayor; for his tutorials and isinpolygon SPS function
  • @Coh3n; for his tutorials
  • @KeepBotting; for his Karamja Fisher (used some of his coding) and his recommendation to fix a function
  • @Ashaman88; for helping me understanding "case" in antiban (from his scripts)
  • NOTE: No plans on public release of a working script. Possible Jr. member release once I rewrite everything after finals.

Unfortunately, the script is one failsafe away from working for long periods of time. At the Lumbridge fishing spot, there are only two bubble "spots", and they can spawn off screen. The "spots" can either be at the north part of the river, or the south part of the river. The script works fine until both fishing "spots" are off screen. The original path of walking to the river gets me to the north side. When the two bubble "spots" move to the south side, the script gets stuck and eventually the player is logged out for being idle too long.

I tried fixing this by adding a procedure that walks to the south side of the river, to use in case the bubble "spot" was not found. But, then I thought, what if the bubbles move again? So I tried creating a procedure that would walk to the opposite side of the river, if the bubble color is not present. This is where I am stuck. My original attempt (script version 1.0) was using if..then..else statements, which did not end up working the way I used them. The player just stood idle when the bubble colors were not found I then tried to use another method.

The second method (version 1.1) I used was to check if my player was on the north part of the river, if he was, I would walk to the south part of the river. If the player was not at the north part of the river, he would walk to the north part. That way he would walk to the opposite side if the bubbles were not found. He still stood idle.

HOWEVER, I then changed the color of what was being searched (to make the color automatically not on the screen). For version 1.0 the player remained idle, for version 1.1 he ran to the south side of the river, but did not run back to the north. If someone could please look over my procedure to see what I did wrong, I would greatly appreciate it. I've marked the location to where the procedures I mentioned are (line 168 for version 1.0 and line 187 for version 1.1). If you feel one method is better than the other, review that specific script only.


Version 1.2 is working. Willing to PM to people that are interested in helping me improve it. It's still barebones. :
========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 4 Hours, 57 Minutes and 34 Seconds
Fish Caught: 3078
Loads Done: 114
Catches Per Hour: 621
Experience Gained: 178524
Experience Per Hour: 35997
========================================================

========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 4 Hours, 55 Minutes and 28 Seconds
Fish Caught: 3159
Loads Done: 117
Catches Per Hour: 641
Experience Gained: 183222
Experience Per Hour: 37206
========================================================


Version 1.3 has fixed colors and better wait times.

========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 5 Hours, 54 Minutes and 26 Seconds
Fish Caught: 4158
Loads Done: 154
Catches Per Hour: 704
Experience Gained: 241164
Experience Per Hour: 40825
========================================================

Version 2.0 Plans:
  • Increased failsafes
  • Better colors to improve speed
  • Better detection of fishing spot moved while fishing
  • Playerform GUI
  • Break system
  • 6 hour fix
  • Pretty painted proggy

KeepBotting

2014-12-11 19:02:26

I see a bit of my code in there. May want to credit me if/when you release. credits were added to OP

As far as your question, first thing I notice is that amIOnNorthRiver uses a single TPoint for location checking.
This is bad, what if you're not on that exact point, but only one or two points over? It will still return false, even though you're so close as makes no difference.
In my Karamja fisher, I use distance from single TPoints to check locations - you may want to check that out.

Secondly, I'm assuming that WalkToNorthRiver's path assumes the player starts at the south river. Conversely, WalkToSouthRiver probably assumes that the player starts at the north river.

(why are those two paths so long? from what I can glean from the SPS map, you've only got to walk between these two places. blindWalk or a path comprised of 2-3 points should do the job just as effectively)

I can imagine this will cause problems if amIOnNorthRiver returns false when it's not supposed to, because of this logic:

  if (amIOnNorthRiver()) then
walkToSouthRiver()
else
walkToNorthRiver();

Given that amIOnNorthRiver returns false 100% of the time (which is possible), this dictates that the player should always walk to the north river.


tl;dr improve amIOnNorthRiver and the problem should be sorted out. Check out my Karamja fisher if you need help with the logic.
You could easily debug it by doing
writeLn(toStr(amIOnNorthRiver));
in your script which will help you see when it's returning what

Let me know if I've missed anything that renders this post moot.

Lipcot

2014-12-11 19:03:41

From: KeepBotting
I see a bit of my code in there. May want to credit me if/when you release.

As far as your question, first thing I notice is that amIOnNorthRiver uses a single TPoint for location checking.
This is bad, what if you're not on that exact point, but only one or two points over? It will still return false, even though you're so close as makes no difference.
In my Karamja fisher, I use distance from single TPoints to check locations - you may want to check that out.

Secondly, I'm assuming that WalkToNorthRiver's path assumes the player starts at the south river. Conversely, WalkToSouthRiver probably assumes that the player starts at the north river.
I can imagine this will cause problems if amIOnNorthRiver returns false when it's not supposed to, because of this logic:

  if (amIOnNorthRiver()) then
walkToSouthRiver()
else
walkToNorthRiver();

Given that amIOnNorthRiver returns false 100% of the time (which is possible), this dictates that the player should always walk to the north river.


tl;dr improve amIOnNorthRiver and the problem should be sorted out.

Let me know if I've missed anything that renders this post moot


he could use @themayor; 's sps polygon snippet if im not mistaken? that would be useful

KeepBotting

2014-12-11 19:07:09

From: undorak7
he could use @themayor; 's sps polygon snippet if im not mistaken? that would be useful

@The Mayor;* :) his name has a space in it

Yes, he could use it. It's one of many alternatives, there are several ways to do it: TBox, distance from TPoints, polygons

MasterXehanort

2014-12-11 19:11:59

Will definitely look into those. Thanks @KeepBotting; and @undorak7; . I'll post updates on how it's running. Also, added a credits section to the OP, I wouldn't even have a single line if it weren't for the community. No plans on public release, just really want to level up ironman. Possible Jr member release if I can rewrite it over break and use my own code.

KeepBotting

2014-12-11 19:15:25

From: MMOE
Will definitely look into those. Thanks @KeepBotting and @undorak7. I'll post updates on how it's running. Also, added a credits section to the OP, I wouldn't even have a single line if it weren't for the community. No plans on public release, just really want to level up ironman. Possible Jr member release if I can rewrite it over break and use my own code.

Quite welcome

Don't hesitate to quote/PM me or even add me on Skype if you've got more questions :)

Brose

2014-12-12 06:12:21

Unfortunately, the script is one failsafe away from working for long periods of time. At the Lumbridge fishing spot, there are only two bubble "spots", and they can spawn off screen. The "spots" can either be at the north part of the river, or the south part of the river. The script works fine until both fishing "spots" are off screen. The original path of walking to the river gets me to the north side. When the two bubble "spots" move to the south side, the script gets stuck and eventually the player is logged out for being idle too long.


I think KeepBotting already pretty much solved your issue. What I did in my own fishing script is that whenever I cannot find any fishing spots, I will run a changelocation procedure which will check my relative position against the 2 fishing spots and will walk to the further one.
Which means say there are 2 spots, A and B. If I am at A and i find no fishes, it will walk to B. If I am at B. Then it will walk to A. etc

It looks abit like this:
procedure changeLoc();
var
dist1, dist2, i : Integer;
myPoint : Tpoint;
ctrlPoints: TPointArray;
begin
myPoint := SPS.getPlayerPos();
idealLoc1 := Point(204, 121);
idealLoc2 := Point(238, 153);
dist1 := Distance(myPoint, idealLoc1);
dist2 := Distance(myPoint, idealLoc2);

if (dist1 <= dist2) then
begin
writeLn('Cannot find lobster spots, moving to location 2');
paintStatus('Changing location... (2)');
ctrlPoints := TPABetweenPoints(myPoint, idealLoc2, 20 + random(20), 15);
for i := high(ctrlPoints) downto 0 do
begin
SPS.walkToPos(ctrlPoints[i]);
exit;
end;
end;

if (dist1 > dist2) then
begin
writeLn('Cannot find lobster spots, moving to location 1');
paintStatus('Changing location... (1)');
ctrlPoints := TPABetweenPoints(myPoint, idealLoc1, 20 + random(20), 15);
for i := high(ctrlPoints) downto 0 do
begin
SPS.walkToPos(ctrlPoints[i]);
exit;
end;
end;

minimap.waitPlayerMoving;
end;

Edit: I saw the TPoint of amIOnNorthRiver function. You could use a Tbox to check your location on SPS so that it will return true so long you are within the box and need not be restricted to a single coordinate.

MasterXehanort

2014-12-12 12:16:10

UPDATE: I added the isinPolygon code you guys linked me too. At first I thought it didn't work, BUT then I noticed that the xp tracker I had was within the mainscreen bounds, which is similar in color to the bubble spots. As soon as I took the xp tracker off the mainscreen boundary the script started working perfectly. Thanks guys. Going to run this throughout finals week and come back and rewrite it over break :D
@KeepBotting; @undorak7; @Brose; @The Mayor; @Ashaman88;

From: KeepBotting

(why are those two paths so long? from what I can glean from the SPS map, you've only got to walk between these two places. blindWalk or a path comprised of 2-3 points should do the job just as effectively)


The walkToNorthRiver procedure is used to walk there from the bankchest across the river, as well as the failsafe to walk to from south.

Brose

2014-12-12 13:55:47

As a rule of thumb. You should always make it a habit to move the xp tracker to the correct location which is just above the chatbox

The Mayor

2014-12-12 15:16:48

From: MMOE
UPDATE: I added the isinPolygon code you guys linked me too. At first I thought it didn't work, BUT then I noticed that the xp tracker I had was within the mainscreen bounds, which is similar in color to the bubble spots. As soon as I took the xp tracker off the mainscreen boundary the script started working perfectly. Thanks guys. Going to run this throughout finals week and come back and rewrite it over break :D
@KeepBotting; @undorak7; @Brose; @The Mayor; @Ashaman88;



The walkToNorthRiver procedure is used to walk there from the bankchest across the river, as well as the failsafe to walk to from south.


You should put up 1.2

KeepBotting

2014-12-12 16:39:09

From: MMOE
UPDATE: I added the isinPolygon code you guys linked me too. At first I thought it didn't work, BUT then I noticed that the xp tracker I had was within the mainscreen bounds, which is similar in color to the bubble spots. As soon as I took the xp tracker off the mainscreen boundary the script started working perfectly. Thanks guys. Going to run this throughout finals week and come back and rewrite it over break :D
@KeepBotting; @undorak7; @Brose; @The Mayor; @Ashaman88;


The walkToNorthRiver procedure is used to walk there from the bankchest across the river, as well as the failsafe to walk to from south.


Awesome job, glad you worked it out :) I'm excited to see the rewrite!

MasterXehanort

2014-12-12 17:56:35

Stopped it manually a bit early. But proggy:

========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 4 Hours, 57 Minutes and 34 Seconds
Fish Caught: 3078
Loads Done: 114
Catches Per Hour: 621
Experience Gained: 178524
Experience Per Hour: 35997
========================================================

========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 4 Hours, 55 Minutes and 28 Seconds
Fish Caught: 3159
Loads Done: 117
Catches Per Hour: 641
Experience Gained: 183222
Experience Per Hour: 37206
========================================================

It's a little slower after the fix, but that's fine for now.


From: The Mayor
You should put up 1.2

PM'd you version 1.2.

MasterXehanort

2014-12-18 17:40:24

Version 1.3 has updated colors and wait times. Would like to get even better colors, but the goblin building is nearly the same color as the bubbles. Though it does fish via clicking the closest ATPA/TPA, using a better color for the bubble increases tolerance too much and the house color gets detected and put into its own TPA. The house can at times be closer to the player than the bubbles, and the mouse keeps looking for the 'lure' uptext. I would like to trying to implement a search boundary function where the TPA's clicked/detected are limited to a box to the left of the player.


@KeepBotting; any suggestions about how I would go about this? I've had a look at @footballjds;'s Fishing guild script and tried to break down his 'search bounds function', but I'm having trouble breaking it down and how to implement something similar into my own script.

function searchBounds: TBox;
var
sDist, nDist: integer;
sps_Pos, mmX, msX: TPoint;
msB: TBox;
begin
sps_Pos := fishGuild.getPlayerPos;
//smartImage.clearArea(mainscreen.getBounds);

sDist := abs(sps_Pos.y - paths[2][high(paths[2])].y);
nDist := abs(sps_Pos.y - paths[1][high(paths[1])].y);
msB := mainscreen.getBounds;
result := msB;
if nDist < sDist then
begin
if SPS_PosToMM(paths[1][high(paths[1])], sps_Pos, mmX) then
begin
msX := minimap.pointToMainscreen(mmX);
if msB.isPointInside(msX) then
result := intToBox(msB.x1, msB.y1, msX.x + 65, msX.y + 65);
end;
end else
begin
if SPS_PosToMM(paths[2][high(paths[2])], sps_Pos, mmx) then
begin
msX := minimap.pointToMainscreen(mmX);
if msB.isPointInside(msX) then
result := intToBox(msX.x - 100, msX.y - 65, msB.x2, msB.y2);
end;
end;
result.setLimit(mainscreen.getBounds);
smartimage.drawBox(result, false, 656583);
end;

========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 1 Hour, 31 Minutes and 16 Seconds
Fish Caught: 1080
Loads Done: 40
Catches Per Hour: 710
Experience Gained: 62640
Experience Per Hour: 41177
========================================================

KeepBotting

2014-12-18 18:16:59

From: MMOE
Version 1.3 has updated colors and wait times. Would like to get even better colors, but the goblin building is nearly the same color as the bubbles. Though it does fish via clicking the closest ATPA/TPA, using a better color for the bubble increases tolerance too much and the house color gets detected and put into its own TPA. The house can at times be closer to the player than the bubbles, and the mouse keeps looking for the 'lure' uptext. I would like to trying to implement a search boundary function where the TPA's clicked/detected are limited to a box to the left of the player.


@KeepBotting; any suggestions about how I would go about this? I've had a look at @footballjds;'s Fishing guild script and tried to break down his 'search bounds function', but I'm having trouble breaking it down and how to implement something similar into my own script.

snippity snip

========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 1 Hour, 31 Minutes and 16 Seconds
Fish Caught: 1080
Loads Done: 40
Catches Per Hour: 710
Experience Gained: 62640
Experience Per Hour: 41177
========================================================


First of all let me congratulate you on your hard work. You've kept at this for a long time which is great. Getting a script to the level where it can run smoothly for >an hour is 90% of the battle. It's all downhill from here :)

Now, I *could* run through football's code and comment it a bit for you, and I will if you're set on using it, but lemme give you a quick description of how I'd do this.

I'd do something called TPA filtering - it's what I used in my iOak script. Here's a basic outline:

  1. Make a finder function that will find a pretty unique color (fishing spot bubbles)
  2. Make a finder function that will find a very common color (the entire river water)
  3. Make yet another function that will compare all the findings of the colors, and delete the ones that don't have BOTH colors in them

This will effectively return the entire screen as found colors, but them proceed to delete the ones in which both colors aren't found.

Here's some colors I picked out in ACA (don't use these, they were only picked across one SMART instance/one game world) I'm not going to embed the images for the sake of brevity

Unique fishing spot bubbles: http://puu.sh/dAiZ7.png

Common river water: http://puu.sh/dAj19.png

Note that the first screenshot includes none of the river water, and conversely the second screenshot includes none of the fishing spot bubbles. This is what we'll use to our advantage.

Now onto the code. First thing we need to do to make this work is declare your ATPAs globally, we're going to divide this across several functions so it's easier to understand.

***For best results, copypaste these into Simba, they'll be easier to read


var
fishTpa:TPointArray;
fishAtpa:T2DPointArray;

Now that we've declared relevant variables, let's start finding our fishing spot bubbles.

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

writeLn('Detecting fishing spots');
if findColorsTolerance(fishTpa, color, mainScreen.getBounds(), tolerance, cts values) then //you'll need to fill those in
begin
fishTpa.sortFromPoint(mainScreen.playerPoint); //sort it first
writeln('Preliminary TPA length: ' + toStr(length(fishTpa)) + '');

smartImage.debugTpa(fishTpa); //debug it
result := fishTpa.split(30, 30); //split to atpa
end;

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

treeAtpa := result; //assign it global so we can work on it later in out TPA filtering function

if length(result) < 1 then
begin
writeln('*** FATAL ERROR: No fishing spots found!');
terminateScript();
end;
end;

This will create an ATPA of our fishing spots and assign it to a global variable. Now for the cool part.

This function is where the magic happens. We're going to see if we can't find our water color inside our fishing bubble color.

function filter():T2DPointArray;
var
i:integer; //for..to..do
searchBoxArray:TBoxArray; //stores the bounds of ALL tpa's we're searching
newBoxArray:TBoxArray; //stores the bounds of the tpa's that we'll keep
bounds:TBox; //stores the bounds of the current tpa we're searching

tmpTpa:TPointArray; //holds fishTpa's copy, exclusion routines will be run on this
tmpAtpa:T2DPointArray; //the function will result this, but since we're working with tboxarrays we need a placeholder var

exclusionTpa:TPointArray; //holds the points to be excluded from tmpTpa - derived from findcolorstolerance'ing the river water color

begin
if (not isLoggedIn()) then
exit;
if tabBackpack.isFull() then
exit;

find(); //make sure to fill our global tpa/atpa first by calling the procedure that actually does the finding

writeln('Filtering fishing spots');

tmpTpa := fishTpa.copy(); //copy fishTpa into a temporary array which we can muck around with here in filter()

searchBoxArray := fishAtpa.getEachBounds(); //fill searchBoxArray, I hate dealing with atpas so a tboxarray of its bounds works better for me
writeln('The search box array contains ' + toStr(length(searchBoxArray)) + ' TPAs');

for i := 0 to (length(searchBoxArray) - 1) do //loop through each set of bounds MINUS THE LAST ONE cuz it's a lil bitch m8
begin
bounds := searchBoxArray[i]; //grab the bounds from the search box array, no need to getTpaBounds() because it's not a tpa anymore :)
writeln('Bounds for TPA #' + toStr(i) + ': ' + toStr(bounds) + '.');
if findColorsTolerance(exclusionTpa, color, bounds, tolerance, cts values) then //these should be the colors of the river water, searches and stores the tpa in exclusionTpa
begin
writeln('Exclusion TPA length: ' + toStr(length(exclusionTpa)) + '');
smartImage.debugTpa(exclusionTpa);
writeln('Fishing spot has been excluded');
end else
begin
writeln('Fishing spot is there');
newBoxArray.append(searchBoxArray[i]); //append the good spot's tbox onto the new tbox array
end;
end;

result := newBoxArray.toAtpa(); //convert to atpa and result

smartImage.debugAtpa(result); //debug it
writelm('Filtered ATPA length: ' + toStr(length(result)) + '');
end;


Sweet. Now you have a ready-made ATPA that will only contain points if both the fishing spot color and river water color are found inside them. I'm almost positive that the goblin house isn't the same color as the water :D

From here, you can mouse to your points and do your clicking logic however you like (or I could show you my function for that)

Note that these snippets were pulled out of iOak and edited slightly, if I left anything that renders them unusable, let me know. My code-to-explanation ratio is also a bit low, let me know if something doesn't make sense and I'll expound on it

Note also that this is kind of advanced and I understand if you don't want to use it. If that's the case, reply back and I'll go through football's code and try and have it make a little more sense to you :p

MasterXehanort

2014-12-18 23:52:14

From: KeepBotting


Sweet. Now you have a ready-made ATPA that will only contain points if both the fishing spot color and river water color are found inside them. I'm almost positive that the goblin house isn't the same color as the water :D

From here, you can mouse to your points and do your clicking logic however you like (or I could show you my function for that)

Note that these snippets were pulled out of iOak and edited slightly, if I left anything that renders them unusable, let me know. My code-to-explanation ratio is also a bit low, let me know if something doesn't make sense and I'll expound on it

Note also that this is kind of advanced and I understand if you don't want to use it. If that's the case, reply back and I'll go through football's code and try and have it make a little more sense to you :p


Finally let it run out:

========================================================
Sephiroths Lumbridge FishAndBank
Time Ran: 5 Hours, 54 Minutes and 26 Seconds
Fish Caught: 4158
Loads Done: 154
Catches Per Hour: 704
Experience Gained: 241164
Experience Per Hour: 40825
========================================================

Thanks for the tips @KeepBotting; I'll go through what you've put down to help, only two more finals tomorrow so I will have time to actually analyze the code after that. The method definitely makes sense, and the more advanced the better. The more tools I have to implement in my scripts the better off I'll be for future scripts. We must keep the community going.

Also, I manipulated some lines from the fisher and the script is pretty damn versatile. I made it fish/bank lobsters at the fishing guild (30k xp/hr: ~335 lobster/hr) and mine/bank iron ores by the resource dungeon in falador (20k xp/hr ~575 ores/hr).

abdul981

2015-01-08 02:22:28

wheres the download?

Theron

2015-01-17 10:47:28

This currently stable? Need to get my cooking up on my ironman account.:)

MasterXehanort

2015-02-06 18:47:15

From: Theron
This currently stable? Need to get my cooking up on my ironman account.:)


From: abdul981
wheres the download?


As I said in post 5, no plans on public release. The thread was made to help me fix some code logic. That being said, the script is still stable and took me to 99 fishing and banked 99 cooking. The script is still due for a major overhaul in writing, I did have a chance to work on it, but it is still far from a public release that is solely my own.