Wanted
2009-12-04 19:33:22
Edit: Improved beekeeper massively, thanks to Coh3n for the account. Updated script and attachment:
New beekeeper.scar
New beekeeper.scar
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- »» Bee Keeper Solver Routines --//
//-----------------------------------------------------------------//
// * function BeeScreen: Boolean; // * by ZephyrsFury
// * function Bee_Convo: Boolean; // * by ZephyrsFury
// * function Bee_Puzzle: Boolean; // * by Lord Saturn Remade by IceFire908
// * function SolveBeeKeeper: Boolean; // * by Lord Saturn & ZephyrsFury
//-----------------------------------------------------------------//
{*******************************************************************************
function BeeScreen: Boolean;
By: ZephyrsFury
Description: Returns True if the Bee Hive Construction screen is open.
*******************************************************************************}
function BeeScreen: Boolean;
begin
Result := (GetColor(500, 20) = 39423);
end;
{*******************************************************************************
function Bee_Convo: Boolean;
By: ZephyrsFury
Description: Handles the conversation with the Bee Keeper.
*******************************************************************************}
function Bee_Convo: Boolean;
var
T: integer;
begin
T := GetSystemTime;
while (GetSystemTime - T < 20000) do
begin
if (BeeScreen) then Break;
ClickContinue(True, True);
FindTextTpa(0, 0, MCX1, MCY1, MCX2, MCY2, 'Yeah', NPCChars, ClickLeft);
Wait(100 + Random(500));
end;
Result := BeeScreen;
end;
{*******************************************************************************
function Bee_Puzzle: Boolean;
By: Lord Saturn remade by IceFire908
Description: Tries to build the bee hive.
*******************************************************************************}
function Bee_Puzzle: Boolean;
var
StartPs, DestPs: array [0..3] of Boolean;
DestP, StartP, TPA: TPointArray;
PartColors: TVariantArray;
T, C: LongInt;
I, II: Byte;
P: TPoint;
begin //lwr mid lid legs
PartColors := [GetColor(454, 267), 0.00, 3.71, GetColor(429, 212), 0.00, 2.81, 5592409, 4.17, 0.06];
StartP := [Point(79, 55), Point(80, 104), Point(81, 156), Point(76, 205)];
DestP := [Point(260, 151), Point(260, 48), Point(258, 204), Point(259, 98)];
for I := 0 to 2 do
begin
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(PartColors[1 + (3 * I)], PartColors[2 + (3 * I)]);
T := GetSystemTime;
while ((not (FindColorsTolerance(TPA, PartColors[3 * I], 30, 31, 124, 219, 1))) and ((GetSystemTime - T) < 7000)) do
Wait(RandomRange(500, 750));
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(1);
if (Length(TPA) < 1) then
Continue;
P := MiddleTPA(TPA);
if (not (PointInBox(P, IntToBox(30, 31, 124, 219)))) then
Continue;
for II := 0 to 3 do
if ((Distance(80, P.Y, StartP[II].X, StartP[II].Y) < 20) and (not (StartPs[II]))) then
begin
StartPs[II] := True;
P := StartP[II];
Break;
end;
if (I > 3) then
Continue;
if (not (DestPs[I])) then
begin
DestPs[I] := True;
DragMouse(P.X, P.Y, 2, 2, DestP[I].X, DestP[I].Y, 2, 2);
Wait(RandomRange(200, 500));
end;
end;
for I := 0 to 3 do
if (not (StartPs[I])) then
for II := 0 to 3 do
if (not (DestPs[II])) then
begin
StartPs[I] := True;
DestPs[II] := True;
DragMouse(StartP[I].X, StartP[I].Y, 2, 2, DestP[II].X, DestP[II].Y, 2, 2);
Wait(RandomRange(200, 500));
end;
c := CountColor(0, MCX1, MCY1, MCX2, MCY2);
Mouse(270, 275, 10, 5, True);
T := GetSystemTime;
while (CountColor(0, MCX1, MCY1, MCX2, MCY2) = c) do
begin
if (GetSystemTime - T > 5000) then Break;
Wait(100);
end;
Result := FindTextTpa(0, 0, MCX1, MCY1, MCX2, MCY2, 'move', NPCChars, Nothing);
if Result then
begin
T := GetSystemTime;
while (PercentBlackMM = 100) do
begin
if (ClickContinue(True, True)) then
begin
Wait(500 + Random(100));
T := GetSystemTime;
end;
if GetSystemTime - T > 15000 then Exit;
Wait(100);
end;
end;
Result := (PercentBlackMM < 100);
end;
{*******************************************************************************
function SolveBeeKeeper: Boolean;
By: Lord Saturn & ZephyrsFury
Description: Solves the Bee Keeper Random.
*******************************************************************************}
function SolveBeeKeeper: Boolean;
var
Tries: Integer;
begin
for Tries := 0 to 3 do
begin
if (PercentBlackMM < 100) then
begin
Result := True;
Exit;
end;
if Bee_Convo then
Result := Bee_Puzzle;
if (Result) then
Exit;
if (Tries < 3) then
WriteLn('Failed to solve, retrying...');
end;
end;