-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnew_level.c
183 lines (169 loc) · 3.86 KB
/
new_level.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include "rogue.h"
#include "new_level.h"
#include "rooms.h"
#include "passages.h"
#include "random.h"
#include "curses.h"
#include "io.h"
#include "move.h"
#include "monsters.h"
#pragma code-name(push, "LC")
/*
* new_level:
* Dig and draw a new level
*
* @(#)new_level.c 3.7 (Berkeley) 6/2/81
*/
void new_level(void)
{
char rm, i, ch;
// register int rm, i;
// register char ch;
coord stairs;
if (level > max_level)
max_level = level;
wclear(cw);
wclear(mw);
wclear(stdscr);
//clear();
status();
/*
* Free up the monsters on the last level
*/
clear_monsters();
do_rooms(); /* Draw rooms */
do_passages(); /* Draw passages */
// no_food++;
// put_things(); /* Place objects (if any) */
/*
* Place the staircase down.
*/
do {
rm = rnd_room();
rnd_pos(&rooms[rm], &stairs);
} until (winat(stairs.y, stairs.x) == FLOOR);
addch(STAIRS);
/*
* Place the traps
*/
if (rnd(10) < level)
{
ntraps = rnd(level/4)+1;
if (ntraps > MAXTRAPS)
ntraps = MAXTRAPS;
i = ntraps;
while (i--)
{
do
{
rm = rnd_room();
rnd_pos(&rooms[rm], &stairs);
} until (winat(stairs.y, stairs.x) == FLOOR);
switch(rnd(6))
{
when 0: ch = TRAPDOOR;
when 1: ch = BEARTRAP;
when 2: ch = SLEEPTRAP;
when 3: ch = ARROWTRAP;
when 4: ch = TELTRAP;
when 5: ch = DARTTRAP;
}
addch(TRAP);
traps[i].tr_type = ch;
traps[i].tr_flags = 0;
traps[i].tr_pos = stairs;
}
}
do
{
rm = rnd_room();
rnd_pos(&rooms[rm], &hero);
} until(winat(hero.y, hero.x) == FLOOR);
light(&hero);
wmove(cw, hero.y, hero.x);
waddch(cw, PLAYER);
addmsg("Monsters (%d): ", MONSTER_COUNT);
for (i = 0; i < MONSTER_COUNT; i++)
addmsg("%c ", monsters[i].t_type);
endmsg();
}
/*
* Pick a room that is really there
*/
char rnd_room(void)
{
char rm;
do
{
rm = rnd(MAXROOMS);
} while (rooms[rm].r_flags & ISGONE);
return rm;
}
/*
* put_things:
* put potions and scrolls on this level
*/
//put_things()
//{
// register int i;
// register struct linked_list *item;
// register struct object *cur;
// register int rm;
// coord tp;
/*
* Throw away stuff left on the previous level (if anything)
*/
// free_list(lvl_obj);
/*
* Once you have found the amulet, the only way to get new stuff is
* go down into the dungeon.
*/
// if (amulet && level < max_level)
// return;
/*
* Do MAXOBJ attempts to put things on a level
*/
// for (i = 0; i < MAXOBJ; i++)
// if (rnd(100) < 35)
// {
// /*
// * Pick a new object and link it in the list
// */
// item = new_thing();
// attach(lvl_obj, item);
// cur = (struct object *) ldata(item);
// /*
// * Put it somewhere
// */
// rm = rnd_room();
// do {
// rnd_pos(&rooms[rm], &tp);
// } until (winat(tp.y, tp.x) == FLOOR);
// mvaddch(tp.y, tp.x, cur->o_type);
// cur->o_pos = tp;
// }
/*
* If he is really deep in the dungeon and he hasn't found the
* amulet yet, put it somewhere on the ground
*/
// if (level > 25 && !amulet)
// {
// item = new_item(sizeof *cur);
// attach(lvl_obj, item);
// cur = (struct object *) ldata(item);
// cur->o_hplus = cur->o_dplus = 0;
// cur->o_damage = cur->o_hurldmg = "0d0";
// cur->o_ac = 11;
// cur->o_type = AMULET;
/*
* Put it somewhere
*/
// rm = rnd_room();
// do {
// rnd_pos(&rooms[rm], &tp);
// } until (winat(tp.y, tp.x) == FLOOR);
// mvaddch(tp.y, tp.x, cur->o_type);
// cur->o_pos = tp;
// }
//}
#pragma code-name(pop)