SKy Scripter
2008-03-30 01:56:06
Well, i have been working on a project for SRL and it's finished ! xD.
I have Solved Leo The Grave digger.
In case you don't know what this random is :
[ATTACH]11403[/ATTACH]
If you get the chance i would appreciate if you test this!
It does require a plug-in so you must download my attachment.
Here is the Solver. (make sure you put the plug-in in scar before playing script)
I have Solved Leo The Grave digger.
In case you don't know what this random is :
[ATTACH]11403[/ATTACH]
If you get the chance i would appreciate if you test this!
It does require a plug-in so you must download my attachment.
Here is the Solver. (make sure you put the plug-in in scar before playing script)
program New;
{.include SRL\SRL.scar}
var
Leo_Coffins : array [0..4] of record
Inv: Integer;
Name: string;
end;
{*******************************************************************************
function Leo_WalkToCenter: Boolean;
by: SKy Scripter
Description: Walks to The Center Of Leo (on map).
*******************************************************************************}
function Leo_WalkToCenter: Boolean;
var
Canvas:Tcanvas;
mx, my, bit: Integer;
begin
bit := BitmapFromString(153, 153, '');
canvas := GetBitmapCanvas(bit);
CopyCanvas(GetClientCanvas, Canvas, MMX1, MMY1, MMX2, MMY2, 0, 0, 153, 153);
Leo_GetMiddleFloor(mx, my, Canvas);
if ( mx <> 0) and (my <> 0) then
begin
mx := mx + mmx1;
my := my + mmy1;
Mouse(mx, my, 5, 5, true);
flag;
wait(1000 + random(500));
end;
end;
{*******************************************************************************
function Leo_CheckInventory: Boolean;
by: SKy Scripter
Description: Makes a nice Inventory for the Leo Solver. (burys bones)
*******************************************************************************}
function Leo_CheckInventory: Boolean;
var
DTM, x, y, C: Integer;
begin
if (InvCount > 23) then
begin
DTM := DTMFromString('78DA637462626060636440058C4824903605A' +
'A6125A0C695098987438D1D500D3F0135DE4035EC4498C3845F0D' +
'00DBDA01CB');
C := 0;
while (C < 10) do
begin
C := C + 1;
if (FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
Mouse(x, y, 3, 3, True);
Wait(1500 + random(800));
end;
end;
FreeDTM(DTM);
if (InvCount > 23) then
begin
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Rand := 'Leo Too much inventory';
Logout;
end else
Result := true;
end;
end;
{*******************************************************************************
function Leo_CountCoffins: Integer;
by: SKy Scripter
Description: Counts The Amount of coffins in Inventory.
*******************************************************************************}
function Leo_CountCoffins: Integer;
var
Box: TBox;
DTM, i, x, y: Integer;
begin
Result := 0;
DTM := DTMFromString('78DA634C636260B8C58006189148209D0454F' +
'38C809A7CA09A8F04D49401D53C25A0A61CA8E61D013509403577' +
'F1AB0100CF1C0804');
for i := 1 to 28 do
begin
GetInvItemBounds(i, Box);
if (FindDTM(DTM, x, y, Box.x1, Box.y1, Box.x2, Box.y2)) then inc(result);
end;
freeDtm(dtm);
end;
{*******************************************************************************
function Leo_CheckInventory: Boolean;
by: SKy Scripter
Description: Makes a nice Inventory for the Leo Solver. (burys bones)
*******************************************************************************}
function Leo_GatherCoffins: Boolean;
var
x, y, t: Integer;
begin
if (not(LoggedIn)) then LoginPlayer;
wait(400 + random(200));
Leo_WalkToCenter;
MakeCompass('n');
Leo_CheckInventory;
if (InvCount > 23) then exit;
result := true;
repeat
t := t + 1;
if (not(LoggedIn)) then LoginPlayer;
if (FindObjTPA(x, y, 3695480, 20, 5, 5, 5, 5, ['offi'])) then
begin
Mouse(x, y, 0, 0, False);
ChooseOption('ake');
Wait(200 + random(300));
Flag;
Wait(2000 + random(1000));
end else
begin
Leo_WalkToCenter;
wait(500 + random(200));
end;
until (t > 20) or (Leo_CountCoffins = 5);
wait(1000 + random(1000));
if (t > 20) then
begin
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Rand := 'Leo Too much inventory';
Logout;
result := false;
end;
Leo_WalkToCenter;
end;
{*******************************************************************************
procedure Leo_AnalyzeCoffins;
by: SKy Scripter
Description: Saves The Coffins types in variables.
*******************************************************************************}
procedure Leo_AnalyzeCoffins;
var I, DTM, x, y, n, t, w, h, bitmap: Integer;
canvas: tcanvas;
Box: TBox;
begin
if (Leo_CountCoffins < 5) then exit;
DTM := DTMFromString('78DA634C636260B8C58006189148209D0454F' +
'38C809A7CA09A8F04D49401D53C25A0A61CA8E61D013509403577' +
'F1AB0100CF1C0804');
w := 350;
h := 270;
bitmap := BitmapFromString(w, h, '');
Canvas := GetBitmapCanvas(bitmap);
for I:= 1 to 28 do
begin
GetInvItemBounds(i, Box);
if (n > 4) then break;
if (FindDTM(DTM, x, y, Box.x1, Box.y1, Box.x2, Box.y2)) then
begin
Leo_Coffins[n].inv := i;
Leo_Coffins[n].name := 'error';
t := 0;
while (Leo_Coffins[n].name = 'error') and (t < 5) do
begin
Mouse(x, y + 4, 5, 5, true);
wait(2000 +random(500));
try Leo_AnalyzeCoffin(Leo_Coffins[n].name, canvas); except end;
wait(100+ random(200));
CloseWindow;
inc(t);
end;
inc(n);
end;
end;
FreeDTM(DTM);
try FreeBitmap(Bitmap); except end;
wait(1000+random(500));
CloseWindow;
if (n < 5) then
begin
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Rand := 'Could not get all coffins';
Logout;
end;
end;
{*******************************************************************************
function Leo_FindUnReadStone(var x, y:integer): Boolean;
by: SKy Scripter
Description: Finds Graves that has no coffins in it. (to solve them)
*******************************************************************************}
function Leo_FindUnReadStone(var x, y:integer): Boolean;
var P: TPointArray;
T: T2DPointArray;
I: Integer;
begin
FindColorsTolerance(P, 8684943, 5, 5, MSX2 - 5, MSY2 - 5, 50);
T := SplitTPAex(P, 10, 10);
SortATPAFromFirstPoint(T, Point(MSCX, MSCY));
for I := 0 to Length(T) - 1 do
if (Length(T[i]) > 15) then
begin
MiddleTPAEx(T[i], x, y);
if (CountColorTolerance(3101798, x - 50, y - 50, x + 50, y + 50, 15) < 20) then
begin
MMouse(x, y, 3, 3);
Wait(100 + random(50));
if (IsUpText('ead')) then
begin
Result := true;
GetMousePos(x, y);
exit;
end;
end;
end;
end;
{*******************************************************************************
procedure Leo_PlaceCoffinIn(I: Integer);
by: SKy Scripter
Description: Places Coffin in the grave.
*******************************************************************************}
procedure Leo_PlaceCoffinIn(xf, yf, I: Integer);
var
Points: TPointArray;
k, x, y: Integer;
s: string;
Box: Tbox;
begin
GetInvItemBounds(Leo_Coffins[I].Inv, Box);
Mouse(Box.x1 + 5, Box.y1 + 5, 10, 10, False);
ChooseOption('Use');
FindColorsSpiralTolerance(xf, yf, Points, 4149085, xf - 50, yf - 50, xf + 50, yf + 50, 20);
for K := 0 to Length(Points) - 1 do
if (Distance(Points[k].x, Points[k].y, x, y) > 10) then
begin
MMouse(Points[k].x, Points[k].y, 2, 2);
GetMousePos(x, y);
s := rs_GetUpText;
if ((Pos('Use', s) <> 0) and (Pos('Grave',s) <> 0) and (Pos('Gravestone', s) = 0)) then
begin
Mouse(x, y, 0, 0, True);
Flag;
Wait(2000 +random(1000));
break;
end;
end;
end;
{*******************************************************************************
function Leo_SolveGraves: Boolean;
by: SKy Scripter
Description: Places All Coffins in the right graves.
*******************************************************************************}
function Leo_SolveGraves: Boolean;
var
x, y, fs, I, t, bitmap, w, h:Integer;
gravestone: string;
canvas: tcanvas;
begin
Leo_WalkToCenter;
fs := 0;
w := 350;
h := 270;
bitmap := BitmapFromString(w, h, '');
Canvas := GetBitmapCanvas(bitmap);
repeat
inc(fs);
GraveStone := 'error';
t := 0;
while (GraveStone = 'error') and (t < 3) do
begin
if (Leo_FindUnReadStone(x, y)) then
begin
Mouse(x, y, 0, 0, true);
flag;
wait(2000 +random(500));
try
Leo_AnalyzeGraveStone(GraveStone, canvas);
except end;
Writeln('Stone: '+GraveStone);
wait(100+ random(200));
CloseWindow;
inc(t);
end else
begin
Leo_WalkToCenter;
wait(500 + random(200));
end;
wait(500 + random(500));
end;
I:= 0;
for I := 0 to 4 do
if (Leo_Coffins[i].name = GraveStone) then break;
if (Leo_Coffins[i].Inv = -1) then break;
Leo_FindUnReadStone(x, y)
Leo_PlaceCoffinIn(x, y, I);
until (Leo_CountCoffins = 0) or (fs > 8);
result := (Leo_CountCoffins = 0);
try freebitmap(bitmap) except end;
end;
{*******************************************************************************
function FindLeo: Boolean;
by: SKy Scripter
Description: Finds The Leo Random and solves it!
*******************************************************************************}
function FindLeo: Boolean;
var i, n, fs, x, y: integer;
gob: boolean;
label reget;
begin
i:= 0;
while (ClickToContinue) and (i < 20) do
begin
inc(i);
wait(100+ random(50));
end;
CloseWindow;
Wait(2000 + random(500));
KeyDown(VK_UP);
wait(2000 + random(1000));
KeyUp(VK_UP);
if (Leo_GatherCoffins) then
begin
reget:
if (fs > 3) then
begin
Players[CurrentPlayer].Active := false;
Players[CurrentPlayer].Rand := 'Could not get all coffins';
Logout;
Exit;
end;
Leo_AnalyzeCoffins;
gob := false;
for i := 0 to 4 do
for n := 0 to 4 do
if (n <> i) then
if (Leo_Coffins[i].Name = Leo_Coffins[n].Name) then
begin
Inc(fs); gob := true; break;
end;
if (gob) then goto reget;
if (not(Leo_SolveGraves)) then FindLeo;
wait(1000 + random(200));
Leo_WalkToCenter;
end;
result := true;
if (Not(Leo_CountCoffins = 0)) then Exit;
i := 0;
repeat
inc(i);
n := 0;
if (FindColor(x, y, 195836, MMX1, MMY1, MMX2, MMY2)) then
if (Distance(MMCX, MMCY, x, y) > 5) then
begin
MouseFlag(x - 2, y - 2, 5, 5);
Wait(1000 + random(500));
end;
if (FindObjTPA(x, y, 7708364, 20, 5, 5, 5, 5, ['alk'])) then
begin
Mouse(x, y, 0, 0, false);
ChooseOption('alk');
Flag;
Wait(2000 + random(1000));
while (ClickToContinue) and (n < 20) do
begin
n := n + 1;
wait(100 + random(50));
end;
exit;
end;
until (i > 5);
end;
var i:integer;
begin
FindWindowBySize(766, 504);
SetLength(Players, 1);
SetupSRL;
ActivateClient;
wait(1000);
FindLeo;
for i:= 0 to 4 do
begin
Writeln('inv:'+inttostr(Leo_Coffins[i].Inv));
Writeln('Name:'+Leo_Coffins[i].name);
Writeln('');
end;
//Leo_FindUnReadStone(x, y);
end.