SRL Archive - Research & Development Lounge

SMART Debug info [RSBOT like]


Waddo

2008-08-07 17:45:16

If some people can look through my code and try and piont out things i can do to reduce lag.

Save this as includes/srl/srl/misc/smart2.scar

You must have this as the smart over writes the get mouse pos

function IsKeyDown(C:Char): Boolean;
// BETA. Not sure if it works. ~Wizzup?
begin
Result := SmartIsKeyDown(ord(c));
end;

procedure MoveMouse(x, y: Integer);
begin
SmartMoveMouse(x, y);
end;

procedure HoldMouse(x, y: Integer; left: Boolean);
begin
SmartHoldMouse(x, y, left);
end;

procedure ReleaseMouse(x, y: Integer; left: Boolean);
begin
SmartReleaseMouse(x, y, left);
end;

procedure KeyUp(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartReleaseKey(key);
end;

procedure KeyDown(key: Byte);
begin
If Key = 13 Then
Key := 10;
SmartHoldKey(key);
end;

procedure SendKeys(S: String);
begin
SmartSendKeys(S);
end;


function GetColor(x, y: Integer): Integer;
begin
result:= SmartGetColor(x, y);
end;


procedure SmartSetTarget;
var
Smart_Bitmap: Integer;
begin
Smart_Bitmap:= BitmapFromString(765,503,'');
GetBitmapCanvas(Smart_Bitmap).Handle:= SmartGetDC;
SetTargetBitmap(Smart_Bitmap);
FreeBitmap(Smart_Bitmap);
end;

function FindWindow(Title: String): Boolean;
begin
result:= true;
end;

procedure ActivateClient;
begin
end;

function FindWindowBySize(Width, Height: Integer): Boolean;
begin
result:= true;
end;

procedure SmartSetupEx(worldnumber: integer; safe, signed, superdetail: boolean);
var
prefix: string;
begin
prefix := ReadINI('World' + IntToStr(worldnumber), 'Prefix', AppPath + 'includes\SRL\SCSS\worlds.ini');
if(prefix = '')then
begin
writeln('Invalid world number or corrupted world list. Please review your settings');
TerminateScript;
end;
SmartSetup(prefix, safe, signed, superDetail);
end;

Procedure SaveScreenshot(s : string);
var
TempBMP : integer;
TempS : String;
begin;
Temps := s;
While FileExists(Temps) do
begin;
Temps := ExtractFilePath(s) + Copy(ExtractFileName(Temps),1,LastPos('.',ExtractFileName(Temps))-1) + '2' + ExtractFileExt(s);
Writeln(Temps);
end;
TempBMP := BitmapFromString(765,503,'');
Try
CopyClientToBitmap(TempBMP,0,0,765,503);
SaveBitmap(TempBMP, Temps);
Except
end;
FreeBitmap(TempBMP);
end;




Then run this

{credits to JuKKa and everyone who helped JuKKa and every one who helped me
Other main credits to N3ss3s for GetPaintBitmap and also to Lee Lok Hin for beating me to putting in tiles also to bobarkinator for the concept of small chars instead of upchars}

program ReflectionAid;
{.include SRL/SRL/Misc/Smart2.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}

var
i, x,y :integer;

Function GetPaintBitmap(sX, sY: Integer; Text: TStringArray; Dist: Integer): Integer;
Var
TPA: TPointArray;
H, Q, B: Integer;
Begin
Result := BitmapFromString(sX, sY, '');
For B := 0 To High(Text) Do
Begin
TPA := LoadTextTPA(Text[b], SmallChars, H);
For Q := 0 To High(TPA) Do
FastSetPixel(Result, TPA[q].x, TPA[q].y + B * Dist, 16777215);
End;
End;


Procedure ClearSMARTCanvas;
Var
BMP: Integer;
SMARTCanvas, Canvas: TCanvas;
Begin
BMP := BitmapFromString(765, 503, '')
SMARTCanvas := GetBitmapCanvas(BMP);
Canvas := GetBitmapCanvas(BMP);
SMARTCanvas.handle := SmartGetDebugDC;
CopyCanvas(Canvas, SMARTCanvas, 0, 0, 765, 503, -1000, -1000, 1000, 1000);
FreeBitmap(BMP);
End;


Procedure ShowNPCInfo;
Var
SCanvas, Canvas, InfoCanvas: TCanvas;
BMP: Integer;
Text: TStringArray;
NPCs: array of TNPC;
begin
NPCs:=getnpcs;
if not(LoggedIn) then Exit;
SmartSetDebug(True);
BMP := BitmapFromString(765, 503, '');
SCanvas := GetBitmapCanvas(BMP);
InfoCanvas := GetBitmapCanvas(BMP);
SCanvas.handle := SmartGetDebugDC;
getmousepos(x,y);
for i := 0 to high(NPCs) do
begin
if InRange(NPCs[i].MS.X,X-30,X+30) and InRange(NPCs[i].MS.Y,Y-30,Y+30) then
begin
Text := [
'NPC Name : '+NPCs[i].Name,
'NPC ID : '+IntToStr(NPCs[i].NPCType),
'NPC Tiles : ('+IntToStr(NPCs[i].Tile.X)+', '+IntToStr(NPCs[i].Tile.Y)+')']
Canvas := GetBitmapCanvas(GetPaintBitmap(400,200,text,10));
safeCopyCanvas(Canvas, SCanvas, 0, 0, 400, 200, 0,0,400,200);
While IsMouseButtonDown(True) do
Wait(30);
end;
end;
FreeBitmap(BMP);
end;

Procedure ShowAnimInfo;
Var
SCanvas, Canvas: TCanvas;
BMP, Anim: Integer;
Text: TStringArray;

begin
if not(loggedin) then Exit;
Anim:=SmartGetFieldInt(SmartGetFieldArrayObject(0,NPCArray,
SmartGetFieldArrayInt(0,NPCIndexArray,i)),CharAnim);
SmartSetDebug(True);
BMP := BitmapFromString(765, 503, '');
SCanvas := GetBitmapCanvas(BMP);
SCanvas.handle := SmartGetDebugDC;
Text := [
'Animation: '+inttostr(anim),
'Tiles : ('+IntToStr(getmypos.x)+', '+IntToStr(getmypos.y)+')']
Canvas := GetBitmapCanvas(GetPaintBitmap(400,200,text,15));
safeCopyCanvas(Canvas, SCanvas, 0, 0, 400, 200, 0,0,400,200);

FreeBitmap(BMP);
end;

Procedure SetupSMART;
Begin
SmartSetup('world37', false, false, False);
SetTargetDC(SmartGetDC);
If Not (LoggedIn) Then
While Not (SmartGetColor(360, 172) = 13158) Do
Wait(100);
End;

Procedure Setup;
begin
setupsmart;
setupsrl;
//setupreflection;
end;

Procedure DoInfo;
Var
FirstLoop : Boolean;
begin
FirstLoop:=false;
ClearSMARTCanvas;
if isfkeydown(11) then
Repeat
Showaniminfo;
If not firstloop then
while isfkeydown(11) do
wait(10);
firstloop:=true;
wait(100);
until isfkeydown(11);
if isfkeydown(9) then
writeln('Tiles : ('+IntToStr(getmypos.x)+', '+IntToStr(getmypos.y)+')')
else
shownpcinfo;
end;

begin
setup;
ClearSMARTCanvas;
repeat
DoInfo;
wait(100);
until false;
end.



Then select the Runescape client in the smart window with the crosshairs

then mouse over an NPC
User name i noob i cba editing it out
i dont care if it gets stolen if it does and i get it back i would still report ip tho =p



Changes log

There has been some changes before this but this is the changes from now

Made text closer together and put an else function in the isfkeydown so it doesn't do both things.

Made a slight change to the animation procedure.

Made it so Info is displayed in top left corner to make it look tidier
Made it so that on left click Displayed NPC Info will be paused (stops flickering)


Pressing F9 will now writeln your tile co-ords it does not matter if smart is enabled or not.

Shuttleu

2008-08-07 18:41:36

wow pretty good

now i can get the name and id of a npc YAY!

~shut

Waddo

2008-08-07 18:44:23

Ill update it for items when we have hooks and stuff =p

Shuttleu

2008-08-07 18:45:31

cool i cant wait :p

~shut

[-jesus-]

2008-08-07 22:06:24

Looks good, move the paint to the top left or bottom right of the main screen tho?

Lee Lok Hin

2008-08-07 22:10:23

At [-jebus-], It probably paints next to your mouse. Nice make though, slight question. Username in screenie?

{credits to JuKKa and everyone who helped JuKKa and every one who helped me}
program ReflectionAid;
{.include SRL/SRL/Misc/Smart2.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}

var
i, x,y :integer;
NPCs: array of TNPC;

Function GetPaintBitmap(sX, sY: Integer; Text: TStringArray; Dist: Integer): Integer;
Var
TPA: TPointArray;
H, Q, B: Integer;
Begin
Result := BitmapFromString(sX, sY, '');
For B := 0 To High(Text) Do
Begin
TPA := LoadTextTPA(Text[b], UpChars, H);
For Q := 0 To High(TPA) Do
FastSetPixel(Result, TPA[q].x, TPA[q].y + B * Dist, 16777215);
End;
End;


Procedure ClearSMARTCanvas;
Var
BMP: Integer;
SMARTCanvas, Canvas: TCanvas;
Begin
BMP := BitmapFromString(765, 503, '')
SMARTCanvas := GetBitmapCanvas(BMP);
Canvas := GetBitmapCanvas(BMP);
SMARTCanvas.handle := SmartGetDebugDC;
CopyCanvas(Canvas, SMARTCanvas, 0, 0, 765, 503, -1000, -1000, 1000, 1000);
FreeBitmap(BMP);
End;


Procedure ShowNPCInfo;
Var
SCanvas, Canvas: TCanvas;
BMP, Sec: Integer;
Text: TStringArray;

begin
if not(LoggedIn) then Exit;
NPCs := GetNPCs;
SmartSetDebug(True);
BMP := BitmapFromString(765, 503, '');
SCanvas := GetBitmapCanvas(BMP);
SCanvas.handle := SmartGetDebugDC;
getmousepos(x,y);
for i := 0 to high(NPCs) do
begin
if InRange(NPCs[i].MSX,X-30,X+30) and inrange(NPCs[i].MSY,Y-30,Y+30) then
begin
Text := [
'NPC Name : '+NPCs[i].Name,
'NPC ID : '+IntToStr(NPCs[i].NPCType)]
Canvas := GetBitmapCanvas(GetPaintBitmap(400,200,text,25));
safeCopyCanvas(Canvas, SCanvas, 0, 0, 400, 200, NPCs[i].MSX,NPCs[i].MSY , NPCs[i].MSX + 400, NPCs[i].MSY + 200);
end;
end;
FreeBitmap(BMP);
end;

Procedure ShowAnimInfo;
Var
SCanvas, Canvas: TCanvas;
BMP, Sec, Anim: Integer;
Text: TStringArray;

begin
if not(loggedin) then Exit;
Anim:=getanimation;
SmartSetDebug(True);
BMP := BitmapFromString(765, 503, '');
SCanvas := GetBitmapCanvas(BMP);
SCanvas.handle := SmartGetDebugDC;
getmypos(x,y);
begin
Text := [
'Animation: '+inttostr(GetAnimation),
'Tiles Position x: '+IntToStr(x)+' y: '+IntToStr(y)]
Canvas := GetBitmapCanvas(GetPaintBitmap(400,200,text,25));
safeCopyCanvas(Canvas, SCanvas, 0, 0, 400, 200, 0,0,400,200);
end;
FreeBitmap(BMP);
end;

Procedure SetupSMART;
Begin
SmartSetupEx(136, false, false, False);
SetTargetDC(SmartGetDC);
If Not (LoggedIn) Then
While Not (SmartGetColor(360, 172) = 13158) Do
Wait(100);
End;

Procedure Setup;
begin
setupsmart;
setupsrl;
setupreflection;
end;

begin
setup;
ClearSMARTCanvas;
repeat
ClearSMARTCanvas;
shownpcinfo;
wait(100);
if isfkeydown(11) then
showaniminfo;
wait(100);
until false;
end.

I added both tile position and animation, but you must press F11 to get them.

Credits to Yakman's Canvas Tutorial, I swallowed it.


EDIT: ;)

Bobarkinator

2008-08-08 00:07:04

Suggestion, make the text smaller

n3ss3s

2008-08-08 03:04:42

{credits to JuKKa and everyone who helped JuKKa and every one who helped me}


GetPaintBitmap is fully by me…

Bob is right btw, make it SmallChars.

Waddo

2008-08-08 06:17:49

Darn you lee lok kin i was gunna do that today =p oh well saves me time

N3ss3s when will object recognition me finished?

And lee dont you dare put object stuff in i wanna =p


User is a low level uneeded account if it gets robbed i dont really care.

[-jesus-] i want it over the person when the objects come into play then i will see what would be better, for now we will just vote (post if it should go in over the char or in top left corner)

N3ss3s You where meant to be in credits by name simply cos i knew you helped JuKKa and some of he funcs where yours oh well your there now, if you want to writeme out one of them big green rectangles to put above it you can =p

Shuttleu

2008-08-08 07:28:31

i found a bug in this script
its not serious or anything but it is sort of annoying after a little while

if you hover over a npc that is in the bottom right hand corner of the game screen then the writing comes up larger on the main screen

i hope you manage to fix it or find out what is causing it

~shut

Waddo

2008-08-08 07:33:08

Ye ive noticed it b4 but have no idea how to fix
yay people are using it, i think it has something to do with n3ss3s's getpaintbitmap im going to move text closer aswell

n3ss3s

2008-08-08 07:41:45

Let me explain my function, Dist is the distance between the texts if you enter multiple strings to the TSA.


The fail shit that makes the text big is in CopyCanvas, not my function…

Waddo

2008-08-08 08:24:57

Oh kk yer i know what dist was i was looking at the code =p
do you know what is wrong with the copy canvas?
shuold i use safe copy canvas

Twisted

2008-08-08 09:46:39

nevermind at this.

Waddo

2008-08-08 09:56:50

erm twisted we already have that and i dont think that will work properly

Twisted

2008-08-08 10:21:07

begin
setup;
ClearSMARTCanvas;
repeat
ClearSMARTCanvas;
shownpcinfo;
wait(100);
if isfkeydown(11) then
repeat
showaniminfo;
until isfkeydown(11);
until false;
end.

Make that the main loop, so it will stay up instead of u having to hold it down to read, until you press f11 again

Macrosoft

2008-08-08 14:30:07

This should help a lot of people with reflection! Nice Job!

Waddo

2008-08-08 16:10:59

Made some more changes read bottom of thread.

Rubix

2008-08-09 18:15:55

wow very helpful for my new script im making!

jose89

2008-08-09 18:29:01

I really like all of the hard work being put into Reflection, just have one question.

What is the main goal of all of these reflection stuff? make another RsBot?
What would be the advantages?

Shuttleu

2008-08-09 18:49:27

From: jose89
I really like all of the hard work being put into Reflection, just have one question.

What is the main goal of all of these reflection stuff? make another RsBot?
What would be the advantages?

it will make scripts more flawless so they can run better and so the character wont get banned :)

~shut

Waddo

2008-08-09 22:27:43

we arnt making another rsbot

scar>rsbot

scar+reflection>GOD

rsbot has flawless walking scar has easily made failsafes and accurate object finding scar+reflection = ultimate pwnage its almost flawless we can walk perfectly and interact perfeactly and have great colour finding fialsafes

scars colour and shape detection is why it is greater than any other bot, but with reflection we overcome 90% of the downsides of using scar to rsbot

Harry

2008-08-09 22:40:01

From: Waddo
we arnt making another rsbot

scar>rsbot

scar+reflection>GOD


rsbot has flawless walking scar has easily made failsafes and accurate object finding scar+reflection = ultimate pwnage its almost flawless we can walk perfectly and interact perfeactly and have great colour finding fialsafes

scars colour and shape detection is why it is greater than any other bot, but with reflection we overcome 90% of the downsides of using scar to rsbot


I think you should change the >'s to <'s… RSBot is better than SCAR in ways of doing complex stuff. And SCAR and Reflection is not better than God.. :rolleyes:

Waddo

2008-08-10 06:11:33

God is fictional IMHO .'. Scar is greater than god

Twisted

2008-08-10 13:39:19

So you're an atheist?

Harry

2008-08-10 13:46:50

Even if he is fictional, you still should treat him with respect for other people.

/me tries to bring this back on-topic.

Waddo

2008-08-10 14:14:36

Oh its coming back on topic

Ok so ive just added another feature

now when your walking doesn't matter if smart is enabled or not pressing f9 will writeln your tile co-ords, this will prove extremely useful when creating scripts with reflection walking.

Lee Lok Hin

2008-08-11 22:28:56

Waddo, update your reflection. A lot/ Some bits of this script are outdated.

Waddo

2008-08-12 13:30:54

lol lee i aint updated reflection for ages

I cba untill we slow down cos we getting like 2 revs a day

Method

2008-08-12 13:34:42

From: Waddo
lol lee i aint updated reflection for ages

I cba untill we slow down cos we getting like 2 revs a day


It takes less than 30 seconds to browse to your Reflection folder, right-click, hit SVN Update, then wait until the files are downloaded. I'm not sure why you wouldn't update if given the chance (barring changes that aren't working).

Gu3st...

2008-08-12 14:46:39

omfg :(

I really want to try this out but i cant cus i use a higher rev than ur script is made for…

Waddo

2008-08-13 04:00:52

Zytex you can update it if you want (if any one updates and posts can a mod/admin edit it into first post as i am away for 2 days).

Also how do i update ive always just copied and pasted.

Rubix

2008-08-15 16:44:14

hmmm
Line 32: [Hint] (16128:25): Variable '' never used in script C:\Program Files\SCAR 3.15\includes\SRL\SRL\Reflection\Walking.Scar
Line 59: [Error] (16607:20): Unknown identifier 'MSX' in script
when trying to run the second part to load smart and stuff…. i need the NPC # for Sawmill Operator :D

Gu3st...

2008-08-15 19:01:17

From: Waddo
Zytex you can update it if you want (if any one updates and posts can a mod/admin edit it into first post as i am away for 2 days).

Also how do i update ive always just copied and pasted.


Yea i could, if i know what NPC.MSX (or something) is…

Naum

2008-08-16 03:04:11

Omy God Eek I'm Lost I used for tut island I know its pass :p.
Good work.

Waddo

2008-08-16 05:59:02

Ok i'm back now

lol nuaman you actually used it for sheep shearer =p