SRL Archive - SRL Archives

ExamineInv ~ Antiban.scar ~ R1ch


Rich

2009-07-03 19:23:15

This is a nice little function which examines a random item in the inventory if it finds one. If it finds an item and examines it, then the function will return true. Please let me know what you think.

*******************************************************************************
function ExamineInv(FromI, ToI : Integer) Boolean;
By: R1ch
Description: Chooses a random item in the inventory to examine
*******************************************************************************}
function ExamineInv(FromI, ToI : Integer) Boolean;
var
I, T : Integer;
Poz : TIntegerArray;

begin
if (InvEmpty or (not(LoggedIn))) then
Exit;
for I:= FromI to ToI do
if ItemExists(I) then
Poz[I]:= I;
MouseItem(Random(Poz), False);
Wait(500 + Random(1000);
Result:=WaitOption('xamine', 50);
end;

Richard.

Quickmarch

2009-07-03 19:25:47

Hmmm, good idea actually. :)

GJ!

Rich

2009-07-03 19:27:23

Woo! The first reply is a good one. That's always nice to see. Thanks Quickmarch.

Richard.

Naum

2009-07-03 19:30:07

Good, Good:

*******************************************************************************
function ExamineInv(FromI, ToI : Integer) Boolean;
By: R1ch
Description: Chooses a random item in the inventory to examine
*******************************************************************************}
function ExamineInv(FromI, ToI : Integer) Boolean;
var
I : Integer;
Poz : TIntegerArray;

begin
if (InvEmpty or (not(LoggedIn))) then
Exit;
for I:= FromI to ToI do
if ItemExists(I) then
Poz[i]:= I;
MouseItem(Random(Poz), False);
Wait(500 + Random(1000);
Result := WaitOption('xamine', 50);
end;

Rich

2009-07-03 19:35:27

Thanks Naum, it's the little changes that make it better. I'll change it int he first ost in a sec.

Richard.

Floor66

2009-07-03 19:43:42

Hey guys, shortened even more:

{*******************************************************************************
function ExamineInv(FromI, ToI : Integer) Boolean;
By: R1ch
Description: Chooses a random item in the inventory to examine
*******************************************************************************}
function ExamineInv(FromI, ToI : Integer): Boolean; var I : Integer; Poz : TIntegerArray; begin if (InvEmpty or (not(LoggedIn))) then Exit; for I:= FromI to ToI do if ExistsItem(I) then Poz[i]:= I; MouseItem(Poz[Random(Length(Poz))], False); Wait(500 + Random(1000)); Result := WaitOption('xamine', 50); end;

Ok, so sarcasm owns ^^.
Better?

{*******************************************************************************
function ExamineInv(FromI, ToI : Integer) Boolean;
By: R1ch
Description: Chooses a random item in the inventory to examine
*******************************************************************************}
function ExamineInv(FromI, ToI : Integer) Boolean;
var
I : Integer;
Poz : TIntegerArray;
begin
if (InvEmpty or (not(LoggedIn))) then
Exit;
for I:= FromI to ToI do
begin
if ExistsItem(I) then
Poz[i]:= I;
end;
MouseItem(Poz[Random(Length(Poz))], False);
Wait(500 + Random(1000);
Result := WaitOption('xamine', 50);
end;

Naum

2009-07-03 19:45:56

From: Floor66
Hey guys, shortened even more:

{*******************************************************************************
function ExamineInv(FromI, ToI : Integer) Boolean;
By: R1ch
Description: Chooses a random item in the inventory to examine
*******************************************************************************}
function ExamineInv(FromI, ToI : Integer): Boolean; var I : Integer; Poz : TIntegerArray; begin if (InvEmpty or (not(LoggedIn))) then Exit; for I:= FromI to ToI do if ExistsItem(I) then Poz[i]:= I; MouseItem(Poz[Random(Length(Poz))], False); Wait(500 + Random(1000)); Result := WaitOption('xamine', 50); end;
Ok, so sarcasm owns ^^.
Better?

{*******************************************************************************
function ExamineInv(FromI, ToI : Integer) Boolean;
By: R1ch
Description: Chooses a random item in the inventory to examine
*******************************************************************************}
function ExamineInv(FromI, ToI : Integer) Boolean;
var
I : Integer;
Poz : TIntegerArray;
begin
if (InvEmpty or (not(LoggedIn))) then
Exit;
for I:= FromI to ToI do
begin
if ExistsItem(I) then
Poz[i]:= I;
end;
MouseItem(Poz[Random(Length(Poz))], False);
Wait(500 + Random(1000);
Result := WaitOption('xamine', 50);
end;


??, Also you needed to call the length, I forgot, thought it was not an array :(.

Rich

2009-07-03 19:53:50

Ah, yes. I did the same Naum. I'll change that in a minute, after I've fixed a few bugs I found a minute ago.

EDIT: Okay guys. I would really appreciate some help with this. Whatever I do, I can't get it to to work.

Richard

Phran6

2009-07-03 21:11:25

i already have it in my script and it randomly cancel or examine:)

function WearingItemAntiBan(option:string):boolean; // xamine, ancel or random
var
v, i :integer;
z: tpoint;
begin
if (InvEmpty or (not(LoggedIn))) then Exit;
repeat
v:= random(10)+1;
if WearingItem(v) then
begin
z := EquipmentCoords(v);
if option = 'random' then
begin
case Random(2) of
0: option := 'xamin';
1: option := 'ancel';
end;
end;
mouse(z.x, z.y, 6, 6, false);
wait(50+random(50));
result := WaitOption('xamine', 200);
end;
Inc(i);
until(i > 11)or result;
end;

HyperSecret

2009-07-03 21:18:52

Well

MouseItem(random(poz), false);

Is going to pick a random index of poz.

So lets say ItemsExists at index 2, 8, 17, 27. 4 spots. So poz length = 4.
Random(poz) will pick a 0,1,2,3 and only those possiblities. So when it picks 3, there is no item that exists there so what your trying to do will fail.

think about it a little bit. if you can't get it I will help more.

Do a

Writeln(IntToStr(Random(poz))); and see what your outcome is ;).

Floor66

2009-07-03 21:45:02

@My post:

MouseItem(Poz[Random(Length(Poz))], False);

Sir R. M8gic1an

2009-07-04 04:55:03

well, i must say that you are using WaitOption wrong.


Wait(500 + Random(1000);
Result:=WaitOption('xamine', 50);

WaitOption was made precisely to avoid the Wait(500+random(100));


if WaitOption('xamine', 800) then
begin
wait(random(100));
Result := true;
end;

also, by calling ExistsItem in a loop, you are doing continuous FindColorsTolerance, which is not quite so effective.

~RM

EvilChicken!

2009-07-04 05:22:29

I added this to the openDev :)

Thanks, R1ch.

Nava2

2009-07-04 09:05:59

{*******************************************************************************
function ExamineInv(F, T : Integer) Boolean;
By: R1ch
Description: Chooses a random item in the inventory to examine
*******************************************************************************}
function ExamineInv(F, T: Integer) Boolean;
var
i, c : Integer;
p: TIntegerArray;
begin
if (InvEmpty) or (not(LoggedIn)) or (not InRange(T - F, 0, 27)) then Exit;

SetLength(p, T - F);
c := 0;
for i := F to T do
if ItemExists(I) then
begin
p[c]:= I;
Inc(c);
end;
MouseItem(p[Random(c)], False);
Wait(100 + Random(200));;
Result:=WaitOptionEx('xamine', 'action', ClickLeft, 300);
end;

Made it work ;)

Rich

2009-07-04 13:11:07

Thanks Nava! Would anyone be interested in using this?

Floor66

2009-07-04 13:13:14

I guess I would. It's added to the open dev anyways already.