Ejemplo n.º 1
0
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.items_1 = read_list(reader, Packet4Struct1)
        self.player_hits = read_list(reader, HitPacket)

        self.items_3 = []
        for _ in xrange(reader.read_uint32()):
            self.items_3.append(reader.read(72))

        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)

        self.items_6 = []
        for _ in xrange(reader.read_uint32()):
            self.items_6.append(reader.read(88))

        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        self.items_12 = []
        for _ in xrange(reader.read_uint32()):
            self.items_12.append(reader.read(40))

        # objective/quests? not sure
        self.items_13 = read_list(reader, Item13)

        debug = True
        if debug:
            v = vars(self).copy()
            del v['pickups']
            # del v['kill_actions']
            del v['damage_actions']
            del v['sound_actions']
            del v['shoot_actions']
            # del v['player_hits']
            del v['chunk_items']
            for k, v in v.iteritems():
                if not v:
                    continue
                print k, v

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
Ejemplo n.º 2
0
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.items_1 = read_list(reader, Packet4Struct1)
        self.player_hits = read_list(reader, HitPacket)

        self.items_3 = []
        for _ in xrange(reader.read_uint32()):
            self.items_3.append(reader.read(72))

        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)

        self.items_6 = []
        for _ in xrange(reader.read_uint32()):
            self.items_6.append(reader.read(88))

        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        self.items_12 = []
        for _ in xrange(reader.read_uint32()):
            self.items_12.append(reader.read(40))

        # objective/quests? not sure
        self.missions = read_list(reader, MissionData)

        debug = True
        if debug:
            v = vars(self).copy()
            del v['pickups']
            # del v['kill_actions']
            del v['damage_actions']
            del v['sound_actions']
            del v['shoot_actions']
            # del v['player_hits']
            del v['chunk_items']
            for k, v in v.iteritems():
                if not v:
                    continue
                print k, v

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
Ejemplo n.º 3
0
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.items_1 = read_list(reader, Packet4Struct1)
        self.player_hits = read_list(reader, HitPacket)
        self.particles = read_list(reader, ParticleData)
        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)
        self.static_entities = read_list(reader, StaticEntityData)
        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in xrange(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in xrange(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        self.items_12 = []
        for _ in xrange(reader.read_uint32()):
            self.items_12.append(reader.read(40))

        # objective/quests? not sure
        self.missions = read_list(reader, MissionData)

        debug = False
        if debug:
            v = vars(self).copy()
            # del v['kill_actions']
            # del v['player_hits']
            del v["pickups"]
            del v["damage_actions"]
            del v["sound_actions"]
            del v["shoot_actions"]
            del v["chunk_items"]
            for k, v in v.iteritems():
                if not v:
                    continue
                print k, v

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
Ejemplo n.º 4
0
def convert_qmo(path):
    data = ByteReader(open(path, 'rb').read())

    qmo_file = QubicleFile()
    qmo_model = QubicleModel()
    x_size, y_size, z_size = 256, 256, 256
    qmo_model.x_size = x_size
    qmo_model.y_size = y_size
    qmo_model.z_size = z_size
    qmo_model.x_offset = -x_size / 2
    qmo_model.y_offset = 0
    qmo_model.z_offset = -z_size / 2

    min_z = None
    max_z = None

    for i in xrange(256*256):
        something = data.read_float()
        something2 = data.read_float()
        something3 = data.read_float()
        something4 = data.read_uint32()
        something5 = data.read_uint32()
        size = data.read_uint32()*4
        chunk_data = data.read(size)

        x = i % 256
        y = i / 256

        z = something4

        if min_z is None or max_z is None:
            min_z = z
            max_z = z + len(chunk_data) / 4
        else:
            min_z = min(z, min_z)
            max_z = max(max_z, len(chunk_data) / 4)

        for i in xrange(len(chunk_data) / 4):
            r = ord(chunk_data[i*4])
            g = ord(chunk_data[i*4+1])
            b = ord(chunk_data[i*4+2])
            a = ord(chunk_data[i*4+3])
            if a == 0:
                z += 1
                continue
            qmo_model.blocks[switch_axes(x, y, z)] = (r, g, b)
            z += 1

    qmo_model.y_offset

    qmo_file.models.append(qmo_model)
    writer = ByteWriter()
    qmo_file.write(writer)
    name = os.path.splitext(os.path.basename(path))[0]
    out_path = os.path.join('genqmo', name + '.qmo')
    open(out_path, 'wb').write(writer.get())

    print 'Converted', path
Ejemplo n.º 5
0
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.block_actions = read_list(reader, BlockAction)
        self.player_hits = read_list(reader, HitPacket)
        self.particles = read_list(reader, ParticleData)
        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)
        self.static_entities = read_list(reader, StaticEntityPacket)
        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in range(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in range(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        # EXT: used when NPC wizards/creatures use a right-click targeted
        # action such as a spell cast. (NPC rclick action?)
        self.passive_actions = read_list(reader, PassivePacket)

        self.missions = read_list(reader, MissionData)

        debug = False
        if debug:
            v = vars(self).copy()
            # del v['kill_actions']
            # del v['player_hits']
            del v['pickups']
            del v['damage_actions']
            del v['sound_actions']
            del v['shoot_actions']
            del v['chunk_items']
            for k, v in v.items():
                if not v:
                    continue
                print(k, v)

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()
Ejemplo n.º 6
0
    def read(self, reader):
        size = reader.read_uint32()
        decompressed_data = zlib.decompress(reader.read(size))
        reader = ByteReader(decompressed_data)

        self.block_actions = read_list(reader, BlockAction)
        self.player_hits = read_list(reader, HitPacket)
        self.particles = read_list(reader, ParticleData)
        self.sound_actions = read_list(reader, SoundAction)
        self.shoot_actions = read_list(reader, ShootPacket)
        self.static_entities = read_list(reader, StaticEntityPacket)
        self.chunk_items = read_list(reader, ChunkItems)

        self.items_8 = []
        for _ in range(reader.read_uint32()):
            something = reader.read_uint64()
            sub_items = []
            for _ in range(reader.read_uint32()):
                sub_items.append(reader.read(16))
            self.items_8.append((something, sub_items))

        self.pickups = read_list(reader, PickupAction)
        self.kill_actions = read_list(reader, KillAction)
        self.damage_actions = read_list(reader, DamageAction)

        # EXT: used when NPC wizards/creatures use a right-click targeted
        # action such as a spell cast. (NPC rclick action?)
        self.passive_actions = read_list(reader, PassivePacket)

        self.missions = read_list(reader, MissionPacket)

        debug = False
        if debug:
            v = vars(self).copy()
            # del v['kill_actions']
            # del v['player_hits']
            del v['pickups']
            del v['damage_actions']
            del v['sound_actions']
            del v['shoot_actions']
            del v['chunk_items']
            for k, v in v.items():
                if not v:
                    continue
                print(k, v)

        if len(decompressed_data) != reader.tell():
            raise NotImplementedError()