comparison rogue4/wizard.c @ 12:9535a08ddc39

Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
author edwarj4
date Sat, 24 Oct 2009 16:52:52 +0000
parents
children 00e90f1bffd6
comparison
equal deleted inserted replaced
11:949d558c2162 12:9535a08ddc39
1
2 /*
3 * Special wizard commands (some of which are also non-wizard commands
4 * under strange circumstances)
5 *
6 * @(#)wizard.c 4.14 (Berkeley) 1/26/82
7 */
8
9 #include <curses.h>
10 #include <ctype.h>
11 #include <string.h>
12 #include "rogue.h"
13
14 /*
15 * whatis:
16 * What a certin object is
17 */
18 whatis(insist)
19 bool insist;
20 {
21 register THING *obj;
22
23 if (pack == NULL)
24 {
25 msg("You don't have anything in your pack to identify");
26 return;
27 }
28
29 for (;;)
30 if ((obj = get_item("identify", 0)) == NULL && insist)
31 msg("You must identify something");
32 else
33 break;
34
35 if (!insist && obj == NULL)
36 return;
37
38 switch (obj->o_type)
39 {
40 case SCROLL:
41 s_know[obj->o_which] = TRUE;
42 if (s_guess[obj->o_which])
43 {
44 free(s_guess[obj->o_which]);
45 s_guess[obj->o_which] = NULL;
46 }
47 when POTION:
48 p_know[obj->o_which] = TRUE;
49 if (p_guess[obj->o_which])
50 {
51 free(p_guess[obj->o_which]);
52 p_guess[obj->o_which] = NULL;
53 }
54 when STICK:
55 ws_know[obj->o_which] = TRUE;
56 obj->o_flags |= ISKNOW;
57 if (ws_guess[obj->o_which])
58 {
59 free(ws_guess[obj->o_which]);
60 ws_guess[obj->o_which] = NULL;
61 }
62 when WEAPON:
63 case ARMOR:
64 obj->o_flags |= ISKNOW;
65 when RING:
66 r_know[obj->o_which] = TRUE;
67 obj->o_flags |= ISKNOW;
68 if (r_guess[obj->o_which])
69 {
70 free(r_guess[obj->o_which]);
71 r_guess[obj->o_which] = NULL;
72 }
73 }
74 msg(inv_name(obj, FALSE));
75 }
76
77 #ifdef WIZARD
78 /*
79 * create_obj:
80 * Wizard command for getting anything he wants
81 */
82 create_obj()
83 {
84 register THING *obj;
85 register char ch, bless;
86
87 obj = new_item();
88 msg("type of item: ");
89 obj->o_type = readchar();
90 mpos = 0;
91 msg("which %c do you want? (0-f)", obj->o_type);
92 obj->o_which = (isdigit((ch = readchar())) ? ch - '0' : ch - 'a' + 10);
93 obj->o_group = 0;
94 obj->o_count = 1;
95 mpos = 0;
96 if (obj->o_type == WEAPON || obj->o_type == ARMOR)
97 {
98 msg("blessing? (+,-,n)");
99 bless = readchar();
100 mpos = 0;
101 if (bless == '-')
102 obj->o_flags |= ISCURSED;
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 if (bless == '+')
109 obj->o_hplus += rnd(3)+1;
110 }
111 else
112 {
113 obj->o_ac = a_class[obj->o_which];
114 if (bless == '-')
115 obj->o_ac += rnd(3)+1;
116 if (bless == '+')
117 obj->o_ac -= rnd(3)+1;
118 }
119 }
120 else if (obj->o_type == RING)
121 switch (obj->o_which)
122 {
123 case R_PROTECT:
124 case R_ADDSTR:
125 case R_ADDHIT:
126 case R_ADDDAM:
127 msg("blessing? (+,-,n)");
128 bless = readchar();
129 mpos = 0;
130 if (bless == '-')
131 obj->o_flags |= ISCURSED;
132 obj->o_ac = (bless == '-' ? -1 : rnd(2) + 1);
133 when R_AGGR:
134 case R_TELEPORT:
135 obj->o_flags |= ISCURSED;
136 }
137 else if (obj->o_type == STICK)
138 fix_stick(obj);
139 else if (obj->o_type == GOLD)
140 {
141 msg("how much?");
142 get_num(&obj->o_goldval, stdscr);
143 }
144 add_pack(obj, FALSE);
145 }
146 #endif
147
148 /*
149 * telport:
150 * Bamf the hero someplace else
151 */
152 teleport()
153 {
154 register int rm;
155 coord c;
156
157 mvaddch(hero.y, hero.x, chat(hero.y, hero.x));
158 do
159 {
160 rm = rnd_room();
161 rnd_pos(&rooms[rm], &c);
162 } until (step_ok(winat(c.y, c.x)));
163 if (&rooms[rm] != proom)
164 {
165 leave_room(&hero);
166 hero = c;
167 enter_room(&hero);
168 }
169 else
170 {
171 hero = c;
172 look(TRUE);
173 }
174 mvaddch(hero.y, hero.x, PLAYER);
175 /*
176 * turn off ISHELD in case teleportation was done while fighting
177 * a Fungi
178 */
179 if (on(player, ISHELD)) {
180 player.t_flags &= ~ISHELD;
181 fung_hit = 0;
182 strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0");
183 }
184 no_move = 0;
185 count = 0;
186 running = FALSE;
187 flush_type();
188 return rm;
189 }
190
191 #ifdef WIZARD
192 /*
193 * passwd:
194 * See if user knows password
195 */
196 passwd()
197 {
198 register char *sp, c;
199 char buf[MAXSTR], *xcrypt();
200
201 msg("wizard's Password:");
202 mpos = 0;
203 sp = buf;
204 while ((c = readchar()) != '\n' && c != '\r' && c != ESCAPE)
205 if (c == md_killchar())
206 sp = buf;
207 else if (c == md_erasechar() && sp > buf)
208 sp--;
209 else
210 *sp++ = c;
211 if (sp == buf)
212 return FALSE;
213 *sp = '\0';
214 return (strcmp(PASSWD, xcrypt(buf, "mT")) == 0);
215 }
216
217 /*
218 * show_map:
219 * Print out the map for the wizard
220 */
221 show_map()
222 {
223 register int y, x, real;
224
225 wclear(hw);
226 for (y = 1; y < LINES - 1; y++)
227 for (x = 0; x < COLS; x++)
228 {
229 if (!(real = flat(y, x) & F_REAL))
230 wstandout(hw);
231 wmove(hw, y, x);
232 waddch(hw, chat(y, x));
233 if (!real)
234 wstandend(hw);
235 }
236 show_win(hw, "---More (level map)---");
237 }
238 #endif