2001-03-26 00:43:58 +04:00
|
|
|
/* $NetBSD: hack.mkmaze.c,v 1.5 2001/03/25 20:44:01 jsm Exp $ */
|
1997-10-19 20:56:41 +04:00
|
|
|
|
1993-08-02 21:16:36 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
|
|
|
|
*/
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-08-02 21:16:36 +04:00
|
|
|
#ifndef lint
|
2001-03-26 00:43:58 +04:00
|
|
|
__RCSID("$NetBSD: hack.mkmaze.c,v 1.5 2001/03/25 20:44:01 jsm Exp $");
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#include "hack.h"
|
1997-10-19 20:56:41 +04:00
|
|
|
#include "extern.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
#include "def.mkroom.h" /* not really used */
|
2001-03-26 00:43:58 +04:00
|
|
|
const struct permonst hell_hound =
|
1997-10-19 20:56:41 +04:00
|
|
|
{"hell hound", 'd', 12, 14, 2, 3, 6, 0};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
makemaz()
|
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int x, y;
|
|
|
|
int zx, zy;
|
|
|
|
coord mm;
|
|
|
|
boolean al = (dlevel >= 30 && !flags.made_amulet);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
for (x = 2; x < COLNO - 1; x++)
|
|
|
|
for (y = 2; y < ROWNO - 1; y++)
|
|
|
|
levl[x][y].typ = (x % 2 && y % 2) ? 0 : HWALL;
|
|
|
|
if (al) {
|
|
|
|
struct monst *mtmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
zx = 2 * (COLNO / 4) - 1;
|
|
|
|
zy = 2 * (ROWNO / 4) - 1;
|
|
|
|
for (x = zx - 2; x < zx + 4; x++)
|
|
|
|
for (y = zy - 2; y <= zy + 2; y++) {
|
|
|
|
levl[x][y].typ =
|
|
|
|
(y == zy - 2 || y == zy + 2 || x == zx - 2 || x == zx + 3) ? POOL :
|
|
|
|
(y == zy - 1 || y == zy + 1 || x == zx - 1 || x == zx + 2) ? HWALL :
|
|
|
|
ROOM;
|
|
|
|
}
|
|
|
|
(void) mkobj_at(AMULET_SYM, zx, zy);
|
|
|
|
flags.made_amulet = 1;
|
|
|
|
walkfrom(zx + 4, zy);
|
|
|
|
if ((mtmp = makemon(&hell_hound, zx, zy)) != NULL)
|
|
|
|
mtmp->msleep = 1;
|
|
|
|
if ((mtmp = makemon(PM_WIZARD, zx + 1, zy)) != NULL) {
|
|
|
|
mtmp->msleep = 1;
|
|
|
|
flags.no_of_wizards = 1;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
} else {
|
1997-10-19 20:56:41 +04:00
|
|
|
mm = mazexy();
|
|
|
|
zx = mm.x;
|
|
|
|
zy = mm.y;
|
|
|
|
walkfrom(zx, zy);
|
|
|
|
(void) mksobj_at(WAN_WISHING, zx, zy);
|
|
|
|
(void) mkobj_at(ROCK_SYM, zx, zy); /* put a rock on top of
|
|
|
|
* it */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
for (x = 2; x < COLNO - 1; x++)
|
|
|
|
for (y = 2; y < ROWNO - 1; y++) {
|
|
|
|
switch (levl[x][y].typ) {
|
1993-03-21 12:45:37 +03:00
|
|
|
case HWALL:
|
|
|
|
levl[x][y].scrsym = '-';
|
|
|
|
break;
|
|
|
|
case ROOM:
|
|
|
|
levl[x][y].scrsym = '.';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
for (x = rn1(8, 11); x; x--) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mm = mazexy();
|
|
|
|
(void) mkobj_at(rn2(2) ? GEM_SYM : 0, mm.x, mm.y);
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
for (x = rn1(10, 2); x; x--) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mm = mazexy();
|
|
|
|
(void) mkobj_at(ROCK_SYM, mm.x, mm.y);
|
|
|
|
}
|
|
|
|
mm = mazexy();
|
|
|
|
(void) makemon(PM_MINOTAUR, mm.x, mm.y);
|
1997-10-19 20:56:41 +04:00
|
|
|
for (x = rn1(5, 7); x; x--) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mm = mazexy();
|
|
|
|
(void) makemon((struct permonst *) 0, mm.x, mm.y);
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
for (x = rn1(6, 7); x; x--) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mm = mazexy();
|
1997-10-19 20:56:41 +04:00
|
|
|
mkgold(0L, mm.x, mm.y);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
for (x = rn1(6, 7); x; x--)
|
|
|
|
mktrap(0, 1, (struct mkroom *) 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
mm = mazexy();
|
|
|
|
levl[(xupstair = mm.x)][(yupstair = mm.y)].scrsym = '<';
|
|
|
|
levl[xupstair][yupstair].typ = STAIRS;
|
|
|
|
xdnstair = ydnstair = 0;
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
walkfrom(x, y)
|
|
|
|
int x, y;
|
|
|
|
{
|
|
|
|
int q, a, dir;
|
|
|
|
int dirs[4];
|
1993-03-21 12:45:37 +03:00
|
|
|
levl[x][y].typ = ROOM;
|
1997-10-19 20:56:41 +04:00
|
|
|
while (1) {
|
1993-03-21 12:45:37 +03:00
|
|
|
q = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
for (a = 0; a < 4; a++)
|
|
|
|
if (okay(x, y, a))
|
|
|
|
dirs[q++] = a;
|
|
|
|
if (!q)
|
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
dir = dirs[rn2(q)];
|
1997-10-19 20:56:41 +04:00
|
|
|
move(&x, &y, dir);
|
1993-03-21 12:45:37 +03:00
|
|
|
levl[x][y].typ = ROOM;
|
1997-10-19 20:56:41 +04:00
|
|
|
move(&x, &y, dir);
|
|
|
|
walkfrom(x, y);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
move(x, y, dir)
|
|
|
|
int *x, *y;
|
|
|
|
int dir;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
switch (dir) {
|
|
|
|
case 0:
|
|
|
|
--(*y);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
(*x)++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
(*y)++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
--(*x);
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
|
|
|
okay(x, y, dir)
|
|
|
|
int x, y;
|
|
|
|
int dir;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
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);
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
1997-10-19 20:56:41 +04:00
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
coord
|
1997-10-19 20:56:41 +04:00
|
|
|
mazexy()
|
|
|
|
{
|
|
|
|
coord mm;
|
|
|
|
mm.x = 3 + 2 * rn2(COLNO / 2 - 2);
|
|
|
|
mm.y = 3 + 2 * rn2(ROWNO / 2 - 2);
|
1993-03-21 12:45:37 +03:00
|
|
|
return mm;
|
|
|
|
}
|