SRL Archive - Test corner

Procedure DropDTM(DTM: Integer; DropPattern: Integer);


Bionicle

2010-01-29 21:55:29

Well I made this function for my script, and I realized that SRL could use a function that would drop items by DTMs.

What it does:
  • Drops a certain item in your inventory with five different patterns.
  • If an item is missed for some reason or another (probably lag), the procedure will look back after dropping the next item to see if that one was dropped or not, and if it was not, drops it.
  • If any items were missed, at the end the procedure will look at the inventory and drop any other items.
  • One every forty times the script will 'accidentally' hit the "Use" option and click the item to un-highlight it, or hit the "Examine" option.

{*******************************************************************************
procedure DropDTM(DTM: Integer; DropPattern: Integer);
By: bionicle1800
Description: Drops an item by the DTM specified by the user. There is five
different dropping patterns, specified in the integer DropPattern
as 1, 2, 3, 4 or 5. 0 is a random pattern. If an item is missed
due to lag, it will go back and drop it. After the inventory is
dropped, it will search for items it may have missed before ending.
Also has AntiBan where the function will 'accidentally' click 'use'
or 'examine' one every forty times.
*******************************************************************************}
Procedure DropDTM(DTM: Integer; DropPattern: Integer);

Var
I, K, DropTime: Integer;
InvSlot, InvSlot2: TBox;
WayDrop: TIntegerArray;

Begin
If Not LoggedIn Then
Exit;

GameTab(Tab_Inv);
If InRange(DropPattern, 0, 6) Then
Begin
Srl_Warn('DropDTM', 'DropPattern ' + IntToStr(DropPattern) + ' is not a valid number.', warn_AllVersions);
Exit;
End;

If DropPattern = 0 Then
DropPattern := RandomRange(1, 6);

Case DropPattern Of
1: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
3: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
4: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
5: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
End;
For I := 0 To 27 Do
Begin
InvSlot := InvBox(WayDrop[I]);

If FindDTM(DTM, X, Y, InvSlot.X1, InvSlot.Y1, InvSlot.X2, InvSlot.Y2) Then
Begin
Case Random(40) Of
0: Begin
Mouse(X, Y, 3, 3, false);
WaiOption('xamine', 30+Random(30));
End;
19: Begin
Mouse(X, Y, 3, 3, false);
WaitOption('Use', 30+Random(30));
Wait(30+Random(30));
Mouse(X, Y, 4, 4, true);
End;
End;
Mouse(X, Y, 3, 3, false);
WaitOption('rop', 30+Random(30));
Wait(50+Random(50));
If (I > 0) Then
Begin
K := I - 1;
InvSlot2 := InvBox(WayDrop[K]);

If FindDTM(DTM, X, Y, InvSlot2.X1, InvSlot2.Y1, InvSlot2.X2, InvSlot2.Y2) Then
Begin
Mouse(X, Y, 3, 3, false);
WaitOption('rop', 30+Random(30));
Wait(50+Random(50));
End Else
Wait(10+Random(5));

End;
End;
End;
MarkTime(DropTime);
Repeat

If FindDTM(DTM, X, Y, MIX1, MIY1, MIX2, MIY2) Then
Begin
Mouse(X, Y, 3, 3, false);
WaitOption('rop', 30+Random(30));
Wait(300+Random(300));
End Else
Break;

Until(TimeFromMark(DropTime) > 20000)
Writeln('Dropped all items.');
End;

E: Fixed something
E2: Shortened, thanks R!ch!e :p

Timer

2010-01-29 21:56:58

procedure DropItemsByIdentifier(ItemType: string; Identifier: Integer; Tol: TIntegerArray);

Bionicle

2010-01-29 21:58:52

From: Timer
procedure DropItemsByIdentifier(ItemType: string; Identifier: Integer; Tol: TIntegerArray);


Hmm. Well it's still an improvement imo with the better drop detection…

Timer

2010-01-29 22:03:47

If it works, we don't replace it.

Bionicle

2010-01-29 22:05:29

From: Timer
If it works, we don't replace it.


I never said replace…this can be added along side…it is completely different except for the fact that it uses DTMs, and, imo, less 'bot like'. I don't think any current dropping procedures look back to see if the item was actually dropped or not.

YoHoJo

2010-01-29 22:46:38

I like it a lot, because my powerminer's looks just like it pretty much! :p =D

Rick

2010-01-29 23:57:14

Hmm, some feedback for this procedure:

Eww Capitalised bolds :p


If Not GameTab(Tab_Inv) Then
GameTab(Tab_Inv);

The GameTab function already checks if it is on the desired tab so it could just be:


GameTab(Tab_Inv);


If DropPattern > 5 Then

You should use an in range check:


If InRange(DropPattern, 0, 5) Then


If DropPattern = 0 Then
Begin

Case Random(5) Of
0: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
1: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
3: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
4: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
End;

End Else
Begin

Case DropPattern Of
1: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
3: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
4: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
5: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
End;

End;

Could be greatly shortened to:


if DropPattern = 0 then
DropPattern := RandomRange(1, 6);
case DropPattern Of
1: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
3: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
4: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
5: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
end;


Wait(30+Random(30));
ChooseOption('rop');

You could use:

WaitOption('rop', 30 + Random(30))


If (I > 0) Then
Begin
K := I - 1;

Not really sure what you're doing here :/


Repeat
If FindDTM(DTM, X, Y, MIX1, MIY1, MIX2, MIY2) Then
Begin
Mouse(X, Y, 3, 3, false);
Wait(30+Random(30));
ChooseOption('rop');
Wait(300+Random(300));
End Else
Break;
Until(TimeFromMark(DropTime) > 20000)

This could still potentially miss some items, and if it doesn't find the DTM in each InvBox, why would it find the DTM in a much larger area. If it fails to find the DTM, it is because the user messed up their DTM :)

So you procedure, with proper standards :p becomes this:



procedure DropDTM(DTM: Integer; DropPattern: Integer);
var
i, K, DropTime: Integer;
InvSlot: TBox;
WayDrop: TIntegerArray;
begin
if not LoggedIn then
Exit;
GameTab(Tab_Inv);
if InRange(DropPattern, 0, 5) then
begin
Srl_Warn('DropDTM', 'DropPattern ' + IntToStr(DropPattern) + ' is not a valid number.', warn_AllVersions);
Exit;
end;
if DropPattern = 0 then
DropPattern := RandomRange(1, 6);
case DropPattern Of
1: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
3: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
4: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
5: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
end;
for i := 0 to 27 do
begin
InvSlot := InvBox(WayDrop[i]);
if FindDTM(DTM, X, Y, InvSlot.X1, InvSlot.Y1, InvSlot.X2, InvSlot.Y2) then
begin
case Random(40) of
0: begin
Mouse(X, Y, 3, 3, false);
Wait(30+Random(30));
ChooseOption('xamine');
end;
19: begin
Mouse(X, Y, 3, 3, false);
ChooseOption('Use');
Wait(30+Random(30));
Mouse(X, Y, 4, 4, true);
end;
end;
Mouse(X, Y, 3, 3, false);
WaitOption('rop', 30 + Random(30));
end;
end;
end;

Nice Work :)

Also, is anyone else getting this invalid parameters issue in Sandwich.scar ?

Bionicle

2010-01-30 09:57:15

From: r!ch!e
Hmm, some feedback for this procedure:

Eww Capitalised bolds :p


If Not GameTab(Tab_Inv) Then
GameTab(Tab_Inv);

The GameTab function already checks if it is on the desired tab so it could just be:


GameTab(Tab_Inv);


If DropPattern > 5 Then

You should use an in range check:


If InRange(DropPattern, 0, 5) Then


If DropPattern = 0 Then
Begin

Case Random(5) Of
0: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
1: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
3: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
4: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
End;

End Else
Begin

Case DropPattern Of
1: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
3: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
4: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
5: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
End;

End;

Could be greatly shortened to:


if DropPattern = 0 then
DropPattern := RandomRange(1, 6);
case DropPattern Of
1: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
3: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
4: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
5: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
end;


Wait(30+Random(30));
ChooseOption('rop');

You could use:

WaitOption('rop', 30 + Random(30))


If (I > 0) Then
Begin
K := I - 1;

Not really sure what you're doing here :/


Repeat
If FindDTM(DTM, X, Y, MIX1, MIY1, MIX2, MIY2) Then
Begin
Mouse(X, Y, 3, 3, false);
Wait(30+Random(30));
ChooseOption('rop');
Wait(300+Random(300));
End Else
Break;
Until(TimeFromMark(DropTime) > 20000)

This could still potentially miss some items, and if it doesn't find the DTM in each InvBox, why would it find the DTM in a much larger area. If it fails to find the DTM, it is because the user messed up their DTM :)

So you procedure, with proper standards :p becomes this:



procedure DropDTM(DTM: Integer; DropPattern: Integer);
var
i, K, DropTime: Integer;
InvSlot: TBox;
WayDrop: TIntegerArray;
begin
if not LoggedIn then
Exit;
GameTab(Tab_Inv);
if InRange(DropPattern, 0, 5) then
begin
Srl_Warn('DropDTM', 'DropPattern ' + IntToStr(DropPattern) + ' is not a valid number.', warn_AllVersions);
Exit;
end;
if DropPattern = 0 then
DropPattern := RandomRange(1, 6);
case DropPattern Of
1: WayDrop := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28];
2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
3: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
4: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
18, 23, 28, 17, 22, 27, 21, 26, 25];
5: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
end;
for i := 0 to 27 do
begin
InvSlot := InvBox(WayDrop[i]);
if FindDTM(DTM, X, Y, InvSlot.X1, InvSlot.Y1, InvSlot.X2, InvSlot.Y2) then
begin
case Random(40) of
0: begin
Mouse(X, Y, 3, 3, false);
Wait(30+Random(30));
ChooseOption('xamine');
end;
19: begin
Mouse(X, Y, 3, 3, false);
ChooseOption('Use');
Wait(30+Random(30));
Mouse(X, Y, 4, 4, true);
end;
end;
Mouse(X, Y, 3, 3, false);
WaitOption('rop', 30 + Random(30));
end;
end;
end;

Nice Work :)

Also, is anyone else getting this invalid parameters issue in Sandwich.scar ?


Thanks for that :p I knew it could probably be shortened some how, but I didn't know how, also yea I got that problem a few days ago, just uninstall and reinstall SCAR/SRL.

DropPattern := RandomRange(1, 6);
Thanks, but shouldn't it be 1, 5? :p

Also the:

If (I > 0) Then
Begin
K := I - 1;
Is for the looking back one inventory slot to see if the log was dropped, if you look further down, it would make sense:
If (I > 0) Then
Begin
K := I - 1;
InvSlot2 := InvBox(WayDrop[K]);
If FindDTM(DTM, X, Y, InvSlot2.X1, InvSlot2.Y1, InvSlot2.X2, InvSlot2.Y2) Then
Begin
Mouse(X, Y, 3, 3, false);
Wait(30+Random(30));
ChooseOption('rop');
Wait(50+Random(50));
End Else
Wait(10+Random(5));
End;
The If (I > 0) is there because there is no -1 inventory slot :p it would just come back with an invalid parameters error.

And also, that last part, usually the item is missed due to lag (at least for me), and it has worked flawlessly so far for me.


@YoHoJo, i just had a look at your procedure, and its similar with the examine and the use, but definitely not the same :p

Rick

2010-01-30 11:51:46


program New;

var
i: Integer;

begin
for i := 0 to 9999 do
if RandomRange(1, 5) = 5 then
Writeln('Lol');
end.

Try running that and see if it returns 'Lol' :p RandomRange(1, 6) means a random number from 1, 2, 3, 4, 5.

If it lags then maybe increase your wait times ? I just feel its kinda pointless code.

And you could still use WaitOption :p

Bionicle

2010-01-30 12:35:01

From: r!ch!e

program New;

var
i: Integer;

begin
for i := 0 to 9999 do
if RandomRange(1, 5) = 5 then
Writeln('Lol');
end.

Try running that and see if it returns 'Lol' :p RandomRange(1, 6) means a random number from 1, 2, 3, 4, 5.

If it lags then maybe increase your wait times ? I just feel its kinda pointless code.

And you could still use WaitOption :p


Increase wait time = slower drop :p
And yea, i forgot to put in WaitOption, ill put it in now.

Rick

2010-01-30 13:56:08

Lo, you still didn't change DropPattern := RandomRange(1, 6); Right now, drop pattern 5 is being missed.

Bionicle

2010-01-30 14:45:03

From: r!ch!e
Lo, you still didn't change DropPattern := RandomRange(1, 6); Right now, drop pattern 5 is being missed.


Lol, yea I was kicked off the computer before I could finish fixing it, along with the WaitOptions…just did it, thanks :p