SRL Archive - SRL Archives

DropAllDTM


Da 0wner

2009-05-22 02:35:48

function DropAllDTM(DTM : integer) : boolean;
var
i, x, y, c, t : integer;
box : TBox;
begin
for i := 1 to 28 do
begin
if not ExistsItem(i) then
Continue;
Box := InvBox(i);
if FindDTM(DTM, x, y, Box.x1, Box.y1, Box.x2, Box.y2) then
begin
c := GetColor(x, y);
Mouse(x, y, 3, 3, false);
Wait(100 + random(100));
ChooseOptionEx('rop', 'action');
MarkTime(t);
while (GetColor(x, y) = c) and (TimeFromMark(t) <= 3000) do
if TimeFromMark(t) >= 3000 then
break;
Wait(100 + random(100));
end;
end;
while (FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2)) and (TimeFromMark(t) <= 2500) do
if TimeFromMark(t) >= 2500 then
break;
result := not FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2);
end;

Drops all instances of the DTM. Very fast.

Dynamite

2009-05-22 02:36:42

Isnt there already something like this?
I will check.
Nice though.
Cheers :)

T~M

Da 0wner

2009-05-22 02:39:16

Maybe. However I looked in Inventory.scar and nothing like this. Closest thing is the drop functions that just drop the item in the slot.

Richard

2009-05-22 02:41:41

function DropAllDTM(DTM : integer) : boolean;
var
i, x, y, c, t : integer;
box : TBox;
begin
for i := 1 to 28 do
begin
if not ExistsItem(i) then
Continue;
Box := InvBox(i);
if FindDTM(DTM, x, y, Box.x1, Box.y1, Box.x2, Box.y2) then
begin
c := GetColor(x, y);
Mouse(x, y, 3, 3, false);
Wait(100 + random(100));
ChooseOption('rop');
MarkTime(t);
while (GetColor(x, y) = c) and (TimeFromMark(t) <= 3000) do
if TimeFromMark(t) >= 3000 then
break;
Wait(100 + random(100));
end;
end;
result := GetColor(x, y) <> c;
end;

Not bad, how quickly can it drop the invent?

Da 0wner

2009-05-22 02:43:42

I had mine exactly like yours.
It doesn't return the result correctly.

Richard

2009-05-22 02:45:11

Well it shouldn't do, are you sure it returned the result correctly normally?

You don't change the x and y values anywhere except for in FindDTM, so it shouldn't make any difference.

EDIT: Wait, your result will only return true if the final drop was successful, so if all the others fail, but the last one works, it claims it was successful…

Da 0wner

2009-05-22 02:49:15

Crap. I posted wrong one. I had mine check if it found the DTM found in the whole inventory.

Richard

2009-05-22 03:06:49

Not sure if it works, but I switched the x's and y's to TPAs to save having mass amounts of variables:

function DropAllDTM(DTM : integer) : boolean;
var
i, c, t, z : integer;
box : TBox;
XY: TPointArray;
begin
z := 0;
for i := 0 to 27 do
begin
if not ExistsItem(i+1) then
Continue;
Box := InvBox(i+1);
if FindDTM(DTM, XY[i].x, XY[i].y, Box.x1, Box.y1, Box.x2, Box.y2) then
begin
c := GetColor(XY[i].x, XY[i].y);
Mouse(XY[i].x, XY[i].y, 3, 3, false);
Wait(100 + random(100));
ChooseOption('rop');
MarkTime(t);
while (GetColor(XY[i].x, XY[i].y) = c) and (TimeFromMark(t) <= 3000) do
if TimeFromMark(t) >= 3000 then
break;
Wait(100 + random(100));
end;
end;
For i := 0 to High(XY) do
Begin
If (GetColor(XY[i].x, XY[i].y) <> c) then
Inc(z);
end;
Result := (z = 28);
end;

Doubt its very efficient though.

Da 0wner

2009-05-22 03:21:56

That might be a bit slower.
But the one I edited in the main post seems good for me :p.

Richard

2009-05-22 03:24:22

Shouldn't be too much slower, 1msec for each GetColor, only an extra 27 msecs.

But that way seems to make more sense.

Da 0wner

2009-05-22 03:33:11

Can you go on MSN??

Nadeem

2009-05-22 06:19:49

Whats the point of this block really?

MarkTime(t);
while (GetColor(XY[i].x, XY[i].y) = c) and (TimeFromMark(t) <= 3000) do
if TimeFromMark(t) >= 3000 then
break;

Like, we already know it is supposed to drop so why not just wait 100ms + random instead of wasting a few ms on that block of code..?

nonetheless, good job though :P



~NS

Da 0wner

2009-05-22 06:40:53

Failsafes newb.

Nava2

2009-05-22 07:16:22

You should use ChooseOptionEx :)

Will make it much faster.

Da 0wner

2009-05-22 07:19:53

What does it do differently?

Edit: Added it ;).

Nava2

2009-05-22 07:36:58

Out of curiousity, what was the time difference?

Da 0wner

2009-05-22 08:10:01

Didn't check :(.

marpis

2009-05-22 09:09:43

i think you should do

repeat
...
until(not FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2) or (TimeFromMark(t) > 60000));
cause if you get a lag spike and the Optionbox doesn't pop up instantly, the item will not be dropped.

Da 0wner

2009-05-22 09:18:39

No. You won't get a lag spike :D. If this gets added to SRL devs will do that maybe.

Nava2

2009-05-23 17:22:11

Just so your aware, this won't get added.

I might mod it though.