def readTitletool(file): data = [] with open(file, "rb") as f: br = BinaryReader(f) dataCount = br.ReadInt() for i in range(dataCount): data.append({ "id": br.ReadInt(), "enable": br.ByteToInt(br.ReadByte()), "effect": { "normal": br.ReadBytesToString(64, 'latin1'), "attack": br.ReadBytesToString(64, 'latin1'), "damage": br.ReadBytesToString(64, 'latin1') }, "color": { "text": "{:08x}".format(br.ReadInt()), "background": "{:08x}".format(br.ReadInt()), }, "option": { "id": br.ReadIntToList(5), "level": [ br.ByteToInt(br.ReadByte()), br.ByteToInt(br.ReadByte()), br.ByteToInt(br.ReadByte()), br.ByteToInt(br.ReadByte()), br.ByteToInt(br.ReadByte()) ] }, "itemId": br.ReadInt() }) return data
def readShop(file): data = [] with open(file, "rb") as f: br = BinaryReader(f) dataCount = br.ReadInt() for i in range(dataCount): id = br.ReadInt() shopName = br.ReadBytesToString(br.ReadInt(), 'latin1') sellRate = br.ReadInt() buyRate = br.ReadInt() itemCount = br.ReadInt() sellItems = br.ReadIntToList(itemCount) data.append({ "npcId": id, "shopName": shopName, "rate": { "sell": sellRate, "buy": buyRate }, "itemCount": itemCount, "items": sellItems }) if dataCount == id: break return data
def readSMC(file): data = [] with open(file, "rb") as f: br = BinaryReader(f) dataCount = br.ReadInt() for i in range(dataCount): id = br.ReadInt() if id != 0: meshClass = br.ReadBytesToString(br.ReadInt16(), 'latin1') meshSize = br.ReadInt() meshData = [] for j in range(meshSize): meshNum = br.ReadInt() meshTFNM = br.ReadBytesToString(br.ReadInt16(), 'latin1') texSize = br.ReadInt() meshData.append({ "meshNum": meshNum, "meshPath": meshTFNM, }) texData = [] for k in range(texSize): textureName = br.ReadBytesToString( br.ReadInt16(), 'latin1') texturePath = br.ReadBytesToString( br.ReadInt16(), 'latin1') texData.append({ "texName": textureName, "texPath": texturePath, }) data.append({ "id": id - 1, "model": { "modelName": meshClass, "mesh": meshData, "texture": texData } }) return data
def readZoneData(file): DEF_EXTRA_MAX = 30 data = [] with open(file, "rb") as f: br = BinaryReader(f) zoneCount = br.ReadInt() zoneInfoChunk = [] for i in range(zoneCount): zoneType = br.ReadInt() extraCnt = br.ReadInt() nString = br.ReadInt() wldFileName = br.ReadBytesToString(128, 'latin1') texName1 = br.ReadBytesToString(64, 'latin1') texName2 = br.ReadBytesToString(64, 'latin1') fLoadingStep = br.ReadFloat() fTer_Lodmul = br.ReadFloat() zoneInfoChunk.append({ "zoneType": zoneType, "extraCnt": extraCnt, "nString": nString, "wldFileName": wldFileName, "texture": { "texName1": texName1, "texName2": texName2 }, "loadingStep": fLoadingStep, "terLodmul": fTer_Lodmul }) nExtraCnt = br.ReadInt() zoneExtraChunk = [] for i in range(nExtraCnt): zoneExtraChunk.append(br.ReadIntToList(DEF_EXTRA_MAX)) data.append({"zoneData": zoneInfoChunk, "zoneExtra": zoneExtraChunk}) return data
def readStr(file, fileType, encoding, gamigo, simple): data = [] with open(file, "rb") as f: br = BinaryReader(f) dataCount, dataMax = br.ReadInt() - 1, br.ReadInt() fileTypeLower = fileType.lower() descCount = 1 emptyDescFiles = [ 'strclient', 'straffinity', 'strcombo', 'strrareoption', 'strsetitem', 'stroption' ] if 'strskill' in fileTypeLower: descCount = 2 elif 'strquest' in fileTypeLower: descCount = 3 elif fileTypeLower in emptyDescFiles: descCount = 0 for i in range(dataCount): if br.pos() >= br.size(): break id = br.ReadInt() name = br.ReadString(encoding) desc = [] for j in range(descCount): desc.append(br.ReadString(encoding)) if 'stritem' in fileTypeLower and gamigo: unknown0 = br.ReadInt() unknown1 = br.ReadBytesToString( unknown0, encoding) if unknown0 else 'False' if not simple: chunk = {"id": id, "name": name} if descCount: chunk["description"] = desc else: chunk = [] chunk.append(id) chunk.append(name) if descCount: chunk.append(desc) data.append(chunk) return data
def readAnimation(file): data = [] with open(file, "rb") as f: br = BinaryReader(f) magic = br.ReadBytesToString(4, 'latin1') version = br.ReadInt() animCount = br.ReadInt() for i in range(animCount): skaPath = br.ReadBytesToString(br.ReadInt(), 'latin1') animName = br.ReadBytesToString(br.ReadInt(), 'latin1') fps = br.ReadFloat() numberOfFrames = br.ReadInt() threshold = br.ReadInt() isCompressed = True if br.ReadInt() else False customSpeed = br.ReadInt() bones = [] boneCount = br.ReadInt() for j in range(boneCount): boneName = br.ReadBytesToString(br.ReadInt(), 'latin1') defaultPosition = br.ReadFloatToList(12) positions = [] positionCount = br.ReadInt() for k in range(positionCount): positions.append({ "frame": br.ReadInt16(), "flags": br.ReadInt16(), "position": { "x": br.ReadFloat(), "y": br.ReadFloat(), "z": br.ReadFloat() } }) rotations = [] rotationCount = br.ReadInt() for k in range(rotationCount): rotations.append({ "frame": br.ReadInt16(), "flags": br.ReadInt16(), "position": { "w": br.ReadFloat(), "x": br.ReadFloat(), "y": br.ReadFloat(), "z": br.ReadFloat() } }) offsetLen = br.ReadFloat() bones.append({ "boneName": boneName, "defaultPosition": defaultPosition, # matrix12 "positions": positions, "rotations": rotations, "offsetLen": offsetLen }) data.append({ "skaPath": skaPath, "name": animName, "fps": fps, "frameCount": numberOfFrames, "threshold": threshold, "isCompressed": isCompressed, "customSpeed": customSpeed, "bones": bones, "morphCount": br.ReadInt() }) return {"magic": magic, "version": version, "animations": data}
def readMob(file): DEF_SMC_LENGTH = 128 DEF_ANI_LENGTH = 64 data = [] with open(file, "rb") as f: br = BinaryReader(f) dataCount = br.ReadInt() for i in range(dataCount): data.append({ "npcId": br.ReadInt(), "level": br.ReadInt(), "health": br.ReadInt(), "mana": br.ReadInt(), "flag": br.ReadInt(), "flag1": br.ReadInt(), "speed": { "attack": br.ReadInt(), "walk": br.ReadFloat(), "run": br.ReadFloat(), }, "scale": br.ReadFloat(), "attackArea": br.ReadFloat(), "size": br.ReadFloat(), "master": { "skill": br.ByteToInt(br.ReadByte()), "specialSkill": br.ByteToInt(br.ReadByte()) }, "skillEffect": br.ReadIntToList(5), "attackType": br.ByteToInt(br.ReadByte()), "fire": { "delayCount": br.ByteToInt(br.ReadByte()), "delay": br.ReadFloatToList(4), "object": br.ByteToInt(br.ReadByte()), "speed": br.ReadFloat() }, "skill": { "skill0": [br.ReadInt(), br.ByteToInt(br.ReadByte())], "skill1": [br.ReadInt(), br.ByteToInt(br.ReadByte())] }, "rvr": { "grade": br.ReadInt(), "value": br.ReadInt() }, "bound": br.ReadFloat(), "model": { "smc": br.ReadBytesToString(DEF_SMC_LENGTH, 'latin1'), "animation": { "idle": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "walk": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "damage": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "attack": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "die": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "run": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "idle2": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "attack2": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), }, }, "fireEffect": { "0": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "1": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1'), "2": br.ReadBytesToString(DEF_ANI_LENGTH, 'latin1') } }) return data
def readItem(file, isGamigo): MAX_MAKE_ITEM_MATERIAL = 10 DEF_SMC_DEFAULT_LENGTH = 64 DEF_MAX_ORIGIN_OPTION = 10 DEF_EFFECT_DEFAULT_LENGTH = 32 data = [] with open(file, "rb") as f: br = BinaryReader(f) dataCount = br.ReadInt() for i in range(dataCount): data.append({ "itemId": br.ReadInt(), "jobFlag": br.ReadInt(), "stack": br.ReadInt(), "fame/maxuse": br.ReadInt(), "level": br.ReadInt(), "flag": br.ReadInt64(), "wearing": br.ReadInt(), "type": br.ReadInt(), "subtype": br.ReadInt(), "crafting": { "needItemId": br.ReadIntToList(MAX_MAKE_ITEM_MATERIAL), "needItemCount": br.ReadIntToList(MAX_MAKE_ITEM_MATERIAL) }, "specialSkill": { "needSpecialSkill1": br.ReadIntToList(2), "needSpecialSkill2": br.ReadIntToList(2), }, "iconPosition": br.ReadIntToList(3), "num": br.ReadIntToList(4), "price": br.ReadInt(), "set": br.ReadIntToList(7 if isGamigo else 5), "smc": br.ReadBytesToString(DEF_SMC_DEFAULT_LENGTH, 'latin1'), "effect": { "normal": br.ReadBytesToString(DEF_EFFECT_DEFAULT_LENGTH, 'latin1'), "attack": br.ReadBytesToString(DEF_EFFECT_DEFAULT_LENGTH, 'latin1'), "damage": br.ReadBytesToString(DEF_EFFECT_DEFAULT_LENGTH, 'latin1') }, "rareOption": { "id": br.ReadInt(), "chance": br.ReadInt(), "optionIds": br.ReadIntToList(DEF_MAX_ORIGIN_OPTION), "optionLevels": br.ReadIntToList(DEF_MAX_ORIGIN_OPTION) }, "rvr": { "type": br.ReadInt(), "grade": br.ReadInt() }, "fortuneId": br.ByteToInt(br.ReadByte()), "castleWar": br.ReadInt() }) return data
def readBigpet(file): DEF_APET_NAME_LENGTH = 20 DEF_SMCFILE_LENGTH = 64 DEF_APET_ANI_LENGTH = 32 DEF_MAX_EVOLUTION = 4 data = [] with open(file, "rb") as f: br = BinaryReader(f) dataCount = br.ReadInt() for i in range(dataCount): id = br.ReadInt() name = br.ReadBytesToString(DEF_APET_NAME_LENGTH, 'latin-1') type = br.ReadInt() itemId = br.ReadInt() aiSlot = br.ReadInt() mount = br.ReadIntToList(2) summonSkill = br.ReadIntToList(2) flag = br.ReadInt() smc = [ br.ReadBytesToString(DEF_SMCFILE_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_SMCFILE_LENGTH, 'latin-1') ] idle1 = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] idle2 = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] attack1 = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] attack2 = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] damage = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] die = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] walk = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] run = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] levelup = [ br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1'), br.ReadBytesToString(DEF_APET_ANI_LENGTH, 'latin-1') ] apetEvolutionData = [] for j in range(DEF_MAX_EVOLUTION): apetEvolutionData.append({ "level": br.ReadInt(), "stamina": br.ReadInt(), "faith": br.ReadInt(), "evPetId": br.ReadInt() }) data.append({ "id": id, "name": name, "type": type, "itemId": itemId, "aiSlot": aiSlot, "mount": mount, "summonSkill": summonSkill, "flag": flag, "model": { "smc": smc, "animation": { "idle1": idle1, "idle2": idle2, "attack1": attack1, "attack2": attack2, "damage": damage, "die": die, "walk": walk, "run": run, "levelup": levelup } }, "evolutionData": apetEvolutionData, # DEF_MAX_ACCEXP = 1 "accExpData": { "maxAccParam1": br.ReadInt(), "maxAccParam2": br.ReadInt(), "accRateParam1": br.ReadInt(), "accRateParam2": br.ReadInt() } }) return data