SCAR Code:
{ REFLECTION DEBUGGER by Heysus
Debugs:
- Main Screen (Tiles, Objects, NPCs, Ground Items)
- Minimap
- Inventory
- NPC Chat Interfaces
}
Program ReflectionDebugger;
// SMART include without the color/mouse functions
procedure SmartSetTarget;
var
Smart_Bitmap: Integer;
begin
Smart_Bitmap:= BitmapFromString(765,503,'');
GetBitmapCanvas(Smart_Bitmap).Handle:= SmartGetDC;
SetTargetBitmap(Smart_Bitmap);
FreeBitmap(Smart_Bitmap);
end;
procedure SmartSetupEx(worldnumber: integer; members, signed, superdetail: boolean);
var
prefix: string;
begin
prefix := ReadINI('World' + IntToStr(worldnumber), 'Prefix', AppPath + 'includes\SRL\SRL\misc\worlds.ini');
if(prefix = '')then
begin
writeln('Invalid world number or corrupted world list. Please review your settings');
TerminateScript;
end;
SmartSetup('http://'+prefix+'.runescape.com/', 'plugin.js?param=o0,a' + IntToStr((Integer(not(Signed)) + 1) * Integer(not((SuperDetail and Signed)))) + ',m' + IntToStr(Integer(Members)));
end;
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.scar}
var
x, y, LastP: integer;
Form: TForm;
Box: TGroupBox;
Labels: Array of TLabel;
Procedure InitForm;
var
i: integer;
begin
Form := CreateForm;
Form.Left := 0;
Form.Top := 0;
Form.Width := 205;
Form.Height := 155;
Form.Caption := 'ReflectionDebug';
Form.Color := clBtnFace;
Form.Font.Color := clWindowText;
Form.Font.Height := 12;
Form.Font.Name := 'MS Sans Serif';
Form.Font.Style := [];
Form.Visible := False;
Form.PixelsPerInch := 96;
Box := TGroupBox.Create(Form);
Box.Parent := Form;
Box.Left := 10;
Box.Top := 5;
Box.Width := 176;
Box.Height := 105;
Box.Caption := '';
Box.TabOrder := 8;
SetArrayLength(Labels, 6);
for i:=0 to 5 do
begin
Labels[i] := TLabel.Create(Form);
Labels[i].Parent := Box;
Labels[i].Left := 10;
Labels[i].Top := 17 + 15*i;
Labels[i].Width := 160;
Labels[i].Height := 17;
Labels[i].Caption := '';
end;
end;
Procedure SafeInitForm;
var
V: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('InitForm', V);
end;
Procedure ShowForm;
begin
Form.Show;
end;
Procedure SafeShowForm;
var
V: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowForm', V);
end;
Function GetMouseArea: string;
begin
GetMousePos(x, y);
if PointInBox(Point(x, y), IntToBox(7, 32, 519, 366)) then
Result := 'Main Screen';
if PointInBox(Point(x, y), IntToBox(5, 368, 521, 507)) then
Result := 'Interface';
if (PointInBox(Point(x, y), IntToBox(MIX1, MIY1, MIX2, MIY2))) and (GetCurrentTab = 4) then
Result := 'Inventory';
if Rs_OnMinimap(x, y) then
Result := 'Minimap';
if (not(LoggedIn)) or (GetTimeRunning < 3000) then
Result := 'Reflection Debugger';
Box.Caption := Result;
end;
Procedure Clear;
var
i: integer;
begin
for i:=0 to 5 do
Labels[i].Caption := '';
end;
Procedure Start;
begin
FindWindowBySize(766, 504);
Labels[1].Caption := 'Reflection Debugger';
Labels[2].Caption := 'By Heysus';
Labels[3].Caption := 'Version 1.0';
ClearDebug;
end;
Function TileDist(MS, T: TPoint): integer;
begin
T := TileToMS(T, 0);
Result := Distance(MS.x, MS.y, T.x, T.y);
end;
Procedure DebugInventory;
var
x, y: integer;
Item: TInvItem;
begin
GetMousePos(x, y);
Item := GetInvItemInfo(CoordsToItem(x, y));
Labels[0].Caption := 'Name: ' + Between(' ', '/', rs_GetUpText);
Labels[1].Caption := 'ID: ' + IntToStr(Item.ID);
Labels[2].Caption := 'Amount: ' + IntToStr(Item.Stack);
end;
Function DebugInterface: boolean;
var
a, b, c, x, y, Count, P: integer;
str: string;
Letters: TStringArray;
Exists: Array of Boolean;
begin
if LastP > 0 then
begin
for a:=1 to 8 do
begin
str := GetInterfaceText(LastP, a);
if str <> '' then
if FindText(x, y, str, NPCChars, MCX1, MCY1, MCX2, MCY2) then
Inc(C);
end;
if C > 1 then
begin
Labels[0].Caption := 'Parent: ' + IntToStr(LastP);
Labels[1].Caption := '(Text in Debug Box)';
exit;
end;
end;
Clear;
Labels[0].Caption := 'Searching Interfaces...';
Letters := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
SetArrayLength(Exists, 26);
for a:=0 to 25 do
if FindText(x, y, Letters[a], NPCChars, MCX1, MCY1, MCX2, MCY2) then
Exists[a] := true;
for a:=0 to 751 do
begin
if not ValidInterface(a) then
continue;
str := '';
for b:=0 to 8 do
str := str + GetInterfaceText(a, b);
c := 0;
for b:=0 to 25 do
if (Pos(Letters[b], str) > 0) = (Exists[b]) then
Inc(c);
if c > Count then
begin
P := a;
Count := c;
end;
end;
if Count = 0 then
exit;
LastP := P;
Labels[0].Caption := 'Parent: ' + IntToStr(P);
Labels[1].Caption := '(Text in Debug Box)';
ClearDebug;
for C:=0 to 8 do
begin
str := GetInterfaceText(P, C);
if str <> '' then
Writeln(IntToStr(P) + ', ' + IntToStr(C) + ' ' + str);
end;
end;
Procedure DebugMainScreen;
var
a, b, x, y, d, i: integer;
TP, P: TPoint;
TPA: TPointArray;
Obj: UID;
NPC: TNPC;
NPCs: Array of TNPC;
begin
/// MOUSE POS ///
GetMousePos(x, y);
TP := GetMyPos;
P := TileToMS(GetMyPos, 0);
i := Distance(x, y, P.x, P.y)/30
D := 10000;
for a := TP.x - i to TP.x + i do
begin
for b := TP.y - i to TP.y + i do
begin
if (TileDist(Point(x, y), Point(a, b)) < D) or (TileDist(Point(x, y), Point(a, b)) < 30) then
begin
D := TileDist(Point(x, y), Point(a, b));
P := Point(a, b);
end;
end;
end;
/// OBJECT ///
Obj := GetObjectAt(P.x, P.y);
/// NPC ///
NPCs := GetNPCs;
for i:=0 to High(NPCs) do
if (NPCs[i].Tile.x = P.x) and (NPCs[i].Tile.y = P.y) then
begin
NPC := NPCs[i];
break;
end;
/// GROUND ITEM ///
TPA := GetGroundItems(P.x, P.y);
i := 1;
Labels[0].Caption := 'Mouse Tile: (' + IntToStr(P.x) + ', ' + IntToStr(P.y) + ')';
if (Obj.objtype > 0) and (Obj.objtype <> NPC.Index) and (Obj.objtype <> 2047) then
begin
Labels[i].Caption := 'Object ID: ' + IntToStr(Obj.objtype);
Inc(i);
end;
if NPC.Name <> '' then
begin
Labels[i].Caption := 'NPC Name: ' + NPC.Name;
Labels[i+1].Caption := 'NPC Index: ' + IntToStr(NPC.Index);
i := i + 2;
end;
if GetArrayLength(TPA) > 0 then
begin
Labels[i].Caption := 'Ground Item: ' + IntToStr(TPA[0].x);
Inc(i);
end;
if i < 5 then
for i:=i to 5 do
Labels[i].Caption := '';
end;
Procedure DebugMinimap;
var
x, y, i: integer;
P, P2: TPoint;
begin
P := GetMyPos;
GetMousePos(x, y);
Labels[0].Caption := 'Player Tile: (' + IntToStr(P.x) + ', ' + IntToStr(P.y) + ')';
P2 := TileToMM(P);
Labels[1].Caption := 'Mouse Tile: (' + IntToStr(P.x - (P2.x - x)/4) + ', ' + IntToStr(P.y + (P2.y - y)/4) + ')';
Labels[2].Caption := 'Angle: ' + FloatToStr(GetMinimapAngleDeg);
for i:=3 to 5 do
Labels[i].Caption := '';
end;
Procedure Setup;
begin
SetupSRL;
SMARTSetupEx(80, False, True, False);
Wait(1000);
SetTargetDC(SmartGetDC);
SetupReflection;
end;
begin
Setup;
SafeInitForm;
SafeShowForm;
repeat
try
case GetMouseArea of
'': Clear;
'Reflection Debugger': Start;
'Main Screen': DebugMainScreen;
'Inventory': DebugInventory;
'Interface': DebugInterface;
'Minimap': DebugMinimap;
end;
except
end;
Wait(100);
until(false);
end.