SRL Archive - SRL Archives

*FindWhirPoolXY and FindWhirlPoolMS


Sir R. M8gic1an

2009-01-26 06:42:25


{*******************************************************************************
function FindWhirPoolXY(x, y:integer): Boolean;
by: Rasta Magician
Description: Returns true if whirpool found at (x,y)
*******************************************************************************}
function FindWhirlPoolXY(x, y:integer): Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
if not LoggedIn then exit;
Result := False;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.21, 1.58);

if not(FindColorsTolerance(arP, 13940675, x-25, y-25, x+25, y+25, 15)) then
begin
//Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPA(arP, 5);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) > Round(300*WhirlPoolAcc)) then
begin
Result := True;

writeln('Found Whirlpool! ');
writeln('Whirpool Points: '+IntToStr(Length(ararP[i])));


break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

each rs square is 40*40, thise searches in an area of 45*45 just in case the x,y given is not the exact center of the square.
WhirpoolAcc is a constant extended that already exists in Fishing.scar and is default set to 1.00


{*******************************************************************************
function FindWhirPoolMS: Boolean;
by: Wizzup, edited by Rasta Magician
Description: Returns true if whirpool found in MainScreen
*******************************************************************************}
function FindWhirlPoolMS: Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
if not LoggedIn then exit;
Result := False;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.21, 1.58);

if not(FindColorsTolerance(arP, 13940675, MSX1, MSY2, MSX2, MSY2, 15)) then
begin
//Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPA(arP, 5);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) > Round(300*WhirlPoolAcc)) then
begin
Result := True;

writeln('Found Whirlpool!');
writeln('Whirpool Points: '+IntToStr(Length(ararP[i])));


break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

returns true if found on the mainscreen at all


{*******************************************************************************
function FindWhirPoolEx: Boolean;
by: Rasta Magician
Description: Returns true if whirpool found in the 4 spots around your
player in which he might be fishing in
*******************************************************************************}
function FindWhirlPoolEx: Boolean;
begin
Result := True;
if not FindWhirlPoolXY(MSCX - 20, MSCY) then
if not FindWhirlPoolXY(MSCX + 20, MSCY) then
if not FindWhirlPoolXY(MSCX, MSCY - 20) then
if not FindWhirlPoolXY(MSCX, MSCY + 20) then
Result := False;
end;

return true if the whirpool is found on any of the 4 spots around the player that you might be fishing in.

hope you like it :)

~RM

benjaa

2009-01-26 06:49:47

!! this is really useful

thanks rasta! ill go test it on an account :)

keep it up
rep++

JuKKa

2009-01-26 08:12:53

It should be distance instead…

lets say inrange of about 10-40

ZephyrsFury

2009-01-26 08:14:20

Is the one in SRL outdated? If it is and this works then I'll add it.

JuKKa

2009-01-26 08:15:54


Function FindWhirlPool: Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
if not LoggedIn then exit;
Result := False;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(1.21, 1.58);

if not(FindColorsTolerance(arP, 13940675, MSX1, MSY2, MSX2, MSY2, 15)) then
begin
//Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPA(arP, 5);
arL := High(ararP);

for i := 0 to arL do
begin
if (Length(ararP[i]) > Round(300*WhirlPoolAcc)) then
Result := InRange(Distance(MSCX, MSCY, ararP[I].X, ararp[I].Y), 10, 35);
If(Result)Then
Break;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2M(0.2, 0.2);
end;

Thats the way to do it!!!

Sir R. M8gic1an

2009-01-26 08:23:55

Jukka wtf are you on about? :)

find whirpoolXY does not need distance as it only searches in a box around the point given, therefore making it faster rather than searching the whole MS and then comparing distances. (and already ensures that it is at minimum distance)

FindWhirpoolMS i don't see why distance as it has nothing to reffer to. and the point of it is finding a whirlpool anywhere on the MS. no idea why, just the way Wizzup had it in fishing.scar.


edit: and that wouldn't even compile as ararP.x would not work. ararP = ATPA, ararP = TPA, so what you are looking for is actually ararP[0].x ;)

From: Jukka
Thats the way to do it!!!


Zeph: yes, the one in Fishing.scar is very outdated. Wizzup made it for 2-3 updates ago.

~RM

JuKKa

2009-01-26 08:32:11

my way is faster.. Scar is quite fast using Findcolorsspiraltolerance. Its faster using it once then calling it 4 times.

and im sure u could make it compile, havent scripted for scar in ages.

and if i understand correctly ur saying that distance is slow? Cause its not. Distance is still the way to do it !!!

Sir R. M8gic1an

2009-01-26 08:38:12

Two Counter arguments for that:
1. the distances are wrong :p
2. by using that way you may also detect a whirpool on the fishing spot NEXT to yours, but NOT yours and still return whirpool found.

~RM

ZephyrsFury

2009-01-26 08:44:01

I think it would be good to have the function check just the area surrounding the player rather than the whole mainscreen.