1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 2: /* hack.mkmaze.c - version 1.0.2 */ 3: 4: #include "hack.h" 5: #include "def.mkroom.h" /* not really used */ 6: extern struct monst *makemon(); 7: extern struct permonst pm_wizard; 8: extern struct obj *mkobj_at(); 9: extern coord mazexy(); 10: struct permonst hell_hound = 11: { "hell hound", 'd', 12, 14, 2, 3, 6, 0 }; 12: 13: makemaz() 14: { 15: int x,y; 16: register zx,zy; 17: coord mm; 18: boolean al = (dlevel >= 30 && !flags.made_amulet); 19: 20: for(x = 2; x < COLNO-1; x++) 21: for(y = 2; y < ROWNO-1; y++) 22: levl[x][y].typ = (x%2 && y%2) ? 0 : HWALL; 23: if(al) { 24: register struct monst *mtmp; 25: 26: zx = 2*(COLNO/4) - 1; 27: zy = 2*(ROWNO/4) - 1; 28: for(x = zx-2; x < zx+4; x++) for(y = zy-2; y <= zy+2; y++) { 29: levl[x][y].typ = 30: (y == zy-2 || y == zy+2 || x == zx-2 || x == zx+3) ? POOL : 31: (y == zy-1 || y == zy+1 || x == zx-1 || x == zx+2) ? HWALL: 32: ROOM; 33: } 34: (void) mkobj_at(AMULET_SYM, zx, zy); 35: flags.made_amulet = 1; 36: walkfrom(zx+4, zy); 37: if(mtmp = makemon(&hell_hound, zx, zy)) 38: mtmp->msleep = 1; 39: if(mtmp = makemon(PM_WIZARD, zx+1, zy)) { 40: mtmp->msleep = 1; 41: flags.no_of_wizards = 1; 42: } 43: } else { 44: mm = mazexy(); 45: zx = mm.x; 46: zy = mm.y; 47: walkfrom(zx,zy); 48: (void) mksobj_at(WAN_WISHING, zx, zy); 49: (void) mkobj_at(ROCK_SYM, zx, zy); /* put a rock on top of it */ 50: } 51: 52: for(x = 2; x < COLNO-1; x++) 53: for(y = 2; y < ROWNO-1; y++) { 54: switch(levl[x][y].typ) { 55: case HWALL: 56: levl[x][y].scrsym = '-'; 57: break; 58: case ROOM: 59: levl[x][y].scrsym = '.'; 60: break; 61: } 62: } 63: for(x = rn1(8,11); x; x--) { 64: mm = mazexy(); 65: (void) mkobj_at(rn2(2) ? GEM_SYM : 0, mm.x, mm.y); 66: } 67: for(x = rn1(10,2); x; x--) { 68: mm = mazexy(); 69: (void) mkobj_at(ROCK_SYM, mm.x, mm.y); 70: } 71: mm = mazexy(); 72: (void) makemon(PM_MINOTAUR, mm.x, mm.y); 73: for(x = rn1(5,7); x; x--) { 74: mm = mazexy(); 75: (void) makemon((struct permonst *) 0, mm.x, mm.y); 76: } 77: for(x = rn1(6,7); x; x--) { 78: mm = mazexy(); 79: mkgold(0L,mm.x,mm.y); 80: } 81: for(x = rn1(6,7); x; x--) 82: mktrap(0,1,(struct mkroom *) 0); 83: mm = mazexy(); 84: levl[(xupstair = mm.x)][(yupstair = mm.y)].scrsym = '<'; 85: levl[xupstair][yupstair].typ = STAIRS; 86: xdnstair = ydnstair = 0; 87: } 88: 89: walkfrom(x,y) int x,y; { 90: register int q,a,dir; 91: int dirs[4]; 92: levl[x][y].typ = ROOM; 93: while(1) { 94: q = 0; 95: for(a = 0; a < 4; a++) 96: if(okay(x,y,a)) dirs[q++]= a; 97: if(!q) return; 98: dir = dirs[rn2(q)]; 99: move(&x,&y,dir); 100: levl[x][y].typ = ROOM; 101: move(&x,&y,dir); 102: walkfrom(x,y); 103: } 104: } 105: 106: move(x,y,dir) 107: register int *x, *y; 108: register int dir; 109: { 110: switch(dir){ 111: case 0: --(*y); break; 112: case 1: (*x)++; break; 113: case 2: (*y)++; break; 114: case 3: --(*x); break; 115: } 116: } 117: 118: okay(x,y,dir) 119: int x,y; 120: register int dir; 121: { 122: move(&x,&y,dir); 123: move(&x,&y,dir); 124: if(x<3 || y<3 || x>COLNO-3 || y>ROWNO-3 || levl[x][y].typ != 0) 125: return(0); 126: else 127: return(1); 128: } 129: 130: coord 131: mazexy(){ 132: coord mm; 133: mm.x = 3 + 2*rn2(COLNO/2 - 2); 134: mm.y = 3 + 2*rn2(ROWNO/2 - 2); 135: return mm; 136: }