SRL Archive - SRL Archives

Herblore.scar


Rich

2009-07-05 21:22:31

{*******************************************************************************
function CountEmptyVials : Integer;
By: R1ch
Description: Gets amount of empty vials in inventory
*******************************************************************************}
function CountEmptyVials : Integer;
begin
Result:= CountItems('bmp',srl_GetBitmap(srl_Empty_Vial), []);
srl_FreeBitmaps;
end;

{*******************************************************************************
function CountFullVials : Integer;
By: R1ch
Description: Gets amount of full vials in inventory
*******************************************************************************}
function CountFullVials : Integer;
begin
Result:= CountItems('bmp',srl_GetBitmap(srl_Full_Vial), []);
srl_FreeBitmaps;
end;

{*******************************************************************************
function CountAllVials : Integer;
By: R1ch
Description: Gets amount of vials in inventory
*******************************************************************************}
function CountAllVials : Integer;
begin
Result:= CountEmptyVials + CountFullVials;
end;

{*******************************************************************************
function EmptyVials(Amount : Integer) : Boolean;
By: R1ch
Description: Emptys Amount vial in the inventory.
*******************************************************************************}
function EmptyVials(Amount : Integer) : Boolean;
var
I, X, Y : Integer;
E, F : TIntegerArray;

begin
srl_LoadBitmaps([110, 111]);
if (CountFullVials < Amount) then
begin
srl_Warn('EmptyVials', 'Incorrect amount: ' + IntToStr(Amount), warn_AllVersions);
srl_FreeBitmaps;
Exit;
end;
F[0]:= CountFullVials;
E[0]:= CountEmptyVials;
for I:= 1 to Amount do
begin
if FindBitmapToleranceIn(srl_GetBitmap(srl_Full_Vial), X, Y, MIX1, MIY1, MIX2, MIY2, 15) then
begin
MMouse(X, Y, 8, 8);
GetMousePos(X, Y);
if WaitUpTextMulti(['ial', 'ater'], 300) then
begin
Mouse(X, Y, 0, 0, False);
WaitOptionMulti(['mpty', 'ial', 'ater'], 300);
end;
end else
begin
srl_FreeBitmaps;
Exit;
end;
end;
F[1]:= CountFullVials;
E[1]:= CountEmptyVials;
if ((E[0] - E[1]) = Amount) then
if ((F[0] - Amount) = F[1]) then
Result:= True;
srl_FreeBitmaps;
end;

{*******************************************************************************
function NoVials : Boolean;
By: R1ch
Description: Emptys Amount vial in the inventory.
*******************************************************************************}
function NoVials : Boolean;
begin
Result:= (CountAllVials = 0);
end;

Bitmaps:
 bmp_Empty_Vial: Result := BitmapFromString(13, 18, 'beNpjYEAFjEgIJ6gvtspPNY4' +
'L1fZ2UcKtknHH8pBtS4OBqKvWvjTbDJcyiJqNCwPbq+2KMkzwK1s/' +
'P6ClwhZoO6a94eExUdHxEKNWzfJrKrPOSTJ0cvZwd/dBNicpKQ0Zh' +
'YXHBASGeXsH2to6ISvLzs4DopwcKAoJjfL3D3V0cjcyNkOymrGkpA' +
'yCiopKCgqKgoMj3dy8zS1s1NW1UF3IuGrV2i1btm7evGXjps1AG+3' +
'snLGFM2NGRnZlZVUNGABtdHBwxRbCjIWFRVVV1UAEBBCHYVUGNAqI' +
'IABoqbOLh6mZFZqa3Nz8iopKOIJ4wcLSFtmbiUmp5eUVcDUJiSmhY' +
'dGeXv7WNg4mphYwlYz5+YXIyoC6IiPjvH0C7e1dgGECUZacnFZaWg' +
'ZUBkdAkejoBD+/EKAvYAYy5OUVlJWVwxFQWUpKemxcUmBQuIurJzD' +
'0QAYCANcanbA=');

bmp_Full_Vial: Result := BitmapFromString(9, 12, 'beNpzS2YAAcZtS4OBaOPCwPZqu' +
'6IMEwYoYIRLrZ8f0FJhm59qDJEID4+Jio6HaFk1y6+pzDonydDJ2c' +
'Pd3ScpKQ0ZhYXHBASGeXsH2to6ZWfnAVFODhSFhEb5+4c6OrkbGZu' +
'VlJRBUFFRSUFBUXBwpJubt7mFjbq6FtANq1at3bJl6+bNWzZu2gw0' +
'zc7OGeI2IMrIyK6srKoBA6BpDg6uYHGQ4wsLi6qqqoEICCAWwaXWb' +
'zwO1AUBQAOdXTxMzayA4tNn71m74RgEAdVk5s+Oim9198kCuWHtkT' +
'Xrj0KkaprX5xQtjEnq9AkocAIA+nR08w==');
Quite self explanatory. And they now use bitmaps instead of DTMs.

Comments?

Richard

Coh3n

2009-07-06 05:54:38

I was going to say that everyone is saying to use Bitmap.scar instead of making your own DTMs, but you got it covered. ;)

I like them TBH, the first one is a lot like The Man's procedures except it's kinda got the Check + Count in one. Because obviously if there's say, 10 Vials in the inventory, then there's a vial in the inventory. :p If that made any sense… XD

Good job, IMO. :)

ian.

2009-07-06 05:56:06

Sorry, I'm tired and stuff. :p Good work. :D

Coh3n

2009-07-06 06:01:58

From: 99_ aka ian.
Use bitmaps instead? :)


He says he'll switch later on. ;)

Awkwardsaw

2009-07-06 06:26:27

man. all the bitmap stuff is crazy :P i remember a few years ago, if some one used a bitmap every one would be all "omg noob use learn dtms", now its like, "omg use a bitmap, i cant handle the 0.01 second lag" :p

no offence to any one

ian.

2009-07-06 06:27:51

From: akwardsaw
man. all the bitmap stuff is crazy :P i remember a few years ago, if some one used a bitmap every one would be all "omg noob use learn dtms", now its like, "omg use a bitmap, i cant handle the 0.01 second lag" :p

no offence to any one


It's more for the SRL_LoadBitmap thing or something like that. Easier to load/free with SRL instead of in the script. Or something. :p

Coh3n

2009-07-06 06:28:27

From: akwardsaw
man. all the bitmap stuff is crazy :P i remember a few years ago, if some one used a bitmap every one would be all "omg noob use learn dtms", now its like, "omg use a bitmap, i cant handle the 0.01 second lag" :p

no offence to any one


Lol, I haven't been here two years, but I know what you mean. :p I've seen people saying that. I always thought DTMs were better TBH, apparently not. XD

EDIT: @ian. That makes sense. :p

Awkwardsaw

2009-07-06 06:29:23

i still havnt even looked at srl_loadbitmap procedures and such. i probobly wont for a while too :p. unless i come across it next time i lurk in the includes

senrath

2009-07-06 06:30:26

I'd call it CountEmptyVials or something like that, because EmptyVials makes it sound like it's for emptying out vials.

Rich

2009-07-06 10:19:38

Good point Senrath. I'll change that in a second. Also, I might as well make a function that does empty the vials.

Cohen, I know what you mean about begin taught to use DTMs. I've always seen people saying that DTMs are better, and now it's the other way…apparently.

Tickyy

2009-07-06 10:37:49

From: akwardsaw
i cant handle the 0.01 second lag


Did you ever try the FindRange, at cooking.scar, if not yet then i'll just have to say that it'll completly freeze your Screen, and yes its made by dtm's.

It's the small things that make the thing changes. ;)

HyperSecret

2009-07-06 10:46:46

I believe the main reason people are saying Bitmaps now is because in SCAR 3.20 freddy made the bitmaps finding more fast and accurate, making bitmap searching now faster than DTM searching.

I believe, I could be wrong.

Rich

2009-07-06 10:54:48

Ok…I'll make bitmaps for these later on, after school, and then hopefully they'll be more efficient.

Rich

2009-07-07 20:11:13

Ok, I've changed them to bitmaps, and added EmptyVials, which is pretty self-explanatory.

{*******************************************************************************
function CountEmptyVials : Integer;
By: R1ch
Description: Gets amount of empty vials in inventory
*******************************************************************************}
function CountEmptyVials : Integer;
begin
srl_LoadBitmaps([110]);
Result:= CountItems('bmp', srl_Empty_Vial, []);
srl_FreeBitmaps;
end;

{*******************************************************************************
function CountFullVials : Integer;
By: R1ch
Description: Gets amount of full vials in inventory
*******************************************************************************}
function CountFullVials : Integer;
begin
srl_LoadBitmaps([111]);
Result:= CountItems('bmp', srl_Full_Vial, []);
srl_FreeBitmaps;
end;

{*******************************************************************************
function CountAllVials : Integer;
By: R1ch
Description: Gets amount of vials in inventory
*******************************************************************************}
function CountAllVials : Integer;
begin
Result:= CountEmptyVials + CountFullVials;
end;

{*******************************************************************************
function EmptyVials(Amount : Integer) : Boolean;
By: R1ch
Description: Emptys Amount vial in the inventory.
*******************************************************************************}
function EmptyVials(Amount : Integer) : Boolean;
var
I, X, Y : Integer;
E, F : TIntegerArray;

begin
srl_LoadBitmaps([110, 111]);
if (CountFullVials > Amount) then
begin
srl_Warn('EmptyVials', 'Incorrect amount: ' + IntToStr(Amount), warn_AllVersions);
srl_FreeBitmaps;
Exit;
end;
F[0]:= CountFullVials;
E[0]:= CountEmptyVials;
for I:= 1 to Amount do
begin
if FindBitmapToleranceIn(srl_Full_Vial, X, Y, MIX1, MIY1, MIX2, MIY2, 15) then
begin
MMouse(X, Y, 8, 8);
GetMousePos(X, Y);
if WaitUpTextMulti(['ial', 'ater'], 300) then
begin
Mouse(X, Y, 0, 0, False);
WaitOptionMulti(['mpty', 'ial', 'ater'], 300);
end;
end else
begin
srl_FreeBitmaps;
Exit;
end;
end;
F[1]:= CountFullVials;
E[1]:= CountEmptyVials;
if ((E[0] - E[1]) = Amount) then
if ((F[0] - Amount) = F[1]) then
Result:= True;
end;

Please comment.

EDIT: Sorry about double post, I just noticed.

Da 0wner

2009-07-07 20:15:02

Maybe
function NoVials : boolean;
begin
result := (CountEmptyVials = 0) and (CountFullVials = 0);
end;
?

senrath

2009-07-07 20:16:49

Whats the point of this?
  if (CountFullVials > Amount) then
begin
srl_Warn('EmptyVials', 'Incorrect amount: ' + IntToStr(Amount), warn_AllVersions);
srl_FreeBitmaps;
Exit;
end;

Rich

2009-07-07 20:26:49

From: Da 0wner
Maybe
function NoVials : boolean;
begin
result := (CountEmptyVials = 0) and (CountFullVials = 0);
end;
?


Added, but changed a bit.

From: senrath
Whats the point of this?
  if (CountFullVials > Amount) then
begin
srl_Warn('EmptyVials', 'Incorrect amount: ' + IntToStr(Amount), warn_AllVersions);
srl_FreeBitmaps;
Exit;
end;


Sorry, that's meant to be:
  if (CountFullVials < Amount) then
begin
srl_Warn('EmptyVials', 'Incorrect amount: ' + IntToStr(Amount), warn_AllVersions);
srl_FreeBitmaps;
Exit;
end;

Sir R. M8gic1an

2009-07-07 22:41:14

test your functions, i can see mistakes from here. GJ on the thinking behind them.

~RM

Rich

2009-07-07 23:02:38

Could you point the mistakes out, then I test it :p I just means that it'll be easier for me.

Thanks,
Richard

Da 0wner

2009-07-07 23:19:01

srl_GetBitmap(srl_full_vial) returns the bitmap.

Rich

2009-07-08 00:21:46

So instead of
srl_LoadBitmaps([111]);
I'd use
srl_GetBitmap(srl_Full_Vial)
?

Da 0wner

2009-07-08 00:34:38

From: Awkwardsaw
man. all the bitmap stuff is crazy :P i remember a few years ago, if some one used a bitmap every one would be all "omg noob use learn dtms", now its like, "omg use a bitmap, i cant handle the 0.01 second lag" :p

no offence to any one


It's actually like 0.06.

Edit: And just set a bitmap variable to srl_getbitmap(id). Then use it, and then free it.

Rich

2009-07-08 10:40:39

Changed them around a bit more, and fixed some bugs. If you find any more, please let me know.

senrath

2009-07-08 18:21:31

Whoops. There's a really obvious error in CountEmptyVials.

Rich

2009-07-08 18:38:57

From: senrath
Whoops. There's a really obvious error in CountEmptyVials.


That must have happened in the copy/paste process. Sorry about that.:p

Sir R. M8gic1an

2009-07-09 00:27:16

you shouldn't use srl_freebitmaps because that'll free any bitmap that the script is using too.


{*******************************************************************************
procedure srl_FreeBitmapEx(which: integer);
By: Rasta Magician
Description: Frees SRL bitmap which
*******************************************************************************}

procedure srl_FreeBitmapEx(which: integer);
begin
try
FreeBitmap(srl_Bitmaps[which]);
srl_BitmapSet[which] := False;
except end;
end;

also, your bitmaps are kinda big

~RM

Darkcorn

2009-08-12 06:14:20

thx dude im new though but this will help me out thx =)