Metin2 Python Loader -
def get_skill(self, vnum: int) -> Optional[SkillInfo]: """Get skill by virtual number""" return self.database.skills.get(vnum)
class GameRegion(Enum): """Game region constants""" GLOBAL = "global" KOREA = "korea" JAPAN = "japan" CHINA = "china" TURKEY = "turkey" Archive Loader ============================================ class Metin2Archive: """Loader for Metin2 archive files (.epk, .pak, etc.)""" metin2 python loader
EPK_HEADER = b'EPK\x01' PAK_HEADER = b'PAK\x00' vnum: int) ->
def load_skills(self) -> Dict[int, SkillInfo]: """Load skill_proto database""" possible_paths = [ 'data/skill_proto', 'db/skill_proto', 'skill_proto.txt' ] for path in possible_paths: data = self.archive.read_file(path) if data: self._parse_skills(data) break return self.skills pak_path) elif header == self.EPK_HEADER: self._parse_epk(f
def __init__(self, game_path: str): self.game_path = Path(game_path) self.pak_files = [] self.file_index = {} def load_archives(self) -> bool: """Load all archive files from game directory""" try: # Find all archive files for ext in ['*.pak', '*.epk']: self.pak_files.extend(self.game_path.rglob(ext)) # Index files for pak_file in self.pak_files: self._index_pak_file(pak_file) print(f"Loaded {len(self.pak_files)} archives with {len(self.file_index)} files") return True except Exception as e: print(f"Error loading archives: {e}") return False
def _index_pak_file(self, pak_path: Path): """Index files inside a PAK archive""" try: with open(pak_path, 'rb') as f: # Read header header = f.read(4) if header == self.PAK_HEADER: self._parse_pak(f, pak_path) elif header == self.EPK_HEADER: self._parse_epk(f, pak_path) except Exception as e: print(f"Error indexing {pak_path}: {e}")
def get_mob(self, vnum: int) -> Optional[MobInfo]: """Get monster by virtual number""" return self.database.mobs.get(vnum)