YoHoJo
2009-12-13 13:24:19
if (CountItems('bmp', bmp_Coffin, [30]) < 5) then
begin
WriteLn('Could not find all coffins!');
FreeBitmap(bmp_Coffin);
Exit;
end;I was running my miner overnight.
Came and saw this:
***** STR: FOUND RANDOM: 'Leo The Gravedigger' *****
Could not find all coffins!Shouldn't there be a logout somewhere around there and set player to false?
Just wondering. And for you lazies here's the entire leo solver:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Leo The Grave Digger Routines --//
//-----------------------------------------------------------------//
// * function InLeoGraveyard: Boolean; // * by ZephyrsFury
// * procedure Leo_WaitForScreen; // * by Nielsie95 and SKy Scripter
// * procedure Leo_ToCenter; // * by Nielsie95 and SKy Scripter
// * function Leo_FixInv: Boolean; // * by Nielsie95 and SKy Scripter
// * function Leo_TalkToLeo: Boolean; // * by Nielsie95 and SKy Scripter
// * procedure Leo_GrabCoffins; // * by Nielsie95 and SKy Scripter
// * function Leo_ClickNearestGrave(cx, cy: Integer): Boolean; // * by Nielsie95 and SKy Scripter
// * procedure Leo_FollowGrave(var x, y: Integer); // * by Nielsie95 and SKy Scripter
// * function Leo_BuryCoffins: Boolean; // * by Nielsie95 and SKy Scripter
// * function SolveLeo: Boolean; // * by Nielsie95 and SKy Scripter
{*******************************************************************************
function InLeoGraveyard: Boolean;
By: ZephyrsFury
Description: Checks if we're in the Leo random.
*******************************************************************************}
function InLeoGraveyard: Boolean;
var
Pts: TPointArray;
ATPA: T2DPointArray;
X, Y, II, GraveCount, cts: Integer;
B: TBox;
begin
if (InBlack) then
if (FindColor(X, Y, 60909, MMX1, MMY1, MMX2, MMY2)) then
if (CountColor(60909, MMX1, MMY1, MMX2, MMY2) = 1) then
if (InRange(PercentBlackMM, 75, 80)) then
begin
FindColorsPie(Pts, clWhite, 50, 0.0, 360.0, 0.0, 76.0, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY);
B := GetTPABounds(Pts);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(100.0, 100.0);
FindColorsTolerance(Pts, 0, B.X1, B.Y1, B.X2, B.Y2, 2);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(cts);
ATPA := SplitTPAEx(Pts, 1, 1);
for II := 0 to High(ATPA) do
if (Length(ATPA[II]) < 50) then
Inc(GraveCount);
Result := (GraveCount > 5);
end;
end;
{*******************************************************************************
procedure Leo_WaitForScreen;
By: Nielsie95 and SKy Scripter
Description: Waits for a gravestone/coffin screen.
*******************************************************************************}
procedure Leo_WaitForScreen;
var
t: Integer;
begin
t := GetSystemTime;
while (GetColor(460, 30) <> 39423) and ((GetSystemTime - t) <= (5 * 1000)) do Wait(100);
end;
{*******************************************************************************
procedure Leo_ToCenter;
By: Nielsie95 and SKy Scripter
Description: Walks to the center of the screen.
*******************************************************************************}
function Leo_ToCenter : boolean;
var
p: TPointArray;
t: T2DPointArray;
c: TIntegerArray;
i, arL: Integer;
H, S, L: Extended;
b: TBox;
begin
result := false;
ColorToleranceSpeed(0);
if FindColorsTolerance(p, 15658734, MMX1, MMY1, MMX2, MMY2, 60) then
begin
c := GetColors(p);
ClearSameIntegers(c);
arL := High(c);
for i := 0 to arL do
begin
ColorToHSL(c[i], H, S, L);
if (L > 85) and (L < 99) then
begin
if (not InIntArray([16711422, 15527148, 13816530, 14869218, 12961221], c[i])) then
begin
FindColorsTolerance(p, c[i], MMX1, MMY1, MMX2, MMY2, 0);
t := SplitTPAEx(p, 2, 2);
SortATPAFromFirstPoint(t, Point(MMCX, MMCY));
if (Length(t[0]) < 35) then Continue;
b := GetTPABounds(t[0]);
if (CountColor(195836, b.x1 -3, b.y1 -3, b.x2 +3, b.y2 +3) < 1) then Continue;
if (Distance((b.x1 + b.x2) shr 1, (b.y1 + b.y2) shr 1, 628, 86)) > 4 then
Mouse((b.x1 + b.x2) shr 1, (b.y1 + b.y2) shr 1, 3, 3, True);
Wait(300 + Random(50));
Flag;
Result := True;
Break;
end;
end;
end;
end;
ColorToleranceSpeed(1);
wait(1500 + random(500));
end;
{*******************************************************************************
function Leo_FixInv: Boolean;
By: Nielsie95 and SKy Scripter
Description: Makes sure there is enough room to get all the coffins.
*******************************************************************************}
function Leo_FixInv: Boolean;
var
i, x, y: Integer;
b: TBox;
begin
Result := (InvCount < 24);
if Result then Exit;
ColorToleranceSpeed(1);
for i := 1 to 28 do
begin
if (not ExistsItem(i)) then Continue;
b := InvBox(i);
if (FindBitmapToleranceIn(srl_GetBitmap(bmp_Bones_Normal), x, y, b.x1, b.y1, b.x2, b.y2, 35)) or
(FindBitmapToleranceIn(srl_GetBitmap(bmp_Bones_Big), x, y, b.x1, b.y1, b.x2, b.y2, 35)) then
begin
y := InvCount;
MouseItem(i, True);
x := GetSystemTime;
Wait(500);
while (InvCount = y) and ((GetSystemTime - x) < (5 * 1000)) do Wait(100);
Wait(500);
if (InvCount < 24) then
Break;
end;
end;
Result := (InvCount < 24);
if Result then Exit;
for i := 28 downto 1 do
begin
if (not ExistsItem(i)) then Continue;
y := InvCount;
MouseItem(i, False);
Wait(200 + Random(200));
ChooseOption('rop');
x := GetSystemTime;
Wait(500);
while (InvCount = y) and ((GetSystemTime - x) < (5 * 1000)) do Wait(100);
Wait(500);
if (InvCount < 24) then
Break;
end;
Result := (InvCount < 24);
end;
{*******************************************************************************
function Leo_TalkToLeo: Boolean;
By: Nielsie95 and SKy Scripter
Description: Finds Leo and handles the talking.
*******************************************************************************}
function Leo_TalkToLeo: Boolean;
var
x, y: Integer;
begin
Result := False;
SetColorSpeed2Modifiers(0.11, 0.26);
if (not FindObjTPA(x, y, 3953239, 7, 2, 15, 25, 15, ['Leo'])) then
begin
Leo_ToCenter;
if (not FindObjTPA(x, y, 3953239, 7, 2, 15, 25, 15, ['Leo'])) then
Exit;
end;
Mouse(x, y, 0, 0, True);
x := GetSystemTime;
while (not InConvo) and ((GetSystemTime - x) <= (5 * 1000)) do Wait(100);
if (not InConvo) then Exit;
while ClickContinue(True, True) do Wait(500 + Random(500));
Result := True;
Wait(1500 + Random(1500));
ColorToleranceSpeed(1);
if SimilarColors(GetColor(395, 201), 65535 , 40) then //changed to yellow
begin
Mouse(455, 47, 6, 6, True);
Wait(1500 + Random(500));
Leo_TalkToLeo;
Exit;
end;
Wait(500 + Random(500));
if (Pos('peers at the', GetBlackChatMessage) > 0) then
begin
x := GetSystemTime;
while (not InConvo) and ((GetSystemTime - x) <= (10 * 1000)) do Wait(100);
while ClickContinue(True, True) do Wait(500 + Random(500));
x := GetSystemTime;
Wait(1000);
if (not InConvo) then Exit;
while InConvo and (not ClickContinue(False, False)) and ((GetSystemTime - x) <= (15 * 1000)) do Wait(100);
end;
end;
{*******************************************************************************
procedure Leo_GrabCoffins;
By: Nielsie95 and SKy Scripter
Description: Grabs all coffins from the screen.
*******************************************************************************}
procedure Leo_GrabCoffins;
var
i, bmp_Coffin, x, y, c, Time, f: Integer;
p: TPointArray;
t: T2DPointArray;
begin
bmp_Coffin := BitmapFromString(17, 5, 'beNpjYGQAAUYIivPVifLSAqI' +
'wd40gZzUggkmhAcb8aJOcSGMIyggzTA3Wn9WgsX2GgakOH8QENF01' +
'aVaVyZZAVJpoDkQre3WOLTXZM9cQqP3COjOg9sQAPaDtcJcAtdRn2' +
'AB1QRBQI9B8oMaiODO41RB7gRohCKgrNS6uKdsWrhFuHZouuEYGAG' +
'sCPyY=');
Time := GetSystemTime;
while (CountItems('bmp', bmp_Coffin, [30]) < 5) and ((GetSystemTime - Time) <= (60 * 1000)) and (f < 5) do
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.1, 0.2);
FindColorsTolerance(p, 3563122, MSX1, MSY1, MSX2, MSY2, 13);
if (Length(p) < 30) then Continue;
t := SplitTPAEx(p, 7, 7);
SortATPAFromFirstPoint(t, Point(MSCX, MSCY));
for i := 0 to High(t) do
begin
MiddleTPAEx(t[i], x, y);
MMouse(x, y, 5, 15);
Wait(200 + Random(50));
if IsUpText('Take-coffin') then
begin
GetMousePos(x, y);
c := InvCount;
Mouse(x, y, 0, 0, True);
Wait(500);
FFlag(0);
Wait(1500);
y := 0;
while (c = InvCount) and (y < 20) do
begin
Inc(y);
Wait(500);
end;
if (c < InvCount) then
Break;
end;
end;
if (i > High(t)) then
begin
Inc(f);
Leo_ToCenter;
end;
ColorToleranceSpeed(1);
end;
FreeBitmap(bmp_Coffin);
end;
{*******************************************************************************
function Leo_ClickNearestGrave(cx, cy: Integer): Boolean;
By: Nielsie95 and SKy Scripter
Description: Puts the coffin inside the grave.
*******************************************************************************}
function Leo_ClickNearestGrave(cx, cy: Integer): Boolean;
var
i, c, x, y: Integer;
p: TPointArray;
t: T2DPointArray;
b: TBox;
begin
Result := False;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.33);
FindColorsTolerance(p, 4609120, MSX1, MSY1, MSX2, MSY2, 13);
SetColorSpeed2Modifiers(0.1, 0.2);
t := SplitTPAEx(p, 3, 3);
SortATPAFrom(t, Point(cx, cy));
SortATPAFromFirstPoint(t, Point(cx, cy));
for i := 0 to High(t) do
if (Length(t[i]) > 150) then
begin
b := GetTPABounds(t[i]);
if (CountColorTolerance(3563122, b.x1 + 10, b.y1 + 10, b.x2 -10, b.y2 -10, 13) > 5) then Continue;
MiddleTPAEx(t[i], x, y);
MMouse(x -4, y -4, 10, 10);
Wait(200 + Random(150));
if (not IsUpText('Grave')) then Continue;
GetMousePos(x, y);
c := InvCount;
Mouse(x, y, 0, 0, True);
Result := True;
Wait(500);
FFLag(0);
y := 0;
while (c = InvCount) and (y < 20) do
begin
Inc(y);
Wait(500);
end;
if (c > InvCount) then
Break
else
Leo_ClickNearestGrave(cx, cy);
end;
end;
{*******************************************************************************
procedure Leo_FollowGrave(var x, y: Integer);
By: Nielsie95 and SKy Scripter
Description: Follows the grave while we're walking to it.
*******************************************************************************}
procedure Leo_FollowGrave(var x, y: Integer);
var
t, c: Integer;
p: TPointArray;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.33);
t := GetSystemTime;
c := 0;
while (FlagPresent or (c < 10)) and ((GetSystemTime - t) <= (18 * 1000)) and (GetColor(460, 30) <> 39423) do
begin
FindColorsTolerance(p, 4609120, x - 10, y - 20, x + 10, y + 29, 13);
if (Length(p) > 5) then
MiddleTPAEx(p, x, y);
Wait(50);
Inc(c);
end;
end;
{*******************************************************************************
function Leo_BuryCoffins: Boolean;
By: Nielsie95 and SKy Scripter
Description: Finds the coffins, identifies, and puts them in the right grave.
*******************************************************************************}
function Leo_BuryCoffins: Boolean;
var
i, c, f, x, y, bmp_Coffin: Integer;
p: TPointArray;
t: T2DPointArray;
b: TBox;
IDTwice, BuryTwice: Boolean;
GraveStone: string;
Coffins : array [0..4] of record
Inv: Integer;
Name: string;
end;
label
IDCoffins;
begin
bmp_Coffin := BitmapFromString(17, 5, 'beNpjYGQAAUYIivPVifLSAqI' +
'wd40gZzUggkmhAcb8aJOcSGMIyggzTA3Wn9WgsX2GgakOH8QENF01' +
'aVaVyZZAVJpoDkQre3WOLTXZM9cQqP3COjOg9sQAPaDtcJcAtdRn2' +
'AB1QRBQI9B8oMaiODO41RB7gRohCKgrNS6uKdsWrhFuHZouuEYGAG' +
'sCPyY=');
IDCoffins:
f := 0;
ColorToleranceSpeed(1);
if (CountItems('bmp', bmp_Coffin, [30]) < 5) then
begin
if (not Leo_FixInv) then
begin
WriteLn('Could not clear inventory for Leo!');
FreeBitmap(bmp_Coffin);
Exit;
end;
Leo_GrabCoffins;
end;
if (CountItems('bmp', bmp_Coffin, [30]) < 5) then
begin
WriteLn('Could not find all coffins!');
FreeBitmap(bmp_Coffin);
Exit;
end;
for i := 1 to 28 do
begin
if (not ExistsItem(i)) then Continue;
b := InvBox(i);
if (FindBitmapToleranceIn(bmp_Coffin, x, y, b.x1, b.y1, b.x2, b.y2, 30)) then
with Coffins[f] do
begin
Inv := i;
Name := 'error';
c := GetSystemTime;
while (Name = 'error') and ((GetSystemTime - c) < (30 * 1000)) do
begin
if (GetColor(460, 30) <> 39423) then
Mouse(x + 6, y + 7, 6, 7, true);
Leo_WaitForScreen;
Wait(500);
try
Name := Leo_AnalyzeCoffin2(GetClientCanvas.Handle);
except end;
if (Random(2) = 0) or (Name <> 'error') then
CloseWindow;
end;
if (Name <> 'error') then
begin
WriteLn('Coffins('+IntToStr(f)+'): '+Name);
Inc(f);
end;
end;
end;
for i := 0 to 4 do
begin
for c := 0 to 4 do
if (i <> c) then
if (Coffins[i].Name = Coffins[c].Name) then Break;
if (c < 5) then Break;
end;
if ((f <> 5) or (i < 5)) then
if (not IDTwice) then
begin
IDTwice := True;
WriteLn('Could not identify all coffins, trying again!');
Leo_ToCenter;
goto IDCoffins;
end else
begin
WriteLn('Could not identify all coffins!');
FreeBitmap(bmp_Coffin);
Exit;
end;
f := 0;
c := 0;
Leo_ToCenter;
ColorToleranceSpeed(2);
while (c < 5) and (f < 5) do
begin
SetColorSpeed2Modifiers(0.15, 0.15);
FindColorsTolerance(p, 6513515, MSX1, MSY1, MSX2, MSY2, 3);
SetColorSpeed2Modifiers(0.1, 0.2);
t := SplitTPAEx(p, 15, 30);
SortATPAFromFirstPoint(t, Point(MSCX, MSCY));
for i := 0 to High(t) do
begin
if (Length(t[i]) < 50) then Continue;
b := GetTPABounds(t[i]);
if not (InRange(b.x2 - b.x1, 25, 65) and InRange(b.y2 - b.y1, 50, 120)) then Continue;
if (CountColorTolerance(3563122, b.x1 + 10, b.y1 + 10, b.x2 -10, b.y2 -10, 13) > 5) then Continue;
MMouse(b.x1 + 16, b.y1 + 5, 5, 10);
Wait(200 + Random(150));
if IsUpText('Read') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
b.x1 := (b.x1 + b.x2) shr 1;
b.y1 := ((b.y1 + b.y2) shr 1);
Leo_FollowGrave(b.x1, b.y1);
Leo_WaitForScreen;
if (GetColor(460, 30) <> 39423) then
begin
Leo_WaitForScreen;
if (GetColor(460, 30) <> 39423) then
Break;
end;
GraveStone := 'error';
x := GetSystemTime;
while (GraveStone = 'error') and ((GetSystemTime - x) < (30 * 1000)) do
begin
Wait(500);
try
GraveStone := Leo_AnalyzeGraveStone2(GetClientCanvas.Handle);
except end;
end;
CloseWindow;
if (GraveStone <> 'error') then
begin
WriteLn(GraveStone);
for x := 0 to 4 do
if (Coffins[x].Name = GraveStone) and (Coffins[x].Inv > 0) then
begin
MouseItem(Coffins[x].Inv, False);
Wait(250 + Random(150));
if (not ChooseOption('Use')) then Continue;
if Leo_ClickNearestGrave(b.x1, b.y1) then
begin
Inc(c);
Coffins[x].Inv := -1;
Break;
end
else
MouseItem(Coffins[x].Inv, True);
end;
if (x > 4) then
begin
x := -100;
y := -100;
Break;
end;
end;
Break;
end;
end;
if (x = -100) and (y = -100) then
Break;
if (i > High(t)) then
begin
Leo_ToCenter;
Inc(f);
end;
end;
if (x = -100) and (y = -100) then
if (not BuryTwice) then
begin
BuryTwice := True;
WriteLn('Could not identify all graves, trying again!');
goto IDCoffins;
end else
WriteLn('Could not identify all graves!');
Result := (c = 5) and (x > -100);
FreeBitmap(bmp_Coffin);
end;
{*******************************************************************************
function SolveLeo: Boolean;
By: Nielsie95 and SKy Scripter
Description: Solves the Leo random.
*******************************************************************************}
function SolveLeo: Boolean;
var
cts, X, Y: Integer;
begin
cts := GetColorToleranceSpeed;
Wait(2000);
while ClickContinue(True, True) do Wait(500 + Random(500));
Wait(1000);
if (FindColor(X, Y, 65535, MSX1, MSY1, MSX2, MSY2)) then
Mouse(455, 45, 5, 5, True);
if Leo_BuryCoffins then
if Leo_TalkToLeo then
begin
WriteLn('Solved Leo!');
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2, 0.2);
Result := True;
Exit;
end;
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2, 0.2);
Players[CurrentPlayer].Rand := 'Leo the Gravedigger';
Players[CurrentPlayer].Active := False;
LogOut;
end;