Sir R. M8gic1an
2010-06-10 18:28:22
Okay, I'm very slowly starting on the fisher. Just every now and then when I have a bit of time.
So my first step: I looked through my old fisher, to see the general structure of it, and see what funcs might be useful.
All of these would need a re-write if used, but I'll leave them here as refference.
[php]
Function DiscoverFishEquip: String;
var
i, Ix, Iy:integer;
begin
if not LoggedIn then exit;
Gametab(4);
RMDEbug('AutoDetecting equipment');
Result := '';
Gametab(4);
for i:= bmp_FishGear_Harpoon Downto bmp_FishGear_SmallNet do
begin
if FindBitmapToleranceIn(srl_GetBitmap(i), Ix, Iy, MIX1, MIY1, MIX2, MIY2, 10) then
begin
case i of
bmp_FishGear_SmallNet: Result := 'net';
bmp_FishGear_Rod : Result := 'rod';
bmp_FishGear_FlyRod : Result := 'fly';
bmp_FishGear_Cage : Result := 'cage';
bmp_FishGear_Harpoon : Result := 'harpoon';
end;
Players[CurrentPlayer].Integers[1] := srl_GetBitmap(i);
end;
if Result <> '' then break;
end;
if Result = '' then RMDebug('DiscoverFishEquip: Could not auto detect equip')
else RMDebug('fishing equip found: ' + Result);
end;
Function CheckEquip: Boolean;
var Ix, Iy, t, i:integer;
begin
if not LoggedIN then exit;
if FindNormalRandoms then exit;
for t := 0 to 2 do
begin
if Gametab(4) then break;
wait(1000+Random(500));
end;
if i >= 3 then
begin
RMDebug('couldnt get game tab');
Result := true;
CheckEquip;
exit;
end;
Result := FindBitmapToleranceIn(Players[CurrentPlayer].Integers[1], Ix, Iy, MIX1, MIY1, MIX2, MIY2, 10);
if not Result then RMDebug('CheckEquip: No fishing equipment found! - ');
end;
function PickUpFishingEquip(name:string):boolean;
var
TVFishingArray: TVariantArray;
x, y:integer;
begin
if not LoggedIn then exit;
if CheckEquip then exit;
if FindNormalRandoms then exit;
Result := False;
RMDebug('Looking for equip on the floor');
case lowercase(name) of
'harpoon': TVFishingArray := ['arpoon', 6645357, 14];
'cage': TVFishingArray := ['obster pot', 6974323, 7];
'fly', 'fly fishing': TVFishingArray := ['ly fishing', 872554, 13];
'rod', 'rod fishing': TVFishingArray := ['shing rod', 602951, 15];
'net': TVFishingArray := ['ing net', 1844525, 11];
else exit;
end;
RMFlag(5);
if (FindObj(x, y, TVFishingArray[0], TVFishingArray[1], TVFishingArray[2])) then
begin
RMDebug('Found Equip');
Inc(RodsFound);
Result := True;
Mouse(x, y, 0, 0, True)
RMFlag(5);
Wait(250);
end else
if Players[CurrentPlayer].loc <> 'power' then
Result := GetNewEquip
else begin
RMDebug('Could not find equip');
Players[CurrentPlayer].Rand := 'no equip';
end;
end;
function AreWeNearWater: Boolean;
var
arP: TPointArray;
tmpCTS, Time: Integer;
begin
Time := GetSystemTime;
Result := false;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.15, 0.25);
if not(FindColorsTolerance(arP, 9403503, MSCX-60, MSCY-60, MSCX+60, MSCY+60, 5)) then
begin
RMDebug('We are not near water 1');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
if (Length(arP) >= 1000) then
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if not Result then
begin
RMDebug('We are not near water 2');
Relocate('fish');
Exit;
end;
end;
function IsFishSpotClose: Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
TBs: Array[0..3] of TBox;
tmpCTS, i, j, arL, arL2, FindThisFish, WhirlPoolCheck: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
if not LoggedIn then exit;
Result := False;
if not AreWeNearWater then exit;
TBs[0] := IntToBox(MSCX-20, MSCY - 60, MSCX + 20, MSCY - 20);
TBs[1] := IntToBox(MSCX+20, MSCY - 20, MSCX + 60, MSCY + 20);
TBs[2] := IntToBox(MSCX-20, MSCY + 20, MSCX + 20, MSCY + 60);
TBs[3] := IntToBox(MSCX-60, MSCY - 20, MSCX - 20, MSCY + 20);
if (Round(rs_GetCompassAngleDegrees) mod 90) > 10 then
begin
case Round(rs_GetCompassAngleDegrees / 90) of
0: MakeCompass('w');
1: MakeCompass('n');
2: MakeCompass('e');
3: MakeCompass('s');
4: MakeCompass('w');
end;
RMDebug('IsFishSpotClose: re-adjusting compass ; angle: '+FloatToStr(rs_GetCompassAngleDegrees));
end;
MarkTime(FindThisFish);
MarkTime(WhirlPoolCheck);
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.12, 0.27);
repeat
if TimeFromMark(WhirlPoolCheck) > 500 then
begin
RMHandleWhirlPool;
exit;
end else
MarkTime(WhirlPoolCheck);
if TimeFromMark(FindThisFish) >= 3000 then break;
SetLength(ararP, 4);
for i:= 0 to 3 do
FindColorsTolerance(ararP, 11642528, TBs.x1, TBs.y1, TBs.x2, TBs.y2, 10);
try
arP := MergeATPA(ararP);
except
Continue;
end;
if Length(arP) <= 0 then
Continue;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC, X, Y, Z);
if (X >= 24.95) and (X <= 49.47) and (Y >= 26.29) and (Y <= 52.00) and (Z >= 35.63) and (Z <= 60.26) then
begin
for j := 0 to arL2 do
begin
if (arUC = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPA(arAP, 35);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP) < 10) then Continue;
//DebugTPA(ararP, 'RM_Fisher_Images - IsFishClose'+IntToStr(IsFishCloseN)) ;
if not DirSet then
begin
P := MiddleTPA(ararP);
GetWaterLocation(P);
end;
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
exit;
end;
until(TimeFromMark(FindThisFish) >= 3000);
RMDebug('no fish spot close');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
Function NextSpot: integer;
var
i:integer;
begin
if not LoggedIn then exit;
Result := 1;
for i:=1 to 28 do
if not ExistsItem(i) then
begin
Result:= i;
exit;
end;
end;
function PickUpFishingEquip(name:string):boolean;
var
TVFishingArray: TVariantArray;
x, y:integer;
begin
if not LoggedIn then exit;
if CheckEquip then exit;
if FindNormalRandoms then exit;
Result := False;
RMDebug('Looking for equip on the floor');
case lowercase(name) of
'harpoon': TVFishingArray := ['arpoon', 6645357, 14];
'cage': TVFishingArray := ['obster pot', 6974323, 7];
'fly', 'fly fishing': TVFishingArray := ['ly fishing', 872554, 13];
'rod', 'rod fishing': TVFishingArray := ['shing rod', 602951, 15];
'net': TVFishingArray := ['ing net', 1844525, 11];
else exit;
end;
RMFlag(5);
if (FindObj(x, y, TVFishingArray[0], TVFishingArray[1], TVFishingArray[2])) then
begin
RMDebug('Found Equip');
Inc(RodsFound);
Result := True;
Mouse(x, y, 0, 0, True)
RMFlag(5);
Wait(250);
end else
if Players[CurrentPlayer].loc <> 'power' then
Result := GetNewEquip
else begin
RMDebug('Could not find equip');
Players[CurrentPlayer].Rand := 'no equip';
end;
end;
function AreWeNearWater: Boolean;
var
arP: TPointArray;
tmpCTS, Time: Integer;
begin
Time := GetSystemTime;
Result := false;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.15, 0.25);
if not(FindColorsTolerance(arP, 9403503, MSCX-60, MSCY-60, MSCX+60, MSCY+60, 5)) then
begin
RMDebug('We are not near water 1');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
if (Length(arP) >= 1000) then
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if not Result then
begin
RMDebug('We are not near water 2');
Relocate('fish');
Exit;
end;
end;
function IsFishSpotClose: Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
TBs: Array[0..3] of TBox;
tmpCTS, i, j, arL, arL2, FindThisFish, WhirlPoolCheck: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
if not LoggedIn then exit;
Result := False;
if not AreWeNearWater then exit;
TBs[0] := IntToBox(MSCX-20, MSCY - 60, MSCX + 20, MSCY - 20);
TBs[1] := IntToBox(MSCX+20, MSCY - 20, MSCX + 60, MSCY + 20);
TBs[2] := IntToBox(MSCX-20, MSCY + 20, MSCX + 20, MSCY + 60);
TBs[3] := IntToBox(MSCX-60, MSCY - 20, MSCX - 20, MSCY + 20);
if (Round(rs_GetCompassAngleDegrees) mod 90) > 10 then
begin
case Round(rs_GetCompassAngleDegrees / 90) of
0: MakeCompass('w');
1: MakeCompass('n');
2: MakeCompass('e');
3: MakeCompass('s');
4: MakeCompass('w');
end;
RMDebug('IsFishSpotClose: re-adjusting compass ; angle: '+FloatToStr(rs_GetCompassAngleDegrees));
end;
MarkTime(FindThisFish);
MarkTime(WhirlPoolCheck);
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.12, 0.27);
repeat
if TimeFromMark(WhirlPoolCheck) > 500 then
begin
RMHandleWhirlPool;
exit;
end else
MarkTime(WhirlPoolCheck);
if TimeFromMark(FindThisFish) >= 3000 then break;
SetLength(ararP, 4);
for i:= 0 to 3 do
FindColorsTolerance(ararP, 11642528, TBs.x1, TBs.y1, TBs.x2, TBs.y2, 10);
try
arP := MergeATPA(ararP);
except
Continue;
end;
if Length(arP) <= 0 then
Continue;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC, X, Y, Z);
if (X >= 24.95) and (X <= 49.47) and (Y >= 26.29) and (Y <= 52.00) and (Z >= 35.63) and (Z <= 60.26) then
begin
for j := 0 to arL2 do
begin
if (arUC = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPA(arAP, 35);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP) < 10) then Continue;
//DebugTPA(ararP, 'RM_Fisher_Images - IsFishClose'+IntToStr(IsFishCloseN)) ;
if not DirSet then
begin
P := MiddleTPA(ararP);
GetWaterLocation(P);
end;
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
exit;
end;
until(TimeFromMark(FindThisFish) >= 3000);
RMDebug('no fish spot close');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
Function NextSpot: integer;
var
i:integer;
begin
if not LoggedIn then exit;
Result := 1;
for i:=1 to 28 do
if not ExistsItem(i) then
begin
Result:= i;
exit;
end;
end;
procedure DropFish;
var
i, x, y:integer;
TSA: TStringArray;
begin
if not LoggedIn then exit;
RMDebug('Dropping load');
if DropCrap then
TSA := ['eathe', 'bait', 'obster pot', 'arpoon', 'ly fish', 'ing rod', 'mall fish']
else
TSA := ['nchovies', 'erring', 'aw lobster', 'pike',
'almon', 'hrimps', 'ardine', 'wordfish', 'trout', 'tuna']
;
for i:= 1 to 28 do
begin
if (i mod 3) = 0 then NoRandoms;
MMouseItem(i);
wait(200 + random(50));
if DropCrap then
for x:= 0 to 3+Random(3) do
begin
if IsUpTextMultiCustom(TSA) then break;
if IsUpTextMultiCustom(['nchovies', 'erring', 'pike',
'almon', 'hrimps', 'ardine', 'wordfish', 'trout', 'tuna'])
then break;
wait(100);
end;
if IsUpTextMultiCustom(TSA) then
begin
if DropCrap then Continue;
GetMousePos(x, y);
Mouse(x, y, 2, 2, false);
wait(100+Random(50));
ChooseOption('Drop');
wait(RandomRange(50, 100));
end else begin
if not DropCrap then Continue;
GetMousePos(x, y);
Mouse(x, y, 2, 2, false);
wait(100+Random(50));
ChooseOption('Drop');
wait(RandomRange(50, 100));
end;
end;
Inc(Loads);
Inc(ReportVars[0]);
Inc(Players[CurrentPlayer].Banked);
RMDebug('Dropped a load');
Proggy;
end;
Function StartFishing: boolean;
var
i, x, y:integer;
s: string;
begin
if not LoggedIn then exit;
if InvFull then exit;
NoRandoms;
i:= 0;
Result := False;
if not CheckEquip then
begin
wait(1000 + Random(500));
if not PickUpFishingEquip(Players[CurrentPlayer].Strings[0]) then
begin
LogOut;
RMDebug('Player has no fishing equipment');
end;
end;
while not RMFindFishSpot do
begin
wait(1000);
NoRandoms;
inc(i);
if i > 2 then break;
end;
if i < 3 then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
RMDebug('Started Fishing');
Result := True;
end;
end;
Procedure WaitWhileFishing;
var
LastMove, LastAntiban, CheckSpot, SpotMark, FindFish, LastChecked, x, y: integer;
s: string;
begin
if not LoggedIn then exit;
MarkTime(FindFish);
MarkTime(LastMove);
RMFlag(5);
RMDebug('Getting to Fish Spot');
repeat
case lowercase(Players[CurrentPlayer].Strings[0]) of
'harpoon': s:= 'start harpooning';
'cage': s:= 'attempt to catch';
'fly': s:= 'attempt to catch';
'rod': s:= 'attempt to catch';
'net': s:= 'cast out your';
end;
if IsChatBoxTextAnyLine(s, clMessage) then break;
if TimeFromMark(FindFish) > 5000 then
begin
if FindTextTpa(0,2,MCX1,MCY1,MCX2,MCY2, 'have any feathers', NPCChars, Nothing) or
FindTextTpa(0,2,MCX1,MCY1,MCX2,MCY2, 'have any bait', NPCChars, Nothing) then
begin
RMDebug('Player is missing feathers / bait');
RMDebug('Logging Out');
LogOut;
exit;
end;
RMDebug('Getting to fish spot took too long');
if StartFishing then WaitWhileFishing else exit;
end;
until(false);
NoRandoms;
RMHandleWhirlpool;
RMDebug('Waiting while fishng');
CheckSpot := NextSpot;
MarkTime(SpotMark);
MarkTime(LastChecked);
MarkTime(FindFish);
MarkTime(LastAntiban);
repeat
if (TimeFromMark(Worked) >= (WorkTime + Random(3*60*1000))) then
begin
RMDebug('Wait while fising - Has served his time. Getting ready to switch');
exit;
end;
if not LoggedIn then
begin
RMDebug('Not Logged In!');
break;
end;
If TimeFromMark(LastChecked) > 500 then
begin
RMHandleWhirlpool;
if NoRandoms then
if not StartFishing then break else WaitWhileFishing;
MarkTime(LastChecked);
end;
if InvFull then
begin
Bank;
if not StartFishing then break else WaitWhileFishing;
end;
if ExistsItem(CheckSpot) then
begin
CheckSpot := NextSpot;
wait(50);
x := Length(TAverageFishTime.TIA);
SetLength(TAverageFishTime.TIA, x + 1);
TAverageFishTime.TIA[x] := TimeFromMark(SpotMark);
MarkTime(SpotMark);
end;
wait(450);
if TAverageFishTime.FishyTime + 10000 < 30000 then
y := 30000
else
y:= TAverageFishTime.FishyTime;
if (TimeFromMark(SpotMark) > y) then
begin
MarkTime(SpotMark);
wait(300);
RMDebug('WaitWhileFishing: Not Fishing…');
if StartFishing then WaitWhileFishing else break;
end;
if TimeFromMark(LastAntiban) > 1000+Random(1000) then
begin
MarkTime(LastAntiban);
Antiban(RandomRange(10, 20));
end;
if TimeFromMark(LastMove) > (20000 + Random(5000)) then
begin
AntiBan(100);
MarkTime(LastMove);
end;
if not CheckEquip then
begin
wait(1000 + Random(500));
if NoRandoms then
begin
if LoggedIn then
if StartFishing then
WaitWhileFishing
else
break
else
break
end else
if not PickUpFishingEquip(Players[CurrentPlayer].Strings[0]) then
begin
LogOut;
RMDebug(Players[CurrentPlayer].loc);
RMDebug('Player has no fishing equipment! - waitwhilefishing');
break;
end else
if StartFishing then WaitWhileFishing else break;
end;
if TimeFromMark(FindFish) > 1000 then
if not IsFishSpotClose then
begin
if StartFishing then
WaitWhileFishing
else break;
end else MarkTime(FindFish);
until(false)
end;
procedure DoSomeFishing; //only here while testing i think
var
TP: TPoint;
i, t, x, y: integer;
StartedFishing, FoundSymbol: boolean;
s: string;
begin
if not LoggedIn then exit;
if (TimeFromMark(Worked) >= WorkTime) then
begin
Relocate('bank');
exit;
end;
if not CheckEquip then
begin
wait(1000 + Random(500));
if not PickUpFishingEquip(Players[CurrentPlayer].Strings[0]) then
begin
LogOut;
Players[CurrentPlayer].Active := false;
RMDebug('Player has no fishing equipment');
exit;
end;
end;
if InvFull then Bank;
if Players[CurrentPlayer].loc <> 'power' then
Relocate('fish');
RMFlag(5);
wait(500+Random(1000));
for i:= 0 to 3 do
begin
FoundSymbol := SymbolLocate(i = 0);
if StartFishing then
begin
WaitWhileFishing;
exit;
end;
if not FoundSymbol then
begin
Relocate('bank');
Relocate('fish');
if not FindFishSymbol(false, TP) then
begin
Players[CurrentPlayer].Active := False;
Players[CurrentPlayer].Rand := 'lost';
Logout;
exit;
end;
end;
end;
end;
[/php]
ps: This script is very old, and some of the code just seems senseless to me.
~RM
So my first step: I looked through my old fisher, to see the general structure of it, and see what funcs might be useful.
All of these would need a re-write if used, but I'll leave them here as refference.
[php]
Function DiscoverFishEquip: String;
var
i, Ix, Iy:integer;
begin
if not LoggedIn then exit;
Gametab(4);
RMDEbug('AutoDetecting equipment');
Result := '';
Gametab(4);
for i:= bmp_FishGear_Harpoon Downto bmp_FishGear_SmallNet do
begin
if FindBitmapToleranceIn(srl_GetBitmap(i), Ix, Iy, MIX1, MIY1, MIX2, MIY2, 10) then
begin
case i of
bmp_FishGear_SmallNet: Result := 'net';
bmp_FishGear_Rod : Result := 'rod';
bmp_FishGear_FlyRod : Result := 'fly';
bmp_FishGear_Cage : Result := 'cage';
bmp_FishGear_Harpoon : Result := 'harpoon';
end;
Players[CurrentPlayer].Integers[1] := srl_GetBitmap(i);
end;
if Result <> '' then break;
end;
if Result = '' then RMDebug('DiscoverFishEquip: Could not auto detect equip')
else RMDebug('fishing equip found: ' + Result);
end;
Function CheckEquip: Boolean;
var Ix, Iy, t, i:integer;
begin
if not LoggedIN then exit;
if FindNormalRandoms then exit;
for t := 0 to 2 do
begin
if Gametab(4) then break;
wait(1000+Random(500));
end;
if i >= 3 then
begin
RMDebug('couldnt get game tab');
Result := true;
CheckEquip;
exit;
end;
Result := FindBitmapToleranceIn(Players[CurrentPlayer].Integers[1], Ix, Iy, MIX1, MIY1, MIX2, MIY2, 10);
if not Result then RMDebug('CheckEquip: No fishing equipment found! - ');
end;
function PickUpFishingEquip(name:string):boolean;
var
TVFishingArray: TVariantArray;
x, y:integer;
begin
if not LoggedIn then exit;
if CheckEquip then exit;
if FindNormalRandoms then exit;
Result := False;
RMDebug('Looking for equip on the floor');
case lowercase(name) of
'harpoon': TVFishingArray := ['arpoon', 6645357, 14];
'cage': TVFishingArray := ['obster pot', 6974323, 7];
'fly', 'fly fishing': TVFishingArray := ['ly fishing', 872554, 13];
'rod', 'rod fishing': TVFishingArray := ['shing rod', 602951, 15];
'net': TVFishingArray := ['ing net', 1844525, 11];
else exit;
end;
RMFlag(5);
if (FindObj(x, y, TVFishingArray[0], TVFishingArray[1], TVFishingArray[2])) then
begin
RMDebug('Found Equip');
Inc(RodsFound);
Result := True;
Mouse(x, y, 0, 0, True)
RMFlag(5);
Wait(250);
end else
if Players[CurrentPlayer].loc <> 'power' then
Result := GetNewEquip
else begin
RMDebug('Could not find equip');
Players[CurrentPlayer].Rand := 'no equip';
end;
end;
function AreWeNearWater: Boolean;
var
arP: TPointArray;
tmpCTS, Time: Integer;
begin
Time := GetSystemTime;
Result := false;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.15, 0.25);
if not(FindColorsTolerance(arP, 9403503, MSCX-60, MSCY-60, MSCX+60, MSCY+60, 5)) then
begin
RMDebug('We are not near water 1');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
if (Length(arP) >= 1000) then
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if not Result then
begin
RMDebug('We are not near water 2');
Relocate('fish');
Exit;
end;
end;
function IsFishSpotClose: Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
TBs: Array[0..3] of TBox;
tmpCTS, i, j, arL, arL2, FindThisFish, WhirlPoolCheck: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
if not LoggedIn then exit;
Result := False;
if not AreWeNearWater then exit;
TBs[0] := IntToBox(MSCX-20, MSCY - 60, MSCX + 20, MSCY - 20);
TBs[1] := IntToBox(MSCX+20, MSCY - 20, MSCX + 60, MSCY + 20);
TBs[2] := IntToBox(MSCX-20, MSCY + 20, MSCX + 20, MSCY + 60);
TBs[3] := IntToBox(MSCX-60, MSCY - 20, MSCX - 20, MSCY + 20);
if (Round(rs_GetCompassAngleDegrees) mod 90) > 10 then
begin
case Round(rs_GetCompassAngleDegrees / 90) of
0: MakeCompass('w');
1: MakeCompass('n');
2: MakeCompass('e');
3: MakeCompass('s');
4: MakeCompass('w');
end;
RMDebug('IsFishSpotClose: re-adjusting compass ; angle: '+FloatToStr(rs_GetCompassAngleDegrees));
end;
MarkTime(FindThisFish);
MarkTime(WhirlPoolCheck);
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.12, 0.27);
repeat
if TimeFromMark(WhirlPoolCheck) > 500 then
begin
RMHandleWhirlPool;
exit;
end else
MarkTime(WhirlPoolCheck);
if TimeFromMark(FindThisFish) >= 3000 then break;
SetLength(ararP, 4);
for i:= 0 to 3 do
FindColorsTolerance(ararP, 11642528, TBs.x1, TBs.y1, TBs.x2, TBs.y2, 10);
try
arP := MergeATPA(ararP);
except
Continue;
end;
if Length(arP) <= 0 then
Continue;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC, X, Y, Z);
if (X >= 24.95) and (X <= 49.47) and (Y >= 26.29) and (Y <= 52.00) and (Z >= 35.63) and (Z <= 60.26) then
begin
for j := 0 to arL2 do
begin
if (arUC = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPA(arAP, 35);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP) < 10) then Continue;
//DebugTPA(ararP, 'RM_Fisher_Images - IsFishClose'+IntToStr(IsFishCloseN)) ;
if not DirSet then
begin
P := MiddleTPA(ararP);
GetWaterLocation(P);
end;
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
exit;
end;
until(TimeFromMark(FindThisFish) >= 3000);
RMDebug('no fish spot close');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
Function NextSpot: integer;
var
i:integer;
begin
if not LoggedIn then exit;
Result := 1;
for i:=1 to 28 do
if not ExistsItem(i) then
begin
Result:= i;
exit;
end;
end;
function PickUpFishingEquip(name:string):boolean;
var
TVFishingArray: TVariantArray;
x, y:integer;
begin
if not LoggedIn then exit;
if CheckEquip then exit;
if FindNormalRandoms then exit;
Result := False;
RMDebug('Looking for equip on the floor');
case lowercase(name) of
'harpoon': TVFishingArray := ['arpoon', 6645357, 14];
'cage': TVFishingArray := ['obster pot', 6974323, 7];
'fly', 'fly fishing': TVFishingArray := ['ly fishing', 872554, 13];
'rod', 'rod fishing': TVFishingArray := ['shing rod', 602951, 15];
'net': TVFishingArray := ['ing net', 1844525, 11];
else exit;
end;
RMFlag(5);
if (FindObj(x, y, TVFishingArray[0], TVFishingArray[1], TVFishingArray[2])) then
begin
RMDebug('Found Equip');
Inc(RodsFound);
Result := True;
Mouse(x, y, 0, 0, True)
RMFlag(5);
Wait(250);
end else
if Players[CurrentPlayer].loc <> 'power' then
Result := GetNewEquip
else begin
RMDebug('Could not find equip');
Players[CurrentPlayer].Rand := 'no equip';
end;
end;
function AreWeNearWater: Boolean;
var
arP: TPointArray;
tmpCTS, Time: Integer;
begin
Time := GetSystemTime;
Result := false;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.15, 0.25);
if not(FindColorsTolerance(arP, 9403503, MSCX-60, MSCY-60, MSCX+60, MSCY+60, 5)) then
begin
RMDebug('We are not near water 1');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
if (Length(arP) >= 1000) then
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if not Result then
begin
RMDebug('We are not near water 2');
Relocate('fish');
Exit;
end;
end;
function IsFishSpotClose: Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
TBs: Array[0..3] of TBox;
tmpCTS, i, j, arL, arL2, FindThisFish, WhirlPoolCheck: Integer;
P: TPoint;
X, Y, Z: Extended;
begin
if not LoggedIn then exit;
Result := False;
if not AreWeNearWater then exit;
TBs[0] := IntToBox(MSCX-20, MSCY - 60, MSCX + 20, MSCY - 20);
TBs[1] := IntToBox(MSCX+20, MSCY - 20, MSCX + 60, MSCY + 20);
TBs[2] := IntToBox(MSCX-20, MSCY + 20, MSCX + 20, MSCY + 60);
TBs[3] := IntToBox(MSCX-60, MSCY - 20, MSCX - 20, MSCY + 20);
if (Round(rs_GetCompassAngleDegrees) mod 90) > 10 then
begin
case Round(rs_GetCompassAngleDegrees / 90) of
0: MakeCompass('w');
1: MakeCompass('n');
2: MakeCompass('e');
3: MakeCompass('s');
4: MakeCompass('w');
end;
RMDebug('IsFishSpotClose: re-adjusting compass ; angle: '+FloatToStr(rs_GetCompassAngleDegrees));
end;
MarkTime(FindThisFish);
MarkTime(WhirlPoolCheck);
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.12, 0.27);
repeat
if TimeFromMark(WhirlPoolCheck) > 500 then
begin
RMHandleWhirlPool;
exit;
end else
MarkTime(WhirlPoolCheck);
if TimeFromMark(FindThisFish) >= 3000 then break;
SetLength(ararP, 4);
for i:= 0 to 3 do
FindColorsTolerance(ararP, 11642528, TBs.x1, TBs.y1, TBs.x2, TBs.y2, 10);
try
arP := MergeATPA(ararP);
except
Continue;
end;
if Length(arP) <= 0 then
Continue;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC, X, Y, Z);
if (X >= 24.95) and (X <= 49.47) and (Y >= 26.29) and (Y <= 52.00) and (Z >= 35.63) and (Z <= 60.26) then
begin
for j := 0 to arL2 do
begin
if (arUC = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPA(arAP, 35);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP) < 10) then Continue;
//DebugTPA(ararP, 'RM_Fisher_Images - IsFishClose'+IntToStr(IsFishCloseN)) ;
if not DirSet then
begin
P := MiddleTPA(ararP);
GetWaterLocation(P);
end;
Result := true;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
exit;
end;
until(TimeFromMark(FindThisFish) >= 3000);
RMDebug('no fish spot close');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
Function NextSpot: integer;
var
i:integer;
begin
if not LoggedIn then exit;
Result := 1;
for i:=1 to 28 do
if not ExistsItem(i) then
begin
Result:= i;
exit;
end;
end;
procedure DropFish;
var
i, x, y:integer;
TSA: TStringArray;
begin
if not LoggedIn then exit;
RMDebug('Dropping load');
if DropCrap then
TSA := ['eathe', 'bait', 'obster pot', 'arpoon', 'ly fish', 'ing rod', 'mall fish']
else
TSA := ['nchovies', 'erring', 'aw lobster', 'pike',
'almon', 'hrimps', 'ardine', 'wordfish', 'trout', 'tuna']
;
for i:= 1 to 28 do
begin
if (i mod 3) = 0 then NoRandoms;
MMouseItem(i);
wait(200 + random(50));
if DropCrap then
for x:= 0 to 3+Random(3) do
begin
if IsUpTextMultiCustom(TSA) then break;
if IsUpTextMultiCustom(['nchovies', 'erring', 'pike',
'almon', 'hrimps', 'ardine', 'wordfish', 'trout', 'tuna'])
then break;
wait(100);
end;
if IsUpTextMultiCustom(TSA) then
begin
if DropCrap then Continue;
GetMousePos(x, y);
Mouse(x, y, 2, 2, false);
wait(100+Random(50));
ChooseOption('Drop');
wait(RandomRange(50, 100));
end else begin
if not DropCrap then Continue;
GetMousePos(x, y);
Mouse(x, y, 2, 2, false);
wait(100+Random(50));
ChooseOption('Drop');
wait(RandomRange(50, 100));
end;
end;
Inc(Loads);
Inc(ReportVars[0]);
Inc(Players[CurrentPlayer].Banked);
RMDebug('Dropped a load');
Proggy;
end;
Function StartFishing: boolean;
var
i, x, y:integer;
s: string;
begin
if not LoggedIn then exit;
if InvFull then exit;
NoRandoms;
i:= 0;
Result := False;
if not CheckEquip then
begin
wait(1000 + Random(500));
if not PickUpFishingEquip(Players[CurrentPlayer].Strings[0]) then
begin
LogOut;
RMDebug('Player has no fishing equipment');
end;
end;
while not RMFindFishSpot do
begin
wait(1000);
NoRandoms;
inc(i);
if i > 2 then break;
end;
if i < 3 then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
RMDebug('Started Fishing');
Result := True;
end;
end;
Procedure WaitWhileFishing;
var
LastMove, LastAntiban, CheckSpot, SpotMark, FindFish, LastChecked, x, y: integer;
s: string;
begin
if not LoggedIn then exit;
MarkTime(FindFish);
MarkTime(LastMove);
RMFlag(5);
RMDebug('Getting to Fish Spot');
repeat
case lowercase(Players[CurrentPlayer].Strings[0]) of
'harpoon': s:= 'start harpooning';
'cage': s:= 'attempt to catch';
'fly': s:= 'attempt to catch';
'rod': s:= 'attempt to catch';
'net': s:= 'cast out your';
end;
if IsChatBoxTextAnyLine(s, clMessage) then break;
if TimeFromMark(FindFish) > 5000 then
begin
if FindTextTpa(0,2,MCX1,MCY1,MCX2,MCY2, 'have any feathers', NPCChars, Nothing) or
FindTextTpa(0,2,MCX1,MCY1,MCX2,MCY2, 'have any bait', NPCChars, Nothing) then
begin
RMDebug('Player is missing feathers / bait');
RMDebug('Logging Out');
LogOut;
exit;
end;
RMDebug('Getting to fish spot took too long');
if StartFishing then WaitWhileFishing else exit;
end;
until(false);
NoRandoms;
RMHandleWhirlpool;
RMDebug('Waiting while fishng');
CheckSpot := NextSpot;
MarkTime(SpotMark);
MarkTime(LastChecked);
MarkTime(FindFish);
MarkTime(LastAntiban);
repeat
if (TimeFromMark(Worked) >= (WorkTime + Random(3*60*1000))) then
begin
RMDebug('Wait while fising - Has served his time. Getting ready to switch');
exit;
end;
if not LoggedIn then
begin
RMDebug('Not Logged In!');
break;
end;
If TimeFromMark(LastChecked) > 500 then
begin
RMHandleWhirlpool;
if NoRandoms then
if not StartFishing then break else WaitWhileFishing;
MarkTime(LastChecked);
end;
if InvFull then
begin
Bank;
if not StartFishing then break else WaitWhileFishing;
end;
if ExistsItem(CheckSpot) then
begin
CheckSpot := NextSpot;
wait(50);
x := Length(TAverageFishTime.TIA);
SetLength(TAverageFishTime.TIA, x + 1);
TAverageFishTime.TIA[x] := TimeFromMark(SpotMark);
MarkTime(SpotMark);
end;
wait(450);
if TAverageFishTime.FishyTime + 10000 < 30000 then
y := 30000
else
y:= TAverageFishTime.FishyTime;
if (TimeFromMark(SpotMark) > y) then
begin
MarkTime(SpotMark);
wait(300);
RMDebug('WaitWhileFishing: Not Fishing…');
if StartFishing then WaitWhileFishing else break;
end;
if TimeFromMark(LastAntiban) > 1000+Random(1000) then
begin
MarkTime(LastAntiban);
Antiban(RandomRange(10, 20));
end;
if TimeFromMark(LastMove) > (20000 + Random(5000)) then
begin
AntiBan(100);
MarkTime(LastMove);
end;
if not CheckEquip then
begin
wait(1000 + Random(500));
if NoRandoms then
begin
if LoggedIn then
if StartFishing then
WaitWhileFishing
else
break
else
break
end else
if not PickUpFishingEquip(Players[CurrentPlayer].Strings[0]) then
begin
LogOut;
RMDebug(Players[CurrentPlayer].loc);
RMDebug('Player has no fishing equipment! - waitwhilefishing');
break;
end else
if StartFishing then WaitWhileFishing else break;
end;
if TimeFromMark(FindFish) > 1000 then
if not IsFishSpotClose then
begin
if StartFishing then
WaitWhileFishing
else break;
end else MarkTime(FindFish);
until(false)
end;
procedure DoSomeFishing; //only here while testing i think
var
TP: TPoint;
i, t, x, y: integer;
StartedFishing, FoundSymbol: boolean;
s: string;
begin
if not LoggedIn then exit;
if (TimeFromMark(Worked) >= WorkTime) then
begin
Relocate('bank');
exit;
end;
if not CheckEquip then
begin
wait(1000 + Random(500));
if not PickUpFishingEquip(Players[CurrentPlayer].Strings[0]) then
begin
LogOut;
Players[CurrentPlayer].Active := false;
RMDebug('Player has no fishing equipment');
exit;
end;
end;
if InvFull then Bank;
if Players[CurrentPlayer].loc <> 'power' then
Relocate('fish');
RMFlag(5);
wait(500+Random(1000));
for i:= 0 to 3 do
begin
FoundSymbol := SymbolLocate(i = 0);
if StartFishing then
begin
WaitWhileFishing;
exit;
end;
if not FoundSymbol then
begin
Relocate('bank');
Relocate('fish');
if not FindFishSymbol(false, TP) then
begin
Players[CurrentPlayer].Active := False;
Players[CurrentPlayer].Rand := 'lost';
Logout;
exit;
end;
end;
end;
end;
[/php]
ps: This script is very old, and some of the code just seems senseless to me.
~RM