kanah
2011-10-28 11:54:25
How Long have You Played Runescape?
2 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
Euphemism
What is your general programming knowledge?
C,C++,C#,VisualBasic,x86 Assembly
Are you a member of any other communities?
No
Tell us about yourself…
Please show us one (or multiple) of your scripts.
The Miller
The Random Fact Generator
2 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
Euphemism
What is your general programming knowledge?
C,C++,C#,VisualBasic,x86 Assembly
Are you a member of any other communities?
No
Tell us about yourself…
From: kanah
I am a 23 year old recent graduate from college with a masters of science in electrical engineering; I regret to inform you that as of late I'm still unemployed.
I enjoy strategy games like diplomacy; Axis and Allies; and risk. Yu-Gi-Oh! cards are also cool.
Please show us one (or multiple) of your scripts.
The Miller
program Miller; {The program is named here}
//This acts like an include statement
{$i srl/srl/misc/smart.scar} //For smart use
{$i SRL/SRL.scar} //This needs to be in all scripts
{$i srl/srl/misc/paintsmart.scar} //For painting on screen
{$i SPS/SPS.simba} //A back up for DTM Walking
{$i SRL\SRL\MISC\Stats.simba}
{ AUTHOR: Kanah
WELCOME TO PROJECT STOP WORLD HUNGER
* THE MILLER *
* THE POT MAKER *
* THE DOUGH MASTER *
* THE PASTRY CHEF *
This is the first script in solving the hunger problem
THE MILLER:
INSTRUCTIONS:
* make sure player is either near beefy bill or grain field
* Have all the potnotes you will need in inventory
* Set up your player information
* Enter how many loads u want to do (in Const section)
* You can adjust the type of anti as well (in Const section)
* If the script fails it will create a bitmap of the failure
in the current directory
(almost all failures are a result of lost position)
* YOU CAN ADJUST HOW LONG IS TOO LONG TO BE DOING A SINGLE TASK
adjust the TIMEOUT variable
* This is a stable release, multiple back up systems ensure no infinite loops
and time marking forces some production within a specified time
* SPS IS REQUIRED!
Revision Log:
Rev16 - SRL Stats Added
- Added additional colors to mill and bill's cart records
- bug noticed: Sometimes pote notes are detected as small pots
(I think jagex got rid of the item size bug) No longer checking for
SmallPotDTM
- Made random fact generation and crash screen capture optional
Rev15 - Bot Nuke updates
Rev14 - Added forced angle change in verifylocation
- Changed how middle ladder in mill is found
Rev13 - Top of mill detection made broader
- Another revision to buy pots, now it also tracks the coin gained during selling pots
- Extra click removed from pick grain!!
- Extra Failsafes added to collect flour (a loop counter and fixing pot dtm)
- Added Extra Step in walking to bill to force character to be on south side (can see door there)
- Finding bill's cart now clicks to the left of the cart
Rev12 - Minor bug fixes
- Check Screen Angle during every attempt to grind grain
- Revised buy pots to make sure 20 pots get purchased
- Double Checking in location Check if lost
- Collecting flower now looks for empty pots
- Script Checks for lack of pots in note form, if you run out it logs out
Rev11 - Changed some movement to SPS
Rev10 - Added more backups for getting into grain field
- Findobj now used for picking
- FindObjDTM for grinding now grinding
Rev9 - Added extra step to Walk2Bill (Sometimes the screen doesnt show the second dtm)
- Fine tuned the tolerances to improve reliability
- THIS VERSION PASSED THE ENDURANCE TESTS (consistantly operated successfully for an hour)
Rev8 - Multiplayer
- Breaking;
- Fixed WalkBill2Mill bug (Sometimes it walks around the river lum)
- Fixed Empty Pot bug
- Added more reliable climbing, backup location verification
Rev7.1 - Fixed a Grinding Bug
Rev7 - TIMING FAILSAFE!!!
- Progress Reports
- Adjusted some tolerances and LeverDTM
- Add Randomness to all wait calls
- Add randomness to Mouse
- Replace MoveMouse with MMouse
Rev6 - PUBLIC RELEASE 8/22/2011
- AntiBan and AntiRandom
- code cleaned up (erased old unused code)
- Additional Retries on getting to locations
Rev5 - Handling crashs via screenshot saving
- Door finding via color instead of DTM
Rev4 - Add better Grain picking
- multicolor bill detection
- TPA Location Detection!!!
- Changed from FindDTM to ... FindDTMRotated
Rev3 - Added InMill woot! TPA
- Walking fail safes
- TPA Walking too
Rev2 - Even More FeedBack
- Modularized DTM Minimap movement
- Verify Minimap movement with each step
Rev1 - Adding FeedBack
- Closed loop system for some actions
- Verify Location
Rev0 - Initial Prototype
-uses color and dtm to preform tasks
-open loop system
}
//Function Prototypes here
//Counting Inventory Functions
function CountGrain: Integer; Forward;
function CountFlour: Integer; Forward;
function VerifyLocation: Integer; Forward;
function DistanceToDTM(var DTM: Integer): Extended; Forward;
function DTMWalk(var DTM: Integer; tolerance: Extended): Boolean; Forward;
function DTMDoors(var OpenDTM, ClosedDTM: Integer): Boolean; Forward;
function InMill():Boolean; Forward;
function InGrainField():Boolean; Forward;
function DetermineAction: Integer; Forward;
function FindObjectDoors(Color: TIntegerArray): Boolean; Forward;
function HandleGateDoor( Gate: Boolean ): Boolean; Forward;
function InTopMill: Boolean; Forward;
function FindObjDTM(var x,y,DTM: integer;Text: string): Boolean; Forward;
procedure DeclarePlayers;
var
i: integer;
begin
HowManyPlayers := 5;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
i := 0;
Players[i].Name := '';
Players[i].Pass := '';
Players[i].Nick := '';
Players[i].Active := false;
Players[i].Pin := '';
//Set up more players here, remember to update HowManyPlayers
i := i+1;
Players[i].Name := '';
Players[i].Pass := '';
Players[i].Nick := '';
Players[i].Active := false;
Players[i].Pin := '';
i := i+1;
Players[i].Name := '';
Players[i].Pass := '';
Players[i].Nick := '';
Players[i].Active := false;
Players[i].Pin := '';
i := i+1;
Players[i].Name := '';
Players[i].Pass := '';
Players[i].Nick := '';
Players[i].Active := false;
Players[i].Pin := '';
i := i+1;
Players[i].Name := '';
Players[i].Pass := '';
Players[i].Nick := '';
Players[i].Active := false;
Players[i].Pin := ''
end;
const
{------- SRL Stats ---------}
SRLStats_User = '';
SRLStats_Password = '';
{-----Breaking Settings-----} //Credit to SandoS for Basic Script setup
TAKEBREAKS = True; // Take breaks?
HOWOFTEN = 120; // How often to break in minutes
HOWOFTENRANDOM = 20; // Added randomness to how often you break
HOWLONG = 20; // How long to break for in minutes
HOWLONGRANDOM= 8; // Added randomness in break length
{---- AntiBan Settings ------}
CHANCE = 1.5; //this is the percent chance of taking a random action so 1.1 means 1.1% chance
ENABLEWORLDSWITCH = false;
MRAND = 2; //This is the randomness used in the Mouse and MMouse function calls
TIMEOUT = 3*60;//Fail safe max time spent on a single task in seconds
{ --- Maximum trips --- }
LOADS = 30;
{--- Other Settings ---}
TAKEPICTURE = true;
SHOWRANDOMFACT = false;
GrainColor = 6137511;
ActionBoxX = 500; //This is x limit on the game screen
ActionBoxY = 350; //Y limit on game screen
ITEM_ID_GRAIN = 1947;
ROAD_COLOR = 8292236;
GATE_COLOR = 2962490;
DOOR_COLOR = 14408677;
INVX1 = 548;
INVY1 = 205;
INVX2 = 735;
INVY2 = 462;
TBX1 = 8;
TBY1 = 346;
TBX2 = 511;
TBY2 = 471;
//Location Identifiers
UNKNOWNID = 0;
GRAINFIELDID = 1;
BILLID = 2;
TOPOFMILLID = 3;
BOTTOMOFMILLID = 4;
MIDDLEOFMILLID = 5;
//The bottom of the text box coordinates
TBAX1 = 8;
TBAY1 = 440;
TBAX2 = 491;
TBAY2 = 460;
//This is the number of times to try something
EXTRALIVES = 3;
procedure DrawStar;
//This moves the mouse in a star pattern
var
XPoint,YPoint: TIntegerArray;
i: integer;
begin
Writeln('Trying to Mouse a star');
XPoint := [281,375,302,333,260,216,199,110,192,281];
YPoint := [125,127,190,272,210,283,187,144,120,125];
for i:=0 to 9 do
begin
//MoveMouse(XPoint[i],YPoint[i]);
MMouse(XPoint[i],YPoint[i],MRAND,MRAND);
wait(200+random(20));
end;
end;
procedure AntiRandoms;
begin
try
FindNormalRandoms;
except
writeln('Find normal randoms had a problem!!');
end;
end;
procedure AntiBan;
//This proc preforms a random action
var
RandomNum, WorldNum, LoopCount: Integer;
Angle: Extended;
begin
Angle := rs_GetCompassAngleDegrees;
RandomNum := Random(1000);
if ( RandomNum < (CHANCE*10) ) then
begin
RandomNum := Random(11);
Case RandomNum of
0: begin //Do a world switch
if ( ENABLEWORLDSWITCH ) then
begin
Writeln('Trying to switch worlds');
ExitToLobby;
Wait(300+random(1500));
WorldNum := RandomWorld(false,false);
LobbyTab(2);
SelectWorld(WorldNum);
writeln('Picking world '+ tostr(WorldNum));
wait(300+random(300));
LogInPlayer;
LogInPlayer; //FailSafe
end;
end;
1: begin //Click in a random direction
writeln('Trying a random click');
Mouse(Random(MSX2),Random(MSY2),0,0,false);
end;
2: begin //move change the camera angle
Writeln('Trying Random camera angle');
SetAngle(false);
wait(random(2000));
SetAngle(true);
end;
3: begin //Investigate a stat
Writeln('Trying investigate stat');
HoverSkill('Random', False);
wait(random(3000)+200);
GameTab(25);
end;
4: begin //Sit down and rest for a minute
Writeln('Sitting down and resting');
SetRest;
wait(random(10000));
end;
5: begin //Check out your equipment
Writeln('Trying to check Equipment');
GameTab(26);
wait(random(3000));
GameTab(25);
end;
6: begin //Move the mouse around randomly
Writeln('Moving mouse randomly');
RandomNum := random(15);
for LoopCount := 0 to RandomNum do
begin
MoveMouse(Random(MSX2),Random(MSY2));
wait(300+random(200));
end;
end;
7: begin //Do nothing for a minute
Writeln('Doing nothing for a bit');
wait(random(15000)+200);
end;
8: begin //Move mouse in star pattern on screen
DrawStar;
end;
9: begin //Change Camera Orentation
Writeln('Trying to play with camera');
if ( Random(2) > 0 ) then
begin
SetAngle(false);
MakeCompass('rand');
wait(3000+random(3000));
end;
MakeCompass('rand');
wait(3000+random(3000));
//Return to the starting position
SetAngle(true);
MakeCompass(Angle);
end;
10: begin //Check friends list to see who's on
Writeln('Trying to investiage friends list');
GameTab(30);
wait(3000+random(3000));
GameTab(25);
end;
11: begin //report abuse on some random name but then chicken out and abort
end;
end;
end;
end;
procedure DropGrain;
//Drops all grain in inventory
var
GrainDTM,SmallGrainDTM: Integer; //DTM of grain in inventory
x,y: Integer;
begin
SmallGrainDTM := DTMFromString('m1gAAAHic42JgYJjKxMAwAYgnAfE0IJ4JZfcyQeRmQMUeA9U+AuJbQHwDiO8D8QsofgnEz6DyDAxMRGLiACORGAEAuKUO3w==');
GrainDTM := DTMFromString('mAAEAAHiclcs7CoBQDETRybMQQdHCXbogazdhY+MHRVySIHqFFJa+gUOYkOSSpiAt2HBgx4oZIwb0Pl+pSSd/lzN6hhI1ClS+S9C1DVfht1txsUjfPERCD00=');
writeln('Trying to drop all grain');
while ( CountGrain > 0 ) do
begin
if not(FindDTM(GrainDTM,x,y,MIX1,MIY1,MIX2,MIY2)) then
FindDTM(SmallGrainDTM,x,y,MIX1,MIY1,MIX2,MIY2);
Mouse(x,y,MRAND,MRAND,false);
wait(200+random(100));
ChooseOption('rop');
wait(650+random(100));
end;
FreeDTM(GrainDTM);
FreeDTM(SmallGrainDTM);
end;
function InTopMill: Boolean;
//This function is a back up method of finding the top of the mill, it is assumed
// the InMiddleMill has been called and returned true
var
GrainBagColors: TIntegerArray;
ObjectLocation: TPoint;
TempTPA, TotalTPA: TPointArray;
MyATPA: T2DPointArray;
i,num: integer;
x,y:integer;
begin
GrainBagColors := [6789796,6263449,4883084,6129807,6066586,613151,5672085,5211277];
num := 7;
//Okay we are lookin for a grain bag blob
Writeln('Trying to find top mill with back up method');
//Find the colors
for i := 0 to num do
begin
FindColorsSpiralTolerance(x,y,TempTPA,GrainBagColors[i],MSX1,MSY1,MSX2,MSY2,3);
TotalTPA := CombineTPA(TotalTPA, TempTPA);
end;
//Form the Blob
MyATPA := SplitTPAEx(TotalTPA, 10, 10);
SortATPASize(MyATPA, True);
//The first one in the list should be the bag, if it exists
//check the size of the blob
try
ObjectLocation := MiddleTPA(MyATPA[0]);
//368,173-441,238
// Modified R13 to be broader
if ((ObjectLocation.x > 368)and(ObjectLocation.x < 460)and(ObjectLocation.y > 173)and(ObjectLocation.y < 210)) then
begin
Writeln('In Top Mill!!');
Result := true;
end else
Result := false;
except
Writeln('Failed to find any Grain Bag Colors');
Result := false;
end;
end;
function InMill() : Boolean;
//Uses TPA on the main screen to find the floor and sees if the player is in
// the color area
var
x,y: LongInt;
TempTPA, TotalTPA: TPointArray;
MyATPA: T2DPointArray;
i, num: integer;
Color: Array [0..7] of integer;
BlobBox: TBox;
Area: integer;
begin
num := 7;
Color[0] := 1720403;
Color[1] := 1588303;
Color[2] := 1455944;
Color[3] := 1720662;
Color[4] := 1522253;
Color[5] := 1521737;
Color[6] := 1389636;
Color[7] := 1522251;
Writeln('Trying to find mill');
//Find the colors
for i := 0 to num do
begin
FindColorsSpiralTolerance(x,y,TempTPA,Color[i],MSX1,MSY1,MSX2,MSY2,2);
TotalTPA := CombineTPA(TotalTPA, TempTPA);
end;
//Form the Blob
MyATPA := SplitTPAEx(TotalTPA, 150, 150);
SortATPASize(MyATPA, True);
//The first one in the list should be the mill, if it exists
//check the size of the blob
try
BlobBox := GetTPABounds(MyATPA[0]);
Area := (BlobBox.X2 - BlobBox.X1)*(BlobBox.Y2 - BlobBox.Y1);
writeln('The Blob bounds '+ tostr(BlobBox));
Writeln('Blob Area ' + tostr(Area));
if ( Area > 38000 ) then
begin
Writeln('In Mill!!');
Result := true;
end else
Result := false;
except
Writeln('Failed to find any Mill Colors');
Result := false;
end;
end;
function NextToBill: Boolean;
//Uses TPA on the main screen to find the floor and sees if the player is in
// the color area
var
x,y: LongInt;
TempTPA, TotalTPA: TPointArray;
MyATPA: T2DPointArray;
i, num: integer;
Color: Array [0..7] of integer;
BlobBox: TBox;
Area: integer;
CenterPoint: TPoint;
begin
num := 7;
Color[0] := 9144453;
Color[1] := 7565422;
Color[2] := 7697008;
Color[3] := 16449010;
Color[4] := 8815488;
Color[5] := 6710370;
Color[6] := 5723476;
//Added with R16
Color[7] := 6249562;
Writeln('Trying to find Beefy Bill"s Cart');
//Find the colors
for i := 0 to num do
begin
FindColorsSpiralTolerance(x,y,TempTPA,Color[i],MSX1,MSY1,MSX2,MSY2,2);
TotalTPA := CombineTPA(TotalTPA, TempTPA);
end;
//Form the Blob
MyATPA := SplitTPAEx(TotalTPA, 8, 8);
SortATPASize(MyATPA, True);
//The first one in the list should be the mill, if it exists
//check the size of the blob
try
BlobBox := GetTPABounds(MyATPA[0]);
Area := (BlobBox.X2 - BlobBox.X1)*(BlobBox.Y2 - BlobBox.Y1);
writeln('The Blob bounds '+ tostr(BlobBox));
Writeln('Blob Area ' + tostr(Area));
if ( Area > 390 ) then
begin
Writeln('Next to bill!!');
//R13 add shift to left of cart click
if ( Area < 1200 ) then
begin
CenterPoint := MiddleTPA(MyATPA[0]);
Mouse(CenterPoint.x-70,CenterPoint.y,MRAND,MRAND,true);
FFlag(10);
end;
Result := true;
end else
Result := false;
except
Writeln('Failed to find any cart Colors');
Result := false;
end;
end;
function InMiddleMill: Boolean;
//Uses TPA on the main screen to find the floor and sees if the player is in
// the color area
var
x,y: LongInt;
TempTPA, TotalTPA: TPointArray;
MyATPA: T2DPointArray;
i, num: integer;
Color: Array [0..8] of integer;
BlobBox: TBox;
Area: integer;
begin
num := 8;
Color[0] := 4805726;
Color[1] := 4410967;
Color[2] := 3884108;
Color[3] := 4674140;
Color[4] := 4213331;
Color[5] := 3950158;
Color[6] := 4081745;
Color[7] := 4279381;
Color[8] := 3818315;
Writeln('Trying to find Middle mill');
//Find the colors
for i := 0 to num do
begin
FindColorsSpiralTolerance(x,y,TempTPA,Color[i],MSX1,MSY1,MSX2,MSY2,2);
TotalTPA := CombineTPA(TotalTPA, TempTPA);
end;
//Form the Blob
MyATPA := SplitTPAEx(TotalTPA, 8, 8);
SortATPASize(MyATPA, True);
//The first one in the list should be the mill, if it exists
//check the size of the blob
try
BlobBox := GetTPABounds(MyATPA[0]);
Area := (BlobBox.X2 - BlobBox.X1)*(BlobBox.Y2 - BlobBox.Y1);
writeln('The Blob bounds '+ tostr(BlobBox));
Writeln('Blob Area ' + tostr(Area));
//Area size reduced from 30000 to 28000 in rev 13
if ( Area > 28000 ) then
begin
Writeln('In middle Mill!!');
Result := true;
end else
Result := false;
except
Writeln('Failed to find any middle Mill Colors');
Result := false;
end;
end;
function InGrainField():Boolean;
//Uses TPA on the main screen to find the floor and sees if the player is in
// the color area, and if that fails it tries to collect grain to prove in field
var
x,y: LongInt;
TempTPA, TotalTPA: TPointArray;
MyATPA: T2DPointArray;
i, num: integer;
Color: Array [0..5] of integer;
BlobBox: TBox;
Area: integer;
begin
num := 5;
Color[0] := 5873568;
Color[1] := 5081739;
Color[2] := 4487546;
Color[3] := 6855828;
Color[4] := 4883589;
Color[5] := 5142128;
Writeln('Trying to find Grain Field');
//Find the colors
for i := 0 to num do
begin
FindColorsSpiralTolerance(x,y,TempTPA,Color[i],MSX1,MSY1,MSX2,MSY2,2);
TotalTPA := CombineTPA(TotalTPA, TempTPA);
end;
//Form the Blob
MyATPA := SplitTPAEx(TotalTPA, 15, 15);
SortATPASize(MyATPA, True);
//The first one in the list should be the Grain Field, if it exists
//check the size of the blob
try
BlobBox := GetTPABounds(MyATPA[0]);
Area := (BlobBox.X2 - BlobBox.X1)*(BlobBox.Y2 - BlobBox.Y1);
writeln('The Blob bounds '+ tostr(BlobBox));
Writeln('Blob Area ' + tostr(Area));
if ( Area > 80000 ) then
begin
Writeln('In Grain Field!!');
Result := true;
end else
begin
Result := false;
if ( Area > 40000) then
begin
//Check to see if I can pick wheat
if ( Area < 80000) then
begin
if ( FindObjEx(x,y,['ick','heat'],Color,23,20,MSX1,MSY1,MSX2,MSY2) ) then
begin
num := CountGrain;
Mouse(x,y,MRAND,MRAND,true);
i := 0;
while (CountGrain = num)and(i<(500)) do
begin
wait(10);
inc(i);
if (FindText(x,y,'t reach that',SmallChars,TBAX1,TBAY1,TBAX2,TBAY2)) then
Break;
end;
if (CountGrain > num) then
Result := true;
end;
end else
Result := true;
end;
end;
except
Writeln('Failed to find any Grain Field Color');
Result := false;
end;
end;
procedure ColorWalk( Color: Array of Integer; num, tolerance: integer );
//This procedure finds the biggest color blob on the Main screen and click it
//The mill and the grain field would make nice blobs to click
var
x,y: LongInt;
TempTPA, TotalTPA: TPointArray;
MyATPA: T2DPointArray;
i: integer;
BlobBox: TBox;
Area: integer;
Location: TPoint;
begin
Writeln('Trying to find mill');
//Find the colors
for i := 0 to num do
begin
FindColorsSpiralTolerance(x,y,TempTPA,Color[i],MSX1,MSY1,MSX2,MSY2,tolerance);
TotalTPA := CombineTPA(TotalTPA, TempTPA);
end;
//Form the Blob
try
MyATPA := SplitTPAEx(TotalTPA, 8, 8);
SortATPASize(MyATPA, True);
//The first one in the list should be, if it exists
//check the size of the blob
BlobBox := GetTPABounds(MyATPA[0]);
Area := (BlobBox.X2 - BlobBox.X1)*(BlobBox.Y2 - BlobBox.Y1);
writeln('The Blob bounds '+ tostr(BlobBox));
Writeln('Blob Area ' + tostr(Area));
//Click the location
Location := MiddleTPA(MyATPA[0]);
//Click it
Writeln('Clicking Location');
Mouse(Location.x, Location.y, MRAND,MRAND,true);
except
Writeln('Failed to find any blob colors');
end;
end;
procedure GetIntoGrainField;
//This procedure clicks on the color of the grain to get in the field
var
GrainColors: Array[0..5] of Integer;
x,y,num: integer;
begin
num := 5;
GrainColors[0] := 5873568;
GrainColors[1] := 5081739;
GrainColors[2] := 4487546;
GrainColors[3] := 6855828;
GrainColors[4] := 4883589;
GrainColors[5] := 5142128;
ColorWalk(GrainColors,num,8);
//This is a back up to get into the field
if (FindObjEx(x,y,['ick'],GrainColors,30,20,MSX1,MSY1,MSX2,MSY2)) then
begin
Mouse(x,y,MRAND,MRAND,true);
end;
wait(3300+random(200));
end;
function DistanceToDTM ( var DTM: Integer ): Extended;
//This function determines the distance Between them middle of the mini map
//to some point on it
var
x,y: LongInt;
begin
//First find the DTM
if (FindDTM(DTM,x,y,MMX1,MMY1,MMX2,MMY2)) then
begin
WriteLn('Found DTM Position');
Result := sqrt(sqr((MMX2-MMX1)/2 + MMX1 - x) + sqr((MMY2-MMY1)/2 + MMY1 - y));
WriteLn('The distance is ' + ToStr(Result));
end else
begin
WriteLn('Failed to find DTM');
Result := -1;
end;
end;
function DTMWalk(var DTM: Integer; tolerance: Extended): Boolean;
//This function attempts to use the minimap to walk to a specified dtm
// and to reach the dtm within a specific tolerance
var
x,y: LongInt;
LoopCount: integer;
Angle, CalcAngle, PreviousDist, CurrentDist: Extended;
begin
//This will try 15 times to get to the correct location on the minimap
CalcAngle := rs_GetCompassAngleRadians;
Angle := 0;
Result := false;
PreviousDist := 0;
LoopCount := 0;
while (not(Result) and (LoopCount < 23)) do
begin
//if (FindDTM(DTM,x,y,MMX1,MMY1,MMX2,MMY2)) then
if (FindDTMRotated(DTM,x,y,MMX1,MMY1,MMX2,MMY2,-pi/85+CalcAngle,pi/85+CalcAngle,pi/900,Angle)) then
begin
//See how far off i am
CurrentDist := DistanceToDTM(DTM);
if ( CurrentDist < tolerance ) then
begin
Writeln('Location Reached');
Result := true;
end else
begin
WriteLn('Tolerance not met, trying again');
Result := false;
end;
//If i am getting closer then dont bother clicking
if ( CurrentDist >= PreviousDist ) then
begin
Mouse(x,y,MRAND,MRAND,true);
end;
PreviousDist := CurrentDist;
end else
begin
Writeln('Failed to find DTM on MiniMap');
Result := false;
end;
LoopCount := LoopCount + 1;
wait(500+random(50));
end;
end;
procedure GetIntoMill;
//This function gets into the mill using colorwalk
var
num: integer;
Color: Array [0..4] of Integer;
begin
num := 4;
Color[0] := 1720403;
Color[1] := 1588303;
Color[2] := 1455944;
Color[3] := 1720662;
Color[4] := 1522253;
//Step into mill
ColorWalk(Color,num,2);
end;
function FindObjectDoors(Color: TIntegerArray): Boolean;
//This function determines if a door or gate is open by finding the object on
// screen using the findobject function and returns true if the door is open
var
x,y: integer;
//LoopCount: integer;
Text: TStringArray;
Tol, Step: integer;
begin
Tol := 2;
Step := 50; //This is a recomended value from the documentation
Text := ['oor','ate','pen','ose']; //These are possible uptexts for the gates
//and doors
Result := false;
//for LoopCount := 0 to 1 do
//begin
if (FindObjEx(x, y, Text, Color, Tol, Step, MSX1, MSY1, MSX2, MSY2)) then
begin
Writeln('Found gate or door');
MoveMouse(x,y);
if ( WaitUpText('pen',800) ) then
begin
Writeln('Found Closed door');
Mouse(x,y,MRAND,MRAND,false);
if ( ChooseOption('pen') ) then
begin
Writeln('Opening door');
Result := true;
end;
end else
begin
Writeln('Door seems open');
Result := true;
end;
end;
//end;
end;
function DTMDoors(var OpenDTM, ClosedDTM: Integer): Boolean;
//This function determines if a door is open,
// if the door is shut it attempts to open it
var
x,y: LongInt;
LoopCount, i: Integer;
delta: Integer;
Angle, CalcAngle: Extended;
begin
CaLcAngle := rs_GetCompassAngleRadians;
LoopCount := 0;
delta := 2;
//while (not(FindDTM(OpenDTM,x,y,MSX1,MSY1,MSX2,MSY2)) and (LoopCount < 10)) do
while (not(FindDTMRotated(OpenDTM,x,y,MSX1,MSY1,MSX2,MSY2,-pi/85+CalcAngle,pi/85+CalcAngle,pi/900,Angle)) and (LoopCount < 10)) do
begin
//if (FindDTM(ClosedDTM,x,y,MSX1,MSY1,MSX2,MSY2)) then
if (FindDTMRotated(ClosedDTM,x,y,MSX1,MSY1,MSX2,MSY2,-pi/85+CalcAngle,pi/85+CalcAngle,pi/900,Angle)) then
begin
WriteLn('ClosedDTM Found, attempting to open');
//Try to open door by checking an area around the DTM for the uptext
//MoveMouse(x,y);
MMouse(x,y,MRAND,MRAND);
for i := 0 to 4 do
begin
Case i of
0: begin
MoveMouse(x,y);
wait(350);
if ( IsUpText('pen') ) then
begin
Mouse(x,y,0,0,true);
Break;
end;
end;
1: begin
MoveMouse(x+delta,y);
wait(350);
if ( IsUpText('pen') ) then
begin
Mouse(x+delta,y,0,0,true);
Break;
end;
end;
2: begin
MoveMouse(x-delta,y);
wait(350);
if ( IsUpText('pen') ) then
begin
Mouse(x-delta,y,0,0,true);
Break;
end;
end;
3: begin
MoveMouse(x,y+delta);
wait(350);
if ( IsUpText('pen') ) then
begin
Mouse(x,y+delta,0,0,true);
Break;
end;
end;
4: begin
MoveMouse(x,y-delta);
wait(350);
if ( IsUpText('pen') ) then
begin
Mouse(x,y-delta,0,0,true);
Break;
end;
end;
end;
end;
end else
begin
Writeln('Failed to found ClosedDTM');
end;
wait(450+random(100));
LoopCount := LoopCount+1;
end;
//See if the gate is open
if (FindDTM(OpenDTM,x,y,MSX1,MSY1,MSX2,MSY2)) then
begin
Writeln('Object seems to be open');
Result := true;
end else
begin
Writeln('Failed to find open object');
Result := false;
end;
end;
function VerifyLocation: Integer;
//Function Checks the mini-map and main screen
// to see if it can identify where the character is located
// R12 added logic to close bank/Beefy bill store window
var
TopOfMillDTM, MiddleOfMillDTM: Integer;
x,y: Integer;
Angle: Extended;
CalcAngle: Extended;
XBMP, LoopCount: integer;
begin
CalcAngle := rs_GetCompassAngleDegrees;
if ( (CalcAngle > 15) and (CalcAngle < 345) ) then
begin
MakeCompass(-15+random(30));
wait(100);
end;
XBMP := BitmapFromString(12, 12, 'meJw9j10LAVEURX+DNJJMGaFMUc' +
'qbyAMpTUa+RiNJCKHwICV59q8t7Tq1ut2zz777nHt4f+Pra3y4z89' +
'PTohOD11EsD5aa7i7Akov3nKClQpJJB0IN5f+ci+DFHnIwZZ00iAb' +
'z1UChs50ZUMlOumsgaE9imFx+/BW+Sk3b/C8G63lYRZdbOAW/IxX5' +
'ARCNEge5aDnShWDUgbLke6Vq+jARWBoDSJ+wX/zfg1YQGuAFDzNcE' +
'YIHlpaAChtW2gEEyk2+h8+jICWqHf6P3rifAM=');
if (FindBitmapSpiral(XBMP,x,y,MSX1,MSY1,MSX2,MSY2)) then
begin
Mouse(x,y,MRAND,MRAND,true);
end;
FreeBitmap(XBMP);
SetAngle(true);
CalcAngle := rs_GetCompassAngleRadians;
//Where am I?
TopOfMillDTM := DTMFromString('m6wAAAHic42ZgYKhgYmCoBeImIG6BYpBYARDnAnExlF8JxGFA9d5AHADEoUAcDcRJQBwHxEFA7AOVB4mHeDgwfH7/EYw/fX2JQiOLg7A4UD2xmIkEjAQA0OQnIA==');
//TopOfMillDTM := DTMFromString('mwQAAAHic42RgYKhkYmCoAOIGIG4F4iogLoDiSUAcA8JAdclAnADEYUDsDcRxQOwPxBFQsQ/P/oLxx3dfUNggzMzABsbiQHWEMDMRGA4A49YcNg==');
MiddleOfMillDTM := DTMFromString('m6wAAAHic42ZgYKhiYmCoAOI6IG6B4gaoWAEQ5wFxERDnAnE4UL03EPsAcRAQRwJxPBAnAXEcEAcCsS8QhwFxjL8Hw+tXbxk+vvsExjA2shgIR+pwMogD1ROLmUjASAAA2HMkuw==');
Result := UNKNOWNID;
LoopCount := 0;
while (Result = UNKNOWNID)and(LoopCount<EXTRALIVES) do
begin
MakeCompass('n');
if ( InGrainField ) then
begin
WriteLn('Found Grain Field!!');
Result := GRAINFIELDID;
end else if ( NextToBill ) then
begin
WriteLn('Found Bill cart');
Result := BILLID;
end else if ( InMill ) then
begin
WriteLn('Found Bottom of Mill');
Result := BOTTOMOFMILLID;
end else if ( FindDTMRotated(TopOfMillDTM,x,y,MMX1,MMY1,MMX2,MMY2,-pi/85+CalcAngle,pi/85+CalcAngle,pi/900,Angle) ) then
begin
WriteLn('Found Top of Mill');
Result := TOPOFMILLID;
end else if ( InMiddleMill ) then //Blob finding isnt unique enough to be reliable
//end else if ( FindDTMRotated(MiddleOfMillDTM,x,y,MMX1,MMY1,MMX2,MMY2,-pi/85+CalcAngle,pi/85+CalcAngle,pi/900,Angle) ) then
begin
if (InTopMill) then
begin
Writeln('Found Top of Mill using backup method');
end else
begin
WriteLn('Found Middle of Mill');
Result := MIDDLEOFMILLID;
end;
end else
begin
WriteLn('Unknown Location');
Result := UNKNOWNID;
end;
Inc(LoopCount);
end;
FreeDTM(TopOfMillDTM);
FreeDTM(MiddleOfMillDTM);
end;
function PickGrain: Boolean;
//This function fills the inventory with 20 grain
var
Count, LoopCount: integer;
x,y: LongInt;
PreviousCount: integer;
Color: Array[0..5] of integer;
RandomNum: integer;
begin
writeln('Picking grain');
SetAngle(true);
MakeCompass('n');
Color[0] := 5873568;
Color[1] := 5081739;
Color[2] := 4487546;
Color[3] := 6855828;
Color[4] := 4883589;
Color[5] := 5142128;
Count := CountGrain;
LoopCount := 0;
RandomNum := random(6);
PreviousCount := 0;
Count := CountGrain;
//I don't think I need to location check again do I?
while (( Count < 20 )and (LoopCount < 30) and not(invfull)) do
begin
//find the grain color
if ( FindObjEx(x,y,['ick','heat'],Color,10,50,MSX1,MSY1,MSX2,MSY2)) then
//if (FindColorSpiralTolerance(x,y,Color[RandomNum],MSX1,MSY1,MSX2,MSY2,9)) then
begin
//Click the grain
Mouse(x,y,MRAND,MRAND,true);
writeln('Grain Found at ( '+ tostr(x) + ', ' + tostr(y) + ' )' );
Wait(3000+random(200));
end;
//PreviousCount := Count;
Count := CountGrain;
writeln('Collected ' + tostr(Count) + ' grain');
LoopCount := LoopCount+1;
AntiBan;
end;
Result := ((CountGrain) > 19);
end;
function CountGrain: Integer; //counts grain in inventory
var
GrainDTM, SmallGrainDTM: Integer; //DTM of grain in inventory
begin
SmallGrainDTM := DTMFromString('m1gAAAHic42JgYJjKxMAwAYgnAfE0IJ4JZfcyQeRmQMUeA9U+AuJbQHwDiO8D8QsofgnEz6DyDAxMRGLiACORGAEAuKUO3w==');
GrainDTM := DTMFromString('mAAEAAHiclcs7CoBQDETRybMQQdHCXbogazdhY+MHRVySIHqFFJa+gUOYkOSSpiAt2HBgx4oZIwb0Pl+pSSd/lzN6hhI1ClS+S9C1DVfht1txsUjfPERCD00=');
Result := CountItems('dtm', GrainDTM, [0, 0]);
if (Result = 0) then
Result := CountItems('dtm', SmallGrainDTM, [0, 0]);
FreeDTM(GrainDTM);
FreeDTM(SmallGrainDTM);
end;
function CountFlour: Integer;
//Counts Flour in inventory
// R15 Updated
var
FlourDTM,SmallFlourDTM: Integer;
begin
SmallFlourDTM := DTMFromString('mAAEAAHic42FgYMhiguB0IM4D4mwgTgTiIiAuBuICKD8NiJOAmIORgYERiv8C9QswQsRYgZgbiPmBmIcRIs4CxIX+hgy7Nm1iuHrmNFA1E0EsDiRhmBjASCJGBgD7eAxf');
FlourDTM := DTMFromString('mPwEAAHicpcuxDUBgEIbhYwGlOUxiFmMQBQkiGj8aG4mgUYhIKCzAW/yVDl/y3FfcnSUiqSmSo0SNBgoFYgTwdYeIkCDDwn+HETM2HDi1HaveTej1/QDPdZjma22l5JJvsWH88MgNPzAaXA==');
Result := CountItems('dtm', FlourDTM, [0, 0]);
if (Result = 0) then
begin
Result := CountItems('dtm', SmallFlourDTM, [0, 0]);
end;
Writeln('We have ' + tostr(Result) + ' flour');
FreeDTM(FlourDTM);
FreeDTM(SmallFlourDTM);
end;
function HandleGateDoor( Gate: Boolean ): Boolean;
//This function handles all the gates and doors
// if Gate is true then it checks for gates otherwise it checks for doors
var
GrainGateColors, MillDoorColors: TIntegerArray;
begin
GrainGateColors := [38885913,4215135,4280929,4741996,4412515,4017499,4215135];
MillDoorColors := [2172459,1778216,2502969,2896697,3028284];
//Now decide which to do
if ( Gate ) then
begin
Result := FindObjectDoors( GrainGateColors );
end else
begin
Result := FindObjectDoors( MillDoorColors );
end;
wait(2500+random(1000));
end;
function Walk2Mill: Boolean;
//here we will walk to the mill to grind the grain
var
x,y: LongInt;
Next2GateDTM, MillDTM: integer;
Angle: Extended;
Count: Integer;
LoopCount: Integer;
begin
writeln('Walking to gate');
MakeCompass('n');
SetAngle(true);
//Next2GateDTM := DTMFromString('mFQEAAHic42VgYJjGxMDQD8TdQDwJiGcA8Wwgng/ES4B4IRA3A3EfEM8B4nlAXAvU1wzEFUBcBMSdQFwMxC1AXA7EuUDcCsQTgDgTiLuA2NpWi+FwuTDD/hXRYBrGtnawYfAP8WOwtFZmePf5Ixw/ef+SQRyoj1TMRAZGAQCVfiTl');
Next2GateDTM := DTMFromString('mggAAAHicY2NgYOhnYmCYA8SzgbgOiLuAeCIQ5wDl0oC4DIjzgNgJiP2A+FilEMP3n9/B+OPXD3C2OFAOG2bCgSEAAI3SFhE=');
MillDTM := DTMFromString('mwQAAAHic42RgYHBjYmAIAeJIILYEYgcg9gViayD2B+IkIG4BqmsH4iogbgDiXiDuh4o1AnEdEAeFBDG8//gZTNvZqoNpAz0FBmcnLQZffz+GZ58/MIgD1RHCTERgOAAA8WwThg==');
for LoopCount := 0 to EXTRALIVES do
begin
//move through field to gate
//DTMWalk(Next2GateDTM, 6);
SPS_WalkToPos(Point(4470, 3466));
//Find the Gate and Open it
WriteLn('Checking for gate');
if not(HandleGateDoor( true )) then
writeln('Could not find door');
//Walk to mill door
//if (DTMWalk(MillDTM, 7))then
if SPS_WalkToPos(Point(4484, 3431)) then
Break;
end;
FreeDTM(Next2GateDTM);
for LoopCount := 0 to EXTRALIVES do
begin
//Now get through the door
HandleGateDoor( false );
wait(2000+random(250));
GetIntoMill;
wait(3000+random(300));
if ( InMill ) then
begin
Break;
end else
begin
Writeln('Not in mill, maybe doors didnt open try them again');
DTMWalk(MillDTM, 7);
end;
end;
FreeDTM(MillDTM);
Result := InMill;
end;
function ClimbUpMill: Boolean;
//Climb to top of mill to grind the grain
var
Ladder1DTM, Ladder2DTM: Integer;
x,y: LongInt;
LoopCount: integer;
begin
MakeCompass('n');
SetAngle(True);
//Ladder1DTM := DTMFromString('mlwAAAHicY2dgYDgGxEeB+BIQnwLii0B8CIj3A7EEEOsCsRgQc0MxL1RcX0sFjGvKsxmm9oQxFGQnMliZ6DKY6muC1eDCTHgwFAAAHnMMsw==');
Ladder1DTM := DTMFromString('mWAAAAHicY2FgYLgBxNeAeBEQOzIyMCwG0jVAPAeIZwOxqb4Gg7mhNkN3WwVDb3s7gzhQDBkzomEQAAAhtAmQ');
//If I am on the ground floor then climb
LoopCount := 0;
while (InMill)and(LoopCount<EXTRALIVES) do
begin
//FindDTM(Ladder1DTM,x,y,MSX1,MSY1,MSX2,MSY2);
if FindObjDTM(x,y,Ladder1DTM,'limb') then
begin
Mouse(x,y,MRAND,MRAND,false);
ChooseOption('up');
end;
wait(1500+random(100));
Inc(LoopCount);
end;
FreeDTM(Ladder1DTM);
//Ladder2DTM := DTMFromString('m1gAAAHic42JgYLgHxC+g9A0gvgvEz4H4DRA/hNKfgXgJEC8D4glAvBCItwDxBijeCpWfDcSm+poME9pDwLSFkTaDroYSw8KZ6Qx1lTkM+loqDEW5SQxBnvYM/EC1xGAmIjECAACz3RlR');
Ladder2DTM := DTMFromString('mWAAAAHicY2FgYHgAxHeA+DgQezIyMKwF0g1AvAaIM4HYVEeZwdxQm8Hd3pxhzeIiBnGgGDJmRMMgAAASDAkJ');
//If I am on the middle floor then climb
LoopCount := 0;
while ( (VerifyLocation = MIDDLEOFMILLID) and (LoopCount<EXTRALIVES) ) do
begin
//if (FindDTM(Ladder2DTM,x,y,MSX1,MSY1,MSX2,MSY2)) then
if FindObjDTM(x,y,Ladder2DTM,'limb') then
begin
Mouse(x,y,MRAND,MRAND,false);
ChooseOption('up');
end else
MMouse(0,0,MRAND,MRAND);
wait(1500+random(100));
LoopCount := LoopCount+1;
end;
FreeDTM(Ladder2DTM);
//Verify that I have reached the top floor
if ( VerifyLocation = TOPOFMILLID ) then
Result := true
else
Result := false;
end;
function FindObjDTM(var x,y,DTM: integer;Text: string): Boolean;
//This function finds an object using a dtm instead of a color
// used during grind grain to find hopper
var
Locs: TPointArray;
i,L: integer;
begin
result := false;
if (FindDTMs(DTM,Locs,MSX1,MSY1,MSX2,MSY2)) then
begin
writeln('Found some object DTMs');
L := Length(Locs);
writeln('There are '+tostr(L)+' Points to check');
//I should group the points
RAaSTPA(Locs,70);
L := Length(Locs);
writeln('There are '+tostr(L)+' Points to check after reduction');
//Now for all the points, mouse over and check the text
for i:= 0 to (L-1) do
begin
MMouse(Locs[i].x,Locs[i].y,MRAND,MRAND);
if WaitUpText(Text,350) then
begin
Result := true;
x := Locs[i].x;
y := Locs[i].y;
break;
end;
end;
end else
begin
writeln('Failed to find any DTMs for the object');
end;
end;
function CheckTP4Text(var x,y: integer; Text: string): Boolean;
//This function checks the point (x,y) for the text
begin
MMouse(x,y,MRAND,MRAND);
if (WaitUpText(Text,350) ) then
begin
GetMousePos(x,y);
Result := true;
end else
Result := false;
end;
function GrindGrain: Boolean;
//This procedure operates the grinding equip
// R16 added check last location
var
HopperDTM, LeverDTM, GrainDTM,
HopperColor, SmallGrainDTM: Integer;
x,y: LongInt;
LoopCount, FailCount: Integer;
i,delta: integer;
LastHopperTP, LastLeverTP: Tpoint;
FoundTP: Boolean;
begin
wait(1000+random(200));
MakeCompass('e');
SetAngle(true);
wait(1000+random(200));
delta := 2;
HopperColor := 921102;
//Set up DTMS
//HopperDTM := DTMFromString('mAAEAAHic42FgYPgLxD+B+AsQfwPi/0DMwsjAwAzETED8G8j/AVXzFYirgLgSihuAuAWIG6HipUBcAMQ5QJwOxCVAzMfHx2Brps/gbm8OxmnhrmC+lYkug5WhOoOagiSDi60pg5+bDYOnkyWDOFAPKZiJRIwMAFZMF1w=');
HopperDTM := DTMFromString('mWAAAAHicY2FgYNgKxIeBOBmINwFxHRB7AHElEJcBMR8fH0NTbQ1DZU4sg5KsOIMcUAwZM6FhEAAA0wMIBA==');
//LeverDTM := DTMFromString('mwQAAAHic42RgYHBiZGBwA+JAIA4AYj9GiJgDEDsCsQgQ1wHV1QBxFRA3AHELlG4CYl0g1gNiAy0Vho0Lyhimticz+DhbMbjbmzFYGGmD8alD6xkWzkhlEAeqI4QZicBwAADjAxFa');
LeverDTM := DTMFromString('mrAAAAHic42BgYPBiZGDwAOJwIHYB4iAg1mKEiKcDcTtQTQMUtzFA+OVAnAvERUDsYmPCsHpaPMO6eSUM5oZaDB4O5mDsZmfG4GhlxCAOVIMPMxHAMAAALscOqA==');
GrainDTM := DTMFromString('mAAEAAHiclcs7CoBQDETRybMQQdHCXbogazdhY+MHRVySIHqFFJa+gUOYkOSSpiAt2HBgx4oZIwb0Pl+pSSd/lzN6hhI1ClS+S9C1DVfht1txsUjfPERCD00=');
SmallGrainDTM := DTMFromString('m1gAAAHic42JgYJjKxMAwAYgnAfE0IJ4JZfcyQeRmQMUeA9U+AuJbQHwDiO8D8QsofgnEz6DyDAxMRGLiACORGAEAuKUO3w==');
//Set up last location
FindObjDTM(LastHopperTP.x,LastHopperTP.y,HopperDTM,'opper / 1 more');
FindObjDTM(LastLeverTP.x,LastLeverTP.y,LeverDTM,'pera');
LoopCount := 0;
//Loop through as long as I have grain
while (CountGrain > 0) and (LoopCount < 40) do
begin
//Force Camera angle fail safe
MakeCompass('e');
SetAngle(true);
LoopCount := LoopCount + 1; //Limit the number of tries
//Click the Grain
if not(FindDTM(GrainDTM,x,y,INVX1,INVY1,INVX2,INVY2)) then
begin
FindDTM(SmallGrainDTM,x,y,INVX1,INVY1,INVX2,INVY2);
end;
Mouse(x,y,MRAND,MRAND,true);
wait(1000+random(100));
//Click the Hopper
if not(CheckTP4Text(LastHopperTP.x,LastHopperTP.y,'opper / 1 more')) then
begin
if (FindObjDTM(LastHopperTP.x,LastHopperTP.y,HopperDTM,'opper / 1 more')) then
begin
FoundTP := true;
end else
begin
FoundTP := false;
end;
end else
FoundTP := true;
if (FoundTP) then
begin
Mouse(LastHopperTP.x,LastHopperTP.y,MRAND,MRAND,true);
FailCount := 0;
while ((not(FindText(x, y , 'opper',SmallChars ,TBAX1,TBAY1,TBAX2,TBAY2)) and (FindText(x, y , 'pera',SmallChars ,TBAX1,TBAY1,TBAX2,TBAY2))) and (FailCount < 500)) do
begin
FailCount := FailCount+1;
wait(10);
end;
wait(2800+random(300));
end else
Writeln('Failed to find Hopper');
//operate Controls
if not(CheckTP4Text(LastLeverTP.x,LastLeverTP.y,'pera')) then
begin
if (FindObjDTM(LastLeverTP.x,LastLeverTP.y,LeverDTM,'pera')) then
begin
FoundTP := true;
end else
begin
FoundTP := false;
end;
end else
FoundTP := true;
if (FoundTP) then
begin
//Try to find the lever by checking an area around the DTM for the uptext
Mouse(LastLeverTP.x,LastLeverTP.y,MRAND,MRAND,true);
FailCount := 0;
while (not(FindText(x, y , 'pera',SmallChars ,TBAX1,TBAY1,TBAX2,TBAY2)) and (FailCount < 500)) do
begin
wait(10);
FailCount := FailCount+1;
end;
//wait(1000+random(200));
end else
Writeln('Lever not found');
if (FindText(x, y , 'mpty',SmallChars ,TBAX1,TBAY1,TBAX2,TBAY2) and not(FindText(x, y , 'othin',SmallChars ,TBAX1,TBAY1,TBAX2,TBAY2))) then
begin
Writeln('The bin downstairs is full');
DropGrain;
end;
AntiBan;
end;
//Free the DTMS
FreeDTM(GrainDTM);
FreeDTM(LeverDTM);
FreeDTM(HopperDTM);
FreeDTM(SmallGrainDTM);
if (CountGrain > 0) then
begin
Writeln('Failed to grind all grain');
Result := false;
end else
Result := true;
end;
function ClimbDownMill: Boolean;
//This procedure climbs down the Mill
var
x,y: LongInt;
Ladder1DTM, Ladder2DTM: Integer;
begin
MakeCompass('n');
SetAngle(true);
//Verify that i am on the top floor
//Ladder1DTM := DTMFromString('m1gAAAHic42JgYHgIxa+A+D0QfwXi10D8BIhvAPFlIL4OxEuBeA4QzwXidUC8FoiXAPE2KB8kvxuIjXTUGJysjRmqyrIYXGxNGaICXBkqSjIYrAzVGdKSIhmy02IYNFXkGcSBaonBTERiBAAAtnMZWg==');
Ladder1DTM := DTMFromString('mbQAAAHicY2VgYLgHxLeB+CYQ2zMyMBwD0ilArAPEnUDsBsSJQGygpcqQFBfKYKytxNDZ3MzgamvKIAIUR8eMWDAYAADn7woh');
while ( VerifyLocation = TOPOFMILLID ) do
begin
//if (FindDTM(Ladder1DTM,x,y,MSX1,MSY1,MSX2,MSY2)) then
if (FindObjDTM(x,y,Ladder1DTM,'own')) then
begin
Mouse(x,y,MRAND,MRAND,false);
ChooseOption('own');
end else
Writeln('failed to find ladder');
end;
FreeDTM(Ladder1DTM);
//Ladder2DTM := DTMFromString('m1gAAAHic42JgYLgHxC+g9A0gvgvEz4H4DRA/hNKfgXgJEC8D4glAvBCItwDxBijeCpWfDcSm+poME9pDwLSFkTaDroYSw8KZ6Qx1lTkM+loqDEW5SQxBnvYM/EC1xGAmIjECAACz3RlR');
Ladder2DTM := DTMFromString('mWAAAAHicY2FgYHgAxHeA+DgQezIyMKwF0g1AvAaIM4HYVEeZwdxQm8Hd3pxhzeIiBnGgGDJmRMMgAAASDAkJ');
while ( VerifyLocation = MIDDLEOFMILLID ) do
begin
//if (FindDTM(Ladder2DTM,x,y,MSX1,MSY1,MSX2,MSY2)) then
if FindObjDTM(x,y,Ladder2DTM,'limb') then
begin
Mouse(x,y,MRAND,MRAND,false);
ChooseOption('own');
end else
begin
Writeln('failed to find ladder');
MMouse(0,0,MRAND,MRAND);
end;
end;
FreeDTM(Ladder2DTM);
Result := InMill;
end;
function Walk2Bill: Boolean;
//This walks from Mill to Beefy Bill
var
x,y: LongInt;
ExitDTM, Next2GateDTM, ToBillDTM: Integer;
LoopCount, MillDTM, RoadDTM: Integer;
begin
MakeCompass('n');
SetAngle(true);
ExitDTM := DTMFromString('m1gAAAHic42JgYGBkZGD4A6S5gLQgEH8Bsp8A8X0gvgnE16FsVqCcOBBLA7EYEPMB8Q+g+Hsgfg3ET4H4IRD3dVYzTGwPANMJMUEMC2d3M9RV5jBM6qljmDkxhmH6hGiGKX31DOJAtcRgJiIxAgAARvIbZw==');
Next2GateDTM := DTMFromString('m1gAAAHic42JgYJjGxMAwB4gXAfFCIF4MxFOBeCIQ9wJxK1RMG6jWFIqNgFgPiG2A2BKIjYFYBohVgDgkwAcFmxgqorBfffzB8OXDBwZxoFpiMBORGAEAD+IVPA==');
ToBillDTM := DTMFromString('mwQAAAHic42RgYKhiYmCoh2IQuwyIq6H8Mih2Y4BgBygGsb2QsBMQ7y00Y2i04WDYuGUbQ4q1MENdfT1DdYgEw4EDB4CyjGBaHMgihJmIwHAAAB8DE5c=');
//MillDTM was added on rev 9 = 8/23/11
MillDTM := DTMFromString('mwQAAAHic42RgYHBjYmAIAeJIILYEYgcg9gViayD2B+IkIG4BqmsH4iogbgDiXiDuh4o1AnEdEAeFBDG8//gZTNvZqoNpAz0FBmcnLQZffz+GZ58/MIgD1RHCTERgOAAA8WwThg==');
RoadDTM := DTMFromString('m1gAAAHic42JgYFjGBMGLgXgNEM8H4rVAPB2IJwBxAxBXA7EhUK03EGsAsREQ2wKxJRBrArE7EIcAcSQQB4UGMnz//QpMw7CLmyaDjZM8ipg4UC0xmIlIjAAAMDsUfw==');
for LoopCount := 0 to EXTRALIVES do
begin
//Get close to exit
SPS_WalkToPos(Point(4488, 3435));
if (FindDTM(ExitDTM,x,y,MSX1,MSY1,MSX2,MSY2)) then
Mouse(x,y,MRAND,MRAND,true);
wait(4000+random(100));
//Try to find door
HandleGateDoor( false );
if SPS_WalkPath([Point(4533, 3401), Point(4526, 3382)]) then
Break;
{//Walk Outside of the mill (This helps to find the next dtm)
DTMWalk(MillDTM,8);
//Walk down road
DTMWalk(RoadDTM,8);
//Walk near Beefy Bill's Gate
if (DTMWalk(Next2GateDTM,8)) then
begin
Break;
wait(700+random(300));
end;}
end;
FreeDTM(ExitDTM);
for LoopCount := 0 to EXTRALIVES do
begin
//Find the Gate
HandleGateDoor( true );
//StandNext to bill
{if ( DTMWalk(ToBillDTM,8)) then
Break;}
SPS_WalkToPos(Point(4535, 3361));
if ( NextToBill ) then
begin
wait(random(300)+1050);
break;
end;
end;
FreeDTM(Next2GateDTM);
FreeDTM(ToBillDTM);
FreeDTM(MillDTM);
FreeDTM(RoadDTM);
Result := NextToBill;
end;
function CountPots: Integer;
// R15 update included multiple pot note sizes
var
PotDTM, SmallPotDTM: Integer; //DTM of Pot in inventory
begin
//PotDTM := DTMFromString('m6wAAAHic42ZgYDAAYmMgtgBiGyi2hIrpALEqECtBsRsQm0PVuACxJxD7AXEQEAdC2R5A7AzE2d76QJKJKPyfgXjASAJGAgCvUAcz');
PotDTM := DTMFromString('mFQEAAHic42VgYMhhYmCIB+IUKF0AxBVQXATEGUCcwARRlwbE2UCsx8jAoAvE5kBsAMSWQGwExFpArADEckCsDsQqUKwIxEUBxkDbmAjiLBdFBitVIYYCfyMGcQbigDgSZiQDowAA9/0LYA==');
SmallPotDTM := DTMFromString('mFQEAAHic42VgYNAFYlMgVgFifShbC8rXA2I1IDaD8o2BWB2I3YDYAYjdgdgHiD2gtCMUewGxCxR7Q8WKA4yAJBNWnO2tjyHWGGXBIM6AG2CTA4kxkoFRAADCBQku');
Result := CountItems('dtm', PotDTM, [0, 0]);
{if (Result = 0) then
Result := CountItems('dtm',SmallPotDTM,[0,0]);}
writeln('We have '+tostr(Result)+' empty pots');
FreeDTM(PotDTM);
FreeDTM(SmallPotDTM);
end;
function BuyPots: Boolean;
//This exchanges pot notes for pot with beefy bill
// with R15 small DTM versions are needed
var
PotNoteDTM,SmallPotNoteDTM,
PotDTM, SmallPotDTM: Integer;
BeefyBillBMP: LongInt;
BillColor: Array[0..3] of integer;
x,y: LongInt;
XBMP: LongInt;
RandomNum, LoopCount: integer;
FailCount, Coin: integer;
begin
BillColor[0] := 5200725;
BillColor[1] := 6122596;
BillColor[2] := 5468565;
BillColor[3] := 9478823;
MakeCompass('n');
SetAngle(true);
RandomNum := random(4);
Result := false;
repeat
writeln('Searching for Bill');
if (FindColorSpiralTolerance(x,y,BillColor[RandomNum],MSX1,MSY1,MSX2,MSY2,2)) then
begin
//MoveMouse(x,y);
MMouse(x,y,MRAND,MRAND);
//wait(200+random(50));
if ( WaitUpText('ill',350) ) then
begin
writeln('Found Beefy Bill');
Mouse(x,y,0,0,false);
wait(10);
Result := ChooseOption('rade');
end;
end else
begin
wait(200+random(200));
end;
//He's found
LoopCount := LoopCount+1;
RandomNum := random(4);
until ( Result or (LoopCount > 50) );
wait(3000+random(200));
//PotNoteDTM := DTMFromString('mFQEAAHic42VgYMhhYmAoAuISIK6C4gogroTiciDOA+IMII6D4mdAfdeg+BYQP2KAiL0G4vdA/AmIP0LZ76ByuT4GQJKJJPyfgXTASAZGAQDXxROi');
PotNoteDTM := DTMFromString('mAAEAAHic42FgYHBiYmDwBmJnILaCYnMgNgFiGyB2BWJHIPaH4mdAPU+B+C0QPwfix0D8CIhfAfEHKP4IxG8YIGrzfAyAJBPRWI6BNMBIIkYGAE5JD08=');
SmallPotNoteDTM := DTMFromString('mwQAAAHic42RgYLBmYmCwAmIXIDYBYlcgtgNicyA2BWJnIH4AVPcEip8B8UMoDcIguedAXBpkDCSZ8GJxBsKAkQgMBwBLkwtn');
if not(FindDTM(PotNoteDTM,x,y,INVX1,INVY1,INVX2,INVY2)or(FindDTM(SmallPotNoteDTM,x,y,INVX1,INVY1,INVX2,INVY2))) then
begin
//I dont have any pot notes
writeln('There are no pot notes!!!')
Result := false;
//Close the window
XBMP := BitmapFromString(12, 12, 'meJw9j10LAVEURX+DNJJMGaFMUc' +
'qbyAMpTUa+RiNJCKHwICV59q8t7Tq1ut2zz777nHt4f+Pra3y4z89' +
'PTohOD11EsD5aa7i7Akov3nKClQpJJB0IN5f+ci+DFHnIwZZ00iAb' +
'z1UChs50ZUMlOumsgaE9imFx+/BW+Sk3b/C8G63lYRZdbOAW/IxX5' +
'ARCNEge5aDnShWDUgbLke6Vq+jARWBoDSJ+wX/zfg1YQGuAFDzNcE' +
'YIHlpaAChtW2gEEyk2+h8+jICWqHf6P3rifAM=');
FindBitmapSpiral(XBMP,x,y,MSX1,MSY1,MSX2,MSY2);
Mouse(x,y,MRAND,MRAND,true);
FreeBitmap(XBMP);
end;
if (CountPots < 10) then
begin
if ( Result ) then
begin
//Try to buy pot notes
if not FindDTM(PotNoteDTM,x,y,INVX1,INVY1,INVX2,INVY2) then
FindDTM(SmallPotNoteDTM,x,y,INVX1,INVY1,INVX2,INVY2);
FailCount := 0;
Coin := CoinAmount('inv');
while (CoinAmount('inv')<(Coin+20))and(FindDTM(PotNoteDTM,x,y,INVX1,INVY1,INVX2,INVY2))and(FailCount<EXTRALIVES) do
begin
Mouse(x,y,MRAND,MRAND,false);
ChooseOption('ell 10');
Inc(FailCount);
wait(1000+random(200));
end;
//Buy Back the sold pots
PotDTM := DTMFromString('m6wAAAHic42ZgYDAAYmMgtgBiGyi2hIrpALEqECtBsRsQm0PVuACxJxD7AXEQEAdC2R5A7AzE2d76QJKJKPyfgXjASAJGAgCvUAcz');
SmallPotDTM := DTMFromString('mFQEAAHic42VgYNAFYlMgVgFifShbC8rXA2I1IDaD8o2BWB2I3YDYAYjdgdgHiD2gtCMUewGxCxR7Q8WKA4yAJBNWnO2tjyHWGGXBIM6AG2CTA4kxkoFRAADCBQku');
if not FindDTM(PotDTM,x,y,MSX1,MSY1,MSX2,MSY2) then
FindDTM(SmallPotDTM,x,y,MSX1,MSY1,MSX2,MSY2);
FreeDTM(PotDTM);
FreeDTM(SmallPotDTM);
//I need to buy at least 20, if I have the money to continue buying
FailCount := 0;
while (CountPots < 20) and (CoinAmount('inv')>0) and (FailCount<EXTRALIVES) do
begin
Mouse(x,y,MRAND,MRAND,false);
ChooseOption('uy 10');
Inc(FailCount);
wait(1000+random(200));
end;
//Close the window
XBMP := BitmapFromString(12, 12, 'meJw9j10LAVEURX+DNJJMGaFMUc' +
'qbyAMpTUa+RiNJCKHwICV59q8t7Tq1ut2zz777nHt4f+Pra3y4z89' +
'PTohOD11EsD5aa7i7Akov3nKClQpJJB0IN5f+ci+DFHnIwZZ00iAb' +
'z1UChs50ZUMlOumsgaE9imFx+/BW+Sk3b/C8G63lYRZdbOAW/IxX5' +
'ARCNEge5aDnShWDUgbLke6Vq+jARWBoDSJ+wX/zfg1YQGuAFDzNcE' +
'YIHlpaAChtW2gEEyk2+h8+jICWqHf6P3rifAM=');
FindBitmapSpiral(XBMP,x,y,MSX1,MSY1,MSX2,MSY2);
Mouse(x,y,MRAND,MRAND,true);
FreeBitmap(XBMP);
end;
//FreeDTM(PotDTM);
end;
FreeDTM(PotNoteDTM);
FreeDTM(SmallPotNoteDTM);
end;
function WalkBill2Mill: Boolean;
//Walks from Bill to the mill to collect the flour
var
x,y: LongInt;
RoadDTM,MillDTM: Integer;
Next2GateDTM: Integer;
LoopCount: Integer;
begin
MakeCompass('n');
SetAngle(true);
//Move Close to gate
//Next2GateDTM := DTMFromString('m1gAAAHic42JgYEhkYmCIAWJXIPYB4jggzkHCYUBcD8SpQLWxQJwExIZA7ADE7iD9QFwLxNlAXAzEAb6qDKaJ4gyvn34B41B/fxQMExcHqiUGMxGJEQAANkgYwQ==');
Next2GateDTM := DTMFromString('mwQAAAHic42RgYIhhYmCIA+IMIA4G4homiFgeEGcBsQMQJwLVpQJxLZTOB2IbIHYD4jiQGUDsF6rC8P3nd4bgcD8wDWPDMIgvCVRHCDMRgeEAAL1FGAo=');
RoadDTM := DTMFromString('mwQAAAHic42RgYGhjYmCoB+JqIK4E4g4gngDEU6C4CYgrQOqAuAmIi4G4EIgLgLgKiBuBOBuIg0KC4FghTARMW9mqgWk3dx0wLQ5URwgzEYHhAADDNhGi');
MillDTM := DTMFromString('mwQAAAHic42RgYHBjYmAIAeJIILYEYgcg9gViayD2B+IkIG4BqmsH4iogbgDiXiDuh4o1AnEdEAeFBDG8//gZTNvZqoNpAz0FBmcnLQZffz+GZ58/MIgD1RHCTERgOAAA8WwThg==');
for LoopCount := 0 to EXTRALIVES do
begin
//DTMWalk(Next2GateDTM,7);
SPS_WalkToPos(Point(4519, 3369));
//RadialWalk(5394769,90,130,10,MRAND,MRAND);
HandleGateDoor( true );
{if (DTMWalk(RoadDTM,8)) then
Break;}
if SPS_WalkPath([Point(4527, 3372), Point(4527, 3384)]) then
Break;
end;
FreeDTM(Next2GateDTM);
FreeDTM(RoadDTM);
for LoopCount := 0 to EXTRALIVES do
begin
//Walk to mill door
DTMWalk(MillDTM,9);
HandleGateDoor( false );
GetIntoMill;
wait(2800+random(400));
if ( InMill ) then
Break;
end;
FreeDTM(MillDTM);
Result := InMill;
end;
function CollectFlour: Boolean;
//Places the flour into pots
var
x,y: LongInt;
FlourColor,LoopCount: Integer;
FoundFlour: Boolean;
begin
SetAngle(true);
MakeCompass('n');
FoundFlour := True;
FlourColor := 15858941;
x := 275;
y := 132;
//find the bin
LoopCount := 0;
while (CountFlour < 20) and FoundFlour and (CountPots>0)and(LoopCount<20) do
begin
if (FindColorSpiralTolerance(x,y,FlourColor,MSX1,MSY1,MSX2,MSY2,2)) then
begin
//MoveMouse(x,y);
MMouse(x,y,MRAND,MRAND);
if (IsUpText('ake')) then
begin
Mouse(x,y,MRAND,MRAND,true);
FoundFlour := true;
writeln('Found Flour');
wait(8000+random(1000));
end;
end
else
begin
FoundFlour := False;
Writeln('No flour found');
end;
Inc(LoopCount);
end;
Result := (CountFlour > 19);
end;
function DepositFlour: Boolean;
//Hands Beefy Bill the flour
var
FlourDTM, SmallFlourDTM, RandomNum: Integer;
BillColor: Array[0..3] of integer;
x,y: LongInt;
LoopCount: integer;
StartingFlour: integer;
begin
BillColor[0] := 5200725;
BillColor[1] := 6122596;
BillColor[2] := 5468565;
BillColor[3] := 9478823;
MakeCompass('n');
SetAngle(true);
RandomNum := random(4);
Result := false;
StartingFlour := CountFlour;
//Start by finding Flour Pot and click on bill
FlourDTM := DTMFromString('mPwEAAHicpcuxDUBgEIbhYwGlOUxiFmMQBQkiGj8aG4mgUYhIKCzAW/yVDl/y3FfcnSUiqSmSo0SNBgoFYgTwdYeIkCDDwn+HETM2HDi1HaveTej1/QDPdZjma22l5JJvsWH88MgNPzAaXA==');
SmallFlourDTM := DTMFromString('mAAEAAHic42FgYMhiguB0IM4D4mwgTgTiIiAuBuICKD8NiJOAmIORgYERiv8C9QswQsRYgZgbiPmBmIcRIs4CxIX+hgy7Nm1iuHrmNFA1E0EsDiRhmBjASCJGBgD7eAxf');
if not FindDTM(FlourDTM,x,y,INVX1,INVY1,INVX2,INVY2) then
FindDTM(SmallFlourDTM,x,y,INVX1,INVY1,INVX2,INVY2);
Mouse(x,y,MRAND,MRAND,true);
LoopCount := 0;
repeat
writeln('Searching for Bill');
if (FindColorSpiralTolerance(x,y,BillColor[RandomNum],MSX1,MSY1,MSX2,MSY2,2)) then
begin
//MoveMouse(x,y);
MMouse(x,y,MRAND,MRAND);
if ( WaitUpText('ill',2000) ) then
begin
writeln('Found Beefy Bill');
Mouse(x,y,MRAND,MRAND,true);
wait(1800+random(400));
end else
begin
wait(400+random(100));
end;
if (FindText(x,y,'ank ',NPCChars,MCX1,MCY1,MCX2,MCY2)) then
begin
Mouse(x,y,MRAND,MRAND,true);
if ( CountFlour > 0 ) then
begin
wait(100);
if not FindDTM(FlourDTM,x,y,INVX1,INVY1,INVX2,INVY2) then
FindDTM(SmallFlourDTM,x,y,INVX1,INVY1,INVX2,INVY2);
Mouse(x,y,MRAND,MRAND,true);
end;
end else
begin
FindDTM(FlourDTM,x,y,INVX1,INVY1,INVX2,INVY2);
Mouse(x,y,MRAND,MRAND,true);
end;
end else
begin
wait(400+random(200));
end;
//He's found
LoopCount := LoopCount+1;
RandomNum := random(4);
Result := (CountFlour = 0);
until ( Result or (LoopCount > 50) );
FreeDTM(FlourDTM);
FreeDTM(SmallFlourDTM);
//Update the stat
stats_IncVariable('Flour (Made)', StartingFlour-CountFlour);
end;
function Walk2Grain: Boolean;
//Walks to the grain
var
x,y: LongInt;
GateDTM, DoorDTM: Integer;
RoadDTM, MillDTM: Integer;
Next2GateDTM: Integer;
Next2GrainGate: Integer;
OpenGateDTM: Integer;
LoopCount: Integer;
begin
Result := false;
MakeCompass('n');
SetAngle(true);
//Next2GateDTM := DTMFromString('m1gAAAHic42JgYEhkYmCIAWJXIPYB4jggzkHCYUBcD8SpQLWxQJwExIZA7ADE7iD9QFwLxNlAXAzEAb6qDKaJ4gyvn34B41B/fxQMExcHqiUGMxGJEQAANkgYwQ==');
Next2GateDTM := DTMFromString('mwQAAAHic42RgYIhhYmCIA+IMIA4G4homiFgeEGcBsQMQJwLVpQJxLZTOB2IbIHYD4jiQGUDsF6rC8P3nd4bgcD8wDWPDMIgvCVRHCDMRgeEAAL1FGAo=');
RoadDTM := DTMFromString('mwQAAAHic42RgYGhjYmCoB+JqIK4E4g4gngDEU6C4CYgrQOqAuAmIi4G4EIgLgLgKiBuBOBuIg0KC4FghTARMW9mqgWk3dx0wLQ5URwgzEYHhAADDNhGi');
MillDTM := DTMFromString('mwQAAAHic42RgYHBjYmAIAeJIILYEYgcg9gViayD2B+IkIG4BqmsH4iogbgDiXiDuh4o1AnEdEAeFBDG8//gZTNvZqoNpAz0FBmcnLQZffz+GZ58/MIgD1RHCTERgOAAA8WwThg==');
for LoopCount := 0 to EXTRALIVES do
begin
//Move Close to gate
//DTMWalk(Next2GateDTM,8);
SPS_WalkToPos(Point(4519, 3369));
//RadialWalk(5394769,90,130,30,MRAND,MRAND);
//Find the Gate
HandleGateDoor( true );
//Walk down the road
//if (DTMWalk(RoadDTM,8)) then
// Break;}
if SPS_WalkPath([Point(4527, 3372), Point(4527, 3384)]) then
Break;
end;
FreeDTM(Next2GateDTM);
FreeDTM(RoadDTM);
//This is a new instance of next to gate!!!!
//Next2GateDTM := DTMFromString('mAAEAAHic42FgYGhiYmCYAMQ9QFwJxFVA3ArELUC8DIi7ofKZTBC1pUA9OUDcCMStQJwAxOlA3AHEXkAcDRXzBuJ4IA4IDGR49v4VGL//8AWMQWLIGFlcHKiHFMxEIkYGAHEfIvI=');
Next2GateDTM := DTMFromString('mwQAAAHic42RgYChiYmCoAeJaIM4G4kwmiFgJEIcDcTuID1RXDMQpQJwIxLVA3AzECUCczgCRDw73Y/j+8zsKBomB8LFKIQZ7Oy0GcaA6QpiJCAwHALa2GV8=');
for LoopCount := 0 to EXTRALIVES do
begin
if not SPS_WalkPath([Point(4530, 3397), Point(4520, 3413), Point(4500, 3428), Point(4485, 3435), Point(4484, 3453), Point(4483, 3462)]) then
Continue;
wait(1000+random(200));
{//Walk to mill door
DTMWalk(MillDTM,9);
//Get Beside the gate
DTMWalk(Next2GateDTM,8);}
//Open the gate
HandleGateDoor( true );
//Walk in
GetIntoGrainField;
if ( InGrainField ) then
begin
Result := true;
Break;
end;
end;
FreeDTM(MillDTM);
FreeDTM(Next2GateDTM);
//Result := InGrainField;
end;
function DetermineAction: Integer;
//This function determines what should be going on based on inventory and
// location
var
Location, FlourCount, PotCount, FreeInv, GrainCount: Integer;
RandomNum: Integer;
begin
//First lets look at the location
Location := VerifyLocation;
GrainCount := CountGrain;
FreeInv := 28 - InvCount;
PotCount := CountPots;
FlourCount := CountFlour;
Writeln('Location = '+tostr(Location));
Writeln('Grain count = '+tostr(GrainCount));
Writeln('Free Inv = '+tostr(FreeInv));
Case Location of
GRAINFIELDID:
begin
//In Grain Field, lets see if i have 20 grain
if ( (FreeInv+GrainCount) > 19 ) then
begin
//I need to collect this grain
Result := 0;
end else
begin
//I should prob walk to the mill
Result := 1;
end;
end;
BILLID:
begin
//At bill, now what should i do
if ( FlourCount > 0 ) then
begin
// deposit flour
Result := 10;
end else
begin
//See if I have flower to deposit
if ( PotCount > 19 ) then
begin
Result := 7; //Walk back to mill
end else
Result := 11; //Walk back to grain
end;
end;
TOPOFMILLID:
begin
if (GrainCount > 0) then
begin
Result := 3; //Grind the grain
end else
begin
Result := 4;//Climb down
end;
end;
BOTTOMOFMILLID:
begin
if (PotCount > 0) then
begin
//Here i might need to collect flour or the bin might be out, pick one
// at random
RandomNum := random(2);
if ( RandomNum = 0 ) and (FlourCount > 0) then
begin
Result := 9;//Walk to bill to deposit flour
end else
begin
Result := 8;//Collect the flour
end;
end else
begin
if ( GrainCount > 0) then
begin
Result := 2;//Climb up to grind the grain
end else
begin
Result := 5;//Walk to bill to get pots to collect flour
end;
end;
end;
MIDDLEOFMILLID:
begin
if ( GrainCount = 0 ) then
begin
Result := 4; //Climb Down
end else
Result := 2; //Climb up
end;
UNKNOWNID:
begin
Result := 12; //Failure
end;
end;
end;
Procedure HandleCrash;
//This function Saves Useful information like a screen sho
var
ScreenBMP: TMufasaBitmap;
ClientPoints: TBox;
width, height: integer;
BMPName: string;
i: integer;
begin
//Allocate the memory
ScreenBMP := TMufasaBitmap.create;
GetClientDimensions(width, height);
BMPName := 'MillerCrash';
ScreenBMP := BitmapFromClient(0, 0, width-1, height-1);
i := 0;
While FileExists(ScriptPath+BMPName+tostr(i)+'.bmp') do
i := i + 1;
if (TAKEPICTURE) then
SaveBitmap(ScreenBMP,ScriptPath+BMPName+tostr(i)+'.bmp');
wait(300);
FreeBitmap(ScreenBMP);
end;
function HandleBreaks( var BreakTimer, FirstBreakTime: Integer): Boolean;
//This function handles all breaking except the initial time setup
// it is required the BreakTimer has be initialized with a MarkTime before calling
// BreakTimer is the time Marker, FirstBreakTime is the settings for when to break
var
x,y: integer;
num: integer;
Font: String;
color,TextSpacing: integer;
Clock: TIntegerArray;
begin
Result := false;
Clock := [0,0,0];
if (TAKEBREAKS) then
begin
//Do the things required for taking a break
if ( TimeFromMark(BreakTimer) >= FirstBreakTime ) then
begin
//Time to logout and take this break
//Set my BreakTimer
MarkTime(BreakTimer);
FirstBreakTime := (HOWLONG + random(HOWLONGRANDOM))*60*1000;
//Time to logout
while (LoggedIn) do
Logout;
TextSpacing := 20;
color := 592381;
Font := 'SmallChars';
//Here I wait
while ( TimeFromMark(BreakTimer) < FirstBreakTime) do
begin
wait(1000);
x := INVX1;
y := INVY1;
ConvertTime(GetTimeRunning,Clock[0],Clock[1],Clock[2]);
ClearRSCanvas(SMART_Canvas.canvas);
Smart_DrawText(x,y,Font,'=========== THE MILLER =============',color);
y:=y+TextSpacing;
Smart_DrawText(x,y,Font,'Time Running ' +tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]),color);
y:=y+TextSpacing;
Smart_DrawText(x,y,Font,'Taking a Break',color);
//Now time to set up time remaining in break
num := FirstBreakTime - TimeFromMark(BreakTimer);
if ( num < 0 ) then
num := 0;
Clock[0] := floor(num/(1000*60*60));//Hours
Clock[1] := floor((num-(Clock[0]*1000*60*60))/(1000*60));//Minutes
Clock[2] := floor((num-(Clock[0]*1000*60*60)-(Clock[1]*1000*60))/1000);//Seconds
y:=y+TextSpacing;
Smart_DrawText(x,y,Font,'Time Remaining in break ' +tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]),color);
end;
//Log back in
while not(LoggedIn) do
LoginPlayer;
//Tell the program how to procede from here
Result := true;
MarkTime(BreakTimer);
FirstBreakTime := (HOWOFTEN + random(HOWOFTENRANDOM))*60*1000;
end;
end;
end;
function GetRandomFact: string;
//This function returns a random fact from
// the website 'http://randomfactgenerator.net/'
// Author: kanah
// Special thanks to Euphemism for the idea
var
SearchString0, SearchString1, Text: string;
begin
//Search strings are used to mark the begining and end of useful info
SearchString0 := '<div id="facts">';
SearchString1 := '<br/><br/>';
//Text is loaded with the raw html text from the website
Text := GetPage('http://randomfactgenerator.net/');
//Text is now broken down from the entire html page into the random fact
Text := Between(SearchString0,SearchString1,Text);
//Now trim to remove spaces and get rid of the "<div>" text
Trim(Text);
delete(Text,1,pos('>',Text));
Result := Text;
end;
procedure ProgressReport( Action,Loads: Integer );
//This function generates a progress report
var
Clock: TIntegerArray;
ActionText: TStringArray;
x,y, TextSpacing, color: integer;
Font: String;
RandomFact: string;
begin
ActionText := ['Collect Grain','Walk to Mill','Climb up mill', 'Grind grain',
'Climb down mill', 'walk to bill', 'buy pots', 'walk bill to mill',
'Collect flour', 'walk to bill', 'Deposit flour', 'walk to grain',
'Lost'];
SRLRandomsReport;
Stats_Commit;
if (SHOWRANDOMFACT) then
RandomFact := GetRandomFact;
Clock := [0,0,0];
ConvertTime(GetTimeRunning,Clock[0],Clock[1],Clock[2]);
writeln('=========== THE MILLER =============');
Writeln('Time Running ' +tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
writeln('Current action: '+ActionText[Action]);
writeln('Grain Count: '+tostr(CountGrain));
writeln('Flour Count: '+tostr(CountFlour));
Writeln('Total Flour: '+tostr(Loads*18));
if (SHOWRANDOMFACT) then
writeln(RandomFact);
writeln('====================================');
TextSpacing := 20;
x := (MSX1+MSX2)/2;//INVX1;
y := 5;//INVY1;
color := 592381;
Font := 'SmallChars';
ClearRSCanvas(SMART_Canvas.canvas);
Smart_DrawText(x,y,Font,'=========== THE MILLER =============',color);
y:=y+TextSpacing;
Smart_DrawText(x,y,Font,'Time Running ' +tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]),color);
y:=y+TextSpacing;
Smart_DrawText(x,y,Font,'Total Flour: '+tostr(Loads*18),color);
y:=y+TextSpacing;
if (SHOWRANDOMFACT) then
Smart_DrawText(x,y,Font,RandomFact,color);
end;
function Check4PotNotes: boolean;
//This function makes sure there is pot notes to trade
// Checked for bot nuke compliance
var
PotNoteDTM, SmallPotNoteDTM: integer;
begin
PotNoteDTM := DTMFromString('mAAEAAHic42FgYHBiYmDwBmJnILaCYnMgNgFiGyB2BWJHIPaH4mdAPU+B+C0QPwfix0D8CIhfAfEHKP4IxG8YIGrzfAyAJBPRWI6BNMBIIkYGAE5JD08=');
//This is the new PotNote image since the bot nuke
SmallPotNoteDTM := DTMFromString('mwQAAAHic42RgYLBmYmCwAmIXIDYBYlcgtgNicyA2BWJnIH4AVPcEip8B8UMoDcIguedAXBpkDCSZ8GJxBsKAkQgMBwBLkwtn');
Result := (CountItems('dtm', PotNoteDTM, [0, 0]) > 0);
if not(Result) then
Result := (CountItems('dtm', SmallPotNoteDTM, [0, 0]) > 0);
if (Result) then
writeln('Found pot notes');
FreeDTM(SmallPotNoteDTM);
FreeDTM(PotNoteDTM);
end;
{Main does not need a declaration}
{procedure main;}
//Variables declared here are GLOBAL
var
Iterations: Integer;
LoopCount,i,Action: Integer;
TimeFailSafe, BreakTimer, FirstBreakTime: Integer;
begin
//These actions must be done first
Smart_Server := 152;
Smart_Members := False;
Smart_Signed := True;
//Smart_SuperDetail = False;
ClearDebug;
SetupSRL;
SMART_SetupDebug;
DeclarePlayers;
//Setup SPS
SPS_Setup(RUNESCAPE_SURFACE, ['11_8']);
//Set up SRL stats
SetupSRLStats({scriptid} 181, SRLStats_User, SRLStats_Password);
//Here is my function testing spot
//************** Remaining functional code *****************
for i := 0 to (HowManyPlayers-1) do
begin
if (Players[i].Active) then
begin
for LoopCount:= 0 to EXTRALIVES do
begin
if (LoggedIn) then
begin
break;
end else
begin
LoginPlayer; //Login the current player
end;
end;
//Find out what i should be doing
//Check location and inventory
Iterations := 0;
wait(1000);
setrun(true);
ProgressReport(0,0);
Action := DetermineAction;
MarkTime(TimeFailSafe);
//set up break things
MarkTime(BreakTimer);
FirstBreakTime := (HOWOFTEN + random(HOWOFTENRANDOM))*60*1000;
while (Iterations < LOADS) do
begin
RunEnergy(60);
Case Action of
0: begin
Writeln('Collect grain action');
if ( PickGrain ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
1: begin
Writeln('Walk to Mill action');
if ( Walk2Mill ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
2: begin
Writeln('Climb up ladder action');
if ( ClimbUpMill ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
3: begin
Writeln('Grind grain action');
if ( GrindGrain ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
4: begin
Writeln('Climb down ladder action');
if ( ClimbDownMill ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
5: begin
Writeln('Walk to bill action');
if ( Walk2Bill ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
6: begin
Writeln('Buy pots action');
if (Check4PotNotes) then
begin
if ( BuyPots ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end else
begin
writeln('Out of pots');
break;
end;
end;
7: begin
Writeln('Walk bill to mill action');
if ( WalkBill2Mill ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
8: begin
Writeln('Collect flour action');
if ( CollectFlour ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
9: begin
Writeln('Walk to bill action');
if ( Walk2Bill ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
10: begin
Writeln('Deposit Flour action');
if ( DepositFlour ) then
begin
//Success, continue
AntiBan;
Action := Action+1;
Iterations := Iterations + 1;
ProgressReport(10,Iterations);
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
11: begin
Writeln('Walk to Grain action');
if ( Walk2Grain ) then
begin
//Success start over
Action := 0;
AntiBan;
MarkTime(TimeFailSafe);
end else
begin
//Failure, do something!!
AntiRandoms;
Action := DetermineAction;
end;
end;
12: begin
Writeln('Lost, Logging out');
HandleCrash;
break;
end;
end;
ProgressReport(Action,Iterations);
if ( TimeFromMark(TimeFailSafe) > (TIMEOUT*1000) ) then
begin
Writeln('System seems to be locked up in Determine Action');
Writeln('Taking the back up way out');
Action := 12; //Jump to Handle crash
end;
if (HandleBreaks(BreakTimer,FirstBreakTime) and LoggedIn) then //Check to see if it's time to break
begin
//I took a break, I should reset the failsafe timer
MarkTime(TimeFailSafe);
end;
end;
if not( Action = 12 ) then
writeln('Success');
Logout;
end else
begin
writeln('Skipping over inactive player ' +Players[i].Name);
end;
Inc(CurrentPlayer);
end;
end.The Random Fact Generator
function GetRandomFact: string;
//This function returns a random fact from
// the website 'http://randomfactgenerator.net/'
// Author: kanah
// Special thanks to Euphemism for the idea
var
SearchString0, SearchString1, Text: string;
begin
//Search strings are used to mark the begining and end of useful info
SearchString0 := '<div id="facts">';
SearchString1 := '<br/><br/>';
//Text is loaded with the raw html text from the website
Text := GetPage('http://randomfactgenerator.net/');
//Text is now broken down from the entire html page into the random fact
Text := Between(SearchString0,SearchString1,Text);
//Now trim to remove spaces and get rid of the "<div>" text
Trim(Text);
delete(Text,1,pos('>',Text));
Result := Text;
end;I have posted 2 scripts on the forums:
The Miller: [url]http://villavu.com/forum/showthread.php?p=828396#post828396[/url]
Random Fact generator:
[url]http://villavu.com/forum/showthread.php?p=836526#post836526[/url]
Note: The Miller's code may be a little messy as I was learning and often left old unused code from previous revisions as comments.