"""Compile first-person heist art and the rival owners' headquarters map.""" from pathlib import Path import json from PIL import Image from pack_underworld_v2 import cells,normalize,pack,SRC,OUT from make_hall_layout import reachable ROOT=Path(__file__).resolve().parents[2] def main(): actors=cells('heist-actors-v1.png',4,2,8) actors=normalize(actors[:4],256)+normalize(actors[4:7],256)+normalize(actors[7:],256) weapons=cells('heist-weapons-v1.png',4,1,4) weapons=normalize(weapons[:2],(256,320),.96)+normalize(weapons[2:],(256,320),.96) props=[normalize([f],256)[0] for f in cells('heist-props-v1.png',4,1,4)] van=Image.open(SRC/'heist-van-v1.png').convert('RGBA') assert van.getchannel('A').histogram()[0]>10000,'Van windshield requires alpha' van=van.resize((640,480),Image.Resampling.NEAREST) city=(OUT/'city-detail.bin').read_bytes() _,w,h,_,_=__import__('struct').unpack('<4sIIII',city[:20]) materials=[Image.frombytes('RGBA',(w,h),city[20+i*w*h*4:20+(i+1)*w*h*4],'raw','BGRA').resize((128,128),Image.Resampling.NEAREST) for i in (8,10,3,6)] manifest={n:pack(n,f) for n,f in [('heist-van-v1.bin',[van]),('heist-actors-v1.bin',actors),('heist-weapons-v1.bin',weapons),('heist-props-v1.bin',props),('heist-materials-v1.bin',materials)]} (OUT/'manifest-heist-hq-v1.json').write_text(json.dumps(manifest,indent=2)+'\n') grid=[[80]*32 for _ in range(32)] def room(x0,y0,x1,y1): for y in range(y0,y1+1): for x in range(x0,x1+1):grid[y][x]=0 room(2,23,29,29) # arrival courtyard room(10,17,21,22) # lobby and front entrance room(14,4,17,21) # central hallway room(6,12,12,16);room(13,14,14,15) # security, terminal room(6,5,12,10);room(13,8,14,9) # owners' office and dossiers room(20,5,25,11);room(18,8,19,9) # strongroom room(2,13,4,24);room(5,14,6,15) # concealed service route for y in (8,9):grid[y][19]=81 # access-controlled vault door # Front reception desk forces a choice of side rather than a straight firing lane. for x in range(14,18):grid[19][x]=83 visited=reachable(grid,(16,26)) assert (9,13) in visited and (8,7) in visited assert (23,6) not in visited,'Vault must require access or a drill' opened=[row[:] for row in grid] opened[8][19]=opened[9][19]=0 assert (23,6) in reachable(opened,(16,26)) road=[[(197+y//5%2) for x in range(32)] for y in range(32)] for y in range(1,31): for x in range(11,22):road[y][x]=0 if y%6 in (0,1): for x in (10,22):road[y][x]=0 text='; Rival owners HQ and van road. Generated by pack_heist_hq.py.\n.data\n' for name,arr in [('hqMapTemplate',grid),('hqRoadMap',road)]: text+=name+' label byte\n' text+='\n'.join(' db '+','.join(map(str,row)) for row in arr)+'\n' text+='.code\n' (ROOT/'src_graphics/heist_hq_map.inc').write_text(text,encoding='ascii') print('Compiled heist atlas packs and two independent mission maps.') if __name__=='__main__':main()