('unit_width', 'H', 12580), # 13036 ('unit_height', 'H', 13036), # 13492 ('sprite_selw', 'H', 13492), # 13948 ('sprite_selh', 'H', 13948), # 14404 ('sprite_portrait', 'H', 14404), # 14860 ('build_minerals', 'H', 14860), # 15316 ('build_gas', 'H', 15316), # 15772 ('build_time', 'H', 15772), # 16228 ('unit_restricts', 'H', 16228), # 16684 ('unit_team', 'B', 16684), # 16912 ('food_provided', 'B', 16912), # 17140 ('food_required', 'B', 17140), # 17368 ('space_required', 'B', 17368), # 17596 ('space_provided', 'B', 17596), # 17824 ('score_produce', 'H', 17824), # 18280 ('score_destroy', 'H', 18280), # 19192 ('unit_game', 'B', 19192), # 19420 ('unit_available', 'H', 19420), # 19876 ] # unknown 5 import tbl t = tbl.read(open("stat_txt.tbl")) dat = open('units.dat') units = [UnitType(number, field) for number, field in enumerate(zip(*map(readitem, fields)))] for i, x in enumerate(units): print i, x.name.ljust(50), x.myunknown_1
import struct import tbl t = tbl.read("data/broodat.mpq/arr/images.tbl") for i in range(520): x = i sp = open("data/broodat.mpq/arr/sprites.dat") sp.seek(x * 2) x = struct.unpack("<H", sp.read(2))[0] sp = open("data/broodat.mpq/arr/images.dat") sp.seek(x * 4) x = struct.unpack("<I", sp.read(4))[0] x = t[x - 1] x = x.replace("\\", "/").lower() x = '/'.join(x.split("/")[2:]) if x: print " %i: \"%s\"," % (i, x)
import struct import sys import tbl t = tbl.read("data/broodat.mpq/arr/images.tbl") sp = open("data/broodat.mpq/arr/images.dat") def main(self, file): file = open(file) image = struct.unpack("<517H", file.read(517*2)) length = (-1,)*130 + struct.unpack("<387B", file.read(387*1)) unk1 = struct.unpack("<517B", file.read(517*1)) unk2 = struct.unpack("<517B", file.read(517*1)) circ = (-1,)*130 + struct.unpack("<387B", file.read(387*1)) vert = (-1,)*130 + struct.unpack("<387B", file.read(387*1)) image2 = [] for x in image: sp.seek(x*4) y = struct.unpack("<I", sp.read(4))[0] y = t[y-1] image2.append(y) circ2 = [] for x in circ: sp.seek((x+561)*4) y = struct.unpack("<I", sp.read(4))[0] y = t[y-1] circ2.append(y) out = zip(image2, length, unk1, unk2, circ2, vert) for x in enumerate(out):
import struct import tbl f = open("weapons.dat") t = tbl.read(open("stat_txt.tbl")) def g(s): s = "<130" + s l = struct.calcsize(s) r = f.read(l) assert len(r) == l return struct.unpack(s, r) s = "HIBHIIBBBBBHHHHHBBHHHH" assert struct.calcsize("<" + s) == 42, struct.calcsize("<" + s) l = map(g, s) print '<meta http-equiv="refresh" content="1"/><table border=2>' desc = "ID label sprite spell flag min max upgrade type mbehavior mtype explosion inner middle outer dmg bonus cool factor p1 p2 msg icon" desc = desc.split(" ") print '<tr><td>' + '</td><td>'.join(desc) + '</td></tr>' for i, x in enumerate(zip(*l)): x = (t[x[0] - 1], ) + x[1:-2] + (t[x[-2] - 1], ) + x[-1:] print '<tr><td>' + str(i) + '</td><td>' + '</td><td>'.join(map( str, x)) + '</td></tr>' print '</table>'
def __init__(self, dat_file, tbl_file): DatFile.__init__(self, dat_file) self._tbl = tbl.read(tbl_file)
import tbl def read_field((name, type, start), count, dat_file): dat_file.seek(start) type = '<%i%s' % (count, type) return struct.unpack(type, dat_file.read(struct.calcsize(type))) class DatType(object): def __init__(self, number, attrs): for key, value in attrs: setattr(self, key, value) class DatFile(cdict.cdict): #_fields = None _item_type = DatType #_count = None def __init__(self, dat_file): cdict.cdict.__init__(self, self._read_item) self.data = zip(*[read_field(field, self._count, dat_file) for field in self._fields]) def _read_item(self, key): return self._item_type(key, zip([x[0] for x in self._fields], self.data[key])) class DatTblFile(DatFile): def __init__(self, dat_file, tbl_file): DatFile.__init__(self, dat_file) self._tbl = tbl.read(tbl_file) def _read_item(self, key): return self._item_type(key, zip([x[0] for x in self._fields], self.data[key]), self._tbl) stat_txt = tbl.read(open(os.path.join(os.path.dirname(__file__), 'files/stat_txt.tbl')))