Brandon
01-19-2012, 02:54 AM
How can I make this function better? It highlights all the items on the floor using paint.. but for whatever reason it won't click exactly where the paint is.. instead it hovers NEAR it and always at the same item instead of iterating through all ground items:
Procedure PickUpItems(ItemList: TStringArray);
var
Items, TPA: TPointArray;
Item: TPoint;
ItemArray: Array of ItemPickup;
I, CTS: Integer;
begin
LProc:= 'PickUpItems';
SetLength(ItemArray, Length(ItemCheckList) + 1);
For I:= 0 To High(ItemCheckList) do
Case lowercase(ItemCheckList[I]) of
'noted':
begin
ItemArray[I].Color := 8767731; //Noted Items.
ItemArray[I].Speed := [0.64, 1.34];
ItemArray[I].Tolerance := 10;
end;
'bones', 'bone':
begin
ItemArray[I].Color := 13423589; //Bones Items.
ItemArray[I].Speed := [0.39, 2.16];
ItemArray[I].Tolerance := 11;
end;
'bluecharm', 'blue charm', 'bluecharms':
begin
ItemArray[I].Color := 10725730; //BlueCharm Items.
ItemArray[I].Speed := [0.11, 0.44];
ItemArray[I].Tolerance := 22;
end;
'coins', 'gold', 'gp':
begin
ItemArray[I].Color := 4641005; //Coins Items.
ItemArray[I].Speed := [0.29, 3.33];
ItemArray[I].Tolerance := 5;
end;
end;
Items:= GetMMDotsOnMS('item');
if (Length(Items) > 0) then
begin
Item:= MMToMS(Items[0]);
if ((Item.X <> 0) AND (Item.Y <> 0) AND (InvFull = False)) then
begin
For I:= 0 To High(ItemArray) - 1 do
begin
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(ItemArray[I].Speed[0], ItemArray[I].Speed[1]);
FindColorsTolerance(TPA, ItemArray[I].Color, MSX1, MSY1, MSX2, MSY2, ItemArray[I].Tolerance);
DebugTPA(TPA, '');
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.02, 0.02);
end;
if (Length(TPA) < 1) then
exit;
Item.x:= MSCX; Item.y:= MSCY;
SortTPAFrom(TPA, Item);
For I:= 0 To High(TPA) do
begin
//MiddleTPAEx(TPA, Item.X, Item.Y);
//MMouse(Item.X, Item.Y, 0, 0);
MMouse(TPA[I].x, TPA[I].y, 0, 0);
wait(200);
if (isUptextMultiCustom(ItemList) or IsUptextMultiCustom(['ake', 'nteract', 'ttack'])) then
begin
ClickMouse2(False);
WaitOptionMulti(ItemList, 300);
wait(200);
while isMoving do
wait(1);
end;
end;
end;
end;
end;
Procedure PickUpItems(ItemList: TStringArray);
var
Items, TPA: TPointArray;
Item: TPoint;
ItemArray: Array of ItemPickup;
I, CTS: Integer;
begin
LProc:= 'PickUpItems';
SetLength(ItemArray, Length(ItemCheckList) + 1);
For I:= 0 To High(ItemCheckList) do
Case lowercase(ItemCheckList[I]) of
'noted':
begin
ItemArray[I].Color := 8767731; //Noted Items.
ItemArray[I].Speed := [0.64, 1.34];
ItemArray[I].Tolerance := 10;
end;
'bones', 'bone':
begin
ItemArray[I].Color := 13423589; //Bones Items.
ItemArray[I].Speed := [0.39, 2.16];
ItemArray[I].Tolerance := 11;
end;
'bluecharm', 'blue charm', 'bluecharms':
begin
ItemArray[I].Color := 10725730; //BlueCharm Items.
ItemArray[I].Speed := [0.11, 0.44];
ItemArray[I].Tolerance := 22;
end;
'coins', 'gold', 'gp':
begin
ItemArray[I].Color := 4641005; //Coins Items.
ItemArray[I].Speed := [0.29, 3.33];
ItemArray[I].Tolerance := 5;
end;
end;
Items:= GetMMDotsOnMS('item');
if (Length(Items) > 0) then
begin
Item:= MMToMS(Items[0]);
if ((Item.X <> 0) AND (Item.Y <> 0) AND (InvFull = False)) then
begin
For I:= 0 To High(ItemArray) - 1 do
begin
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(ItemArray[I].Speed[0], ItemArray[I].Speed[1]);
FindColorsTolerance(TPA, ItemArray[I].Color, MSX1, MSY1, MSX2, MSY2, ItemArray[I].Tolerance);
DebugTPA(TPA, '');
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.02, 0.02);
end;
if (Length(TPA) < 1) then
exit;
Item.x:= MSCX; Item.y:= MSCY;
SortTPAFrom(TPA, Item);
For I:= 0 To High(TPA) do
begin
//MiddleTPAEx(TPA, Item.X, Item.Y);
//MMouse(Item.X, Item.Y, 0, 0);
MMouse(TPA[I].x, TPA[I].y, 0, 0);
wait(200);
if (isUptextMultiCustom(ItemList) or IsUptextMultiCustom(['ake', 'nteract', 'ttack'])) then
begin
ClickMouse2(False);
WaitOptionMulti(ItemList, 300);
wait(200);
while isMoving do
wait(1);
end;
end;
end;
end;
end;