mejrs.github.io
mejrs.github.io copied to clipboard
Export Coords
My apologies for listing this under issues, but is there any way to export the coords of any specific monster for an offline project?
All the data is here:
https://github.com/mejrs/data_rs3 (note that the npc data is rather out of date).
The files/folders of interest are the npcids folder, npc_morph_collection and npc_name_collection.
You can use a script like
import concurrent.futures, urllib.request, json, itertools
GAME = "rs3" # or "osrs"
def load_url(url, timeout = 10000):
with urllib.request.urlopen(url, timeout=timeout) as conn:
return json.loads(conn.read())
def load_location(id, timeout = 10000):
try:
with urllib.request.urlopen(f"https://mejrs.github.io/data_{GAME}/npcids/npcid={id}.json", timeout=timeout) as conn:
return json.loads(conn.read())
except urllib.error.HTTPError as e:
return []
def get_positions_names(names):
name_mapping = load_url(f"https://mejrs.github.io/data_{GAME}/npc_name_collection.json")
ids = itertools.chain(*(name_mapping[name] for name in names if name in name_mapping))
return get_positions_ids(ids)
def get_positions_ids(ids):
morph_mapping = load_url(f"https://mejrs.github.io/data_{GAME}/npc_morph_collection.json")
all_ids = itertools.chain(*(morph_mapping.get(id, []) + [id] for id in ids))
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
results = executor.map(load_location, all_ids)
return itertools.chain(*results)
if __name__ == "__main__":
data = get_positions_names(["Man"])
print(list(data))
to print/process the data