Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Coords #2

Open
tyronehoare opened this issue Jun 19, 2022 · 1 comment
Open

Export Coords #2

tyronehoare opened this issue Jun 19, 2022 · 1 comment

Comments

@tyronehoare
Copy link

My apologies for listing this under issues, but is there any way to export the coords of any specific monster for an offline project?

@mejrs
Copy link
Owner

mejrs commented Jun 19, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants