SRL Archive - Reflection

Milk


bevardis

2011-08-17 18:23:53

(The github picture is clickable)


It's a simple RuneScape debugger that works with Simba.
As of Build 49, it debugs compass, animation, coordinates and inventory items. It also paints all that on smart, I used Home's PrintOnSmart function. You have to have smart enabled if you want it to draw on screen. As of B50, it is in R2, also paints NPCS and Objects on screen.

Used my script template. B stands for build.

Current build is 50. Changelog..

masterBB

2011-08-17 18:35:13

I suggest to display inventory items onscreen. If you need help, this is one of my specialisms!

bevardis

2011-08-21 06:47:02

Build 49 uploaded.
[QUOTE=What's new]
Drawing on smart.
Debugging all inventory items.
Compass debugging.
Choosing what to debug (booleans).
[/QUOTE]

Flight

2011-08-21 06:50:24

You might find this useful as well. It's from R1 and converted over to R2.


{*******************************************************************************
procedure EnableSmartCanvas;
by: Cstrike
Description: Enables canvas for drawing on.
*******************************************************************************}
procedure EnableSmartCanvas;
begin
{$IFDEF SMART}
SmartSetDebug(true);
{$ELSE}
Writeln ('[R_EnableSmartCanvas] SMART not defined.');
{$ENDIF}
end;

{*******************************************************************************
procedure DisableSmartCanvas;
by: Cstrike
Description: Disables canvas.
*******************************************************************************}
procedure DisableSmartCanvas;
begin
{$IFDEF SMART}
SmartSetDebug(false);
{$ELSE}
Writeln ('[R_DisableSmartCanvas] SMART not defined.');
{$ENDIF}
end;

{*******************************************************************************
procedure ClearSmartCanvas;
by: Shuttleu (IIRC)
Description: Clears canvas.
*******************************************************************************}
procedure ClearSmartCanvas;
{$IFDEF SMART}
var
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
ClearRSCanvas(drawing.canvas);
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure SMART_DrawTrapezoidEx(Clear: boolean; TL, TR, BL, BR: TPoint; color: TColor);
Contributors: Sir R. Magician, caused, mastaraymond, modded by Cstrike
Description: Draws a trapezoid onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawTrapezoidEx(Clear: boolean; TL, TR, BL, BR: TPoint; color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;
if Clear then ClearRSCanvas(drawing.canvas);
drawing.canvas.moveto(TL.x,TL.y);
drawing.canvas.LineTo(TR.x,TR.y);
drawing.canvas.LineTo(BR.x,BR.y);
drawing.canvas.LineTo(BL.x,BL.y);
drawing.canvas.LineTo(TL.x,TL.y);
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure SMART_DrawTrapezoid(TL, TR, BL, BR: TPoint);
Contributors: Cstrike
Description: New version from drawing it.
*******************************************************************************}
procedure SMART_DrawTrapezoid(TL, TR, BL, BR: TPoint);
{$IFDEF SMART}
begin
SMART_DrawTrapezoidEx(True, TL, TR, BL, BR, clRed);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawLine(Clear: Boolean; TP1, TP2: TPoint; Color: TColor);
by: mormonman
Description: Draws a line on your screen.
*******************************************************************************}
procedure R_DrawLine(Clear: Boolean; TP1, TP2: TPoint; Color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
begin

drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;

if Clear then ClearRSCanvas(drawing.canvas);

drawing.canvas.moveto(TP1.x,TP1.y);
drawing.canvas.LineTo(TP2.x,TP2.y);


try
FreeBitmap(drawing);
except end;

{$ELSE}
begin
{$ENDIF}

end;

{*******************************************************************************
procedure R_DrawCircle(Clear: Boolean; Center, Radius: Integer; Color: TColor);
by: mormonman
Description: Draws a circle on your screen defined by center and radius.
*******************************************************************************}
procedure R_DrawCircle(Clear: Boolean; Center: TPoint; Radius: Integer; Color: TColor);
{$IFDEF SMART}
var
TPA: TPointArray;
begin
TPA := R_SortedCircleTPA(Center, Radius);
if Length(TPA) < 1 then Exit;
R_Debug('l:' +tostr(Length(TPA)), 'TPALENGTH');
SMART_DrawDotsEx(Clear, TPA, Color);
{$ELSE}
begin
{$ENDIF}

end;

{*******************************************************************************
procedure R_DrawPolygonEx(Clear: Boolean; Points: TPointArray; Border:Boolean; color: TColor);
by: mormonman
Description: Fills Polygon.
*******************************************************************************}
procedure R_DrawPolygonEx(Clear: Boolean; Points: TPointArray; Border:Boolean; color: TColor);
{$IFDEF SMART}
var
tmp: TPointArray;
i, Hi: Integer;
begin
if Clear then ClearSmartCanvas;
tmp := Points;
if length(tmp) < 2 then Exit;
Hi := High(tmp);
for i := 0 to Hi - 1 do
R_DrawLine(False, tmp[i], tmp[i+1], color);
R_DrawLine(False, tmp[Hi], tmp[0], color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DebugObjects(ObjType: Integer; ClearDebug: Boolean; Color: TColor);
by: Bad Boy JH
Description: Draws all the objects on your screen.
*******************************************************************************}
procedure R_DebugObjects(ObjType: Integer; ClearDebug: Boolean; Color: TColor);
{$IFDEF SMART}
var
I, X, Y, height, c, Hi: integer;
atpa: T2DPointArray;
Temp, tpa: tpointarray;
MyPos, T, A: TTile;
TheObject: TRSObject;
ScreenPoint, P: TPoint;
begin
MyPos := R_GetMyPos;
c := 1;
if ClearDebug then ClearSmartCanvas;
for X := MyPos.x - 7 to MyPos.x + 7 do
for Y := MyPos.y - 7 to MyPos.y + 7 do
if R_TileOnMS(Point(X, Y), 0) then
begin
ScreenPoint := R_TileToMS(Point(X, Y), 0);
TheObject := R_GetObjectAt(Point(X, Y), ObjType);
if TheObject = NULL_RSObject then
Continue;
T := TheObject.Tile;
A := Point(X, Y);
if (T.x = A.x) and (T.y = A.y) then
else
begin
Inc(c);
SetLength(atpa, c);
SetLength(atpa[c-1], 2);
P := R_TileToMS(T, 0);
if PointInBox(P, MSBOX) then
R_DrawLine(False, ScreenPoint, P, clSilver);
end;
Temp := LoadTextTPA('. ' + IntToStr(TheObject.ID), UpChars, height);
for i:= 0 to High(temp) do
begin
Temp[i].x := Temp[i].x + ScreenPoint.x - Height;
Temp[i].y := Temp[i].y + ScreenPoint.y - Height;
end;
TPA := CombineTPA(TPA, Temp);
end;
SMART_DrawDotsEx(False, TPA, Color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DebugNPCs(ClearDebug: Boolean);
by: Copied from Bad Boy JH and modded by Cstrike
Description: Draws all the NPCs on your screen. Only gets first NPC on a tile.
*******************************************************************************}
procedure R_DebugNPCs(ClearDebug: Boolean);
{$IFDEF SMART}
var
I, X, Y, height: integer;
Temp, tpa: tpointarray;
MyPos: TTile;
TheNPCArray: TNPCArray;
TheNPC: TNPC;
ScreenPoint: TPoint;
begin
MyPos := R_GetMyPos;
for X := MyPos.x - 7 to MyPos.x + 7 do
for Y := MyPos.y - 7 to MyPos.y + 7 do
if R_TileOnMS(Point(X, Y), 0) then
begin
ScreenPoint := R_TileToMS(Point(X, Y), 0);
TheNPCArray := R_GetNPCsAt(Point(X, Y), True);
if (high(TheNPCArray) < 0) then
Continue;
TheNPC := TheNPCArray[0]; // Only gets first one
if TheNPC = NULL_NPC then
Continue;
Temp := LoadTextTPA('. ' + ToStr(TheNPC.ID), UpChars, height);
for i:= 0 to High(temp) do
begin
Temp[i].x := Temp[i].x + ScreenPoint.x - Height;
Temp[i].y := Temp[i].y + ScreenPoint.y - Height;
end;
TPA := CombineTPA(TPA, Temp);
end;
SMART_DrawDotsEx(ClearDebug, TPA, clRed);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawTile (Tile: TTile; ClearScreen: Boolean; Color: TColor);
by: Cstrike
Description: Draws tile on your screen.
*******************************************************************************}
procedure R_DrawTile (Tile: TPoint; ClearScreen: Boolean; Color: TColor);
{$IFDEF SMART}
var
CornerTL, CornerBR: TPoint;
newTPA: TPointArray;
begin
if not R_TileOnMS(Tile, 0) or not R_LoggedIn then
Exit;
CornerBR := R_TileToMSEx(Tile, 1.0, 0.0, 0);
CornerTL := R_TileToMSEx(Tile, 0.0, 1.0, 0);
FindTPAEdgesWrap(TPAFromBox(IntToBox(CornerTL.X, CornerTL.Y, CornerBR.X, CornerBR.Y)), newTPA);
SMART_DrawDotsEx(ClearScreen, newTPA, Color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawTileHeight (Tile: TTile; Height: Integer; ClearScreen: Boolean; ColorBase, ColorHeight: TColor);
by: Cstrike
Description: Draws tile on your screen.
*******************************************************************************}
procedure R_DrawTileHeight (Tile: TPoint; Height: Integer; ClearScreen: Boolean; ColorBase, ColorHeight: TColor);
{$IFDEF SMART}
var
CornerTL, CornerBR: TPoint;
newTPA: TPointArray;
i: Integer;
begin
if not R_TileOnMS(Tile, 0) or not R_LoggedIn then
Exit;
for i:=0 to 1 do
begin
CornerBR := R_TileToMSEx(Tile, 1.0, 0.0, Height*i);
CornerTL := R_TileToMSEx(Tile, 0.0, 1.0, Height*i);
FindTPAEdgesWrap(TPAFromBox(IntToBox(CornerTL.X, CornerTL.Y, CornerBR.X, CornerBR.Y)), newTPA);
if i = 0 then
SMART_DrawDotsEx(ClearScreen, newTPA, ColorBase)
else
SMART_DrawDotsEx(False, newTPA, ColorHeight);
end;
{$ELSE}
begin
{$ENDIF}
end;

That's for Tile/Objects/NPCs.

weequ

2011-08-21 06:51:10

Nice job. Are you going to add object and npc drawing? Maybe an option to turn certain things on and off?

bevardis

2011-08-21 06:54:22

From: Flight
You might find this useful as well. It's from R1 and converted over to R2.


{*******************************************************************************
procedure EnableSmartCanvas;
by: Cstrike
Description: Enables canvas for drawing on.
*******************************************************************************}
procedure EnableSmartCanvas;
begin
{$IFDEF SMART}
SmartSetDebug(true);
{$ELSE}
Writeln ('[R_EnableSmartCanvas] SMART not defined.');
{$ENDIF}
end;

{*******************************************************************************
procedure DisableSmartCanvas;
by: Cstrike
Description: Disables canvas.
*******************************************************************************}
procedure DisableSmartCanvas;
begin
{$IFDEF SMART}
SmartSetDebug(false);
{$ELSE}
Writeln ('[R_DisableSmartCanvas] SMART not defined.');
{$ENDIF}
end;

{*******************************************************************************
procedure ClearSmartCanvas;
by: Shuttleu (IIRC)
Description: Clears canvas.
*******************************************************************************}
procedure ClearSmartCanvas;
{$IFDEF SMART}
var
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
ClearRSCanvas(drawing.canvas);
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure SMART_DrawTrapezoidEx(Clear: boolean; TL, TR, BL, BR: TPoint; color: TColor);
Contributors: Sir R. Magician, caused, mastaraymond, modded by Cstrike
Description: Draws a trapezoid onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawTrapezoidEx(Clear: boolean; TL, TR, BL, BR: TPoint; color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;
if Clear then ClearRSCanvas(drawing.canvas);
drawing.canvas.moveto(TL.x,TL.y);
drawing.canvas.LineTo(TR.x,TR.y);
drawing.canvas.LineTo(BR.x,BR.y);
drawing.canvas.LineTo(BL.x,BL.y);
drawing.canvas.LineTo(TL.x,TL.y);
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure SMART_DrawTrapezoid(TL, TR, BL, BR: TPoint);
Contributors: Cstrike
Description: New version from drawing it.
*******************************************************************************}
procedure SMART_DrawTrapezoid(TL, TR, BL, BR: TPoint);
{$IFDEF SMART}
begin
SMART_DrawTrapezoidEx(True, TL, TR, BL, BR, clRed);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawLine(Clear: Boolean; TP1, TP2: TPoint; Color: TColor);
by: mormonman
Description: Draws a line on your screen.
*******************************************************************************}
procedure R_DrawLine(Clear: Boolean; TP1, TP2: TPoint; Color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
begin

drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;

if Clear then ClearRSCanvas(drawing.canvas);

drawing.canvas.moveto(TP1.x,TP1.y);
drawing.canvas.LineTo(TP2.x,TP2.y);


try
FreeBitmap(drawing);
except end;

{$ELSE}
begin
{$ENDIF}

end;

{*******************************************************************************
procedure R_DrawCircle(Clear: Boolean; Center, Radius: Integer; Color: TColor);
by: mormonman
Description: Draws a circle on your screen defined by center and radius.
*******************************************************************************}
procedure R_DrawCircle(Clear: Boolean; Center: TPoint; Radius: Integer; Color: TColor);
{$IFDEF SMART}
var
TPA: TPointArray;
begin
TPA := R_SortedCircleTPA(Center, Radius);
if Length(TPA) < 1 then Exit;
R_Debug('l:' +tostr(Length(TPA)), 'TPALENGTH');
SMART_DrawDotsEx(Clear, TPA, Color);
{$ELSE}
begin
{$ENDIF}

end;

{*******************************************************************************
procedure R_DrawPolygonEx(Clear: Boolean; Points: TPointArray; Border:Boolean; color: TColor);
by: mormonman
Description: Fills Polygon.
*******************************************************************************}
procedure R_DrawPolygonEx(Clear: Boolean; Points: TPointArray; Border:Boolean; color: TColor);
{$IFDEF SMART}
var
tmp: TPointArray;
i, Hi: Integer;
begin
if Clear then ClearSmartCanvas;
tmp := Points;
if length(tmp) < 2 then Exit;
Hi := High(tmp);
for i := 0 to Hi - 1 do
R_DrawLine(False, tmp[i], tmp[i+1], color);
R_DrawLine(False, tmp[Hi], tmp[0], color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DebugObjects(ObjType: Integer; ClearDebug: Boolean; Color: TColor);
by: Bad Boy JH
Description: Draws all the objects on your screen.
*******************************************************************************}
procedure R_DebugObjects(ObjType: Integer; ClearDebug: Boolean; Color: TColor);
{$IFDEF SMART}
var
I, X, Y, height, c, Hi: integer;
atpa: T2DPointArray;
Temp, tpa: tpointarray;
MyPos, T, A: TTile;
TheObject: TRSObject;
ScreenPoint, P: TPoint;
begin
MyPos := R_GetMyPos;
c := 1;
if ClearDebug then ClearSmartCanvas;
for X := MyPos.x - 7 to MyPos.x + 7 do
for Y := MyPos.y - 7 to MyPos.y + 7 do
if R_TileOnMS(Point(X, Y), 0) then
begin
ScreenPoint := R_TileToMS(Point(X, Y), 0);
TheObject := R_GetObjectAt(Point(X, Y), ObjType);
if TheObject = NULL_RSObject then
Continue;
T := TheObject.Tile;
A := Point(X, Y);
if (T.x = A.x) and (T.y = A.y) then
else
begin
Inc(c);
SetLength(atpa, c);
SetLength(atpa[c-1], 2);
P := R_TileToMS(T, 0);
if PointInBox(P, MSBOX) then
R_DrawLine(False, ScreenPoint, P, clSilver);
end;
Temp := LoadTextTPA('. ' + IntToStr(TheObject.ID), UpChars, height);
for i:= 0 to High(temp) do
begin
Temp[i].x := Temp[i].x + ScreenPoint.x - Height;
Temp[i].y := Temp[i].y + ScreenPoint.y - Height;
end;
TPA := CombineTPA(TPA, Temp);
end;
SMART_DrawDotsEx(False, TPA, Color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DebugNPCs(ClearDebug: Boolean);
by: Copied from Bad Boy JH and modded by Cstrike
Description: Draws all the NPCs on your screen. Only gets first NPC on a tile.
*******************************************************************************}
procedure R_DebugNPCs(ClearDebug: Boolean);
{$IFDEF SMART}
var
I, X, Y, height: integer;
Temp, tpa: tpointarray;
MyPos: TTile;
TheNPCArray: TNPCArray;
TheNPC: TNPC;
ScreenPoint: TPoint;
begin
MyPos := R_GetMyPos;
for X := MyPos.x - 7 to MyPos.x + 7 do
for Y := MyPos.y - 7 to MyPos.y + 7 do
if R_TileOnMS(Point(X, Y), 0) then
begin
ScreenPoint := R_TileToMS(Point(X, Y), 0);
TheNPCArray := R_GetNPCsAt(Point(X, Y), True);
if (high(TheNPCArray) < 0) then
Continue;
TheNPC := TheNPCArray[0]; // Only gets first one
if TheNPC = NULL_NPC then
Continue;
Temp := LoadTextTPA('. ' + ToStr(TheNPC.ID), UpChars, height);
for i:= 0 to High(temp) do
begin
Temp[i].x := Temp[i].x + ScreenPoint.x - Height;
Temp[i].y := Temp[i].y + ScreenPoint.y - Height;
end;
TPA := CombineTPA(TPA, Temp);
end;
SMART_DrawDotsEx(ClearDebug, TPA, clRed);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawTile (Tile: TTile; ClearScreen: Boolean; Color: TColor);
by: Cstrike
Description: Draws tile on your screen.
*******************************************************************************}
procedure R_DrawTile (Tile: TPoint; ClearScreen: Boolean; Color: TColor);
{$IFDEF SMART}
var
CornerTL, CornerBR: TPoint;
newTPA: TPointArray;
begin
if not R_TileOnMS(Tile, 0) or not R_LoggedIn then
Exit;
CornerBR := R_TileToMSEx(Tile, 1.0, 0.0, 0);
CornerTL := R_TileToMSEx(Tile, 0.0, 1.0, 0);
FindTPAEdgesWrap(TPAFromBox(IntToBox(CornerTL.X, CornerTL.Y, CornerBR.X, CornerBR.Y)), newTPA);
SMART_DrawDotsEx(ClearScreen, newTPA, Color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawTileHeight (Tile: TTile; Height: Integer; ClearScreen: Boolean; ColorBase, ColorHeight: TColor);
by: Cstrike
Description: Draws tile on your screen.
*******************************************************************************}
procedure R_DrawTileHeight (Tile: TPoint; Height: Integer; ClearScreen: Boolean; ColorBase, ColorHeight: TColor);
{$IFDEF SMART}
var
CornerTL, CornerBR: TPoint;
newTPA: TPointArray;
i: Integer;
begin
if not R_TileOnMS(Tile, 0) or not R_LoggedIn then
Exit;
for i:=0 to 1 do
begin
CornerBR := R_TileToMSEx(Tile, 1.0, 0.0, Height*i);
CornerTL := R_TileToMSEx(Tile, 0.0, 1.0, Height*i);
FindTPAEdgesWrap(TPAFromBox(IntToBox(CornerTL.X, CornerTL.Y, CornerBR.X, CornerBR.Y)), newTPA);
if i = 0 then
SMART_DrawDotsEx(ClearScreen, newTPA, ColorBase)
else
SMART_DrawDotsEx(False, newTPA, ColorHeight);
end;
{$ELSE}
begin
{$ENDIF}
end;

That's for Tile/Objects/NPCs.


Thank you.

From: weequ
Nice job. Are you going to add object and npc drawing? Maybe an option to turn certain things on and off?


Why not, it's useful, just don't know how would it work out. There is an option to turn debugs on or off, but they're in boolens. Will probobly make them more user friendly.

Gu3st...

2011-08-21 07:04:51

From: Flight
You might find this useful as well. It's from R1 and converted over to R2.


{*******************************************************************************
procedure EnableSmartCanvas;
by: Cstrike
Description: Enables canvas for drawing on.
*******************************************************************************}
procedure EnableSmartCanvas;
begin
{$IFDEF SMART}
SmartSetDebug(true);
{$ELSE}
Writeln ('[R_EnableSmartCanvas] SMART not defined.');
{$ENDIF}
end;

{*******************************************************************************
procedure DisableSmartCanvas;
by: Cstrike
Description: Disables canvas.
*******************************************************************************}
procedure DisableSmartCanvas;
begin
{$IFDEF SMART}
SmartSetDebug(false);
{$ELSE}
Writeln ('[R_DisableSmartCanvas] SMART not defined.');
{$ENDIF}
end;

{*******************************************************************************
procedure ClearSmartCanvas;
by: Shuttleu (IIRC)
Description: Clears canvas.
*******************************************************************************}
procedure ClearSmartCanvas;
{$IFDEF SMART}
var
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
ClearRSCanvas(drawing.canvas);
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure SMART_DrawTrapezoidEx(Clear: boolean; TL, TR, BL, BR: TPoint; color: TColor);
Contributors: Sir R. Magician, caused, mastaraymond, modded by Cstrike
Description: Draws a trapezoid onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawTrapezoidEx(Clear: boolean; TL, TR, BL, BR: TPoint; color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;
if Clear then ClearRSCanvas(drawing.canvas);
drawing.canvas.moveto(TL.x,TL.y);
drawing.canvas.LineTo(TR.x,TR.y);
drawing.canvas.LineTo(BR.x,BR.y);
drawing.canvas.LineTo(BL.x,BL.y);
drawing.canvas.LineTo(TL.x,TL.y);
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure SMART_DrawTrapezoid(TL, TR, BL, BR: TPoint);
Contributors: Cstrike
Description: New version from drawing it.
*******************************************************************************}
procedure SMART_DrawTrapezoid(TL, TR, BL, BR: TPoint);
{$IFDEF SMART}
begin
SMART_DrawTrapezoidEx(True, TL, TR, BL, BR, clRed);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawLine(Clear: Boolean; TP1, TP2: TPoint; Color: TColor);
by: mormonman
Description: Draws a line on your screen.
*******************************************************************************}
procedure R_DrawLine(Clear: Boolean; TP1, TP2: TPoint; Color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
begin

drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;

if Clear then ClearRSCanvas(drawing.canvas);

drawing.canvas.moveto(TP1.x,TP1.y);
drawing.canvas.LineTo(TP2.x,TP2.y);


try
FreeBitmap(drawing);
except end;

{$ELSE}
begin
{$ENDIF}

end;

{*******************************************************************************
procedure R_DrawCircle(Clear: Boolean; Center, Radius: Integer; Color: TColor);
by: mormonman
Description: Draws a circle on your screen defined by center and radius.
*******************************************************************************}
procedure R_DrawCircle(Clear: Boolean; Center: TPoint; Radius: Integer; Color: TColor);
{$IFDEF SMART}
var
TPA: TPointArray;
begin
TPA := R_SortedCircleTPA(Center, Radius);
if Length(TPA) < 1 then Exit;
R_Debug('l:' +tostr(Length(TPA)), 'TPALENGTH');
SMART_DrawDotsEx(Clear, TPA, Color);
{$ELSE}
begin
{$ENDIF}

end;

{*******************************************************************************
procedure R_DrawPolygonEx(Clear: Boolean; Points: TPointArray; Border:Boolean; color: TColor);
by: mormonman
Description: Fills Polygon.
*******************************************************************************}
procedure R_DrawPolygonEx(Clear: Boolean; Points: TPointArray; Border:Boolean; color: TColor);
{$IFDEF SMART}
var
tmp: TPointArray;
i, Hi: Integer;
begin
if Clear then ClearSmartCanvas;
tmp := Points;
if length(tmp) < 2 then Exit;
Hi := High(tmp);
for i := 0 to Hi - 1 do
R_DrawLine(False, tmp[i], tmp[i+1], color);
R_DrawLine(False, tmp[Hi], tmp[0], color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DebugObjects(ObjType: Integer; ClearDebug: Boolean; Color: TColor);
by: Bad Boy JH
Description: Draws all the objects on your screen.
*******************************************************************************}
procedure R_DebugObjects(ObjType: Integer; ClearDebug: Boolean; Color: TColor);
{$IFDEF SMART}
var
I, X, Y, height, c, Hi: integer;
atpa: T2DPointArray;
Temp, tpa: tpointarray;
MyPos, T, A: TTile;
TheObject: TRSObject;
ScreenPoint, P: TPoint;
begin
MyPos := R_GetMyPos;
c := 1;
if ClearDebug then ClearSmartCanvas;
for X := MyPos.x - 7 to MyPos.x + 7 do
for Y := MyPos.y - 7 to MyPos.y + 7 do
if R_TileOnMS(Point(X, Y), 0) then
begin
ScreenPoint := R_TileToMS(Point(X, Y), 0);
TheObject := R_GetObjectAt(Point(X, Y), ObjType);
if TheObject = NULL_RSObject then
Continue;
T := TheObject.Tile;
A := Point(X, Y);
if (T.x = A.x) and (T.y = A.y) then
else
begin
Inc(c);
SetLength(atpa, c);
SetLength(atpa[c-1], 2);
P := R_TileToMS(T, 0);
if PointInBox(P, MSBOX) then
R_DrawLine(False, ScreenPoint, P, clSilver);
end;
Temp := LoadTextTPA('. ' + IntToStr(TheObject.ID), UpChars, height);
for i:= 0 to High(temp) do
begin
Temp[i].x := Temp[i].x + ScreenPoint.x - Height;
Temp[i].y := Temp[i].y + ScreenPoint.y - Height;
end;
TPA := CombineTPA(TPA, Temp);
end;
SMART_DrawDotsEx(False, TPA, Color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DebugNPCs(ClearDebug: Boolean);
by: Copied from Bad Boy JH and modded by Cstrike
Description: Draws all the NPCs on your screen. Only gets first NPC on a tile.
*******************************************************************************}
procedure R_DebugNPCs(ClearDebug: Boolean);
{$IFDEF SMART}
var
I, X, Y, height: integer;
Temp, tpa: tpointarray;
MyPos: TTile;
TheNPCArray: TNPCArray;
TheNPC: TNPC;
ScreenPoint: TPoint;
begin
MyPos := R_GetMyPos;
for X := MyPos.x - 7 to MyPos.x + 7 do
for Y := MyPos.y - 7 to MyPos.y + 7 do
if R_TileOnMS(Point(X, Y), 0) then
begin
ScreenPoint := R_TileToMS(Point(X, Y), 0);
TheNPCArray := R_GetNPCsAt(Point(X, Y), True);
if (high(TheNPCArray) < 0) then
Continue;
TheNPC := TheNPCArray[0]; // Only gets first one
if TheNPC = NULL_NPC then
Continue;
Temp := LoadTextTPA('. ' + ToStr(TheNPC.ID), UpChars, height);
for i:= 0 to High(temp) do
begin
Temp[i].x := Temp[i].x + ScreenPoint.x - Height;
Temp[i].y := Temp[i].y + ScreenPoint.y - Height;
end;
TPA := CombineTPA(TPA, Temp);
end;
SMART_DrawDotsEx(ClearDebug, TPA, clRed);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawTile (Tile: TTile; ClearScreen: Boolean; Color: TColor);
by: Cstrike
Description: Draws tile on your screen.
*******************************************************************************}
procedure R_DrawTile (Tile: TPoint; ClearScreen: Boolean; Color: TColor);
{$IFDEF SMART}
var
CornerTL, CornerBR: TPoint;
newTPA: TPointArray;
begin
if not R_TileOnMS(Tile, 0) or not R_LoggedIn then
Exit;
CornerBR := R_TileToMSEx(Tile, 1.0, 0.0, 0);
CornerTL := R_TileToMSEx(Tile, 0.0, 1.0, 0);
FindTPAEdgesWrap(TPAFromBox(IntToBox(CornerTL.X, CornerTL.Y, CornerBR.X, CornerBR.Y)), newTPA);
SMART_DrawDotsEx(ClearScreen, newTPA, Color);
{$ELSE}
begin
{$ENDIF}
end;

{*******************************************************************************
procedure R_DrawTileHeight (Tile: TTile; Height: Integer; ClearScreen: Boolean; ColorBase, ColorHeight: TColor);
by: Cstrike
Description: Draws tile on your screen.
*******************************************************************************}
procedure R_DrawTileHeight (Tile: TPoint; Height: Integer; ClearScreen: Boolean; ColorBase, ColorHeight: TColor);
{$IFDEF SMART}
var
CornerTL, CornerBR: TPoint;
newTPA: TPointArray;
i: Integer;
begin
if not R_TileOnMS(Tile, 0) or not R_LoggedIn then
Exit;
for i:=0 to 1 do
begin
CornerBR := R_TileToMSEx(Tile, 1.0, 0.0, Height*i);
CornerTL := R_TileToMSEx(Tile, 0.0, 1.0, Height*i);
FindTPAEdgesWrap(TPAFromBox(IntToBox(CornerTL.X, CornerTL.Y, CornerBR.X, CornerBR.Y)), newTPA);
if i = 0 then
SMART_DrawDotsEx(ClearScreen, newTPA, ColorBase)
else
SMART_DrawDotsEx(False, newTPA, ColorHeight);
end;
{$ELSE}
begin
{$ENDIF}
end;

That's for Tile/Objects/NPCs.
IIRC, those doesn't work. Did you test them?

Smarter Child

2011-08-21 07:07:36

You should create a form for this, or an even easier method would be to assign certain debugging to certain keys. [i.e. if IsFKeyDown(2) then DebugSoAndSo;] :)

Flight

2011-08-21 07:21:25

From: Zyt3x
IIRC, those doesn't work. Did you test them?


Yes I did, and yes they do.

Gu3st...

2011-08-21 07:32:27

From: Flight
Yes I did, and yes they do.
Nice :)

Echo_

2011-08-21 09:21:05

I thought we already had one of these, nice job anyways :thumbsup:

E: What does Milk stand for?

marpis

2011-08-21 09:59:31

From: bevardis

Why not, it's useful, just don't know how would it work out. There is an option to turn debugs on or off, but they're in boolens. Will probobly make them more user friendly.


GetAllNPCs, draw all their IDs in a certain color at (NPC.MS.x, NPC.MS.y)

bevardis

2011-08-21 11:54:53

From: Echo_
I thought we already had one of these, nice job anyways :thumbsup:

E: What does Milk stand for?


No idea, "Mommy, I like kittens" fits in, but is somewhat unrelated. Maybe I Will think of something. You (and others) can too.

Flight

2011-08-21 12:24:14

From: Zyt3x
Nice :)


Although I noticed they're not as quick as one would want them to be… I think through those functions all tiles/objects/npcs are loaded into the array, therefore they're slow to be written on the screen and will be offset once the screen position has changed. (Player walk or camera shift)

Maybe there's a way to limit what's loaded to the current 'Plane' only?

bevardis

2011-08-26 06:49:52

Build 50
-NPC debugging
-Object debugging
-Reflection 2 support
-Using Cstrike's RefPaint R2 version
-Increased loop sleep time

masterBB

2011-09-11 15:33:15

From: bevardis
No idea, "Mommy, I like kittens" fits in, but is somewhat unrelated. Maybe I Will think of something. You (and others) can too.


Master information list kit
Making info listing kool
Master intelligence logger kit
My information leet kit

^^ that 'k' followed by an 'l' makes this challenging.