3 * Dig and draw a new level
5 * @(#)new_level.c 3.7 (Berkeley) 6/2/81
7 * Rogue: Exploring the Dungeons of Doom
8 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
11 * See the file LICENSE.TXT for full copyright and licensing information.
25 if (level
> max_level
)
32 * Free up the monsters on the last level
35 do_rooms(); /* Draw rooms */
36 do_passages(); /* Draw passages */
38 put_things(); /* Place objects (if any) */
40 * Place the staircase down.
44 rnd_pos(&rooms
[rm
], &stairs
);
45 } until (winat(stairs
.y
, stairs
.x
) == FLOOR
);
52 ntraps
= rnd(level
/4)+1;
53 if (ntraps
> MAXTRAPS
)
61 rnd_pos(&rooms
[rm
], &stairs
);
62 } until (winat(stairs
.y
, stairs
.x
) == FLOOR
);
65 case 0: ch
= TRAPDOOR
;
66 when
1: ch
= BEARTRAP
;
67 when
2: ch
= SLEEPTRAP
;
68 when
3: ch
= ARROWTRAP
;
70 when
5: ch
= DARTTRAP
;
73 traps
[i
].tr_type
= ch
;
74 traps
[i
].tr_flags
= 0;
75 traps
[i
].tr_pos
= stairs
;
81 rnd_pos(&rooms
[rm
], &hero
);
83 until(winat(hero
.y
, hero
.x
) == FLOOR
);
85 wmove(cw
, hero
.y
, hero
.x
);
90 * Pick a room that is really there
100 } while (rooms
[rm
].r_flags
& ISGONE
);
106 * put potions and scrolls on this level
112 register struct linked_list
*item
;
113 register struct object
*cur
;
118 * Throw away stuff left on the previous level (if anything)
122 * Once you have found the amulet, the only way to get new stuff is
123 * go down into the dungeon.
125 if (amulet
&& level
< max_level
)
128 * Do MAXOBJ attempts to put things on a level
130 for (i
= 0; i
< MAXOBJ
; i
++)
134 * Pick a new object and link it in the list
137 attach(lvl_obj
, item
);
138 cur
= (struct object
*) ldata(item
);
144 rnd_pos(&rooms
[rm
], &tp
);
145 } until (winat(tp
.y
, tp
.x
) == FLOOR
);
146 mvaddch(tp
.y
, tp
.x
, cur
->o_type
);
150 * If he is really deep in the dungeon and he hasn't found the
151 * amulet yet, put it somewhere on the ground
153 if (level
> 25 && !amulet
)
155 item
= new_item(sizeof *cur
);
156 attach(lvl_obj
, item
);
157 cur
= (struct object
*) ldata(item
);
158 cur
->o_hplus
= cur
->o_dplus
= 0;
159 strcpy(cur
->o_damage
, "0d0");
160 strcpy(cur
->o_hurldmg
, "0d0");
162 cur
->o_type
= AMULET
;
168 rnd_pos(&rooms
[rm
], &tp
);
169 } until (winat(tp
.y
, tp
.x
) == FLOOR
);
170 mvaddch(tp
.y
, tp
.x
, cur
->o_type
);