PDA

View Full Version : [Utility] [Reflection] Item,Npc, and Object Id getter



bran_corn
02-17-2016, 02:58 AM
Ok so I wrote my first script, it fetches the IDs of the npcs, objects, and items on your screen and labels them.
I wrote this since I was finding it a pain to get the ids manually and a lot of the time the id's and the names didn't match up. I know the code isn't super elegant. I'd love to hear feedback!

Note that if there are too many objects around you can just comment out the functions that labels them.


// 2016 Bran_corn @villavu.com
//use this script to get ids ect



program new;
{$DEFINE SMART}
{$i aerolib\aerolib.simba }
{$i reflection/reflection.Simba}
{$I SRL-OSR\SRL\utilities\drawing.simba}

procedure PrintNpcIdToScreen();
var
Npcs :TReflectNPCArray ;
i: integer;
ScreenCoord : TPoint;
begin

WriteLn('----------------------------------------------------------');
WriteLn('labelling npcs...');
Npcs.GetAll;
for i:= 0 to high(Npcs) do begin
ScreenCoord := Npcs[i].GetMsPoint;//TReflectionTiles.TileToMS(Npcs[i].GetTile);

if (((ScreenCoord.X > 50) and (ScreenCoord.X < 550)) and ((ScreenCoord.Y > 50) and (ScreenCoord.Y < 350))) then begin
WriteLn('');
WriteLn(Npcs[i].GetName);
WriteLn(Npcs[i].Getid );
OS_SMART.graphics().drawCircle(ScreenCoord,3,clred , True);
OS_SMART.graphics().DrawClippedText(Npcs[i].GetName+' ' +InttoStr(Npcs[i].Getid) ,statChars,ScreenCoord);
end;
end;
end;


procedure PrintItemIdToScreen();
var
Items :TReflectGroundItemArray ;
Item :TReflectGroundItem;
i: integer;
ScreenCoord : TPoint;
begin
WriteLn('----------------------------------------------------------');
WriteLn('labelling items...');
Items.GetAll;
for i:= 0 to high(Items) do begin
Item:= Items[i];
ScreenCoord := Item.GetMsPoint;//TReflectionTiles.TileToMS(Npcs[i].GetTile);
//WriteLn(ScreenCoord);
if (((ScreenCoord.X > 50) and (ScreenCoord.X < 550)) and ((ScreenCoord.Y > 50) and (ScreenCoord.Y < 350))) then begin
WriteLn('');
WriteLn(Item.GetName);
WriteLn(Item.Getid );
OS_SMART.graphics().drawCircle(ScreenCoord,3,clblu e, True);
OS_SMART.graphics().DrawClippedText(Item.GetName +' ' +InttoStr(Item.Getid) ,statChars,ScreenCoord,clblue);
end;
end;
end;

procedure PrintObjectIdToScreen();
var
myObjects :TReflectObjectArray ;
myObject :TReflectObject;
i: integer;
ScreenCoord : TPoint;
begin
WriteLn('----------------------------------------------------------');
WriteLn('labelling objects...');
myObjects.GetAll(ObjGame,30) ;
for i:= 0 to high(myObjects) do begin
myObject:= myObjects[i];
ScreenCoord := myObject.GetMsPoint;//TReflectionTiles.TileToMS(Npcs[i].GetTile);
if (((ScreenCoord.X > 50) and (ScreenCoord.X < 550)) and ((ScreenCoord.Y > 50) and (ScreenCoord.Y < 350))) then begin
WriteLn('');
WriteLn(myObject.GetName);
WriteLn(myObject.GetId );
OS_SMART.graphics().drawCircle(ScreenCoord,3,clpur ple, True);
OS_SMART.graphics().DrawClippedText(myObject.GetNa me +' ' + inttostr(myObject.Getid ),statChars,ScreenCoord,clpurple);
end;
end;
end;

procedure setup();
begin
setDefaultZoom;
end;

begin
initAL();
Reflect.Setup;
setup;
While True do begin
OS_SMART.graphics().Clear;
ClearDebug;
PrintNpcIdToScreen;
PrintItemIdToScreen ;
PrintObjectIdToScreen ;
Wait(10000);
end;
end.

Laquisha
02-17-2016, 03:08 AM
This is definitely something that is missing from the reflection include and should have been added a long time ago.

Something like:


Reflect.Smart.Graphics.DebugModels();
//or preferably
Reflect.Smart.Graphics.Debug(Models); //Items, Objects etc..


would be really useful as this is a time consuming part of writing a script. mudda_fudda; Kyle; you down?

Bulbasaur
02-17-2016, 06:37 PM
Very useful. thank you :)

Hoodz
02-17-2016, 06:53 PM
I dont this will work correctly when there are multiple objects/npcs/grounditems on one tile

bran_corn
02-21-2016, 11:36 PM
Went on a trip for the last few days, back around now.


Very useful. thank you :)
Did you run it? Did it work find on your computer? (curious to make sure it works fine on other peoples' systems!)


I dont this will work correctly when there are multiple objects/npcs/grounditems on one tile
Good point, I'll have to investigate what it does in those cases. When I wrote it the other night I was getting all round items as id=1 and name ="toolkit" due to reflection being out of date so I'll poke around and try and find a good way to display everything!

hakishakataki
03-17-2016, 09:12 PM
I'm grabbing this error

Error: File "SRL-OSR\SRL\utilities\drawing.simba" not found at line 10

guerr
03-20-2016, 07:13 PM
Awsome, i will be getting info reflection soon, this will be useful to me, thanks a bunch,