SRL Archive - Newly Added to Reflection

New Ref. debug features! Painting to help you


Cstrike

2010-12-04 18:52:04

RefPaint.simba

Located in the core but is NOT included when you run reflection
You must define it yourself


You need to define PaintSmart first and then the include. Try this:

{$DEFINE SMART}
{$i srl\srl.scar}
{$i srl\srl\misc\paintsmart.scar}
{$i reflection\reflection.simba}
{$i reflection\core\RefPaint.simba}


So what can you do with it?
Well we want to eventually be stand alone instead of going always over to RSBot to keep getting interface data and stuff like that. Unfortunately we are stuck with getting absolutes from them for the time being, but we will be working on a way around that.

So what is new here that you can try?

I ran this:
program new;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i srl\srl\misc\paintsmart.scar}
{$i reflection\reflection.simba}
{$i reflection\core\RefPaint.simba}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
Nick := '';
Pin := '';
end;
end;

procedure SetupScript;
begin
Smart_Server := 121;
Smart_Members := false;
Smart_Signed := true;
Smart_SuperDetail := false;
ActivateClient;
SetupSRL;
SetupReflection;
DeclarePlayers;
LoginPlayer;
Wait (410+random(770));
end;

begin
SetupScript;
EnableSmartCanvas;
R_DrawTile(GetMyPos, True, clRed);
R_DebugNPCs(False);
R_DebugObjects(0, false, clBlue);
R_DebugObjects(1, false, 57645);
R_DebugObjects(2, false, clWhite);
R_DebugObjects(3, false, clYellow);
end.

And got this:


Note that for the colors, you can set them to a pre-defined constant, or your own color that you pick. If you're unsure, just use clRed.
Not too bad. Please note that you can't get the yellow interface debugging around your items yet, that will come soon. This was not included in the core because it is not essential for any scripts to run. The stuff in here is mainly for your debugging. Note there are some new functions in RefPaint.simba that I have not included here, like drawing a trapezoid.

Enjoy.

Special thanks to Bad Boy JH for the code and idea.

NOTE: Takes a while to process the data so some NPC's who move may not be on the same tile, but you should be able to work around this since it is after all debugging points that you want.
In the future I may play with the code to increase the speed.

Gu3st...

2010-12-04 19:08:14

This is cool! :)
Good job :D

Bad Boy JH

2010-12-05 02:54:27

good modification of it, I like it alot…

pyroryan

2010-12-05 02:56:16

Nice work!

Coh3n

2010-12-05 03:56:43

From: cstrike

Located in the core but is NOT included when you run reflection
You must define it yourself

Why not make a misc folder like in SRL?

This is pretty sweet by the way. Could you also add the item IDs to display on the item?

I think you should also come up with some kind of legend. Like Blue = Object IDs, Green = Tiles. Or whatever they actually are, that's just what I got out of it. :p

TomTuff

2010-12-05 05:22:42

Wow cstrike, pumping out all the features and functions for reflection like a champ. I was using mini-debugging scripts to do things like this on my own before :p

lordsaturn

2010-12-05 05:52:40

Thank you for making this. +rep.

Edit: Instead of painting to client, you could paint to a debug image? It would probably be much quicker, and you are achieving the same result.

Bad Boy JH

2010-12-05 07:14:12

Possible, I could do something like that, don't see the advantage, but it could be done. Perhaps doing all the other stuff that Tribot offers (which is where I got the inspiration for the original idea). I may start working on one for the inventory (should be easy). I know that tribot does it really easily and quickly, anyone know how they do it?

Shuttleu

2010-12-05 07:20:55

and make the text smaller

~shut

Bad Boy JH

2010-12-05 08:05:46

It works even when angle isn't 0, 90, 180 or 270

function XToY(X: Integer; Point1, Point2: TPoint): Integer;
var
M: Extended;
begin
M := 1.0 * (Point2.y - Point1.y) / (Point2.x - Point1.x);
Result := Round((X - Point1.x) * M) + Point1.y;
end;

function YToX(Y: Integer; Point1, Point2: TPoint): Integer;
var
M: Extended;
begin
M := 1.0 * (Point2.y - Point1.y) / (Point2.x - Point1.x);
Result := Round(((1.0 * Y - Point1.y) / M) + Point1.x);
end;

procedure DebugTile(Tile: TTile; ClearScreen: Boolean; Color: TColor);
var
TR, BR, TL, BL: TPoint;
Box: TPointArray;
Y, X: Integer;
begin
TR := TileToMSEx(Tile, 1, 1, 0);
BR := TileToMSEx(Tile, 1, 0, 0);
TL := TileToMSEx(Tile, 0, 1, 0);
BL := TileToMSEx(Tile, 0, 0, 0);

for X := Min(TR.x, BR.x) to Max(TR.x, BR.x) do
Box := CombineTPA(Box, [Point(X, XToY(X, TR, BR))]);
for X := TL.x to TR.x do
Box := CombineTPA(Box, [Point(X, XToY(X, TR, TL))]);
for X := BL.x to BR.x do
Box := CombineTPA(Box, [Point(X, XToY(X, BL, BR))]);
for X := Min(TL.x, BL.x) to Max(TL.x, BL.x) do
Box := CombineTPA(Box, [Point(X, XToY(X, BL, TL))]);

for Y := TR.y to BR.y do
Box := CombineTPA(Box, [Point(YToX(Y, TR, BR), Y)]);
for Y := Min(TL.y, TR.y) to Max(TL.y, TR.y) do
Box := CombineTPA(Box, [Point(YToX(Y, TR, TL), Y)]);
for Y := Min(BL.y, BR.y) to Max(BL.y, BR.y) do
Box := CombineTPA(Box, [Point(YToX(Y, BL, BR), Y)]);
for Y := TL.y to BL.y do
Box := CombineTPA(Box, [Point(YToX(Y, BL, TL), Y)]);
ClearDoubleTPA(Box);
SMART_DrawDotsEx(ClearScreen, Box, Color);
end;

Shuttleu

2010-12-05 08:06:04

im gonna use it now :D

~shut

Shuttleu

2010-12-05 08:25:04

{*******************************************************************************
procedure R_PrintTile(ClearScreen: Boolean; Color: TColor);
by: Shuttleu
Description: Prints your tile position on the screen.
*******************************************************************************}
procedure R_PrintTile(ClearScreen: Boolean; Color: TColor);
{$IFDEF SMART}
begin
SMART_DrawTextEx(ClearScreen, 5, 5, 'UpChars', IntToStr(GetMyPos.x)+', '+IntToStr(GetMyPos.y), Color);
{$ELSE}
begin
{$ENDIF}
end;

~shut

lordsaturn

2010-12-05 08:56:01

From: Bad Boy JH
Possible, I could do something like that, don't see the advantage, but it could be done. Perhaps doing all the other stuff that Tribot offers (which is where I got the inspiration for the original idea). I may start working on one for the inventory (should be easy). I know that tribot does it really easily and quickly, anyone know how they do it?


I have already explained the advantage, it's faster. Tribot and powerbot work by integrating the hooks into the bot, so that they can debug without having to run any script.

Sir R. M8gic1an

2010-12-05 09:51:34

Nice!

~RM

Coh3n

2010-12-05 19:37:44

I thought about this last night: You could make a whole program that debugs SMART.

Run this:

program FormTemplate;
{$i SRL/SRL/misc/SMART.scar}
{$i SRL/SRL.scar}

var
frmMain: TForm;

procedure InitForm;
begin
frmMain := TForm.Create(frmMain);
with frmMain do
begin
SetBounds(200, 200, 300, 500);
Caption := 'Test Form!';
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
// SMART Settings
SMART_Server := 152;
SMART_Members := False;
SMART_Signed := True;
SMART_SuperDetail := False;

SetupSRL;

SafeInitForm;
SafeShowFormModal;
end.
You could have a list of check boxes in the form to check off what you want debugged. :)

bbri06

2010-12-05 19:42:22

Oooo me love you long time!

Bad Boy JH

2010-12-05 20:07:41

I felt that that was where this mini project was going, chucking it onto a form.

Just a follow on from the post about speed and tribot's debugging procedures, would it be impossible to try and add an extention or plugin or something to that effect, which integrates the hooks into SMART, which allows for more efficent debugging simmilar to tribot?

Bad Boy JH

2010-12-05 21:08:37

From: Shuttleu
{*******************************************************************************
procedure R_PrintTile(ClearScreen: Boolean; Color: TColor);
by: Shuttleu
Description: Prints your tile position on the screen.
*******************************************************************************}
procedure R_PrintTile(ClearScreen: Boolean; Color: TColor);
{$IFDEF SMART}
begin
SMART_DrawTextEx(ClearScreen, 5, 5, 'UpChars', IntToStr(GetMyPos.x)+', '+IntToStr(GetMyPos.y), Color);
{$ELSE}
begin
{$ENDIF}
end;
~shut


Minor simplification

procedure R_PrintTile(ClearScreen: Boolean; Color: TColor);
{$IFDEF SMART}
begin
SMART_DrawTextEx(ClearScreen, 5, 5, 'UpChars', ToStr(GetMyPos), Color);
{$ELSE}
begin
{$ENDIF}
end;

ToStr, how I love thee

Cstrike

2010-12-05 21:50:22

From: Coh3n
I thought about this last night: You could make a whole program that debugs SMART.

Run this:

program FormTemplate;
{$i SRL/SRL/misc/SMART.scar}
{$i SRL/SRL.scar}

var
frmMain: TForm;

procedure InitForm;
begin
frmMain := TForm.Create(frmMain);
with frmMain do
begin
SetBounds(200, 200, 300, 500);
Caption := 'Test Form!';
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmMain.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
// SMART Settings
SMART_Server := 152;
SMART_Members := False;
SMART_Signed := True;
SMART_SuperDetail := False;

SetupSRL;

SafeInitForm;
SafeShowFormModal;
end.
You could have a list of check boxes in the form to check off what you want debugged. :)


OMG
I know mc_teo is working on something like this, but I want to create a debug thing just like that w/ forms and all

Nava2

2010-12-06 00:13:26

Why not put this into ``Development''?

Coh3n

2010-12-06 03:45:45

From: cstrike
OMG
I know mc_teo is working on something like this, but I want to create a debug thing just like that w/ forms and all

Yeah. Honestly, would be very very easy. You can just add check boxes and call a different SMART paint method when each one it checked.

Death12652

2010-12-26 10:39:57

THANK YOU for this it helps so much.