SRL Archive - RS3 Outdated / Broken Scripts

Crafting Guild Bowl Maker (beta)


EtherFreak

2011-01-09 14:34:11

My latest atrocity is now up and running (ish). I believe that it will work ok, but it is still a work in progress. detailed feedback is nice.

I have had it work for 100 loads without a glitch, but results may vary.

SETUP:
Have a pickaxe equipped. (or in tool belt)
Be on a free world (not members!)
be inside the crafting guild.
chose the number of loads to run.
for smart, enter your username/pass in the usual field and remove the // where it says to.

Notes:
Random detection may not be perfect yet.
no continue from break (but every time you run, you will empty all inv slots, and start over).

Future Plans:
Add urn support for better exp per hour. improve random detection, improve fail safes.

Once again, Please note this is a BETA, and as such, bugs may be encountered. Feel free to make suggestions to improve the script if you have more programing experience.

Update 0.1
Added failsafes to the script, so if it fails, it will quit after a few tries, and give better feedback. also fixed some timing issues to make it seem more human.

Update 0.2
Fixed the wheel finding issue, and the update with the urns.

Update 03
Removed the bucket setup, as buckets are no longer needed. fixed some timing issues.

Update 04
Changed from static time to detection of the completion of each process. minor changes here and there, and improved the wheel finding (hopefully). Also added a few more failsafes.

Update 05
Fixed some timing issues, and some other errors found in my code. seems to work good so far. One minor issue is the uptext detection can sometimes not be read, but has not stopped the script as of yet. Please make sure you are on a FREE world for this script to work correctly. it may work on members, but I do not have the layout correct for crafting bowls on a members world.

Update V1
fixed wheel finding, and seems to be working great. I am not aware of any issues as of yet, and my testing has found none thus far. remember, this is made for free worlds only!!!

Becks

2011-01-09 14:35:42

I'll give it a run. exp per hour?

EtherFreak

2011-01-09 14:58:29

I guess I should add in exp calculations. it takes about 5 min to complete a load of 14 bowls, which gives 462 exp. so in one hour, you will get about 5.5 k exp per hour. probably not the way to get to lvl 99, but a way to catch a few levels for free.

EtherFreak

2011-01-11 02:03:30

As of version 0.1 beta, it now takes about 4.5 minutes to complete a run. I am having an occasional hang on finding the potters wheel. I will try and setup a bitmap to find the wheel, but I will need to learn how to take bitmaps.

As always, feedback is appreciated.

KingKong

2011-01-11 03:28:40

I don't think bitmaps will work for the wheel since on the main map and it changes everytime, the easiest way would be using reflection and using tiletoms or if you feel like a challenge you could use tpa finding.

RISK

2011-01-11 04:33:40

In your procedure names / function names, you should camel cap the names.
From this: "findtpalrg"
To something like this: "FindTPA_LRG" or something of the sorts depending on how you like.
It makes for better readability.

You should also do the same with your statements. Like: "dropallexcept" to "DropAllExcept".

Also, you should work on your standards. Like this example:

repeat
// Code here
until loadcount=count

That should be:

repeat
// Code here
until(Blagh blagh blagh);

The previous was all about your standards, which you really need to work on.

–

You should use a procedure called "MainLoop" instead of using the "begin end." nest. That way you do not have to clutter your "begin end." nest and only have to call on one procedure to get everything started.

Something like this:

procedure MainLoop;
begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
Wait(1000); // I find this is amazing for slow computers - This is optional!

Kill := 0;
Count := 0;
Wait(5000); // From your "InitRun" procedure
SetAngle(True);
SymbolAccuracy := 0.5;
MouseSpeed := (7 + Random (3));
FindNormalRandoms;

{
@ SymbolAccuracy :
- This should not have to be declared at the start. It is automatically
declared in SRL to be at 0.7. You should also ALWAYS use it "On the fly",
and not declare it in the start and then revert it back to its default
value once you done with it.

PS: I may be wrong on the 0.7 value part. The point remains, though!

@ MouseSpeed :
- While this is a decent idea, the mouse would still be too slow. The SRL
default MouseSpeed value is about 14 or so. Which is perfect. So try
making your MouseSpeed randomizing something like this:
"MouseSpeed := RandomRange(12, 17);"
}
end;

–

Also for your problem with finding the wheel that is used in the script:
Learn how to use TPA object finding. Not only will it replace your standard "if FindObj*" stuff, it will also give you more experience at more "Advanced" things of scripting.

Here is a good tutorial: HERE. The first two parts about the CTS and the advanced arrays are what you what. (Specifically TPointArrays for the array segment).

You will notice a HUGE difference in your script after you learn how to properly use CTS and TPAs for object finding.

–

Overall, this is a nice script idea and a good base to start on. I really look forward to seeing what you create in the future. So don't give up with scripting, EtherFreak!

EtherFreak

2011-01-18 01:16:46

Kongking, thank you for letting me know about the bitmaps, It saved me from trying to figure it out the hard way.
Risk, I will look into improving my TPA. I tackled tpa once to get my mining procedures working good, and good they work. As for my mouse speed, I have the speed set to what I feel is most like me playing on my computer. I try to have my scripts look like me playing. I will work on getting my procedures up to standard, and I am working on expanding my knowledge with TPA finding. As for symbol finding, I did not know it started off at 0.7.

Look for future releases of this script, I am working on it between school and work.

EtherFreak

2011-02-11 15:12:20

Well, I am having no luck with my TPA to find the pottery wheel. I often find the wall, or other random things. If anyone is so inclined to take this script further, feel free and just credit where credit is due. I will continue to fool with it, and should I get a working wheel finding method, I will post my update.

KingKong

2011-02-12 23:15:58

Tried using reflection to find the wheel instead, its easier. If you don't want to use reflections then use FindObj to find the wheel, maybe that would make it easier.

grats

2011-02-13 00:19:25

From: KingKong
Tried using reflection to find the wheel instead, its easier. If you don't want to use reflections then use FindObj to find the wheel, maybe that would make it easier.


He would have to use smart then wouldn't he?

KingKong

2011-02-13 05:20:29

If he uses reflection, then yes you need smart, but if he uses findobj, then he doesn't need to, since its SRL function.

Sir R. M8gic1an

2011-02-13 08:54:10

Here's my crafter from just before I got Dev status.


{==============================================================================]
[==============================================================================]
[ RM Power Crafter ]
[ By: Rasta Magician ]
[==============================================================================]
[ Features ]
[==============================================================================]
[ 1. Debug ]
[ 2. AntiRandoms ]
[ 3. AntiBan ]
[ 4. Multiplayer ]
[ 5. Resting ]
[ 6. Progress Report ]
[ 7. Local Control ]
[ 8. Responder ]
[ 9. Proggy To File ]
[ 10. Smart Cycleing ]
[==============================================================================]
[ Description ]
[==============================================================================]
[ Mines clay, softens it, molds it into bowls(f2p), ]
[ plant pots or pot lids (with needed quest), then fires the clay, drops it ]
[ and repeats the whole thing. All of this happens inside the Crafting Guild ]
[ ]
[==============================================================================]
[ How To Use ]
[==============================================================================]
[ 0. You need level 40 crafting ]
[ 1. Wield a pick ]
[ 2. Wear a brown appron ]
[ 3. Have jugs in inventory (I suggest 4 jugs) ]
[ ]
[==============================================================================]
[ Credits ]
[==============================================================================]
[ SRL Team ]
[ Ed, thx for testing ]
[==============================================================================]
[ RM Power Crafter by Rasta Magician ]
[==============================================================================]
[==============================================================================}

{
add one more text for moulding clay
mold and fire menu colors changed place
}


program RMScript;
{$DEFINE SMART }
{$DEFINE Reflection}
//{$DEFINE FORM }

{$IFDEF SMART }
{.include srl/srl/misc/Smart.scar}
{$ENDIF}
{.include srl/srl.scar}
{$IFDEF Reflection}
{.include SRL\SRL\Reflection\Reflection.scar}
{$ENDIF}
{.include srl/srl/skill/mining.scar}

{$IFDEF FORM }
{.include srl/srl/misc/users.scar}
{$ENDIF}

Const
WorkTime = (30*60*1000); //10 mins
RestTime = (3*60*1000); //3 mins

IsMember = true;

UseDebug = True;
UseResponder = True;
SaveProggyToFile = True;

ScriptName = 'RM Power Crafter';
Version = '2.0';

YourSRLID = ''; //your SRLID
YourSRLPass = ''; //your SRL Stats pass
MyScriptID = '1199'; // don't touch

var
Rested, Worked, Loads,
PickColor, LadderColor, OvenColor,
ClayDTM, SoftDTM, JugDTM, WJugDTM, GemDTM,
JugCount, ClayCount,
ClayMined :integer;
ProggyStr: string;


function IsSameIntArray(i1, i2:TIntegerArray):boolean;
var i:integer;
begin
Result := false;
if Length(i1) <> Length(i2) then exit;

Result := true;
for i:= 0 to high(i1) do
if i1[i] <> i2[i] then
Result := False;
end;

//for debugging TPAs, to help me perfect my finders
//by Wizzup?
Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I, L: Integer;
xs, ys, xe, ye: Integer;

Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(Points) Do
Begin
xs := Min(xs, Points[i].X);
ys := Min(ys, Points[i].Y);

xe := Max(xe, Points[i].X);
ye := Max(ye, Points[i].Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To High(Points) Do
FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, 255);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;

//Declaring players
Procedure DeclarePlayers;
begin

{$IFDEF Form}
SRLPlayerForm(True, [], [], [], []);
exit
{$ENDIF}

NumberOfPlayers(1);
CurrentPlayer := 0;

Players[0].Name :='RMagician';
Players[0].Pass :='Th1sIsN0tMyPW!';
Players[0].Nick :='agi';
Players[0].Active := True;


end;

//Used for debugging and finding errors
Procedure RMDebug(s:string);
var name:string;
begin
if not UseDebug then exit;
try name := Players[CurrentPlayer].Name +' : '; except name:= '' end;
writeln(name+TheTime+' - '+s);
end;


//local control, F12 to activate and then text. used to check on proggies and
//to reactivate players
//untested with smart, might not work
{$IFDEF SMART}
procedure Proggy; forward;
Procedure EasyRC;
var i:integer;
begin
if not IsFKeyDown(12) then exit;
LogOut;

Proggy;
writeln('Fresh proggie on your right');
writeln('');

writeln('--- MENU ---');
writeln('F9 --> Status');
writeln('F10 --> Reset All');
writeln('F11 --> manage players');
writeln('F1 --> Keep on autoing');
writeln('--- End Menu --- ');
writeln('');
wait(2000);
repeat
if IsFKeyDown(9) then //status
begin
for i:=0 to High(players) do
writeln(IntToStr(i)+': '+Players[i].Nick+' - '+BoolToStr(Players[i].Active));
end;

if IsFKeyDown(10) then //Reset All
begin
for i:= 0 to High(Players) do
Players[i].Active := true;
writeln('Reset all :) ');
end;

if IsFKeyDown(11) then // Manage Players
begin

end;

if IsFKeyDown(1) then break;
until(false)
writeln('Restarting to auto :)');
LoginPlayer;
end;

{$ELSE}

//local control, F12 to activate and then text. used to check on proggies and
//to reactivate players
//untested with smart, might not work
Procedure EasyRC;
var
i, h1, h2, x, y:integer;
s, str: string;
begin
if not LoggedIn then exit;
if IsFKeyDown(12) then
begin
RMDebug('Trying to use Easy RC');
h1 := GetClientWindowHandle;
GetMousePos(x, y);
SetClientPos(False);
Disguise('RM Easy RC');
if FindWindowTitlePart('RM Easy RC', false) then writeln('Using Easy RC');
h2 := GetClientWindowHandle;
SetOnTop(h1, False);
SetOnTop(h2, True);
SetClientWindowHandle(h2);
wait(100);
ActivateClient;
wait(100);

repeat
s:= ReadLn('What to do?'+chr(13)+'Status / Reset N / Reset All / Proggy / Exit');
lowercase(s);
if (s = 'exit') or (s = '') then break;

if s= 'status' then
begin
for i:= 0 to High(Players) do
if not Players[i].Active then str:= str+chr(13)+Players[i].Name;
readln('these are set to false: '+chr(13)+str+chr(13)+'Press ok');
end;


if s = 'proggy' then
begin
Readln(ProggyStr+chr(13)+'Press ok');
end;

if Pos('reset', s) > 0 then
begin
str := TrimLetters(Trim(s));
if str = '' then
begin
for i:= 0 to High(Players) do
Players[i].Active:= True;
ReadLn('All Players Active'+chr(13)+'Press ok');
end else
try begin
i:= StrToInt(str);
Players[i].Active := True;
Readln('activated player: '+str+chr(13)+'Press ok');
end except break end;
end;
until(false)

SetOnTop(h2, False);
SetOnTop(h1, True);
SetClientWindowHandle(h1);
ActivateClient;
MMouse(x, y, 2, 2);
wait(3000);
Disguise(' A: '+IntToStr(PlayersActive)+'/'+IntToStr(Length(Players))+' Loads: '+IntToStr(loads));
RMDebug('Done using Easy RC');
end;
end;
{$ENDIF}


type
MyChat = record
Chatter: TStringArray;
Said: TStringArray;
LastResponded: integer;
end;
var
Trigger: Array of Array[0..1] of TStringArray; //questions, could make more triggers... if i
Answers: Array of TStringArray; //find i need them
RMTalks: MyChat;
Responses: Integer;



// to setup the questions qnd qnswers for the auto responder
procedure SetupRespond;
begin

SetLength(RMTalks.Chatter, 8);
SetLength(RMTalks.Said, 8);

SetLength(Trigger, 7); //how many questions
SetLength(Answers, Length(Trigger));
//you can have as many trigger words and rows as you want
//you can have as many answers as you want

Trigger[0][0]:= ['wc', 'woodcutting']; // trigger words 1
Trigger[0][1]:= ['lvl', 'level']; // trigger words 2
//Trigger[0][2]:= ['','','','','','']; // trigger words 3
Answers[0]:= [
'My Woodcutting Level is: '+IntToStr(Players[CurrentPlayer].Level[20]), //answer 1
'Wc: '+IntToStr(Players[CurrentPlayer].Level[20]), //answer 2
IntToStr(Players[CurrentPlayer].Level[20])+' wc lvl', //answer 3
'my wcing lvl is '+IntToStr(Players[CurrentPlayer].Level[20]) //answer 4
]

Trigger[1][0] := ['axe'];
Trigger[1][1] := ['which', 'what'];
Answers[1] := [
'I''m using a '+Players[CurrentPlayer].Strings[2]+' axe',
Players[CurrentPlayer].Strings[2],
'my axe is made out of '+Players[CurrentPlayer].Strings[2]
]

Trigger[2][0]:= ['good place', 'train'];
Trigger[2][1]:= ['woodcutting', 'wc'];
Answers[2] := [
'Try Training Woodcutting at Draynor',
'Draynor', 'Varrock', 'Edgy', 'Fally',
'Try Training Woodcutting at Edgeville',
'Try Training Woodcutting at Varrock Palace',
'Try Training Woodcutting at South of Falador'
]


Trigger[3][0]:= ['fish', 'fishing', '><>', '<><']; // trigger words 1
Trigger[3][1]:= ['lvl', 'level', 'levl', 'lvel']; // trigger words 2
//Trigger[3][2]:= ['','','','','','']; // trigger words 3
Answers[3]:= [
'My Fishing Level is: '+IntToStr(Players[CurrentPlayer].Level[17]), //answer 1
'Fishing: '+IntToStr(Players[CurrentPlayer].Level[17]), //answer 2
IntToStr(Players[CurrentPlayer].Level[17])+' '+chr(62)+chr(60)+chr(62)+' lvl', //answer 3
'my fishy lvl is '+IntToStr(Players[CurrentPlayer].Level[17]) //answer 4
]


Trigger[5][0]:= ['place', 'train'];
Trigger[5][1]:= ['fishing', '><>', 'fish'];
Answers[5] := [
'Try Training fishing at Draynor',
'Draynor', 'Edgy', 'Al-Kharid', 'Karamja',
'Try Training fishing at Edgeville',
'Try Training fishing at Al-Kharid, close to bank',
'Try Training fishing at lumbridge'
]

Trigger[6][0]:= ['hi','hey', 'hello', 'sup?']; // trigger words 1
Trigger[6][1]:= ['']; // trigger words 2
Answers[6]:= ['hi','hey', 'hello', 'sup?', 'how do you do?'] ;
end;

//from srl, modded for any line
function GetChatTextLine(var chat: string; line:integer): Boolean;
var
x, y: Integer;
textP: TPoint;
begin
if not LoggedIn then exit;
textP := TextCoords(line);
if findcolor(x, y, 16711680, textp.x, textp.y, textp.x + 200, textp.y + 14) then
begin
chat := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False,

False, -1, 1, 16711680, 60, False, tr_allChars)));
Result := True;
end;
end;

//from srl, modded for any line
function GetChatterLine(var name: string; line:integer): Boolean;
var
i: Integer;
textP: TPoint;
begin
if not LoggedIn then exit;
textP := TextCoords(line);
name := LowerCase(Trim(GetTextAtEx(textP.x - 2, textP.y - 2, 0, SmallChars, False, False, 0, 1,
0, 60, False, tr_allChars)))
i := Pos(':', name)
if (i <> 0) then
begin
Delete(name, i, i);
Result := True;
end;
end;

//my responder, used as antiban to look more human
procedure RMRespond;
var
str: string;
i, h, t, k, triggered:integer;
TSA:TStringArray;
begin
if not LoggedIn then exit;
if (TimeFromMark(RMTalks.LastResponded) < 60000+Random(30000)) then exit;


SetLength(TSA, 8)
str:='';
TSA:=['', '', '', '', '', '', '', ''];
RMTalks.said := ['', '', '', '', '', '', '', ''];
triggered := 0;

// Getting text on all the lines
for i:= 7 DownTo 0 do
begin
GetChatterLine(RMTalks.Chatter[i], i+1);
if Pos(Lowercase(Players[CurrentPlayer].Nick), Lowercase(RMTalks.Chatter[i])) > 0 then
break; //if we already answered, it means we already checked further up.
GetChatTextLine(RMTalks.said[i], i+1);
TSA[i] := RMTalks.said[i];
end;

for i:=High(TSA) DownTo 0 do //all text lines
for h:= 0 to High(Trigger) do //questions
begin
triggered:= 0;
for t:=0 to High(Trigger[h]) do //How many triggers

for k:=0 to High(Trigger[h][t]) do //specific trigger

if Pos(Trigger[h][t][k], TSA[i]) > 0 then
begin
Inc(triggered);
if triggered >= 2 then
begin

Inc(Responses);
str:=(Answers[h][Random(Length(Answers[h]))]);

TypeSend(AddMistakes(str, RandomRange(10, 30)));

RMDebug('Question: '+Trigger[h][0][0]+ ' ' + Trigger[h][t][k]);
RMDebug('Responding: ' + str);

str := '';
MarkTime(RMTalks.LastResponded);
triggered := 0;
SetupRespond;

exit;
end; //end if
break;
end; //end if
//end k loop
end; //end h loop
//end of i loop
end;

//making sure we solve those annoying randoms :)
Function NoRandoms: boolean;
var
x, y:integer;
s:string;
begin
if not LoggedIn then exit;
Result := False;
GetMousePos(x, y);
if UseResponder then RMRespond;
if ClickToContinue then
begin
MMouse(x, y, 3, 3);
Result := True;
end;
if FindNormalRandoms then Result:=true;
if FindFight then
begin
//none of the run aways check for randoms....

case random(4) of
0: s:='n';
1: s:='w';
2: s:='s';
3: s:='e';
end;

RMDebug('running to ' + s + ' and waiting for 8 - 10 s');
RunTo(s, True);
SleepAndMoveMouse(RandomRange(8000, 10000));

case s of
'n': s:= 'S';
's': s:= 'N';
'w': s:= 'E';
'e': s:= 'W';
end;

RMDebug('Returning to ' + s);
RunTo(s, True);

Result:=True;

NoRandoms;
end;

EasyRc;

end;



//Progress report
procedure Proggy;
var
JX2, i, i2, xph:integer;
str: string;
begin
ClearReport;
SRLRandomsReport;

AddToReport('');
AddToReport('[====== '+Padr(ScriptName+' '+Version, 27)+' ======]');
AddToReport('[ By Rasta Magician ]');
AddToReport('[=========================================]');
AddToReport('[ ' + Padr('Written ' + (TheTime) + ' on ' + (TheDate(3)) + '.', 40) + ']')
AddToReport('[ '+ Padr(TimeRunning, 40)+']');
AddToReport('[ ' + Padr('Players: ' + IntToStr(PlayersActive)+ ' / ' + IntToStr(HowManyPlayers), 40) + ']');
AddToReport('[ ' + Padr('Current Player: ' + Players[CurrentPlayer].Nick, 40) + ']');
AddToReport('[ '+ Padr('Loads: '+IntToStr(Loads), 40)+']');
AddToReport('[ '+ Padr('Clay Mined: '+IntToStr(ClayMined), 40)+']');
AddToReport('[ '+ Padr('Mining XP: '+IntToStr(ClayMined*5), 40)+']');
AddToReport('[ '+ Padr('=== CRAFTING XP ===', 40)+']');
xph := Round((ClayMined*40*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Lids: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*37.5*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Plant Pots: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*33*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Bowls: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*25*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Dishes: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*12.6*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Pots: '+IntToStr(xph)+' xp/h', 40)+']');
AddToReport('[ '+ Padr('=== CRAFTING XP ===', 40)+']')
AddToReport('[ '+Padr('Rested: '+IntToStr(Rested), 40)+']');
AddToReport('[================== RM ===================]');

ProggyStr := '';
ProggyStr := ProggyStr + chr(13) + ('[====== '+Padr(ScriptName+' '+Version, 27)+' ======]');
ProggyStr := ProggyStr + chr(13) + ('[ By Rasta Magician ]');
ProggyStr := ProggyStr + chr(13) + ('[=========================================]');
ProggyStr := ProggyStr + chr(13) + ('[ ' + Padr('Written ' + (TheTime) + ' on ' + (TheDate(3)) + '.', 40) + ']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr(TimeRunning, 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ ' + Padr('Players: ' + IntToStr(PlayersActive)+ ' / ' + IntToStr(HowManyPlayers), 40) + ']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr('Loads: '+IntToStr(Loads), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr('Clay Mined: '+IntToStr(ClayMined), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ '+Padr('Rested: '+IntToStr(Rested), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[================== RM ===================]');


AddToReport('[ P | A | L | Mins | Rand ' + Padl(']', 13));
AddToReport('[-----------------------------------------]');

ProggyStr := ProggyStr + chr(13) + ('[ P | A | L | Mins | Rand ' + Padl(']', 13));
ProggyStr := ProggyStr + chr(13) + ('[-----------------------------------------]');

for i:= 0 to HowManyPlayers - 1 do
begin
str := '[ ' + Padr(Players[i].Nick, 4) + ' | ';
if Players[i].Active then
str := str + 'T | '
else
str := str + 'F | ';

str := str + Padr(IntToStr(Players[i].Banked), 2) + ' | ' + Padr(IntToStr(Players[i].Worked), 5) +'| ';
str := str + Padr(Players[i].Rand, 16) + ' ]';
AddToReport(str);
ProggyStr := ProggyStr + chr(13) + str;
end;

str := ScriptName+' '+Version
i := length(str);
if (i mod 2) <> 0 then
i2 := 1;

AddToReport('[-----------------------------------------]');
AddToReport('[====== '+Padl('', 14 - Trunc(i/2)) + str + Padr('', 13 + i2 - Trunc(i/2))+' ======]');
AddToReport('[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]');

ProggyStr := ProggyStr + chr(13) + ('[-----------------------------------------]');
ProggyStr := ProggyStr + chr(13) + ('[====== '+Padl('', 14 - Trunc(i/2)) + str + Padr('', 13 + i2 - Trunc(i/2))+' ======]');
ProggyStr := ProggyStr + chr(13) + ('[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]');

if SaveProggyToFile then
begin
JX2 := ReWriteFile((ScriptPath + ScriptName +' '+ Version + '.txt'), False);
WriteFileString(JX2, ProggyStr);
CloseFile(JX2);
RMDebug('Progress report saved to: ' + ScriptPath + ScriptName + ' ' + Version + '.txt');
end;
Disguise(' A: '+IntToStr(PlayersActive) + '/' + IntToStr(HowManyPlayers) +
' Loads: ' + IntToStr(Loads));
end;

//Antiban, basically just picks up the mouse, increases mouse speed
//clicks a tab and resets everything back to the original.
//just to make sure we stay logged in.
procedure FastSwitchTabs;
var x, y, i, h:integer;
begin
if not LoggedIn then exit;
RMDebug('Inactive Move');
GetMousePos(x, y);
PickUpMouse;
IncEx(MouseSpeed, 10);
i := GetCurrentTab;
repeat
h := 1+Random(12);
until(h <> i)
GameTab(h);
wait(500+Random(500));
GameTab(i);
MMouse(x, y, 3, 3);
DecEx(MouseSpeed, 10);
end;

//will take "Time" + Random(1000) to complete the action, will return to original angle
// By Rasta Magician, heavily based on RandomMovement by Krazy_Meerkat
// will always move the compass around unlike in RandomMovement
procedure CompassMove(Time:Integer);
var
Keys: array of Integer;
I: Integer;
Deg: Extended;
begin
if not LoggedIn then exit;
Keys := [VK_RIGHT, VK_LEFT];
I := Random(2);
ActivateClient;
Deg := rs_GetCompassAngleDegrees;
Wait(100 + random(50));
KeyDown(Keys[I]);
Wait(Round(Time/2) + random(500));
KeyUp(Keys[I]);
Wait(Round(Time/2) + random(500));
MakeCompass(FloatToStr(Deg));
end;

//Random Right Click Return by Rasta Magician,
//Will right-click anywhere on he main map, choose "Cancel" and return the
//mouse to it's original position
procedure RRClickReturn;
var x, y:integer;
begin
if not LoggedIn then exit;
IncEx(MouseSpeed, 7);
GetMousePos(x, y);
ActivateClient;
Mouse(MSX1, MSY1, MSX2, MSY2, False);
wait(100 + Random(50));
ChooseOption('ancel');
wait(50 + Random(100));
MMouse(x, y, 3, 3);
DecEx(MouseSpeed, 7);
end;

//just antiban with a percentage
Procedure AntiBan(percentage: integer);
var p: integer;
begin
if not Loggedin then exit;
if random(100) <= percentage then
begin
case random(14) of
0, 1: FastSwitchTabs;
2, 3: CompassMove(1000);
4, 5: RRClickReturn;
6, 7: SleepAndMoveMouse(2000);
8, 9: HoverSkill('random', false);
//10, 11: DoEmote(Random(37)+1);
12, 13: PickUpMouse;
end;
Gametab(4);
end;
end;

{$IFDEF SMART}
Procedure SetupSmart(world: integer);
begin

SmartSetupEx(world, False, True, False);
Wait(5000);
SetTargetDC(SmartGetDC);
repeat
wait(100);
until(SmartGetColor(253, 233)<>1118604);

end;
{$ENDIF}

//Used to set up all the necessary things before the script starts running
Procedure SetupScript;
begin
ClearDebug;
Disguise(ScriptName + ' ' + Version);
{$IFDEF SMART}
SetupSmart(100);
{$IFDEF Reflection}
RMDebug('Checking hooks, if they''re outdated un-define reflection to run this');
SetupReflection;
{$ENDIF}
{$ENDIF}
SetupSRL;
DeclarePlayers;
if UseResponder then SetupRespond;

SRLID := YourSRLID;
SRLPassword := YourSRLPass;
ScriptID := MyScriptID;
ActivateClient;
LoginPlayer;
end;


//for prepqring the playe and making sure he has all the requirements
procedure SetupPlayer;
begin
if not LoggedIn then exit;
SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
CloseWindow;
MarkTime(Worked);
GameTab(4);
wait(500);
JugCount := CountItems(JugDTM, 'dtm', []);
RMDebug('Player has '+IntToStr(JugCount)+' jugs');
SetAngle(true);
end;

//switching palyers, or in case of jsut one player making it rest
// "not playing" for a while decreases the chance of getting a lot of randoms
procedure SwitchPlayers;
var Time: integer;
begin
if (TimeFromMark(Worked) >= (WorkTime + Random(3*60*1000)) )or(not LoggedIn) then
begin
if PlayersActive > 1 then
NextPlayer(Players[CurrentPlayer].Active)
else begin
if not LoggedIn then TerminateScript;
LogOut;
RMDebug('resting....');
Time := GetSystemTime;
while (GetSystemTime - Time < RestTime) do
Disguise('Rest: '+IntToStr(Round((RestTime - (GetSystemTime - Time))/1000))+' s');

Disguise(' A: '+IntToStr(PlayersActive) + '/' + IntToStr(HowManyPlayers) +
' Loads: ' + IntToStr(Loads));
ActivateClient;
LoginPlayer;
Inc(Rested);
MarkTime(Worked);
end;
SetupPlayer;
end;
end;

procedure LoadDTMS;
begin

ClayDTM := DTMFromString('78DA6374626260E066644006D31BC218FE036' +
'990E87F206004A96146550391859140DA03A8868D801A2FA01A4E' +
'026A40760910506389E9660C353640351CF8D50000D181089F');

SoftDTM := DTMFromString('78DA63B4676260E060644006B9417C0CFF813' +
'448F43F10303A01D5FC6740038C4824900E00AA6163C4AFC605A8' +
'4698801A33A01A3E026A2C816A5808A8F106AAE125A0C69AB07B0' +
'05BEC0953');

JugDTM := DTMFromString('78DA637462626078C68002DA6A6B184480342' +
'310FF0702465BA09AEB0C6880918115AA06CCF304AAB949408D37' +
'50CD3D026ABC806ADE1150630754F391801A4BA09AA744B8F93DA' +
'61A0674735E1350630154F39C801A1BEC7E4751E38C3D9C51D4F8' +
'03D53C2242CD1322ECFA44408D37613703001F0C187A');

WJugDTM := DTMFromString('78DA63CC656260B8CB80024ACBCF31F003694' +
'620FE0F048CE94035D719D00023032B540D985784690E869A72A0' +
'9AD704D46403D57C22A02609A8E60501352037DFC7AF060021030' +
'F2C');


end;

procedure FreeDTMS;
begin
FreeDTM(ClayDTM);
FreeDTM(SoftDTM);
FreeDTM(JugDTM);
FreeDTM(WJugDTM);
end;

//Just a few things it does when the script ends.
procedure ScriptTerminate;
begin
Proggy;
FreeDTMS;
writeln('');
writeln('Thank for using my script, Rasta Magician');
writeln('Script stopped at ' + TheTime + ' ' + TheDate(3));
writeln('Please post the Progress Report');
end;



function AutoColorOven: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
//try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.60, 8.58);

if not (FindColorsTolerance(arP, 661291, MMX1, MMY1, MMX2, MMY2, 6)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
// end except end;
end;

function AutoColorOven2: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
//try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.16);

if not (FindColorsTolerance(arP, 1126745, MMX1, MMY1, MMX2, MMY2, 4)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
// end except end;
end;

function AutoColorPick: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
// try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.38, 1.13);

if not (FindColorsTolerance(arP, 2903683, MMX1, MMY1, MMX2, MMY2, 6)) then
begin
Writeln('Failed to find the color, no result. - pick');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color. - pick');
// end except end;
end;

function AutoColorWaterSymbol: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
// try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.32);

if not (FindColorsTolerance(arP, 15549204, MMX1, MMY1, MMX2, MMY2, 10)) then
begin
Writeln('Failed to find the color, no result. - Water');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color. - water');
// end except end;
end;

procedure DoTheColors;
var x, y: integer;
begin
{
PickColor := AutoColorPick;
LadderColor := FindLadderColor;
OvenColor := AutoColorOven;

if OvenColor = 0 then
OvenColor := AutoColorOven2;

if LadderColor = 0 then
LadderColor := AutoColorWaterSymbol;
}
end;


Function Relocate(place: string): boolean;
var
ATPA: T2DPointArray;
TPA : TPointArray;
TP: TPoint;
Color: boolean;
Str: string;
begin
if GetMMLevels('run', str) >= 25 then
SetRun(true);

Color := True;
{$IFDEF Reflection}
RMDebug('[REF] Relocating.. '+place);
Color := False;
RMDebug('before case');
case lowercase(place) of
'mine': if not WalkToTile(Point(2939, 3282), 1, 2) then Color := true;
'water': if not WalkToTile(Point(2933, 3280), 1, 2) then Color := true;
'wheel': if not WalkToTile(Point(2936, 3288), 1, 2) then Color := true;
'oven': if not WalkToTile(Point(2930, 3290), 1, 2) then Color := true;
end;
RMDebug('aafter case');
if Color then
RMDebug('reflection failed, trying color')
else begin
RMDebug('At '+place);
Result := true;
wait(750+random(500));
exit;
end;
{$ENDIF}

Result := true;
RMDebug('Relocating.. '+place);
case lowercase(place) of
'mine':
begin
if PickColor = 0 then
begin
PickColor := AutoColorPick;
if PickColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, PickColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 1);
SortATPAFrom(ATPA, IntToPoint(MMX2, MMY2));
SortTPAFrom(ATPA[0], IntToPoint(MMX2, MMY2));
TP := ATPA[0][0];
Mouse(TP.x, TP.y + 8, 3, 3, true);
end else Result := false;
end;

'water':
begin
if LadderColor = 0 then
begin
LadderColor := FindLadderColor;
if LadderColor = 0 then
LadderColor := AutoColorWaterSymbol;
if LadderColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, LadderColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 2);
SortATPASize(ATPA, true);
TP := MiddleTPA(ATPA[0]);
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;

'wheel':
begin
if OvenColor = 0 then
begin
OvenColor := AutoColorOven;
if OvenColor = 0 then
OvenColor := AutoColorOven2;
if OvenColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, OvenColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 2);
SortATPAFrom(ATPA, IntToPoint(MMX2, MMY1));
SortTPAFrom(ATPA[0], IntToPoint(MMX2, MMY1));
TP := ATPA[0][0];
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;

'oven':
begin
if OvenColor = 0 then
begin
OvenColor := AutoColorOven;
if OvenColor = 0 then
OvenColor := AutoColorOven2;
if OvenColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, OvenColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
SortTPAFrom(TPA, IntToPoint(MMX1, MMCY));
TP := TPA[0];
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;
end;

if not Result then
begin
RMDebug('failed at relocating to ' + place);
exit;
end;

FFlag(0);
wait(1000+Random(750));

// RMDebug('Arrived at destination. We hope to see you again soon, with RM Airways');
end;

function FindIt(var fx, fy: Integer; CTS, Color, Tol, H, W:integer; SCS2M1, SCS2M2:extended; text:TStringArray): Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(SCS2M1, SCS2M2);

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

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arP, H, W);
arL := High(ararP);

for i := 0 to arL do
begin
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 0, 0);
Wait(350);
if IsUpTextMultiCustom(text) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;



Function Find(s: string): boolean;
var x, y:integer;
begin
case lowercase(s) of
'clay': Result := FindIt(x, y, 2, 7250880, 9, 10, 10, 0.03, 1.24, ['ine', 'ock']);
'water': Result := FindIt(x, y, 1, 11172192, 10, 5, 5, 0.2, 0.2, ['ink']);
'wheel': Result := FindIt(x, y, 2, 8290185, 2, 20, 20, 0.08, 0.25, ['otter''s', 'heel']);
'oven': Result := FindIt(x, y, 4, 660057, 4, 5, 5, 0.06, 0.40, ['ven']);
end;

if Result then
Mouse(x, y, 0, 0, true);
RMDebug('Looking for '+s+'... Found? '+BoolToStr(Result));
end;

Procedure MineIt;
var x, y, t, tries:integer;
begin
if not LoggedIn then exit;
if InvFull then exit;
if not Relocate('mine') then exit;

MarkTime(t);
repeat
if not LoggedIn then break;

{
if FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
DropItem(CoordsToItem(x, y));
wait(200+Random(100));
Inc(ReportVars[2]);
end;
}

if InvFull then break;
if Find('clay') then
begin
Tries := 0;

x := GetSystemTime;
repeat
wait(100);
FindNormalRandoms;
if GetSystemTime - x >= 5000 then break;
until(FindBlackChatMessage('swing your'))

if GetSystemTime - x >= 5000 then Continue;

x := GetSystemTime;
repeat
wait(100);
FindNormalRandoms;
if GetSystemTime - x >= 5000 then break;
until(FindBlackChatMessage('manage to mine'))

end else Inc(Tries);

if Tries >= 5 then
if not Relocate('mine') then
break;

until(InvFull)or(TimeFromMark(t) >= (60*5000))

ClayCount := CountItems(ClayDTM, 'dtm', []);
ClayMined := ClayMined + ClayCount;
ReportVars[1] := ClayCount;
IncEx(Players[CurrentPlayer].Integers[0], ClayCount);
end;

Procedure SoftenClay;
var x, y, WaterCount, ClayCount, i, Time:integer;
begin
if not LoggedIn then exit;
if not InvFull then exit;

Gametab(4);

ClayCount := CountItems(ClayDTM, 'dtm', []);
if ClayCount <= 0 then exit;

JugCount := CountItems(JugDTM, 'dtm', []);
RMDebug('2 - Player has '+IntToStr(JugCount)+' jugs');

if JugCount <= 0 then
begin
RMDebug('Player has no jugs!');
Players[CurrentPlayer].active := false;
LogOut;
exit;
end;

Time := GetSystemTime;
if not Relocate('water') then exit;
repeat
if not LoggedIn then break;

if not FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then break;

if FindDTM(JugDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);
wait(350+Random(500));
if Find('water')then
begin
FFlag(0);
Wait(355*JugCount+500+Random(500));
WaterCount := CountItems(WJugDTM, 'dtm', []);
RMDebug(IntToStr(WaterCount)+' jugs are filled with water');

if not WaterCount = JugCount then
begin
for i:= 0 to 5 do
begin
wait(500);
WaterCount := CountItems(WJugDTM, 'dtm', []);
if WaterCount = JugCount then break;
end;
if not WaterCount = JugCount then
begin
RMDebug('something wrong with filling the jugs...');
Continue;
end;
end;

ClayCount := CountItems(ClayDTM, 'dtm', []);
RMDebug('Player has '+IntToStr(ClayCount)+' clay');

Mouse(x, y, 3, 3, true); //clicking jug again

if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);

wait(200+random(100));
MMouse(247, 406, 18, 15);
for i:= 0 to 9 do
begin
wait(100);
if GetColor(254, 412) = 938605 then break;
end;

GetMousePos(x,y);
Mouse(x, y, 0, 0, false);
wait(250);
if not ChooseOption('All') then
begin
RMDebug('problem choosing option');
Continue;
end;

wait(1000+ 750*WaterCount + Random(500));

if not CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
if not CountItems(ClayDTM, 'dtm', []) = 0 then
begin
for i:= 0 to 5 do
begin
wait(500);

if CountItems(ClayDTM, 'dtm', []) = 0 then
exit;
if CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
break;


end;
end else break;

if not CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
if not CountItems(ClayDTM, 'dtm', []) = 0 then
begin
RMDebug('Problem softening the clay....');
Continue;
end;
end;

end else begin
RMDebug('Couldn''t find the water');
if not Relocate('water') then break;
Continue;
end;
end else begin
RMDebug('found no jug');
LogOut;
Players[CurrentPlayer].Active := false;
exit;
end;

until(GetSystemTime - Time >= 60*5000)
end;

Procedure MoldClay;
var
x, y, i, SoftCount, Time:integer;
TPA: TPointArray;
TP: TPoint;
CFound: boolean;
begin
if not LoggedIn Then exit;
if not InvFull then exit;

if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

SoftCount := CountItems(SoftDTM, 'dtm', []);
if SoftCount <= 0 then exit;

if not Relocate('wheel') then exit;

if IsMember then
TP := IntToPoint(MCX2, MCY2)
else
TP := IntToPoint(314, 448);

repeat
if not LoggedIn then break;

CFound := false;
Gametab(4);
if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);

if Find('wheel') then
begin
FFlag(0);
for i:= 0 to 9 do
begin
wait(200);
if FindColor(x, y, 128, 229, 350, 239, 360) then //won't break as often as getcolor
begin
CFound := true;
break;
end;
end;

if not CFound then continue;

if FindColorsTolerance(TPA, 0, 61, 439, 467, 457, 0) then
begin
SortTPAFrom(TPA, TP);
Mouse(TPA[0].x, TPA[0].y - 50, 3, 3, false);
wait(750);
if not ChooseOption('ake X') then
begin
RMDebug('Problems choosing X');
Continue;
end else begin
wait(350+Random(250));
TypeSend(IntToStr(RandomRange(28, 99)));

i := GetSystemTime;
repeat
wait(250);
Antiban(RandomRange(2,4));
if not FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
break;
until((GetSystemTime - i) >= 750*SoftCount)

i := GetSystemTime;
repeat
wait(100);
Antiban(RandomRange(2,5));
if not FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
break;
until((GetSystemTime - i) >= 30000)

if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
RMDebug('Something went wrong with moudling');
Continue;
end;
end;
end;
end;
end else begin
RMDebug('could not find soft clay');
break;
end;

SoftCount := CountItems(SoftDTM, 'dtm', []);
if SoftCount <= 0 then break;

if not Relocate('wheel') then break;
until (false);
end;

Procedure FireClay;
var
i, x, y, Time, TimeIt: integer;
TPA, CTPA: TPointArray;
TIA: TIntegerArray;
TB: TBox;
TP: TPoint;
CFound: boolean;
begin
if not LoggedIn Then exit;
if not InvFull then exit;


if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

if not Relocate('oven') then exit;

if IsMember then
TP := IntToPoint(MCX2, MCY2)
else
TP := IntToPoint(314, 448);

Gametab(4);
Time := GetSystemTime;
repeat
if not LoggedIn then break;
CFound := false;

for i:= 28 Downto 1 do
begin
TB := InvBox(i);
if not FindDTM(JugDTM, x, y, TB.x1, TB.y1, TB.x2, TB.y2) then
begin
SetLength(CTPA, 6);
CTPA[0] := Point(TB.x1 + 20, TB.y1 + 5);
CTPA[1] := Point(TB.x1 + 20, TB.y1 + 10);
CTPA[2] := Point(TB.x1 + 20, TB.y1 + 15);
CTPA[3] := Point(TB.x1 + 20, TB.y1 + 20);
CTPA[4] := Point(TB.x1 + 20, TB.y1 + 25);
CTPA[5] := Point(TB.x1 + 20, TB.y1 + 30);
TIA := GetColors(CTPA);
end;
end;

if Find('oven') then
begin
FFlag(0);

for i:= 0 to 9 do
begin
wait(200);
if FindColor(x, y, 128, 229, 350, 239, 360) then //won't break as often as getcolor
begin
CFound := true;
break;
end;
end;

if not CFound then continue;

if FindColorsTolerance(TPA, 0, 61, 438, 467, 457, 0) then
begin
SortTPAFrom(TPA, TP);
Mouse(TPA[0].x, TPA[0].y - 50, 3, 3, false);
wait(100);
if not ChooseOption('ake X') then
begin
RMDebug('Problems choosing X');
Continue;
end else begin
wait(350+Random(250));
TypeSend(IntToStr(RandomRange(28, 99)));

wait(1000);
TimeIt := GetSystemTime;
repeat
wait(250);

if FindNPCChatText('t have any', Nothing) then
break;

if IsChatBoxTextAnyLine('have any more', 0) then
break;


if random(100) <= 5 then CompassMove(1000);
NoRandoms;
until(GetSystemTime - TimeIt >= (4000*26))

if not IsChatBoxTextAnyLine('have any more', 0) then
if not FindNPCChatText('t have any', Nothing) then
Continue;

RMDebug('done waiting for fired stuff');
for x := 0 to 9 do
begin
if not IsSameIntArray(TIA, GetColors(CTPA)) then
break;
wait(750);
end;

RMDebug('all is done, dropping now');
for i:= 1 to 28 do
begin
if i mod 3 = 0 then
NoRandoms;
TB := InvBox(i);
if not FindDTM(JugDTM, x, y, TB.x1, TB.y1, TB.x2, TB.y2) then
begin
DropItem(i);
wait(200+Random(150));
end;
end;
Inc(Loads);
Inc(Players[CurrentPlayer].Banked);
Inc(ReportVars[0]);
RMDebug('done dropping');
break;
end;
end else begin
RMDebug('Could not find the text color....');
Continue;
end;
end else begin
RMDebug('Problems Finding the Oven');
if not Relocate('oven') then break;
Continue;
end;

if GetSystemTime - Time >= 60000 then
break;
until(false)

end;

begin
SetupScript;
SetupPlayer;
DoTheColors;
LoadDTMS;

repeat
if not LoggedIn then break;
MineIt;
SoftenClay;
MoldClay;
FireClay;
Proggy;
SwitchPlayers;
until(false)


end.{==============================================================================]
[==============================================================================]
[ RM Power Crafter ]
[ By: Rasta Magician ]
[==============================================================================]
[ Features ]
[==============================================================================]
[ 1. Debug ]
[ 2. AntiRandoms ]
[ 3. AntiBan ]
[ 4. Multiplayer ]
[ 5. Resting ]
[ 6. Progress Report ]
[ 7. Local Control ]
[ 8. Responder ]
[ 9. Proggy To File ]
[ 10. Smart Cycleing ]
[==============================================================================]
[ Description ]
[==============================================================================]
[ Mines clay, softens it, molds it into bowls(f2p), ]
[ plant pots or pot lids (with needed quest), then fires the clay, drops it ]
[ and repeats the whole thing. All of this happens inside the Crafting Guild ]
[ ]
[==============================================================================]
[ How To Use ]
[==============================================================================]
[ 0. You need level 40 crafting ]
[ 1. Wield a pick ]
[ 2. Wear a brown appron ]
[ 3. Have jugs in inventory (I suggest 4 jugs) ]
[ ]
[==============================================================================]
[ Credits ]
[==============================================================================]
[ SRL Team ]
[ Ed, thx for testing ]
[==============================================================================]
[ RM Power Crafter by Rasta Magician ]
[==============================================================================]
[==============================================================================}

{
add one more text for moulding clay
mold and fire menu colors changed place
}


program RMScript;
{$DEFINE SMART }
{$DEFINE Reflection}
//{$DEFINE FORM }

{$IFDEF SMART }
{.include srl/srl/misc/Smart.scar}
{$ENDIF}
{.include srl/srl.scar}
{$IFDEF Reflection}
{.include SRL\SRL\Reflection\Reflection.scar}
{$ENDIF}
{.include srl/srl/skill/mining.scar}

{$IFDEF FORM }
{.include srl/srl/misc/users.scar}
{$ENDIF}

Const
WorkTime = (30*60*1000); //10 mins
RestTime = (3*60*1000); //3 mins

IsMember = true;

UseDebug = True;
UseResponder = True;
SaveProggyToFile = True;

ScriptName = 'RM Power Crafter';
Version = '2.0';

YourSRLID = ''; //your SRLID
YourSRLPass = ''; //your SRL Stats pass
MyScriptID = '1199'; // don't touch

var
Rested, Worked, Loads,
PickColor, LadderColor, OvenColor,
ClayDTM, SoftDTM, JugDTM, WJugDTM, GemDTM,
JugCount, ClayCount,
ClayMined :integer;
ProggyStr: string;


function IsSameIntArray(i1, i2:TIntegerArray):boolean;
var i:integer;
begin
Result := false;
if Length(i1) <> Length(i2) then exit;

Result := true;
for i:= 0 to high(i1) do
if i1[i] <> i2[i] then
Result := False;
end;

//for debugging TPAs, to help me perfect my finders
//by Wizzup?
Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I, L: Integer;
xs, ys, xe, ye: Integer;

Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(Points) Do
Begin
xs := Min(xs, Points[i].X);
ys := Min(ys, Points[i].Y);

xe := Max(xe, Points[i].X);
ye := Max(ye, Points[i].Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To High(Points) Do
FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, 255);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;

//Declaring players
Procedure DeclarePlayers;
begin

{$IFDEF Form}
SRLPlayerForm(True, [], [], [], []);
exit
{$ENDIF}

NumberOfPlayers(1);
CurrentPlayer := 0;

Players[0].Name :='RMagician';
Players[0].Pass :='Th1sIsN0tMyPW!';
Players[0].Nick :='agi';
Players[0].Active := True;


end;

//Used for debugging and finding errors
Procedure RMDebug(s:string);
var name:string;
begin
if not UseDebug then exit;
try name := Players[CurrentPlayer].Name +' : '; except name:= '' end;
writeln(name+TheTime+' - '+s);
end;


//local control, F12 to activate and then text. used to check on proggies and
//to reactivate players
//untested with smart, might not work
{$IFDEF SMART}
procedure Proggy; forward;
Procedure EasyRC;
var i:integer;
begin
if not IsFKeyDown(12) then exit;
LogOut;

Proggy;
writeln('Fresh proggie on your right');
writeln('');

writeln('--- MENU ---');
writeln('F9 --> Status');
writeln('F10 --> Reset All');
writeln('F11 --> manage players');
writeln('F1 --> Keep on autoing');
writeln('--- End Menu --- ');
writeln('');
wait(2000);
repeat
if IsFKeyDown(9) then //status
begin
for i:=0 to High(players) do
writeln(IntToStr(i)+': '+Players[i].Nick+' - '+BoolToStr(Players[i].Active));
end;

if IsFKeyDown(10) then //Reset All
begin
for i:= 0 to High(Players) do
Players[i].Active := true;
writeln('Reset all :) ');
end;

if IsFKeyDown(11) then // Manage Players
begin

end;

if IsFKeyDown(1) then break;
until(false)
writeln('Restarting to auto :)');
LoginPlayer;
end;

{$ELSE}

//local control, F12 to activate and then text. used to check on proggies and
//to reactivate players
//untested with smart, might not work
Procedure EasyRC;
var
i, h1, h2, x, y:integer;
s, str: string;
begin
if not LoggedIn then exit;
if IsFKeyDown(12) then
begin
RMDebug('Trying to use Easy RC');
h1 := GetClientWindowHandle;
GetMousePos(x, y);
SetClientPos(False);
Disguise('RM Easy RC');
if FindWindowTitlePart('RM Easy RC', false) then writeln('Using Easy RC');
h2 := GetClientWindowHandle;
SetOnTop(h1, False);
SetOnTop(h2, True);
SetClientWindowHandle(h2);
wait(100);
ActivateClient;
wait(100);

repeat
s:= ReadLn('What to do?'+chr(13)+'Status / Reset N / Reset All / Proggy / Exit');
lowercase(s);
if (s = 'exit') or (s = '') then break;

if s= 'status' then
begin
for i:= 0 to High(Players) do
if not Players[i].Active then str:= str+chr(13)+Players[i].Name;
readln('these are set to false: '+chr(13)+str+chr(13)+'Press ok');
end;


if s = 'proggy' then
begin
Readln(ProggyStr+chr(13)+'Press ok');
end;

if Pos('reset', s) > 0 then
begin
str := TrimLetters(Trim(s));
if str = '' then
begin
for i:= 0 to High(Players) do
Players[i].Active:= True;
ReadLn('All Players Active'+chr(13)+'Press ok');
end else
try begin
i:= StrToInt(str);
Players[i].Active := True;
Readln('activated player: '+str+chr(13)+'Press ok');
end except break end;
end;
until(false)

SetOnTop(h2, False);
SetOnTop(h1, True);
SetClientWindowHandle(h1);
ActivateClient;
MMouse(x, y, 2, 2);
wait(3000);
Disguise(' A: '+IntToStr(PlayersActive)+'/'+IntToStr(Length(Players))+' Loads: '+IntToStr(loads));
RMDebug('Done using Easy RC');
end;
end;
{$ENDIF}


type
MyChat = record
Chatter: TStringArray;
Said: TStringArray;
LastResponded: integer;
end;
var
Trigger: Array of Array[0..1] of TStringArray; //questions, could make more triggers... if i
Answers: Array of TStringArray; //find i need them
RMTalks: MyChat;
Responses: Integer;



// to setup the questions qnd qnswers for the auto responder
procedure SetupRespond;
begin

SetLength(RMTalks.Chatter, 8);
SetLength(RMTalks.Said, 8);

SetLength(Trigger, 7); //how many questions
SetLength(Answers, Length(Trigger));
//you can have as many trigger words and rows as you want
//you can have as many answers as you want

Trigger[0][0]:= ['wc', 'woodcutting']; // trigger words 1
Trigger[0][1]:= ['lvl', 'level']; // trigger words 2
//Trigger[0][2]:= ['','','','','','']; // trigger words 3
Answers[0]:= [
'My Woodcutting Level is: '+IntToStr(Players[CurrentPlayer].Level[20]), //answer 1
'Wc: '+IntToStr(Players[CurrentPlayer].Level[20]), //answer 2
IntToStr(Players[CurrentPlayer].Level[20])+' wc lvl', //answer 3
'my wcing lvl is '+IntToStr(Players[CurrentPlayer].Level[20]) //answer 4
]

Trigger[1][0] := ['axe'];
Trigger[1][1] := ['which', 'what'];
Answers[1] := [
'I''m using a '+Players[CurrentPlayer].Strings[2]+' axe',
Players[CurrentPlayer].Strings[2],
'my axe is made out of '+Players[CurrentPlayer].Strings[2]
]

Trigger[2][0]:= ['good place', 'train'];
Trigger[2][1]:= ['woodcutting', 'wc'];
Answers[2] := [
'Try Training Woodcutting at Draynor',
'Draynor', 'Varrock', 'Edgy', 'Fally',
'Try Training Woodcutting at Edgeville',
'Try Training Woodcutting at Varrock Palace',
'Try Training Woodcutting at South of Falador'
]


Trigger[3][0]:= ['fish', 'fishing', '><>', '<><']; // trigger words 1
Trigger[3][1]:= ['lvl', 'level', 'levl', 'lvel']; // trigger words 2
//Trigger[3][2]:= ['','','','','','']; // trigger words 3
Answers[3]:= [
'My Fishing Level is: '+IntToStr(Players[CurrentPlayer].Level[17]), //answer 1
'Fishing: '+IntToStr(Players[CurrentPlayer].Level[17]), //answer 2
IntToStr(Players[CurrentPlayer].Level[17])+' '+chr(62)+chr(60)+chr(62)+' lvl', //answer 3
'my fishy lvl is '+IntToStr(Players[CurrentPlayer].Level[17]) //answer 4
]


Trigger[5][0]:= ['place', 'train'];
Trigger[5][1]:= ['fishing', '><>', 'fish'];
Answers[5] := [
'Try Training fishing at Draynor',
'Draynor', 'Edgy', 'Al-Kharid', 'Karamja',
'Try Training fishing at Edgeville',
'Try Training fishing at Al-Kharid, close to bank',
'Try Training fishing at lumbridge'
]

Trigger[6][0]:= ['hi','hey', 'hello', 'sup?']; // trigger words 1
Trigger[6][1]:= ['']; // trigger words 2
Answers[6]:= ['hi','hey', 'hello', 'sup?', 'how do you do?'] ;
end;

//from srl, modded for any line
function GetChatTextLine(var chat: string; line:integer): Boolean;
var
x, y: Integer;
textP: TPoint;
begin
if not LoggedIn then exit;
textP := TextCoords(line);
if findcolor(x, y, 16711680, textp.x, textp.y, textp.x + 200, textp.y + 14) then
begin
chat := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False,

False, -1, 1, 16711680, 60, False, tr_allChars)));
Result := True;
end;
end;

//from srl, modded for any line
function GetChatterLine(var name: string; line:integer): Boolean;
var
i: Integer;
textP: TPoint;
begin
if not LoggedIn then exit;
textP := TextCoords(line);
name := LowerCase(Trim(GetTextAtEx(textP.x - 2, textP.y - 2, 0, SmallChars, False, False, 0, 1,
0, 60, False, tr_allChars)))
i := Pos(':', name)
if (i <> 0) then
begin
Delete(name, i, i);
Result := True;
end;
end;

//my responder, used as antiban to look more human
procedure RMRespond;
var
str: string;
i, h, t, k, triggered:integer;
TSA:TStringArray;
begin
if not LoggedIn then exit;
if (TimeFromMark(RMTalks.LastResponded) < 60000+Random(30000)) then exit;


SetLength(TSA, 8)
str:='';
TSA:=['', '', '', '', '', '', '', ''];
RMTalks.said := ['', '', '', '', '', '', '', ''];
triggered := 0;

// Getting text on all the lines
for i:= 7 DownTo 0 do
begin
GetChatterLine(RMTalks.Chatter[i], i+1);
if Pos(Lowercase(Players[CurrentPlayer].Nick), Lowercase(RMTalks.Chatter[i])) > 0 then
break; //if we already answered, it means we already checked further up.
GetChatTextLine(RMTalks.said[i], i+1);
TSA[i] := RMTalks.said[i];
end;

for i:=High(TSA) DownTo 0 do //all text lines
for h:= 0 to High(Trigger) do //questions
begin
triggered:= 0;
for t:=0 to High(Trigger[h]) do //How many triggers

for k:=0 to High(Trigger[h][t]) do //specific trigger

if Pos(Trigger[h][t][k], TSA[i]) > 0 then
begin
Inc(triggered);
if triggered >= 2 then
begin

Inc(Responses);
str:=(Answers[h][Random(Length(Answers[h]))]);

TypeSend(AddMistakes(str, RandomRange(10, 30)));

RMDebug('Question: '+Trigger[h][0][0]+ ' ' + Trigger[h][t][k]);
RMDebug('Responding: ' + str);

str := '';
MarkTime(RMTalks.LastResponded);
triggered := 0;
SetupRespond;

exit;
end; //end if
break;
end; //end if
//end k loop
end; //end h loop
//end of i loop
end;

//making sure we solve those annoying randoms :)
Function NoRandoms: boolean;
var
x, y:integer;
s:string;
begin
if not LoggedIn then exit;
Result := False;
GetMousePos(x, y);
if UseResponder then RMRespond;
if ClickToContinue then
begin
MMouse(x, y, 3, 3);
Result := True;
end;
if FindNormalRandoms then Result:=true;
if FindFight then
begin
//none of the run aways check for randoms....

case random(4) of
0: s:='n';
1: s:='w';
2: s:='s';
3: s:='e';
end;

RMDebug('running to ' + s + ' and waiting for 8 - 10 s');
RunTo(s, True);
SleepAndMoveMouse(RandomRange(8000, 10000));

case s of
'n': s:= 'S';
's': s:= 'N';
'w': s:= 'E';
'e': s:= 'W';
end;

RMDebug('Returning to ' + s);
RunTo(s, True);

Result:=True;

NoRandoms;
end;

EasyRc;

end;



//Progress report
procedure Proggy;
var
JX2, i, i2, xph:integer;
str: string;
begin
ClearReport;
SRLRandomsReport;

AddToReport('');
AddToReport('[====== '+Padr(ScriptName+' '+Version, 27)+' ======]');
AddToReport('[ By Rasta Magician ]');
AddToReport('[=========================================]');
AddToReport('[ ' + Padr('Written ' + (TheTime) + ' on ' + (TheDate(3)) + '.', 40) + ']')
AddToReport('[ '+ Padr(TimeRunning, 40)+']');
AddToReport('[ ' + Padr('Players: ' + IntToStr(PlayersActive)+ ' / ' + IntToStr(HowManyPlayers), 40) + ']');
AddToReport('[ ' + Padr('Current Player: ' + Players[CurrentPlayer].Nick, 40) + ']');
AddToReport('[ '+ Padr('Loads: '+IntToStr(Loads), 40)+']');
AddToReport('[ '+ Padr('Clay Mined: '+IntToStr(ClayMined), 40)+']');
AddToReport('[ '+ Padr('Mining XP: '+IntToStr(ClayMined*5), 40)+']');
AddToReport('[ '+ Padr('=== CRAFTING XP ===', 40)+']');
xph := Round((ClayMined*40*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Lids: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*37.5*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Plant Pots: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*33*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Bowls: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*25*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Dishes: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*12.6*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Pots: '+IntToStr(xph)+' xp/h', 40)+']');
AddToReport('[ '+ Padr('=== CRAFTING XP ===', 40)+']')
AddToReport('[ '+Padr('Rested: '+IntToStr(Rested), 40)+']');
AddToReport('[================== RM ===================]');

ProggyStr := '';
ProggyStr := ProggyStr + chr(13) + ('[====== '+Padr(ScriptName+' '+Version, 27)+' ======]');
ProggyStr := ProggyStr + chr(13) + ('[ By Rasta Magician ]');
ProggyStr := ProggyStr + chr(13) + ('[=========================================]');
ProggyStr := ProggyStr + chr(13) + ('[ ' + Padr('Written ' + (TheTime) + ' on ' + (TheDate(3)) + '.', 40) + ']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr(TimeRunning, 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ ' + Padr('Players: ' + IntToStr(PlayersActive)+ ' / ' + IntToStr(HowManyPlayers), 40) + ']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr('Loads: '+IntToStr(Loads), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr('Clay Mined: '+IntToStr(ClayMined), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ '+Padr('Rested: '+IntToStr(Rested), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[================== RM ===================]');


AddToReport('[ P | A | L | Mins | Rand ' + Padl(']', 13));
AddToReport('[-----------------------------------------]');

ProggyStr := ProggyStr + chr(13) + ('[ P | A | L | Mins | Rand ' + Padl(']', 13));
ProggyStr := ProggyStr + chr(13) + ('[-----------------------------------------]');

for i:= 0 to HowManyPlayers - 1 do
begin
str := '[ ' + Padr(Players[i].Nick, 4) + ' | ';
if Players[i].Active then
str := str + 'T | '
else
str := str + 'F | ';

str := str + Padr(IntToStr(Players[i].Banked), 2) + ' | ' + Padr(IntToStr(Players[i].Worked), 5) +'| ';
str := str + Padr(Players[i].Rand, 16) + ' ]';
AddToReport(str);
ProggyStr := ProggyStr + chr(13) + str;
end;

str := ScriptName+' '+Version
i := length(str);
if (i mod 2) <> 0 then
i2 := 1;

AddToReport('[-----------------------------------------]');
AddToReport('[====== '+Padl('', 14 - Trunc(i/2)) + str + Padr('', 13 + i2 - Trunc(i/2))+' ======]');
AddToReport('[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]');

ProggyStr := ProggyStr + chr(13) + ('[-----------------------------------------]');
ProggyStr := ProggyStr + chr(13) + ('[====== '+Padl('', 14 - Trunc(i/2)) + str + Padr('', 13 + i2 - Trunc(i/2))+' ======]');
ProggyStr := ProggyStr + chr(13) + ('[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]');

if SaveProggyToFile then
begin
JX2 := ReWriteFile((ScriptPath + ScriptName +' '+ Version + '.txt'), False);
WriteFileString(JX2, ProggyStr);
CloseFile(JX2);
RMDebug('Progress report saved to: ' + ScriptPath + ScriptName + ' ' + Version + '.txt');
end;
Disguise(' A: '+IntToStr(PlayersActive) + '/' + IntToStr(HowManyPlayers) +
' Loads: ' + IntToStr(Loads));
end;

//Antiban, basically just picks up the mouse, increases mouse speed
//clicks a tab and resets everything back to the original.
//just to make sure we stay logged in.
procedure FastSwitchTabs;
var x, y, i, h:integer;
begin
if not LoggedIn then exit;
RMDebug('Inactive Move');
GetMousePos(x, y);
PickUpMouse;
IncEx(MouseSpeed, 10);
i := GetCurrentTab;
repeat
h := 1+Random(12);
until(h <> i)
GameTab(h);
wait(500+Random(500));
GameTab(i);
MMouse(x, y, 3, 3);
DecEx(MouseSpeed, 10);
end;

//will take "Time" + Random(1000) to complete the action, will return to original angle
// By Rasta Magician, heavily based on RandomMovement by Krazy_Meerkat
// will always move the compass around unlike in RandomMovement
procedure CompassMove(Time:Integer);
var
Keys: array of Integer;
I: Integer;
Deg: Extended;
begin
if not LoggedIn then exit;
Keys := [VK_RIGHT, VK_LEFT];
I := Random(2);
ActivateClient;
Deg := rs_GetCompassAngleDegrees;
Wait(100 + random(50));
KeyDown(Keys[I]);
Wait(Round(Time/2) + random(500));
KeyUp(Keys[I]);
Wait(Round(Time/2) + random(500));
MakeCompass(FloatToStr(Deg));
end;

//Random Right Click Return by Rasta Magician,
//Will right-click anywhere on he main map, choose "Cancel" and return the
//mouse to it's original position
procedure RRClickReturn;
var x, y:integer;
begin
if not LoggedIn then exit;
IncEx(MouseSpeed, 7);
GetMousePos(x, y);
ActivateClient;
Mouse(MSX1, MSY1, MSX2, MSY2, False);
wait(100 + Random(50));
ChooseOption('ancel');
wait(50 + Random(100));
MMouse(x, y, 3, 3);
DecEx(MouseSpeed, 7);
end;

//just antiban with a percentage
Procedure AntiBan(percentage: integer);
var p: integer;
begin
if not Loggedin then exit;
if random(100) <= percentage then
begin
case random(14) of
0, 1: FastSwitchTabs;
2, 3: CompassMove(1000);
4, 5: RRClickReturn;
6, 7: SleepAndMoveMouse(2000);
8, 9: HoverSkill('random', false);
//10, 11: DoEmote(Random(37)+1);
12, 13: PickUpMouse;
end;
Gametab(4);
end;
end;

{$IFDEF SMART}
Procedure SetupSmart(world: integer);
begin

SmartSetupEx(world, False, True, False);
Wait(5000);
SetTargetDC(SmartGetDC);
repeat
wait(100);
until(SmartGetColor(253, 233)<>1118604);

end;
{$ENDIF}

//Used to set up all the necessary things before the script starts running
Procedure SetupScript;
begin
ClearDebug;
Disguise(ScriptName + ' ' + Version);
{$IFDEF SMART}
SetupSmart(100);
{$IFDEF Reflection}
RMDebug('Checking hooks, if they''re outdated un-define reflection to run this');
SetupReflection;
{$ENDIF}
{$ENDIF}
SetupSRL;
DeclarePlayers;
if UseResponder then SetupRespond;

SRLID := YourSRLID;
SRLPassword := YourSRLPass;
ScriptID := MyScriptID;
ActivateClient;
LoginPlayer;
end;


//for prepqring the playe and making sure he has all the requirements
procedure SetupPlayer;
begin
if not LoggedIn then exit;
SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
CloseWindow;
MarkTime(Worked);
GameTab(4);
wait(500);
JugCount := CountItems(JugDTM, 'dtm', []);
RMDebug('Player has '+IntToStr(JugCount)+' jugs');
SetAngle(true);
end;

//switching palyers, or in case of jsut one player making it rest
// "not playing" for a while decreases the chance of getting a lot of randoms
procedure SwitchPlayers;
var Time: integer;
begin
if (TimeFromMark(Worked) >= (WorkTime + Random(3*60*1000)) )or(not LoggedIn) then
begin
if PlayersActive > 1 then
NextPlayer(Players[CurrentPlayer].Active)
else begin
if not LoggedIn then TerminateScript;
LogOut;
RMDebug('resting....');
Time := GetSystemTime;
while (GetSystemTime - Time < RestTime) do
Disguise('Rest: '+IntToStr(Round((RestTime - (GetSystemTime - Time))/1000))+' s');

Disguise(' A: '+IntToStr(PlayersActive) + '/' + IntToStr(HowManyPlayers) +
' Loads: ' + IntToStr(Loads));
ActivateClient;
LoginPlayer;
Inc(Rested);
MarkTime(Worked);
end;
SetupPlayer;
end;
end;

procedure LoadDTMS;
begin

ClayDTM := DTMFromString('78DA6374626260E066644006D31BC218FE036' +
'990E87F206004A96146550391859140DA03A8868D801A2FA01A4E' +
'026A40760910506389E9660C353640351CF8D50000D181089F');

SoftDTM := DTMFromString('78DA63B4676260E060644006B9417C0CFF813' +
'448F43F10303A01D5FC6740038C4824900E00AA6163C4AFC605A8' +
'4698801A33A01A3E026A2C816A5808A8F106AAE125A0C69AB07B0' +
'05BEC0953');

JugDTM := DTMFromString('78DA637462626078C68002DA6A6B184480342' +
'310FF0702465BA09AEB0C6880918115AA06CCF304AAB949408D37' +
'50CD3D026ABC806ADE1150630754F391801A4BA09AA744B8F93DA' +
'61A0674735E1350630154F39C801A1BEC7E4751E38C3D9C51D4F8' +
'03D53C2242CD1322ECFA44408D37613703001F0C187A');

WJugDTM := DTMFromString('78DA63CC656260B8CB80024ACBCF31F003694' +
'620FE0F048CE94035D719D00023032B540D985784690E869A72A0' +
'9AD704D46403D57C22A02609A8E60501352037DFC7AF060021030' +
'F2C');


end;

procedure FreeDTMS;
begin
FreeDTM(ClayDTM);
FreeDTM(SoftDTM);
FreeDTM(JugDTM);
FreeDTM(WJugDTM);
end;

//Just a few things it does when the script ends.
procedure ScriptTerminate;
begin
Proggy;
FreeDTMS;
writeln('');
writeln('Thank for using my script, Rasta Magician');
writeln('Script stopped at ' + TheTime + ' ' + TheDate(3));
writeln('Please post the Progress Report');
end;



function AutoColorOven: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
//try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.60, 8.58);

if not (FindColorsTolerance(arP, 661291, MMX1, MMY1, MMX2, MMY2, 6)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
// end except end;
end;

function AutoColorOven2: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
//try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.16);

if not (FindColorsTolerance(arP, 1126745, MMX1, MMY1, MMX2, MMY2, 4)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
// end except end;
end;

function AutoColorPick: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
// try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.38, 1.13);

if not (FindColorsTolerance(arP, 2903683, MMX1, MMY1, MMX2, MMY2, 6)) then
begin
Writeln('Failed to find the color, no result. - pick');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color. - pick');
// end except end;
end;

function AutoColorWaterSymbol: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
// try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.32);

if not (FindColorsTolerance(arP, 15549204, MMX1, MMY1, MMX2, MMY2, 10)) then
begin
Writeln('Failed to find the color, no result. - Water');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color. - water');
// end except end;
end;

procedure DoTheColors;
var x, y: integer;
begin
{
PickColor := AutoColorPick;
LadderColor := FindLadderColor;
OvenColor := AutoColorOven;

if OvenColor = 0 then
OvenColor := AutoColorOven2;

if LadderColor = 0 then
LadderColor := AutoColorWaterSymbol;
}
end;


Function Relocate(place: string): boolean;
var
ATPA: T2DPointArray;
TPA : TPointArray;
TP: TPoint;
Color: boolean;
Str: string;
begin
if GetMMLevels('run', str) >= 25 then
SetRun(true);

Color := True;
{$IFDEF Reflection}
RMDebug('[REF] Relocating.. '+place);
Color := False;
RMDebug('before case');
case lowercase(place) of
'mine': if not WalkToTile(Point(2939, 3282), 1, 2) then Color := true;
'water': if not WalkToTile(Point(2933, 3280), 1, 2) then Color := true;
'wheel': if not WalkToTile(Point(2936, 3288), 1, 2) then Color := true;
'oven': if not WalkToTile(Point(2930, 3290), 1, 2) then Color := true;
end;
RMDebug('aafter case');
if Color then
RMDebug('reflection failed, trying color')
else begin
RMDebug('At '+place);
Result := true;
wait(750+random(500));
exit;
end;
{$ENDIF}

Result := true;
RMDebug('Relocating.. '+place);
case lowercase(place) of
'mine':
begin
if PickColor = 0 then
begin
PickColor := AutoColorPick;
if PickColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, PickColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 1);
SortATPAFrom(ATPA, IntToPoint(MMX2, MMY2));
SortTPAFrom(ATPA[0], IntToPoint(MMX2, MMY2));
TP := ATPA[0][0];
Mouse(TP.x, TP.y + 8, 3, 3, true);
end else Result := false;
end;

'water':
begin
if LadderColor = 0 then
begin
LadderColor := FindLadderColor;
if LadderColor = 0 then
LadderColor := AutoColorWaterSymbol;
if LadderColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, LadderColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 2);
SortATPASize(ATPA, true);
TP := MiddleTPA(ATPA[0]);
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;

'wheel':
begin
if OvenColor = 0 then
begin
OvenColor := AutoColorOven;
if OvenColor = 0 then
OvenColor := AutoColorOven2;
if OvenColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, OvenColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 2);
SortATPAFrom(ATPA, IntToPoint(MMX2, MMY1));
SortTPAFrom(ATPA[0], IntToPoint(MMX2, MMY1));
TP := ATPA[0][0];
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;

'oven':
begin
if OvenColor = 0 then
begin
OvenColor := AutoColorOven;
if OvenColor = 0 then
OvenColor := AutoColorOven2;
if OvenColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, OvenColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
SortTPAFrom(TPA, IntToPoint(MMX1, MMCY));
TP := TPA[0];
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;
end;

if not Result then
begin
RMDebug('failed at relocating to ' + place);
exit;
end;

FFlag(0);
wait(1000+Random(750));

// RMDebug('Arrived at destination. We hope to see you again soon, with RM Airways');
end;

function FindIt(var fx, fy: Integer; CTS, Color, Tol, H, W:integer; SCS2M1, SCS2M2:extended; text:TStringArray): Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(SCS2M1, SCS2M2);

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

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arP, H, W);
arL := High(ararP);

for i := 0 to arL do
begin
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 0, 0);
Wait(350);
if IsUpTextMultiCustom(text) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;



Function Find(s: string): boolean;
var x, y:integer;
begin
case lowercase(s) of
'clay': Result := FindIt(x, y, 2, 7250880, 9, 10, 10, 0.03, 1.24, ['ine', 'ock']);
'water': Result := FindIt(x, y, 1, 11172192, 10, 5, 5, 0.2, 0.2, ['ink']);
'wheel': Result := FindIt(x, y, 2, 8290185, 2, 20, 20, 0.08, 0.25, ['otter''s', 'heel']);
'oven': Result := FindIt(x, y, 4, 660057, 4, 5, 5, 0.06, 0.40, ['ven']);
end;

if Result then
Mouse(x, y, 0, 0, true);
RMDebug('Looking for '+s+'... Found? '+BoolToStr(Result));
end;

Procedure MineIt;
var x, y, t, tries:integer;
begin
if not LoggedIn then exit;
if InvFull then exit;
if not Relocate('mine') then exit;

MarkTime(t);
repeat
if not LoggedIn then break;

{
if FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
DropItem(CoordsToItem(x, y));
wait(200+Random(100));
Inc(ReportVars[2]);
end;
}

if InvFull then break;
if Find('clay') then
begin
Tries := 0;

x := GetSystemTime;
repeat
wait(100);
FindNormalRandoms;
if GetSystemTime - x >= 5000 then break;
until(FindBlackChatMessage('swing your'))

if GetSystemTime - x >= 5000 then Continue;

x := GetSystemTime;
repeat
wait(100);
FindNormalRandoms;
if GetSystemTime - x >= 5000 then break;
until(FindBlackChatMessage('manage to mine'))

end else Inc(Tries);

if Tries >= 5 then
if not Relocate('mine') then
break;

until(InvFull)or(TimeFromMark(t) >= (60*5000))

ClayCount := CountItems(ClayDTM, 'dtm', []);
ClayMined := ClayMined + ClayCount;
ReportVars[1] := ClayCount;
IncEx(Players[CurrentPlayer].Integers[0], ClayCount);
end;

Procedure SoftenClay;
var x, y, WaterCount, ClayCount, i, Time:integer;
begin
if not LoggedIn then exit;
if not InvFull then exit;

Gametab(4);

ClayCount := CountItems(ClayDTM, 'dtm', []);
if ClayCount <= 0 then exit;

JugCount := CountItems(JugDTM, 'dtm', []);
RMDebug('2 - Player has '+IntToStr(JugCount)+' jugs');

if JugCount <= 0 then
begin
RMDebug('Player has no jugs!');
Players[CurrentPlayer].active := false;
LogOut;
exit;
end;

Time := GetSystemTime;
if not Relocate('water') then exit;
repeat
if not LoggedIn then break;

if not FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then break;

if FindDTM(JugDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);
wait(350+Random(500));
if Find('water')then
begin
FFlag(0);
Wait(355*JugCount+500+Random(500));
WaterCount := CountItems(WJugDTM, 'dtm', []);
RMDebug(IntToStr(WaterCount)+' jugs are filled with water');

if not WaterCount = JugCount then
begin
for i:= 0 to 5 do
begin
wait(500);
WaterCount := CountItems(WJugDTM, 'dtm', []);
if WaterCount = JugCount then break;
end;
if not WaterCount = JugCount then
begin
RMDebug('something wrong with filling the jugs...');
Continue;
end;
end;

ClayCount := CountItems(ClayDTM, 'dtm', []);
RMDebug('Player has '+IntToStr(ClayCount)+' clay');

Mouse(x, y, 3, 3, true); //clicking jug again

if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);

wait(200+random(100));
MMouse(247, 406, 18, 15);
for i:= 0 to 9 do
begin
wait(100);
if GetColor(254, 412) = 938605 then break;
end;

GetMousePos(x,y);
Mouse(x, y, 0, 0, false);
wait(250);
if not ChooseOption('All') then
begin
RMDebug('problem choosing option');
Continue;
end;

wait(1000+ 750*WaterCount + Random(500));

if not CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
if not CountItems(ClayDTM, 'dtm', []) = 0 then
begin
for i:= 0 to 5 do
begin
wait(500);

if CountItems(ClayDTM, 'dtm', []) = 0 then
exit;
if CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
break;


end;
end else break;

if not CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
if not CountItems(ClayDTM, 'dtm', []) = 0 then
begin
RMDebug('Problem softening the clay....');
Continue;
end;
end;

end else begin
RMDebug('Couldn''t find the water');
if not Relocate('water') then break;
Continue;
end;
end else begin
RMDebug('found no jug');
LogOut;
Players[CurrentPlayer].Active := false;
exit;
end;

until(GetSystemTime - Time >= 60*5000)
end;

Procedure MoldClay;
var
x, y, i, SoftCount, Time:integer;
TPA: TPointArray;
TP: TPoint;
CFound: boolean;
begin
if not LoggedIn Then exit;
if not InvFull then exit;

if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

SoftCount := CountItems(SoftDTM, 'dtm', []);
if SoftCount <= 0 then exit;

if not Relocate('wheel') then exit;

if IsMember then
TP := IntToPoint(MCX2, MCY2)
else
TP := IntToPoint(314, 448);

repeat
if not LoggedIn then break;

CFound := false;
Gametab(4);
if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);

if Find('wheel') then
begin
FFlag(0);
for i:= 0 to 9 do
begin
wait(200);
if FindColor(x, y, 128, 229, 350, 239, 360) then //won't break as often as getcolor
begin
CFound := true;
break;
end;
end;

if not CFound then continue;

if FindColorsTolerance(TPA, 0, 61, 439, 467, 457, 0) then
begin
SortTPAFrom(TPA, TP);
Mouse(TPA[0].x, TPA[0].y - 50, 3, 3, false);
wait(750);
if not ChooseOption('ake X') then
begin
RMDebug('Problems choosing X');
Continue;
end else begin
wait(350+Random(250));
TypeSend(IntToStr(RandomRange(28, 99)));

i := GetSystemTime;
repeat
wait(250);
Antiban(RandomRange(2,4));
if not FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
break;
until((GetSystemTime - i) >= 750*SoftCount)

i := GetSystemTime;
repeat
wait(100);
Antiban(RandomRange(2,5));
if not FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
break;
until((GetSystemTime - i) >= 30000)

if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
RMDebug('Something went wrong with moudling');
Continue;
end;
end;
end;
end;
end else begin
RMDebug('could not find soft clay');
break;
end;

SoftCount := CountItems(SoftDTM, 'dtm', []);
if SoftCount <= 0 then break;

if not Relocate('wheel') then break;
until (false);
end;

Procedure FireClay;
var
i, x, y, Time, TimeIt: integer;
TPA, CTPA: TPointArray;
TIA: TIntegerArray;
TB: TBox;
TP: TPoint;
CFound: boolean;
begin
if not LoggedIn Then exit;
if not InvFull then exit;


if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

if not Relocate('oven') then exit;

if IsMember then
TP := IntToPoint(MCX2, MCY2)
else
TP := IntToPoint(314, 448);

Gametab(4);
Time := GetSystemTime;
repeat
if not LoggedIn then break;
CFound := false;

for i:= 28 Downto 1 do
begin
TB := InvBox(i);
if not FindDTM(JugDTM, x, y, TB.x1, TB.y1, TB.x2, TB.y2) then
begin
SetLength(CTPA, 6);
CTPA[0] := Point(TB.x1 + 20, TB.y1 + 5);
CTPA[1] := Point(TB.x1 + 20, TB.y1 + 10);
CTPA[2] := Point(TB.x1 + 20, TB.y1 + 15);
CTPA[3] := Point(TB.x1 + 20, TB.y1 + 20);
CTPA[4] := Point(TB.x1 + 20, TB.y1 + 25);
CTPA[5] := Point(TB.x1 + 20, TB.y1 + 30);
TIA := GetColors(CTPA);
end;
end;

if Find('oven') then
begin
FFlag(0);

for i:= 0 to 9 do
begin
wait(200);
if FindColor(x, y, 128, 229, 350, 239, 360) then //won't break as often as getcolor
begin
CFound := true;
break;
end;
end;

if not CFound then continue;

if FindColorsTolerance(TPA, 0, 61, 438, 467, 457, 0) then
begin
SortTPAFrom(TPA, TP);
Mouse(TPA[0].x, TPA[0].y - 50, 3, 3, false);
wait(100);
if not ChooseOption('ake X') then
begin
RMDebug('Problems choosing X');
Continue;
end else begin
wait(350+Random(250));
TypeSend(IntToStr(RandomRange(28, 99)));

wait(1000);
TimeIt := GetSystemTime;
repeat
wait(250);

if FindNPCChatText('t have any', Nothing) then
break;

if IsChatBoxTextAnyLine('have any more', 0) then
break;


if random(100) <= 5 then CompassMove(1000);
NoRandoms;
until(GetSystemTime - TimeIt >= (4000*26))

if not IsChatBoxTextAnyLine('have any more', 0) then
if not FindNPCChatText('t have any', Nothing) then
Continue;

RMDebug('done waiting for fired stuff');
for x := 0 to 9 do
begin
if not IsSameIntArray(TIA, GetColors(CTPA)) then
break;
wait(750);
end;

RMDebug('all is done, dropping now');
for i:= 1 to 28 do
begin
if i mod 3 = 0 then
NoRandoms;
TB := InvBox(i);
if not FindDTM(JugDTM, x, y, TB.x1, TB.y1, TB.x2, TB.y2) then
begin
DropItem(i);
wait(200+Random(150));
end;
end;
Inc(Loads);
Inc(Players[CurrentPlayer].Banked);
Inc(ReportVars[0]);
RMDebug('done dropping');
break;
end;
end else begin
RMDebug('Could not find the text color....');
Continue;
end;
end else begin
RMDebug('Problems Finding the Oven');
if not Relocate('oven') then break;
Continue;
end;

if GetSystemTime - Time >= 60000 then
break;
until(false)

end;

begin
SetupScript;
SetupPlayer;
DoTheColors;
LoadDTMS;

repeat
if not LoggedIn then break;
MineIt;
SoftenClay;
MoldClay;
FireClay;
Proggy;
SwitchPlayers;
until(false)


end.

It won't work anymore cus of color updates, but it might give you some inspiration :)


~RM

Sir R. M8gic1an

2011-02-13 08:54:25

Here's my crafter from just before I got Dev status.


{==============================================================================]
[==============================================================================]
[ RM Power Crafter ]
[ By: Rasta Magician ]
[==============================================================================]
[ Features ]
[==============================================================================]
[ 1. Debug ]
[ 2. AntiRandoms ]
[ 3. AntiBan ]
[ 4. Multiplayer ]
[ 5. Resting ]
[ 6. Progress Report ]
[ 7. Local Control ]
[ 8. Responder ]
[ 9. Proggy To File ]
[ 10. Smart Cycleing ]
[==============================================================================]
[ Description ]
[==============================================================================]
[ Mines clay, softens it, molds it into bowls(f2p), ]
[ plant pots or pot lids (with needed quest), then fires the clay, drops it ]
[ and repeats the whole thing. All of this happens inside the Crafting Guild ]
[ ]
[==============================================================================]
[ How To Use ]
[==============================================================================]
[ 0. You need level 40 crafting ]
[ 1. Wield a pick ]
[ 2. Wear a brown appron ]
[ 3. Have jugs in inventory (I suggest 4 jugs) ]
[ ]
[==============================================================================]
[ Credits ]
[==============================================================================]
[ SRL Team ]
[ Ed, thx for testing ]
[==============================================================================]
[ RM Power Crafter by Rasta Magician ]
[==============================================================================]
[==============================================================================}

{
add one more text for moulding clay
mold and fire menu colors changed place
}


program RMScript;
{$DEFINE SMART }
{$DEFINE Reflection}
//{$DEFINE FORM }

{$IFDEF SMART }
{.include srl/srl/misc/Smart.scar}
{$ENDIF}
{.include srl/srl.scar}
{$IFDEF Reflection}
{.include SRL\SRL\Reflection\Reflection.scar}
{$ENDIF}
{.include srl/srl/skill/mining.scar}

{$IFDEF FORM }
{.include srl/srl/misc/users.scar}
{$ENDIF}

Const
WorkTime = (30*60*1000); //10 mins
RestTime = (3*60*1000); //3 mins

IsMember = true;

UseDebug = True;
UseResponder = True;
SaveProggyToFile = True;

ScriptName = 'RM Power Crafter';
Version = '2.0';

YourSRLID = ''; //your SRLID
YourSRLPass = ''; //your SRL Stats pass
MyScriptID = '1199'; // don't touch

var
Rested, Worked, Loads,
PickColor, LadderColor, OvenColor,
ClayDTM, SoftDTM, JugDTM, WJugDTM, GemDTM,
JugCount, ClayCount,
ClayMined :integer;
ProggyStr: string;


function IsSameIntArray(i1, i2:TIntegerArray):boolean;
var i:integer;
begin
Result := false;
if Length(i1) <> Length(i2) then exit;

Result := true;
for i:= 0 to high(i1) do
if i1[i] <> i2[i] then
Result := False;
end;

//for debugging TPAs, to help me perfect my finders
//by Wizzup?
Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I, L: Integer;
xs, ys, xe, ye: Integer;

Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(Points) Do
Begin
xs := Min(xs, Points[i].X);
ys := Min(ys, Points[i].Y);

xe := Max(xe, Points[i].X);
ye := Max(ye, Points[i].Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To High(Points) Do
FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, 255);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;

//Declaring players
Procedure DeclarePlayers;
begin

{$IFDEF Form}
SRLPlayerForm(True, [], [], [], []);
exit
{$ENDIF}

NumberOfPlayers(1);
CurrentPlayer := 0;

Players[0].Name :='RMagician';
Players[0].Pass :='Th1sIsN0tMyPW!';
Players[0].Nick :='agi';
Players[0].Active := True;


end;

//Used for debugging and finding errors
Procedure RMDebug(s:string);
var name:string;
begin
if not UseDebug then exit;
try name := Players[CurrentPlayer].Name +' : '; except name:= '' end;
writeln(name+TheTime+' - '+s);
end;


//local control, F12 to activate and then text. used to check on proggies and
//to reactivate players
//untested with smart, might not work
{$IFDEF SMART}
procedure Proggy; forward;
Procedure EasyRC;
var i:integer;
begin
if not IsFKeyDown(12) then exit;
LogOut;

Proggy;
writeln('Fresh proggie on your right');
writeln('');

writeln('--- MENU ---');
writeln('F9 --> Status');
writeln('F10 --> Reset All');
writeln('F11 --> manage players');
writeln('F1 --> Keep on autoing');
writeln('--- End Menu --- ');
writeln('');
wait(2000);
repeat
if IsFKeyDown(9) then //status
begin
for i:=0 to High(players) do
writeln(IntToStr(i)+': '+Players[i].Nick+' - '+BoolToStr(Players[i].Active));
end;

if IsFKeyDown(10) then //Reset All
begin
for i:= 0 to High(Players) do
Players[i].Active := true;
writeln('Reset all :) ');
end;

if IsFKeyDown(11) then // Manage Players
begin

end;

if IsFKeyDown(1) then break;
until(false)
writeln('Restarting to auto :)');
LoginPlayer;
end;

{$ELSE}

//local control, F12 to activate and then text. used to check on proggies and
//to reactivate players
//untested with smart, might not work
Procedure EasyRC;
var
i, h1, h2, x, y:integer;
s, str: string;
begin
if not LoggedIn then exit;
if IsFKeyDown(12) then
begin
RMDebug('Trying to use Easy RC');
h1 := GetClientWindowHandle;
GetMousePos(x, y);
SetClientPos(False);
Disguise('RM Easy RC');
if FindWindowTitlePart('RM Easy RC', false) then writeln('Using Easy RC');
h2 := GetClientWindowHandle;
SetOnTop(h1, False);
SetOnTop(h2, True);
SetClientWindowHandle(h2);
wait(100);
ActivateClient;
wait(100);

repeat
s:= ReadLn('What to do?'+chr(13)+'Status / Reset N / Reset All / Proggy / Exit');
lowercase(s);
if (s = 'exit') or (s = '') then break;

if s= 'status' then
begin
for i:= 0 to High(Players) do
if not Players[i].Active then str:= str+chr(13)+Players[i].Name;
readln('these are set to false: '+chr(13)+str+chr(13)+'Press ok');
end;


if s = 'proggy' then
begin
Readln(ProggyStr+chr(13)+'Press ok');
end;

if Pos('reset', s) > 0 then
begin
str := TrimLetters(Trim(s));
if str = '' then
begin
for i:= 0 to High(Players) do
Players[i].Active:= True;
ReadLn('All Players Active'+chr(13)+'Press ok');
end else
try begin
i:= StrToInt(str);
Players[i].Active := True;
Readln('activated player: '+str+chr(13)+'Press ok');
end except break end;
end;
until(false)

SetOnTop(h2, False);
SetOnTop(h1, True);
SetClientWindowHandle(h1);
ActivateClient;
MMouse(x, y, 2, 2);
wait(3000);
Disguise(' A: '+IntToStr(PlayersActive)+'/'+IntToStr(Length(Players))+' Loads: '+IntToStr(loads));
RMDebug('Done using Easy RC');
end;
end;
{$ENDIF}


type
MyChat = record
Chatter: TStringArray;
Said: TStringArray;
LastResponded: integer;
end;
var
Trigger: Array of Array[0..1] of TStringArray; //questions, could make more triggers... if i
Answers: Array of TStringArray; //find i need them
RMTalks: MyChat;
Responses: Integer;



// to setup the questions qnd qnswers for the auto responder
procedure SetupRespond;
begin

SetLength(RMTalks.Chatter, 8);
SetLength(RMTalks.Said, 8);

SetLength(Trigger, 7); //how many questions
SetLength(Answers, Length(Trigger));
//you can have as many trigger words and rows as you want
//you can have as many answers as you want

Trigger[0][0]:= ['wc', 'woodcutting']; // trigger words 1
Trigger[0][1]:= ['lvl', 'level']; // trigger words 2
//Trigger[0][2]:= ['','','','','','']; // trigger words 3
Answers[0]:= [
'My Woodcutting Level is: '+IntToStr(Players[CurrentPlayer].Level[20]), //answer 1
'Wc: '+IntToStr(Players[CurrentPlayer].Level[20]), //answer 2
IntToStr(Players[CurrentPlayer].Level[20])+' wc lvl', //answer 3
'my wcing lvl is '+IntToStr(Players[CurrentPlayer].Level[20]) //answer 4
]

Trigger[1][0] := ['axe'];
Trigger[1][1] := ['which', 'what'];
Answers[1] := [
'I''m using a '+Players[CurrentPlayer].Strings[2]+' axe',
Players[CurrentPlayer].Strings[2],
'my axe is made out of '+Players[CurrentPlayer].Strings[2]
]

Trigger[2][0]:= ['good place', 'train'];
Trigger[2][1]:= ['woodcutting', 'wc'];
Answers[2] := [
'Try Training Woodcutting at Draynor',
'Draynor', 'Varrock', 'Edgy', 'Fally',
'Try Training Woodcutting at Edgeville',
'Try Training Woodcutting at Varrock Palace',
'Try Training Woodcutting at South of Falador'
]


Trigger[3][0]:= ['fish', 'fishing', '><>', '<><']; // trigger words 1
Trigger[3][1]:= ['lvl', 'level', 'levl', 'lvel']; // trigger words 2
//Trigger[3][2]:= ['','','','','','']; // trigger words 3
Answers[3]:= [
'My Fishing Level is: '+IntToStr(Players[CurrentPlayer].Level[17]), //answer 1
'Fishing: '+IntToStr(Players[CurrentPlayer].Level[17]), //answer 2
IntToStr(Players[CurrentPlayer].Level[17])+' '+chr(62)+chr(60)+chr(62)+' lvl', //answer 3
'my fishy lvl is '+IntToStr(Players[CurrentPlayer].Level[17]) //answer 4
]


Trigger[5][0]:= ['place', 'train'];
Trigger[5][1]:= ['fishing', '><>', 'fish'];
Answers[5] := [
'Try Training fishing at Draynor',
'Draynor', 'Edgy', 'Al-Kharid', 'Karamja',
'Try Training fishing at Edgeville',
'Try Training fishing at Al-Kharid, close to bank',
'Try Training fishing at lumbridge'
]

Trigger[6][0]:= ['hi','hey', 'hello', 'sup?']; // trigger words 1
Trigger[6][1]:= ['']; // trigger words 2
Answers[6]:= ['hi','hey', 'hello', 'sup?', 'how do you do?'] ;
end;

//from srl, modded for any line
function GetChatTextLine(var chat: string; line:integer): Boolean;
var
x, y: Integer;
textP: TPoint;
begin
if not LoggedIn then exit;
textP := TextCoords(line);
if findcolor(x, y, 16711680, textp.x, textp.y, textp.x + 200, textp.y + 14) then
begin
chat := LowerCase(Trim(GetTextAtEx(x - 3, textp.y - 2, 0, SmallChars, False,

False, -1, 1, 16711680, 60, False, tr_allChars)));
Result := True;
end;
end;

//from srl, modded for any line
function GetChatterLine(var name: string; line:integer): Boolean;
var
i: Integer;
textP: TPoint;
begin
if not LoggedIn then exit;
textP := TextCoords(line);
name := LowerCase(Trim(GetTextAtEx(textP.x - 2, textP.y - 2, 0, SmallChars, False, False, 0, 1,
0, 60, False, tr_allChars)))
i := Pos(':', name)
if (i <> 0) then
begin
Delete(name, i, i);
Result := True;
end;
end;

//my responder, used as antiban to look more human
procedure RMRespond;
var
str: string;
i, h, t, k, triggered:integer;
TSA:TStringArray;
begin
if not LoggedIn then exit;
if (TimeFromMark(RMTalks.LastResponded) < 60000+Random(30000)) then exit;


SetLength(TSA, 8)
str:='';
TSA:=['', '', '', '', '', '', '', ''];
RMTalks.said := ['', '', '', '', '', '', '', ''];
triggered := 0;

// Getting text on all the lines
for i:= 7 DownTo 0 do
begin
GetChatterLine(RMTalks.Chatter[i], i+1);
if Pos(Lowercase(Players[CurrentPlayer].Nick), Lowercase(RMTalks.Chatter[i])) > 0 then
break; //if we already answered, it means we already checked further up.
GetChatTextLine(RMTalks.said[i], i+1);
TSA[i] := RMTalks.said[i];
end;

for i:=High(TSA) DownTo 0 do //all text lines
for h:= 0 to High(Trigger) do //questions
begin
triggered:= 0;
for t:=0 to High(Trigger[h]) do //How many triggers

for k:=0 to High(Trigger[h][t]) do //specific trigger

if Pos(Trigger[h][t][k], TSA[i]) > 0 then
begin
Inc(triggered);
if triggered >= 2 then
begin

Inc(Responses);
str:=(Answers[h][Random(Length(Answers[h]))]);

TypeSend(AddMistakes(str, RandomRange(10, 30)));

RMDebug('Question: '+Trigger[h][0][0]+ ' ' + Trigger[h][t][k]);
RMDebug('Responding: ' + str);

str := '';
MarkTime(RMTalks.LastResponded);
triggered := 0;
SetupRespond;

exit;
end; //end if
break;
end; //end if
//end k loop
end; //end h loop
//end of i loop
end;

//making sure we solve those annoying randoms :)
Function NoRandoms: boolean;
var
x, y:integer;
s:string;
begin
if not LoggedIn then exit;
Result := False;
GetMousePos(x, y);
if UseResponder then RMRespond;
if ClickToContinue then
begin
MMouse(x, y, 3, 3);
Result := True;
end;
if FindNormalRandoms then Result:=true;
if FindFight then
begin
//none of the run aways check for randoms....

case random(4) of
0: s:='n';
1: s:='w';
2: s:='s';
3: s:='e';
end;

RMDebug('running to ' + s + ' and waiting for 8 - 10 s');
RunTo(s, True);
SleepAndMoveMouse(RandomRange(8000, 10000));

case s of
'n': s:= 'S';
's': s:= 'N';
'w': s:= 'E';
'e': s:= 'W';
end;

RMDebug('Returning to ' + s);
RunTo(s, True);

Result:=True;

NoRandoms;
end;

EasyRc;

end;



//Progress report
procedure Proggy;
var
JX2, i, i2, xph:integer;
str: string;
begin
ClearReport;
SRLRandomsReport;

AddToReport('');
AddToReport('[====== '+Padr(ScriptName+' '+Version, 27)+' ======]');
AddToReport('[ By Rasta Magician ]');
AddToReport('[=========================================]');
AddToReport('[ ' + Padr('Written ' + (TheTime) + ' on ' + (TheDate(3)) + '.', 40) + ']')
AddToReport('[ '+ Padr(TimeRunning, 40)+']');
AddToReport('[ ' + Padr('Players: ' + IntToStr(PlayersActive)+ ' / ' + IntToStr(HowManyPlayers), 40) + ']');
AddToReport('[ ' + Padr('Current Player: ' + Players[CurrentPlayer].Nick, 40) + ']');
AddToReport('[ '+ Padr('Loads: '+IntToStr(Loads), 40)+']');
AddToReport('[ '+ Padr('Clay Mined: '+IntToStr(ClayMined), 40)+']');
AddToReport('[ '+ Padr('Mining XP: '+IntToStr(ClayMined*5), 40)+']');
AddToReport('[ '+ Padr('=== CRAFTING XP ===', 40)+']');
xph := Round((ClayMined*40*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Lids: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*37.5*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Plant Pots: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*33*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Bowls: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*25*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Dishes: '+IntToStr(xph)+' xp/h', 40)+']');
xph := Round((ClayMined*12.6*3600*1000) / GetTimeRunning);
AddToReport('[ '+ Padr('Pots: '+IntToStr(xph)+' xp/h', 40)+']');
AddToReport('[ '+ Padr('=== CRAFTING XP ===', 40)+']')
AddToReport('[ '+Padr('Rested: '+IntToStr(Rested), 40)+']');
AddToReport('[================== RM ===================]');

ProggyStr := '';
ProggyStr := ProggyStr + chr(13) + ('[====== '+Padr(ScriptName+' '+Version, 27)+' ======]');
ProggyStr := ProggyStr + chr(13) + ('[ By Rasta Magician ]');
ProggyStr := ProggyStr + chr(13) + ('[=========================================]');
ProggyStr := ProggyStr + chr(13) + ('[ ' + Padr('Written ' + (TheTime) + ' on ' + (TheDate(3)) + '.', 40) + ']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr(TimeRunning, 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ ' + Padr('Players: ' + IntToStr(PlayersActive)+ ' / ' + IntToStr(HowManyPlayers), 40) + ']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr('Loads: '+IntToStr(Loads), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ '+ Padr('Clay Mined: '+IntToStr(ClayMined), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[ '+Padr('Rested: '+IntToStr(Rested), 40)+']');
ProggyStr := ProggyStr + chr(13) + ('[================== RM ===================]');


AddToReport('[ P | A | L | Mins | Rand ' + Padl(']', 13));
AddToReport('[-----------------------------------------]');

ProggyStr := ProggyStr + chr(13) + ('[ P | A | L | Mins | Rand ' + Padl(']', 13));
ProggyStr := ProggyStr + chr(13) + ('[-----------------------------------------]');

for i:= 0 to HowManyPlayers - 1 do
begin
str := '[ ' + Padr(Players[i].Nick, 4) + ' | ';
if Players[i].Active then
str := str + 'T | '
else
str := str + 'F | ';

str := str + Padr(IntToStr(Players[i].Banked), 2) + ' | ' + Padr(IntToStr(Players[i].Worked), 5) +'| ';
str := str + Padr(Players[i].Rand, 16) + ' ]';
AddToReport(str);
ProggyStr := ProggyStr + chr(13) + str;
end;

str := ScriptName+' '+Version
i := length(str);
if (i mod 2) <> 0 then
i2 := 1;

AddToReport('[-----------------------------------------]');
AddToReport('[====== '+Padl('', 14 - Trunc(i/2)) + str + Padr('', 13 + i2 - Trunc(i/2))+' ======]');
AddToReport('[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]');

ProggyStr := ProggyStr + chr(13) + ('[-----------------------------------------]');
ProggyStr := ProggyStr + chr(13) + ('[====== '+Padl('', 14 - Trunc(i/2)) + str + Padr('', 13 + i2 - Trunc(i/2))+' ======]');
ProggyStr := ProggyStr + chr(13) + ('[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]');

if SaveProggyToFile then
begin
JX2 := ReWriteFile((ScriptPath + ScriptName +' '+ Version + '.txt'), False);
WriteFileString(JX2, ProggyStr);
CloseFile(JX2);
RMDebug('Progress report saved to: ' + ScriptPath + ScriptName + ' ' + Version + '.txt');
end;
Disguise(' A: '+IntToStr(PlayersActive) + '/' + IntToStr(HowManyPlayers) +
' Loads: ' + IntToStr(Loads));
end;

//Antiban, basically just picks up the mouse, increases mouse speed
//clicks a tab and resets everything back to the original.
//just to make sure we stay logged in.
procedure FastSwitchTabs;
var x, y, i, h:integer;
begin
if not LoggedIn then exit;
RMDebug('Inactive Move');
GetMousePos(x, y);
PickUpMouse;
IncEx(MouseSpeed, 10);
i := GetCurrentTab;
repeat
h := 1+Random(12);
until(h <> i)
GameTab(h);
wait(500+Random(500));
GameTab(i);
MMouse(x, y, 3, 3);
DecEx(MouseSpeed, 10);
end;

//will take "Time" + Random(1000) to complete the action, will return to original angle
// By Rasta Magician, heavily based on RandomMovement by Krazy_Meerkat
// will always move the compass around unlike in RandomMovement
procedure CompassMove(Time:Integer);
var
Keys: array of Integer;
I: Integer;
Deg: Extended;
begin
if not LoggedIn then exit;
Keys := [VK_RIGHT, VK_LEFT];
I := Random(2);
ActivateClient;
Deg := rs_GetCompassAngleDegrees;
Wait(100 + random(50));
KeyDown(Keys[I]);
Wait(Round(Time/2) + random(500));
KeyUp(Keys[I]);
Wait(Round(Time/2) + random(500));
MakeCompass(FloatToStr(Deg));
end;

//Random Right Click Return by Rasta Magician,
//Will right-click anywhere on he main map, choose "Cancel" and return the
//mouse to it's original position
procedure RRClickReturn;
var x, y:integer;
begin
if not LoggedIn then exit;
IncEx(MouseSpeed, 7);
GetMousePos(x, y);
ActivateClient;
Mouse(MSX1, MSY1, MSX2, MSY2, False);
wait(100 + Random(50));
ChooseOption('ancel');
wait(50 + Random(100));
MMouse(x, y, 3, 3);
DecEx(MouseSpeed, 7);
end;

//just antiban with a percentage
Procedure AntiBan(percentage: integer);
var p: integer;
begin
if not Loggedin then exit;
if random(100) <= percentage then
begin
case random(14) of
0, 1: FastSwitchTabs;
2, 3: CompassMove(1000);
4, 5: RRClickReturn;
6, 7: SleepAndMoveMouse(2000);
8, 9: HoverSkill('random', false);
//10, 11: DoEmote(Random(37)+1);
12, 13: PickUpMouse;
end;
Gametab(4);
end;
end;

{$IFDEF SMART}
Procedure SetupSmart(world: integer);
begin

SmartSetupEx(world, False, True, False);
Wait(5000);
SetTargetDC(SmartGetDC);
repeat
wait(100);
until(SmartGetColor(253, 233)<>1118604);

end;
{$ENDIF}

//Used to set up all the necessary things before the script starts running
Procedure SetupScript;
begin
ClearDebug;
Disguise(ScriptName + ' ' + Version);
{$IFDEF SMART}
SetupSmart(100);
{$IFDEF Reflection}
RMDebug('Checking hooks, if they''re outdated un-define reflection to run this');
SetupReflection;
{$ENDIF}
{$ENDIF}
SetupSRL;
DeclarePlayers;
if UseResponder then SetupRespond;

SRLID := YourSRLID;
SRLPassword := YourSRLPass;
ScriptID := MyScriptID;
ActivateClient;
LoginPlayer;
end;


//for prepqring the playe and making sure he has all the requirements
procedure SetupPlayer;
begin
if not LoggedIn then exit;
SetGraphics(4, 'current', 'always', 'off', 'low', 'few', 'off', 'few', 'off');
CloseWindow;
MarkTime(Worked);
GameTab(4);
wait(500);
JugCount := CountItems(JugDTM, 'dtm', []);
RMDebug('Player has '+IntToStr(JugCount)+' jugs');
SetAngle(true);
end;

//switching palyers, or in case of jsut one player making it rest
// "not playing" for a while decreases the chance of getting a lot of randoms
procedure SwitchPlayers;
var Time: integer;
begin
if (TimeFromMark(Worked) >= (WorkTime + Random(3*60*1000)) )or(not LoggedIn) then
begin
if PlayersActive > 1 then
NextPlayer(Players[CurrentPlayer].Active)
else begin
if not LoggedIn then TerminateScript;
LogOut;
RMDebug('resting....');
Time := GetSystemTime;
while (GetSystemTime - Time < RestTime) do
Disguise('Rest: '+IntToStr(Round((RestTime - (GetSystemTime - Time))/1000))+' s');

Disguise(' A: '+IntToStr(PlayersActive) + '/' + IntToStr(HowManyPlayers) +
' Loads: ' + IntToStr(Loads));
ActivateClient;
LoginPlayer;
Inc(Rested);
MarkTime(Worked);
end;
SetupPlayer;
end;
end;

procedure LoadDTMS;
begin

ClayDTM := DTMFromString('78DA6374626260E066644006D31BC218FE036' +
'990E87F206004A96146550391859140DA03A8868D801A2FA01A4E' +
'026A40760910506389E9660C353640351CF8D50000D181089F');

SoftDTM := DTMFromString('78DA63B4676260E060644006B9417C0CFF813' +
'448F43F10303A01D5FC6740038C4824900E00AA6163C4AFC605A8' +
'4698801A33A01A3E026A2C816A5808A8F106AAE125A0C69AB07B0' +
'05BEC0953');

JugDTM := DTMFromString('78DA637462626078C68002DA6A6B184480342' +
'310FF0702465BA09AEB0C6880918115AA06CCF304AAB949408D37' +
'50CD3D026ABC806ADE1150630754F391801A4BA09AA744B8F93DA' +
'61A0674735E1350630154F39C801A1BEC7E4751E38C3D9C51D4F8' +
'03D53C2242CD1322ECFA44408D37613703001F0C187A');

WJugDTM := DTMFromString('78DA63CC656260B8CB80024ACBCF31F003694' +
'620FE0F048CE94035D719D00023032B540D985784690E869A72A0' +
'9AD704D46403D57C22A02609A8E60501352037DFC7AF060021030' +
'F2C');


end;

procedure FreeDTMS;
begin
FreeDTM(ClayDTM);
FreeDTM(SoftDTM);
FreeDTM(JugDTM);
FreeDTM(WJugDTM);
end;

//Just a few things it does when the script ends.
procedure ScriptTerminate;
begin
Proggy;
FreeDTMS;
writeln('');
writeln('Thank for using my script, Rasta Magician');
writeln('Script stopped at ' + TheTime + ' ' + TheDate(3));
writeln('Please post the Progress Report');
end;



function AutoColorOven: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
//try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.60, 8.58);

if not (FindColorsTolerance(arP, 661291, MMX1, MMY1, MMX2, MMY2, 6)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
// end except end;
end;

function AutoColorOven2: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
//try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.16);

if not (FindColorsTolerance(arP, 1126745, MMX1, MMY1, MMX2, MMY2, 4)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
// end except end;
end;

function AutoColorPick: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
// try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.38, 1.13);

if not (FindColorsTolerance(arP, 2903683, MMX1, MMY1, MMX2, MMY2, 6)) then
begin
Writeln('Failed to find the color, no result. - pick');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color. - pick');
// end except end;
end;

function AutoColorWaterSymbol: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
// try begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.32);

if not (FindColorsTolerance(arP, 15549204, MMX1, MMY1, MMX2, MMY2, 10)) then
begin
Writeln('Failed to find the color, no result. - Water');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
if (rs_OnMinimap(arP[i].x, arP[i].y)) then
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

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

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color. - water');
// end except end;
end;

procedure DoTheColors;
var x, y: integer;
begin
{
PickColor := AutoColorPick;
LadderColor := FindLadderColor;
OvenColor := AutoColorOven;

if OvenColor = 0 then
OvenColor := AutoColorOven2;

if LadderColor = 0 then
LadderColor := AutoColorWaterSymbol;
}
end;


Function Relocate(place: string): boolean;
var
ATPA: T2DPointArray;
TPA : TPointArray;
TP: TPoint;
Color: boolean;
Str: string;
begin
if GetMMLevels('run', str) >= 25 then
SetRun(true);

Color := True;
{$IFDEF Reflection}
RMDebug('[REF] Relocating.. '+place);
Color := False;
RMDebug('before case');
case lowercase(place) of
'mine': if not WalkToTile(Point(2939, 3282), 1, 2) then Color := true;
'water': if not WalkToTile(Point(2933, 3280), 1, 2) then Color := true;
'wheel': if not WalkToTile(Point(2936, 3288), 1, 2) then Color := true;
'oven': if not WalkToTile(Point(2930, 3290), 1, 2) then Color := true;
end;
RMDebug('aafter case');
if Color then
RMDebug('reflection failed, trying color')
else begin
RMDebug('At '+place);
Result := true;
wait(750+random(500));
exit;
end;
{$ENDIF}

Result := true;
RMDebug('Relocating.. '+place);
case lowercase(place) of
'mine':
begin
if PickColor = 0 then
begin
PickColor := AutoColorPick;
if PickColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, PickColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 1);
SortATPAFrom(ATPA, IntToPoint(MMX2, MMY2));
SortTPAFrom(ATPA[0], IntToPoint(MMX2, MMY2));
TP := ATPA[0][0];
Mouse(TP.x, TP.y + 8, 3, 3, true);
end else Result := false;
end;

'water':
begin
if LadderColor = 0 then
begin
LadderColor := FindLadderColor;
if LadderColor = 0 then
LadderColor := AutoColorWaterSymbol;
if LadderColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, LadderColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 2);
SortATPASize(ATPA, true);
TP := MiddleTPA(ATPA[0]);
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;

'wheel':
begin
if OvenColor = 0 then
begin
OvenColor := AutoColorOven;
if OvenColor = 0 then
OvenColor := AutoColorOven2;
if OvenColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, OvenColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
ATPA := SplitTPA(TPA, 2);
SortATPAFrom(ATPA, IntToPoint(MMX2, MMY1));
SortTPAFrom(ATPA[0], IntToPoint(MMX2, MMY1));
TP := ATPA[0][0];
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;

'oven':
begin
if OvenColor = 0 then
begin
OvenColor := AutoColorOven;
if OvenColor = 0 then
OvenColor := AutoColorOven2;
if OvenColor = 0 then
begin
LogOut;
Players[CurrentPlayer].Rand := 'AC Fail';
exit;
end;
end;
if FindColorsTolerance(TPA, OvenColor, MMX1, MMY1, MMX2, MMY2, 0) then
begin
SortTPAFrom(TPA, IntToPoint(MMX1, MMCY));
TP := TPA[0];
Mouse(TP.x, TP.y, 3, 3, true);
end else Result := false;
end;
end;

if not Result then
begin
RMDebug('failed at relocating to ' + place);
exit;
end;

FFlag(0);
wait(1000+Random(750));

// RMDebug('Arrived at destination. We hope to see you again soon, with RM Airways');
end;

function FindIt(var fx, fy: Integer; CTS, Color, Tol, H, W:integer; SCS2M1, SCS2M2:extended; text:TStringArray): Boolean;
var
arP: TPointArray;
ararP: T2DPointArray;
tmpCTS, i, arL: Integer;
P: TPoint;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(SCS2M1, SCS2M2);

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

SortTPAFrom(arP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arP, H, W);
arL := High(ararP);

for i := 0 to arL do
begin
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 0, 0);
Wait(350);
if IsUpTextMultiCustom(text) then
begin;
Result := True;
Break;
end;
end;

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

if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;

GetMousePos(fx, fy);
end;



Function Find(s: string): boolean;
var x, y:integer;
begin
case lowercase(s) of
'clay': Result := FindIt(x, y, 2, 7250880, 9, 10, 10, 0.03, 1.24, ['ine', 'ock']);
'water': Result := FindIt(x, y, 1, 11172192, 10, 5, 5, 0.2, 0.2, ['ink']);
'wheel': Result := FindIt(x, y, 2, 8290185, 2, 20, 20, 0.08, 0.25, ['otter''s', 'heel']);
'oven': Result := FindIt(x, y, 4, 660057, 4, 5, 5, 0.06, 0.40, ['ven']);
end;

if Result then
Mouse(x, y, 0, 0, true);
RMDebug('Looking for '+s+'... Found? '+BoolToStr(Result));
end;

Procedure MineIt;
var x, y, t, tries:integer;
begin
if not LoggedIn then exit;
if InvFull then exit;
if not Relocate('mine') then exit;

MarkTime(t);
repeat
if not LoggedIn then break;

{
if FindDTM(GemDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
DropItem(CoordsToItem(x, y));
wait(200+Random(100));
Inc(ReportVars[2]);
end;
}

if InvFull then break;
if Find('clay') then
begin
Tries := 0;

x := GetSystemTime;
repeat
wait(100);
FindNormalRandoms;
if GetSystemTime - x >= 5000 then break;
until(FindBlackChatMessage('swing your'))

if GetSystemTime - x >= 5000 then Continue;

x := GetSystemTime;
repeat
wait(100);
FindNormalRandoms;
if GetSystemTime - x >= 5000 then break;
until(FindBlackChatMessage('manage to mine'))

end else Inc(Tries);

if Tries >= 5 then
if not Relocate('mine') then
break;

until(InvFull)or(TimeFromMark(t) >= (60*5000))

ClayCount := CountItems(ClayDTM, 'dtm', []);
ClayMined := ClayMined + ClayCount;
ReportVars[1] := ClayCount;
IncEx(Players[CurrentPlayer].Integers[0], ClayCount);
end;

Procedure SoftenClay;
var x, y, WaterCount, ClayCount, i, Time:integer;
begin
if not LoggedIn then exit;
if not InvFull then exit;

Gametab(4);

ClayCount := CountItems(ClayDTM, 'dtm', []);
if ClayCount <= 0 then exit;

JugCount := CountItems(JugDTM, 'dtm', []);
RMDebug('2 - Player has '+IntToStr(JugCount)+' jugs');

if JugCount <= 0 then
begin
RMDebug('Player has no jugs!');
Players[CurrentPlayer].active := false;
LogOut;
exit;
end;

Time := GetSystemTime;
if not Relocate('water') then exit;
repeat
if not LoggedIn then break;

if not FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then break;

if FindDTM(JugDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);
wait(350+Random(500));
if Find('water')then
begin
FFlag(0);
Wait(355*JugCount+500+Random(500));
WaterCount := CountItems(WJugDTM, 'dtm', []);
RMDebug(IntToStr(WaterCount)+' jugs are filled with water');

if not WaterCount = JugCount then
begin
for i:= 0 to 5 do
begin
wait(500);
WaterCount := CountItems(WJugDTM, 'dtm', []);
if WaterCount = JugCount then break;
end;
if not WaterCount = JugCount then
begin
RMDebug('something wrong with filling the jugs...');
Continue;
end;
end;

ClayCount := CountItems(ClayDTM, 'dtm', []);
RMDebug('Player has '+IntToStr(ClayCount)+' clay');

Mouse(x, y, 3, 3, true); //clicking jug again

if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);

wait(200+random(100));
MMouse(247, 406, 18, 15);
for i:= 0 to 9 do
begin
wait(100);
if GetColor(254, 412) = 938605 then break;
end;

GetMousePos(x,y);
Mouse(x, y, 0, 0, false);
wait(250);
if not ChooseOption('All') then
begin
RMDebug('problem choosing option');
Continue;
end;

wait(1000+ 750*WaterCount + Random(500));

if not CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
if not CountItems(ClayDTM, 'dtm', []) = 0 then
begin
for i:= 0 to 5 do
begin
wait(500);

if CountItems(ClayDTM, 'dtm', []) = 0 then
exit;
if CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
break;


end;
end else break;

if not CountItems(ClayDTM, 'dtm', []) = (ClayCount - WaterCount) then
if not CountItems(ClayDTM, 'dtm', []) = 0 then
begin
RMDebug('Problem softening the clay....');
Continue;
end;
end;

end else begin
RMDebug('Couldn''t find the water');
if not Relocate('water') then break;
Continue;
end;
end else begin
RMDebug('found no jug');
LogOut;
Players[CurrentPlayer].Active := false;
exit;
end;

until(GetSystemTime - Time >= 60*5000)
end;

Procedure MoldClay;
var
x, y, i, SoftCount, Time:integer;
TPA: TPointArray;
TP: TPoint;
CFound: boolean;
begin
if not LoggedIn Then exit;
if not InvFull then exit;

if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

SoftCount := CountItems(SoftDTM, 'dtm', []);
if SoftCount <= 0 then exit;

if not Relocate('wheel') then exit;

if IsMember then
TP := IntToPoint(MCX2, MCY2)
else
TP := IntToPoint(314, 448);

repeat
if not LoggedIn then break;

CFound := false;
Gametab(4);
if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, true);

if Find('wheel') then
begin
FFlag(0);
for i:= 0 to 9 do
begin
wait(200);
if FindColor(x, y, 128, 229, 350, 239, 360) then //won't break as often as getcolor
begin
CFound := true;
break;
end;
end;

if not CFound then continue;

if FindColorsTolerance(TPA, 0, 61, 439, 467, 457, 0) then
begin
SortTPAFrom(TPA, TP);
Mouse(TPA[0].x, TPA[0].y - 50, 3, 3, false);
wait(750);
if not ChooseOption('ake X') then
begin
RMDebug('Problems choosing X');
Continue;
end else begin
wait(350+Random(250));
TypeSend(IntToStr(RandomRange(28, 99)));

i := GetSystemTime;
repeat
wait(250);
Antiban(RandomRange(2,4));
if not FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
break;
until((GetSystemTime - i) >= 750*SoftCount)

i := GetSystemTime;
repeat
wait(100);
Antiban(RandomRange(2,5));
if not FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
break;
until((GetSystemTime - i) >= 30000)

if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
RMDebug('Something went wrong with moudling');
Continue;
end;
end;
end;
end;
end else begin
RMDebug('could not find soft clay');
break;
end;

SoftCount := CountItems(SoftDTM, 'dtm', []);
if SoftCount <= 0 then break;

if not Relocate('wheel') then break;
until (false);
end;

Procedure FireClay;
var
i, x, y, Time, TimeIt: integer;
TPA, CTPA: TPointArray;
TIA: TIntegerArray;
TB: TBox;
TP: TPoint;
CFound: boolean;
begin
if not LoggedIn Then exit;
if not InvFull then exit;


if FindDTM(ClayDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

if FindDTM(SoftDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
exit;

if not Relocate('oven') then exit;

if IsMember then
TP := IntToPoint(MCX2, MCY2)
else
TP := IntToPoint(314, 448);

Gametab(4);
Time := GetSystemTime;
repeat
if not LoggedIn then break;
CFound := false;

for i:= 28 Downto 1 do
begin
TB := InvBox(i);
if not FindDTM(JugDTM, x, y, TB.x1, TB.y1, TB.x2, TB.y2) then
begin
SetLength(CTPA, 6);
CTPA[0] := Point(TB.x1 + 20, TB.y1 + 5);
CTPA[1] := Point(TB.x1 + 20, TB.y1 + 10);
CTPA[2] := Point(TB.x1 + 20, TB.y1 + 15);
CTPA[3] := Point(TB.x1 + 20, TB.y1 + 20);
CTPA[4] := Point(TB.x1 + 20, TB.y1 + 25);
CTPA[5] := Point(TB.x1 + 20, TB.y1 + 30);
TIA := GetColors(CTPA);
end;
end;

if Find('oven') then
begin
FFlag(0);

for i:= 0 to 9 do
begin
wait(200);
if FindColor(x, y, 128, 229, 350, 239, 360) then //won't break as often as getcolor
begin
CFound := true;
break;
end;
end;

if not CFound then continue;

if FindColorsTolerance(TPA, 0, 61, 438, 467, 457, 0) then
begin
SortTPAFrom(TPA, TP);
Mouse(TPA[0].x, TPA[0].y - 50, 3, 3, false);
wait(100);
if not ChooseOption('ake X') then
begin
RMDebug('Problems choosing X');
Continue;
end else begin
wait(350+Random(250));
TypeSend(IntToStr(RandomRange(28, 99)));

wait(1000);
TimeIt := GetSystemTime;
repeat
wait(250);

if FindNPCChatText('t have any', Nothing) then
break;

if IsChatBoxTextAnyLine('have any more', 0) then
break;


if random(100) <= 5 then CompassMove(1000);
NoRandoms;
until(GetSystemTime - TimeIt >= (4000*26))

if not IsChatBoxTextAnyLine('have any more', 0) then
if not FindNPCChatText('t have any', Nothing) then
Continue;

RMDebug('done waiting for fired stuff');
for x := 0 to 9 do
begin
if not IsSameIntArray(TIA, GetColors(CTPA)) then
break;
wait(750);
end;

RMDebug('all is done, dropping now');
for i:= 1 to 28 do
begin
if i mod 3 = 0 then
NoRandoms;
TB := InvBox(i);
if not FindDTM(JugDTM, x, y, TB.x1, TB.y1, TB.x2, TB.y2) then
begin
DropItem(i);
wait(200+Random(150));
end;
end;
Inc(Loads);
Inc(Players[CurrentPlayer].Banked);
Inc(ReportVars[0]);
RMDebug('done dropping');
break;
end;
end else begin
RMDebug('Could not find the text color....');
Continue;
end;
end else begin
RMDebug('Problems Finding the Oven');
if not Relocate('oven') then break;
Continue;
end;

if GetSystemTime - Time >= 60000 then
break;
until(false)

end;

begin
SetupScript;
SetupPlayer;
DoTheColors;
LoadDTMS;

repeat
if not LoggedIn then break;
MineIt;
SoftenClay;
MoldClay;
FireClay;
Proggy;
SwitchPlayers;
until(false)


end.

It won't work anymore cus of color updates, but it might give you some inspiration :)


~RM

EtherFreak

2011-03-29 13:49:45

fixed the wheel finding issue, and the issue with the urn update. I will look at adding urn support in the near future.

tarajunky

2011-03-29 15:11:51

have 14 buckets in your first 14 inventory slots.


Buckets should not be necessary anymore, since you can wet clay directly from any water source.

EtherFreak

2011-04-03 04:53:53

I was not aware of this. good to know, to have better exp per hour.

EtherFreak

2011-04-03 22:13:53

New update, removed the bucket requirements, due to buckets not being necessary. Improved some timing issues. look for future updates.

YoHoJo

2011-04-04 00:45:29

Moved to Public Scripts Section!

grats

2011-04-04 05:09:06

It has a problem when it's going to the pottery wheel, it mis-clicked like 5 times before it found the wheels, every time it was clicking above the actual wheel.

it found it after a while though!

will post proggy after a while



[[(608, 41)], [(636, 49)]]
going to throw
failed to find wheel, trying again
failed to find wheel, trying again
failed to find wheel, trying again
[[(592, 77)], [(619, 85)]]
going to throw
failed to find wheel, trying again
failed to find wheel, trying again
failed at throwing, logging out
going to fire
failed to click oven, trying again
going to fire

didn't execute after logging out (which it did log out so we know if it fails too much it will logoff)


edit:

after watching it for a while
I'd add a failsafe for clicking the pottery wheel & the "create bowls" or whatever..
also when firing the bowls / pots, add a failsafe for that too.. sometimes it doesn't click & just sits there for the wait time then drops

mining & softening clay is working great, didn't see 1 problem with either of those.

EtherFreak

2011-04-04 15:59:07

Thank you for the detailed feedback. I am looking into this issues now, and should have them resolved by tonight. I also plan on getting away from the time, and want to get to inventory detection for the stages. This will be coming over time, depending on how well tpa works with me.

EtherFreak

2011-04-05 03:26:51

Update 04 is now up and running. I have removed all static wait times, and added a few more failsafes. I also have improved the wheel finding yet again, and hopefully it remains problem free. I probably will be lifting the beta title in the near future, when I believe I have worked out all the kinks.

Once again, detailed feedback is appreciated so I can iron out all possible issues that may arise.

grats

2011-04-05 19:33:14

Where did the download for 04 go? I have it at home, was going to test it out in class

Smartzkid

2011-04-05 19:36:52

In class? :p

grats

2011-04-05 19:47:13

From: Smartzkid
In class? :p


Yea, I'm in my networking class and my teacher says I participate too much and to let other kids answer stuff lol………….

i luffs yeww

2011-04-05 19:53:21

From: grats
Yea, I'm in my networking class and my teacher says I participate too much and to let other kids answer stuff lol………….


Happens to me, too. :<

EtherFreak

2011-04-05 21:25:57

user error strikes again, must of deleted it by accident when I was editing spelling earlier. stranger things have been known to happen.

grats

2011-04-06 02:48:18

the new update tries to click the minimap when it goes to soften clay

EtherFreak

2011-04-06 03:01:20

Please verify you have downloaded the latest version. 04 got deleted by accedent, and put up again with possible changes. The most current version has an option to select the sink water color. sorry for any inconvenece this may have caused.

grats

2011-04-06 03:14:50

From: EtherFreak
Please verify you have downloaded the latest version. 04 got deleted by accedent, and put up again with possible changes. The most current version has an option to select the sink water color. sorry for any inconvenece this may have caused.


Yea got the newest one now, working good

had 3 different versions of 04 lol

how do I make the mouse move faster?


I'll get a good report with this one, hopefully it gives me a strange rock, need one more for this week

edit:

oh I just noticed

is it supposed to sometimes click the flower pots? (to the right of the bowls)

I have high level so it just does them fine, but if someone isn't that high of level in crafting it might cause a problem.. the option to choose between the two would be neat.

EtherFreak

2011-04-06 14:12:03

oh I just noticed
is it supposed to sometimes click the flower pots? (to the right of the bowls)


No, it is not suppose to do that. However, one can not make flower pots on f2p, and it was set up to click the bowl location on f2p and not p2p. I will ether need the dimensions of the p2p throwing options, or recommend that the script only be run on free worlds.

I was planning on adding an option to make urns as well, so I could add flower pot support, but there again, i need to look at members to do this.

nhawkesn

2011-04-27 05:41:00

will you be adding urn support any time soon?

EtherFreak

2011-05-09 16:01:46

I plan to get non members urn support up and running when I have time. if I get members again or have enough testers, I will try and get members urns as well.

EtherFreak

2011-11-08 14:19:08

A new version is released, that should be good for a while. Depending on feedback, I may lift the term BETA. As always, let me know of any issues you come across, so I can try to fix them. Please note, this is made for FREE worlds! Members worlds have more crafting options, so my layout is wrong. I will be working on urn support for FREE worlds before too long.

EtherFreak

2012-01-31 02:15:53

fixed wheel finding, and seems to be working great. I am not aware of any issues as of yet, and my testing has found none thus far. remember, this is made for free worlds only!!!