Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site mcvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!mcvax!play From: play@mcvax.UUCP (funhouse) Newsgroups: net.sources Subject: Hack sources (part 14 of 15) Message-ID: <6256@mcvax.UUCP> Date: Mon, 17-Dec-84 19:42:10 EST Article-I.D.: mcvax.6256 Posted: Mon Dec 17 19:42:10 1984 Date-Received: Wed, 19-Dec-84 02:18:51 EST Organization: CWI, Amsterdam Lines: 1054 # This is part 14 (of 15) of the Hack sources. Send complaints to # mcvax!play . # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # mklev.c mklev.h mklv.makemaz.c mklv.shk.c mklv.shknam.c echo x - mklev.c cat > "mklev.c" << '//E*O*F mklev.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include #include "mklev.h" #include "def.trap.h" extern char *getlogin(); extern struct monst *makemon(); char *tfile,*tspe,**args; char nul[40]; #include "savelev.h" #ifdef WIZARD boolean wizard; #endif WIZARD #define somex() ((rand()%(croom->hx-croom->lx+1))+croom->lx) #define somey() ((rand()%(croom->hy-croom->ly+1))+croom->ly) struct rm levl[COLNO][ROWNO]; struct monst *fmon; struct obj *fobj; struct gen *fgold, *ftrap; char *fut_geno; /* monsters that should not be created anymore */ struct mkroom rooms[MAXNROFROOMS+1], *croom, *troom; coord doors[DOORMAX]; int doorindex = 0; int comp(); xchar dlevel; schar nxcor,xx,yy,dx,dy,tx,ty; /* for corridors and other things... */ boolean goldseen; int nroom; xchar xdnstair,xupstair,ydnstair,yupstair; main(argc,argv) char *argv[]; { register unsigned tryct; if(argc < 6) panic("Too few arguments!!"); args = argv; tfile = argv[1]; tspe = argv[2]; dlevel = atoi(argv[3]); if(dlevel < 1) panic("Bad level"); fut_geno = argv[4]; #ifdef WIZARD wizard = (argv[5][0] == 'w'); #endif WIZARD (void) srand(getpid()); init_objects(); rooms[0].hx = -1; /* in case we are in a maze */ /* a: normal; b: maze */ if(*tspe == 'b') { makemaz(); savelev(); exit(0); } /* construct the rooms */ while(nroom < (MAXNROFROOMS/3)) { croom = rooms; nroom = 0; (void) makerooms(0); /* not secret */ } /* for each room: put things inside */ for(croom = rooms; croom->hx > 0; croom++) { /* put a sleeping monster inside */ if(!rn2(3)) (void) makemon((struct permonst *) 0, somex(), somey()); /* put traps and mimics inside */ goldseen = FALSE; while(!rn2(8-(dlevel/6))) mktrap(0,0); if(!goldseen && !rn2(3)) mkgold(0,somex(),somey()); if(!rn2(3)) { mkobj_at(0, somex(), somey()); tryct = 0; while(!rn2(5)) { if(++tryct > 100){ printf("tryct overflow4\n"); break; } mkobj_at(0, somex(), somey()); } } } tryct = 0; do { if(++tryct > 1000) panic("Cannot make dnstairs\n"); croom = &rooms[rn2(nroom)]; xdnstair = somex(); ydnstair = somey(); } while((*tspe =='n' && (!(xdnstair%2) || !(ydnstair%2))) || g_at(xdnstair,ydnstair,ftrap)); levl[xdnstair][ydnstair].scrsym ='>'; levl[xdnstair][ydnstair].typ = STAIRS; troom = croom; do { if(++tryct > 2000) panic("Cannot make upstairs\n"); croom = &rooms[rn2(nroom)]; xupstair = somex(); yupstair = somey(); } while(croom == troom || m_at(xupstair,yupstair) || g_at(xupstair,yupstair,ftrap)); levl[xupstair][yupstair].scrsym ='<'; levl[xupstair][yupstair].typ = STAIRS; qsort((char *) rooms, nroom, sizeof(struct mkroom), comp); croom = rooms; troom = croom+1; nxcor = 0; mkpos(); do makecor(); while (croom->hx > 0 && troom->hx > 0); /* make a secret treasure vault, not connected to the rest */ if(nroom < (2*MAXNROFROOMS/3)) if(!rn2(3)) { register int x,y; troom = croom = &rooms[nroom]; if(makerooms(1)) { /* make secret room */ troom->rtype = 6; /* treasure vault */ for(x = troom->lx; x <= troom->hx; x++) for(y = troom->ly; y <= troom->hy; y++) mkgold(rnd(dlevel*100) + 50, x, y); } } #ifdef WIZARD if(wizard){ if(rn2(3)) mkshop(); else mkzoo(); } else #endif WIZARD if(dlevel > 1 && dlevel < 20 && rn2(dlevel) < 2) mkshop(); else if(dlevel > 6 && (!rn2(7) || !strcmp("david", getlogin()))) mkzoo(); savelev(); exit(0); } makerooms(secret) int secret; { register int lowx, lowy; register int tryct = 0; while(nroom < (MAXNROFROOMS/2) || secret) for(lowy = rn1(3,3); lowy < ROWNO-7; lowy += rn1(2,4)) { for(lowx = rn1(3,4); lowx < COLNO-10; lowx += rn1(2,7)) { if(tryct++ > 10000) return(0); if((lowy += (rn2(5)-2)) < 3) lowy = 3; else if(lowy > ROWNO-6) lowy = ROWNO-6; if(levl[lowx][lowy].typ) continue; if((secret && maker(lowx, 1, lowy, 1)) || (!secret && maker(lowx,rn1(9,2),lowy,rn1(4,2)) && nroom+2 > MAXNROFROOMS)) return(1); } } return(1); } comp(x,y) register struct mkroom *x,*y; { if(x->lx < y->lx) return(-1); return(x->lx > y->lx); } coord finddpos(xl,yl,xh,yh) { coord ff; register x,y; ff.x = (xl == xh) ? xl : (xl + rn2(xh-xl+1)); ff.y = (yl == yh) ? yl : (yl + rn2(yh-yl+1)); if(okdoor(ff.x, ff.y)) return(ff); if(xl < xh) for(x = xl; x <= xh; x++) if(okdoor(x, ff.y)){ ff.x = x; return(ff); } if(yl < yh) for(y = yl; y <= yh; y++) if(okdoor(ff.x, y)){ ff.y = y; return(ff); } return(ff); } /* when croom and troom exist, find position for a door in croom and direction for a corridor towards position [tx,ty] in the wall of troom */ mkpos() { coord cc,tt; if(troom->hx < 0 || croom->hx < 0 || doorindex >= DOORMAX) return; if(troom->lx > croom->hx) { dx = 1; dy = 0; xx = croom->hx+1; tx = troom->lx-1; cc = finddpos(xx,croom->ly,xx,croom->hy); tt = finddpos(tx,troom->ly,tx,troom->hy); } else if(troom->hy < croom->ly) { dy = -1; dx = 0; yy = croom->ly-1; cc = finddpos(croom->lx,yy,croom->hx,yy); ty = troom->hy+1; tt = finddpos(troom->lx,ty,troom->hx,ty); } else if(troom->hx < croom->lx) { dx = -1; dy = 0; xx = croom->lx-1; tx = troom->hx+1; cc = finddpos(xx,croom->ly,xx,croom->hy); tt = finddpos(tx,troom->ly,tx,troom->hy); } else { dy = 1; dx = 0; yy = croom->hy+1; ty = troom->ly-1; cc = finddpos(croom->lx,yy,croom->hx,yy); tt = finddpos(troom->lx,ty,troom->hx,ty); } xx = cc.x; yy = cc.y; tx = tt.x; ty = tt.y; if(levl[xx+dx][yy+dy].typ) { if(nxcor) newloc(); else { dodoor(xx,yy,croom); xx += dx; yy += dy; } return; } dodoor(xx,yy,croom); } /* if allowable, create a door at [x,y] */ okdoor(x,y) register x,y; { if(levl[x-1][y].typ == DOOR || levl[x+1][y].typ == DOOR || levl[x][y+1].typ == DOOR || levl[x][y-1].typ == DOOR || levl[x-1][y].typ == SDOOR || levl[x+1][y].typ == SDOOR || levl[x][y-1].typ == SDOOR || levl[x][y+1].typ == SDOOR || (levl[x][y].typ != HWALL && levl[x][y].typ != VWALL) || doorindex >= DOORMAX) return(0); return(1); } dodoor(x,y,aroom) register x,y; register struct mkroom *aroom; { register struct mkroom *broom; register tmp; if(doorindex >= DOORMAX) panic("DOORMAX exceeded?"); if(!okdoor(x,y) && nxcor) return; if(!rn2(8)) levl[x][y].typ = SDOOR; else { levl[x][y].scrsym ='+'; levl[x][y].typ = DOOR; } aroom->doorct++; broom = aroom+1; if(broom->hx < 0) tmp = doorindex; else for(tmp = doorindex; tmp > broom->fdoor; tmp--) doors[tmp] = doors[tmp-1]; doorindex++; doors[tmp].x = x; doors[tmp].y = y; for( ; broom->hx >= 0; broom++) broom->fdoor++; } newloc() { register a,b; register int tryct = 0; ++croom; ++troom; if(nxcor || croom->hx < 0 || troom->hx < 0) { if(nxcor++ > rn1(nroom,4)) { croom = &rooms[nroom]; return; } do { if(++tryct > 100){ printf("tryct overflow5\n"); croom = &rooms[nroom]; return; } a = rn2(nroom); b = rn2(nroom); croom = &rooms[a]; troom = &rooms[b]; } while(croom == troom || (troom == croom+1 && !rn2(3))); } mkpos(); } /* make a trap somewhere (in croom if mazeflag = 0) */ mktrap(num,mazeflag) register num,mazeflag; { register struct gen *gtmp; register int kind,nopierc,nomimic,fakedoor,fakegold,tryct = 0; register xchar mx,my; if(!num || num >= TRAPNUM) { nopierc = (dlevel < 4) ? 1 : 0; nomimic = (dlevel < 9 || goldseen ) ? 1 : 0; if(index(fut_geno, 'M')) nomimic = 1; kind = rn2(TRAPNUM - nopierc - nomimic); /* note: PIERC = 7, MIMIC = 8, TRAPNUM = 9 */ } else kind = num; if(kind == MIMIC) { register struct monst *mtmp; fakedoor = (!rn2(3) && !mazeflag); fakegold = (!fakedoor && !rn2(2)); if(fakegold) goldseen = TRUE; do { if(++tryct > 200) return; if(fakedoor) { /* note: fakedoor maybe on actual door */ if(rn2(2)){ if(rn2(2)) mx = croom->hx+1; else mx = croom->lx-1; my = somey(); } else { if(rn2(2)) my = croom->hy+1; else my = croom->ly-1; mx = somex(); } } else if(mazeflag) { extern coord mazexy(); coord mm; mm = mazexy(); mx = mm.x; my = mm.y; } else { mx = somex(); my = somey(); } } while(m_at(mx,my)); if(mtmp = makemon(PM_MIMIC,mx,my)) mtmp->mimic = fakegold ? '$' : fakedoor ? '+' : (mazeflag && rn2(2)) ? AMULET_SYM : "=/)%?![<>" [ rn2(9) ]; return; } gtmp = newgen(); gtmp->gflag = kind; do { if(++tryct > 200){ printf("tryct overflow7\n"); free((char *) gtmp); return; } if(mazeflag){ extern coord mazexy(); coord mm; mm = mazexy(); gtmp->gx = mm.x; gtmp->gy = mm.y; } else { gtmp->gx = somex(); gtmp->gy = somey(); } } while(g_at(gtmp->gx, gtmp->gy, ftrap)); gtmp->ngen = ftrap; ftrap = gtmp; if(mazeflag && !rn2(10) && gtmp->gflag < PIERC) gtmp->gflag |= SEEN; } /*VARARGS1*/ panic(str,arg1,arg2,arg3) char *str,*arg1,*arg2,*arg3; { char bufr[BUFSZ]; extern char *sprintf(); (void) sprintf(bufr,str,arg1,arg2,arg3); (void) write(1,"\nMKLEV ERROR: ",15); puts(bufr); (void) fflush(stdout); exit(1); } maker(lowx,ddx,lowy,ddy) schar lowx,ddx,lowy,ddy; { register x, y, hix = lowx+ddx, hiy = lowy+ddy; if(nroom >= MAXNROFROOMS) return(0); if(hix > COLNO-5) hix = COLNO-5; if(hiy > ROWNO-4) hiy = ROWNO-4; chk: if(hix <= lowx || hiy <= lowy) return(0); /* check area around room (and make room smaller if necessary) */ for(x = lowx-4; x <= hix+4; x++) for(y = lowy-3; y <= hiy+3; y++) if(levl[x][y].typ) { if(rn2(3)) return(0); lowx = x+5; lowy = y+4; goto chk; } /* on low levels the room is lit (usually) */ /* secret vaults are always lit */ if((rnd(dlevel) < 10 && rn2(77)) || (ddx == 1 && ddy == 1)) for(x = lowx-1; x <= hix+1; x++) for(y = lowy-1; y <= hiy+1; y++) levl[x][y].lit = 1; croom->lx = lowx; croom->hx = hix; croom->ly = lowy; croom->hy = hiy; croom->rtype = croom->doorct = croom->fdoor = 0; for(x = lowx-1; x <= hix+1; x++) for(y = lowy-1; y <= hiy+1; y += (hiy-lowy+2)) { levl[x][y].scrsym = '-'; levl[x][y].typ = HWALL; } for(x = lowx-1; x <= hix+1; x += (hix-lowx+2)) for(y = lowy; y <= hiy; y++) { levl[x][y].scrsym = '|'; levl[x][y].typ = VWALL; } for(x = lowx; x <= hix; x++) for(y = lowy; y <= hiy; y++) { levl[x][y].scrsym = '.'; levl[x][y].typ = ROOM; } croom++; croom->hx = -1; nroom++; return(1); } makecor() { register nx, ny; register struct rm *crm; register dix, diy, secondtry = 0; tryagain: nx = xx + dx; ny = yy + dy; if(nxcor && !rn2(35)) { newloc(); return; } if(nx == COLNO-1 || nx == 0 || ny == 0 || ny == ROWNO-1) { if(nxcor) { newloc(); return; } else { printf("something went wrong. we try again...\n"); execl("./mklev",args[0],tfile,tspe,args[3],args[4],args[5],0); panic("cannot execute ./mklev\n"); } } dix = abs(nx-tx); diy = abs(ny-ty); if(dy && dix > diy) { dy = 0; dx = (nx > tx) ? -1 : 1; } else if(dx && diy > dix) { dx = 0; dy = (ny > ty) ? -1 : 1; } crm = &levl[nx][ny]; if(!(crm->typ)) { if(rn2(100)) { crm->typ = CORR; crm->scrsym = CORR_SYM; } else { crm->typ = SCORR; crm->scrsym = ' '; } xx = nx; yy = ny; if(nxcor && !rn2(50)) { mkobj_at(ROCK_SYM, nx, ny); } return; } if(crm->typ == CORR || crm->typ == SCORR) { xx = nx; yy = ny; return; } if(nx == tx && ny == ty) { dodoor(nx,ny,troom); newloc(); return; } if(!secondtry++ && (nx != xx+dx || ny != yy+dy)) goto tryagain; if(dx) { if(ty < ny) dy = -1; else dy = levl[nx+dx][ny-1].typ == ROOM?1:-1; dx = 0; } else { if(tx < nx) dx = -1; else dx = levl[nx-1][ny+dy].typ == ROOM?1:-1; dy = 0; } } struct monst * m_at(x,y) register x,y; { register struct monst *mtmp; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(mtmp->mx == x && mtmp->my == y) return(mtmp); return(0); } struct gen * g_at(x,y,ptr) register x,y; register struct gen *ptr; { while(ptr) { if(ptr->gx == x && ptr->gy == y) return(ptr); ptr = ptr->ngen; } return(0); } //E*O*F mklev.c// echo x - mklev.h cat > "mklev.h" << '//E*O*F mklev.h//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "config.h" #ifdef BSD #include /* declarations for strcat etc. */ #else #include /* idem on System V */ #define index strchr #define rindex strrchr #endif BSD #include "def.objclass.h" typedef struct { xchar x,y; } coord; #include "def.monst.h" /* uses coord */ #include "def.gen.h" #include "def.obj.h" extern char *sprintf(); #define BUFSZ 256 /* for getlin buffers */ #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */ #define HWALL 1 /* Level location types */ #define VWALL 2 #define SDOOR 3 #define SCORR 4 #define LDOOR 5 #define DOOR 6 /* smallest accessible type */ #define CORR 7 #define ROOM 8 #define STAIRS 9 #ifdef QUEST #define CORR_SYM ':' #else #define CORR_SYM '#' #endif QUEST #define ERRCHAR '{' #define TRAPNUM 9 struct rm { char scrsym; unsigned typ:5; unsigned new:1; unsigned seen:1; unsigned lit:1; }; extern struct rm levl[COLNO][ROWNO]; #ifndef QUEST struct mkroom { xchar lx,hx,ly,hy; schar rtype,rlit,doorct,fdoor; }; #define MAXNROFROOMS 15 extern struct mkroom rooms[MAXNROFROOMS+1]; #define DOORMAX 100 extern coord doors[DOORMAX]; #endif QUEST #include "def.permonst.h" extern struct permonst mons[]; #define PM_ACIDBLOB &mons[7] #define PM_PIERC &mons[17] #define PM_MIMIC &mons[37] #define PM_CHAM &mons[47] #define PM_DEMON &mons[54] #define PM_MINOTAUR &mons[55] /* last in mons array */ #define PM_SHK &mons[56] /* very last */ #define CMNUM 55 /* number of common monsters */ extern long *alloc(); extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */ extern xchar dlevel; #ifdef WIZARD extern boolean wizard; #endif WIZARD #define newstring(x) (char *) alloc((unsigned)(x)) //E*O*F mklev.h// echo x - mklv.makemaz.c cat > "mklv.makemaz.c" << '//E*O*F mklv.makemaz.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "mklev.h" extern struct monst *makemon(); extern coord mazexy(); makemaz() { int x,y; register zx,zy; coord mm; for(x = 2; x < COLNO-1; x++) for(y = 2; y < ROWNO-1; y++) levl[x][y].typ = (x%2 && y%2) ? 0 : HWALL; mm = mazexy(); zx = mm.x; zy = mm.y; walkfrom(zx,zy); mkobj_at(AMULET_SYM, zx, zy); mkobj_at(ROCK_SYM, zx, zy); /* put a rock on top of the amulet */ /* (probably this means that one needs a wand of digging to reach the amulet - we must make sure that the player has a chance of getting one; let us say when he kills the minotaur; of course the minotaur itself may be blocked behind rocks, but well...) */ for(x = 2; x < COLNO-1; x++) for(y = 2; y < ROWNO-1; y++) { switch(levl[x][y].typ) { case HWALL: levl[x][y].scrsym = '-'; break; case ROOM: levl[x][y].scrsym = '.'; break; } } for(x = rn1(8,11); x; x--) { mm = mazexy(); mkobj_at(0, mm.x, mm.y); } for(x = rn1(10,2); x; x--) { mm = mazexy(); mkobj_at(ROCK_SYM, mm.x, mm.y); } mm = mazexy(); (void) makemon(PM_MINOTAUR, mm.x, mm.y); for(x = rn1(5,7); x; x--) { mm = mazexy(); (void) makemon((struct permonst *) 0, mm.x, mm.y); } for(x = rn1(6,7); x; x--) { mm = mazexy(); mkgold(0,mm.x,mm.y); } for(x = rn1(6,7); x; x--) mktrap(0,1); mm = mazexy(); levl[(xupstair = mm.x)][(yupstair = mm.y)].scrsym = '<'; levl[xupstair][yupstair].typ = STAIRS; xdnstair = ydnstair = 0; } walkfrom(x,y) int x,y; { register int q,a,dir; int dirs[4]; levl[x][y].typ = ROOM; while(1) { q = 0; for(a = 0; a < 4; a++) if(okay(x,y,a)) dirs[q++]= a; if(!q) return; dir = dirs[rn2(q)]; move(&x,&y,dir); levl[x][y].typ = ROOM; move(&x,&y,dir); walkfrom(x,y); } } move(x,y,dir) register int *x, *y; register int dir; { switch(dir){ case 0: --(*y); break; case 1: (*x)++; break; case 2: (*y)++; break; case 3: --(*x); break; } } okay(x,y,dir) int x,y; register int dir; { move(&x,&y,dir); move(&x,&y,dir); if(x<3 || y<3 || x>COLNO-3 || y>ROWNO-3 || levl[x][y].typ != 0) return(0); else return(1); } coord mazexy(){ coord mm; mm.x = 3 + 2*rn2(COLNO/2 - 2); mm.y = 3 + 2*rn2(ROWNO/2 - 2); return mm; } //E*O*F mklv.makemaz.c// echo x - mklv.shk.c cat > "mklv.shk.c" << '//E*O*F mklv.shk.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #ifndef QUEST #include "mklev.h" #include "def.eshk.h" #define ESHK ((struct eshk *)(&(shk->mextra[0]))) extern struct monst *makemon(); char shtypes[] = "=/)%?!["; /* 8 shoptypes: 7 specialised, 1 mixed */ schar shprobs[] = { 3,3,5,5,10,10,14,50 }; /* their probabilities */ mkshop(){ register struct mkroom *sroom; register int sh,sx,sy,i; register char let; int roomno; register struct monst *shk; for(sroom = &rooms[0], roomno = 0; ; sroom++, roomno++){ if(sroom->hx < 0) return; if(sroom->lx <= xdnstair && xdnstair <= sroom->hx && sroom->ly <= ydnstair && ydnstair <= sroom->hy) continue; if(sroom->lx <= xupstair && xupstair <= sroom->hx && sroom->ly <= yupstair && yupstair <= sroom->hy) continue; if( #ifdef WIZARD wizard || #endif WIZARD sroom->doorct == 1) break; } #ifdef WIZARD if(wizard){ extern char *getenv(); register char *ep = getenv("SHOPTYPE"); if(ep){ if(*ep == 'z' || *ep == 'Z'){ mkzoo(); return; } for(i=0; shtypes[i]; i++) if(*ep == shtypes[i]) break; let = i; goto gotlet; } } #endif WIZARD for(i = rn2(100),let = 0; (i -= shprobs[let])>= 0; let++) if(!shtypes[let]) break; /* superfluous */ #ifdef WIZARD gotlet: #endif WIZARD sroom->rtype = 8+let; let = shtypes[let]; sh = sroom->fdoor; sx = doors[sh].x; sy = doors[sh].y; if(sx == sroom->lx-1) sx++; else if(sx == sroom->hx+1) sx--; else if(sy == sroom->ly-1) sy++; else if(sy == sroom->hy+1) sy--; else { printf("Where is shopdoor?"); return; } if(!(shk = makemon(PM_SHK,sx,sy))) return; shk->isshk = shk->mpeaceful = 1; shk->msleep = 0; shk->mtrapseen = ~0; /* we know all the traps already */ ESHK->shoproom = roomno; ESHK->shd = doors[sh]; ESHK->shk.x = sx; ESHK->shk.y = sy; ESHK->robbed = 0; ESHK->visitct = 0; shk->mgold = 1000 + 30*rnd(100); /* initial capital */ ESHK->billct = 0; findname(ESHK->shknam, let); for(sx = sroom->lx; sx <= sroom->hx; sx++) for(sy = sroom->ly; sy <= sroom->hy; sy++){ register struct monst *mtmp; if((sx == sroom->lx && doors[sh].x == sx-1) || (sx == sroom->hx && doors[sh].x == sx+1) || (sy == sroom->ly && doors[sh].y == sy-1) || (sy == sroom->hy && doors[sh].y == sy+1)) continue; if(rn2(100) < dlevel && !m_at(sx,sy) && (mtmp = makemon(PM_MIMIC, sx, sy))){ mtmp->mimic = (let && rn2(10) < dlevel) ? let : ']'; continue; } mkobj_at(let, sx, sy); } #ifdef WIZARD if(wizard) printf("I made a %c-shop.", let ? let : 'g'); #endif WIZARD } mkzoo(){ register struct mkroom *sroom; register int sh,sx,sy,i; int goldlim = 500 * dlevel; for(sroom = &rooms[0]; ; sroom++){ if(sroom->hx < 0) return; if(sroom->lx <= xdnstair && xdnstair <= sroom->hx && sroom->ly <= ydnstair && ydnstair <= sroom->hy) continue; if(sroom->lx <= xupstair && xupstair <= sroom->hx && sroom->ly <= yupstair && yupstair <= sroom->hy) continue; if(sroom->doorct == 1) break; } sroom->rtype = 7; sh = sroom->fdoor; for(sx = sroom->lx; sx <= sroom->hx; sx++) for(sy = sroom->ly; sy <= sroom->hy; sy++){ if((sx == sroom->lx && doors[sh].x == sx-1) || (sx == sroom->hx && doors[sh].x == sx+1) || (sy == sroom->ly && doors[sh].y == sy-1) || (sy == sroom->hy && doors[sh].y == sy+1)) continue; (void) makemon((struct permonst *) 0,sx,sy); i = sq(dist2(sx,sy,doors[sh].x,doors[sh].y)); if(i >= goldlim) i = 5*dlevel; goldlim -= i; mkgold(10 + rn2(i), sx, sy); } #ifdef WIZARD if(wizard) printf("I made a zoo."); #endif WIZARD } dist2(x0,y0,x1,y1){ return((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1)); } sq(a) int a; { return(a*a); } #endif QUEST //E*O*F mklv.shk.c// echo x - mklv.shknam.c cat > "mklv.shknam.c" << '//E*O*F mklv.shknam.c//' /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ #include "mklev.h" char *shkliquors[] = { /* Ukraine */ "Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka", /* N. Russia */ "Konosja", "Weliki Oestjoeg", "Syktywkar", "Sablja", "Narodnaja", "Kyzyl", /* Silezie */ "Walbrzych", "Swidnica", "Klodzko", "Raciborz", "Gliwice", "Brzeg", "Krnov", "Hradec Kralove", /* Schweiz */ "Leuk", "Brig", "Brienz", "Thun", "Sarnen", "Burglen", "Elm", "Flims", "Vals", "Schuls", "Zum Loch", 0 }; char *shkbooks[] = { /* Eire */ "Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch", "Loughrea", "Croagh", "Maumakeogh", "Ballyjamesduff", "Kinnegad", "Lugnaquillia", "Enniscorthy", "Gweebarra", "Kittamagh", "Nenagh", "Sneem", "Ballingeary", "Kilgarvan", "Cahersiveen", "Glenbeigh", "Kilmihil", "Kiltamagh", "Droichead Atha", "Inniscrone", "Clonegal", "Lisnaskea", "Culdaff", "Dunfanaghy", "Inishbofin", "Kesh", 0 }; char *shkarmors[] = { /* Turquie */ "Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep", "Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak", "Iskenderun", "Kadirli", "Siverek", "Pervari", "Malasgirt", "Bayburt", "Ayancik", "Zonguldak", "Balya", "Tefenni", "Artvin", "Kars", "Makharadze", "Malazgirt", "Midyat", "Birecik", "Kirikkale", "Alaca", "Polatli", "Nallihan", 0 }; char *shkwands[] = { /* Wales */ "Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach", "Rhaeader", "Llandrindod", "Llanfair-ym-muallt", "Y-Fenni", "Measteg", "Rhydaman", "Beddgelert", "Curig", "Llanrwst", "Llanerchymedd", "Caergybi", /* Scotland */ "Nairn", "Turriff", "Inverurie", "Braemar", "Lochnagar", "Kerloch", "Beinn a Ghlo", "Drumnadrochit", "Morven", "Uist", "Storr", "Sgurr na Ciche", "Cannich", "Gairloch", "Kyleakin", "Dunvegan", 0 }; char *shkrings[] = { /* Hollandse familienamen */ "Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken", "Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy", "Olycan", "Sadelin", "Svaving", "Tapper", "Terwen", "Wirix", "Ypey", /* Skandinaviske navne */ "Rastegaisa", "Varjag Njarga", "Kautekeino", "Abisko", "Enontekis", "Rovaniemi", "Avasaksa", "Haparanda", "Lulea", "Gellivare", "Oeloe", "Kajaani", "Fauske", 0 }; char *shkfoods[] = { /* Indonesia */ "Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan", "Bandjar", "Parbalingga", "Bojolali", "Sarangan", "Ngebel", "Djombang", "Ardjawinangun", "Berbek", "Papar", "Baliga", "Tjisolok", "Siboga", "Banjoewangi", "Trenggalek", "Karangkobar", "Njalindoeng", "Pasawahan", "Pameunpeuk", "Patjitan", "Kediri", "Pemboeang", "Tringanoe", "Makin", "Tipor", "Semai", "Berhala", "Tegal", "Samoe", 0 }; char *shkweapons[] = { /* Perigord */ "Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard", "Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac", "Fleac", "Lonzac", "Vergt", "Queyssac", "Liorac", "Echourgnac", "Cazelon", "Eypau", "Carignan", "Monbazillac", "Jonzac", "Pons", "Jumilhac", "Fenouilledes", "Laguiolet", "Saujon", "Eymoutiers", "Eygurande", "Eauze", "Labouheyre", 0 }; char *shkgeneral[] = { /* Suriname */ "Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi", "Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo", "Akalapi", "Sipaliwini", /* Greenland */ "Annootok", "Upernavik", "Angmagssalik", /* N. Canada */ "Aklavik", "Inuvik", "Tuktoyaktuk", "Chicoutimi", "Ouiatchouane", "Chibougamau", "Matagami", "Kipawa", "Kinojevis", "Abitibi", "Maganasipi", /* Iceland */ "Akureyri", "Kopasker", "Budereyri", "Akranes", "Bordeyri", "Holmavik", 0 }; struct shk_nx { char x; char **xn; } shk_nx[] = { { POTION_SYM, shkliquors }, { SCROLL_SYM, shkbooks }, { ARMOR_SYM, shkarmors }, { WAND_SYM, shkwands }, { RING_SYM, shkrings }, { FOOD_SYM, shkfoods }, { WEAPON_SYM, shkweapons }, { 0, shkgeneral } }; findname(nampt, let) char *nampt; char let; { register struct shk_nx *p = shk_nx; register char **q; register int i; while(p->x && p->x != let) p++; q = p->xn; for(i=0; i