-
Notifications
You must be signed in to change notification settings - Fork 1
/
wizard.c
305 lines (256 loc) · 5.39 KB
/
wizard.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*
* Special wizard commands (some of which are also non-wizard commands
* under strange circumstances)
*
* @(#)wizard.c 4.30 (Berkeley) 02/05/99
*
* Rogue: Exploring the Dungeons of Doom
* Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman
* All rights reserved.
*
* See the file LICENSE.TXT for full copyright and licensing information.
*/
#include <stdlib.h>
#include <curses.h>
#include <string.h>
#include <ctype.h>
#include "rogue.h"
/*
* whatis:
* What a certin object is
*/
void
whatis(bool insist, int type)
{
THING *obj;
if (pack == NULL) {
msg("you don't have anything in your pack to identify");
return;
}
for (;;) {
obj = get_item("identify", type);
if (insist) {
if (n_objs == 0)
return;
else if (obj == NULL)
msg("you must identify something");
else if (type && obj->o_type != type &&
!(type == R_OR_S && (obj->o_type == RING || obj->o_type == STICK)) )
msg("you must identify a %s", type_name(type));
else
break;
}
else
break;
}
if (obj == NULL)
return;
switch (obj->o_type) {
case SCROLL:
set_know(obj, scr_info);
break;
case POTION:
set_know(obj, pot_info);
break;
case STICK:
set_know(obj, ws_info);
break;
case WEAPON:
case ARMOR:
obj->o_flags |= ISKNOW;
break;
case RING:
set_know(obj, ring_info);
}
msg(inv_name(obj, FALSE));
}
/*
* set_know:
* Set things up when we really know what a thing is
*/
void
set_know(THING *obj, struct obj_info *info)
{
char **guess;
info[obj->o_which].oi_know = TRUE;
obj->o_flags |= ISKNOW;
guess = &info[obj->o_which].oi_guess;
if (*guess) {
free(*guess);
*guess = NULL;
}
}
/*
* type_name:
* Return a pointer to the name of the type
*/
char *
type_name(int type)
{
struct h_list *hp;
static struct h_list tlist[] = {
{POTION, "potion", FALSE},
{SCROLL, "scroll", FALSE},
{FOOD, "food", FALSE},
{R_OR_S, "ring, wand or staff", FALSE},
{RING, "ring", FALSE},
{STICK, "wand or staff", FALSE},
{WEAPON, "weapon", FALSE},
{ARMOR, "suit of armor", FALSE},
};
for (hp = tlist; hp->h_ch; hp++)
if (type == hp->h_ch)
return hp->h_desc;
/* NOTREACHED */
return(0);
}
#ifdef MASTER
/*
* create_obj:
* wizard command for getting anything he wants
*/
void
create_obj()
{
THING *obj;
char ch, bless;
obj = new_item();
msg("type of item: ");
obj->o_type = readchar();
mpos = 0;
msg("which %c do you want? (0-f)", obj->o_type);
obj->o_which = (isdigit((ch = readchar())) ? ch - '0' : ch - 'a' + 10);
obj->o_group = 0;
obj->o_count = 1;
mpos = 0;
if (obj->o_type == WEAPON || obj->o_type == ARMOR) {
msg("blessing? (+,-,n)");
bless = readchar();
mpos = 0;
if (bless == '-')
obj->o_flags |= ISCURSED;
if (obj->o_type == WEAPON) {
init_weapon(obj, obj->o_which);
if (bless == '-')
obj->o_hplus -= rnd(3)+1;
if (bless == '+')
obj->o_hplus += rnd(3)+1;
}
else {
obj->o_arm = a_class[obj->o_which];
if (bless == '-')
obj->o_arm += rnd(3)+1;
if (bless == '+')
obj->o_arm -= rnd(3)+1;
}
}
else if (obj->o_type == RING)
switch (obj->o_which) {
case R_PROTECT:
case R_ADDSTR:
case R_ADDHIT:
case R_ADDDAM:
msg("blessing? (+,-,n)");
bless = readchar();
mpos = 0;
if (bless == '-')
obj->o_flags |= ISCURSED;
obj->o_arm = (bless == '-' ? -1 : rnd(2) + 1);
break;
case R_AGGR:
case R_TELEPORT:
obj->o_flags |= ISCURSED;
}
else if (obj->o_type == STICK)
fix_stick(obj);
else if (obj->o_type == GOLD) {
msg("how much?");
get_num(&obj->o_goldval, stdscr);
}
add_pack(obj, FALSE);
}
#endif
/*
* telport:
* Bamf the hero someplace else
*/
void
teleport()
{
static coord c;
mvaddch(hero.y, hero.x, floor_at());
do {
find_floor((struct room *) NULL, &c, FALSE, TRUE);
}
while (chat(c.y, c.x) != FLOOR);
if (roomin(&c) != proom) {
leave_room(&hero);
hero = c;
enter_room(&hero);
}
else {
hero = c;
look(TRUE);
}
mvaddch(hero.y, hero.x, PLAYER);
/*
* turn off ISHELD in case teleportation was done while fighting
* a Flytrap
*/
if (on(player, ISHELD)) {
player.t_flags &= ~ISHELD;
vf_hit = 0;
strcpy(monsters['F'-'A'].m_stats.s_dmg, "000x0");
}
no_move = 0;
count = 0;
running = FALSE;
flush_type();
}
#ifdef MASTER
/*
* passwd:
* See if user knows password
*/
int
passwd()
{
char *sp, c;
static char buf[MAXSTR];
msg("wizard's Password:");
mpos = 0;
sp = buf;
while ((c = readchar()) != '\n' && c != '\r' && c != ESCAPE)
if (c == md_killchar())
sp = buf;
else if (c == md_erasechar() && sp > buf)
sp--;
else
*sp++ = c;
if (sp == buf)
return FALSE;
*sp = '\0';
return (strcmp(PASSWD, md_crypt(buf, "mT")) == 0);
}
/*
* show_map:
* Print out the map for the wizard
*/
void
show_map()
{
int y, x, real;
wclear(hw);
for (y = 1; y < NUMLINES - 1; y++)
for (x = 0; x < NUMCOLS; x++) {
real = flat(y, x);
if (!(real & F_REAL))
wstandout(hw);
wmove(hw, y, x);
waddch(hw, chat(y, x));
if (!real)
wstandend(hw);
}
show_win("---More (level map)---");
}
#endif