Here's some cooking interface functions that could probably use reworking;
work fine for me, but test/review would help me/others interested in working with the cooking interface.
{*******************************************************************************
Function to return true if the Cooking Interface pop up is open.
*******************************************************************************}
function Cook_Screen: boolean;
var
x,y,bmp: integer;
begin
Bmp := BitmapFromString(75, 25, 'meJzVmFtsVGUQxzGR2ylt91J62e1luyuFtibbLgnFtlJsaylXE2tKFKPSkFTEC/pEBWIAk5KIqS8F1BCJoQ9GnpBYow8GnkgM0Sdj4oOpb8ZLGo0++zvnvzv79exSNDEkkuHLnPnmm5n/zHxzznZ0587RcvSf/MtbG83T4PAOqK//YWhoeMc/sjBaQv8yBq+i4t7QqjVr71uxwqV75vqugUHL61RWRe5qJ4TurgCrIjFjyto3BaNYvAZa3loopJWr1kAG0MCiX9bvMkixdv+6VMPuqQ1H51sPXhBAjJQNSfbdqLBcGj/CUOSlBnXKhKZfmnBLu/RN0yxEqiMhF65lzkY7BtqOzmdnF8HomnJDssoiTCST2q2tbzCnPLgHwYgaJCEryvYIo3i0JYaS4YWD6YMXOk583zW7KILPHJhWHS2lyabWplT6gU0dWjMb2i0Yy7AbPxi7HICKx9LV0PdE24tz6+ozHAQIxiFtGRwcCbjBh3K5nJj19bXIWzMZpcWCkTVFQvyNOya7Zhaghj1ThATB+JLZRQJDAafKmxu8wSlNmqkJIHUMlYmzWO56Z6Hr/CIwrROIqr2zUzzR8l/WUgEEUQgvDGoKT6Ra2PWJb97nl+zUTTLpjhfFpuK6MWMB1yFo9igUdmFDAN1y+xUkjYFfnSJODhoWKasnqZFKaVlSvQSTOrKigJpbCIWhShGJyuRet7Yjc1ap0O1GDWu0KDkPVdYdPgbQ7mDpPJHcLoKdFWPALWlWBbsXCgbq6OxUNbWF043jxxgC2VM3OaWksducaoYvHezu5LE4LR578YXaIFsAKE0dN54JYKG6HmXN4i+NJJQf8gxAxkJDoXWl9uDxTx+Z+4UVgzKVaGql4pCSXOzk3F7UsjMLZCN9YFqXyG5T2/gxM5UcmTSM0fZtEuox3bELfutbt2jL5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UVaIcMm6anEJChBh/9vSl97/9M0THP/wsCMN/U/DbhpLV1tUTtg+w8JsCy0jydVy9RrebVa9pawZh0c9hZxZFgs/UqL0glh4J/6qNFsZyMQMF/eB7yTN5cNmLB+lM4PQOjVkaqYIw2qtQU8XHpbX4QyBe+unrAgy+Nqttojrx5Bk3bM/zyvPBZK5cGrYL2QAWlQsugACc1z//sSU3YOlFqEa1K0kgQSw1dwpgCQXo1i5pwjsrL01LOXmpsIxa+bPBpyA3l9nL/OQNSA9DXEAkzcFlcb7tvSV/QimgCFt25OWcehpf5fJTTr+ckaWpWy7huvsVNYm+M9f4+DTiY7WiLl32z1mj/6t/vX39jEfuV01tXUPvWOPIJN/zfH5HC++F7u7uwaER98jfsl7UXA==');
result := FindBitmapToleranceIn(bmp, x, y, MSX1, MSY1, MSX2, MSY2, 15);
freebitmap(bmp);
end;
{*******************************************************************************
Function to return true if the bmp created for the Overviewed item/main item being
investigated in the Cook_Screen is changed after TimeOut milliseconds.
*******************************************************************************}
function WaitCookItemChange(TimeOut: integer): boolean;
var
t, x, y, bmp: integer;
aBox: TBox;
begin
result := false;
aBox := IntToBox(247, 50, 282, 85);
CopyClientToBitmap(bmp, aBox.x1, aBox.y1, aBox.x2, aBox.y2);
MarkTime(t);
while (FindBitmapToleranceIn(bmp, x, y, aBox.x1, aBox.y1, aBox.x2, aBox.y2, 15)) do
begin
Wait(Round(TimeOut/10)+random(Round(TimeOut/15)));
if (TimeFromMark(t)>=TimeOut) then
exit;
end;
result := true;
end;
{*******************************************************************************
Function to return true after Selecting one of the 8 Lists in the Drop-Down
cooking interface menu. (See valid string parameters to pass to function)
Valid string arguements:
- 'Meat'
- 'Fish'
- 'Bread'
- 'Pies'
- 'Cake'
- 'Stew'
- 'Baked Potatoes'
- 'Other Recipes'
*******************************************************************************}
function FoodList(category: string): boolean;
var
i: integer;
TxtShow: string;
begin
result := false;
if not Cook_Screen then
exit;
TxtShow := GetTextAtExWrap(20, 45, 115, 58, 0, 5, 2, 6533359, 15, 'upchars'); // as far as the longest option goes... can be extended to the box shown after else;
if (TxtShow = category) then
begin
result := true;
exit;
end else
begin
MouseBox(18, 43, 235, 61, mouse_left);
for i := 0 to 7 do // currently 8 options shown in the drop down Combo Box, also currently 8 options for food categories too.
begin
TxtShow := GetTextAtExWrap(21, 69+(i*15), 118, 80+(i*15), 0, 5, 2, 6533359, 15, 'upchars');
if (TxTShow = category) then
begin
MouseBox(21, 69+(i*15), 118, 80+(i*15), mouse_left);
result := WaitCookItemChange(1500);
break;
end;
end;
end;
end;
{*******************************************************************************
Function to return true after finding the specific item name in one of
the 8 food lists. MUST ALREADY HAVE DESIRED ITEM IN INVENTORY.
See function details for valid food names.
*******************************************************************************}
function FoodFindEx(name: string): boolean;
var
i: integer;
aBox: TBox;
TPA: TPointArray;
boxCols: TIntegerArray;
overview: TStringArray;
list: Array[0..7] of Array of String;
begin
result := false;
overview := ['Meat', 'Fish', 'Bread', 'Pies', 'Cake', 'Stew', 'Baked Potatoes', 'Other Recipes'];
list[0] := ['Cooked chicken', 'Cooked undead chicken', 'Cooked meat', 'Cooked undead meat', 'Sinew', 'Poorly-cooked bird meat', 'Cooked rabbit', 'Poorly-cooked beast meat', 'Ugthanki meat', 'Cooked turkey', 'Cooked turkey drumstick', 'Thin snail meat', 'Lean snal meat', 'Cooked crab meat', 'Fat snail meat', 'Cooked oomlie wrap'];
list[1] := ['Crayfish', 'Shrimps', 'Karambwanji', 'Sardine', 'Anchovies', 'Poison karambwan', 'Herring', 'Mackerel', 'Trout', 'Cod', 'Pike', 'Salmon', 'Cooked slimy eel', 'Tuna', 'Cooked karambwan', 'Rainbow fish', 'Cave eel', 'Lobster', 'Bass', 'Swordfish', 'Lava eel', 'Monkfish', 'Shark', 'Baron shark', 'Sea turtle', 'Cavefish', 'Manta ray', 'Rocktail', 'Tiger shark'];
list[2] := ['Bread', 'Plain pizza', 'Pitta bread'];
list[3] := ['Redberry pie', 'Meat pie', 'Mud pie', 'Apple pie', 'Garden pie', 'Fish pie', 'Admiral pie', 'Wild pie', 'Summer pie'];
list[4] := ['Cooked fishcake', 'Cake'];
list[5] := ['Stew', 'Curry'];
list[6] := ['Baked Potato', 'Scrambled egg', 'Fried onions', 'Fried mushrooms'];
list[7] := ['Burnt meat', 'Burnt chicken', 'Soda ash', 'Barley malt', 'Bowl of hot water', 'Nettle tea', 'Cooked sweetcorn'];
boxCols := [1290732, 1269431];
for i := 0 to High(list) do
begin
if StrInArr(name, list[i]) then
if FoodList(overview[i]) then
begin
MMouse(240, 0, 500, 500); // don't want text hover hints to obstruct TPA finding
for i := 0 to High(boxCols) do
if FindColorsTolerance(TPA, boxCols[i], 18, 65, 220, 305, 15) then
begin
// AFAIK if you have the item, upon food list switch, you will auto-go to
// the item if the options (ex in fish list) has scroll-able amount of options.
// hence - won't need to change to add in scroll-to-find-item unless RS updates.
aBox := GetTPABounds(TPA);
MouseBox(aBox.x1, aBox.y1, aBox.x2, aBox.y2, mouse_left);
result := true;
writeln('Result = ' + BoolToStr(result) + ' ...');
exit;
end;
end;
end;
SetLength(TPA, 0);
SetLength(list, 0);
end;
{*******************************************************************************
Function to find an item and cook it all. *May want to add a second param,
in which is variant: all (bool) to cook all, or 1-28/x integer and grab
interface text to confirm amount of x-integer to cook.
item: string = the name of item to cook.
amount: variant = True to cook all, or integers 1-28.
*******************************************************************************}
function FoodMake(item: string): boolean;
var
i,x,y: integer;
aBox: TBox;
redX: TIntegerArray;
begin
result := false;
if FoodFindEx(item) then
begin
redX := [254,263108,328874];
for i := 0 to 2 do
if FindColorTolerance(x, y, redX[i], 445, 175, 480, 315-50, 10) then
exit; // can't proceed if we don't meet requirements / have materials.
GetMousePos(x,y);
aBox := IntToBox(260, 305, 480, 325);
if PointInBox(Point(x,y), aBox) then
ClickMouse2(Mouse_left)
else
MouseTBox(aBox, mouse_left);
result := true;
end;
end;
Cheers,
Lj