comparison rogue3/wizard.c @ 0:527e2150eaf0

Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
author edwarj4
date Tue, 13 Oct 2009 13:33:34 +0000
parents
children e7aab31362af
comparison
equal deleted inserted replaced
-1:000000000000 0:527e2150eaf0
1
2 /*
3 * Special wizard commands (some of which are also non-wizard commands
4 * under strange circumstances)
5 *
6 * @(#)wizard.c 3.8 (Berkeley) 6/3/81
7 *
8 * Rogue: Exploring the Dungeons of Doom
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * All rights reserved.
11 *
12 * See the file LICENSE.TXT for full copyright and licensing information.
13 */
14
15 #include "curses.h"
16 #include <ctype.h>
17 #include <string.h>
18 #include <stdlib.h>
19 #include "machdep.h"
20 #include "rogue.h"
21
22 /*
23 * whatis:
24 * What a certin object is
25 */
26
27 void
28 whatis()
29 {
30 struct object *obj;
31 struct linked_list *item;
32
33 if ((item = get_item("identify", 0)) == NULL)
34 return;
35 obj = (struct object *) ldata(item);
36 switch (obj->o_type)
37 {
38 case SCROLL:
39 s_know[obj->o_which] = TRUE;
40 if (s_guess[obj->o_which])
41 {
42 free(s_guess[obj->o_which]);
43 s_guess[obj->o_which] = NULL;
44 }
45 when POTION:
46 p_know[obj->o_which] = TRUE;
47 if (p_guess[obj->o_which])
48 {
49 free(p_guess[obj->o_which]);
50 p_guess[obj->o_which] = NULL;
51 }
52 when STICK:
53 ws_know[obj->o_which] = TRUE;
54 obj->o_flags |= ISKNOW;
55 if (ws_guess[obj->o_which])
56 {
57 free(ws_guess[obj->o_which]);
58 ws_guess[obj->o_which] = NULL;
59 }
60 when WEAPON:
61 case ARMOR:
62 obj->o_flags |= ISKNOW;
63 when RING:
64 r_know[obj->o_which] = TRUE;
65 obj->o_flags |= ISKNOW;
66 if (r_guess[obj->o_which])
67 {
68 free(r_guess[obj->o_which]);
69 r_guess[obj->o_which] = NULL;
70 }
71 }
72 msg(inv_name(obj, FALSE));
73 }
74
75 /*
76 * create_obj:
77 * Wizard command for getting anything he wants
78 */
79
80 void
81 create_obj()
82 {
83 struct linked_list *item;
84 struct object *obj;
85 int bless;
86 int ch;
87
88 item = new_item(sizeof *obj);
89 obj = (struct object *) ldata(item);
90 msg("Type of item: ");
91 obj->o_type = readchar(cw);
92 mpos = 0;
93 msg("Which %c do you want? (0-f)", obj->o_type);
94 obj->o_which = (isdigit((ch = readchar(cw))) ? ch - '0' : ch - 'a' + 10);
95 obj->o_group = 0;
96 obj->o_count = 1;
97 mpos = 0;
98 if (obj->o_type == WEAPON || obj->o_type == ARMOR)
99 {
100 msg("Blessing? (+,-,n)");
101 bless = readchar(cw);
102 mpos = 0;
103 if (obj->o_type == WEAPON)
104 {
105 init_weapon(obj, obj->o_which);
106 if (bless == '-') {
107 obj->o_hplus -= rnd(3)+1;
108 obj->o_flags |= ISCURSED;
109 }
110 if (bless == '+')
111 obj->o_hplus += rnd(3)+1;
112 }
113 else
114 {
115 obj->o_ac = a_class[obj->o_which];
116 if (bless == '-') {
117 obj->o_ac += rnd(3)+1;
118 obj->o_flags |= ISCURSED;
119 }
120 if (bless == '+')
121 obj->o_ac -= rnd(3)+1;
122 }
123 }
124 else if (obj->o_type == RING)
125 switch (obj->o_which)
126 {
127 case R_PROTECT:
128 case R_ADDSTR:
129 case R_ADDHIT:
130 case R_ADDDAM:
131 msg("Blessing? (+,-,n)");
132 bless = readchar(cw);
133 mpos = 0;
134 if (bless == '-')
135 obj->o_flags |= ISCURSED;
136 obj->o_ac = (bless == '-' ? -1 : rnd(2) + 1);
137 }
138 else if (obj->o_type == STICK)
139 fix_stick(obj);
140 add_pack(item, FALSE);
141 }
142
143 /*
144 * telport:
145 * Bamf the hero someplace else
146 */
147
148 int
149 teleport()
150 {
151 int rm;
152 coord c;
153
154 c = hero;
155 mvwaddch(cw, hero.y, hero.x, mvwinch(stdscr, hero.y, hero.x));
156 do
157 {
158 rm = rnd_room();
159 rnd_pos(&rooms[rm], &hero);
160 } until(winat(hero.y, hero.x) == FLOOR);
161 light(&c);
162 light(&hero);
163 mvwaddch(cw, hero.y, hero.x, PLAYER);
164 /*
165 * turn off ISHELD in case teleportation was done while fighting
166 * a Fungi
167 */
168 if (on(player, ISHELD)) {
169 player.t_flags &= ~ISHELD;
170 fung_hit = 0;
171 strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0");
172 }
173 count = 0;
174 running = FALSE;
175 flush_type(); /* flush typeahead */
176 return rm;
177 }
178
179 /*
180 * passwd:
181 * see if user knows password
182 */
183
184 int
185 passwd()
186 {
187 char *sp, c;
188 char buf[80];
189
190 msg("Wizard's Password:");
191 mpos = 0;
192 sp = buf;
193 while ((c = readchar(cw)) != '\n' && c != '\r' && c != '\033')
194 if (c == md_killchar())
195 sp = buf;
196 else if (c == md_erasechar() && sp > buf)
197 sp--;
198 else
199 *sp++ = c;
200 if (sp == buf)
201 return FALSE;
202 *sp = '\0';
203 return (strcmp(PASSWD, crypt(buf, "mT")) == 0);
204 }