BazzBarrett
2009-02-26 20:30:27
kk this took me the last 4 hours hope you like it.
ive tested this on my acount and on pictures plus difrent combos and it worked perfect every time. realy realy needs testing though any bugs post it here and ill fix asap :) thanks to lysolman00 and Main_FTW for the pictures very very big help until i finaly got an acount in there. tell me what you think this is my first time solving a full random by color but i think i was pritty good.
EDIT: Added a few things mainly sujested by nava2
ive tested this on my acount and on pictures plus difrent combos and it worked perfect every time. realy realy needs testing though any bugs post it here and ill fix asap :) thanks to lysolman00 and Main_FTW for the pictures very very big help until i finaly got an acount in there. tell me what you think this is my first time solving a full random by color but i think i was pritty good.
EDIT: Added a few things mainly sujested by nava2
program New;
{.include SRL/SRL.scar}
{*******************************************************************************
Function InSandwichLady:Boolean;
by: BazzBarrett
Description: returns true if in the sandwich lady random.
*******************************************************************************}
function InSandwichLady: Boolean;
begin
Result := False;
if InBlack then
Result := GetMusic = 'Snack Attack';
end;
{*******************************************************************************
Function FindColorsForSandWitchLady(var x, y: Integer; Color, x1, y1, x2, y2, Tol: Integer):Boolean;
by: BazzBarrett
Description: Special color finding function specificly for Sandwich Lady.
*******************************************************************************}
Function FindColorsForSandWitchLady(var x, y: Integer; Color, x1, y1, x2, y2, Tol: Integer):Boolean;
var
CTS: Integer;
CTPA: TPointArray;
ATPA: T2DPointArray;
begin
try
Result := False;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if FindColorsTolerance(CTPA, color, x1, y1, x2, y2, Tol) then
begin
ATPA := TPAToATPAEx(CTPA, 70, 100);
SortATPASize(ATPA, True);
MiddleTPAEx(ATPA[0], X, Y);
Result := True;
end;
finally
ColorToleranceSpeed(CTS);
end;
end;
{*******************************************************************************
Procedure SandWichCorrectCoords(var p : TPoint);
by: BazzBarrett
Description: Fixes the location of the mouse when selecting the correct
food.
*******************************************************************************}
Procedure SandWichCorrectCoords(var p : TPoint);
begin
if distance(p.x, p.y, 116, 208) < 36 then p := Point(116, 208);
if distance(p.x, p.y, 180, 144) < 36 then p := Point(180, 144);
if distance(p.x, p.y, 214, 229) < 36 then p := Point(214, 229);
if distance(p.x, p.y, 293, 150) < 36 then p := Point(293, 150);
if distance(p.x, p.y, 335, 230) < 36 then p := Point(335, 230);
if distance(p.x, p.y, 429, 157) < 36 then p := Point(429, 157);
if distance(p.x, p.y, 427, 232) < 36 then p := Point(427, 232);
end;
{
Roll
Meat pie
doughnut
Chocolate bar
Baguette
Square sandwich
Triangle sandwich
}
{*******************************************************************************
Function SandwichFindFood(Food:String):Boolean;
by: BazzBarrett
Description: Finds food specifyed by food in the Sandwich lady random.
*******************************************************************************}
Function SandwichFindFood(Food:String):Boolean;
var
fx, fy, Fi, sbx, sby: Integer;
SB1, SB2: TBox;
FType: String;
begin
if (pos('roll', Food) > 0) then FType := 'roll';
if (pos('eat', Food) > 0) then FType := 'pie';
if (pos('ughn', Food) > 0) then FType := 'doughnut';
if (pos('olat', Food) > 0) then FType := 'chocolate';
if (pos('uett', Food) > 0) then FType := 'baguette';
if (pos('uar', Food) > 0) then FType := 's sandwich';
if (pos('ang', Food) > 0) then FType := 't sandwich';
For Fi := 0 to 20 do
begin
case LowerCase(FType) of
'roll': //FindColorSkipBoxTolerance
begin
if FindColorsForSandWitchLady(fx, fy, 1209743, 78, 133, 462, 248, 5) then
begin
MMouse(fx, fy, 5, 5);
Result := True;
exit;
end;
end;
'pie':
begin
if FindColorsForSandWitchLady(fx, fy, 7105652, 78, 133, 462, 248, 10) then
begin
MMouse(fx, fy, 5, 5);
Result := True;
exit;
end;
end;
'doughnut':
begin
if FindColorsForSandWitchLady(fx, fy, 5877182, 78, 133, 462, 248, 5) then
begin
MMouse(fx, fy, 5, 5);
Result := True;
exit;
end;
end;
'chocolate':
begin
if FindColorsForSandWitchLady(fx, fy, 1715272, 78, 133, 462, 248, 10) then
begin
MMouse(fx, fy, 5, 5);
Result := True;
exit;
end;
end;
'baguette':
begin
if SandwichFindFood('square') then
begin
GetMousePos(sbx, sby);
Sb1.x1 := Sbx-50;
Sb1.y1 := Sby - 50;
Sb1.x2 := Sbx + 50;
Sb1.y2 := Sby + 50;
if SandwichFindFood('Triange') then
begin
GetMousePos(sbx, sby);
Sb2.x1 := Sbx-50;
Sb2.y1 := Sby - 50;
Sb2.x2 := Sbx + 50;
Sb2.y2 := Sby + 50;
if FindColorSkipBoxArrayTolerance(fx, fy, 6989242, 78, 133, 462, 248, 5, [SB1, Sb2]) then
begin
MMouse(fx, fy, 5, 5);
Result := True;
exit;
end;
end;
end;
end;
's sandwich':
begin
if FindColorsForSandWitchLady(fx, fy, 5868444, 78, 133, 462, 248, 5) then
begin
MMouse(fx, fy, 5, 5);
Result := True;
exit;
end;
end;
't sandwich':
begin
if SandwichFindFood('square') then
begin
GetMousePos(sbx, sby);
Sb1.x1 := Sbx-50;
Sb1.y1 := Sby - 50;
Sb1.x2 := Sbx + 50;
Sb1.y2 := Sby + 50;
if FindColorSkipBoxTolerance(fx, fy, 1215567, 78, 133, 462, 248, 5, Sb1) then
begin
MMouse(fx, fy, 5, 5);
Result := True;
exit;
end;
end;
end;
end;
Wait(150);
end;
end;
{*******************************************************************************
Function FindTheLady:Boolean;
by: BazzBarrett
Description: Finds the Sandwich lady.
*******************************************************************************}
Function FindTheLady:Boolean;
var
CTS, II, lx, ly, Trys, I, LMin : Integer;
FoundHer: Boolean;
TPA : TPointArray;
ATPA: T2DPointArray;
begin
if GetColor(104, 27) = 0 then
begin
Result := True;
Exit;
end;
While Not(Foundher) or (Trys > 5) do
begin
MakeCompass('N');
SetAngle(True);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 10660562, MSX1, MSY1, MSX2, MSY2, 5);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
LMin := min(High(ATPA), 5);
For II := 0 to LMin do// I think this is the same as what you mean Nava2 - changed it again
begin
MiddleTPAEx(ATPA[II], lX, lY)
MMouse(lX, lY, 2, 2);
Wait(80+Random(40));
If(IsUpTextmultiCustom(['alk', 'alk-To', 'wich']))then
begin
Result := True;
Mouse(lx, ly, 0, 0, True);
FoundHer := True;
Break;
end;
end;
inc(Trys);
if Not(FoundHer) then
begin
wait(1000+random(500));
Mouse(656, 85, 4, 4, true);
wait(300);
FFlag(0);
end;
end;
if FoundHer then
begin
For I := 0 to 5 do
begin
Mouse(lx, ly, 0, 0, True);
wait(750+random(500));
ClickToContinue;
For II := 0 to 10 do
begin
Wait(750+random(300));
Result := (GetColor(55, 20) = 20);
if Result = True Then Break;
end;
if Result = true then exit;
end;
end;
Result := False;
Writeln('Failed To Find Sandwich Lady... logging out');
LogOut;
end;
{*******************************************************************************
Procedure LeaveSandwichLady;
by: BazzBarrett
Description: leaves the sandwich lady random through the portal.
*******************************************************************************}
Procedure LeaveSandwichLady;
var
CTS, II, lx, ly, Trys, I, LMin : Integer;
Foundit: Boolean;
TPA : TPointArray;
ATPA: Array of TPointArray;
begin
While Not(Foundit) or (Trys > 5) do
begin
MakeCompass('N');
SetAngle(True);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 6461561, MSX1, MSY1, MSX2, MSY2, 5);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 15, 15);
LMin := min(High(ATPA), 4);
For II := 0 to LMin do
begin
MiddleTPAEx(ATPA[II], lX, lY)
MMouse(lX, lY, 2, 2);
Wait(60+Random(30));
If(IsUpTextmultiCustom(['xit', 'nter', 'portal']))then
begin
Mouse(lx, ly, 0, 0, True);
Foundit := True;
Break;
end;
end;
inc(Trys);
if Not(Foundit) then
begin
wait(150+random(500));
Mouse(656, 85, 4, 4, true);
wait(300);
FFlag(0);
end;
end;
if Foundit Then
begin
Writeln('Sandwich lady random solved!');
end else
begin
Writeln('So close but failed to leave logging out');
logout;
end;
end;
{*******************************************************************************
Function SolveSandwichLady:Boolean;
by: BazzBarrett
Description: solves the sandwich lady random.
*******************************************************************************}
Function SolveSandwichLady:Boolean;
var
Food: String;
FI: Integer;
L: TPoint;
begin
if FindTheLady then
begin
Food := GetTextAtEx(150, 282, 20, SmallChars, False, False, 0, 3, 2070783, 35, false, tr_AllChars);
Food := Between('a ', ' for', Food);
Writeln('Found Sandwich Lady, choosing a ' + Food);
wait(1000+random(1000));
if SandwichFindFood(Food) then
begin
GetMousePos(L.x, L.y);
SandWichCorrectCoords(L);
Mouse(L.x, L.y, 3, 3, true);
writeln('Clicked ' + food);
wait(RandomRange(500, 1000));
ClickToContinue;
wait(RandomRange(500, 1000));
LeaveSandwichLady;
Result := True;
end else
begin
Writeln('Failed to Find the correct');
logout;
end;
end;
end;
begin
SetUpSRL;
ActivateClient;
if FindSandwichLady then SolveSandwichLady;
end.