def read(self, fd): self.fAngle = bytes_to_int(fd.read(4)) self.vRotation = Vector(bytes_to_float(fd.read(4)), bytes_to_float(fd.read(4)), bytes_to_float(fd.read(4))) self.vPos = Vector(bytes_to_float(fd.read(4)), bytes_to_float(fd.read(4)), bytes_to_float(fd.read(4))) self.vScale = Vector(bytes_to_float(fd.read(4)), bytes_to_float(fd.read(4)), bytes_to_float(fd.read(4))) self.dwObjType = bytes_to_unsigned_int(fd.read(4)) self.dwModelID = bytes_to_unsigned_int(fd.read(4)) self.dwMotion = bytes_to_unsigned_int(fd.read(4)) self.dwAIInterface = bytes_to_unsigned_int(fd.read(4)) self.dwaAI2 = bytes_to_unsigned_int(fd.read(4)) for i in range(0, 64): c = bytes_to_unsigned_int(fd.read(1)) self.name += str(c) fd.read(32) for i in range(0, 32): c = bytes_to_unsigned_int(fd.read(1)) self.characterKey += str(c) self.belligenre = bytes_to_unsigned_int(fd.read(4)) fd.read(4)
def __load_lnd_obj__(self, fd, world, y, x): obj_count = bytes_to_unsigned_int(fd.read(4)) for k in range(0, obj_count): dwTypeObj = bytes_to_unsigned_int(fd.read(4)) obj = Obj() if dwTypeObj == 2: obj = ObjCtrl() obj.read(fd) world.lands[y][x].objs.append(obj) sfx_count = bytes_to_unsigned_int(fd.read(4)) for k in range(0, sfx_count): dwTypeSfx = bytes_to_unsigned_int(fd.read(4)) sfx = Obj() sfx.read(fd) world.lands[y][x].sfxs.append(obj)
def __load_lnd__(self, fn, world, define): gLogger.info("loading:", fn) x = int(0) y = int(0) with open(fn, "rb") as fd: version = bytes_to_unsigned_int(fd.read(4)) if version <= 0: gLogger.error("version:", version, "is unknow") if version >= 1: y = bytes_to_unsigned_int(fd.read(4)) x = bytes_to_unsigned_int(fd.read(4)) self.__load_lnd_terrain__(fd, world, y, x) self.__load_lnd_water__(fd, world, y, x) if version >= 2: world.land_attributes = fd.read(WATER_AREA) # land attributes self.__load_lnd_layer__(fd, world, y, x) self.__load_lnd_obj__(fd, world, y, x)
def __load_lnd_layer__(self, fd, world, y, x): layerCount = bytes_to_unsigned_int(fd.read(1)) for j in range(0, layerCount): layer = Layer() layer.textureID = fd.read(2) layer.patchEnabled = fd.read(PATCH_ENABLED) layer.lightMap = fd.read(LIGHT_AREA) world.lands[y][x].layers.append(layer)
def read(self, fd): self.dwVersion = bytes_to_unsigned_int(fd.read(4)) if self.dwVersion == 2147483648: self.__read_ctrlelement__(fd) elif self.dwVersion == 2415919104: self.__read_ctrlelement_v2__(fd) else: self.dwSet = self.dwVersion self.__read_ctrlelement_v3__(fd)
def __read_ctrlelement__(self, fd): self.dwSet = bytes_to_unsigned_int(fd.read(4)) self.dwSetItem = bytes_to_unsigned_int(fd.read(4)) self.dwSetLevel = bytes_to_unsigned_int(fd.read(4)) self.dwSetQuestNum = bytes_to_unsigned_int(fd.read(4)) self.dwSetFlagNum = bytes_to_unsigned_int(fd.read(4)) self.dwSetGender = bytes_to_unsigned_int(fd.read(4)) self.bSetJob = fd.read(4 * MAX_JOB) self.dwSetEndu = bytes_to_unsigned_int(fd.read(4)) self.dwMinItemNum = bytes_to_unsigned_int(fd.read(4)) self.dwMaxiItemNum = bytes_to_unsigned_int(fd.read(4)) self.dwInsideItemKind = fd.read(4 * MAX_CTRLDROPITEM) self.dwInsideItemPer = fd.read(4 * MAX_CTRLDROPITEM) self.dwMonResKind = fd.read(4 * MAX_CTRLDROPMOB) self.dwMonResNum = fd.read(4 * MAX_CTRLDROPMOB) self.dwMonActAttack = fd.read(4 * MAX_CTRLDROPMOB) self.dwTrapOperType = bytes_to_unsigned_int(fd.read(4)) self.dwTrapRandomPer = bytes_to_unsigned_int(fd.read(4)) self.dwTrapDelay = bytes_to_unsigned_int(fd.read(4)) self.dwTrapKind = fd.read(4 * MAX_TRAP) self.dwTrapLevel = fd.read(4 * MAX_TRAP) self.strLinkCtrlKey = fd.read(MAX_KEY) self.strCtrlKey = fd.read(MAX_KEY) self.dwSetQuestNum1 = bytes_to_unsigned_int(fd.read(4)) self.dwSetFlagNum1 = bytes_to_unsigned_int(fd.read(4)) self.dwSetQuestNum2 = bytes_to_unsigned_int(fd.read(4)) self.dwSetFlagNum2 = bytes_to_unsigned_int(fd.read(4)) self.dwSetItemCount = bytes_to_unsigned_int(fd.read(4)) self.dwTeleWorldId = bytes_to_unsigned_int(fd.read(4)) self.vTele = Vector(bytes_to_unsigned_int(fd.read(4)), bytes_to_unsigned_int(fd.read(4)), bytes_to_unsigned_int(fd.read(4)))