void mkswamp(void) { // Michiel Huisjes & Fred de Wilde struct mkroom *sroom; int sx, sy, i, eelct = 0; for (i = 0; i < 5; i++) { // 5 tries sroom = &rooms[rn2(nroom)]; if (sroom->hx < 0 || sroom->rtype || has_upstairs(sroom) || has_dnstairs(sroom)) continue; // satisfied; make a swamp sroom->rtype = SWAMP; for (sx = sroom->lx; sx <= sroom->hx; sx++) for (sy = sroom->ly; sy <= sroom->hy; sy++) if ((sx + sy) % 2 && !o_at(sx, sy) && !t_at(sx, sy) && !m_at(sx, sy) && !nexttodoor(sx, sy)) { levl[sx][sy].typ = POOL; levl[sx][sy].scrsym = POOL_SYM; if (!eelct || !rn2(4)) { (void) makemon(PM_EEL, sx, sy); eelct++; } } } }
static void mkswamp(struct level *lev) { struct mkroom *sroom; int sx, sy, i, eelct = 0; for (i = 0; i < 5; i++) { /* turn up to 5 rooms swampy */ sroom = &lev->rooms[rn2(lev->nroom)]; if (sroom->hx < 0 || sroom->rtype != OROOM || has_upstairs(lev, sroom) || has_dnstairs(lev, sroom)) continue; /* satisfied; make a swamp */ sroom->rtype = SWAMP; for (sx = sroom->lx; sx <= sroom->hx; sx++) for (sy = sroom->ly; sy <= sroom->hy; sy++) if (!OBJ_AT_LEV(lev, sx, sy) && !MON_AT(lev, sx, sy) && !t_at(lev, sx, sy) && !nexttodoor(lev, sx, sy)) { if ((sx + sy) % 2) { lev->locations[sx][sy].typ = POOL; if (!eelct || !rn2(4)) { /* mkclass() won't do, as we might get kraken */ makemon(rn2(5) ? &mons[PM_GIANT_EEL] : rn2(2) ? &mons[PM_PIRANHA] : &mons[PM_ELECTRIC_EEL], lev, sx, sy, NO_MM_FLAGS); eelct++; } } else if (!rn2(4)) /* swamps tend to be moldy */ makemon(mkclass(&lev->z, S_FUNGUS, 0), lev, sx, sy, NO_MM_FLAGS); } lev->flags.has_swamp = 1; } }
void mkzoo(int type) { struct mkroom *sroom; struct monst *mon; int sh, sx, sy, i; int goldlim = 500 * dlevel; int moct = 0; i = nroom; for (sroom = &rooms[rn2(nroom)];; sroom++) { if (sroom == &rooms[nroom]) sroom = &rooms[0]; if (!i-- || sroom->hx < 0) return; if (sroom->rtype) continue; if (type == MORGUE && sroom->rlit) continue; if (has_upstairs(sroom) || (has_dnstairs(sroom) && rn2(3))) continue; if (sroom->doorct == 1 || !rn2(5)) break; } sroom->rtype = type; 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; mon = makemon((type == MORGUE) ? morguemon() : (type == BEEHIVE) ? PM_KILLER_BEE : (struct permonst *) 0, sx, sy); if (mon) mon->msleep = 1; switch (type) { case ZOO: i = sq(dist2(sx, sy, doors[sh].x, doors[sh].y)); if (i >= goldlim) i = 5 * dlevel; goldlim -= i; mkgold((long) (10 + rn2(i)), sx, sy); break; case MORGUE: // Usually there is one dead body in the morgue if (!moct && rn2(3)) { mksobj_at(CORPSE, sx, sy); moct++; } break; case BEEHIVE: if (!rn2(3)) mksobj_at(LUMP_OF_ROYAL_JELLY, sx, sy); break; } } }
static void mkshop(struct level *lev) { struct mkroom *sroom; int styp, j; char *ep = NULL; /* first determine shoptype */ styp = -1; for (sroom = &lev->rooms[0];; sroom++) { if (sroom->hx < 0) return; if (sroom - lev->rooms >= lev->nroom) { pline("lev->rooms not closed by -1?"); return; } if (sroom->rtype != OROOM) continue; if (has_dnstairs(lev, sroom) || has_upstairs(lev, sroom)) continue; if ((wizard && ep && sroom->doorct != 0) || sroom->doorct == 1) break; } if (!sroom->rlit) { int x, y; for (x = sroom->lx - 1; x <= sroom->hx + 1; x++) for (y = sroom->ly - 1; y <= sroom->hy + 1; y++) lev->locations[x][y].lit = 1; sroom->rlit = 1; } if (styp < 0) { /* pick a shop type at random */ j = 1 + mklev_rn2(100, lev); for (styp = 0; (j -= shtypes[styp].prob) > 0; styp++) continue; /* big rooms cannot be wand or book shops, so make them general stores */ if (isbig(sroom) && (shtypes[styp].symb == WAND_CLASS || shtypes[styp].symb == SPBOOK_CLASS)) styp = 0; } sroom->rtype = SHOPBASE + styp; /* set room bits before stocking the shop */ topologize(lev, sroom); /* stock the room with a shopkeeper and artifacts */ stock_room(styp, lev, sroom); }
static void mkshop(void) { struct mkroom *sroom; int i = -1; char *ep = (char *)0; /* (init == lint suppression) */ gottype: for (sroom = &rooms[0];; sroom++) { if (sroom->hx < 0) return; if (sroom - rooms >= nroom) { pline("rooms not closed by -1?"); return; } if (sroom->rtype != OROOM) continue; if (has_dnstairs(sroom) || has_upstairs(sroom)) continue; if ((flags.debug && ep && sroom->doorct != 0) || sroom->doorct == 1) break; } if (!sroom->rlit) { int x, y; for (x = sroom->lx - 1; x <= sroom->hx + 1; x++) for (y = sroom->ly - 1; y <= sroom->hy + 1; y++) levl[x][y].lit = 1; sroom->rlit = 1; } if (i < 0) { /* shoptype not yet determined */ int j; /* pick a shop type at random */ for (j = rnd(100), i = 0; (j -= shtypes[i].prob) > 0; i++) continue; /* big rooms cannot be wand or book shops, * - so make them general stores */ if (isbig(sroom) && (shtypes[i].symb == WAND_CLASS || shtypes[i].symb == SPBOOK_CLASS)) i = 0; } sroom->rtype = SHOPBASE + i; /* set room bits before stocking the shop */ topologize(sroom); /* stock the room with a shopkeeper and artifacts */ stock_room(i, sroom); }
/* pick an unused room, preferably with only one door */ static struct mkroom * pick_room(struct level *lev, boolean strict, enum rng rng) { struct mkroom *sroom; int i = lev->nroom; for (sroom = &lev->rooms[rn2_on_rng(lev->nroom, rng)]; i--; sroom++) { if (sroom == &lev->rooms[lev->nroom]) sroom = &lev->rooms[0]; if (sroom->hx < 0) return NULL; if (sroom->rtype != OROOM) continue; if (!strict) { if (has_upstairs(lev, sroom) || (has_dnstairs(lev, sroom) && rn2_on_rng(3, rng))) continue; } else if (has_upstairs(lev, sroom) || has_dnstairs(lev, sroom)) continue; if (sroom->doorct == 1 || !rn2_on_rng(5, rng) || wizard) return sroom; } return NULL; }
mkshop(){ register struct mkroom *sroom; register int sh,sx,sy,i = -1; register char let; int roomno; register struct monst *shk; #ifdef WIZARD /* first determine shoptype */ if(wizard){ extern char *getenv(); register char *ep = getenv("SHOPTYPE"); if(ep){ if(*ep == 'z' || *ep == 'Z'){ mkzoo(ZOO); return; } if(*ep == 'm' || *ep == 'M'){ mkzoo(MORGUE); return; } if(*ep == 'b' || *ep == 'B'){ mkzoo(BEEHIVE); return; } if(*ep == 's' || *ep == 'S'){ mkswamp(); return; } for(i=0; shtypes[i]; i++) if(*ep == shtypes[i]) break; goto gottype; } } gottype: #endif WIZARD for(sroom = &rooms[0], roomno = 0; ; sroom++, roomno++){ if(sroom->hx < 0) return; if(sroom - rooms >= nroom) { pline("rooms not closed by -1?"); return; } if(sroom->rtype) continue; if(!sroom->rlit || has_dnstairs(sroom) || has_upstairs(sroom)) continue; if( #ifdef WIZARD (wizard && getenv("SHOPTYPE") && sroom->doorct != 0) || #endif WIZARD sroom->doorct == 1) break; } if(i < 0) { /* shoptype not yet determined */ register int j; for(j = rn2(100), i = 0; (j -= shprobs[i])>= 0; i++) if(!shtypes[i]) break; /* superfluous */ if(isbig(sroom) && i + SHOPBASE == WANDSHOP) i = GENERAL-SHOPBASE; } sroom->rtype = i + SHOPBASE; let = shtypes[i]; 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 { #ifdef WIZARD /* This is said to happen sometimes, but I've never seen it. */ if(wizard) { register int j = sroom->doorct; extern int doorindex; pline("Where is shopdoor?"); pline("Room at (%d,%d),(%d,%d).", sroom->lx, sroom->ly, sroom->hx, sroom->hy); pline("doormax=%d doorct=%d fdoor=%d", doorindex, sroom->doorct, sh); while(j--) { pline("door [%d,%d]", doors[sh].x, doors[sh].y); sh++; } more(); } #endif WIZARD 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->shoplevel = dlevel; ESHK->shd = doors[sh]; ESHK->shk.x = sx; ESHK->shk.y = sy; ESHK->robbed = 0; ESHK->visitct = 0; ESHK->following = 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 = 1; mtmp->mappearance = (let && rn2(10) < dlevel) ? let : ']'; continue; } (void) mkobj_at(let, sx, sy); } }