SRL Archive - Devs' Corner

All RS Objects indexed -- split from items.simba


Cstrike

2010-11-30 13:54:09

One of the issues with making a whole array was the compiling issue. Compiling the true item database was a bit much… so some ideas batted around that seemed very feasible is a plugin. Only downside is noobs who don't know about moving plugins won't be able to use this feature.

I stumbled across reading .txt files, and spent all morning learning how to do it. If you want to test it, go update your reflection to the newest version, and you'll find a script in /Reflection/Development/Object_List/

Run it (its standalone, doesn't need SRL/SMART/Reflection to work!), and see how it outputs stuff.

Or you can try this (same code):
program ReflectionObjectFinder;

function R_FindObjectArray(ObjectName: String): TIntegerArray;
var FileInt, i: Integer;
FilePath, Data: String;
TSA: TStringArray;
begin
Result := [];
FilePath := AppPath+'Includes\Reflection\Development\Object_Files\Objects.txt';
FileInt := OpenFile(FilePath, true);
try
if not ReadFileString (FileInt, Data, FileSize(FileInt)) then
begin
Writeln ('[Reflection] Error in file while reading: "'+FilePath+'"');
Exit;
end;
except
Writeln ('[Reflection] File doesn''t exist at path: "'+FilePath+'"');
Exit;
end;
CloseFile(FileInt);
TSA := Explode(chr(10), Data);
for i:=0 to high(TSA) do
if (Pos(lowercase(ObjectName), lowercase(TSA[i]))) > 0 then
begin
Insert('&', TSA[i], 1);
SetArrayLength(Result, high(Result)+2);
Result[high(Result)] := StrToInt(Between('&', ':', TSA[i]));
end;
end;

begin
writeln(R_FindObjectArray('ank boot'));
end.

It can generate the list in 0.046 sec if I recall the number correctly. I tried 'ank boot' to get all the bank booths and it does. The code probably can be optimized a bit more, I didn't know how to work around Between(…), so I just injected my own letter at the start of each string and read the numbers between my injected character and the colon.

If this is a feasible idea, we can replace items.simba with the same idea (since Method got us a bigger items database, and objects.txt as well… thank you very much to him for this work). Next step if you guys like this idea is to make it go from name to integer, or integer to name for objects, and items. If we could get an NPC database we're set.


Advantages
Heres a quick example:

1) Grab all object names with the fragment 'bank booth'
2) With the TIA, search on screen for any valid bank booth object [interactable]
3) Open it

Not bad huh? UNIVERSAL BANKING! :stirthepot:



EDIT: If you want to put it to the test you can always search a blank string, it will harvest every item :)
EDIT2: If further developed, would have to customize pathname obviously to account for people who don't name their folder "Reflection"

pyroryan

2010-11-30 13:59:06

Very nice :)

Looks like our first option works :P

lordsaturn

2010-11-30 14:36:01

R_FindObjectArray? How about R_ID() or R_IDof()

Cstrike

2010-11-30 14:39:24

From: lordsaturn
R_FindObjectArray? How about R_ID() or R_IDof()


What parameters would you put inside of those?
Plus they might be a bit misleading as names ;)


The goal would be for us to have

R_FindObjectArray
R_FindNPCArray
R_FindItemArray

Coh3n

2010-11-30 15:50:56

From: cstrike
What parameters would you put inside of those?
Plus they might be a bit misleading as names ;)


The goal would be for us to have

R_FindObjectArray
R_FindNPCArray
R_FindItemArray

Should be R_GetNPCArray, GetItemArray, and GetObject array as it's actually getting the array of IDs. FindObjectArray would be to find one of the objects in the parameters on the MainScreen unless that's what you meant in the first place in which cast just ignore me. :p

Cstrike

2010-11-30 16:02:20

From: Coh3n
Should be R_GetNPCArray, GetItemArray, and GetObject array as it's actually getting the array of IDs. FindObjectArray would be to find one of the objects in the parameters on the MainScreen unless that's what you meant in the first place in which cast just ignore me. :p


I like those names better :)

BTW a new function can be modded to find if it's on the main screen easily, so far these just return all the items in all of Runescape that have the ID.

Coh3n

2010-11-30 16:06:47

From: cstrike
I like those names better :)

BTW a new function can be modded to find if it's on the main screen easily, so far these just return all the items in all of Runescape that have the ID.

Yeah that's what I thought and why I suggested 'Get' instead of 'Find'. :)

I like this. and it's even better that it generates the list in < 1ms. Any idea how long it would take for all the Normal Trees?

Cstrike

2010-11-30 16:09:32

From: Coh3n
Yeah that's what I thought and why I suggested 'Get' instead of 'Find'. :)

I like this. and it's even better that it generates the list in < 1ms. Any idea how long it would take for all the Normal Trees?


Do you have an account at the trees? I don't have one on me :( but I could test it right now.
Though I can test it later if you don't have access to one or don't feel like handing one over (which I can understand :) ). I'll get a compile time for you as well.

Coh3n

2010-11-30 16:19:06

From: cstrike
Do you have an account at the trees? I don't have one on me :( but I could test it right now.
Though I can test it later if you don't have access to one or don't feel like handing one over (which I can understand :) ). I'll get a compile time for you as well.

I meant how long it would take to just generate a ID list of all the trees in RS. You shouldn't need an account for that?

Nava2

2010-11-30 16:26:46

From: Coh3n
I meant how long it would take to just generate a ID list of all the trees in RS. You shouldn't need an account for that?


Haha.. You don't really understand what this is. :)

Its just a list of collected IDs. It wasn't read from the cache like the other.

Coh3n

2010-11-30 16:31:58

From: Nava2
Haha.. You don't really understand what this is. :)

Its just a list of collected IDs. It wasn't read from the cache like the other.

Yeah I know. He said in the first post he got all the IDs for all the BankBooths using what he posted. Couldn't you just do the same with 'Tree'?

pyroryan

2010-11-30 16:36:47

Method extracted this from the cache for us. So yes it is from the cache.

@Coh3n

8503:Yew tree
8504:Yew tree
8505:Yew tree
8506:Yew tree
8507:Yew tree
8508:Yew tree
8509:Yew tree
8510:Yew tree
8511:Yew tree
8512:Yew tree
8513:Yew tree
Suppose you could.

Cstrike

2010-11-30 16:39:54

From: Coh3n
I meant how long it would take to just generate a ID list of all the trees in RS. You shouldn't need an account for that?


Oh sorry, misread your post :) Thought you meant 'how long would it take to get every ID and then test all those ID's with the command GetObjectsById (AllIDshere), and then search the entire object array for which ID's are on the mainscreen' :)

Getting all the tree ID's in the game, of which has a high(); of 269, would take ~400 milliseconds to return all of them. It would take ~500 ms to get every tree (including maple/yew/logs or an AIO everything).

I'd need to structure it better, the only way I could look for the root word "tree" was searching ":tree".

Coh3n

2010-11-30 16:51:51

From: cstrike
I'd need to structure it better, the only way I could look for the root word "tree" was searching ":tree".

Cause if you used 'tree' it would return all other tree types as well I'm assuming?

You could add a boolean parameter to determine whether you want the exact text or all variations of it. That may work. So, if the boolean was true, 'ank boot' wouldn't work, but "Bank Booth" would.

Cstrike

2010-11-30 17:10:11

From: Coh3n
Cause if you used 'tree' it would return all other tree types as well I'm assuming?

You could add a boolean parameter to determine whether you want the exact text or all variations of it. That may work. So, if the boolean was true, 'ank boot' wouldn't work, but "Bank Booth" would.


This I want to do, though currently I'm unsure of how to do it :(
I'll have to research more into string grabbing (I just need a way to find when the string ends, one way I might do it is if pos(tree…) = x, and length from 'tree…' to the end is > x, then ignore it when that boolean you said is true).

lordsaturn

2010-11-30 19:31:50

Have you considered trying to do this with an .ini? Maybe you could compare efficiency between ini and txt.

Method

2010-11-30 19:37:52

From: Nava2
Haha.. You don't really understand what this is. :)

Its just a list of collected IDs. It wasn't read from the cache like the other.


As pyroryan mentioned, yes it was. However, that's not to say that this list is complete by any means. I haven't looked into how the client uses the settings array for grabbing the "parent" of particular objects and npcs, so it'll be missing those until I do.

Cstrike

2010-11-30 19:55:10

From: lordsaturn
Have you considered trying to do this with an .ini? Maybe you could compare efficiency between ini and txt.


If I just renamed it, would that be as good? Or would it need to be re-written like with the ReadINI…etc

Coh3n

2010-12-01 01:02:59

From: cstrike
If I just renamed it, would that be as good? Or would it need to be re-written like with the ReadINI…etc

Should probably redo it using the INI functions. Personally, I get runtime errors when working with .ini files for some reason. If I use ReadINI, WriteINI, etc to write a .txt file it seems to work really well though.

lordsaturn

2010-12-01 02:27:24

From: cstrike
If I just renamed it, would that be as good? Or would it need to be re-written like with the ReadINI…etc


I would recommend loading the ids in through the txt file, then writing them to the ini. Because it would be difficult to do it manually. INI files are structured differently, looks kind of like an xml file when done correctly with different subsections and stuff.

After all that, use readini to load it up and track the time it takes to load.

Cstrike

2010-12-01 11:03:12

Is there an INI converter that can do it cheap and quick for me? And will there be a noticeable compile time difference do you think [can you still view these forums even? lol]