SRL Archive - SRL Archives

Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;


Wizzup?

2007-10-06 14:54:40

What does it do?

You put in a TPointArray.
It takes the outer points of the TPointArray, uses that box to copy that part from the client to your bitmap, set's all the points in the TPA red on that Bitmap and Draws the bitmap on the debug image.
Has the option to save the file in your scriptpath.

Make the name '' if you don't want it to save the Bitmap

Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I, L: Integer;
xs, ys, xe, ye: Integer;

Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(Points) Do
Begin
xs := Min(xs, Points[I].X);
ys := Min(ys, Points[I].Y);

xe := Max(xe, Points[I].X);
ye := Max(ye, Points[I].Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To High(Points) Do
FastSetPixel(ClientBMP, Points[I].X - xs, Points[I].Y - ys, 255);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;

How do you use this?

Function IsFishRod: Boolean;

Var
x, y, z: Integer;
Ar: TPointArray;

Begin
If Not LoggedIn Then Exit;
GameTab(4);

Result := FindColor(x, y, FishingRodColor, MIX1, MIY1, MIX2, MIY2);
If Result Then Exit;

If FindBitmapToleranceIn(FishingRod, x, y, MIX1, MIY1, MIX2, MIY2, 50) Then
Begin
z := GetColorToleranceSpeed;
Result := True;
FishingRodColor := GetColor(x, y);
ColorToleranceSpeed(2);
FindColorsTolerance(Ar, FishingRodColor, x - 20, y - 20, x + 20, y + 20, 25);
ColorToleranceSpeed(z);
DebugTPA(Ar, 'InvRod'); // HERE.
FishRodColors := GetColors(Ar);
ShrinkArray(FishRodColors);
WriteLn('FishingRodColor: ' +IntToStr(FishingRodColor));
End;
End;

Function DebugATPA(aPoints: Array Of TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I, L, C, Col: Integer;
xs, ys, xe, ye: Integer;
OuterPoints: TPointArray;

Begin
For I := 0 To High(aPoints) Do
L := L + Length(aPoints[I]);
SetLength(OuterPoints, L + 1);
C := 0;
For I := 0 To High(aPoints) Do
For L := 0 To High(aPoints[I]) Do
Begin
C := C + 1;
OuterPoints[C] := aPoints[I][L];
End;

Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(OuterPoints) Do
Begin
xs := Min(xs, OuterPoints[I].X);
ys := Min(ys, OuterPoints[I].Y);

xe := Max(xe, OuterPoints[I].X);
ye := Max(ye, OuterPoints[I].Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye)
For I := 0 To High(aPoints) Do
Begin
Col := Random(16777215);
For L := 0 To High(aPoints[I]) Do
FastSetPixel(ClientBMP, aPoints[I][L].X - xs, aPoints[I][L].Y - ys, Col);
End;

SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;


Few TPA examples:






aTPA example:


~ Wizzup?

Lorax

2007-10-06 15:01:39

gr8

SKy Scripter

2007-10-06 15:03:04


xe := xs xor xs;
ye := ys xor ys;
lol…
I Like how you try and confuse people XD, jk ;)

you mean

xe := 0;
ye := 0;


:p



anyway this is always fun to do.. ;)

Wizzup?

2007-10-06 15:04:38

From: SKy Scripter

xe := xs xor xs;
ye := ys xor ys;
lol…
I Like how you try and counfuse people XD, jk ;)





anyway this is always fun to do.. ;)


Yes. ;)
I asked Yakman for a use of xor bitwise, and he came up with
this he read on wikipedia….

It's faster than xe := 0 actually.. :rolleyes:

EDIT:

Assembly language programmers sometimes use the XOR operation as a short-cut to set the value of a register to zero. Performing XOR on a value against itself always yields zero, and on many architectures, this operation requires fewer CPU clock cycles than the sequence of operations that may be required to load a zero value and save it to the register.

mastaraymond

2007-10-06 16:09:48

Hehe cool ^^. I always used MSPaint to draw the points ^^.

SKy Scripter

2007-10-06 16:22:35


program New;
var i, st, x : Integer;
begin
st := GetSystemTime;
for i := 1 to 10000 do
x := i xor i;
writeln(inttostr(GetSystemTime - st));
end.

ok???

Successfully compiled
30.msc
Successfully executed



program New;
var i, st, x : Integer;
begin
st := GetSystemTime;
for i := 1 to 10000 do
x := 0;
writeln(inttostr(GetSystemTime - st)+'.msc');
end.
;


Successfully compiled
20.msc
Successfully executed

Lol, idk…

Edit : this is the same speed as declaring a zero

program New;
var i, st, x : Integer;
begin
st := GetSystemTime;
for i := 1 to 10000 do
x := 20 xor 20;
writeln(inttostr(GetSystemTime - st)+'.msc');
end.

Bobarkinator

2007-10-06 16:29:00

Sexy, couldn't this same theory be used to paint on the client? Like, take a picture of the client, drawing on it, then refreshing every millisecond, would have to be done in a plugin if you wanted any kind of speed.

Wizzup?

2007-10-06 18:04:51

From: Bobarkinator
Sexy, couldn't this same theory be used to paint on the client? Like, take a picture of the client, drawing on it, then refreshing every millisecond, would have to be done in a plugin if you wanted any kind of speed.


Yes, the RS_Monkey has that, let me see..

GetClientCavas.Pixels[a[i].x, a[i].y] := 255;

That draws directly on RS, but it get's removed every new rs draw (approx. 50 times a second)

Bobarkinator

2007-10-06 18:45:30

Which is why you would need to refresh just as often if it could be anything useful. That's why you would need a plugin because it would take up a lot of resources.

HyperSecret

2007-10-06 18:52:35

wow you guys…where do you think of all these things…? is there some place with tuts or something, website maybe, where you learn all these capabilities and all? if so let me know would be very interested…

Santa_Clause

2007-10-06 20:18:57

I'd love to know more about this too, please.

SKy Scripter

2007-10-06 20:30:19

this is what my Certer And Quiz Solver is based on XD

wizzup? learned it from me, ;) jk jk jk….

The Claw

2007-10-06 21:45:40

From: HyperSecret
wow you guys…where do you think of all these things…? is there some place with tuts or something, website maybe, where you learn all these capabilities and all? if so let me know would be very interested…


Yup, any script by Wizzup or Fawki ;) Seriously, thats how I learnt this stuff..and with many annoying questions to wizzup and nielsie on msn <3 :p

Actually it would be kinda cool to paint on the screen during runtime..i knew it was possible, but i mean doing it every time the rs changed, so that it was always there until you wanted to clear it. would be an interesting tool to see if your finding procedures are actually working, and stuff.

mat_de_b

2007-10-07 04:54:41

this isnt tough to do… i already did it in my item creater :D

mastaraymond

2007-10-07 05:12:40

From: The Claw
Yup, any script by Wizzup or Fawki ;) Seriously, thats how I learnt this stuff..and with many annoying questions to wizzup and nielsie on msn <3 :p

Actually it would be kinda cool to paint on the screen during runtime..i knew it was possible, but i mean doing it every time the rs changed, so that it was always there until you wanted to clear it. would be an interesting tool to see if your finding procedures are actually working, and stuff.
In freddy suggestion section someone suggested it. Even IF you made a plugin, which draws on the client, scar will see that text… Its really useless. What you can do is take a bitmap of the screen, edit it and draw it onto a Canvas ( Debug\Form).

~Raymond

Wizzup?

2007-10-07 05:13:54

From: mat_de_b
this isnt tough to do… i already did it in my item creater :D


This is just universal, just copy paste in script and call DebugTPA, thats what I use it for. :)

It can be handy for everything that works with FindColorsTolerance, really…

From: The Claw
Yup, any script by Wizzup or Fawki ;) Seriously, thats how I learnt this stuff..and with many annoying questions to wizzup and nielsie on msn <3 :p

Actually it would be kinda cool to paint on the screen during runtime..i knew it was possible, but i mean doing it every time the rs changed, so that it was always there until you wanted to clear it. would be an interesting tool to see if your finding procedures are actually working, and stuff.


Yes, i took out a BIG bug in my FindColorsTolerance in the IsFishRod function. :p

ShowerThoughts

2007-10-07 05:58:36

it makes a dtm what it does? what are the red points lines? can some1 explain me t-stuff(points) or that stuff on msn
cant find a tut about it
is x and y a t point? or where the t point saved in ?

hermpie

Killerdou

2007-10-07 06:11:43

you could theoretically have a invisible canvas over the client that would draw picture, but we are not going to be able to see whats behind it in delphi, i tried everything XD

mat_de_b

2007-10-07 08:34:39

why do you need to draw on the rs screen? just make a canvas that updates at roughly the same speed and draw on that so then you have your RS channeled through a canvas on which you can draw…

Bobarkinator

2007-10-07 17:30:56

Test this on the main screen:

program New;
var
TPA: TPointArray;
i: Integer;
begin
FindColorsTolerance(TPA,65535,281,225,473,260,0);
repeat
for i:= 0 to GetArrayLength(TPA)- 1 do
GetClientCanvas.Pixels[TPA[i].x,TPA[i].y]:= 255;
Wait(1);
until(False)
end.

Yes this will lag the crap out of you.

itSchRis917

2007-10-07 17:44:12

^^ ummm.. doesnt do ANYTHING for me.. doesnt even affect the performance of my PC.. i guess my PC is just THAT good. :D

Bobarkinator

2007-10-07 17:46:24

Are you on the runescape main screen? Oh ya and target it also.

itSchRis917

2007-10-07 17:58:26

Yes, i was on the RS mainscreen, and i targeted it. Still nothing.. strange..

pwnaz0r

2007-10-07 23:00:55

Works for me. To draw on client, no changes is not possible because the clients pixels are constantly resetting. Solution? Create a canvas on top of the client. (possibly make the form transparent or if it is possible, make the parent nil or client(if there is a parent named as such?)

im probably wrong but thats what i think (SKy Scripter you noob :D)

danrox2004

2007-10-08 07:45:34

That didnt work for me because i had the old SCAR 3.12, however it works with SCAR 3.12C

Bobarkinator

2007-10-08 08:12:50

From: pwnaz0r
Works for me. To draw on client, no changes is not possible because the clients pixels are constantly resetting. Solution? Create a canvas on top of the client. (possibly make the form transparent or if it is possible, make the parent nil or client(if there is a parent named as such?)

im probably wrong but thats what i think (SKy Scripter you noob :D)


I wonder if you could have the parent as "GetClientCanvas"

n3ss3s

2007-10-08 08:44:47

I dont know is this somewhat same thing, but in a rock finder of mine (47ms all rocks from screen ftw) it does a FindColorsSpiralTolerance, paints all the pixels red, does a FindColorSpiral2, around the point it found does FindColorsTolerance, uses your plugins MiddleTPA, thats how to find one rock, but all of the rocks, it does FindColorsSpiralTolerance instead of FindColorSpiral2, and does a for loop with teh MiddleTPA and all kinds of things…

Btw, wizzy remember the topic I made long time ago, about painting your pixels red? Now we use it ;)

danrox2004

2007-10-08 08:54:17

What does the function High(x):Int64 do? Its not in the SCAR manual and i haven't seen it before.

Wizzup?

2007-10-08 09:21:29

From: danrox2004
What does the function High(x):Int64 do? Its not in the SCAR manual and i haven't seen it before.


http://www.delphibasics.co.uk/RTL.asp?Name=High&ExpandCode1=Yes

I might look into putting a canvas on the RS screen, so it won't reset your stuff, if you guys think it's usefull.. :)

danrox2004

2007-10-08 09:58:36

From: Wizzup?
http://www.delphibasics.co.uk/RTL.asp?Name=High&ExpandCode1=Yes

I might look into putting a canvas on the RS screen, so it won't reset your stuff, if you guys think it's usefull.. :)


Thanks

Wizzup?

2007-10-18 04:50:13

Added DebugATPA. :)

Bobarkinator

2008-02-24 18:32:21

Gravedig, just so you know you updated your plugin to use T2DPointArray but you didn't update this so they aren't compatible ;)

MylesMadness

2008-02-24 18:51:34

@bob
I just tryed using it about 5 mins ago to..

Bobarkinator

2008-02-24 22:23:56

Really? Didn't work for me. I'll try again.

MylesMadness

2008-02-25 09:49:55

No I was saying I just tried to use it 5 mins ago(More like 24 hours) as well and it didn't work.

Bobarkinator

2008-02-25 19:13:00

Ah ok, so then, just letting you know that DebugATPA needs updating.

mastaraymond

2008-02-26 13:31:36

From: Bobarkinator
Ah ok, so then, just letting you know that DebugATPA needs updating.

Just replace TPointArrayArray with T2DPointArray, not really updating IMO..

MylesMadness

2008-02-26 15:09:54

That didn't work for me

the scar noob

2008-02-26 15:17:17

From: mastaraymond
Just replace TPointArrayArray with T2DPointArray, not really updating IMO..

TPointArrayArray, Array of TPointArray and T2DPointArray, aren't they all the same? So what's the difference then?

-Tsn.

Sumilion

2008-02-26 15:52:25

From: the scar noob
TPointArrayArray, Array of TPointArray and T2DPointArray, aren't they all the same? So what's the difference then?

-Tsn.


Their names :p

Bobarkinator

2008-02-26 16:18:46

Tried T2DPointArry didn't work, didn't try TPointArrayArray;

king vash

2008-02-27 20:08:27

I just needed this, but it's not working for me either, if it was fixed it could really help with debug

Bobarkinator

2008-02-27 22:51:18

It is working. I figured out that I was doing some things wrong. Add me on MSN if you need help. [email]monkeyaregoodpeople@gmail.com[/email]

Gu3st...

2008-03-05 08:24:23

From: Wizzup?
Yes, the RS_Monkey has that, let me see..

GetClientCavas.Pixels[a[i].x, a[i].y] := 255;

That draws directly on RS, but it get's removed every new rs draw (approx. 50 times a second)


What about making a window (like in form, u know) with a .GIF image on it, and so just paint on that gif? :)

Wizzup?

2008-03-05 13:23:46

From: Zytex!
What about making a window (like in form, u know) with a .GIF image on it, and so just paint on that gif? :)


Or just on a bitmap…
Why would you want to paint it on a .gif?

Bobarkinator

2008-03-05 16:58:29

From: Zytex!
What about making a window (like in form, u know) with a .GIF image on it, and so just paint on that gif? :)


Or maybe you could just draw on a the SCARs debug canvas ;)

Gu3st...

2008-03-06 02:58:22

uh i thinked wrong :P sry, nvm