"""Extract local Half-Life assets; never alters the Steam installation.""" import pathlib, struct from PIL import Image PROJECT = pathlib.Path(__file__).resolve().parents[1] SOURCE = pathlib.Path.home()/'.steam/steam/steamapps/common/Half-Life/valve' out = PROJECT/'assets/textures' out.mkdir(parents=True, exist_ok=True) body = bytearray((SOURCE/'models/zombie.mdl').read_bytes()) tex = bytearray((SOURCE/'models/zombiet.mdl').read_bytes()) base = len(body) count, records, data, refs, families, skins = struct.unpack_from('<6i', tex, 180) for i in range(count): pos = records + i*80 name, flags, w, h, pixel = struct.unpack_from('<64s4i', tex, pos) image = Image.frombytes('P', (w,h), bytes(tex[pixel:pixel+w*h])) image.putpalette(bytes(tex[pixel+w*h:pixel+w*h+768])) image.convert('RGB').save(out/('zombie_%02d.png'%i)) struct.pack_into('