SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » Sandwich Solver Routines --//
//-----------------------------------------------------------------//
// * function Sandwich_InRandom: Boolean; // * by Nielsie95
// * function Sandwich_InMenu: Boolean; // * by Nielsie95
// * function Sandwich_SolveQuestion(s: string): Boolean; // * by Nielsie95
// * function SolveSandwichLady: Boolean; // * by Nielsie95
//-----------------------------------------------------------------//
{*******************************************************************************
function Sandwich_InRandom: Boolean;
by: Nielsie95
Description: Checks if we're in the Sandwich Lady random.
*******************************************************************************}
function Sandwich_InRandom: Boolean;
begin
Result := (not(TabExists(tab_Inv)));
end;
{*******************************************************************************
function Sandwich_InMenu: Boolean;
by: Nielsie95
Description: Returns True if the sandwich option screen is open.
*******************************************************************************}
function Sandwich_InMenu: Boolean;
begin
Result := SimilarColors(GetColor(502, 22), 8042720, 3);
end;
{*******************************************************************************
function Sandwich_SolveQuestion(s: string): Boolean;
by: Nielsie95
Description: Checks and Picks the required food item.
*******************************************************************************}
function Sandwich_SolveQuestion(s: string): Boolean;
var
i, x, y, t: Integer;
p, z: TPointArray;
q: T2DPointArray;
b: TBox;
Info: TVariantArray;
begin
Result := False;
case s of
'baguette', 'square sandwich', 'triangle sandwich':
Info := [3631225, 24, 300, 0.03, 0.45];
'roll', 'bread roll':
Info := [1540514, 20, 400, 0.02, 0.16];
'meat pie', 'pie':
Info := [5264481, 25, 400, 0.25, 0.35];
{'meat pie',} 'doughnut':
Info := [6014428, 10, 400, 0.02, 2.37];
'kebab':
Info := [4091012, 25, 150, 0.02, 0.5];
'chocolate bar':
Info := [1914204, 15, 150, 0.04, 0.14];
else
begin
WriteLn('Sandwich Lady: Unknown target: '+s+'!');
CloseWindow;
Exit;
end;
end;
SetColorSpeed2Modifiers(Info[3], Info[4]);
case s of
'kebab', 'chocolate bar', 'roll', 'bread roll', 'meat pie', 'pie', 'doughnut':
begin
t := GetSystemTime;
while (not Result) and ((GetSystemTime - t) < 15000) and
Sandwich_InMenu do
begin
FindColorsTolerance(p, Info[0], 60, 115, 475, 275, Info[1]);
if (Length(p) < Info[2]) then Continue;
q := SplitTPAEx(p, 3, 3);
SortATPASize(q, True);
for i := 0 to High(q) do
begin
if (Length(q[i]) < Info[2]) then Break;
b := GetTPABounds(q[i]);
if (not InRange(b.x2 - b.x1, 10, 65) and InRange(b.y2 - b.y1, 10, 65)) then Continue;
MiddleTPAEx(q[i], x, y);
if IntInBox(x, y, IntToBox(83, 135, 460, 270)) then
begin
//WriteLn(Length(q[i]));
Mouse(x, y, 6, 6, True);
x := GetSystemTime;
while Sandwich_InMenu and ((GetSystemTime - x) < 15000) do Wait(100);
Result := True;
Break;
end;
end;
Wait(60);
end;
end;
'baguette', 'square sandwich', 'triangle sandwich':
begin
t := GetSystemTime;
while ((GetSystemTime - t) < 15000) and Sandwich_InMenu do
begin
FindColorsTolerance(z, Info[0], 60, 115, 475, 275, Info[1]);
if (Length(z) < Info[2]) then Continue;
q := SplitTPAEx(z, 5, 5);
SortATPASize(q, True);
x := 0;
for i := 0 to High(q) do
if (Length(q[i]) > 200) then
Inc(x);
if (x > 2) then
begin
SetLength(z, 3);
y := 0;
for i := 0 to High(q) do
if (Length(q[i]) > 200) then
begin
z[y] := MiddleTPA(q[i]);
Inc(y);
if (y > 2) then Break;
end;
Break;
end;
Wait(60);
end;
if (Length(z) = 3) then
begin
t := GetSystemTime;
while ((GetSystemTime - t) < 15000) and (Length(z) > 1) do
begin
for i := 0 to High(z) do
begin
if (s = 'baguette') then
if (CountColorTolerance(954823, z[i].x - 20, z[i].y - 20, z[i].x + 20, z[i].y + 20, 25) > 75) then
begin
Swap(z[i], z[High(z)]);
SetLength(z, Length(z) -1);
Continue;
end;
FindColorsTolerance(p, Info[0], z[i].x - 40, z[i].y - 40, z[i].x + 40, z[i].y + 40, Info[1]);
if (Length(p) > 800) then
begin
q := SplitTPAEx(p, 3, 3);
SortATPASize(q, True);
z[i] := MiddleTPA(p);
if (Length(q[0]) > 1800) then
if (s = 'square sandwich') then
begin
Swap(z[0], z[i]);
SetLength(z, 1);
Break;
end
else
begin
Swap(z[i], z[High(z)]);
SetLength(z, Length(z) -1);
Continue;
end;
b := GetTPABounds(q[0]);
if (((b.x2 - b.x1) > 75) and ((b.y2 - b.y1) < 20)) or
(((b.y2 - b.y1) > 75) and ((b.x2 - b.x1) < 20)) then
if (s = 'baguette') then
begin
Swap(z[0], z[i]);
SetLength(z, 1);
Break;
end
else
begin
Swap(z[i], z[High(z)]);
SetLength(z, Length(z) -1);
Continue;
end;
end;
end;
Wait(60);
end;
end
else
begin
WriteLn('Could not find 3 possible options!');
CloseWindow;
Exit;
end;
if (Length(z) = 1) then
begin
Mouse(z[0].x, z[0].y, 6, 6, True);
x := GetSystemTime;
while Sandwich_InMenu and ((GetSystemTime - x) < 15000) do Wait(100);
Result := True;
end;
end;
end;
end;
{*******************************************************************************
function SolveSandwichLady: Boolean;
by: Nielsie95
Description: Solves the Sandwich Lady random.
*******************************************************************************}
function SolveSandwichLady: Boolean;
var
x, y, t, cts, deg: Integer;
s: string;
aci: TAutoColorInfo;
begin
Result := False;
if (not Sandwich_InRandom) then
begin
WriteLn('Not in Sandwich Lady!');
Exit;
end;
with aci do
begin
UpText := 'Talk';
MaxDist := 15;
Color := 8620738;
HueMod := 0.06;
SatMod := 0.81;
LumTol := 19;
MinR := 135; MaxR := 232;
MinG := 99; MaxG := 193;
MinB := 92; MaxB := 191;
MinX := 16.67; MaxX := 61.12;
MinY := 15.12; MaxY := 58.43;
MinZ := 12.38; MaxZ := 56.78;
MinCount := 100;
end;
cts := GetColorToleranceSpeed;
deg := Round(rs_GetCompassAngleDegrees);
MakeCompass('n');
SetAngle(True);
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.2, 0.2);
t := GetSystemTime;
SetAngle(True);
while (not FindColorTolerance(x, y, 2070783, 130, 260, 215, 315, 2)) and
((GetSystemTime - t) < 40000) do
begin
Wait(1500);
if AreTalking then
begin
if (not ClickContinue(True,True)) then
FindNPCChatText('ready to try', ClickLeft);
end
else if FindObjRecordEx(x, y, aci, MSX1, MSY1, MSX2, MSY2, False, False) then
begin
Mouse(x, y, 0, 0, False);
Wait(100 + Random(200));
ChooseOption('Talk');
Wait(500);
FFlag(0);
x := GetSystemTime;
while (not AreTalking) and ((GetSystemTime - x) < 5000) do Wait(100);
end;
end;
if FindColorTolerance(x, y, 2070783, 130, 260, 215, 315, 2) then
begin
s := rs_GetUpTextAt(x, y - 2, 38)
s := Trim(LowerCase(Between('Have a', 'for free', s)));
end;
if (s = '') then
begin
WriteLn('Sandwich Lady: Could not find target!');
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(cts);
CloseWindow;
Exit;
end;
WriteLn('Sandwich Lady: Target: '+s);
if Sandwich_SolveQuestion(s) then
begin
if Sandwich_InMenu then
CloseWindow;
with aci do
begin
UpText := 'orta';
MaxDist := 15;
Color := 8565144;
HueMod := 0.10;
SatMod := 0.45;
LumTol := 15;
MinR := 112; MaxR := 193;
MinG := 141; MaxG := 210;
MinB := 90; MaxB := 173;
MinX := 18.35; MaxX := 52.00;
MinY := 23.59; MaxY := 59.81;
MinZ := 13.46; MaxZ := 47.84;
MinCount := 100;
end;
t := GetSystemTime;
while Sandwich_InRandom and ((GetSystemTime - t) < 20000) do
begin
Wait(100);
if AreTalking then
ClickContinue(True,True)
else if FindObjRecordEx(x, y, aci, MSX1, MSY1, MSX2, MSY2, False, False) then
begin
Mouse(x, y, 0, 0, False);
Wait(100 + Random(200));
ChooseOption('Enter');
Wait(500);
FFlag(0);
Wait(4000);
end;
end;
end;
Result := (not Sandwich_InRandom);
MakeCompass(IntToStr(Deg));
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(cts);
end;