Mercurial > hg > early-roguelike
comparison xrogue/wizard.c @ 133:e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
author | John "Elwin" Edwards |
---|---|
date | Tue, 21 Apr 2015 08:55:20 -0400 |
parents | |
children | ce0cf824c192 |
comparison
equal
deleted
inserted
replaced
124:d10fc4a065ac | 133:e6179860cb76 |
---|---|
1 /* | |
2 wizard.c - Special wizard commands | |
3 | |
4 XRogue: Expeditions into the Dungeons of Doom | |
5 Copyright (C) 1991 Robert Pietkivitch | |
6 All rights reserved. | |
7 | |
8 Based on "Advanced Rogue" | |
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
10 All rights reserved. | |
11 | |
12 Based on "Rogue: Exploring the Dungeons of Doom" | |
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
14 All rights reserved. | |
15 | |
16 See the file LICENSE.TXT for full copyright and licensing information. | |
17 */ | |
18 | |
19 /* | |
20 * Special wizard commands (some of which are also non-wizard commands | |
21 * under strange circumstances) | |
22 */ | |
23 | |
24 #include <curses.h> | |
25 #include <ctype.h> | |
26 #include <string.h> | |
27 #include "rogue.h" | |
28 #include "mach_dep.h" | |
29 | |
30 /* | |
31 * create_obj: | |
32 * Create any object for wizard, scroll, magician, or cleric | |
33 */ | |
34 | |
35 create_obj(prompt, which_item, which_type) | |
36 bool prompt; | |
37 int which_item, which_type; | |
38 { | |
39 reg struct linked_list *item; | |
40 reg struct object *obj; | |
41 reg int wh; | |
42 char *pt; | |
43 reg int ch, whc, newtype = 0, msz, newitem; | |
44 WINDOW *thiswin; | |
45 | |
46 thiswin = cw; | |
47 if (prompt) { | |
48 bool nogood = TRUE; | |
49 | |
50 thiswin = hw; | |
51 wclear(hw); | |
52 wprintw(hw,"Item\t\t\tKey\n\n"); | |
53 wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_RING].mi_name,RING, | |
54 things[TYP_STICK].mi_name,STICK); | |
55 wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_POTION].mi_name,POTION, | |
56 things[TYP_SCROLL].mi_name,SCROLL); | |
57 wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_ARMOR].mi_name,ARMOR, | |
58 things[TYP_WEAPON].mi_name,WEAPON); | |
59 wprintw(hw,"%s\t%c\n",things[TYP_MM].mi_name,MM); | |
60 wprintw(hw,"%s\t\t\t%c\n",things[TYP_FOOD].mi_name,FOOD); | |
61 if (wizard) { | |
62 wprintw(hw,"%s\t\t%c\n",things[TYP_RELIC].mi_name,RELIC); | |
63 wprintw(hw,"monster\t\t\tm"); | |
64 } | |
65 wprintw(hw,"\n\nWhat do you want to create? "); | |
66 draw(hw); | |
67 do { | |
68 ch = wgetch(hw); | |
69 if (ch == ESC) { | |
70 restscr(cw); | |
71 return; | |
72 } | |
73 switch (ch) { | |
74 case RING: | |
75 case STICK: | |
76 case POTION: | |
77 case SCROLL: | |
78 case ARMOR: | |
79 case WEAPON: | |
80 case FOOD: | |
81 case MM: | |
82 nogood = FALSE; | |
83 break; | |
84 case RELIC: | |
85 case 'm': | |
86 if (wizard) | |
87 nogood = FALSE; | |
88 break; | |
89 default: | |
90 nogood = TRUE; | |
91 } | |
92 } while (nogood); | |
93 newitem = ch; | |
94 } | |
95 else | |
96 newitem = which_item; | |
97 | |
98 pt = "those"; | |
99 msz = 0; | |
100 if(newitem == 'm') { | |
101 /* make monster and be done with it */ | |
102 wh = makemonster(TRUE, "create"); | |
103 if (wh > 0) { | |
104 creat_mons (&player, wh, TRUE); | |
105 light(&hero); | |
106 } | |
107 return; | |
108 } | |
109 if(newitem == GOLD) pt = "gold"; | |
110 else if(isatrap(newitem)) pt = "traps"; | |
111 | |
112 switch(newitem) { | |
113 case POTION: whc = TYP_POTION; msz = MAXPOTIONS; | |
114 when SCROLL: whc = TYP_SCROLL; msz = MAXSCROLLS; | |
115 when WEAPON: whc = TYP_WEAPON; msz = MAXWEAPONS; | |
116 when ARMOR: whc = TYP_ARMOR; msz = MAXARMORS; | |
117 when RING: whc = TYP_RING; msz = MAXRINGS; | |
118 when STICK: whc = TYP_STICK; msz = MAXSTICKS; | |
119 when MM: whc = TYP_MM; msz = MAXMM; | |
120 when RELIC: whc = TYP_RELIC; msz = MAXRELIC; | |
121 when FOOD: whc = TYP_FOOD; msz = MAXFOODS; | |
122 otherwise: | |
123 if (thiswin == hw) | |
124 restscr(cw); | |
125 mpos = 0; | |
126 msg("Even wizards can't create %s !!",pt); | |
127 return; | |
128 } | |
129 if(msz == 1) { /* if only one type of item */ | |
130 ch = 'a'; | |
131 } | |
132 else if (prompt) { | |
133 register struct magic_item *wmi; | |
134 char wmn; | |
135 register int ii; | |
136 int old_prob; | |
137 | |
138 mpos = 0; | |
139 wmi = NULL; | |
140 wmn = 0; | |
141 switch(newitem) { | |
142 case POTION: wmi = &p_magic[0]; | |
143 when SCROLL: wmi = &s_magic[0]; | |
144 when RING: wmi = &r_magic[0]; | |
145 when STICK: wmi = &ws_magic[0]; | |
146 when MM: wmi = &m_magic[0]; | |
147 when RELIC: wmi = &rel_magic[0]; | |
148 when FOOD: wmi = &foods[0]; | |
149 when WEAPON: wmn = 1; | |
150 when ARMOR: wmn = 2; | |
151 } | |
152 wclear(hw); | |
153 thiswin = hw; | |
154 if (wmi != NULL) { | |
155 ii = old_prob = 0; | |
156 while (ii < msz) { | |
157 if(wmi->mi_prob == old_prob && wizard == FALSE) { | |
158 msz--; /* can't make a unique item */ | |
159 } | |
160 else { | |
161 mvwaddch(hw,ii % 13,ii > 12 ? cols/2 : 0, ii + 'a'); | |
162 waddstr(hw,") "); | |
163 waddstr(hw,wmi->mi_name); | |
164 ii++; | |
165 } | |
166 old_prob = wmi->mi_prob; | |
167 wmi++; | |
168 } | |
169 } | |
170 else if (wmn != 0) { | |
171 for(ii = 0 ; ii < msz ; ii++) { | |
172 mvwaddch(hw,ii % 13,ii > 12 ? cols/2 : 0, ii + 'a'); | |
173 waddstr(hw,") "); | |
174 if(wmn == 1) | |
175 waddstr(hw,weaps[ii].w_name); | |
176 else | |
177 waddstr(hw,armors[ii].a_name); | |
178 } | |
179 } | |
180 sprintf(prbuf,"Which %s? ",things[whc].mi_name); | |
181 mvwaddstr(hw,lines - 1, 0, prbuf); | |
182 draw(hw); | |
183 do { | |
184 ch = wgetch(hw); | |
185 if (ch == ESC) { | |
186 restscr(cw); | |
187 msg(""); | |
188 return; | |
189 } | |
190 } until (isalpha(ch)); | |
191 if (thiswin == hw) /* restore screen if need be */ | |
192 restscr(cw); | |
193 newtype = ch - 'a'; | |
194 if(newtype < 0 || newtype >= msz) { /* if an illegal value */ | |
195 mpos = 0; | |
196 msg("There is no such %s",things[whc].mi_name); | |
197 return; | |
198 } | |
199 } | |
200 else | |
201 newtype = which_type; | |
202 item = new_item(sizeof *obj); /* get some memory */ | |
203 obj = OBJPTR(item); | |
204 obj->o_type = newitem; /* store the new items */ | |
205 obj->o_mark[0] = '\0'; | |
206 obj->o_which = newtype; | |
207 obj->o_group = 0; | |
208 obj->contents = NULL; | |
209 obj->o_count = 1; | |
210 obj->o_flags = 0; | |
211 obj->o_dplus = obj->o_hplus = 0; | |
212 obj->o_weight = 0; | |
213 wh = obj->o_which; | |
214 mpos = 0; | |
215 if (!wizard) /* users get 0 to +5 */ | |
216 whc = rnd(6); | |
217 else /* wizard gets to choose */ | |
218 whc = getbless(); | |
219 if (whc < 0) | |
220 obj->o_flags |= ISCURSED; | |
221 switch (obj->o_type) { | |
222 case WEAPON: | |
223 case ARMOR: | |
224 if (obj->o_type == WEAPON) { | |
225 init_weapon(obj, wh); | |
226 obj->o_hplus += whc; | |
227 if (!wizard) whc = rnd(6); | |
228 obj->o_dplus += whc; | |
229 } | |
230 else { /* armor here */ | |
231 obj->o_weight = armors[wh].a_wght; | |
232 obj->o_ac = armors[wh].a_class - whc; | |
233 } | |
234 when RING: | |
235 r_know[wh] = TRUE; | |
236 switch(wh) { | |
237 case R_ADDSTR: | |
238 case R_ADDWISDOM: | |
239 case R_ADDINTEL: | |
240 case R_PROTECT: | |
241 case R_ADDHIT: | |
242 case R_ADDDAM: | |
243 case R_DIGEST: | |
244 obj->o_ac = whc + 2; | |
245 break; | |
246 default: | |
247 obj->o_ac = 0; | |
248 } | |
249 obj->o_weight = things[TYP_RING].mi_wght; | |
250 when MM: | |
251 if (whc > 1 && m_magic[wh].mi_bless != 0) | |
252 obj->o_flags |= ISBLESSED; | |
253 m_know[wh] = TRUE; | |
254 switch(wh) { | |
255 case MM_JUG: | |
256 switch(rnd(11)) { | |
257 case 0: obj->o_ac = P_PHASE; | |
258 when 1: obj->o_ac = P_CLEAR; | |
259 when 2: obj->o_ac = P_SEEINVIS; | |
260 when 3: obj->o_ac = P_HEALING; | |
261 when 4: obj->o_ac = P_MFIND; | |
262 when 5: obj->o_ac = P_TFIND; | |
263 when 6: obj->o_ac = P_HASTE; | |
264 when 7: obj->o_ac = P_RESTORE; | |
265 when 8: obj->o_ac = P_FLY; | |
266 when 9: obj->o_ac = P_SKILL; | |
267 when 10:obj->o_ac = P_FFIND; | |
268 } | |
269 when MM_HUNGER: | |
270 case MM_CHOKE: | |
271 if (whc < 0 ) | |
272 whc = -whc; /* cannot be negative */ | |
273 obj->o_ac = (whc + 1) * 2; | |
274 break; | |
275 when MM_OPEN: | |
276 case MM_DRUMS: | |
277 case MM_DISAPPEAR: | |
278 case MM_KEOGHTOM: | |
279 if (whc < 0) | |
280 whc = -whc; /* these cannot be negative */ | |
281 obj->o_ac = (whc + 3) * 5; | |
282 break; | |
283 when MM_BRACERS: | |
284 obj->o_ac = whc + 4; | |
285 when MM_DISP: | |
286 obj->o_ac = 3; | |
287 when MM_PROTECT: | |
288 obj->o_ac = whc + 4; | |
289 when MM_SKILLS: | |
290 if (whc < 2) | |
291 obj->o_ac = rnd(NUM_CHARTYPES-1); | |
292 else | |
293 obj->o_ac = player.t_ctype; | |
294 when MM_CRYSTAL: | |
295 obj->o_ac = 1; | |
296 otherwise: | |
297 obj->o_ac = 0; | |
298 } | |
299 obj->o_weight = things[TYP_MM].mi_wght; | |
300 when STICK: | |
301 if (whc > 1 && ws_magic[wh].mi_bless != 0) | |
302 obj->o_flags |= ISBLESSED; | |
303 ws_know[wh] = TRUE; | |
304 fix_stick(obj); | |
305 when SCROLL: | |
306 if (whc > 3 && s_magic[wh].mi_bless != 0) | |
307 obj->o_flags |= ISBLESSED; | |
308 obj->o_weight = things[TYP_SCROLL].mi_wght; | |
309 s_know[wh] = TRUE; | |
310 when POTION: | |
311 if (whc > 3 && p_magic[wh].mi_bless != 0) | |
312 obj->o_flags |= ISBLESSED; | |
313 obj->o_weight = things[TYP_POTION].mi_wght; | |
314 if (wh == P_ABIL) obj->o_kind = rnd(NUMABILITIES); | |
315 p_know[wh] = TRUE; | |
316 when RELIC: | |
317 obj->o_weight = things[TYP_RELIC].mi_wght; | |
318 switch (obj->o_which) { | |
319 case QUILL_NAGROM: obj->o_charges = QUILLCHARGES; | |
320 when EMORI_CLOAK: obj->o_charges = 1; | |
321 otherwise: break; | |
322 } | |
323 when FOOD: | |
324 obj->o_weight = things[TYP_FOOD].mi_wght; | |
325 } | |
326 mpos = 0; | |
327 obj->o_flags |= ISKNOW; | |
328 if (add_pack(item, FALSE) == FALSE) { | |
329 obj->o_pos = hero; | |
330 fall(item, TRUE); | |
331 } | |
332 } | |
333 | |
334 /* | |
335 * getbless: | |
336 * Get a blessing for a wizards object | |
337 */ | |
338 | |
339 int | |
340 getbless() | |
341 { | |
342 reg char bless; | |
343 | |
344 msg("Blessing? (+,-,n)"); | |
345 bless = wgetch(msgw); | |
346 if (bless == '+') | |
347 return (15); | |
348 else if (bless == '-') | |
349 return (-1); | |
350 else | |
351 return (0); | |
352 } | |
353 | |
354 /* | |
355 * get a non-monster death type | |
356 */ | |
357 | |
358 getdeath() | |
359 { | |
360 register int i; | |
361 int which_death; | |
362 char label[80]; | |
363 | |
364 clear(); | |
365 for (i=0; i<DEATHNUM; i++) { | |
366 sprintf(label, "[%d] %s", i+1, deaths[i].name); | |
367 mvaddstr(i+2, 0, label); | |
368 } | |
369 mvaddstr(0, 0, "Which death? "); | |
370 refresh(); | |
371 | |
372 /* Get the death */ | |
373 for (;;) { | |
374 get_str(label, stdscr); | |
375 which_death = atoi(label); | |
376 if ((which_death < 1 || which_death > DEATHNUM)) { | |
377 mvaddstr(0, 0, "Please enter a number in the displayed range -- "); | |
378 refresh(); | |
379 } | |
380 else break; | |
381 } | |
382 return(deaths[which_death-1].reason); | |
383 } | |
384 | |
385 /* | |
386 * make a monster for the wizard | |
387 */ | |
388 | |
389 makemonster(showall, action) | |
390 bool showall; /* showall -> show uniques and genocided creatures */ | |
391 char *action; | |
392 { | |
393 register int i; | |
394 register short which_monst; | |
395 register int num_monst = NUMMONST, pres_monst=1, num_lines=2*(lines-3); | |
396 int max_monster; | |
397 char monst_name[40]; | |
398 | |
399 /* If we're not showing all, subtract UNIQUES, DINOS, and quartermaster */ | |
400 if (!showall) num_monst -= NUMUNIQUE + NUMDINOS + 1; | |
401 max_monster = num_monst; | |
402 | |
403 /* Print out the monsters */ | |
404 | |
405 if (levtype == OUTSIDE) { | |
406 num_monst = NUMDINOS; | |
407 max_monster = NUMMONST - 1; | |
408 pres_monst = (pres_monst + NUMMONST - NUMDINOS - 1); | |
409 } | |
410 | |
411 while (num_monst > 0) { | |
412 register int left_limit; | |
413 | |
414 if (num_monst < num_lines) left_limit = (num_monst+1)/2; | |
415 else left_limit = num_lines/2; | |
416 | |
417 wclear(hw); | |
418 touchwin(hw); | |
419 | |
420 /* Print left column */ | |
421 wmove(hw, 2, 0); | |
422 for (i=0; i<left_limit; i++) { | |
423 sprintf(monst_name, "[%d] %c%s\n", | |
424 pres_monst, | |
425 (showall || monsters[pres_monst].m_normal) | |
426 ? ' ' | |
427 : '*', | |
428 monsters[pres_monst].m_name); | |
429 waddstr(hw, monst_name); | |
430 pres_monst++; | |
431 } | |
432 | |
433 /* Print right column */ | |
434 for (i=0; i<left_limit && pres_monst<=max_monster; i++) { | |
435 sprintf(monst_name, "[%d] %c%s", | |
436 pres_monst, | |
437 (showall || monsters[pres_monst].m_normal) | |
438 ? ' ' | |
439 : '*', | |
440 monsters[pres_monst].m_name); | |
441 wmove(hw, i+2, cols/2); | |
442 waddstr(hw, monst_name); | |
443 pres_monst++; | |
444 } | |
445 | |
446 if ((num_monst -= num_lines) > 0) { | |
447 mvwaddstr(hw, lines-1, 0, morestr); | |
448 draw(hw); | |
449 wait_for(' '); | |
450 } | |
451 | |
452 else { | |
453 mvwaddstr(hw, 0, 0, "Which monster"); | |
454 if (!terse) { | |
455 waddstr(hw, " do you wish to "); | |
456 waddstr(hw, action); | |
457 } | |
458 waddstr(hw, "? "); | |
459 draw(hw); | |
460 } | |
461 } | |
462 | |
463 get_monst: | |
464 get_str(monst_name, hw); | |
465 which_monst = atoi(monst_name); | |
466 if (levtype == OUTSIDE) | |
467 if ((which_monst < NUMMONST-NUMDINOS || which_monst > max_monster)) { | |
468 mvwaddstr(hw, 0, 0, "Please enter a number in the displayed range -- "); | |
469 draw(hw); | |
470 goto get_monst; | |
471 } | |
472 if ((which_monst < 1 || which_monst > max_monster)) { | |
473 mvwaddstr(hw, 0, 0, "Please enter a number in the displayed range -- "); | |
474 draw(hw); | |
475 goto get_monst; | |
476 } | |
477 restscr(cw); | |
478 return(which_monst); | |
479 } | |
480 | |
481 /* | |
482 * passwd: | |
483 * see if user knows password | |
484 */ | |
485 | |
486 bool | |
487 passwd() | |
488 { | |
489 register char *sp, c; | |
490 char buf[LINELEN]; | |
491 | |
492 msg("Wizard's Password:"); | |
493 mpos = 0; | |
494 sp = buf; | |
495 while ((c = wgetch(cw)) != '\n' && c != '\r' && c != '\033') { | |
496 if (c == killchar()) | |
497 sp = buf; | |
498 else if (c == erasechar() && sp > buf) | |
499 sp--; | |
500 else | |
501 *sp++ = c; | |
502 } | |
503 if (sp == buf) | |
504 return FALSE; | |
505 *sp = '\0'; | |
506 return (strcmp(PASSWD, xcrypt(buf, "mT")) == 0); | |
507 | |
508 /* don't mess with the password here or elsewhere. | |
509 * | |
510 * If anyone goes wizard they forfeit being placed in the scorefile. | |
511 * So, no need to be secretive about it. Let them have it! | |
512 * | |
513 * Additionally, you can begin the game as wizard by starting it | |
514 * with a null argument, as in: xrogue "" | |
515 */ | |
516 } | |
517 | |
518 /* | |
519 * teleport: | |
520 * Bamf the hero someplace else | |
521 */ | |
522 | |
523 void | |
524 teleport() | |
525 { | |
526 register struct room *new_rp = NULL, *old_rp = roomin(&hero); | |
527 register int rm, which; | |
528 coord old; | |
529 bool got_position = FALSE; | |
530 | |
531 /* Disrupt whatever the hero was doing */ | |
532 dsrpt_player(); | |
533 | |
534 /* | |
535 * If the hero wasn't doing something disruptable, NULL out his | |
536 * action anyway and let him know about it. We don't want him | |
537 * swinging or moving into his old place. | |
538 */ | |
539 if (player.t_action != A_NIL) { | |
540 player.t_action = A_NIL; | |
541 msg("You feel momentarily disoriented."); | |
542 } | |
543 | |
544 old = hero; | |
545 mvwaddch(cw, hero.y, hero.x, mvwinch(stdscr, hero.y, hero.x)); | |
546 if (ISWEARING(R_TELCONTROL) || wizard) { | |
547 got_position = move_hero(H_TELEPORT); | |
548 if (!got_position) | |
549 msg("Your attempt fails."); | |
550 else { | |
551 new_rp = roomin(&hero); | |
552 msg("You teleport successfully."); | |
553 } | |
554 } | |
555 if (!got_position) { | |
556 do { | |
557 rm = rnd_room(); | |
558 rnd_pos(&rooms[rm], &hero); | |
559 } until(winat(hero.y, hero.x) == FLOOR); | |
560 new_rp = &rooms[rm]; | |
561 } | |
562 player.t_oldpos = old; /* Save last position */ | |
563 | |
564 /* If hero gets moved, darken old room */ | |
565 if (old_rp && old_rp != new_rp) { | |
566 old_rp->r_flags |= FORCEDARK; /* Fake darkness */ | |
567 light(&old); | |
568 old_rp->r_flags &= ~FORCEDARK; /* Restore light state */ | |
569 } | |
570 | |
571 /* Darken where we just came from */ | |
572 else if (levtype == MAZELEV) light(&old); | |
573 | |
574 light(&hero); | |
575 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
576 /* if entering a treasure room, wake everyone up......Surprise! */ | |
577 if (new_rp->r_flags & ISTREAS) | |
578 wake_room(new_rp); | |
579 | |
580 /* Reset current room and position */ | |
581 oldrp = new_rp; /* Used in look() */ | |
582 player.t_oldpos = hero; | |
583 /* | |
584 * make sure we set/unset the ISINWALL on a teleport | |
585 */ | |
586 which = winat(hero.y, hero.x); | |
587 if (isrock(which)) turn_on(player, ISINWALL); | |
588 else turn_off(player, ISINWALL); | |
589 | |
590 /* | |
591 * turn off ISHELD in case teleportation was done while fighting | |
592 * something that holds you | |
593 */ | |
594 if (on(player, ISHELD)) { | |
595 register struct linked_list *ip, *nip; | |
596 register struct thing *mp; | |
597 | |
598 turn_off(player, ISHELD); | |
599 hold_count = 0; | |
600 for (ip = mlist; ip; ip = nip) { | |
601 mp = THINGPTR(ip); | |
602 nip = next(ip); | |
603 if (on(*mp, DIDHOLD)) { | |
604 turn_off(*mp, DIDHOLD); | |
605 turn_on(*mp, CANHOLD); | |
606 } | |
607 turn_off(*mp, DIDSUFFOCATE); /* Suffocation -- see below */ | |
608 } | |
609 } | |
610 | |
611 /* Make sure player does not suffocate */ | |
612 extinguish(suffocate); | |
613 | |
614 count = 0; | |
615 running = FALSE; | |
616 flushinp(); | |
617 } | |
618 | |
619 /* | |
620 * whatis: | |
621 * What a certin object is | |
622 */ | |
623 | |
624 whatis(what) | |
625 struct linked_list *what; | |
626 { | |
627 register struct object *obj; | |
628 register struct linked_list *item; | |
629 | |
630 if (what == NULL) { /* do we need to ask which one? */ | |
631 if ((item = get_item(pack, "identify", IDENTABLE, FALSE, FALSE))==NULL) | |
632 return; | |
633 } | |
634 else | |
635 item = what; | |
636 obj = OBJPTR(item); | |
637 switch (obj->o_type) { | |
638 case SCROLL: | |
639 s_know[obj->o_which] = TRUE; | |
640 if (s_guess[obj->o_which]) { | |
641 free(s_guess[obj->o_which]); | |
642 s_guess[obj->o_which] = NULL; | |
643 } | |
644 when POTION: | |
645 p_know[obj->o_which] = TRUE; | |
646 if (p_guess[obj->o_which]) { | |
647 free(p_guess[obj->o_which]); | |
648 p_guess[obj->o_which] = NULL; | |
649 } | |
650 when STICK: | |
651 ws_know[obj->o_which] = TRUE; | |
652 if (ws_guess[obj->o_which]) { | |
653 free(ws_guess[obj->o_which]); | |
654 ws_guess[obj->o_which] = NULL; | |
655 } | |
656 when RING: | |
657 r_know[obj->o_which] = TRUE; | |
658 if (r_guess[obj->o_which]) { | |
659 free(r_guess[obj->o_which]); | |
660 r_guess[obj->o_which] = NULL; | |
661 } | |
662 when MM: | |
663 /* If it's an identified jug, identify its potion */ | |
664 if (obj->o_which == MM_JUG && (obj->o_flags & ISKNOW)) { | |
665 if (obj->o_ac != JUG_EMPTY) | |
666 p_know[obj->o_ac] = TRUE; | |
667 break; | |
668 } | |
669 | |
670 m_know[obj->o_which] = TRUE; | |
671 if (m_guess[obj->o_which]) { | |
672 free(m_guess[obj->o_which]); | |
673 m_guess[obj->o_which] = NULL; | |
674 } | |
675 otherwise: | |
676 break; | |
677 } | |
678 obj->o_flags |= ISKNOW; | |
679 if (what == NULL) | |
680 msg(inv_name(obj, FALSE)); | |
681 } | |
682 | |
683 /* | |
684 * Choose a quest item | |
685 * (if on STARTLEV equipage level = 0) | |
686 */ | |
687 | |
688 choose_qst() | |
689 { | |
690 bool doit = TRUE; | |
691 bool escp = TRUE; | |
692 | |
693 /* let wizard in on this too */ | |
694 if (waswizard == TRUE || (levtype == POSTLEV && level == 0)) { | |
695 wclear(hw); | |
696 touchwin(hw); | |
697 wmove(hw, 2, 0); | |
698 wprintw(hw, "a) Cloak of Emori\n"); | |
699 wprintw(hw, "b) Ankh of Heil\n"); | |
700 wprintw(hw, "c) Quill of Nagrom\n"); | |
701 wprintw(hw, "d) Eye of Vecna\n"); | |
702 wprintw(hw, "e) Ring of Surtur\n"); | |
703 wprintw(hw, "f) Staff of Ming\n"); | |
704 wprintw(hw, "g) Wand of Orcus\n"); | |
705 wprintw(hw, "h) Rod of Asmodeus\n"); | |
706 wprintw(hw, "i) Amulet of Yendor\n"); | |
707 wprintw(hw, "j) Amulet of Stonebones\n"); | |
708 wprintw(hw, "k) Mandolin of Brian\n"); | |
709 wprintw(hw, "l) Horn of Geryon\n"); | |
710 wprintw(hw, "m) Daggers of Musty Doit\n"); | |
711 wprintw(hw, "n) Axe of Aklad\n"); | |
712 wprintw(hw, "o) Morning Star of Hruggek\n"); | |
713 wprintw(hw, "p) Flail of Yeenoghu\n"); | |
714 wprintw(hw, "q) Card of Alteran\n"); | |
715 mvwaddstr(hw, 0, 0, "Select a quest item: "); /* prompt */ | |
716 | |
717 if (menu_overlay) /* Print the selections. The longest line is | |
718 * Hruggek (26 characters). The prompt is 21. | |
719 */ | |
720 over_win(cw, hw, 20, 29, 0, 21, NULL); | |
721 else | |
722 draw(hw); | |
723 | |
724 while (doit) { | |
725 switch (wgetch(cw)) { | |
726 case EOF: | |
727 case ESC: | |
728 escp = FALSE; /* used below */ | |
729 doit = FALSE; | |
730 when 'a': | |
731 quest_item = EMORI_CLOAK; | |
732 doit = FALSE; | |
733 when 'b': | |
734 quest_item = HEIL_ANKH; | |
735 doit = FALSE; | |
736 when 'c': | |
737 quest_item = QUILL_NAGROM; | |
738 doit = FALSE; | |
739 when 'd': | |
740 quest_item = EYE_VECNA; | |
741 doit = FALSE; | |
742 when 'e': | |
743 quest_item = SURTUR_RING; | |
744 doit = FALSE; | |
745 when 'f': | |
746 quest_item = MING_STAFF; | |
747 doit = FALSE; | |
748 when 'g': | |
749 quest_item = ORCUS_WAND; | |
750 doit = FALSE; | |
751 when 'h': | |
752 quest_item = ASMO_ROD; | |
753 doit = FALSE; | |
754 when 'i': | |
755 quest_item = YENDOR_AMULET; | |
756 doit = FALSE; | |
757 when 'j': | |
758 quest_item = STONEBONES_AMULET; | |
759 doit = FALSE; | |
760 when 'k': | |
761 quest_item = BRIAN_MANDOLIN; | |
762 doit = FALSE; | |
763 when 'l': | |
764 quest_item = GERYON_HORN; | |
765 doit = FALSE; | |
766 when 'm': | |
767 quest_item = MUSTY_DAGGER; | |
768 doit = FALSE; | |
769 when 'n': | |
770 quest_item = AXE_AKLAD; | |
771 doit = FALSE; | |
772 when 'o': | |
773 quest_item = HRUGGEK_MSTAR; | |
774 doit = FALSE; | |
775 when 'p': | |
776 quest_item = YEENOGHU_FLAIL; | |
777 doit = FALSE; | |
778 when 'q': | |
779 quest_item = ALTERAN_CARD; | |
780 doit = FALSE; | |
781 otherwise: | |
782 doit = TRUE; | |
783 } | |
784 } | |
785 if (menu_overlay) { | |
786 status(FALSE); | |
787 touchwin(cw); | |
788 if (escp == TRUE) { | |
789 msg("Your quest item is the %s. --More--", | |
790 rel_magic[quest_item].mi_name); | |
791 wait_for(' '); | |
792 } | |
793 return; | |
794 } | |
795 else { | |
796 if (escp == TRUE) { | |
797 wmove(hw, lines-4, 0); | |
798 wprintw(hw, "Your quest item is the %s.", | |
799 rel_magic[quest_item].mi_name); | |
800 } | |
801 wmove(hw, lines-1, 0); | |
802 wprintw(hw, spacemsg); | |
803 draw(hw); | |
804 wait_for(' '); | |
805 wclear(hw); | |
806 draw(hw); | |
807 wmove(cw, 0, 0); | |
808 wclrtoeol(cw); | |
809 status(FALSE); | |
810 touchwin(cw); | |
811 return; | |
812 } | |
813 } | |
814 else { | |
815 msg("You can no longer select a quest item. "); | |
816 return; | |
817 } | |
818 } | |
819 |