2 * Draw the nine rooms on the screen
4 * @(#)rooms.c 3.8 (Berkeley) 6/15/81
6 * Rogue: Exploring the Dungeons of Doom
7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * See the file LICENSE.TXT for full copyright and licensing information.
19 register struct room
*rp
;
20 register struct linked_list
*item
;
21 register struct thing
*tp
;
22 register int left_out
;
28 * bsze is the maximum room size
33 * Clear things for a new level
35 for (rp
= rooms
; rp
<= &rooms
[MAXROOMS
-1]; rp
++)
36 rp
->r_goldval
= rp
->r_nexits
= rp
->r_flags
= 0;
38 * Put the gone rooms, if any, on the level
41 for (i
= 0; i
< left_out
; i
++)
42 rooms
[rnd_room()].r_flags
|= ISGONE
;
44 * dig and populate all the rooms on the level
46 for (i
= 0, rp
= rooms
; i
< MAXROOMS
; rp
++, i
++)
49 * Find upper left corner of box that this room goes in
51 top
.x
= (i
%3)*bsze
.x
+ 1;
53 if (rp
->r_flags
& ISGONE
)
56 * Place a gone room. Make certain that there is a blank line
57 * for passage drawing.
61 rp
->r_pos
.x
= top
.x
+ rnd(bsze
.x
-2) + 1;
62 rp
->r_pos
.y
= top
.y
+ rnd(bsze
.y
-2) + 1;
65 } until(rp
->r_pos
.y
> 0 && rp
->r_pos
.y
< LINES
-1);
68 if (rnd(10) < level
-1)
69 rp
->r_flags
|= ISDARK
;
71 * Find a place and size for a random room
75 rp
->r_max
.x
= rnd(bsze
.x
- 4) + 4;
76 rp
->r_max
.y
= rnd(bsze
.y
- 4) + 4;
77 rp
->r_pos
.x
= top
.x
+ rnd(bsze
.x
- rp
->r_max
.x
);
78 rp
->r_pos
.y
= top
.y
+ rnd(bsze
.y
- rp
->r_max
.y
);
79 } until (rp
->r_pos
.y
!= 0);
83 if (rnd(100) < 50 && (!amulet
|| level
>= max_level
))
85 rp
->r_goldval
= GOLDCALC
;
86 rnd_pos(rp
, &rp
->r_gold
);
87 if (roomin(&rp
->r_gold
) != rp
)
94 if (rnd(100) < (rp
->r_goldval
> 0 ? 80 : 25))
96 item
= new_item(sizeof *tp
);
97 tp
= (struct thing
*) ldata(item
);
101 } until(mvwinch(stdscr
, mp
.y
, mp
.x
) == FLOOR
);
102 new_monster(item
, randmonster(FALSE
), &mp
);
104 * See if we want to give it a treasure to carry around.
106 if (rnd(100) < monsters
[tp
->t_type
-'A'].m_carry
)
107 attach(tp
->t_pack
, new_thing());
113 * Draw a box around a room
117 register struct room
*rp
;
121 move(rp
->r_pos
.y
, rp
->r_pos
.x
+1);
122 vert(rp
->r_max
.y
-2); /* Draw left side */
123 move(rp
->r_pos
.y
+rp
->r_max
.y
-1, rp
->r_pos
.x
);
124 horiz(rp
->r_max
.x
); /* Draw bottom */
125 move(rp
->r_pos
.y
, rp
->r_pos
.x
);
126 horiz(rp
->r_max
.x
); /* Draw top */
127 vert(rp
->r_max
.y
-2); /* Draw right side */
131 for (j
= 1; j
< rp
->r_max
.y
-1; j
++)
133 move(rp
->r_pos
.y
+ j
, rp
->r_pos
.x
+1);
134 for (k
= 1; k
< rp
->r_max
.x
-1; k
++)
141 mvaddch(rp
->r_gold
.y
, rp
->r_gold
.x
, GOLD
);
146 * draw a horizontal line
158 * draw a vertical line
176 * pick a random spot in a room
180 register struct room
*rp
;
183 cp
->x
= rp
->r_pos
.x
+ rnd(rp
->r_max
.x
-2) + 1;
184 cp
->y
= rp
->r_pos
.y
+ rnd(rp
->r_max
.y
-2) + 1;