SRL Archive - Reflection Help

Findgrounditems help plz


ZaSz

2009-04-07 18:04:40

ok so i did
procedure pickupitems;
begin
if FindGroundItems(itemd, [idi1,idi2,idi3], 10) then
begin
for I := 0 to high(itemd) do
begin
gametab(4);
if (DistanceFrom(point(itemd[i].tile.x,itemd[i].tile.y)) < 8) then
begin
itempos := TileToMS(point(itemd[i].tile.x,itemd[i].Tile.y), Random(5));
mmouse(itempos.x,itempos.y,0,0);
wait(200+random(400));
for d := 0 to 2 do
if OptionExists(itemnames[d]) then
begin
mouse(itempos.x,itempos.y,1,1,false);
wait(300+random(600));
R_ChooseOption('ake '+itemnames[d]);
work;
end;
end;
if (DistanceFrom(point(itemd[i].tile.x,itemd[i].tile.y)) > 7) then
begin
walktotile(itemd[i].tile,2,1);
wait(400+random(400));
itempos := TileToMS(point(itemd[i].tile.x,itemd[i].Tile.y), Random(5));
mmouse(itempos.x,itempos.y,0,0);
wait(200+random(400));
for d := 0 to 2 do
if OptionExists(itemnames[d]) then
begin
mouse(itempos.x,itempos.y,1,1,false);
wait(300+random(600));
R_ChooseOption('ake '+itemnames[d]);
work;
end;
end;
end;
end;
end;

it finds items perfectly, but after I pick them up and go on, the next time i call the procedure, it checks where the last item was as if the item was still on the ground…

This is annoying once ive picked up 4 items cause it takes forever to pick up the only item on the ground…

HELP please.

caused

2009-06-13 02:28:38

I'm having excactly the same Problem.

FindGroundItems makes a list of items on the Ground that are in the defined ID range.

It always finds the same item again though..

Is there a solution yet ?

oh..
to clarify:
FindGroundItems(Items,[1540,1541],30)            //Clicks the right item
mouse(Items[0].MS.x,Items[0].MS.y,2,2,True); // ^^
FindGroundItems(Items,[1540,1541],30) //Clicks the same item as above, even if its gone.
mouse(Items[0].MS.x,Items[0].MS.y,2,2,True); // ^^

senrath

2009-06-13 02:31:58

After you act on the item, set the length of the array you used to 0.

Edit: Do this:

procedure pickupitems;
begin
if FindGroundItems(itemd, [idi1,idi2,idi3], 10) then
begin
for I := 0 to high(itemd) do
begin
gametab(4);
if (DistanceFrom(point(itemd[i].tile.x,itemd[i].tile.y)) < 8) then
begin
itempos := TileToMS(point(itemd[i].tile.x,itemd[i].Tile.y), Random(5));
mmouse(itempos.x,itempos.y,0,0);
wait(200+random(400));
for d := 0 to 2 do
if OptionExists(itemnames[d]) then
begin
mouse(itempos.x,itempos.y,1,1,false);
wait(300+random(600));
R_ChooseOption('ake '+itemnames[d]);
work;
end;
end;
if (DistanceFrom(point(itemd[i].tile.x,itemd[i].tile.y)) > 7) then
begin
walktotile(itemd[i].tile,2,1);
wait(400+random(400));
itempos := TileToMS(point(itemd[i].tile.x,itemd[i].Tile.y), Random(5));
mmouse(itempos.x,itempos.y,0,0);
wait(200+random(400));
for d := 0 to 2 do
if OptionExists(itemnames[d]) then
begin
mouse(itempos.x,itempos.y,1,1,false);
wait(300+random(600));
R_ChooseOption('ake '+itemnames[d]);
work;
end;
end;
end;
end;
SetArrayLength(itemd, 0);
end;

caused

2009-06-13 02:33:25

Damn, right. That should work.. Trying it now…

EDIT Works Really well :). Thanks

guess i should take a look at your scripts =). Much to learn X)

ZaSz

2009-06-13 02:50:35

I had this fixed, i just used setlength(itemd,0) before procedure.

this was for my autofighter lol

Shuttleu

2009-06-13 03:03:43

or create a local variable instead of a global one
it will save memory and one line less ;)

~shut