Jump to content

PY - Check and optimalize the client's NPC and MOBS


Recommended Posts

I've brought you some files for optimizing your client. The first file examines whether there are any entities in the mob_proto that are missing from the npclist.txt. These entities might remain unseen in your client, making them invisible to you.

The second file is designed to purge the missing entries from the mob_proto. This step will help clean up and enhance the efficiency of your client.

The third program's purpose is to inspect the unpacked version of your client and identify any NPCs or creatures that are not listed in your npclist. You have the option to manually remove these entities and then repackage your client.

By implementing these optimizations, you can effectively rid your client of unnecessary elements. These entities won't burden your client's memory during startup, potentially resulting in significant RAM savings.

Missing_ids.py
 

Quote

def read_ids_from_file(filename, encoding='utf-8'):
    ids = set()
    with open(filename, 'r', encoding=encoding) as file:
        for line in file:
            line = line.strip()
            if line:
                ids.add(line.split()[0])
    return ids

def main():
    a_ids = read_ids_from_file('npclist.txt', encoding='utf-8')
    b_ids = read_ids_from_file('mob_proto.txt', encoding='utf-8')

    if '0' in a_ids:
        a_ids.remove('0')

    missing_ids = a_ids - b_ids

    with open('npclist_modified.txt', 'w', encoding='utf-8') as output_file:
        with open('npclist.txt', 'r', encoding='utf-8') as input_file:
            for line in input_file:
                line = line.strip()
                if not line:  # Üres sorok kihagyása
                    continue

                line_id = line.split()[0]
                if line_id not in missing_ids:
                    output_file.write(line + '\n')

    print(f"Modified 'npclist.txt' written to 'npclist_modified.txt'.")

if __name__ == "__main__":
    main()

mob_proto_delete.py
 

Quote

def read_ids_from_file(filename, encoding='utf-8'):
    ids = set()
    with open(filename, 'r', encoding=encoding) as file:
        for line in file:
            line = line.strip()
            if line:
                ids.add(line.split()[0])
    return ids

def main():
    a_ids = read_ids_from_file('mob_proto.txt', encoding='utf-8')
    b_ids = read_ids_from_file('npclist.txt', encoding='utf-8')

    missing_ids = a_ids - b_ids

    with open('mob_proto_modified.txt', 'w', encoding='utf-8') as output_file:
        with open('mob_proto.txt', 'r', encoding='utf-8') as input_file:
            for line in input_file:
                line = line.strip()
                if not line:  # Üres sorok kihagyása
                    continue

                line_id = line.split()[0]
                if line_id not in missing_ids:
                    output_file.write(line + '\n')

    print(f"Modified 'mob_proto.txt' written to 'mob_proto_modified.txt'.")

if __name__ == "__main__":
    main()

show_folders_need_to_delete.py
 

Quote

import os

def get_missing_folders(root_folder, existing_folders):
    missing_folders = []
    
    for root, _, _ in os.walk(root_folder):
        root_parts = root.split(os.path.sep)
        if any(folder in ["npc", "npc2", "npc_mount", "npc_pet", "monster", "monster2"] for folder in root_parts):
            for folder in ["npc", "npc2", "npc_mount", "npc_pet", "monster", "monster2"]:
                folder_path = os.path.join(root, folder)
                if os.path.exists(folder_path):
                    subfolders = [subfolder for subfolder in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, subfolder))]
                    for subfolder in subfolders:
                        if subfolder not in existing_folders:
                            missing_folders.append(os.path.join(folder_path, subfolder))

    return missing_folders

def main():
    root_folder = 'D:/Luigina/luigina.client/data'
    npclist_file = 'npclist.txt'

    existing_folders = set()

    with open(npclist_file, 'r', encoding='utf-8') as file:
        for line in file:
            line = line.strip()
            if line:
                parts = line.split('\t')
                if len(parts) == 2 and parts[0] != '0':
                    _, folder_name = parts
                    existing_folders.add(folder_name)

    missing_folders = get_missing_folders(root_folder, existing_folders)

    with open('missing_folders.txt', 'w', encoding='utf-8') as output_file:
        for folder in missing_folders:
            output_file.write(folder + '\n')

    print(f"{len(missing_folders)} missing folders written to 'missing_folders.txt'.")

if __name__ == "__main__":
    main()
 

show_missing_ids.py

Quote

def read_ids_from_file(filename, encoding='utf-8'):
    ids = set()
    with open(filename, 'r', encoding=encoding) as file:
        for line in file:
            line = line.strip()
            if line:
                ids.add(line.split()[0])
    return ids

def main():
    a_ids = read_ids_from_file('mob_proto.txt', encoding='utf-8')
    b_ids = read_ids_from_file('npclist.txt', encoding='utf-8')

    missing_ids = a_ids - b_ids

    with open('missing_ids.txt', 'w') as output_file:
        for id in missing_ids:
            output_file.write(id + '\n')

    print(f"{len(missing_ids)} missing IDs written to 'missing_ids.txt'.")

if __name__ == "__main__":
    main()
 

 

  • Metin2 Dev 3
  • Love 2
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.