Rich
2013-12-20 17:33:38
function dropItems(textsToLookFor: TStringArray; amountOfItems: Integer = 28) : TIntegerArray;
var
colourPoints: TPointArray;
slotColours: T2DIntegerArray;
blackAmounts: TIntegerArray;
dontCheck: TBoolArray;
slotBox: TBox;
i, ii, count, diff: Integer;
begin
setArrayLength(blackAmounts, 28);
setArrayLength(slotColours, 28);
setArrayLength(dontCheck, 28);
for i := 1 to 28 do
if tabBackpack.isItemInSlot(i) then
begin
slotBox := tabBackpack.getSlotBox(i);
blackAmounts[i - 1] := CountColorTolerance(65536, slotBox, 0);
incEx(slotBox.x1, 4);
DecEx(slotBox.x2, 4);
incEx(slotBox.y1, 4);
DecEx(slotBox.y2, 4);
colourPoints := slotBox.CreateTPA;
slotColours[i - 1] := getColors(colourPoints);
end;
for i := 1 to 28 do
if (tabBackpack.isItemInSlot(i) and (not dontCheck[i - 1])) then
begin
slotBox := tabBackpack.getSlotBox(i);
mouseBox(slotBox, MOUSE_MOVE);
if (isMouseOverText(textsToLookFor, 400)) then
begin
tabBackpack.dropItems([i]);
inc(result[count]);
wait(100 + random(200));
for ii := i + 1 to 28 do
begin
diff := (slotColours[i - 1].average - slotColours[ii - 1].average);
if (tabBackpack.isItemInSlot(ii) and InRange(diff, - 90000, 90000) and
(blackAmounts[i - 1] = blackAmounts[ii - 1])) then
begin
slotBox := tabBackpack.getSlotBox(ii);
mouseBox(slotBox, MOUSE_MOVE);
if isMouseOverText(textsToLookFor, 400) then
begin
tabBackpack.dropItems([ii]);
inc(result[count]);
wait(100 + random(200));
end;
end;
end;
inc(count);
if count = amountOfItems then
exit;
end
else
for ii := i + 1 to 28 do
if tabBackpack.isItemInSlot(ii) then
begin
diff := (slotColours[i - 1].average - slotColours[ii - 1].average);
if (blackAmounts[i - 1] = blackAmounts[ii - 1]) and
(inRange(diff, - 90000, 90000)) then
dontCheck[ii - 1] := true;
end;
end;
end; What this does it drop various items in your backpack by giving just the item names, and the amount of different items you're dropping to speed it up a bit. The function counts the amount of black pixels each item has, and works out the average colour for each slot in backpack. When it finds an item in the backpack which has MouseOverText which matches the input, it'll drop that item and any others which match the amount of black pixels and average colour (and of course a MouseOverText check just to be sure). Likewise, if it finds an item which isn't getting dropped, it'll not check other slots where the same item is for MouseOverText. It's always better to put the amount of items being dropped (for example 2) because after dropping 2 sets of different items the function will end. The length of result is the amount of different items dropped and the value for each field is the amount of each item dropped.
No idea why I wrote this, I got a bit bored after playing around thought someone might find it useful.
Cheers!