SRL Archive - JM Competition Judging

Ollybest


BraK

2012-11-06 12:09:46

Didn't leave any script setup information.

program OllysFishNdCook;

{$define SMART}
{$i SRL/SRL.simba}
{$i SRL/SRL/misc/reports.simba}
{$i SRL/SRL/misc/debug.simba}
{$i SRL/SRL/misc/smartgraphics.simba}
const

(*

Infomation:

This script fishes and cooks herring and sardine in alkarid (west of the bank).

Setup:

#1 Change the settings below to suit your needs
#2 Enter player info starting at line 42
#3 Make sure you have the levels reqiured (10 fishing, 5 cooking)
#4 Make sure you have *fishing bait* in your invent and a *fishing rod in your toolbelt*
#5 Have your player at one of the two fishing spots (should work from anywhere around it but just to be safe)
- [url]http://i.imgur.com/xNl1v.png[/url]
#6 Start the script and get going!

Notes:

I made this script in the first week of the comp and never really touched it since... because I lost intrest quickly
but here it is. This is a multiplayer version so I can enter the comp, I have a single player version that has a form
but i nearly killed myself trying to make the form work for multiplayer. Also you need SMART for this script.

*)

{Script Settings}
DropBurnt = False; //Drop the burnt food we cook?
TakeBreaks = True; //Take random breaks? Every 1 - 4 hrs for 5-30mins

{Mouse}
MouseTrail = True; //display fancy mousetrails?
Mouse_Speed = 18; //mousespeed higher = faster, lowest = slower (default 18)

{Debug}
Text_Debug = True; //display debug in the debug box?
SMART_Debug = True; //display onscreen debug?

procedure DeclarePlayers;
begin
HowManyPlayers := 1; //HOW MANY PLAYERS? CHANGE!
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
BoxRewards := ['xp', 'lamp'];
end;
{ with Players[1] do //remove brackets if using
begin
Name := ''; //you get the jist if you want more players
Pass := '';
Active := True;
BoxRewards := ['xp', 'lamp'];
end;
with Players[2] do
begin
Name := ''; //you get the jist if you want more players
Pass := '';
Active := True;
BoxRewards := ['xp', 'lamp'];
end; } //remove brackets if using
end;

//global vars, alot of them but i dont feel like loading then freeing data every 2 seconds
var
Bait_BMP, RawHerring_BMP, RawSardine_BMP, CookedHerring_BMP, BurntFood_BMP,
CookedSardine_BMP, FishOutline_BMP, Paint_BMP: Integer; //bitmaps
RightSpot_DTMs, LeftSpot_DTMs, Range_DTMs: TIntegerArray; //dtm arrays
Compass_Time, Bait_Time, NextBreak, BreakTime : Integer; //timers
FishSpotBox, ClientArea, ClearScreen: TBox; //boxes
HerringCount, SardineCount, BurntCount, trips, cookedsard, cookedherr : Integer; //counters
FishBox: TPointArray; //box (as a tpa)
Spot, Version: String; //text
Label
ScriptStart;

//loads vars at the start of the script
procedure LoadVars;
begin
Version := '1.00';
SetArrayLength(Range_DTMs, 5);
SetArrayLength(LeftSpot_DTMs, 4);
SetArrayLength(RightSpot_DTMs, 4);
FishSpotBox := Inttobox(249, 244 - 50, 272, 282 - 50);
TPAFromBoxWrap(IntToBox(249, 250 - 50, 272, 273 - 50), FishBox);
If (TakeBreaks) Then
begin
NextBreak := RandomRange(3600000,14400000);
Marktime(BreakTime);
end;
end;

//credit to ashaman, will check if we're not logged in multiple times to prevent false postives
function WaitLoggedIn(Time: Integer): Boolean;
var
T: Integer;
begin
repeat
MarkTime(T);
SRL_ResetNavBar;
if TimeFromMark(T) > Time then
begin
Result := False;
Exit;
end;
until (GetColor(472, 490) = 16777215);
Result := True;
end;

//debug with time and the function
procedure O_Debug(Func, Text: string);
begin
if (Text_Debug) then
Writeln('[' + MsToTime(GetTimeRunning, TIME_BARE) + '] - [' + Func + '] > ' + Text);
end;

//takes a screenshot and saves it in a file
procedure O_ScreenShot(Reason: string);
var
Path, Filename, Time: string;
I: integer;
begin
Time := TheTime;
Path := AppPath + 'Scripts' + + '/Fish Cook Bank' + {$IFDEF WINDOWS}
'\' {$ELSE}
'/' {$ENDIF}
if (not (DirectoryExists(Path))) then
if (not (CreateDirectory(Path))) then
begin
O_Debug('SCREENSHOT', 'Could Not Save Screenshot');
Exit;
end;
for I := 0 to High(I) do
begin
Filename := Reason + ' ' + TheDate(Date_Day) + ' ' + IntToStr(I) + '.png';
if (not (FileExists(Path + Filename))) then
Break;
end;
SaveScreenshot(Path + Filename);
O_Debug('SCREENSHOT', ' Screenshot saved as "' + Path + Filename + '"');
end;

//loads data.. bitmaps/dtms ugly but hey more dtms = less chance of failing!
procedure LoadData;
begin
Paint_BMP := BitmapFromString(765, 51, 'meJzt1kEKgwAQBMGc/f9/k0BARES8JMHtKua2+4BeFgAAAACGezyeZmZmZrfexeD5QVkBAHzVedUIHgBgmMO80TwAwEi7yNE8AMBg29SRPQDAYGvqaB4AYLxP8MgeAGA82QMARMgeACBC9gAAEbIHAIiQPQBAhOwBACJkDwAQIXsAgAjZAwBEyB4AIEL2AAARsgcAiJA9AECE7AEAImQPABAhewCACNkDAETIHgAgQvYAABGyBwCIkD0AQITsAQAiZA8AECF7AIAI2QMARMgeACBC9gAAEbIHAIiQPQBAhOwBACJkDwAQIXsAgAjZAwBErMGjfACAwbapI3sAgMF2qaN8AICRDiNH+QAAw5zkzfskfgCAAS5WzefNzMzM7L77QVkBAAAA8Ecv/phZ6g==');
//bitmaps! a change from dtms
Bait_BMP := BitmapFromString(19, 15, 'meJxjYKAHYGJgkGzcBERMMC4TKXrhiiGGkOcA4m0kD+AxH5cUEyxksCrAJQUPTPyyTLjF8ViHy0z8oUej4CXDWCYifIpVFzxI8YQt8QAA/QEeHQ==');
RawSardine_BMP := BitmapFromString(9, 8, 'meJxjYCABeDV7Bk8JwhT36/YFiiesikcTBwqGzw7DFJ+0YuLUNVNmrJ+OJr5w18Il+5YkrklAE1+wc0Hy+qTUTcnEOxUA6EMZ1g==');
RawHerring_BMP := BitmapFromString(8, 6, 'meJxjYMAJNm7cuXXbvl27Dq1cuRGIVq/eBBEHiuzde/TgoVPrN2xft27b7j1HIOJAkSNHz544eQmoC4iOHTsPEQeKnD5z9cKFm0CVEITbTgYA51U1Wg==');
CookedSardine_BMP := BitmapFromString(15, 14, 'meJxjYBhgwARGxAAf3wgizYxPyo+JyyaoLDwyBagyv7CBoMqomIzE5EJiVAINTE0vJaiytKK9orq7qqa3tmEifpXVdf0t7TPbu+cStBpoGlBlQXETQZXllZ3NbTN6Jy7Br4wJ7M6G5ildfQsImklkJEIAAKIHJ4A=');
CookedHerring_BMP := BitmapFromString(16, 6, 'meJxjYKAHqKjurq7rq2uc1NA8pbltem5+HRABuUDx4rLWvMIGIEJWD1fZ0j6zvWtOUUkzELV1zoZoKShuBHLp4nAGAGjDJC4=');
BurntFood_BMP := BitmapFromString(9, 9, 'meJxjYKAOMDA0xipubGxqYWHt4uKOJm5mZgEUd3JyRRMHClpb22KK+/sHBwaFBoeEU+5UAB8xCdA=');
FishOutline_BMP := BitmapFromString(30, 30, 'meJxjYKAp+E8DBDVZX5+aCM1kavl/1ORRk0dNHjV51ORRk0dNHjUZl8k0asnQrPVFEwAATHbz6Q==');

RightSpot_DTMs[0] := DTMFromString('mlwAAAHicY2dgYChhYmAIBOJOIM4F4lYgrgFiPyDuAMoXAnEllI4F4kQgngbE////Z/DLM8XAv58xMHxhZGCQZMCOGfFgKAAAUqQRfA==');
RightSpot_DTMs[1] := DTMFromString('mrAAAAHic42BgYChhYmDIBOIqIO4FYj8gngzE8UBcAcQdQDUroHgJEE8D4hwg3g7EsUD8//9/hs6emXD8+xkDQ6e/EkN8sAmDX54pwxdGBgY5Bgg2YkCwYZiRAIYBAHtTFuM=');
RightSpot_DTMs[2] := DTMFromString('mggAAAHicY2NgYChhYmDoAuJWIA4E4gAg9gPiDqBcFxBPAuIwII4D4mlA/P//f4bOnplg/PsZAxx/YWRgkGPAxIw4MAQAALKnEwA=');
RightSpot_DTMs[3] := DTMFromString('m1gAAAHic42JgYChhYmBIBuJIIPYBYm8gjgfiVCDOAeJ8IJ4IxB1AtfVAPBWI5wNxNxDvgOJCIE4B4kYg/v//P0OnvxJDXrgSQ019N0Nnz0yG+GATMPbLM2VoygsBi31hZGCQYyCMGYnECAAADPYZcA==');

LeftSpot_DTMs[0] := DTMFromString('mggAAAHicY2NgYJAEYkUGCLCHYgcgNgJibyC2gcpxA7EzEP///5+hs38uGP9+xgDHXxgZGOQYMDEjDgwBAFEkD6E=');
LeftSpot_DTMs[1] := DTMFromString('mrAAAAHic42BgYChmYmBIBOIiIG4C4mgg9oWKzQLiNqCaqUC8EIjnAnEtEBcBcQEQTwfi////M3T2z0XgIDU4/v2MgeELIwODHANuzEgAwwAAQ84Wog==');
LeftSpot_DTMs[2] := DTMFromString('mlwAAAHicY2dgYChgYmCYCcQNQFwDxMVAvAiIZwFxHVC+H4gnAfEsIJ4DxMVAnAHEmaFWDK9eMTB09s6GY988UzD+wsjAoMyAHTPiwVAAAPB4Ewc=');
LeftSpot_DTMs[3] := DTMFromString('mrAAAAHic42BgYChmYmBYAMTVQBwCxElAXADETUA8C4jbgGomAvECIO4F4i1AvB2IdwLxdCD+//8/Q16UGkNn/1wwdnUzYnC0M2bw97Fj+P2MgeELIwODHANuzEgAwwAARMEWNQ==');

Range_DTMs[0] := DTMFromString('mFQEAAHic42VgYAhiYmDwAeIwII4D4nQgdgNiFyBuwoETgfqWAPEKIF4FxKuBeBYQNwBxDhBnAHEqA0RdLBAvZgABRoaOvvkYuLc0mOHZCwGs+AsjA4MGA2mYkQyMAgA+TyQi');
Range_DTMs[1] := DTMFromString('mAAEAAHic42FgYAhiYmDwAeJ6IE4B4kggdgLiJiB2BWJfILYGYksgbgHiRKCeJUA8HYiXAfFqIK4H4sVA3AHEVUBcA8RdQFzLAAKMDB1981HwpKowhmcvBBiK3DQZ2vxVwTRI3DvPguELIwODBgPxmJFEjAwAl6cdEQ==');
Range_DTMS[2] := DTMFromString('m1gAAAHic42JgYMhhYmAIB+JYIE4G4jwgrgDiJiCeB8QLoXJeQLWVQFwPxB1APAmIpwHxZCDuA+IwIE4H4gMHDjC0TZ6DFT95ywXGnbVxDF8YGRg0GAhjRiIxAgAAulYddQ==');
Range_DTMs[3] := DTMFromString('m6wAAAHic42ZgYMhhYmBIB+IEIA4B4hggTgLifCCuB+KVQLwIiOcAsRdQfTIQFwJxChBnAHE7EE8C4mlAXAAVbwDiAwcOMLSGKMPxhLpghrbJc+DYq9gMjEHsL4wMDMoMxGFGEjASAACRJBvW');
Range_DTms[4] := DTMFromString('mvQEAAHictczPikFxGMbxh40rmBuwMStNs1HKDcwCKWEO0snKQkaShCZ+p8ZOkoWaUSKzsrWTcj9W9nyPTjYzS9769Pb+fZL05pfiSOMdRdhIoocvNFDAB2powvHmBh10EUUEef6usMQCc3xjgrXXP2CHX0yxxR4bz8yrP2Hc20ZWzujnj3ImpuM5oIoVUtl+VSn3on41LCsRvOXWYHTl7rfNWMNmSqae0MknPeu+fA/wb1wAe9g2jQ==');
end;

//free's the data we loaded
procedure FreeData;
var
i: integer;
BMPs: TIntegerArray;
begin
BMPs := [Bait_BMP, RawSardine_BMP, RawHerring_BMP, CookedSardine_BMP, CookedHerring_BMP, FishOutline_BMP, Paint_BMP, BurntFood_BMP];
for i := 0 to High(BMPs) do
FreeBitmap(BMPs[i]);
FreeDTMs(RightSpot_DTMs);
FreeDTMs(LeftSpot_DTMs);
FreeDTMs(Range_DTMs);
end;

//switches to next player if using multiplayer
Procedure O_NextPlayer;
begin
Players[CurrentPlayer].Active := False;
Logout;

If AllPlayersInactive Then
begin
Writeln('All Players Inactive!');
TerminateScript;
end;

CurrentPlayer := NextPlayerIndex;
LoginPlayer;
end;

//shutdown / switchplayer message
procedure Shutdown(Why: string);
begin

If HowManyPlayers > 1 Then //if we're using more than 1 player
begin
Writeln('-------------------------');
WriteLn(' -- Changing Player! -- ');
Writeln(' Reason: ' + Why + '');
WriteLn('-------------------------');
O_NextPlayer;
Exit;
end;

Writeln('-------------------------');
WriteLn(' -- Script ShutDown! -- ');
Writeln(' Reason: ' + Why + '');
WriteLn('-------------------------');
O_Screenshot('Shutdown');
CloseBank;
FindNormalRandoms;
TerminateScript;
end;

//clears the smart canvas - the nav bar
procedure Smart_ClearScreen;
begin
if (not SMART_DebugSetup) then
SMART_SetupDebug;
SMART_Canvas.Rectangle(ClearScreen, 0);
end;

//gets the client area, used for painting on smart
procedure GetClientArea;
var
W, H: Integer;
begin
GetClientDimensions(W, H);
ClientArea := IntToBox(3, 3, W - 3, H - 3);
ClearScreen := IntToBox(3, 3+SRL_NAVBAR_INGAME_Y, W - 3, H - 3+SRL_NAVBAR_INGAME_Y);
end;

//by fight more human like mouse
procedure HumanWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, targetArea: extended);
var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, D: extended;
lastX, lastY, MSP, W, T, TDist: integer;
sqrt2, sqrt3, sqrt5, maxStep, rCnc: extended;
B: Tbox;
P: Tpoint;
Tpa: TPointArray;
begin
MSP := MouseSpeed;
sqrt2 := sqrt(2);
sqrt3 := sqrt(3);
sqrt5 := sqrt(5);
TDist := Distance(Round(xs), Round(ys), Round(xe), Round(ye));
MarkTime(T);
repeat
if (TimeFromMark(T) > 10000) then
break;
dist := hypot(xs - xe, ys - ye);
wind := minE(wind, dist);
if (dist < 1) then
dist := 1;
D := (Round((Round(TDist) * 0.3)) / 7);
if (D > 30) then
D := 30;
if (D < 8) then
D := 8;
rCnc := Random(6);
if (rCnc = 1) then
D := RandomRange(2, 4);
if (D <= Round(dist)) then
maxStep := D
else
maxStep := Round(dist);
if dist >= targetArea then
begin
windX := windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY := windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end
else
begin
windX := windX / sqrt2;
windY := windY / sqrt2;
end;
veloX := veloX + windX;
veloY := veloY + windY;
veloX := veloX + gravity * (xe - xs) / dist;
veloY := veloY + gravity * (ye - ys) / dist;
if (hypot(veloX, veloY) > maxStep) then
begin
randomDist := maxStep / 2.0 + random(round(maxStep) div 2);
veloMag := sqrt(veloX * veloX + veloY * veloY);
veloX := (veloX / veloMag) * randomDist;
veloY := (veloY / veloMag) * randomDist;
end;
lastX := Round(xs);
lastY := Round(ys);
xs := xs + veloX;
ys := ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
W := (Random((Round(100 / MSP))) * 6);
if (W < 5) then
W := 5;
W := Round(W * 0.8);
wait(W);
lastdist := dist;
if (MouseTrail) then
if (PointInBox(Point(lastX, lastY), ClientArea)) then
begin
TPAFromCircleWrap(LastX,LastY,2,TPA); //mousetrails
FillEllipse(TPA);
Smart_DrawDotsEx(False,TPA,RandomRange(16500000, 17000000));
end;
until (hypot(xs - xe, ys - ye) < 1) if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MMouse(Round(xe), Round(ye), 0, 0);
MouseSpeed := MSP;
end;

//by flight thanks
procedure HumanMMouse(eX, eY, ranX, ranY: Integer);
var
randSpeed: extended;
X, Y, MS: integer;
begin
MS := MouseSpeed;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
GetMousePos(X, Y);
HumanWindMouse(X, Y, RandomRange(eX - ranX, eX + ranX), RandomRange(eY - ranY, eY + ranY), 9, 5, 10.0 / randSpeed, 15.0 / randSpeed, 10.0 * randSpeed);
MouseSpeed := MS;
end;

//mousebox that uses human mouse
procedure HumanMouseBox(X1, Y1, X2, Y2: Integer; ClickType: Integer);
var
FX, FY: Integer;
begin
Smart_DrawBoxEx(False, False, IntToBox(X1, Y1, X2, Y2), ClYellow);
GaussBox(FX, FY, X1, Y1, X2, Y2);
HumanMMouse(FX, FY, 0, 0);
if InRange(ClickType, mouse_Right, mouse_move) then
ClickMouse2(ClickType);
end;

//inv mouse that uses humanmmouse
function HumanInvMouse(InvSlot, Action: Byte): boolean;
var
TB: TBox;
CurrPT: TPoint;
begin
result := false;
if (not InRange(Action, 0, 3)) then
begin
srl_Warn('InvMouse', 'Action #' + IntToStr(Action) + ' is not a valid action', warn_AllVersions);
Exit;
end;
if (not InRange(InvSlot, 1, 28)) then
begin
srl_Warn('InvMouse', 'Inventory slot #' + IntToStr(InvSlot) + ' is not a valid slot', warn_AllVersions);
Exit;
end;
GameTab(tab_inv);
Result := true;
TB := InvBox(InvSlot);
GetMousePos(CurrPT.x, CurrPT.y);
if PointInBox(CurrPT, TB) then
HumanMouseBox(Max(CurrPT.x - random(2), TB.x1), Max(CurrPT.y - random(2), TB.y1), Min(CurrPT.x + random(2), TB.x2), Min(CurrPT.y + random(2), TB.y2), Action)
else
HumanMouseBox(TB.X1, TB.Y1, TB.X2, TB.Y2, Action);
end;

//drops item in i inv slot
function HumanDropItem(i: Integer): Boolean;
var
InvSlot: TBox;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
if ExistsItem(i) then
begin
InvSlot := InvBox(i);
HumanMouseBox(InvSlot.X1, InvSlot.Y1, InvSlot.X2, InvSlot.Y2, Mouse_Right);
if WaitOptionMulti(['rop', 'action'], RandomRange(320, 450)) then
begin
Result := True;
Wait(RandomRange(50, 200));
end;
end;
end;

//moves the mouse in a random 100 radius of where the mouse currently is
procedure SmallMouseMovement;
var
randSpeed: extended;
x, y, MS: integer;
begin
MS := mouseSpeed;
RandSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
GetMousePos(x, y);
HumanWindMouse(X, Y, RandomRange(x - 100, x + 100), RandomRange(y - 100, y + 100), 9, 5, 10.0 / randSpeed, 15.0 / randSpeed, 10.0 * randSpeed);
MouseSpeed := Ms;
end;

//antiban while the flag is present
procedure WhileFlag;
begin
case random(1000) of
250: Wait(RandomRange(500, 4500));
500: PickupMouse;
750: SleepAndMoveMouse(RandomRange(200, 1700));
999: SmallMouseMovement;
end;
end;

//handles a break if we're using them
Procedure HandleBreaks;
var
b, t, C: integer;
begin
If (TakeBreaks) Then
If TimeFromMark(BreakTime) > NextBreak Then
begin
Marktime(t);
B := RandomRange(300000,1800000); //5min to 30min
O_Debug('BREAK','Taking a break for '+ MsToTime(B, Time_Formal));
repeat
Wait(RandomRange(20000,40000));
O_Debug('BREAK','Break time left: '+MsToTime((B-TimeFromMark(t)), Time_Formal));
SMART_ClearScreen;
SMART_DrawTextMulti(False, False, ['TAKING A BREAK'], point(100,150), bigchars, Random(ClYellow));
until timefrommark(t) > B;
NextBreak := RandomRange(3600000,14400000); //1hr to 4 hrs
O_Debug('BREAK','Break is over! Our next break will be in '+ MsToTime(NextBreak, Time_Formal));
LoginPlayer;
exit;
end;
end;

//rounds the number to get the info per hour
function RoundPH(Input: Integer): Integer;
begin
Result := Round((Input) / (GetTimeRunning / 3600000.0));
end;

//draws/writes proggys
procedure Proggys;
var
i, CookXpGained, FishXpGained, TotalCaught, FishCooked: Integer;
Pts: TPointArray;
Font, Prog: TStringArray;
begin
CookXpGained := ((cookedsard * 40) + (cookedherr * 50));
FishXpGained := ((SardineCount * 20) + (HerringCount * 30));
TotalCaught := (SardineCount + HerringCount);
FishCooked := (cookedsard + cookedherr);
SRLProgressReport(ResultDebugBox, 'Fish Cook Bank', 'Olly', Version, ['Running For', 'Total Trips', 'Trips P/H', 'Total Cook Xp', 'Cook Xp P/H', 'Total Fish Xp', 'Fish Xp P/H', 'Total Fish Caught', 'Fish Caught P/H', 'Total Fish Cooked', 'Fish Cookeed P/H', 'Burnt Food'], [MsToTime(GetTimeRunning, Time_Short), Trips, RoundPH(Trips), CookXpGained, RoundPH(CookXpGained), FishXPGained, RoundPH(FishXPGained), TotalCaught, RoundPH(TotalCaught), FishCooked, RoundPH(FishCooked), burntcount]);

SetArrayLength(Prog, 8);
Prog[0] := 'Fish Cook Bank';
Prog[1] := 'Running For: ' + MsToTime(GetTimeRunning, Time_Short);
Prog[2] := 'Total Trips: ' + IntToStr(Trips) + ' [' + IntToStr(RoundPH(Trips)) + ' P/H]';
Prog[3] := 'Total Cook XP: ' + IntToStr(CookXpGained) + ' [' + IntToStr(RoundPH(CookXpGained)) + ' P/H]';
Prog[4] := 'Total Fish XP: ' + IntToStr(FishXpGained) + ' [' + IntToStr(RoundPH(FishXPGained)) + ' P/H]';
Prog[5] := 'Fish Caught: ' + IntToStr(TotalCaught) + ' [' + IntToStr(RoundPH(TotalCaught)) + ' P/H]';
Prog[6] := 'Fish Cooked: ' + IntToStr(fishcooked) + ' [' + IntToStr(RoundPH(FishCooked)) + ' P/H]';
Prog[7] := 'V' + Version;
SMART_DrawBitmap(True, Paint_BMP, Point(0, 0 - 50));
Pts := [Point(10, 10 - 50), Point(228, 11 - 50), Point(228, 30 - 50), Point(376, 11 - 50), Point(376, 30 - 50), Point(568, 11 - 50), Point(568, 30 - 50), Point(729, 32 - 50)];
font := ['bigChars', 'StatChars', 'StatChars', 'StatChars', 'StatChars', 'StatChars', 'StatChars', 'SmallCharsNS'];
for i := 0 to high(prog) do
SMART_DrawTextMulti(False, False, [prog[i]], pts[i], font[i], Clwhite);
end;

//setups the script at the startup
procedure SetupScript;
begin
ClearDebug;
MouseSpeed := Mouse_Speed;
Smart_ClearCanvas;
LoadVars;
LoadData;
AddOnTerminate('FreeData');
Writeln('Going To Log In Player');
DeclarePlayers;
LogInPlayer;
O_Debug('SETUP','Setting Up Script');
GetClientArea;
end;

//drops items in a inv slot array with some randomness
procedure DropEx(InvSlots: TIntegerArray);
var
I, Len: Integer;
begin
Len := Length(InvSlots);
for I := 1 to Len - 4 do
Swap(InvSlots[RandomRange(I - 1, I + 4)], InvSlots[RandomRange(I - 1, I + 4)]);
for I := 0 to Len - 1 do
HumanDropItem(InvSlots[I]);
end;

//checks and fixes compass to make sure its facing east
function CheckCompass: Boolean;
var
R, A: integer;
label
Start;
begin
R := 0;
Start:
if not WaitLoggedIn(1000) then
Exit;
Inc(r);
A := Round(Rs_GetCompassAngleDegrees);
Result := InRange(A, 85, 95);
if (Result) then
Exit;
O_Debug('COMPASS', 'Adjusting Compass To East, Angle Was: ' + ToStr(A));
MakeCompass('E');
Result := InRange(A, 86, 94);
if (Result) then
Exit;
if R > 10 then
Shutdown('Failed to correct compass 10 times!');
goto Start;
end;

//waits till we're not moving, if flag is selected will wait till flag dissapears aswell
procedure NotMoving(WaitFlag: Boolean);
var
T: Integer;
begin
MarkTime(T);
if WaitFlag then
Flag;
repeat
Wait(RandomRange(50, 100));
until not IsMoving or (TimeFromMark(T) > 15000);
Wait(RandomRange(200, 250));
end;

//removes the length of tpa's under x
procedure SetMinTPALength(var ATPAInput: T2DPointArray; MinTPALength: Integer);
var
i, ATPALength: Integer;
begin
ATPALength := Length(ATPAInput);
SortATPASize(ATPAInput, True);
for i := 0 to ATPALength - 1 do
begin
if (Length(ATPAInput[i]) < MinTPALength) then
begin
SetLength(ATPAInput, i);
Break;
end;
end;
end;

//by home, splits an area into boxes
function AreaToBoxArray(const AreaX1, AreaY1, AreaX2, AreaY2, Width, Height: Integer): TBoxArray;
var
AreaW, AreaH: Integer;
BoxX, BoxY: Integer;
x, y, i: Integer;
begin
AreaW := AreaX2 - AreaX1 + 1;
AreaH := AreaY2 - AreaY1 + 1;
BoxX := AreaW div Width;
if AreaW mod Width <> 0 then
Inc(BoxX);
BoxY := AreaH div Height;
if AreaH mod Height <> 0 then
Inc(BoxY);
SetLength(Result, BoxX * BoxY);
i := 0;
for y := 0 to BoxY - 1 do
for x := 0 to BoxX - 1 do
begin
Result[i] := IntToBox(AreaX1 + x * Width, AreaY1 + y * Height, Min(AreaX2, AreaX1 + (x + 1) * Width - 1), Min(AreaY2, AreaY1 + (y + 1) * Height - 1));
Inc(i);
end;
end;

//see's if we have something typed in the chatbox
function HasWrote: boolean;
begin
result := CountColorTolerance(16711680, 99, 511 - 50, 121, 522 - 50, 5) > 0;
end;

//creates a random key
function RandomKey(Length: Integer): string;
var
I: integer;
begin
Result := '';
for I := 1 to Length do
Result := Result + chr(65 + Random(25));
end;

//types random keys with length of x
procedure TypeRandomKeys(MaxLength: Integer);
var
S: string;
begin
if (HasWrote) then
Exit;
S := RandomKey(RandomRange(1, MaxLength));
TypesendEx(LowerCase(S), False);
end;

//converts an string array to a single string
function TStringToString(Strings: TStringArray): string;
var
s: string;
i: Integer;
begin
for i := 0 to high(Strings) do
s := s + Strings[i] + ' ';
Result := s;
end;

//checks for the "you need a" message incase we dont have the level / ran out of bait
function CheckLevelAndItem: Boolean;
var
S: string;
begin
S := (getTextAtExWrap(26, 447 - 50, 474, 494 - 50, 0, 5, 30, 0, 15, UpChars));
Result := ArrInStr(['You need a'], S);
if Result then
Shutdown('ERROR: ' + S);
end;

//calls a function every x saves alot of "if timefrommark(b) > 150000 then do this" etc
procedure TimeTrigger(proc: function: boolean; var time: integer; Everyxms: integer);
begin
if TimeFromMark(Time) > Everyxms then
begin
proc();
MarkTime(time);
end;
end;

//checks if the mouse is on the minimap (randomness could take it off)
function MouseOnMM: Boolean;
var
MpX, MpY: Integer;
begin
GetMousePos(MpX, MpY);
if RS_OnMinimap(MpX, MpY) then
result := true
else
result := false;
end;

//clears everything that isnt on the minimap circle
procedure TPAClearOffMM(var InputTPA: TPointArray);
var
cleararea: TPointArray;
begin
TPAFromBoxWrap(IntToBox(540, 2, 716, 171), ClearArea);
FilterPointsDist(ClearArea, 74, 146, MMCX, MMCY);
clearTPAfromtpawrap(InputTPA, ClearArea, InputTPA);
end;

//if found a symbol will click it and walk to it
function ClickSymbols(Symbols: TStringArray; accuracy: extended): Boolean;
var
tpa: tpointarray;
ATPA: T2DPointArray;
x, y, i, A: integer;
S: string;
begin
if not WaitLoggedIn(1000) then
Exit;
symbolaccuracy := accuracy;
result := false;
S := TStringToString(symbols);
if FindSymbolsMulti(TPA, symbols) then
O_Debug('SYMBOL WALK', 'Found Symbol(s): ' + tostr(S))
else
begin
O_Debug('SYMBOL WALK', 'Didnt Find Symbol(s): ' + tostr(S)) Exit;
end;
TPAClearOffMM(TPA);
splittpawrap(tpa, 1, atpa);
SortATPAFromFirstPoint(ATPA, Point(MMCX, MMCY));
A := High(ATPA);
for I := 0 to A do
begin
MiddleTPAEx(ATPA[i], X, Y);
smart_drawcircle(false, point(x, y), 7, false, clblue);
MouseCircle(x, y, 5, mouse_move);
if MouseOnMM then
begin
O_Debug('SYMBOL WALK', 'Clicking Symbol...');
clickmouse2(mouse_left);
result := true;
exit;
end;
O_Debug('SYMBOL WALK', 'Mouse Isnt On Minimap!')
end;
end;

//attempts to find a bitmap untill maxtime is reached
function WaitFindBitmapInv(BMP, WaitPerLoop, MaxTime: integer): boolean;
var
t, x, y: integer;
begin
if not WaitLoggedIn(1000) then
Exit;
t := (getSystemTime + MaxTime);
while (getSystemTime < t) do
begin
if FindBitmapToleranceIn(BMP, X, Y, MIX1, MIY1, MIX2, MIY2, 20) then
begin
result := true;
break;
end;
wait(WaitPerLoop);
end;
end;

//checks if we have bait in our invent
function HasBait: Boolean;
begin
if not WaitLoggedIn(1000) then
Exit;
Gametab(Tab_inv);
Result := Waitfindbitmapinv(Bait_BMP, 100, 500);
if not (Result) then
Shutdown('WE HAVE NO BAIT!');
end;

function GetWallTPA: TPointArray;
var
CTS: Integer;
TPA: TPointArray;
begin
if not WaitLoggedIn(1000) then
Exit;
CTS := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.05, 0.98);
FindColorsTolerance(TPA, 6846116, MSX1, MSY1, MSX2, MSY2, 13);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
if Length(TPA) < 100 then
begin
O_Debug('ROOM BOUNDS', 'Did Not Get Enough Wall Colour');
Exit;
end;
Result := TPA;
end;

//Finds the roombounds as a TPA
function GetRoomBounds: TBox;
var
TPA, TPANew, MS: TPointArray;
ATPA, ATPAA: T2DPointArray;
TmpCTS, i: Integer;
begin
if not WaitLoggedIn(1000) then
Exit;

TPA := GetWallTPA;
if Length(TPA) < 100 then
begin
Result := (MSBOX);
Exit;
end;

SplitTPAExWrap(TPA, 1, 1, ATPA);
SetMinTPALength(ATPA, 2200);
SortATPASize(ATPA, True);

for i := 0 to High(ATPA) do
begin
Result := GetTPABounds(ATPA[i]);
SMART_DrawBoxEx(False, False, Result, ClBlue);
Exit;
end;
Result := (MSBOX);
end;

//results true if the cooking interface is open
function CookScreen: Boolean;
begin
Result := GetColor(326, 407 - 50) = 2104079;
end;

//ocr sucks in alkarid so i use this nooby method (that works PERFECTLY) to detect the uptext //"Use Ra.', l.!er!-in.g -^ -" lol..
function RangeUpText: Boolean;
var
I, X, Y: integer;
Box: Tbox;
BMPs: Tintegerarray;
L, Text: string;
begin
if not WaitLoggedIn(1000) then
Exit;

O_Debug('UPTEXT', 'Range uptext may have failed.. uptext says "' + getuptext + '"');
Text := '';
Box := inttobox(6, 58 - 50, 324, 81 - 50);

SetArrayLength(BMPs, 5);
Bmps[0] := BitmapFromString(8, 10, 'meJxjYMAJfv/Wu/dYCogeP5VGE4ezL11mwSqOrAWXONDki5dYMM3/8k0b03Ag+PZDF6u9yOKYutAAAJSBJh8=');
Bmps[1] := BitmapFromString(8, 9, 'meJxjYCAATt9UPnVDGZfsoaPsyNyzd7RPXVWAIITgOUGE+mOcWMVP31BDMfYY55mb6hBEyIHYAQBSLhnT');
Bmps[2] := BitmapFromString(7, 8, 'meJxjYMAOTt9SBaIbd1XuP9OHC568Jg9nHz/BBRW8KgcXfPDcAMI4coofLnj3sTaEATQNLnj/sSam4O37CDYaAAArvxlv');
Bmps[3] := BitmapFromString(7, 10, 'meJxjYMAJHjyRAqK794Vu3+GHiDxLgeXvXiRCVMQqBjCePJCHr/ggyeScPalSyxguySRBZFlkZ10/zFQmRRuVzMAAHhPJJM=');
Bmps[4] := BitmapFromString(7, 8, 'meJxjYMAJ7j+SuPdYHIiQReDsi5dY4IJANkQlXDGySqzan3/QgbMvXGQCcl8giWACAAgGHXE=');

for i := 0 to High(BMPs) do
with Box do
If FindBitmapToleranceIn(BMPs[i], X, Y, X1, Y1, X2, Y2, 95) then
begin
case i of
0: L := 'R';
1: L := 'A';
2: L := 'N';
3: L := 'G';
4: L := 'E';
end;
Text := Text + L;
end;

if Text = 'RANGE' then
Result := true
else
Result := false;

for i := 0 to High(BMPs) do
FreeBitmap(BMPs[i]);
end;

//finds the range to cook our food on
function FindRange(MinLength: Integer): Boolean;
var
I, TmpCTS, X, Y: integer;
TPA, Range, PBox: TPointArray;
ATPA: T2DPointArray;
Hue, Sat: array of Extended;
Col, Tol: TIntegerArray;
SearchArea: TBox;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
PBox := TPAFromBox(IntToBox(244, 207 - 50, 273, 240 - 50));
SearchArea := GetRoomBounds;
TmpCTS := GetColorToleranceSpeed;

Hue := [0.40, 3.48, 0.06];
Sat := [0.07, 0.56, 0.46];
Col := [4934478, 10394505, 3162448];
Tol := [14, 13, 11];

for i := 0 to High(Hue) do
begin
With SearchArea Do
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue[i], Sat[i]);
FindColorsTolerance(TPA, Col[i], X1, Y1, X2, Y2, Tol[i]);
CombineTPAWrap(TPA, Range, Range);
end;
end;

SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(TmpCTS);

ClearTPAFromTPAWrap(Range, PBox, Range);
SplitTPAWrap(Range, 1, ATPA);
SetMinTPALength(ATPA, MinLength);
SortATPAFromFirstPoint(ATPA, Point(SearchArea.X1, SearchArea.Y2)); //sort it from the southwest point of the room! (where the range is)

for I := 0 to High(ATPA) do
begin
Smart_DrawBoxEx(False, False, GetTPABounds(ATPA[i]), ClLime);
MiddleTPAEx(ATPA[i], X, Y);
HumanMMouse(X, Y, 5, 5);
if WaitUpTextMulti(['> Range', 'ange', 'Range /', '-> Range', 'ange', 'nge / ', '> Ra', '-^ Range', 'Range / 1 more option'], RandomRange(300, 400)) or (RangeUpText) then
begin
ClickMouse2(Mouse_Right);
if WaitOptionMulti(['> Range', '-> Rang', '-> Range'], RandomRange(100, 200)) then
begin
O_Debug('RANGE', 'Found Range... Clicking!');
NotMoving(True);
if WaitFunc(@ CookScreen, RandomRange(30, 60), RandomRange(3000, 4000)) then
begin
O_Debug('RANGE', 'CookScreen Is Open');
Result := True;
Break;
end else
CheckLevelAndItem;
end;
end;
end;
end;

procedure FindWaterIn(var TPA: TPointArray; X1, Y1, X2, Y2: Integer);
var
CTS: Integer;
begin
if not WaitLoggedIn(1000) then
Exit;
CTS := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.21, 0.66);
FindColorsTolerance(TPA, 9928818, X1, Y1, X2, Y2, 10);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
end;

function FindFishSpotIn(MinWaterLength, X1, Y1, X2, Y2: Integer; Click: Boolean): Boolean;
var
TPA, FishSpot, WaterTPA: TPointArray;
X, Y, i, CTS: Integer;
ATPA: T2DPointArray;
Hue, Sat: TExtendedArray;
Col, Tol: TIntegerArray;
Box: TBox;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
CTS := GetColorToleranceSpeed;
Hue := [0.41, 0.43, 0.45, 0.39, 0.43, 0.23, 0.39, 0.60, 0.27, 0.27];
Sat := [0.92, 1.13, 1.28, 1.24, 1.48, 1.22, 0.78, 3.91, 0.75, 0.72];
Col := [11708834, 11378840, 11114125, 11444890, 11181976, 11181461,
11577507, 14656419, 12169127, 12300455];
Tol := [5, 4, 2, 5, 4, 5, 5, 9, 9, 8];

for i := 0 to High(Hue) do
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue[i], Sat[i]);
FindColorsTolerance(TPA, Col[i], X1, Y1, X2, Y2, Tol[i]);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
CombineTPAWrap(TPA, FishSpot, FishSpot);
end;

SplitTPAWrap(FishSpot, 15, ATPA);
SetMinTPALength(ATPA, 3);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY + 40));

for I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], X, Y);
Box := IntToBox(X - 8, Y - 8, X + 8, Y + 8);
FindWaterIn(WaterTPA, Box.X1, Box.Y1, Box.X2, Box.Y2);
if GetArrayLength(WaterTPA) > MinWaterLength then
begin
if not (Click) then
begin
Result := true;
Exit;
end;
HumanMMouse(X, Y, 6, 10);
if WaitUpTextMulti(['Fishing Spot', 'et Fishin', 'ishing'], RandomRange(300, 500)) then
begin
ClickMouse2(False);
if WaitOptionMulti(['Bait', 'Bait Fish', 'ait'], RandomRange(300, 500)) then
begin
O_Debug('FISH', 'Clicked Fishing Spot');
Result := True;
Flag;
Exit;
end;
end;
end
else
O_Debug('FISH', 'Not Enough Water In Bounds');
end;
Result := False;
end;

//uses cactus around bank to tell if we're there
function NearBank: Boolean;
begin
Result := (CountColorTolerance(2647877, MMX1, MMY1, MMX2, MMY2, 30) > 300);
end;

function TPAWalkEx(SearchArea: TBox; hue, sat: extended; colour, Tol: integer; sortFrom: TPoint): boolean;
var
tpa: tpointarray;
i, CTS, x, y, H: integer;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
FindColorsTolerance(TPA, Colour, SearchArea.X1, SearchArea.Y1, SearchArea.X2, SearchArea.Y2, Tol);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
RAaSTPA(TPA, RandomRange(2, 5));
TPAClearOffMM(TPA);
SMART_DrawDotsEx(False, TPA, ClRed);
if GetArrayLength(TPA) < 1 then
Exit;
SortTPAFrom(TPA, SortFrom);
H := High(TPA);
for i := 0 to H do
begin
X := TPA[i].X;
Y := TPA[i].Y;
Smart_Drawcircle(false, point(x, y), 2, false, clred);
HumanMMouse(X, Y, 2, 2);
if MouseOnMM then
begin
ClickMouse2(Mouse_Left);
if WaitFunc(@ Flag, 50, 3000) then
begin
Result := true;
Exit;
end;
end;
end;
end;

function ShoreWalk(Area: TBox; Point: TPoint): Boolean;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := TpaWalkEx(Area, 0.27, 0.89, 4089207, 10, Point);
if Result then
NotMoving(True);
end;

function BoxWalk(var Box: TBox): Boolean;
var
M: TPoint;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
M := MiddleBox(Box) Smart_DrawDot(False, M, ClBlue);
HumanMMouse(M.X, M.Y, 2, 2);
if MouseOnMM then
begin
ClickMouse2(Mouse_Left);
NotMoving(True);
Result := True;
Exit;
end;
end;

//walks to the dock by the river sorts the tpa from the highest point (closest to land)
function WalkToDock(OffsetX, OffsetY: integer): Boolean;
var
TPA, Dock: TPointArray;
X, Y, i, cts, H, j: Integer;
Hue, Sat: TExtendedArray;
Col, Tol: TIntegerArray;
ATPA: T2DPointArray;
p : tpoint;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
CTS := GetColorToleranceSpeed;
Hue := [0.11, 0.31, 0.07, 0.15, 0.05, 0.03, 0.14];
Sat := [0.50, 1.85, 0.90, 0.51, 0.21, 0.15, 0.33];
Col := [2448751, 2118755, 2118497, 2383220, 2383211, 2253434, 2316138]; //all used aca, just it has so much tolerance lol
Tol := [8, 4, 5, 6, 7, 4, 8];

for i := 0 to High(Hue) do
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue[i], Sat[i]);
FindColorsTolerance(TPA, Col[i], MMX1, MMY1, MMX2, MMY2, Tol[i]);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
CombineTPAWrap(TPA, Dock, Dock);
end;

if GetArrayLength(Dock) < 1 then
begin
O_debug('WALK', 'Didnt get enough of colour of the dock!');
Exit;
end;

Smart_DrawdotsEx(false,DOCK,clyellow);
SplitTPAWrap(Dock,10,ATPA);
SortATPASize(ATPA,True);

H := High(ATPA);
for I := 0 to H do
begin
RAaSTPA(ATPA[i], RandomRange(2, 4)); //some extra randomness :)
SortTPAByY(ATPA[i], True); //sort it by y (the "top" closest to land
for j:= 0 to high(ATPA[i]) do
begin
P := Point(atpa[i][j].x,atpa[i][j].y);
SMART_DrawCircle(False, Point(P.X + OffsetX, P.Y + OffsetY), 2, False, ClBlue);
HumanMMouse(P.X + OffsetX, P.Y + OffsetY, 3, 3);
If MouseOnMM Then
begin
ClickMouse2(Mouse_Left);
if WaitFunc(@ Flag, 50, 3000) then
begin
NotMoving(True);
Result := true;
Exit;
end;
end;
Exit;
end;
end;
end;

//walks us to the bank using multiple methods of walking
function WalkToBank: Boolean;
var
TPA: TPointArray;
X, Y, i, L: Integer;
ATPA: T2DPointArray;
begin
if not WaitLoggedIn(1000) then
Exit;
Smart_ClearScreen;
Result := False;
FindColorsTolerance(TPA, 779230, MMX1, MMY1, MMX2, MMY2, 49); //npc dots
TPAClearOffMM(TPA);
SplitTPAWrap(TPA, 3, ATPA);
SortATPASize(ATPA, True);
for i := 0 to High(ATPA) do
begin
L := GetArrayLength(ATPA[i]);
if InRange(L, 20, 150) then
begin
O_Debug('WALK', 'Walk to bank > found right length of npc dots');
Smart_DrawBoxEx(False, False, GetTPABounds(ATPA[i]), ClLime);
MiddleTPAEx(ATPA[i], X, Y);
HumanMMouse(X + 13, Y, 3, 7);
Wait(RandomRange(50, 100));
if MouseOnMM then
begin
ClickMouse2(True);
FFlag(4);
NotMoving(False);
if NearBank then
begin
O_Debug('WALK', 'Walk to bank > (npc dots) success! near the bank');
Result := True;
Exit;
end;
Break;
end;
end;
end;
if TPAwalkEx(IntToBox(660, 106 - 50, 706, 153 - 50), 0.20, 0.77, 5667492, 8, Point(697, 129)) then
NotMoving(true);
if NearBank then
begin
O_Debug('WALK', 'Walk to bank > (TPA) success! near the bank');
Result := True;
Exit;
end;
O_Debug('WALK', 'Walk to bank > couldnt use npc dots or TPA to walk to bank attempting symbol');
if ClickSymbols(['bank'], 0.45) then
NotMoving(False);
if NearBank then
begin
O_Debug('WALK', 'Walk to bank > (symbol) success! near the bank');
Result := True;
Exit;
end;
end;

//finds the players onscreen as a tpa
function GetPlayersOnMS: TPointArray;
var
i, L: integer;
B: TPoint;
NPCs, TPA, NewTPA: TPointArray;
Boxes: TBoxarray;
begin
if not WaitLoggedIn(1000) then
Exit;
NPCs := GetMMDotsOnMS('player');
L := GetArrayLength(NPCs);
if L < 1 then
Exit;
SetArrayLength(Boxes, L);
for i := 0 to L - 1 do
begin
B := MMtoMS(NPCs[i]) Boxes[i] := IntToBox(B.x - 15, B.y - 20, B.x + 20, B.y + 20);
TPAFromBoxWrap(Boxes[i], TPA);
CombineTPAWrap(TPA, NewTPA, NewTPA);
end;
Result := NewTPA;
end;

//finds the range dtm looping though the array
function FindRangeDTMs(var x, y: integer): Boolean;
var
afound: extended;
i, H: Integer;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
H := High(Range_DTMs);
for i := 0 to H do
begin
if FindDTMRotated(Range_DTMs[i], x, y, MMX1, MMY1, MMX2, MMY2, - Pi / 4, Pi / 4, Pi / 60, aFound) then
begin
Result := True;
Exit;
end;
end;
end;

//finds the spot dtm looping though the array and if finds will make an area of the spot
function FindLeftSpotDTMs(var box: tbox): Boolean;
var
afound: extended;
X, Y, i, H: Integer;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
H := High(LeftSpot_DTMs);
for i := 0 to H do
begin
if FindDTMRotated(LeftSpot_DTMs[i], x, y, MMX1, MMY1, MMX2, MMY2, - Pi / 4, Pi / 4, Pi / 60, aFound) then
begin
Box := IntToBox(X - 20, Y + 1, X + 20, Y + 25);
Result := True;
Exit;
end;
end;
end;

//finds the spot dtm looping though the array and if finds will make an area of the spot
function FindRightSpotDTMs(var box: tbox): Boolean;
var
afound: extended;
X, Y, i, H: Integer;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
H := High(RightSpot_DTMs);
for i := 0 to H do
begin
if FindDTMRotated(RightSpot_DTMs[i], x, y, MMX1, MMY1, MMX2, MMY2, - Pi / 4, Pi / 4, Pi / 60, aFound) then
begin
Box := IntToBox(X - 20, Y - 2, X + 22, Y + 18);
Result := True;
Exit;
end;
end;
end;

function AtLeftSpot: Boolean;
var
LeftSpotArea: Tbox;
begin
if not WaitLoggedIn(1000) then
Exit;
NotMoving(True);
Result := False;
if FindLeftSpotDTMs(LeftSpotArea) then
begin
Result := PointInBox(Point(MMCX, MMCY), LeftSpotArea);
if not Result then
Exit;
SMART_DrawBoxEx(False, False, LeftSpotArea, ClYellow);
Spot := 'left';
end;
end;

function AtRightSpot: Boolean;
var
RightSpotArea: Tbox;
begin
if not WaitLoggedIn(1000) then
Exit;
NotMoving(True);
Result := False;
if FindRightSpotDTMs(RightSpotArea) then
begin
Result := PointInBox(Point(MMCX, MMCY), RightSpotArea);
if not Result then
Exit;
SMART_DrawBoxEx(False, False, RightSpotArea, ClYellow);
Spot := 'right';
end;
end;

//tells us if we're at a fish spot, just a wrapper reall saves some code
function AtFishSpot: Boolean;
begin
Result := AtLeftSpot or AtRightSpot;
end;

//antiban examines the mainscreen
procedure ExamineMS;
begin
HumanMMouse(Random(MSX2), Random(MSY2), 0, 0);
if WaitUpTextMulti(['ptio', 'evel'], 500) then
begin
ClickMouse2(False);
if not ChooseOptionMulti(['Examine', 'Cancel', 'ancel']) then
HumanMMouse(690, 466 - 50, 50, 50);
end;
end;

//antiban moves the mouseoffscreen
procedure MMOffScreen;
var
W, H, RX, RY: Integer;
begin
GetClientDimensions(W, H);
H := H + 50;
RX := RandomRange(0, W);
RY := RandomRange(0, H);
case Random(4) of
0: HumanMMouse(W / 2, RandomRange( - 130, - 60), RX, 0);
1: HumanMMouse(RandomRange( - 100, - 10), H / 2, 0, RY);
2: HumanMMouse(W / 2, h + RandomRange(10, 100), RX, 0);
3: HumanMMouse(W + RandomRange(10, 100), H / 2, 0, RY);
end;
end;

//antiban hovers a random skill, increased chance of hovering over fishing/cooking
procedure HoverRandomSkill;
var
RandomS, Tab: Integer;
Skills: TStringArray;
r: string;
begin
Tab := GetCurrentTab SetArrayLength(Skills, 4);
skills := ['fishing', 'fishing', 'cooking', 'random'];
RandomS := RandomRange(0, GetArrayLength(Skills));
R := Skills[RandomS];
HoverSkill(R, False);
GameTab(Tab);
end;

//antiban hovers over a random tab, more of a chance of going on tab stats and friends
procedure RandomTab;
var
tab: integer;
begin
tab := GetCurrentTab;
case Random(4) of
0: GameTab(Tab_Stats);
1: GameTab(Tab_Friends);
2: GameTab(RandomRange(Tab_Combat, Tab_Notes));
3: GameTab(RandomRange(Tab_Combat, Tab_Notes));
end;
Wait(RandomRange(200, 6500));
gametab(tab);
end;


//antiban, edited flights version thanks :p
procedure CheckMovingObjs(DoClick: Boolean);
var
TBA: TBoxArray;
MidBox: TPoint;
TIA: TIntegerArray;
H, I: Integer;
TPA, PBox: TPointArray;
begin
if not WaitLoggedIn(1000) then
Exit;
PBox := TPAFromBox(IntToBox(240, 130, 275, 185));
TBA := AreaToBoxArray(MSX1, MSY1, MSX2, MSY2, 35, 20);
TIA := PixelShiftMulti(TBA, 500);
for H := 0 to High(TBA) do
begin
if (TIA[H] > 50) then
begin
MidBox := MiddleBox(TBA[H]);
SetArrayLength(TPA, Length(TPA) + 1);
TPA[High(TPA)] := MidBox;
end;
end;
ClearTPAFromTPAWrap(TPA, PBox, TPA);
if (Length(TPA) < 1) then
Exit;
I := Random(Length(TPA));
HumanMMouse(TPA[I].X, TPA[I].Y, 5, 5);
if DoClick then
if WaitUpTextMulti(['ptio', 'evel'], 500) then //option or a player
begin
ClickMouse2(False);
if not ChooseOptionMulti(['Examine', 'Cancel', 'ancel']) then
HumanMMouse(690, 466 - 50, 50, 50);
end;
end;

//a good chance of doing a random action before doing something that takes a decent amount of time (after clicking a fish spot or cooking)
procedure RandomAction;
begin
if not WaitLoggedIn(1000) then
Exit;
case random(80) of
0..7: MMOffScreen;
8..10: HumanMMouse(1, 1, 760, 500);
11..12: HumanInvMouse(RandomRange(1, 28), Mouse_Move);
13..14: CheckMovingObjs(False);
15: PickupMouse;
16: SleepAndMoveMouse(200 + Random(3500));
17..18: RandomTab;
19: HoverRandomSkill;
20..22: SmallMouseMovement;
end;
end;

//all the anitbans together
procedure AntiBan;
var
i: integer;
begin
if not WaitLoggedIn(1000) then
Exit;
case Random(15000) of

100..114:
HoverRandomSkill;

200..205:
HumanMMouse(1, 1, 760, 500);

300..302:
ExamineInv;

400..406:
Pickupmouse;

500:
RandomRClick;

600..602:
ExamineMS;

700..706:
CheckMovingObjs(False);

800..805:
SleepAndMoveMouse(RandomRange(200, 600));

900..901:
SleepAndMoveMouse(RandomRange(3000, 6300));

1000..1002:
SleepAndMoveMouse(RandomRange(200, 1200));

1100..1106:
Wait(RandomRange(4000, 15000));

1200..1201:
Wait(RandomRange(25000, 40000));

1300..1308:
SmallMouseMovement;

1400:
begin
KeyDown(40);
Wait(RandomRange(320, 1600));
KeyUp(40);
Wait(RandomRange(365, 1444));
SetAngle(SRL_Angle_High);
SetAngle(SRL_Angle_High);
end;

1500..1510:
begin
MMOffScreen;
Wait(Random(5000));
end;

1600..1604:
begin
typerandomkeys(11);
if Random(2) = 1 then
repeat
inc(i);
typebyte(VK_BACK);
wait(randomRange(9, 34));
until (not haswrote) or (i > 25);
end;

2000..2250:
begin
if (haswrote) then
repeat
inc(i);
typebyte(VK_BACK);
wait(randomRange(9, 34));
until (not haswrote) or (i > 25);
end;
end;
end;

//walks to the current fishing spot from the bank
function WalkToSpotFromBank: Boolean;
var
Box: Tbox;
begin
if not WaitLoggedIn(1000) then
Exit;
if Atfishspot then
Exit;
Result := False;
case spot of
'right':
begin
O_Debug('WALK', 'Walking To Right Fishing Spot From Bank');
Box := IntToBox(620, 164 - 50, 708, 216 - 50);
if ShoreWalk(Box, Point(650, 204 - 50)) then
O_Debug('Walk', 'Sucesfully Shore Walked');

if (AtRightSpot) then
begin
O_Debug('WALK', 'Succesfully Walked To Right Spot From Bank');
Result := True;
Exit;
end else
O_Debug('WALK', 'Didnt Walk To Right Spot... Attempting Backup');
if FindRightSpotDTMs(Box) then
BoxWalk(Box)
else
ClickSymbols(['fish'], 0.40);

if (AtRightSpot) then
Result := True
else
Shutdown('couldnt walk to Right spot!');
end;
'left':
begin
O_Debug('WALK', 'Going to walk to left spot from bank');
if WalkToDock(RandomRange( - 10, - 15), RandomRange(1, 3)) then
begin
O_Debug('WALK', 'Walked to left spot > succesfully walked to dock');
if ShoreWalk(IntToBox(600, 133 - 50, 633, 162 - 50), Point(620, 150 - 50)) then
else if FindLeftSpotDTMs(box) then
BoxWalk(Box);
Result := (AtLeftSpot);
if (Result) then
begin
O_Debug('WALK', 'Walked to left spot > succesfully walked to left spot');
exit;
end;
end
else
O_Debug('WALK', 'Didnt walk to left spot.. attempting backup!');
if ShoreWalk(IntToBox(548, 139 - 50, 639, 215 - 50), Point(585, 190 - 50)) then
if FindLeftSpotDTMs(box) then
BoxWalk(Box);
Result := (AtLeftSpot);
if (Result) then
begin
O_Debug('WALK', 'Walked to left spot > succesfully walked to left spot');
exit;
end
else
result := false;
end;
end;
end;

//switches fishing spot, left to right vise versa
procedure SwitchSpots;
var
Box: tbox;
begin
if not WaitLoggedIn(1000) then
Exit;
case Spot of
'left':
begin
O_Debug('WALK', 'At Left Spot Switching To Right Spot');
if ShoreWalk(IntToBox(635, 114 - 50, 710, 150 - 50), Point(693, 141 - 50)) then
if (AtRightSpot) then
begin
O_Debug('WALK', 'Succesfully shore walked(1) to right spot!');
Exit;
end
else if ShoreWalk(IntToBox(627, 123 - 50, 662, 152 - 50), Point(643, 141 - 50)) then
O_Debug('WALK', 'Shore Walked 2');
if (AtRightSpot) then
begin
O_Debug('WALK', 'Succesfully shore walked(2) to right spot!');
Exit;
end
else
O_Debug('WALK', 'Failed to shore walk to right spot, attempting backup');
if FindRightSpotDTMs(Box) then
BoxWalk(Box);
if (AtRightSpot) then
begin
O_Debug('WALK', 'Sucesfully used backup dtms to get to right spot');
Exit;
end
else
Shutdown('Couldnt switch to right spot ');
end;
'right':
begin
O_Debug('WALK', 'At Right Spot Switching To Left Spot');
if ShoreWalk(IntToBox(544, 116 - 50, 619, 145 - 50), Point(557, 150 - 50)) then
if (AtLeftSpot) then
begin
O_Debug('WALK', 'Succesfully shore walked(1) to Left spot!');
Exit;
end
else if ShoreWalk(IntToBox(544, 116 - 50, 619, 145 - 50), Point(603, 154 - 50)) then
O_Debug('WALK', 'Shore Walked 2');
if (AtLeftSpot) then
begin
O_Debug('WALK', 'Succesfully shore walked(2) to Left spot!');
Exit;
end
else
O_Debug('WALK', 'Failed To Walk To Left Spot.... Using Attempting Backup');
WalkToDock( - 3, 1);
if FindLeftSpotDTMs(Box) then
BoxWalk(Box);
if (AtLeftSpot) then
begin
O_Debug('WALK', 'Succesfully Walked To Left Spot');
Exit;
end
else
Shutdown('couldnt switch to Left spot :(');
end;
end
end;

//fills the playerdots on the minimap as a tpa
function GetPlayerDots: TPointArray;
var
tpa, NEWTPA, REsultTPA: tpointarray;
i: integer;
begin
TPA := GetMiniMapDotsIn('white', MMX1, MMY1, MMX2, MMY2);
for i := 0 to high(TPA) do
begin
TPAFromEllipseWrap(TPA[i].x, TPA[i].y, 2, 2, Newtpa);
FillEllipse(NEWTPA);
CombineTPAWrap(NewTPA, RESULTTPA, RESULTTPA);
end;
Result := RESULTTPA;
end;

//attempts to walk to the middle of the range using the walls of the room of the range, either works or doesnt because of the 2 symbols!
function WalkToRangeMMWall: Boolean;
var
X, Y, I, DTMX, DTMY, dist: Integer;
Area, Box: TBox;
WhiteMMTPA: TPointArray;
ATPA: T2DPointArray;
PlayerDots: TPointArray;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
if FindRangeDTMs(DTMX, DTMY) then
begin
PlayerDots := GetPlayerDots;
Area := IntToBox(DTMX - 20, DTMY - 20, DTMX + 20, DTMY + 15);
FindColorsTolerance(WhiteMMTPA, 15989739, Area.X1, Area.Y1, Area.X2, Area.Y2, 30);
ClearTPAFromTPAWrap(WhiteMMTPA, PlayerDots, WhiteMMTPA);
SplitTPAWrap(WhiteMMTPA, 5, ATPA);
SetMinTPALength(ATPA, 30);
if GetArrayLength(ATPA) < 1 then
Exit;
SortATPAFromFirstPoint(ATPA, Point(DTMX, DTMY));
for I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], X, Y);
Dist := Distance(DTMX, DTMY, X, Y);
if Dist < 12 then
begin
Box := GetTPABounds(ATPA[i]);
Smart_DrawBoxEx(False, False, Box, ClLime);
if BoxWalk(Box) then
Result := True
end;
Exit;
end;
end;
end;

//walks to range
function WalkToRange: boolean;
var
x, y: integer;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
if Spot = 'right' then
begin
if WalkToDock(RandomRange( - 2, 3), - 10) then
O_Debug('WALK', 'Walked To Dock')
else if not ShoreWalk(IntToBox(527, 50 - 50, 628, 136 - 50), Point(573, 113 - 50)) then
Shutdown('Couldnt Walk To Middle Of Fish Spots, Failed Dock Walk And TPA Walk')
else
O_Debug('WALK', 'TPA Walked To Get To Middle');
end;
NotMoving(True);
if (WalkToRangeMMWall) then
begin
O_Debug('WALK', 'Found range bounds on the minimap!');
NotMoving(True);
Result := True;
Exit;
end
else if FindRangeDTMs(X, Y) then
begin
O_Debug('WALK', 'Found Range DTMs Clicking..');
Humanmmouse(X, Y, 1, 1);
ClickMouse2(mouse_left);
NotMoving(True);
Result := True;
Exit;
end
else if ClickSymbols(['cookery', 'kebab shop'], 0.30) then
begin
O_Debug('WALK', 'Used Symbols To Get To Range!');
NotMoving(True);
Result := True;
O_Debug('WALK', 'Hopefully Should Be At Range Now!');
end
else
Shutdown('Couldnt Walk Into The Range, Failed DTM And Symbol Walk')
end;

//splits the bank up into boxes and anything that shifts in the boxes will be used to find the bankers
function GetBankSearchBoxes: TBoxArray;
var
TBA: TBoxArray;
TIA: TIntegerArray;
Box: TBox;
a, b: Integer;
begin
if not WaitLoggedIn(1000) then
Exit;
Box := GetRoomBounds;
TBA := AreaToBoxArray(Box.X1, Box.Y1, Box.X2, Box.Y2, 20, 25);
TIA := PixelShiftMulti(TBA, 200);
SetArrayLength(Result, Length(TBA));
b := GetArrayLength(Result);
for a := 0 to High(TBA) do
begin
if (TIA[a] > 1) then
begin
SetArrayLength(Result, Length(Result) + 1);
Result[a] := TBA[a];
end;
end;
if b = getarraylength(Result) then
begin
O_Debug('BANK BOXES', 'Didnt Find Any Boxes To Search In! Using Room Bounds');
SetArrayLength(Result, 0);
Result := [Box];
end;
end;

//opens the bank
function OpenBankerNPC: Boolean;
var
I, TmpCTS, X, Y, C, ii, R: integer;
SearchBoxes: TBoxArray;
Banker, TPA, PBox, ClearPlayers: TPointArray;
ATPA: T2DPointArray;
Hue, Sat: array of Extended;
Col, Tol: TIntegerArray;

label
start;
begin
Start: if not WaitLoggedIn(1000) then
Exit;
Result := False;
Inc(R);
Hue := [0.11, 0.07];
Sat := [1.52, 0.19];
Col := [1988959, 2703901];
Tol := [17, 8];
PBox := TPAFromBox(IntToBox(240, 130, 275, 185));
SearchBoxes := GetBankSearchBoxes;
ClearPlayers := GetPlayersOnMS;
TmpCTS := GetColorToleranceSpeed;
for i := 0 to high(SearchBoxes) do
with SearchBoxes[i] do
begin
Smart_DrawBoxEx(False, false, SearchBoxes[i], clred);
for ii := 0 to High(Hue) do
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue[ii], Sat[ii]);
FindColorsTolerance(TPA, Col[ii], X1, Y1, X2, Y2, Tol[ii]);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(TmpCTS);
CombineTPAWrap(TPA, Banker, Banker);
end;
end;
ClearTPAFromTPAWrap(Banker, PBox, Banker);
ClearTPAFromTPAWrap(Banker, ClearPlayers, Banker);
SplitTPAWrap(Banker, 2, ATPA);
SetMinTPALength(ATPA, 60);
SortATPAFromFirstPoint(ATPA, Point(MSCX - 100, MSCY));
for i := 0 to High(ATPA) do
begin
Smart_DrawBoxEx(False, False, GetTPABounds(ATPA[i]), ClLime);
MiddleTPAEx(ATPA[i], X, Y);
HumanMMouse(X, Y, RandomRange( - 6, 6), RandomRange( - 8, 8));
if WaitUpTextMulti(['anker', 'to Ba', 'ooth'], 250 + Random(100)) then
begin
ClickMouse2(False);
if WaitOption('Bank Bank', 250 + Random(100)) then
begin
MarkTime(c);
repeat
Wait(RandomRange(50, 100));
until (BankScreen) or (PinScreen) or (TimeFromMark(C) > 5000);
if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until (BankScreen) or not (LoggedIn);
end;
if BankScreen then
begin
O_Debug('BANK', 'Open Bank > Succesfull! Bankscreen Open');
Result := True;
Exit;
end;
if TimeFromMark(C) > 5000 then
begin
O_Debug('BANK', 'Find Bank > Failed! Timeout');
Result := False;
end;
end;
end;
end;
if R > 4 then
begin
result := false;
exit;
end;
goto Start;
end;

//if we're fishing (aka the spot is active under us)
function IsFishing: Boolean;
begin
with FishSpotBox do
Result := FindFishSpotIn(20, x1, y1, x2, y2, false);
end;

//checks to be repeated every x
procedure DoChecks;
begin
TimeTrigger(@CheckCompass, Compass_Time, 60000);
TimeTrigger(@HasBait, Bait_Time, 30000);
end;

//searches for a bitmap in slot x
function FindBitmapSlot(var BMP, x, y, slot: Integer): Boolean;
var
InvSlot: TBox;
begin
InvSlot := InvBox(Slot);
Result := FindBitmapToleranceIn(BMP, X, Y, InvSlot.X1, InvSlot.Y1, InvSlot.X2, InvSlot.Y2, 20);
end;

//searches in slot 1-28 and if found will add the slot to an array
function GetBMPInvSlots(Bmp: Integer; var lowestslot, randomslot: Integer): TIntegerArray;
var
x, y, i: integer;
Slot, R: Integer;
InvSlotArray: TIntegerArray;
begin
if not WaitLoggedIn(1000) then
Exit;
for i := 1 to 28 do
if FindBitmapSlot(BMP, x, y, i) then
begin
Slot := CoordsToItem(X, Y);
SetArrayLength(InvSlotArray, Length(InvSlotArray) + 1);
InvSlotArray[High(InvSlotArray)] := Slot;
end;
if length(invslotarray) = 0 then
exit;
LowestSlot := MinA(InvSlotArray);
R := RandomRange(0, Length(InvSlotArray));
RandomSlot := InvSlotArray[R];
Result := InvSlotArray;
end;

//drops all the burnt fish
procedure DropBurntFish;
var
b: tintegerarray;
i: integer;
begin
if not WaitLoggedIn(1000) then
Exit;
B := GetBmpInvSlots(burntfood_bmp, i, i);
if GetArrayLength(B) < 1 then
Exit;
O_Debug('BANK', 'Dropping Burnt Fish...');
DropEx(B);
end;

//Gets a integer array of colours in the invent to track if they change!
function GetInvTIA: TIntegerArray;
var
tpa: tpointarray;
cols: TIntegerArray;
begin
TPAFromBoxWrap(IntToBox(578, 278 - 50, 715, 494 - 50), TPA);
Raastpaex(TPA, 12, 5);
GetColorsWrap(TPA, cols);
Result := Cols;
end;

//checks to see if the inv changed from a told TIA to a new one!
function InvChange(TheOldTIA: TIntegerArray): Boolean;
var
OldCols, NewCols: TIntegerArray;
i, H: integer;
begin
OldCols := TheOldTIA;
NewCols := GetInvTIA;
H := High(OldCols);
for i := 0 to H do
if OldCols[i] <> NewCols[i] then
Result := True;
end;

//starts cooking by clicking the interface box
function StartCooking: Boolean;
begin
if not WaitLoggedIn(1000) then
Exit;
if not CookScreen then
Exit;
Result := False;
HumanMouseBox(225, 449 - 50, 294, 508 - 50, Mouse_Move);
if WaitUpTextMulti(['Cook All', 'ook'], RandomRange(300, 400)) then
begin
ClickMouse2(Mouse_Left);
Result := True;
end;
end;

//cooks the item
procedure CookItem(name: string; bmp: integer);
var
Lowest, Rand, Slot, T, P, retry, i, RangeMinlength: integer;
Fish, InvCols: TIntegerArray;
Reason: string;
label
start;
begin
I := 0;
RangeMinLength := 200;
Start:
if not WaitLoggedIn(1000) then
Exit;
SMART_ClearScreen;
Fish := GetBmpInvSlots(bmp, Lowest, Rand);
if GetArrayLength(Fish) < 1 then
begin
O_Debug('COOK', 'No ' + Name + ' to cook, exiting');
exit;
end;
if Random(4) = 1 then
begin
Slot := Rand;
O_Debug('COOK', 'Going to cook ' + Name + ' going to click a random slot (' + IntToStr(Slot) + ')')
end else
begin
Slot := Lowest;
O_Debug('COOK', 'Going to cook ' + Name + 'going to click closest to first slot (' + IntToStr(Slot) + ')');
end;
if not ItemActivated(Slot) then
repeat
Inc(i);
if not existsitem(Slot) then
Reason := 'no item';
HumanInvMouse(Slot, Mouse_Left);
Wait(RandomRange(800, 1200));
until ItemActivated(Slot) or not (LoggedIn) or (i = 30);
if reason = 'no item' then
goto start;
if i = 30 then
shutdown('problem activateing the item');
if ItemActivated(Slot) then
O_Debug('COOK', 'Activated ' + Name + ' in slot (' + IntToStr(slot) + ')')
else
exit;
if (FindRange(RangeMinLength)) then
begin
if StartCooking then
begin
O_Debug('COOK', 'We are now cooking');
InvCols := GetInvTIA;
MarkTime(P);
MarkTime(T);
SMART_ClearScreen;
repeat
if not WaitFindBitmapInv(Bmp, 25, 60) then
begin
reason := 'ran outta fish to cook!';
break;
end;
if TimeFromMark(P) > 7500 then
begin
Reason := 'inv timed out, no change in 7.5 seconds';
if InvChange(InvCols) then
begin
InvCols := GetInvTIA;
MarkTime(P)
end else
break;
end;
if TimeFromMark(T) > 70000 then
begin
reason := 'something big went wrong';
break;
end;
FindNormalRandoms;
DoChecks;
Antiban;
Wait(RandomRange(500, 1500));
until not (LoggedIn);
end else
reason := 'didnt press cook button';
end else
reason := 'could not find range';

if not WaitLoggedIn(1000) then
Exit;

case Lowercase(Reason) of

'ran outta fish to cook!':
begin
O_Debug('COOK', 'Exited fish loop reason : ' + Reason);
O_Debug('COOK', 'Succesfully cooked all ' + Name);
Exit;
end;

'inv timed out, no change in 7.5 seconds', 'something big went wrong':
begin
O_Debug('FISH', 'Exited fish loop reason : ' + Reason + 'going to retry');
Inc(Retry);
end;

'could not find range','didnt press cook button':
begin
O_Debug('COOK', 'Exited cook loop reason : ' + Reason + 'going to retry');
Inc(Retry);
end;
else
Shutdown('Broke out of cooking loop with no reason!');
end;

if not WaitLoggedIn(1000) then
Exit;

if Retry > 10 then
Shutdown('Failed To Cook Item');

RangeMinLength := 70; //maybe we cant see much of the range lets lower the minlength

GoTo Start;
end;

//deposits all except inv slots x
function DepositAllExcept(IgnoreSlots: TIntegerArray): Boolean;
var
i: Integer;
InvSlot: TBox;
begin
if not WaitLoggedIn(1000) then
Exit;
for i := 1 to 28 do
begin
if not InIntArray(IgnoreSlots, i) then
begin
if ExistsItem(i) then
begin
InvSlot := InvBox(i);
HumanMouseBox(InvSlot.X1, InvSlot.Y1, InvSlot.X2, InvSlot.Y2, Mouse_Right);
if not WaitOptionMulti(['Deposit-All', 'All', 'it-A', 'eposit'], RandomRange(200, 400)) then
HumanMMouse(200, 200, 100, 100);
Wait(RandomRange(800, 1100));
Result := True;
end;
end;
end;
end;

//counts our items for proggys at step x
procedure CountItemsAt(WhatStep: string);
var
H, S, B: TIntegerArray;
I: integer;
begin
if not WaitLoggedIn(1000) then
Exit;
case WhatStep of
'spot':
begin
S := GetBmpInvSlots(rawsardine_bmp, i, i);
H := GetBmpInvSlots(rawherring_bmp, i, i);
Sardinecount := Sardinecount + GetArrayLength(S);
Herringcount := Herringcount + GetArrayLength(H);
end;

'bank':
begin
B := GetBmpInvSlots(BurntFood_bmp, i, i);
H := GetBmpInvSlots(CookedHerring_bmp, i, i);
S := GetBmpInvSlots(CookedSardine_bmp, i, i);
BurntCount := BurntCount + GetArrayLength(B);
CookedHerr := CookedHerr + GetArrayLength(H);
CookedSard := CookedSard + GetArrayLength(S);
end;

else
Shutdown('Trying to count in a invalid step!');
end;
end;

//handles the banking
function HandleBank: Boolean;
var
Slots: TIntegerArray;
i, r: integer;
begin
if not WaitLoggedIn(1000) then Exit;
if not (Bankscreen) then Exit;
Result := False;
R := 0;

repeat
Inc(R);
if not WaitLoggedin(1000) then exit;
Slots := GetBmpInvSlots(Bait_BMP, i, i);
If Bankscreen Then
DepositAllExcept(Slots)
else
openbankernpc;


until (InvCount < 5) or (r > 10);

If R > 10 Then
Exit;

if Random(2) = 1 then
Closebank;

Result := True;
Inc(trips);
Proggys;
DoChecks;
end;

//cooks fish! randomises what one to cook first
procedure CookFish;
begin
if not WaitLoggedIn(1000) then
Exit;
CountItemsAt('spot');
if Random(2) = 1 then
begin
CookItem('Sardine', rawsardine_bmp);
CookItem('Herring', rawherring_bmp);
end
else
CookItem('Herring', rawherring_bmp);
CookItem('Sardine', rawsardine_bmp);
end;

//handles walking to range, cooking, banking etc!
function CookBankReturn: Boolean;
begin
if not WaitLoggedIn(1000) then
Exit;
Result := False;
if (WalkToRange) then
CookFish
else
Shutdown('Couldnt walk to range');
if WalkToBank then
begin
NotMoving(False);
CountItemsAt('bank');
if (DropBurnt) then
DropBurntFish;
if OpenBankerNPC then
begin
O_Debug('BANK', 'Sucessfully opened bank, bankscreen is open');
if (HandleBank) then
O_Debug('BANK', 'Sucessfully depostied fish!')
else
shutdown('couldnt handle bank');
end else
shutdown('couldnt open the bank!');
if WalkToSpotFromBank then
Result := True;
end;
end;

//gets the colour at a point
function GetColorTPoint(T: TPoint): Integer;
begin
Result := GetColor(T.x, T.y);
end;

//draws the spot onscreen the middle being transparent thanks to Kasi!
procedure DrawSpot;
var
TransBox: TBox;
I, R, G, B, H: Integer;
begin
SMART_DrawBitmap(false, FishOutline_BMP, Point(246, 197));
H := High(FishBox);
for I := 0 to H do
begin
ColorToRGB(GetColorTPoint(FishBox[I]), R, G, B);
SMART_DrawDot(false, FishBox[I], RGBtoColor(160, G, B));
end;
end;

//does everything in a loop!
procedure FishLoop;
var
t, Retry, Timeout, p: integer;
Reason: string;
Draw: Boolean;
InvCols: TIntegerArray;
label
start;
begin
if not (AtFishSpot) then
Exit;
Start:
if not WaitLoggedIn(1000) then
Exit;
Retry := 1;
Draw := False;
Timeout := RandomRange(500, 850);
SMART_ClearScreen;
if FindFishSpotIn(20, MSX1, MSY1, MSX2, MSY2, True) then
begin
SMART_ClearScreen;
Retry := 0;
NotMoving(True);
Wait(RandomRange(800, 1200));
RandomAction;
InvCols := GetInvTIA;
MarkTime(P);
MarkTime(T);
repeat
if (IsFishing) then
begin
MarkTime(T);
if not Draw then
begin
DrawSpot;
Draw := True;
end;
end;
if (InvFull) then
begin
Reason := 'inv full';
Break;
end;
if TimeFromMark(T) > TimeOut then
begin
Reason := 'fishspot dissapeared';
O_Debug('FISH', 'We aren''t fishing anymore');
Break;
end;
if TimeFromMark(P) > 15000 then
begin
Reason := 'inv timed out, no change in 15 seconds';
if InvChange(InvCols) then
begin
InvCols := GetInvTIA;
MarkTime(P)
end
else
break;
end;
FindNormalRandoms;
Wait(RandomRange(50, 100));
DoChecks;
antiban;
until not (LoggedIn);
if not WaitLoggedIn(1000) then
Exit;
end
else
Reason := 'found no fishspot';
Inc(Retry);
case Lowercase(Reason) of
'inv full':
begin
O_Debug('FISH', 'Exited fish loop reason : ' + Reason);
Smart_Clearscreen;
if CookBankReturn then
O_Debug('FISH', 'succesfully cooked and bank and made it back to fish spot!')
else
shutdown('Couldnt return to fish spot after banking');

If (TakeBreaks) Then
HandleBreaks;
end;
'inv timed out, no change in 15 seconds':
begin
O_Debug('FISH', 'Exited fish loop reason : ' + Reason);
Inc(Retry);
end;
'fishspot dissapeared', 'found no fishspot':
begin
Inc(Retry) O_Debug('FISH', 'Exited fish loop reason : ' + Reason);
if (Retry) > 20 then
shutdown('DIDNT FIND FISH SPOT 20 ATTEMPTS!');
if (Retry) > 2 then
begin
O_Debug('FISH', 'No fishing spots here! switching spots: ' + Reason);
SwitchSpots;
end;
end;
else
Shutdown('broke out of the fishing loop with no reason...');
end;
goto start;
end;

//attempts to relocate us to a fishspot from anywhere around the area
function Relocate: Boolean;
var
Box: Tbox;
begin
Result := False;
if AtFishSpot then
begin
O_Debug('WALK','Already at fish spot');
result := true exit;
end;
if FindRightSpotDTMs(Box) or FindLeftSpotDTMs(Box) then
BoxWalk(Box)
else if walktodock( - 3, - 7) then
if FindRightSpotDTMs(Box) or FindLeftSpotDTMs(Box) then
BoxWalk(Box)
else
clicksymbols(['fish'], 0.30);
NotMoving(True);

if AtFishSpot then
begin
O_Debug('WALK','Relocated to fish spot!');
Result := True;
Exit;
end
else
Shutdown('Couldnt Relocate');
end;

//Everytime we login this will happen
procedure SetupLogin;
begin
O_Debug('SETUP', 'Waiting A Few Seconds In Case Of Lagg...');
Wait(RandomRange(3000, 4000));
O_Debug('SETUP', 'Moving Compass And Setting Angle..');
MakeCompass('e');
Wait(RandomRange(100, 500));
SetAngle(SRL_ANGLE_HIGH);
SetAngle(SRL_ANGLE_HIGH);
Wait(RandomRange(100, 500));
FindNormalRandoms;
O_Debug('SETUP', 'Setup Complete');
Proggys;
Relocate;
end;

begin
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
SRL_Procs[SRL_Antiban] := @WhileFlag;
SRL_Procs[SRL_OnLogIn] := @SetupLogin;
SetupScript;
ScriptStart:

FishLoop;

if not WaitLoggedIn(1000) then
begin
O_Debug('LOGIN','Not logged in! attempting to log back in!');
If LoginPlayer Then
begin
O_Debug('LOGIN','Succesfully logged back in!');
GoTo ScriptStart;
end else
shutdown('failed logging back in!');
end;
end.


Ashaman88

2012-11-06 12:11:27

Did you add the script setup info inside the script? I see some there

BraK

2012-11-06 12:12:55

I did it's there I could pull it out and place it in the thread. But I just posted it how the users sent it to me. :)

Ashaman88

2012-11-06 12:28:20

From: BraK
I did it's there I could pull it out and place it in the thread. But I just posted it how the users sent it to me. :)


aw ok just making sure! Also when are we looking to have these judged by? Sorry if I missed the thread

BraK

2012-11-06 12:32:51

The 1st of December is the deadline for results. We'll announce them to the public on that day.

Ashaman88

2012-11-21 16:59:12

1. Technique (80/100)
-Ton of unused variables
-Correct usage of loops
-Good job using and freeing variables

2. Individuality (80/100)
-Good use of debug
-Uses a lot of other peoples functions, but for good reason
-Good use of different types of functions

3. Follow rules (90/100)
-Standards are good
-Good checks to see if we are logged in as well as spintickets
-No infinite loops

4. Creativity (96/100)
-Unique antiban
-Lots of great support functions
-Custom uptext finding

5. Efficiency (97/100)
-Lots of different methods and failsafes
-Advanced usage of TPAs,ATPAs
-Good use of logic
-Like function for finding banker
-Breaking up of functions me likey
-Very efficient to do it this way:
SRL_Procs[SRL_Antiban] := @WhileFlag;
SRL_Procs[SRL_OnLogIn] := @SetupLogin;

6. Presentation (95/100)
-Good instructions on setup
-Good standards
-Nice proggy (debug and paint)

7. Requirements (100/100)
-Multiplayer, w/ good explanation of how to use
-Walking (symbol, tpa)
-Cook and fish
-Banking w/ custom functions

8. Added Extras (70/100)

-Thorough debug


Average: 88

NKN

2012-11-24 02:25:12

1. Technique (88/100)
*Unused variables
*Good loops
*Good use of failsafes
*Good custom functions

2. Individuality (95/100)
*Fantastic debugging
*Great object finding
*Debug and Onscreen paint



3. Follow all SRL rules (95/100)
*Good loops
*Unused variables
*Good job freeing variables
*Standards are good

4. Creativity (90/100)
*Script idea is kind of basic
*Screenshots tho, a plus
*Two paints
*Lots of debug
*Big script
*Bitmaps and not just DTMS


5. Efficiency (92/100)
*Could combine some functions(personal preference)
*Advanced TPAs
*Nice script logic
*Lots of procedures and failsafes
*Specially dat bank procedure


6. Presentation (96/100)
*Instructions on setup in script
*Nice standards
*Two proggies
*Screenshots baby

7. Meeting all Requirements (100/100)
*Multiplayer
*Walking
*Two skills
*Banking

8. Added Extras (72/100)
*Nice debugging
*Two paints

Average Score: 91%