SRL Archive - Senior Scripts and Snippets

UseOn Functions


Smartzkid

2007-09-07 16:50:35

UseOnDTM(dtm1, dtm2: integer): boolean; //uses dtm 1 on dtm 2

UseOnBMP(bmp1, bmp2: integer): boolean; //uses bmp1 on bmp2

UseOnInvSlot(slot1, slot2: integer): boolean; //uses item in slot1 on item in slot2 <- not done yet.

All-Ex do the same thing, but with uptext.

function UseOnDTM(dtm1, dtm2: integer): boolean;
var
d1x, d1y, d2x, d2y: integer;
begin
result := false;
if(FindDTM(dtm1, d1x, d1y, MIX1, MIY1, MIX2, MIY2))then
if(FindDTM(dtm2, d2x, d2y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(d1x, d1y, 4, 4);
GetMousePos(d1x, d1y);
if(IsUpText('Use'))then
begin
Mouse(d1x, d1y, 0, 0, true);
end else
begin
Mouse(d1x, d1y, 0, 0, false);
if(not(ChooseOption('Use')))then Exit;
end;
wait(70 + random(130));
Mouse(d2x, d2y, 4, 4, true);
result := true;
end;
end;

function UseOnDTMEx(dtm1, dtm2: integer; UpText1, UpText2: string): boolean;
var
d1x, d1y, d2x, d2y: integer;
begin
result := false;
if(FindDTM(dtm1, d1x, d1y, MIX1, MIY1, MIX2, MIY2))then
if(FindDTM(dtm2, d2x, d2y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(d1x, d1y, 4, 4);
if(not(IsUpText(UpText1)))then Exit;
GetMousePos(d1x, d1y);
if(IsUpText('Use'))then
Mouse(d1x, d1y, 0, 0, true)
else begin
Mouse(d1x, d1y, 0, 0, false);
if(not(ChooseOption('Use')))then Exit;
end;
wait(70 + random(130));
MMouse(d2x, d2y, 4, 4);
if(not(IsUpText(UpText2)))then
begin
Mouse(d1x, d1y, 3, 3, true);
Exit;
end;
GetMousePos(d2x, d2y);
Mouse(d2x, d2y, 0, 0, true);
result := true;
end;
end;

function UseOnBMP(bmp1, bmp2: integer): boolean;
var
b1x, b1y, b2x, b2y: integer;
begin
result := false;
if(FindBitmapIn(bmp1, b1x, b1y, MIX1, MIY1, MIX2, MIY2))then
if(FindBitmapIn(bmp2, b2x, b2y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(b1x, b1y, 4, 4);
GetMousePos(b1x, b1y);
if(IsUpText('Use'))then
begin
Mouse(b1x, b1y, 0, 0, true);
end else
begin
Mouse(b1x, b1y, 0, 0, false);
ChooseOption('Use');
end;
wait(70 + random(130));
Mouse(b2x, b2y, 4, 4, true);
result := true;
end;
end;

function UseOnBMPEx(bmp1, bmp2: integer; UpText1, UpText2: string): boolean;
var
b1x, b1y, b2x, b2y: integer;
begin
result := false;
if(FindBitmapIn(bmp1, b1x, b1y, MIX1, MIY1, MIX2, MIY2))then
if(FindBitmapIn(bmp2, b2x, b2y, MIX1, MIY1, MIX2, MIY2))then
begin
MMouse(b1x, b1y, 4, 4);
if(not(IsUpText(UpText1)))then Exit;
GetMousePos(b1x, b1y);
if(IsUpText('Use'))then
Mouse(b1x, b1y, 0, 0, true)
else begin
Mouse(b1x, b1y, 0, 0, false);
if(not(ChooseOption('Use')))then Exit;
end;
wait(70 + random(130));
MMouse(b2x, b2y, 4, 4);
if(not(IsUpText(UpText2)))then
begin
Mouse(b1x, b1y, 3, 3, true);
Exit;
end;
GetMousePos(b2x, b2y);
Mouse(b2x, b2y, 0, 0, true);
result := true;
end;
end;

I'll test them out in a couple minutes. That is, if you think they're worth keeping.

PS: Would it be possible to set up a repository for this? It'd make things a lot more organized and easier to work on…

The Claw

2007-09-07 19:53:48

Should probably have it right click > choose option 'use', just in case something happens when you left click it

Smartzkid

2007-09-07 23:22:19

Ahh, good idea. Thanks.

I'll fix it tomorrow sometime.

Smartzkid

2007-09-16 21:37:22

Boreas, worth updating?

Smartzkid

2008-11-21 16:43:19

Just thinking about this…Freddy, would you be able to make a function that, given a pointer, tell us if it points to a bitmap, a dtm, or neither?

Widget

2008-11-21 17:44:46

program new;
var
b, d: integer;
begin
b := BitmapFromString(0, 0, '');
d := DTMFromString('78DA639CCCC4C070920105FCFFFF1F4C3342F90059D7045E');
Writeln(IntToStr(b));
Writeln(IntToStr(d));
FreeBitmap(b);
FreeDTM(d);
end.
Output:
Successfully compiled (43 ms)
0
0
Successfully executed

He'd have to rewrite the bitmap/dtm system to be able to figure them out since a lot of times there would be both a bitmap and dtm that you could be trying to point to. Although if he did it probably wouldn't break anything.

Freddy1990

2008-11-22 06:54:05

From: Smartzkid
Just thinking about this…Freddy, would you be able to make a function that, given a pointer, tell us if it points to a bitmap, a dtm, or neither?


No, they're array indexes, best I could do is make a function that tells you if there is a bitmap/dtm/… for the index you provide

Wizzup?

2008-11-22 08:22:01

From: Smartzkid
Just thinking about this…Freddy, would you be able to make a function that, given a pointer, tell us if it points to a bitmap, a dtm, or neither?


The 'pointers' in SCAR are just indexes that link to an array of the Bitmaps, or the array of DTM's, etc. So basically you'll have to check an index of every of arrays. (SCAR also has one for Connections, HTTPClients, Files, etc)

Smartzkid

2008-11-22 19:54:15

That sounds like just what I need, it'd be awesome if you could make it.

So, technically, you could make a function to give us every allocated bitmap/dtm/form/etc?

YoHoJo

2008-11-26 20:14:01

From: The Claw
Should probably have it right click > choose option 'use', just in case something happens when you left click it


Oh no i just drank my half wine! Cracked my Christmas cracker! Ate my pumpkin! And Ate my easter egg!