OSDN Git Service

update year to 2019
[jnethack/source.git] / src / cmd.c
1 /* NetHack 3.6  cmd.c   $NHDT-Date: 1523306904 2018/04/09 20:48:24 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.281 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2013. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2019            */
9 /* JNetHack may be freely redistributed.  See license for details. */
10
11 #include "hack.h"
12 #include "lev.h"
13 #include "func_tab.h"
14
15 #ifdef ALTMETA
16 STATIC_VAR boolean alt_esc = FALSE;
17 #endif
18
19 struct cmd Cmd = { 0 }; /* flag.h */
20
21 extern const char *hu_stat[];  /* hunger status from eat.c */
22 extern const char *enc_stat[]; /* encumbrance status from botl.c */
23
24 #ifdef UNIX
25 /*
26  * Some systems may have getchar() return EOF for various reasons, and
27  * we should not quit before seeing at least NR_OF_EOFS consecutive EOFs.
28  */
29 #if defined(SYSV) || defined(DGUX) || defined(HPUX)
30 #define NR_OF_EOFS 20
31 #endif
32 #endif
33
34 #define CMD_TRAVEL (char) 0x90
35 #define CMD_CLICKLOOK (char) 0x8F
36
37 #ifdef DEBUG
38 extern int NDECL(wiz_debug_cmd_bury);
39 extern int NDECL(wiz_debug_cmd_traveldisplay);
40 #endif
41
42 #ifdef DUMB /* stuff commented out in extern.h, but needed here */
43 extern int NDECL(doapply);            /**/
44 extern int NDECL(dorub);              /**/
45 extern int NDECL(dojump);             /**/
46 extern int NDECL(doextlist);          /**/
47 extern int NDECL(enter_explore_mode); /**/
48 extern int NDECL(dodrop);             /**/
49 extern int NDECL(doddrop);            /**/
50 extern int NDECL(dodown);             /**/
51 extern int NDECL(doup);               /**/
52 extern int NDECL(donull);             /**/
53 extern int NDECL(dowipe);             /**/
54 extern int NDECL(docallcnd);          /**/
55 extern int NDECL(dotakeoff);          /**/
56 extern int NDECL(doremring);          /**/
57 extern int NDECL(dowear);             /**/
58 extern int NDECL(doputon);            /**/
59 extern int NDECL(doddoremarm);        /**/
60 extern int NDECL(dokick);             /**/
61 extern int NDECL(dofire);             /**/
62 extern int NDECL(dothrow);            /**/
63 extern int NDECL(doeat);              /**/
64 extern int NDECL(done2);              /**/
65 extern int NDECL(vanquished);         /**/
66 extern int NDECL(doengrave);          /**/
67 extern int NDECL(dopickup);           /**/
68 extern int NDECL(ddoinv);             /**/
69 extern int NDECL(dotypeinv);          /**/
70 extern int NDECL(dolook);             /**/
71 extern int NDECL(doprgold);           /**/
72 extern int NDECL(doprwep);            /**/
73 extern int NDECL(doprarm);            /**/
74 extern int NDECL(doprring);           /**/
75 extern int NDECL(dopramulet);         /**/
76 extern int NDECL(doprtool);           /**/
77 extern int NDECL(dosuspend);          /**/
78 extern int NDECL(doforce);            /**/
79 extern int NDECL(doopen);             /**/
80 extern int NDECL(doclose);            /**/
81 extern int NDECL(dosh);               /**/
82 extern int NDECL(dodiscovered);       /**/
83 extern int NDECL(doclassdisco);       /**/
84 extern int NDECL(doset);              /**/
85 extern int NDECL(dotogglepickup);     /**/
86 extern int NDECL(dowhatis);           /**/
87 extern int NDECL(doquickwhatis);      /**/
88 extern int NDECL(dowhatdoes);         /**/
89 extern int NDECL(dohelp);             /**/
90 extern int NDECL(dohistory);          /**/
91 extern int NDECL(doloot);             /**/
92 extern int NDECL(dodrink);            /**/
93 extern int NDECL(dodip);              /**/
94 extern int NDECL(dosacrifice);        /**/
95 extern int NDECL(dopray);             /**/
96 extern int NDECL(dotip);              /**/
97 extern int NDECL(doturn);             /**/
98 extern int NDECL(doredraw);           /**/
99 extern int NDECL(doread);             /**/
100 extern int NDECL(dosave);             /**/
101 extern int NDECL(dosearch);           /**/
102 extern int NDECL(doidtrap);           /**/
103 extern int NDECL(dopay);              /**/
104 extern int NDECL(dosit);              /**/
105 extern int NDECL(dotalk);             /**/
106 extern int NDECL(docast);             /**/
107 extern int NDECL(dovspell);           /**/
108 extern int NDECL(dotele);             /**/
109 extern int NDECL(dountrap);           /**/
110 extern int NDECL(doversion);          /**/
111 extern int NDECL(doextversion);       /**/
112 extern int NDECL(doswapweapon);       /**/
113 extern int NDECL(dowield);            /**/
114 extern int NDECL(dowieldquiver);      /**/
115 extern int NDECL(dozap);              /**/
116 extern int NDECL(doorganize);         /**/
117 #endif /* DUMB */
118
119 static int NDECL(dosuspend_core); /**/
120
121 static int NDECL((*timed_occ_fn));
122
123 STATIC_PTR int NDECL(doherecmdmenu);
124 STATIC_PTR int NDECL(dotherecmdmenu);
125 STATIC_PTR int NDECL(doprev_message);
126 STATIC_PTR int NDECL(timed_occupation);
127 STATIC_PTR int NDECL(doextcmd);
128 STATIC_PTR int NDECL(dotravel);
129 STATIC_PTR int NDECL(doterrain);
130 STATIC_PTR int NDECL(wiz_wish);
131 STATIC_PTR int NDECL(wiz_identify);
132 STATIC_PTR int NDECL(wiz_intrinsic);
133 STATIC_PTR int NDECL(wiz_map);
134 STATIC_PTR int NDECL(wiz_makemap);
135 STATIC_PTR int NDECL(wiz_genesis);
136 STATIC_PTR int NDECL(wiz_where);
137 STATIC_PTR int NDECL(wiz_detect);
138 STATIC_PTR int NDECL(wiz_panic);
139 STATIC_PTR int NDECL(wiz_polyself);
140 STATIC_PTR int NDECL(wiz_level_tele);
141 STATIC_PTR int NDECL(wiz_level_change);
142 STATIC_PTR int NDECL(wiz_show_seenv);
143 STATIC_PTR int NDECL(wiz_show_vision);
144 STATIC_PTR int NDECL(wiz_smell);
145 STATIC_PTR int NDECL(wiz_intrinsic);
146 STATIC_PTR int NDECL(wiz_mon_polycontrol);
147 STATIC_PTR int NDECL(wiz_show_wmodes);
148 STATIC_DCL void NDECL(wiz_map_levltyp);
149 STATIC_DCL void NDECL(wiz_levltyp_legend);
150 #if defined(__BORLANDC__) && !defined(_WIN32)
151 extern void FDECL(show_borlandc_stats, (winid));
152 #endif
153 #ifdef DEBUG_MIGRATING_MONS
154 STATIC_PTR int NDECL(wiz_migrate_mons);
155 #endif
156 STATIC_DCL int FDECL(size_monst, (struct monst *, BOOLEAN_P));
157 STATIC_DCL int FDECL(size_obj, (struct obj *));
158 STATIC_DCL void FDECL(count_obj, (struct obj *, long *, long *,
159                                   BOOLEAN_P, BOOLEAN_P));
160 STATIC_DCL void FDECL(obj_chain, (winid, const char *, struct obj *,
161                                   BOOLEAN_P, long *, long *));
162 STATIC_DCL void FDECL(mon_invent_chain, (winid, const char *, struct monst *,
163                                          long *, long *));
164 STATIC_DCL void FDECL(mon_chain, (winid, const char *, struct monst *,
165                                   BOOLEAN_P, long *, long *));
166 STATIC_DCL void FDECL(contained_stats, (winid, const char *, long *, long *));
167 STATIC_DCL void FDECL(misc_stats, (winid, long *, long *));
168 STATIC_PTR int NDECL(wiz_show_stats);
169 STATIC_DCL boolean FDECL(accept_menu_prefix, (int NDECL((*))));
170 #ifdef PORT_DEBUG
171 STATIC_DCL int NDECL(wiz_port_debug);
172 #endif
173 STATIC_PTR int NDECL(wiz_rumor_check);
174 STATIC_PTR int NDECL(doattributes);
175
176 STATIC_DCL void FDECL(enlght_line, (const char *, const char *, const char *,
177                                     const char *));
178 STATIC_DCL char *FDECL(enlght_combatinc, (const char *, int, int, char *));
179 STATIC_DCL void FDECL(enlght_halfdmg, (int, int));
180 STATIC_DCL boolean NDECL(walking_on_water);
181 STATIC_DCL boolean FDECL(cause_known, (int));
182 STATIC_DCL char *FDECL(attrval, (int, int, char *));
183 STATIC_DCL void FDECL(background_enlightenment, (int, int));
184 STATIC_DCL void FDECL(characteristics_enlightenment, (int, int));
185 STATIC_DCL void FDECL(one_characteristic, (int, int, int));
186 STATIC_DCL void FDECL(status_enlightenment, (int, int));
187 STATIC_DCL void FDECL(attributes_enlightenment, (int, int));
188
189 static const char *readchar_queue = "";
190 static coord clicklook_cc;
191
192 STATIC_DCL void FDECL(add_herecmd_menuitem, (winid, int NDECL((*)),
193                                              const char *));
194 STATIC_DCL char FDECL(here_cmd_menu, (BOOLEAN_P));
195 STATIC_DCL char FDECL(there_cmd_menu, (BOOLEAN_P, int, int));
196 STATIC_DCL char *NDECL(parse);
197 STATIC_DCL void FDECL(show_direction_keys, (winid, CHAR_P, BOOLEAN_P));
198 STATIC_DCL boolean FDECL(help_dir, (CHAR_P, int, const char *));
199
200 STATIC_PTR int
201 doprev_message(VOID_ARGS)
202 {
203     return nh_doprev_message();
204 }
205
206 /* Count down by decrementing multi */
207 STATIC_PTR int
208 timed_occupation(VOID_ARGS)
209 {
210     (*timed_occ_fn)();
211     if (multi > 0)
212         multi--;
213     return multi > 0;
214 }
215
216 /* If you have moved since initially setting some occupations, they
217  * now shouldn't be able to restart.
218  *
219  * The basic rule is that if you are carrying it, you can continue
220  * since it is with you.  If you are acting on something at a distance,
221  * your orientation to it must have changed when you moved.
222  *
223  * The exception to this is taking off items, since they can be taken
224  * off in a number of ways in the intervening time, screwing up ordering.
225  *
226  *      Currently:      Take off all armor.
227  *                      Picking Locks / Forcing Chests.
228  *                      Setting traps.
229  */
230 void
231 reset_occupations()
232 {
233     reset_remarm();
234     reset_pick();
235     reset_trapset();
236 }
237
238 /* If a time is given, use it to timeout this function, otherwise the
239  * function times out by its own means.
240  */
241 void
242 set_occupation(fn, txt, xtime)
243 int NDECL((*fn));
244 const char *txt;
245 int xtime;
246 {
247     if (xtime) {
248         occupation = timed_occupation;
249         timed_occ_fn = fn;
250     } else
251         occupation = fn;
252     occtxt = txt;
253     occtime = 0;
254     return;
255 }
256
257 STATIC_DCL char NDECL(popch);
258
259 /* Provide a means to redo the last command.  The flag `in_doagain' is set
260  * to true while redoing the command.  This flag is tested in commands that
261  * require additional input (like `throw' which requires a thing and a
262  * direction), and the input prompt is not shown.  Also, while in_doagain is
263  * TRUE, no keystrokes can be saved into the saveq.
264  */
265 #define BSIZE 20
266 static char pushq[BSIZE], saveq[BSIZE];
267 static NEARDATA int phead, ptail, shead, stail;
268
269 STATIC_OVL char
270 popch()
271 {
272     /* If occupied, return '\0', letting tgetch know a character should
273      * be read from the keyboard.  If the character read is not the
274      * ABORT character (as checked in pcmain.c), that character will be
275      * pushed back on the pushq.
276      */
277     if (occupation)
278         return '\0';
279     if (in_doagain)
280         return (char) ((shead != stail) ? saveq[stail++] : '\0');
281     else
282         return (char) ((phead != ptail) ? pushq[ptail++] : '\0');
283 }
284
285 char
286 pgetchar() /* courtesy of aeb@cwi.nl */
287 {
288     register int ch;
289
290     if (!(ch = popch()))
291         ch = nhgetch();
292     return (char) ch;
293 }
294
295 /* A ch == 0 resets the pushq */
296 void
297 pushch(ch)
298 char ch;
299 {
300     if (!ch)
301         phead = ptail = 0;
302     if (phead < BSIZE)
303         pushq[phead++] = ch;
304     return;
305 }
306
307 /* A ch == 0 resets the saveq.  Only save keystrokes when not
308  * replaying a previous command.
309  */
310 void
311 savech(ch)
312 char ch;
313 {
314     if (!in_doagain) {
315         if (!ch)
316             phead = ptail = shead = stail = 0;
317         else if (shead < BSIZE)
318             saveq[shead++] = ch;
319     }
320     return;
321 }
322
323 /* here after # - now read a full-word command */
324 STATIC_PTR int
325 doextcmd(VOID_ARGS)
326 {
327     int idx, retval;
328     int NDECL((*func));
329
330     /* keep repeating until we don't run help or quit */
331     do {
332         idx = get_ext_cmd();
333         if (idx < 0)
334             return 0; /* quit */
335
336         func = extcmdlist[idx].ef_funct;
337         if (!wizard && (extcmdlist[idx].flags & WIZMODECMD)) {
338 /*JP
339             You("can't do that.");
340 */
341             pline("\82»\82ê\82Í\82Å\82«\82Ü\82¹\82ñ\81D");
342             return 0;
343         }
344         if (iflags.menu_requested && !accept_menu_prefix(func)) {
345 #if 0 /*JP*/
346             pline("'%s' prefix has no effect for the %s command.",
347                   visctrl(Cmd.spkeys[NHKF_REQMENU]),
348                   extcmdlist[idx].ef_txt);
349 #else
350             pline("'%s'\90Ú\93ª\8e«\82Í%s\83R\83}\83\93\83h\82É\82Í\96³\8cø\81D",
351                   visctrl(Cmd.spkeys[NHKF_REQMENU]),
352                   extcmdlist[idx].ef_txt);
353 #endif
354             iflags.menu_requested = FALSE;
355         }
356         retval = (*func)();
357     } while (func == doextlist);
358
359     return retval;
360 }
361
362 /* here after #? - now list all full-word commands */
363 int
364 doextlist(VOID_ARGS)
365 {
366     register const struct ext_func_tab *efp;
367     char buf[BUFSZ];
368     winid datawin;
369     char ch = cmd_from_func(doextcmd);
370
371     datawin = create_nhwindow(NHW_TEXT);
372     putstr(datawin, 0, "");
373 /*JP
374     putstr(datawin, 0, "            Extended Commands List");
375 */
376     putstr(datawin, 0, "            \8ag\92£\83R\83}\83\93\83h\88ê\97\97");
377     putstr(datawin, 0, "");
378     if (ch) {
379 #if 0 /*JP*/
380         Sprintf(buf, "    Press '%s', then type:",
381                 visctrl(ch));
382 #else
383         Sprintf(buf, "    '%s'\82ð\89\9f\82µ\82½\82 \82Æ\83^\83C\83v\82¹\82æ:",
384                 visctrl(ch));
385 #endif
386         putstr(datawin, 0, buf);
387         putstr(datawin, 0, "");
388     }
389
390     for (efp = extcmdlist; efp->ef_txt; efp++) {
391         if (!wizard && (efp->flags & WIZMODECMD))
392             continue;
393         Sprintf(buf, "   %-15s %c %s.",
394                 efp->ef_txt,
395                 (efp->flags & AUTOCOMPLETE) ? '*' : ' ',
396                 efp->ef_desc);
397         putstr(datawin, 0, buf);
398     }
399     putstr(datawin, 0, "");
400 /*JP
401     putstr(datawin, 0, "    Commands marked with a * will be autocompleted.");
402 */
403     putstr(datawin, 0, "    *\95t\82«\82Ì\83R\83}\83\93\83h\82Í\8e©\93®\95â\8a®\82³\82ê\82Ü\82·\81D");
404     display_nhwindow(datawin, FALSE);
405     destroy_nhwindow(datawin);
406     return 0;
407 }
408
409 #ifdef TTY_GRAPHICS
410 #define MAX_EXT_CMD 200 /* Change if we ever have more ext cmds */
411
412 /*
413  * This is currently used only by the tty interface and is
414  * controlled via runtime option 'extmenu'.  (Most other interfaces
415  * already use a menu all the time for extended commands.)
416  *
417  * ``# ?'' is counted towards the limit of the number of commands,
418  * so we actually support MAX_EXT_CMD-1 "real" extended commands.
419  *
420  * Here after # - now show pick-list of possible commands.
421  */
422 int
423 extcmd_via_menu()
424 {
425     const struct ext_func_tab *efp;
426     menu_item *pick_list = (menu_item *) 0;
427     winid win;
428     anything any;
429     const struct ext_func_tab *choices[MAX_EXT_CMD + 1];
430     char buf[BUFSZ];
431     char cbuf[QBUFSZ], prompt[QBUFSZ], fmtstr[20];
432     int i, n, nchoices, acount;
433     int ret, len, biggest;
434     int accelerator, prevaccelerator;
435     int matchlevel = 0;
436     boolean wastoolong, one_per_line;
437
438     ret = 0;
439     cbuf[0] = '\0';
440     biggest = 0;
441     while (!ret) {
442         i = n = 0;
443         any = zeroany;
444         /* populate choices */
445         for (efp = extcmdlist; efp->ef_txt; efp++) {
446             if (!(efp->flags & AUTOCOMPLETE)
447                 || (!wizard && (efp->flags & WIZMODECMD)))
448                 continue;
449             if (!matchlevel || !strncmp(efp->ef_txt, cbuf, matchlevel)) {
450                 choices[i] = efp;
451                 if ((len = (int) strlen(efp->ef_desc)) > biggest)
452                     biggest = len;
453                 if (++i > MAX_EXT_CMD) {
454 #if defined(BETA)
455                     impossible(
456       "Exceeded %d extended commands in doextcmd() menu; 'extmenu' disabled.",
457                                MAX_EXT_CMD);
458 #endif /* BETA */
459                     iflags.extmenu = 0;
460                     return -1;
461                 }
462             }
463         }
464         choices[i] = (struct ext_func_tab *) 0;
465         nchoices = i;
466         /* if we're down to one, we have our selection so get out of here */
467         if (nchoices  <= 1) {
468             ret = (nchoices == 1) ? (int) (choices[0] - extcmdlist) : -1;
469             break;
470         }
471
472         /* otherwise... */
473         win = create_nhwindow(NHW_MENU);
474         start_menu(win);
475         Sprintf(fmtstr, "%%-%ds", biggest + 15);
476         prompt[0] = '\0';
477         wastoolong = FALSE; /* True => had to wrap due to line width
478                              * ('w' in wizard mode) */
479         /* -3: two line menu header, 1 line menu footer (for prompt) */
480         one_per_line = (nchoices < ROWNO - 3);
481         accelerator = prevaccelerator = 0;
482         acount = 0;
483         for (i = 0; choices[i]; ++i) {
484             accelerator = choices[i]->ef_txt[matchlevel];
485             if (accelerator != prevaccelerator || one_per_line)
486                 wastoolong = FALSE;
487             if (accelerator != prevaccelerator || one_per_line
488                 || (acount >= 2
489                     /* +4: + sizeof " or " - sizeof "" */
490                     && (strlen(prompt) + 4 + strlen(choices[i]->ef_txt)
491                         /* -6: enough room for 1 space left margin
492                          *   + "%c - " menu selector + 1 space right margin */
493                         >= min(sizeof prompt, COLNO - 6)))) {
494                 if (acount) {
495                     /* flush extended cmds for that letter already in buf */
496                     Sprintf(buf, fmtstr, prompt);
497                     any.a_char = prevaccelerator;
498                     add_menu(win, NO_GLYPH, &any, any.a_char, 0, ATR_NONE,
499                              buf, FALSE);
500                     acount = 0;
501                     if (!(accelerator != prevaccelerator || one_per_line))
502                         wastoolong = TRUE;
503                 }
504             }
505             prevaccelerator = accelerator;
506             if (!acount || one_per_line) {
507 #if 0 /*JP:T*/
508                 Sprintf(prompt, "%s%s [%s]", wastoolong ? "or " : "",
509                         choices[i]->ef_txt, choices[i]->ef_desc);
510 #else
511                 Sprintf(prompt, "%s%s [%s]", wastoolong ? "\82Ü\82½\82Í" : "",
512                         choices[i]->ef_txt, choices[i]->ef_desc);
513 #endif
514             } else if (acount == 1) {
515 #if 0 /*JP:T*/
516                 Sprintf(prompt, "%s%s or %s", wastoolong ? "or " : "",
517                         choices[i - 1]->ef_txt, choices[i]->ef_txt);
518 #else
519                 Sprintf(prompt, "%s%s\82Ü\82½\82Í%s", wastoolong ? "\82Ü\82½\82Í" : "",
520                         choices[i - 1]->ef_txt, choices[i]->ef_txt);
521 #endif
522             } else {
523 /*JP
524                 Strcat(prompt, " or ");
525 */
526                 Strcat(prompt," \82Ü\82½\82Í ");
527                 Strcat(prompt, choices[i]->ef_txt);
528             }
529             ++acount;
530         }
531         if (acount) {
532             /* flush buf */
533             Sprintf(buf, fmtstr, prompt);
534             any.a_char = prevaccelerator;
535             add_menu(win, NO_GLYPH, &any, any.a_char, 0, ATR_NONE, buf,
536                      FALSE);
537         }
538 /*JP
539         Sprintf(prompt, "Extended Command: %s", cbuf);
540 */
541         Sprintf(prompt, "\8ag\92£\83R\83}\83\93\83h: %s", cbuf);
542         end_menu(win, prompt);
543         n = select_menu(win, PICK_ONE, &pick_list);
544         destroy_nhwindow(win);
545         if (n == 1) {
546             if (matchlevel > (QBUFSZ - 2)) {
547                 free((genericptr_t) pick_list);
548 #if defined(BETA)
549                 impossible("Too many chars (%d) entered in extcmd_via_menu()",
550                            matchlevel);
551 #endif
552                 ret = -1;
553             } else {
554                 cbuf[matchlevel++] = pick_list[0].item.a_char;
555                 cbuf[matchlevel] = '\0';
556                 free((genericptr_t) pick_list);
557             }
558         } else {
559             if (matchlevel) {
560                 ret = 0;
561                 matchlevel = 0;
562             } else
563                 ret = -1;
564         }
565     }
566     return ret;
567 }
568 #endif /* TTY_GRAPHICS */
569
570 /* #monster command - use special monster ability while polymorphed */
571 int
572 domonability(VOID_ARGS)
573 {
574     if (can_breathe(youmonst.data))
575         return dobreathe();
576     else if (attacktype(youmonst.data, AT_SPIT))
577         return dospit();
578     else if (youmonst.data->mlet == S_NYMPH)
579         return doremove();
580     else if (attacktype(youmonst.data, AT_GAZE))
581         return dogaze();
582     else if (is_were(youmonst.data))
583         return dosummon();
584     else if (webmaker(youmonst.data))
585         return dospinweb();
586     else if (is_hider(youmonst.data))
587         return dohide();
588     else if (is_mind_flayer(youmonst.data))
589         return domindblast();
590     else if (u.umonnum == PM_GREMLIN) {
591         if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)) {
592             if (split_mon(&youmonst, (struct monst *) 0))
593                 dryup(u.ux, u.uy, TRUE);
594         } else
595 /*JP
596             There("is no fountain here.");
597 */
598             pline("\82±\82±\82É\82Í\90ò\82Í\82È\82¢\81D");
599     } else if (is_unicorn(youmonst.data)) {
600         use_unicorn_horn((struct obj *) 0);
601         return 1;
602     } else if (youmonst.data->msound == MS_SHRIEK) {
603 /*JP
604         You("shriek.");
605 */
606         You("\8bà\90Ø\82è\90º\82ð\82 \82°\82½\81D");
607         if (u.uburied)
608 /*JP
609             pline("Unfortunately sound does not carry well through rock.");
610 */
611             pline("\8ec\94O\82È\82ª\82ç\89¹\82Í\8aâ\82ð\82¤\82Ü\82­\93`\82í\82ç\82È\82¢\81D");
612         else
613             aggravate();
614     } else if (youmonst.data->mlet == S_VAMPIRE)
615         return dopoly();
616     else if (Upolyd)
617 /*JP
618         pline("Any special ability you may have is purely reflexive.");
619 */
620         pline("\82 \82È\82½\82Ì\8e\9d\82Á\82Ä\82¢\82é\93Á\8eê\94\\97Í\82Í\82Ç\82ê\82à\8eó\93®\93I\82¾\81D");
621     else
622 /*JP
623         You("don't have a special ability in your normal form!");
624 */
625         You("\95\81\92i\82Ì\8ep\82Å\82Ì\93Á\8eê\94\\97Í\82ð\8e\9d\82Á\82Ä\82¢\82È\82¢\81I");
626     return 0;
627 }
628
629 int
630 enter_explore_mode(VOID_ARGS)
631 {
632     if (wizard) {
633 /*JP
634         You("are in debug mode.");
635 */
636         You("\82·\82Å\82É\83f\83o\83b\83O\83\82\81[\83h\82¾\81D");
637     } else if (discover) {
638 /*JP
639         You("are already in explore mode.");
640 */
641         You("\82·\82Å\82É\92T\8c\9f\83\82\81[\83h\82¾\81D");
642     } else {
643 #ifdef SYSCF
644 #if defined(UNIX)
645         if (!sysopt.explorers || !sysopt.explorers[0]
646             || !check_user_string(sysopt.explorers)) {
647 /*JP
648             You("cannot access explore mode.");
649 */
650             You("\92T\8c\9f\83\82\81[\83h\82É\83A\83N\83Z\83X\82Å\82«\82È\82¢\81D");
651             return 0;
652         }
653 #endif
654 #endif
655         pline(
656 /*JP
657         "Beware!  From explore mode there will be no return to normal game.");
658 */
659         "\8cx\8d\90\81I\94­\8c©\83\82\81[\83h\82É\93ü\82Á\82½\82ç\92Ê\8fí\83\82\81[\83h\82É\82Í\96ß\82ê\82È\82¢\81D");
660         if (paranoid_query(ParanoidQuit,
661 /*JP
662                            "Do you want to enter explore mode?")) {
663 */
664                            "\94­\8c©\83\82\81[\83h\82É\88Ú\82è\82Ü\82·\82©\81H")) {
665             clear_nhwindow(WIN_MESSAGE);
666 /*JP
667             You("are now in non-scoring explore mode.");
668 */
669             You("\83X\83R\83A\82ª\82Ì\82ç\82È\82¢\94­\8c©\83\82\81[\83h\82É\88Ú\8ds\82µ\82½\81D");
670             discover = TRUE;
671         } else {
672             clear_nhwindow(WIN_MESSAGE);
673 /*JP
674             pline("Resuming normal game.");
675 */
676             pline("\92Ê\8fí\83\82\81[\83h\82ð\91±\82¯\82é\81D");
677         }
678     }
679     return 0;
680 }
681
682 /* ^W command - wish for something */
683 STATIC_PTR int
684 wiz_wish(VOID_ARGS) /* Unlimited wishes for debug mode by Paul Polderman */
685 {
686     if (wizard) {
687         boolean save_verbose = flags.verbose;
688
689         flags.verbose = FALSE;
690         makewish();
691         flags.verbose = save_verbose;
692         (void) encumber_msg();
693     } else
694 /*JP
695         pline("Unavailable command '%s'.",
696 */
697         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
698               visctrl((int) cmd_from_func(wiz_wish)));
699     return 0;
700 }
701
702 /* ^I command - reveal and optionally identify hero's inventory */
703 STATIC_PTR int
704 wiz_identify(VOID_ARGS)
705 {
706     if (wizard) {
707         iflags.override_ID = (int) cmd_from_func(wiz_identify);
708         if (display_inventory((char *) 0, TRUE) == -1)
709             identify_pack(0, FALSE);
710         iflags.override_ID = 0;
711     } else
712 /*JP
713         pline("Unavailable command '%s'.",
714 */
715         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
716               visctrl((int) cmd_from_func(wiz_identify)));
717     return 0;
718 }
719
720 STATIC_PTR int
721 wiz_makemap(VOID_ARGS)
722 {
723     /* FIXME: doesn't handle riding */
724     if (wizard) {
725         struct monst *mtmp;
726
727         rm_mapseen(ledger_no(&u.uz));
728         for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
729             if (mtmp->isshk)
730                 setpaid(mtmp);
731         if (Punished) {
732             ballrelease(FALSE);
733             unplacebc();
734         }
735         check_special_room(TRUE);
736         dmonsfree();
737         savelev(-1, ledger_no(&u.uz), FREE_SAVE);
738         mklev();
739         vision_reset();
740         vision_full_recalc = 1;
741         cls();
742         (void) safe_teleds(TRUE);
743         if (Punished) {
744             unplacebc();
745             placebc();
746         }
747         docrt();
748         flush_screen(1);
749     }
750     return 0;
751 }
752
753 /* ^F command - reveal the level map and any traps on it */
754 STATIC_PTR int
755 wiz_map(VOID_ARGS)
756 {
757     if (wizard) {
758         struct trap *t;
759         long save_Hconf = HConfusion, save_Hhallu = HHallucination;
760
761         HConfusion = HHallucination = 0L;
762         for (t = ftrap; t != 0; t = t->ntrap) {
763             t->tseen = 1;
764             map_trap(t, TRUE);
765         }
766         do_mapping();
767         HConfusion = save_Hconf;
768         HHallucination = save_Hhallu;
769     } else
770 /*JP
771         pline("Unavailable command '%s'.",
772 */
773         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
774               visctrl((int) cmd_from_func(wiz_map)));
775     return 0;
776 }
777
778 /* ^G command - generate monster(s); a count prefix will be honored */
779 STATIC_PTR int
780 wiz_genesis(VOID_ARGS)
781 {
782     if (wizard)
783         (void) create_particular();
784     else
785 /*JP
786         pline("Unavailable command '%s'.",
787 */
788         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
789               visctrl((int) cmd_from_func(wiz_genesis)));
790     return 0;
791 }
792
793 /* ^O command - display dungeon layout */
794 STATIC_PTR int
795 wiz_where(VOID_ARGS)
796 {
797     if (wizard)
798         (void) print_dungeon(FALSE, (schar *) 0, (xchar *) 0);
799     else
800 /*JP
801         pline("Unavailable command '%s'.",
802 */
803         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
804               visctrl((int) cmd_from_func(wiz_where)));
805     return 0;
806 }
807
808 /* ^E command - detect unseen (secret doors, traps, hidden monsters) */
809 STATIC_PTR int
810 wiz_detect(VOID_ARGS)
811 {
812     if (wizard)
813         (void) findit();
814     else
815 /*JP
816         pline("Unavailable command '%s'.",
817 */
818         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
819               visctrl((int) cmd_from_func(wiz_detect)));
820     return 0;
821 }
822
823 /* ^V command - level teleport */
824 STATIC_PTR int
825 wiz_level_tele(VOID_ARGS)
826 {
827     if (wizard)
828         level_tele();
829     else
830 /*JP
831         pline("Unavailable command '%s'.",
832 */
833         pline("'%s'\83R\83}\83\93\83h\82Í\8eg\82¦\82È\82¢\81D",
834               visctrl((int) cmd_from_func(wiz_level_tele)));
835     return 0;
836 }
837
838 /* #monpolycontrol command - choose new form for shapechangers, polymorphees */
839 STATIC_PTR int
840 wiz_mon_polycontrol(VOID_ARGS)
841 {
842     iflags.mon_polycontrol = !iflags.mon_polycontrol;
843 #if 0 /*JP*/
844     pline("Monster polymorph control is %s.",
845           iflags.mon_polycontrol ? "on" : "off");
846 #else
847     pline("\89ö\95¨\82Ì\95Ï\89»\90§\8cä: %s",
848           iflags.mon_polycontrol ? "\83I\83\93" : "\83I\83t");
849 #endif
850     return 0;
851 }
852
853 /* #levelchange command - adjust hero's experience level */
854 STATIC_PTR int
855 wiz_level_change(VOID_ARGS)
856 {
857     char buf[BUFSZ] = DUMMY;
858     int newlevel;
859     int ret;
860
861 /*JP
862     getlin("To what experience level do you want to be set?", buf);
863 */
864     getlin("\8co\8c±\83\8c\83x\83\8b\82ð\82¢\82­\82Â\82É\90Ý\92è\82µ\82Ü\82·\82©\81H", buf);
865     (void) mungspaces(buf);
866     if (buf[0] == '\033' || buf[0] == '\0')
867         ret = 0;
868     else
869         ret = sscanf(buf, "%d", &newlevel);
870
871     if (ret != 1) {
872         pline1(Never_mind);
873         return 0;
874     }
875     if (newlevel == u.ulevel) {
876 /*JP
877         You("are already that experienced.");
878 */
879         You("\82·\82Å\82É\82»\82Ì\8co\8c±\83\8c\83x\83\8b\82¾\81D");
880     } else if (newlevel < u.ulevel) {
881         if (u.ulevel == 1) {
882 /*JP
883             You("are already as inexperienced as you can get.");
884 */
885             You("\82·\82Å\82É\89Â\94\\82È\8cÀ\82è\82Ì\8dÅ\92á\82Ì\8co\8c±\83\8c\83x\83\8b\82¾\81D");
886             return 0;
887         }
888         if (newlevel < 1)
889             newlevel = 1;
890         while (u.ulevel > newlevel)
891 /*JP
892             losexp("#levelchange");
893 */
894             losexp("#levelchange\83R\83}\83\93\83h\82Å");
895     } else {
896         if (u.ulevel >= MAXULEV) {
897 /*JP
898             You("are already as experienced as you can get.");
899 */
900             You("\82·\82Å\82É\89Â\94\\82È\8cÀ\82è\82Ì\8dÅ\91å\82Ì\8co\8c±\83\8c\83x\83\8b\82¾\81D");
901             return 0;
902         }
903         if (newlevel > MAXULEV)
904             newlevel = MAXULEV;
905         while (u.ulevel < newlevel)
906             pluslvl(FALSE);
907     }
908     u.ulevelmax = u.ulevel;
909     return 0;
910 }
911
912 /* #panic command - test program's panic handling */
913 STATIC_PTR int
914 wiz_panic(VOID_ARGS)
915 {
916 /*JP
917     if (yn("Do you want to call panic() and end your game?") == 'y')
918 */
919     if (yn("panic()\8aÖ\90\94\82ð\8cÄ\82Ñ\8fo\82µ\82Ä\83Q\81[\83\80\82ð\8fI\97¹\82³\82¹\82Ü\82·\82©\81H") == 'y')
920         panic("Crash test.");
921     return 0;
922 }
923
924 /* #polyself command - change hero's form */
925 STATIC_PTR int
926 wiz_polyself(VOID_ARGS)
927 {
928     polyself(1);
929     return 0;
930 }
931
932 /* #seenv command */
933 STATIC_PTR int
934 wiz_show_seenv(VOID_ARGS)
935 {
936     winid win;
937     int x, y, v, startx, stopx, curx;
938     char row[COLNO + 1];
939
940     win = create_nhwindow(NHW_TEXT);
941     /*
942      * Each seenv description takes up 2 characters, so center
943      * the seenv display around the hero.
944      */
945     startx = max(1, u.ux - (COLNO / 4));
946     stopx = min(startx + (COLNO / 2), COLNO);
947     /* can't have a line exactly 80 chars long */
948     if (stopx - startx == COLNO / 2)
949         startx++;
950
951     for (y = 0; y < ROWNO; y++) {
952         for (x = startx, curx = 0; x < stopx; x++, curx += 2) {
953             if (x == u.ux && y == u.uy) {
954                 row[curx] = row[curx + 1] = '@';
955             } else {
956                 v = levl[x][y].seenv & 0xff;
957                 if (v == 0)
958                     row[curx] = row[curx + 1] = ' ';
959                 else
960                     Sprintf(&row[curx], "%02x", v);
961             }
962         }
963         /* remove trailing spaces */
964         for (x = curx - 1; x >= 0; x--)
965             if (row[x] != ' ')
966                 break;
967         row[x + 1] = '\0';
968
969         putstr(win, 0, row);
970     }
971     display_nhwindow(win, TRUE);
972     destroy_nhwindow(win);
973     return 0;
974 }
975
976 /* #vision command */
977 STATIC_PTR int
978 wiz_show_vision(VOID_ARGS)
979 {
980     winid win;
981     int x, y, v;
982     char row[COLNO + 1];
983
984     win = create_nhwindow(NHW_TEXT);
985     Sprintf(row, "Flags: 0x%x could see, 0x%x in sight, 0x%x temp lit",
986             COULD_SEE, IN_SIGHT, TEMP_LIT);
987     putstr(win, 0, row);
988     putstr(win, 0, "");
989     for (y = 0; y < ROWNO; y++) {
990         for (x = 1; x < COLNO; x++) {
991             if (x == u.ux && y == u.uy)
992                 row[x] = '@';
993             else {
994                 v = viz_array[y][x]; /* data access should be hidden */
995                 if (v == 0)
996                     row[x] = ' ';
997                 else
998                     row[x] = '0' + viz_array[y][x];
999             }
1000         }
1001         /* remove trailing spaces */
1002         for (x = COLNO - 1; x >= 1; x--)
1003             if (row[x] != ' ')
1004                 break;
1005         row[x + 1] = '\0';
1006
1007         putstr(win, 0, &row[1]);
1008     }
1009     display_nhwindow(win, TRUE);
1010     destroy_nhwindow(win);
1011     return 0;
1012 }
1013
1014 /* #wmode command */
1015 STATIC_PTR int
1016 wiz_show_wmodes(VOID_ARGS)
1017 {
1018     winid win;
1019     int x, y;
1020     char row[COLNO + 1];
1021     struct rm *lev;
1022     boolean istty = !strcmp(windowprocs.name, "tty");
1023
1024     win = create_nhwindow(NHW_TEXT);
1025     if (istty)
1026         putstr(win, 0, ""); /* tty only: blank top line */
1027     for (y = 0; y < ROWNO; y++) {
1028         for (x = 0; x < COLNO; x++) {
1029             lev = &levl[x][y];
1030             if (x == u.ux && y == u.uy)
1031                 row[x] = '@';
1032             else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
1033                 row[x] = '0' + (lev->wall_info & WM_MASK);
1034             else if (lev->typ == CORR)
1035                 row[x] = '#';
1036             else if (IS_ROOM(lev->typ) || IS_DOOR(lev->typ))
1037                 row[x] = '.';
1038             else
1039                 row[x] = 'x';
1040         }
1041         row[COLNO] = '\0';
1042         /* map column 0, levl[0][], is off the left edge of the screen */
1043         putstr(win, 0, &row[1]);
1044     }
1045     display_nhwindow(win, TRUE);
1046     destroy_nhwindow(win);
1047     return 0;
1048 }
1049
1050 /* wizard mode variant of #terrain; internal levl[][].typ values in base-36 */
1051 STATIC_OVL void
1052 wiz_map_levltyp(VOID_ARGS)
1053 {
1054     winid win;
1055     int x, y, terrain;
1056     char row[COLNO + 1];
1057     boolean istty = !strcmp(windowprocs.name, "tty");
1058
1059     win = create_nhwindow(NHW_TEXT);
1060     /* map row 0, levl[][0], is drawn on the second line of tty screen */
1061     if (istty)
1062         putstr(win, 0, ""); /* tty only: blank top line */
1063     for (y = 0; y < ROWNO; y++) {
1064         /* map column 0, levl[0][], is off the left edge of the screen;
1065            it should always have terrain type "undiggable stone" */
1066         for (x = 1; x < COLNO; x++) {
1067             terrain = levl[x][y].typ;
1068             /* assumes there aren't more than 10+26+26 terrain types */
1069             row[x - 1] = (char) ((terrain == STONE && !may_dig(x, y))
1070                                     ? '*'
1071                                     : (terrain < 10)
1072                                        ? '0' + terrain
1073                                        : (terrain < 36)
1074                                           ? 'a' + terrain - 10
1075                                           : 'A' + terrain - 36);
1076         }
1077         x--;
1078         if (levl[0][y].typ != STONE || may_dig(0, y))
1079             row[x++] = '!';
1080         row[x] = '\0';
1081         putstr(win, 0, row);
1082     }
1083
1084     {
1085         char dsc[BUFSZ];
1086         s_level *slev = Is_special(&u.uz);
1087
1088         Sprintf(dsc, "D:%d,L:%d", u.uz.dnum, u.uz.dlevel);
1089         /* [dungeon branch features currently omitted] */
1090         /* special level features */
1091         if (slev) {
1092             Sprintf(eos(dsc), " \"%s\"", slev->proto);
1093             /* special level flags (note: dungeon.def doesn't set `maze'
1094                or `hell' for any specific levels so those never show up) */
1095             if (slev->flags.maze_like)
1096                 Strcat(dsc, " mazelike");
1097             if (slev->flags.hellish)
1098                 Strcat(dsc, " hellish");
1099             if (slev->flags.town)
1100                 Strcat(dsc, " town");
1101             if (slev->flags.rogue_like)
1102                 Strcat(dsc, " roguelike");
1103             /* alignment currently omitted to save space */
1104         }
1105         /* level features */
1106         if (level.flags.nfountains)
1107             Sprintf(eos(dsc), " %c:%d", defsyms[S_fountain].sym,
1108                     (int) level.flags.nfountains);
1109         if (level.flags.nsinks)
1110             Sprintf(eos(dsc), " %c:%d", defsyms[S_sink].sym,
1111                     (int) level.flags.nsinks);
1112         if (level.flags.has_vault)
1113             Strcat(dsc, " vault");
1114         if (level.flags.has_shop)
1115             Strcat(dsc, " shop");
1116         if (level.flags.has_temple)
1117             Strcat(dsc, " temple");
1118         if (level.flags.has_court)
1119             Strcat(dsc, " throne");
1120         if (level.flags.has_zoo)
1121             Strcat(dsc, " zoo");
1122         if (level.flags.has_morgue)
1123             Strcat(dsc, " morgue");
1124         if (level.flags.has_barracks)
1125             Strcat(dsc, " barracks");
1126         if (level.flags.has_beehive)
1127             Strcat(dsc, " hive");
1128         if (level.flags.has_swamp)
1129             Strcat(dsc, " swamp");
1130         /* level flags */
1131         if (level.flags.noteleport)
1132             Strcat(dsc, " noTport");
1133         if (level.flags.hardfloor)
1134             Strcat(dsc, " noDig");
1135         if (level.flags.nommap)
1136             Strcat(dsc, " noMMap");
1137         if (!level.flags.hero_memory)
1138             Strcat(dsc, " noMem");
1139         if (level.flags.shortsighted)
1140             Strcat(dsc, " shortsight");
1141         if (level.flags.graveyard)
1142             Strcat(dsc, " graveyard");
1143         if (level.flags.is_maze_lev)
1144             Strcat(dsc, " maze");
1145         if (level.flags.is_cavernous_lev)
1146             Strcat(dsc, " cave");
1147         if (level.flags.arboreal)
1148             Strcat(dsc, " tree");
1149         if (Sokoban)
1150             Strcat(dsc, " sokoban-rules");
1151         /* non-flag info; probably should include dungeon branching
1152            checks (extra stairs and magic portals) here */
1153         if (Invocation_lev(&u.uz))
1154             Strcat(dsc, " invoke");
1155         if (On_W_tower_level(&u.uz))
1156             Strcat(dsc, " tower");
1157         /* append a branch identifier for completeness' sake */
1158         if (u.uz.dnum == 0)
1159             Strcat(dsc, " dungeon");
1160         else if (u.uz.dnum == mines_dnum)
1161             Strcat(dsc, " mines");
1162         else if (In_sokoban(&u.uz))
1163             Strcat(dsc, " sokoban");
1164         else if (u.uz.dnum == quest_dnum)
1165             Strcat(dsc, " quest");
1166         else if (Is_knox(&u.uz))
1167             Strcat(dsc, " ludios");
1168         else if (u.uz.dnum == 1)
1169             Strcat(dsc, " gehennom");
1170         else if (u.uz.dnum == tower_dnum)
1171             Strcat(dsc, " vlad");
1172         else if (In_endgame(&u.uz))
1173             Strcat(dsc, " endgame");
1174         else {
1175             /* somebody's added a dungeon branch we're not expecting */
1176             const char *brname = dungeons[u.uz.dnum].dname;
1177
1178             if (!brname || !*brname)
1179                 brname = "unknown";
1180             if (!strncmpi(brname, "the ", 4))
1181                 brname += 4;
1182             Sprintf(eos(dsc), " %s", brname);
1183         }
1184         /* limit the line length to map width */
1185         if (strlen(dsc) >= COLNO)
1186             dsc[COLNO - 1] = '\0'; /* truncate */
1187         putstr(win, 0, dsc);
1188     }
1189
1190     display_nhwindow(win, TRUE);
1191     destroy_nhwindow(win);
1192     return;
1193 }
1194
1195 /* temporary? hack, since level type codes aren't the same as screen
1196    symbols and only the latter have easily accessible descriptions */
1197 static const char *levltyp[] = {
1198     "stone", "vertical wall", "horizontal wall", "top-left corner wall",
1199     "top-right corner wall", "bottom-left corner wall",
1200     "bottom-right corner wall", "cross wall", "tee-up wall", "tee-down wall",
1201     "tee-left wall", "tee-right wall", "drawbridge wall", "tree",
1202     "secret door", "secret corridor", "pool", "moat", "water",
1203     "drawbridge up", "lava pool", "iron bars", "door", "corridor", "room",
1204     "stairs", "ladder", "fountain", "throne", "sink", "grave", "altar", "ice",
1205     "drawbridge down", "air", "cloud",
1206     /* not a real terrain type, but used for undiggable stone
1207        by wiz_map_levltyp() */
1208     "unreachable/undiggable",
1209     /* padding in case the number of entries above is odd */
1210     ""
1211 };
1212
1213 /* explanation of base-36 output from wiz_map_levltyp() */
1214 STATIC_OVL void
1215 wiz_levltyp_legend(VOID_ARGS)
1216 {
1217     winid win;
1218     int i, j, last, c;
1219     const char *dsc, *fmt;
1220     char buf[BUFSZ];
1221
1222     win = create_nhwindow(NHW_TEXT);
1223     putstr(win, 0, "#terrain encodings:");
1224     putstr(win, 0, "");
1225     fmt = " %c - %-28s"; /* TODO: include tab-separated variant for win32 */
1226     *buf = '\0';
1227     /* output in pairs, left hand column holds [0],[1],...,[N/2-1]
1228        and right hand column holds [N/2],[N/2+1],...,[N-1];
1229        N ('last') will always be even, and may or may not include
1230        the empty string entry to pad out the final pair, depending
1231        upon how many other entries are present in levltyp[] */
1232     last = SIZE(levltyp) & ~1;
1233     for (i = 0; i < last / 2; ++i)
1234         for (j = i; j < last; j += last / 2) {
1235             dsc = levltyp[j];
1236             c = !*dsc ? ' '
1237                    : !strncmp(dsc, "unreachable", 11) ? '*'
1238                       /* same int-to-char conversion as wiz_map_levltyp() */
1239                       : (j < 10) ? '0' + j
1240                          : (j < 36) ? 'a' + j - 10
1241                             : 'A' + j - 36;
1242             Sprintf(eos(buf), fmt, c, dsc);
1243             if (j > i) {
1244                 putstr(win, 0, buf);
1245                 *buf = '\0';
1246             }
1247         }
1248     display_nhwindow(win, TRUE);
1249     destroy_nhwindow(win);
1250     return;
1251 }
1252
1253 /* #wizsmell command - test usmellmon(). */
1254 STATIC_PTR int
1255 wiz_smell(VOID_ARGS)
1256 {
1257     int ans = 0;
1258     int mndx;  /* monster index */
1259     coord cc;  /* screen pos of unknown glyph */
1260     int glyph; /* glyph at selected position */
1261
1262     cc.x = u.ux;
1263     cc.y = u.uy;
1264     mndx = 0; /* gcc -Wall lint */
1265     if (!olfaction(youmonst.data)) {
1266         You("are incapable of detecting odors in your present form.");
1267         return 0;
1268     }
1269
1270     pline("You can move the cursor to a monster that you want to smell.");
1271     do {
1272         pline("Pick a monster to smell.");
1273         ans = getpos(&cc, TRUE, "a monster");
1274         if (ans < 0 || cc.x < 0) {
1275             return 0; /* done */
1276         }
1277         /* Convert the glyph at the selected position to a mndxbol. */
1278         glyph = glyph_at(cc.x, cc.y);
1279         if (glyph_is_monster(glyph))
1280             mndx = glyph_to_mon(glyph);
1281         else
1282             mndx = 0;
1283         /* Is it a monster? */
1284         if (mndx) {
1285             if (!usmellmon(&mons[mndx]))
1286                 pline("That monster seems to give off no smell.");
1287         } else
1288             pline("That is not a monster.");
1289     } while (TRUE);
1290     return 0;
1291 }
1292
1293 /* #wizinstrinsic command to set some intrinsics for testing */
1294 STATIC_PTR int
1295 wiz_intrinsic(VOID_ARGS)
1296 {
1297     if (wizard) {
1298         extern const struct propname {
1299             int prop_num;
1300             const char *prop_name;
1301         } propertynames[]; /* timeout.c */
1302         static const char wizintrinsic[] = "#wizintrinsic";
1303         static const char fmt[] = "You are%s %s.";
1304         winid win;
1305         anything any;
1306         char buf[BUFSZ];
1307         int i, j, n, p, amt, typ;
1308         long oldtimeout, newtimeout;
1309         const char *propname;
1310         menu_item *pick_list = (menu_item *) 0;
1311
1312         any = zeroany;
1313         win = create_nhwindow(NHW_MENU);
1314         start_menu(win);
1315         for (i = 0; (propname = propertynames[i].prop_name) != 0; ++i) {
1316             p = propertynames[i].prop_num;
1317             if (p == HALLUC_RES) {
1318                 /* Grayswandir vs hallucination; ought to be redone to
1319                    use u.uprops[HALLUC].blocked instead of being treated
1320                    as a separate property; letting in be manually toggled
1321                    even only in wizard mode would be asking for trouble... */
1322                 continue;
1323             }
1324             if (p == FIRE_RES) {
1325                 any.a_int = 0;
1326                 add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "--", FALSE);
1327             }
1328             any.a_int = i + 1; /* +1: avoid 0 */
1329             oldtimeout = u.uprops[p].intrinsic & TIMEOUT;
1330             if (oldtimeout)
1331                 Sprintf(buf, "%-27s [%li]", propname, oldtimeout);
1332             else
1333                 Sprintf(buf, "%s", propname);
1334             add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
1335         }
1336         end_menu(win, "Which intrinsics?");
1337         n = select_menu(win, PICK_ANY, &pick_list);
1338         destroy_nhwindow(win);
1339
1340         amt = 30; /* TODO: prompt for duration */
1341         for (j = 0; j < n; ++j) {
1342             i = pick_list[j].item.a_int - 1; /* -1: reverse +1 above */
1343             p = propertynames[i].prop_num;
1344             oldtimeout = u.uprops[p].intrinsic & TIMEOUT;
1345             newtimeout = oldtimeout + (long) amt;
1346             switch (p) {
1347             case SICK:
1348             case SLIMED:
1349             case STONED:
1350                 if (oldtimeout > 0L && newtimeout > oldtimeout)
1351                     newtimeout = oldtimeout;
1352                 break;
1353             }
1354
1355             switch (p) {
1356             case BLINDED:
1357                 make_blinded(newtimeout, TRUE);
1358                 break;
1359 #if 0       /* make_confused() only gives feedback when confusion is
1360              * ending so use the 'default' case for it instead */
1361             case CONFUSION:
1362                 make_confused(newtimeout, TRUE);
1363                 break;
1364 #endif /*0*/
1365             case DEAF:
1366                 make_deaf(newtimeout, TRUE);
1367                 break;
1368             case HALLUC:
1369                 make_hallucinated(newtimeout, TRUE, 0L);
1370                 break;
1371             case SICK:
1372                 typ = !rn2(2) ? SICK_VOMITABLE : SICK_NONVOMITABLE;
1373                 make_sick(newtimeout, wizintrinsic, TRUE, typ);
1374                 break;
1375             case SLIMED:
1376                 Sprintf(buf, fmt,
1377                         !Slimed ? "" : " still", "turning into slime");
1378                 make_slimed(newtimeout, buf);
1379                 break;
1380             case STONED:
1381                 Sprintf(buf, fmt,
1382                         !Stoned ? "" : " still", "turning into stone");
1383                 make_stoned(newtimeout, buf, KILLED_BY, wizintrinsic);
1384                 break;
1385             case STUNNED:
1386                 make_stunned(newtimeout, TRUE);
1387                 break;
1388             case VOMITING:
1389                 Sprintf(buf, fmt, !Vomiting ? "" : " still", "vomiting");
1390                 make_vomiting(newtimeout, FALSE);
1391                 pline1(buf);
1392                 break;
1393             default:
1394                 pline("Timeout for %s %s %d.", propertynames[i].prop_name,
1395                       oldtimeout ? "increased by" : "set to", amt);
1396                 incr_itimeout(&u.uprops[p].intrinsic, amt);
1397                 break;
1398             }
1399             context.botl = 1; /* probably not necessary... */
1400         }
1401         if (n >= 1)
1402             free((genericptr_t) pick_list);
1403         doredraw();
1404     } else
1405         pline("Unavailable command '%s'.",
1406               visctrl((int) cmd_from_func(wiz_intrinsic)));
1407     return 0;
1408 }
1409
1410 /* #wizrumorcheck command - verify each rumor access */
1411 STATIC_PTR int
1412 wiz_rumor_check(VOID_ARGS)
1413 {
1414     rumor_check();
1415     return 0;
1416 }
1417
1418 /* #terrain command -- show known map, inspired by crawl's '|' command */
1419 STATIC_PTR int
1420 doterrain(VOID_ARGS)
1421 {
1422     winid men;
1423     menu_item *sel;
1424     anything any;
1425     int n;
1426     int which;
1427
1428     /*
1429      * normal play: choose between known map without mons, obj, and traps
1430      *  (to see underlying terrain only), or
1431      *  known map without mons and objs (to see traps under mons and objs), or
1432      *  known map without mons (to see objects under monsters);
1433      * explore mode: normal choices plus full map (w/o mons, objs, traps);
1434      * wizard mode: normal and explore choices plus
1435      *  a dump of the internal levl[][].typ codes w/ level flags, or
1436      *  a legend for the levl[][].typ codes dump
1437      */
1438     men = create_nhwindow(NHW_MENU);
1439     start_menu(men);
1440     any = zeroany;
1441     any.a_int = 1;
1442     add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1443 /*JP
1444              "known map without monsters, objects, and traps",
1445 */
1446              "\89ö\95¨\81C\95¨\81Cã©\82È\82µ\82Ì\92n\90}",
1447              MENU_SELECTED);
1448     any.a_int = 2;
1449     add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1450 /*JP
1451              "known map without monsters and objects",
1452 */
1453              "\89ö\95¨\81C\95¨\82È\82µ\82Ì\92n\90}",
1454              MENU_UNSELECTED);
1455     any.a_int = 3;
1456     add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1457 /*JP
1458              "known map without monsters",
1459 */
1460              "\89ö\95¨\82È\82µ\82Ì\92n\90}",
1461              MENU_UNSELECTED);
1462     if (discover || wizard) {
1463         any.a_int = 4;
1464         add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1465 /*JP
1466                  "full map without monsters, objects, and traps",
1467 */
1468                  "\89ö\95¨\81C\95¨\81Cã©\82È\82µ\82Ì\8a®\91S\82È\92n\90}",
1469                  MENU_UNSELECTED);
1470         if (wizard) {
1471             any.a_int = 5;
1472             add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1473                      "internal levl[][].typ codes in base-36",
1474                      MENU_UNSELECTED);
1475             any.a_int = 6;
1476             add_menu(men, NO_GLYPH, &any, 0, 0, ATR_NONE,
1477                      "legend of base-36 levl[][].typ codes",
1478                      MENU_UNSELECTED);
1479         }
1480     }
1481 /*JP
1482     end_menu(men, "View which?");
1483 */
1484     end_menu(men, "\82Ç\82ê\82ð\8c©\82é\81H");
1485
1486     n = select_menu(men, PICK_ONE, &sel);
1487     destroy_nhwindow(men);
1488     /*
1489      * n <  0: player used ESC to cancel;
1490      * n == 0: preselected entry was explicitly chosen and got toggled off;
1491      * n == 1: preselected entry was implicitly chosen via <space>|<enter>;
1492      * n == 2: another entry was explicitly chosen, so skip preselected one.
1493      */
1494     which = (n < 0) ? -1 : (n == 0) ? 1 : sel[0].item.a_int;
1495     if (n > 1 && which == 1)
1496         which = sel[1].item.a_int;
1497     if (n > 0)
1498         free((genericptr_t) sel);
1499
1500     switch (which) {
1501     case 1: /* known map */
1502         reveal_terrain(0, TER_MAP);
1503         break;
1504     case 2: /* known map with known traps */
1505         reveal_terrain(0, TER_MAP | TER_TRP);
1506         break;
1507     case 3: /* known map with known traps and objects */
1508         reveal_terrain(0, TER_MAP | TER_TRP | TER_OBJ);
1509         break;
1510     case 4: /* full map */
1511         reveal_terrain(1, TER_MAP);
1512         break;
1513     case 5: /* map internals */
1514         wiz_map_levltyp();
1515         break;
1516     case 6: /* internal details */
1517         wiz_levltyp_legend();
1518         break;
1519     default:
1520         break;
1521     }
1522     return 0; /* no time elapses */
1523 }
1524
1525 /* -enlightenment and conduct- */
1526 static winid en_win = WIN_ERR;
1527 #if 0 /*JP*/
1528 static const char You_[] = "You ", are[] = "are ", were[] = "were ",
1529                   have[] = "have ", had[] = "had ", can[] = "can ",
1530                   could[] = "could ";
1531 #else
1532 static const char You_[] = "\82 \82È\82½\82Í", 
1533                   are[]  = "\82Å\82 \82é",       were[]  = "\82Å\82 \82Á\82½",
1534                   have[] = "\82ð\82à\82Á\82Ä\82¢\82é", had[]   = "\82ð\82à\82Á\82Ä\82¢\82½",
1535                   can[]  = "\82Å\82«\82é",       could[] = "\82Å\82«\82½",
1536                   iru[]  = "\82¢\82é",         ita[]   = "\82¢\82½";
1537 #endif
1538 #if 0 /*JP*//* not used */
1539 static const char have_been[] = "have been ", have_never[] = "have never ",
1540                   never[] = "never ";
1541 #endif
1542
1543 #if 0 /*JP*/
1544 #define enl_msg(prefix, present, past, suffix, ps) \
1545     enlght_line(prefix, final ? past : present, suffix, ps)
1546 #else
1547 #define enl_msg(prefix, present, past, suffix, ps) \
1548     enlght_line(prefix, ps, suffix, final ? past : present)
1549 #endif
1550 #define you_are(attr, ps) enl_msg(You_, are, were, attr, ps)
1551 #define you_have(attr, ps) enl_msg(You_, have, had, attr, ps)
1552 #define you_can(attr, ps) enl_msg(You_, can, could, attr, ps)
1553 /*JP
1554 #define you_have_been(goodthing) enl_msg(You_, have_been, were, goodthing, "")
1555 */
1556 #define you_have_been(goodthing) enl_msg(You_, are, were, goodthing, "")
1557 #if 0 /*JP*/
1558 #define you_have_never(badthing) \
1559     enl_msg(You_, have_never, never, badthing, "")
1560 #else
1561 #define you_have_never(badthing) \
1562     enl_msg(badthing, "\82Ä\82¢\82È\82¢", "\82È\82©\82Á\82½", "", "")
1563 #endif
1564 #if 0 /*JP*/
1565 #define you_have_X(something) \
1566     enl_msg(You_, have, (const char *) "", something, "")
1567 #else
1568 #define you_have_X(something) \
1569     enl_msg(something, "\82Ä\82¢\82é", "\82½", "", "")
1570 #endif
1571 #if 1 /*JP*/
1572 #define you_are_ing(goodthing, ps) enl_msg(You_, iru, ita, goodthing, ps)
1573 #endif
1574
1575 static void
1576 enlght_line(start, middle, end, ps)
1577 const char *start, *middle, *end, *ps;
1578 {
1579     char buf[BUFSZ];
1580
1581 /*JP
1582     Sprintf(buf, " %s%s%s%s.", start, middle, end, ps);
1583 */
1584     Sprintf(buf, "%s%s%s%s\81D", start, middle, end, ps);
1585     putstr(en_win, 0, buf);
1586 }
1587
1588 /* format increased chance to hit or damage or defense (Protection) */
1589 static char *
1590 enlght_combatinc(inctyp, incamt, final, outbuf)
1591 const char *inctyp;
1592 int incamt, final;
1593 char *outbuf;
1594 {
1595     const char *modif, *bonus;
1596 #if 0 /*JP*/
1597     boolean invrt;
1598 #endif
1599     int absamt;
1600
1601     absamt = abs(incamt);
1602     /* Protection amount is typically larger than damage or to-hit;
1603        reduce magnitude by a third in order to stretch modifier ranges
1604        (small:1..5, moderate:6..10, large:11..19, huge:20+) */
1605 #if 0 /*JP*/
1606     if (!strcmp(inctyp, "defense"))
1607 #else
1608     if (!strcmp(inctyp, "\96h\8cä"))
1609 #endif
1610         absamt = (absamt * 2) / 3;
1611
1612     if (absamt <= 3)
1613 /*JP
1614         modif = "small";
1615 */
1616         modif = "\8bÍ\82©\82È";
1617     else if (absamt <= 6)
1618 /*JP
1619         modif = "moderate";
1620 */
1621         modif = "\92\86\92ö\93x\82Ì";
1622     else if (absamt <= 12)
1623 /*JP
1624         modif = "large";
1625 */
1626         modif = "\91å\82«\82È";
1627     else
1628 /*JP
1629         modif = "huge";
1630 */
1631         modif = "\8b­\91å\82È";
1632
1633 #if 0 /*JP*/
1634     modif = !incamt ? "no" : an(modif); /* ("no" case shouldn't happen) */
1635 #endif
1636 /*JP
1637     bonus = (incamt >= 0) ? "bonus" : "penalty";
1638 */
1639     bonus = (incamt > 0) ? "\83{\81[\83i\83X" : "\83y\83i\83\8b\83e\83B";
1640     /* "bonus <foo>" (to hit) vs "<bar> bonus" (damage, defense) */
1641 #if 0 /*JP*/
1642     invrt = strcmp(inctyp, "to hit") ? TRUE : FALSE;
1643 #endif
1644
1645 #if 0 /*JP*/
1646     Sprintf(outbuf, "%s %s %s", modif, invrt ? inctyp : bonus,
1647             invrt ? bonus : inctyp);
1648 #else
1649     Sprintf(outbuf, "%s\82É%s%s", inctyp, modif, bonus);
1650 #endif
1651     if (final || wizard)
1652         Sprintf(eos(outbuf), " (%s%d)", (incamt > 0) ? "+" : "", incamt);
1653
1654     return outbuf;
1655 }
1656
1657 /* report half physical or half spell damage */
1658 STATIC_OVL void
1659 enlght_halfdmg(category, final)
1660 int category;
1661 int final;
1662 {
1663     const char *category_name;
1664     char buf[BUFSZ];
1665
1666     switch (category) {
1667     case HALF_PHDAM:
1668 /*JP
1669         category_name = "physical";
1670 */
1671         category_name = "\95¨\97\9d";
1672         break;
1673     case HALF_SPDAM:
1674 /*JP
1675         category_name = "spell";
1676 */
1677         category_name = "\8eô\95¶";
1678         break;
1679     default:
1680 /*JP
1681         category_name = "unknown";
1682 */
1683         category_name = "\95s\96¾";
1684         break;
1685     }
1686 #if 0 /*JP*/
1687     Sprintf(buf, " %s %s damage", (final || wizard) ? "half" : "reduced",
1688             category_name);
1689     enl_msg(You_, "take", "took", buf, from_what(category));
1690 #else
1691     Sprintf(buf, " %s\83_\83\81\81[\83W\82ð%s", (final || wizard) ? "\94¼\8c¸" : "\8c¸\8f­",
1692             category_name);
1693     enl_msg(You_, "\82µ\82Ä\82¢\82é", "\82µ\82Ä\82¢\82½", buf, from_what(category));
1694 #endif
1695 }
1696
1697 /* is hero actively using water walking capability on water (or lava)? */
1698 STATIC_OVL boolean
1699 walking_on_water()
1700 {
1701     if (u.uinwater || Levitation || Flying)
1702         return FALSE;
1703     return (boolean) (Wwalking
1704                       && (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy)));
1705 }
1706
1707 /* check whether hero is wearing something that player definitely knows
1708    confers the target property; item must have been seen and its type
1709    discovered but it doesn't necessarily have to be fully identified */
1710 STATIC_OVL boolean
1711 cause_known(propindx)
1712 int propindx; /* index of a property which can be conveyed by worn item */
1713 {
1714     register struct obj *o;
1715     long mask = W_ARMOR | W_AMUL | W_RING | W_TOOL;
1716
1717     /* simpler than from_what()/what_gives(); we don't attempt to
1718        handle artifacts and we deliberately ignore wielded items */
1719     for (o = invent; o; o = o->nobj) {
1720         if (!(o->owornmask & mask))
1721             continue;
1722         if ((int) objects[o->otyp].oc_oprop == propindx
1723             && objects[o->otyp].oc_name_known && o->dknown)
1724             return TRUE;
1725     }
1726     return FALSE;
1727 }
1728
1729 /* format a characteristic value, accommodating Strength's strangeness */
1730 STATIC_OVL char *
1731 attrval(attrindx, attrvalue, resultbuf)
1732 int attrindx, attrvalue;
1733 char resultbuf[]; /* should be at least [7] to hold "18/100\0" */
1734 {
1735     if (attrindx != A_STR || attrvalue <= 18)
1736         Sprintf(resultbuf, "%d", attrvalue);
1737     else if (attrvalue > STR18(100)) /* 19 to 25 */
1738         Sprintf(resultbuf, "%d", attrvalue - 100);
1739     else /* simplify "18/ **" to be "18/100" */
1740         Sprintf(resultbuf, "18/%02d", attrvalue - 18);
1741     return resultbuf;
1742 }
1743
1744 void
1745 enlightenment(mode, final)
1746 int mode;  /* BASICENLIGHTENMENT | MAGICENLIGHTENMENT (| both) */
1747 int final; /* ENL_GAMEINPROGRESS:0, ENL_GAMEOVERALIVE, ENL_GAMEOVERDEAD */
1748 {
1749     char buf[BUFSZ], tmpbuf[BUFSZ];
1750
1751     Strcpy(tmpbuf, plname);
1752     *tmpbuf = highc(*tmpbuf); /* same adjustment as bottom line */
1753     /* as in background_enlightenment, when poly'd we need to use the saved
1754        gender in u.mfemale rather than the current you-as-monster gender */
1755 #if 0 /*JP*/
1756     Sprintf(buf, "%s the %s's attributes:", tmpbuf,
1757             ((Upolyd ? u.mfemale : flags.female) && urole.name.f)
1758                 ? urole.name.f
1759                 : urole.name.m);
1760 #else
1761     Sprintf(buf, "%s\82Ì%s\82Ì\91®\90«:",
1762             ((Upolyd ? u.mfemale : flags.female) && urole.name.f)
1763                 ? urole.name.f
1764                 : urole.name.m,
1765              tmpbuf);
1766 #endif
1767
1768     en_win = create_nhwindow(NHW_MENU);
1769     /* title */
1770     putstr(en_win, 0, buf); /* "Conan the Archeologist's attributes:" */
1771     /* background and characteristics; ^X or end-of-game disclosure */
1772     if (mode & BASICENLIGHTENMENT) {
1773         /* role, race, alignment, deities */
1774         background_enlightenment(mode, final);
1775         /* strength, dexterity, &c */
1776         characteristics_enlightenment(mode, final);
1777     }
1778     /* expanded status line information, including things which aren't
1779        included there due to space considerations--such as obvious
1780        alternative movement indicators (riding, levitation, &c), and
1781        various troubles (turning to stone, trapped, confusion, &c);
1782        shown for both basic and magic enlightenment */
1783     status_enlightenment(mode, final);
1784     /* remaining attributes; shown for potion,&c or wizard mode and
1785        explore mode ^X or end of game disclosure */
1786     if (mode & MAGICENLIGHTENMENT) {
1787         /* intrinsics and other traditional enlightenment feedback */
1788         attributes_enlightenment(mode, final);
1789     }
1790     display_nhwindow(en_win, TRUE);
1791     destroy_nhwindow(en_win);
1792     en_win = WIN_ERR;
1793 }
1794
1795 /*ARGSUSED*/
1796 /* display role, race, alignment and such to en_win */
1797 STATIC_OVL void
1798 background_enlightenment(unused_mode, final)
1799 int unused_mode UNUSED;
1800 int final;
1801 {
1802     const char *role_titl, *rank_titl;
1803     int innategend, difgend, difalgn;
1804     char buf[BUFSZ], tmpbuf[BUFSZ];
1805
1806     /* note that if poly'd, we need to use u.mfemale instead of flags.female
1807        to access hero's saved gender-as-human/elf/&c rather than current one */
1808     innategend = (Upolyd ? u.mfemale : flags.female) ? 1 : 0;
1809     role_titl = (innategend && urole.name.f) ? urole.name.f : urole.name.m;
1810     rank_titl = rank_of(u.ulevel, Role_switch, innategend);
1811
1812     putstr(en_win, 0, ""); /* separator after title */
1813 /*JP
1814     putstr(en_win, 0, "Background:");
1815 */
1816     putstr(en_win, 0, "\94w\8ci\8fî\95ñ:");
1817
1818     /* if polymorphed, report current shape before underlying role;
1819        will be repeated as first status: "you are transformed" and also
1820        among various attributes: "you are in beast form" (after being
1821        told about lycanthropy) or "you are polymorphed into <a foo>"
1822        (with countdown timer appended for wizard mode); we really want
1823        the player to know he's not a samurai at the moment... */
1824     if (Upolyd) {
1825         struct permonst *uasmon = youmonst.data;
1826
1827         tmpbuf[0] = '\0';
1828         /* here we always use current gender, not saved role gender */
1829         if (!is_male(uasmon) && !is_female(uasmon) && !is_neuter(uasmon))
1830 /*JP
1831             Sprintf(tmpbuf, "%s ", genders[flags.female ? 1 : 0].adj);
1832 */
1833             Sprintf(tmpbuf, "%s\82Ì", genders[flags.female ? 1 : 0].adj);
1834 #if 0 /*JP*/
1835         Sprintf(buf, "%sin %s%s form", !final ? "currently " : "", tmpbuf,
1836                 uasmon->mname);
1837 #else
1838         Sprintf(buf, "%s%s%s\82Ì\8ep", !final ? "\8d¡\82Ì\82Æ\82±\82ë" : "", tmpbuf,
1839                 uasmon->mname);
1840 #endif
1841 /*JP
1842         you_are(buf, "");
1843 */
1844         you_are_ing(buf, "");
1845     }
1846
1847     /* report role; omit gender if it's redundant (eg, "female priestess") */
1848     tmpbuf[0] = '\0';
1849     if (!urole.name.f
1850         && ((urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE)
1851             || innategend != flags.initgend))
1852 /*JP
1853         Sprintf(tmpbuf, "%s ", genders[innategend].adj);
1854 */
1855         Sprintf(tmpbuf, "%s", genders[innategend].adj);
1856     buf[0] = '\0';
1857     if (Upolyd)
1858 #if 0 /*JP*/
1859         Strcpy(buf, "actually "); /* "You are actually a ..." */
1860 #else
1861         Strcpy(buf, "\8eÀ\8dÛ\82É\82Í"); /* "\82 \82È\82½\82Í\8eÀ\8dÛ\82É\82Í..." */
1862 #endif
1863     if (!strcmpi(rank_titl, role_titl)) {
1864         /* omit role when rank title matches it */
1865 #if 0 /*JP*/
1866         Sprintf(eos(buf), "%s, level %d %s%s", an(rank_titl), u.ulevel,
1867                 tmpbuf, urace.noun);
1868 #else
1869         Sprintf(eos(buf), "\83\8c\83x\83\8b%d\82Ì%s\82Ì%s%s", u.ulevel,
1870                 tmpbuf, urace.adj, role_titl);
1871 #endif
1872     } else {
1873 #if 0 /*JP*/
1874         Sprintf(eos(buf), "%s, a level %d %s%s %s", an(rank_titl), u.ulevel,
1875                 tmpbuf, urace.adj, role_titl);
1876 #else
1877         Sprintf(eos(buf), "\83\8c\83x\83\8b%d\82Ì%s\82Ì%s%s\82Ì%s", u.ulevel,
1878                 tmpbuf, urace.adj, role_titl, rank_titl);
1879 #endif
1880     }
1881         you_are(buf, "");
1882
1883     /* report alignment (bypass you_are() in order to omit ending period);
1884        adverb is used to distinguish between temporary change (helm of opp.
1885        alignment), permanent change (one-time conversion), and original */
1886 #if 0 /*JP*/
1887     Sprintf(buf, " %s%s%s, %son a mission for %s",
1888             You_, !final ? are : were,
1889             align_str(u.ualign.type),
1890             /* helm of opposite alignment (might hide conversion) */
1891             (u.ualign.type != u.ualignbase[A_CURRENT])
1892                /* what's the past tense of "currently"? if we used "formerly"
1893                   it would sound like a reference to the original alignment */
1894                ? (!final ? "currently " : "temporarily ")
1895                /* permanent conversion */
1896                : (u.ualign.type != u.ualignbase[A_ORIGINAL])
1897                   /* and what's the past tense of "now"? certainly not "then"
1898                      in a context like this...; "belatedly" == weren't that
1899                      way sooner (in other words, didn't start that way) */
1900                   ? (!final ? "now " : "belatedly ")
1901                   /* atheist (ignored in very early game) */
1902                   : (!u.uconduct.gnostic && moves > 1000L)
1903                      ? "nominally "
1904                      /* lastly, normal case */
1905                      : "",
1906             u_gname());
1907 #else
1908     Sprintf(buf, "\82 \82È\82½\82Í%s\82Å, %s%s\82Ì\82½\82ß\82Ì\94C\96±\82ð\8ds\82Á\82Ä%s\81D",
1909             align_str(u.ualign.type),
1910             /* helm of opposite alignment (might hide conversion) */
1911             (u.ualign.type != u.ualignbase[A_CURRENT]) ? "\88ê\8e\9e\93I\82É"
1912                /* permanent conversion */
1913                : (u.ualign.type != u.ualignbase[A_ORIGINAL]) ? "\8c»\8dÝ"
1914                   /* atheist (ignored in very early game) */
1915                   : (!u.uconduct.gnostic && moves > 1000L) ? "\96¼\8b`\8fã"
1916                      /* lastly, normal case */
1917                      : "",
1918             u_gname(), !final ? iru : ita);
1919 #endif
1920     putstr(en_win, 0, buf);
1921     /* show the rest of this game's pantheon (finishes previous sentence)
1922        [appending "also Moloch" at the end would allow for straightforward
1923        trailing "and" on all three aligned entries but looks too verbose] */
1924 #if 0 /*JP*/
1925     Sprintf(buf, " who %s opposed by", !final ? "is" : "was");
1926 #else
1927     Strcpy(buf, "\82 \82È\82½\82Í");
1928 #endif
1929     if (u.ualign.type != A_LAWFUL)
1930 #if 0 /*JP*/
1931         Sprintf(eos(buf), " %s (%s) and", align_gname(A_LAWFUL),
1932                 align_str(A_LAWFUL));
1933 #else
1934         Sprintf(eos(buf), "%s(%s)\82¨\82æ\82Ñ", align_gname(A_LAWFUL),
1935                 align_str(A_LAWFUL));
1936 #endif
1937     if (u.ualign.type != A_NEUTRAL)
1938 #if 0 /*JP*/
1939         Sprintf(eos(buf), " %s (%s)%s", align_gname(A_NEUTRAL),
1940                 align_str(A_NEUTRAL),
1941                 (u.ualign.type != A_CHAOTIC) ? " and" : "");
1942 #else
1943         Sprintf(eos(buf), "%s(%s)%s", align_gname(A_NEUTRAL),
1944                 align_str(A_NEUTRAL),
1945                 (u.ualign.type != A_CHAOTIC) ? "\82¨\82æ\82Ñ" : "");
1946 #endif
1947 #if 0 /*JP*/
1948     if (u.ualign.type != A_CHAOTIC)
1949         Sprintf(eos(buf), " %s (%s)", align_gname(A_CHAOTIC),
1950                 align_str(A_CHAOTIC));
1951 #else
1952     if (u.ualign.type != A_CHAOTIC)
1953         Sprintf(eos(buf), "%s(%s)", align_gname(A_CHAOTIC),
1954                 align_str(A_CHAOTIC));
1955 #endif
1956 #if 0 /*JP*/
1957     Strcat(buf, "."); /* terminate sentence */
1958 #else
1959     Sprintf(eos(buf), "\82Æ\91Î\97§\82µ\82Ä%s\81D", !final ? iru : ita);
1960 #endif
1961     putstr(en_win, 0, buf);
1962
1963     /* show original alignment,gender,race,role if any have been changed;
1964        giving separate message for temporary alignment change bypasses need
1965        for tricky phrasing otherwise necessitated by possibility of having
1966        helm of opposite alignment mask a permanent alignment conversion */
1967     difgend = (innategend != flags.initgend);
1968     difalgn = (((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0)
1969                + ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL])
1970                   ? 2 : 0));
1971     if (difalgn & 1) { /* have temporary alignment so report permanent one */
1972 /*JP
1973         Sprintf(buf, "actually %s", align_str(u.ualignbase[A_CURRENT]));
1974 */
1975         Sprintf(buf, "\8eÀ\8dÛ\82É\82Í%s", align_str(u.ualignbase[A_CURRENT]));
1976 /*JP
1977         you_are(buf, "");
1978 */
1979         enl_msg(buf, "\82Ä\82¢\82é", "\82Ä\82¢\82½", "", "");
1980         difalgn &= ~1; /* suppress helm from "started out <foo>" message */
1981     }
1982     if (difgend || difalgn) { /* sex change or perm align change or both */
1983 #if 0 /*JP*/
1984         Sprintf(buf, " You started out %s%s%s.",
1985                 difgend ? genders[flags.initgend].adj : "",
1986                 (difgend && difalgn) ? " and " : "",
1987                 difalgn ? align_str(u.ualignbase[A_ORIGINAL]) : "");
1988 #else
1989         Sprintf(buf, "\82 \82È\82½\82Í%s%s%s\82Å\8aJ\8en\82µ\82½\81D",
1990                 difgend ? genders[flags.initgend].adj : "",
1991                 (difgend && difalgn) ? "\82©\82Â" : "",
1992                 difalgn ? align_str(u.ualignbase[A_ORIGINAL]) : "");
1993 #endif
1994         putstr(en_win, 0, buf);
1995     }
1996 }
1997
1998 /* characteristics: expanded version of bottom line strength, dexterity, &c;
1999    [3.6.1: now includes all status info (except things already shown in the
2000    'background' section), primarily so that blind players can suppress the
2001    status line(s) altogether and use ^X feedback on demand to view HP, &c] */
2002 STATIC_OVL void
2003 characteristics_enlightenment(mode, final)
2004 int mode;
2005 int final;
2006 {
2007     char buf[BUFSZ];
2008     int hp = Upolyd ? u.mh : u.uhp;
2009     int hpmax = Upolyd ? u.mhmax : u.uhpmax;
2010
2011     putstr(en_win, 0, ""); /* separator after background */
2012     putstr(en_win, 0,
2013 /*JP
2014            final ? "Final Characteristics:" : "Current Characteristics:");
2015 */
2016            final ? "\8dÅ\8fI\91®\90«\81F" : "\8c»\8dÝ\82Ì\91®\90«\81F");
2017
2018     if (hp < 0)
2019         hp = 0;
2020 /*JP
2021     Sprintf(buf, "%d hit points (max:%d)", hp, hpmax);
2022 */
2023     Sprintf(buf, "%d\83q\83b\83g\83|\83C\83\93\83g(\8dÅ\91å:%d)", hp, hpmax);
2024     you_have(buf, "");
2025
2026 /*JP
2027     Sprintf(buf, "%d magic power (max:%d)", u.uen, u.uenmax);
2028 */
2029     Sprintf(buf, "%d\96\82\97Í\83|\83C\83\93\83g(\8dÅ\91å:%d)", u.uen, u.uenmax);
2030     you_have(buf, "");
2031
2032     Sprintf(buf, "%d", u.uac);
2033 /*JP
2034     enl_msg("Your armor class ", "is ", "was ", buf, "");
2035 */
2036     enl_msg("\82 \82È\82½\82Ì\96h\8cä\92l\82Í", "\82Å\82 \82é", "\82Å\82 \82Á\82½", buf, "");
2037
2038     if (Upolyd) {
2039         switch (mons[u.umonnum].mlevel) {
2040         case 0:
2041             /* status line currently being explained shows "HD:0" */
2042 /*JP
2043             Strcpy(buf, "0 hit dice (actually 1/2)");
2044 */
2045             Strcpy(buf, "HD0(\8eÀ\8dÛ\82É\82Í1/2)");
2046             break;
2047         case 1:
2048 /*JP
2049             Strcpy(buf, "1 hit die");
2050 */
2051             Strcpy(buf, "HD1");
2052             break;
2053         default:
2054 /*JP
2055             Sprintf(buf, "%d hit dice", mons[u.umonnum].mlevel);
2056 */
2057             Sprintf(buf, "HD%d", mons[u.umonnum].mlevel);
2058             break;
2059         }
2060     } else {
2061         /* flags.showexp does not matter */
2062         /* experience level is already shown in the Background section */
2063 #if 0 /*JP*/
2064         Sprintf(buf, "%-1ld experience point%s",
2065                 u.uexp, plur(u.uexp));
2066 #else
2067         Sprintf(buf, "\8co\8c±\92l%-1ld\83|\83C\83\93\83g",
2068                 u.uexp);
2069 #endif
2070     }
2071     you_have(buf, "");
2072
2073     /* this is shown even if the 'time' option is off */
2074 /*JP
2075     Sprintf(buf, "the dungeon %ld turn%s ago", moves, plur(moves));
2076 */
2077     Sprintf(buf, "%ld\83^\81[\83\93\91O\82É\96À\8b{\82É\93ü\82Á\82½", moves);
2078     /* same phrasing at end of game:  "entered" is unconditional */
2079     enlght_line(You_, "", buf, "");
2080
2081 #ifdef SCORE_ON_BOTL
2082     if (flags.showscore) {
2083         /* describes what's shown on status line, which is an approximation;
2084            only show it here if player has the 'showscore' option enabled */
2085 #if 0 /*JP*/
2086         Sprintf(buf, "%ld%s", botl_score(),
2087                 !final ? "" : " before end-of-game adjustments");
2088         enl_msg("Your score ", "is ", "was ", buf, "");
2089 #else
2090         Sprintf(buf, "%s%ld", botl_score(),
2091                 !final ? "" : "\83Q\81[\83\80\8fI\97¹\8e\9e\82Ì\92²\90®\91O\82Í");
2092         enl_msg("\82 \82È\82½\82Ì\83X\83R\83A\82Í", "\82Å\82 \82é", "\82Å\82 \82Á\82½", buf, "");
2093 #endif
2094     }
2095 #endif
2096
2097     /* bottom line order */
2098     one_characteristic(mode, final, A_STR); /* strength */
2099     one_characteristic(mode, final, A_DEX); /* dexterity */
2100     one_characteristic(mode, final, A_CON); /* constitution */
2101     one_characteristic(mode, final, A_INT); /* intelligence */
2102     one_characteristic(mode, final, A_WIS); /* wisdom */
2103     one_characteristic(mode, final, A_CHA); /* charisma */
2104 }
2105
2106 /* display one attribute value for characteristics_enlightenment() */
2107 STATIC_OVL void
2108 one_characteristic(mode, final, attrindx)
2109 int mode, final, attrindx;
2110 {
2111     extern const char *const attrname[]; /* attrib.c */
2112     boolean hide_innate_value = FALSE, interesting_alimit;
2113     int acurrent, abase, apeak, alimit;
2114     const char *paren_pfx;
2115     char subjbuf[BUFSZ], valubuf[BUFSZ], valstring[32];
2116
2117     /* being polymorphed or wearing certain cursed items prevents
2118        hero from reliably tracking changes to characteristics so
2119        we don't show base & peak values then; when the items aren't
2120        cursed, hero could take them off to check underlying values
2121        and we show those in such case so that player doesn't need
2122        to actually resort to doing that */
2123     if (Upolyd) {
2124         hide_innate_value = TRUE;
2125     } else if (Fixed_abil) {
2126         if (stuck_ring(uleft, RIN_SUSTAIN_ABILITY)
2127             || stuck_ring(uright, RIN_SUSTAIN_ABILITY))
2128             hide_innate_value = TRUE;
2129     }
2130     switch (attrindx) {
2131     case A_STR:
2132         if (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER && uarmg->cursed)
2133             hide_innate_value = TRUE;
2134         break;
2135     case A_DEX:
2136         break;
2137     case A_CON:
2138         if (uwep && uwep->oartifact == ART_OGRESMASHER && uwep->cursed)
2139             hide_innate_value = TRUE;
2140         break;
2141     case A_INT:
2142         if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed)
2143             hide_innate_value = TRUE;
2144         break;
2145     case A_WIS:
2146         if (uarmh && uarmh->otyp == DUNCE_CAP && uarmh->cursed)
2147             hide_innate_value = TRUE;
2148         break;
2149     case A_CHA:
2150         break;
2151     default:
2152         return; /* impossible */
2153     };
2154     /* note: final disclosure includes MAGICENLIGHTENTMENT */
2155     if ((mode & MAGICENLIGHTENMENT) && !Upolyd)
2156         hide_innate_value = FALSE;
2157
2158     acurrent = ACURR(attrindx);
2159     (void) attrval(attrindx, acurrent, valubuf); /* Sprintf(valubuf,"%d",) */
2160 /*JP
2161     Sprintf(subjbuf, "Your %s ", attrname[attrindx]);
2162 */
2163     Sprintf(subjbuf, "\82 \82È\82½\82Ì%s\82Í", attrname[attrindx]);
2164
2165     if (!hide_innate_value) {
2166         /* show abase, amax, and/or attrmax if acurr doesn't match abase
2167            (a magic bonus or penalty is in effect) or abase doesn't match
2168            amax (some points have been lost to poison or exercise abuse
2169            and are restorable) or attrmax is different from normal human
2170            (while game is in progress; trying to reduce dependency on
2171            spoilers to keep track of such stuff) or attrmax was different
2172            from abase (at end of game; this attribute wasn't maxed out) */
2173         abase = ABASE(attrindx);
2174         apeak = AMAX(attrindx);
2175         alimit = ATTRMAX(attrindx);
2176         /* criterium for whether the limit is interesting varies */
2177         interesting_alimit =
2178             final ? TRUE /* was originally `(abase != alimit)' */
2179                   : (alimit != (attrindx != A_STR ? 18 : STR18(100)));
2180 /*JP
2181         paren_pfx = final ? " (" : " (current; ";
2182 */
2183         paren_pfx = final ? " (" : " (\8c»\8dÝ; ";
2184         if (acurrent != abase) {
2185 #if 0 /*JP*/
2186             Sprintf(eos(valubuf), "%sbase:%s", paren_pfx,
2187                     attrval(attrindx, abase, valstring));
2188 #else
2189             Sprintf(eos(valubuf), "%s\8aî\96{:%s", paren_pfx,
2190                     attrval(attrindx, abase, valstring));
2191 #endif
2192             paren_pfx = ", ";
2193         }
2194         if (abase != apeak) {
2195 #if 0 /*JP*/
2196             Sprintf(eos(valubuf), "%speak:%s", paren_pfx,
2197                     attrval(attrindx, apeak, valstring));
2198 #else
2199             Sprintf(eos(valubuf), "%s\8dÅ\91å:%s", paren_pfx,
2200                     attrval(attrindx, apeak, valstring));
2201 #endif
2202             paren_pfx = ", ";
2203         }
2204         if (interesting_alimit) {
2205 #if 0 /*JP*/
2206             Sprintf(eos(valubuf), "%s%slimit:%s", paren_pfx,
2207                     /* more verbose if exceeding 'limit' due to magic bonus */
2208                     (acurrent > alimit) ? "innate " : "",
2209                     attrval(attrindx, alimit, valstring));
2210 #else
2211             Sprintf(eos(valubuf), "%s%s\8fã\8cÀ:%s", paren_pfx,
2212                     /* more verbose if exceeding 'limit' due to magic bonus */
2213                     (acurrent > alimit) ? "\96{\97\88\82Ì" : "",
2214                     attrval(attrindx, alimit, valstring));
2215 #endif
2216             /* paren_pfx = ", "; */
2217         }
2218         if (acurrent != abase || abase != apeak || interesting_alimit)
2219             Strcat(valubuf, ")");
2220     }
2221 /*JP
2222     enl_msg(subjbuf, "is ", "was ", valubuf, "");
2223 */
2224     enl_msg(subjbuf, "\82¾", "\82¾\82Á\82½", valubuf, "");
2225 }
2226
2227 /* status: selected obvious capabilities, assorted troubles */
2228 STATIC_OVL void
2229 status_enlightenment(mode, final)
2230 int mode;
2231 int final;
2232 {
2233     boolean magic = (mode & MAGICENLIGHTENMENT) ? TRUE : FALSE;
2234     int cap;
2235     char buf[BUFSZ], youtoo[BUFSZ];
2236     boolean Riding = (u.usteed
2237                       /* if hero dies while dismounting, u.usteed will still
2238                          be set; we want to ignore steed in that situation */
2239                       && !(final == ENL_GAMEOVERDEAD
2240 /*JP
2241                            && !strcmp(killer.name, "riding accident")));
2242 */
2243                            && !strcmp(killer.name, "\8bR\8fæ\8e\96\8cÌ\82Å")));
2244     const char *steedname = (!Riding ? (char *) 0
2245                       : x_monnam(u.usteed,
2246                                  u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE,
2247                                  (char *) 0,
2248                                  (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION),
2249                                  FALSE));
2250
2251     /*\
2252      * Status (many are abbreviated on bottom line; others are or
2253      *     should be discernible to the hero hence to the player)
2254     \*/
2255     putstr(en_win, 0, ""); /* separator after title or characteristics */
2256 /*JP
2257     putstr(en_win, 0, final ? "Final Status:" : "Current Status:");
2258 */
2259     putstr(en_win, 0, final ? "\8dÅ\8fI\8fó\91Ô:" : "\8c»\8dÝ\82Ì\8fó\91Ô:");
2260
2261     Strcpy(youtoo, You_);
2262     /* not a traditional status but inherently obvious to player; more
2263        detail given below (attributes section) for magic enlightenment */
2264     if (Upolyd) {
2265 #if 0 /*JP*/
2266         Strcpy(buf, "transformed");
2267         if (ugenocided())
2268             Sprintf(eos(buf), " and %s %s inside",
2269                     final ? "felt" : "feel", udeadinside());
2270         you_are(buf, "");
2271 #else /*JP:TODO:\95Ï\89»+\8bs\8eE\83p\83^\81[\83\93*/
2272         you_are_ing("\95Ï\89»\82µ\82Ä", "");
2273 #endif
2274     }
2275     /* not a trouble, but we want to display riding status before maybe
2276        reporting steed as trapped or hero stuck to cursed saddle */
2277     if (Riding) {
2278 #if 0 /*JP*/
2279         Sprintf(buf, "riding %s", steedname);
2280         you_are(buf, "");
2281 #else
2282         Sprintf(buf, "%s\82É\8fæ\82Á\82Ä", steedname);
2283         you_are_ing(buf, "");
2284 #endif
2285 /*JP
2286         Sprintf(eos(youtoo), "and %s ", steedname);
2287 */
2288         Sprintf(youtoo, "\82 \82È\82½\82Æ%s\82Í", steedname);
2289     }
2290     /* other movement situations that hero should always know */
2291     if (Levitation) {
2292         if (Lev_at_will && magic)
2293 /*JP
2294             you_are("levitating, at will", "");
2295 */
2296             you_are_ing("\8e©\95ª\82Ì\88Ó\8eu\82Å\95\82\97V\82µ\82Ä", "");
2297         else
2298 /*JP
2299             enl_msg(youtoo, are, were, "levitating", from_what(LEVITATION));
2300 */
2301             enl_msg(youtoo, "\82¢\82é", "\82¢\82½", "\95\82\97V\82µ\82Ä", from_what(LEVITATION));
2302     } else if (Flying) { /* can only fly when not levitating */
2303 /*JP
2304         enl_msg(youtoo, are, were, "flying", from_what(FLYING));
2305 */
2306         enl_msg(youtoo, "\82¢\82é", "\82¢\82½", "\94ò\82ñ\82Å", from_what(FLYING));
2307     }
2308     if (Underwater) {
2309 /*JP
2310         you_are("underwater", "");
2311 */
2312         enl_msg(You_, "\82¢\82é", "\82¢\82½", "\90\85\96Ê\89º\82É", "");
2313     } else if (u.uinwater) {
2314 /*JP
2315         you_are(Swimming ? "swimming" : "in water", from_what(SWIMMING));
2316 */
2317         enl_msg(You_, Swimming ? "\89j\82¢\82Å" : "\90\85\92\86\82É", "\82¢\82é", "\82¢\82½", from_what(SWIMMING));
2318     } else if (walking_on_water()) {
2319         /* show active Wwalking here, potential Wwalking elsewhere */
2320 #if 0 /*JP*/
2321         Sprintf(buf, "walking on %s",
2322                 is_pool(u.ux, u.uy) ? "water"
2323                 : is_lava(u.ux, u.uy) ? "lava"
2324                   : surface(u.ux, u.uy)); /* catchall; shouldn't happen */
2325         you_are(buf, from_what(WWALKING));
2326 #else
2327         Sprintf(buf, "%s\82Ì\8fã\82ð\95à\82¢\82Ä",
2328                 is_pool(u.ux, u.uy) ? "\90\85"
2329                 : is_lava(u.ux, u.uy) ? "\97n\8aâ"
2330                   : surface(u.ux, u.uy)); /* catchall; shouldn't happen */
2331         you_are_ing(buf, from_what(WWALKING));
2332 #endif
2333     }
2334     if (Upolyd && (u.uundetected || youmonst.m_ap_type != M_AP_NOTHING))
2335         youhiding(TRUE, final);
2336
2337     /* internal troubles, mostly in the order that prayer ranks them */
2338     if (Stoned)
2339 /*JP
2340         you_are("turning to stone", "");
2341 */
2342         enl_msg("\82 \82È\82½\82Í", "\82È\82è\82Â\82Â\82 \82é", "\82È\82Á\82½", "\90Î\82É", "");
2343     if (Slimed)
2344 /*JP
2345         you_are("turning into slime", "");
2346 */
2347         enl_msg("\82 \82È\82½\82Í", "\82È\82è\82Â\82Â\82 \82é", "\82È\82Á\82½", "\83X\83\89\83C\83\80\82É", "");
2348     if (Strangled) {
2349         if (u.uburied) {
2350 /*JP
2351             you_are("buried", "");
2352 */
2353             you_are_ing("\92\82\91§\82µ\82Ä", "");
2354         } else {
2355 /*JP
2356             Strcpy(buf, "being strangled");
2357 */
2358             Strcpy(buf, "\8eñ\82ð\8di\82ß\82ç\82ê\82Ä");
2359             if (wizard)
2360                 Sprintf(eos(buf), " (%ld)", (Strangled & TIMEOUT));
2361 /*JP
2362             you_are(buf, from_what(STRANGLED));
2363 */
2364             enl_msg("\82 \82È\82½\82Í", "\82¢\82é", "\82¢\82½", buf, from_what(STRANGLED));
2365         }
2366     }
2367     if (Sick) {
2368         /* prayer lumps these together; botl puts Ill before FoodPois */
2369         if (u.usick_type & SICK_NONVOMITABLE)
2370 /*JP
2371             you_are("terminally sick from illness", "");
2372 */
2373             enl_msg("\82 \82È\82½\82Í\95a\8bC\82Å\92v\96½\93I\82É\8bC\95ª\82ª\88«", "\82¢", "\82©\82Á\82½", "", "");
2374         if (u.usick_type & SICK_VOMITABLE)
2375 /*JP
2376             you_are("terminally sick from food poisoning", "");
2377 */
2378             enl_msg("\82 \82È\82½\82Í\90H\92\86\93Å\82Å\92v\96½\93I\82É\8bC\95ª\82ª\88«", "\82¢", "\82©\82Á\82½", "", "");
2379     }
2380     if (Vomiting)
2381 /*JP
2382         you_are("nauseated", "");
2383 */
2384         enl_msg(You_, "\93f\82«\8bC\82ª", "\82 \82é", "\82 \82Á\82½", "");
2385     if (Stunned)
2386 /*JP
2387         you_are("stunned", "");
2388 */
2389         you_are("\82­\82ç\82­\82ç\8fó\91Ô", "");
2390     if (Confusion)
2391 /*JP
2392         you_are("confused", "");
2393 */
2394         you_are("\8d¬\97\90\8fó\91Ô", "");
2395     if (Hallucination)
2396 /*JP
2397         you_are("hallucinating", "");
2398 */
2399         you_are("\8c\8ao\8fó\91Ô", "");
2400     if (Blind) {
2401         /* from_what() (currently wizard-mode only) checks !haseyes()
2402            before u.uroleplay.blind, so we should too */
2403 #if 0 /*JP*/
2404         Sprintf(buf, "%s blind",
2405                 !haseyes(youmonst.data) ? "innately"
2406                 : u.uroleplay.blind ? "permanently"
2407                   /* better phrasing desperately wanted... */
2408                   : Blindfolded_only ? "deliberately"
2409                     : "temporarily");
2410 #else
2411         Sprintf(buf, "%s\96Ó\96Ú",
2412                 !haseyes(youmonst.data) ? "\90\82Ü\82ê\82È\82ª\82ç\82É"
2413                 : u.uroleplay.blind ? "\8dP\8bv\93I\82É"
2414                   /* better phrasing desperately wanted... */
2415                   : Blindfolded_only ? "\8cÌ\88Ó\82É"
2416                     : "\88ê\8e\9e\93I\82É");
2417 #endif
2418         if (wizard && (Blinded & TIMEOUT) != 0L
2419             && !u.uroleplay.blind && haseyes(youmonst.data))
2420             Sprintf(eos(buf), " (%ld)", (Blinded & TIMEOUT));
2421         /* !haseyes: avoid "you are innately blind innately" */
2422         you_are(buf, !haseyes(youmonst.data) ? "" : from_what(BLINDED));
2423     }
2424     if (Deaf)
2425 /*JP
2426         you_are("deaf", from_what(DEAF));
2427 */
2428         you_are("\8e¨\82ª\95·\82±\82¦\82È\82¢\8fó\91Ô", from_what(DEAF));
2429
2430     /* external troubles, more or less */
2431     if (Punished) {
2432         if (uball) {
2433 /*JP
2434             Sprintf(buf, "chained to %s", ansimpleoname(uball));
2435 */
2436             Sprintf(buf, "%s\82É\82Â\82È\82ª\82ê\82Ä", ansimpleoname(uball));
2437         } else {
2438             impossible("Punished without uball?");
2439 /*JP
2440             Strcpy(buf, "punished");
2441 */
2442             Strcpy(buf, "\94±\82ð\8eó\82¯\82Ä");
2443         }
2444         you_are(buf, "");
2445     }
2446     if (u.utrap) {
2447         char predicament[BUFSZ];
2448         struct trap *t;
2449         boolean anchored = (u.utraptype == TT_BURIEDBALL);
2450
2451         if (anchored) {
2452 /*JP
2453             Strcpy(predicament, "tethered to something buried");
2454 */
2455             Strcpy(predicament, "\89½\82©\96\84\82Ü\82Á\82Ä\82¢\82é\82à\82Ì\82É\82Â\82È\82ª\82ê\82Ä");
2456         } else if (u.utraptype == TT_INFLOOR || u.utraptype == TT_LAVA) {
2457 /*JP
2458             Sprintf(predicament, "stuck in %s", the(surface(u.ux, u.uy)));
2459 */
2460             Sprintf(predicament, "%s\82É\96\84\82Ü\82Á\82Ä", surface(u.ux, u.uy));
2461         } else {
2462 #if 0 /*JP*/
2463             Strcpy(predicament, "trapped");
2464             if ((t = t_at(u.ux, u.uy)) != 0)
2465                 Sprintf(eos(predicament), " in %s",
2466                         an(defsyms[trap_to_defsym(t->ttyp)].explanation));
2467 #else
2468             predicament[0] = '\0';
2469             if ((t = t_at(u.ux, u.uy)) != 0)
2470                 Sprintf(predicament, "%s\82É",
2471                         defsyms[trap_to_defsym(t->ttyp)].explanation);
2472             Strcat(predicament, "\82Ð\82Á\82©\82©\82Á\82Ä");
2473 #endif
2474         }
2475         if (u.usteed) { /* not `Riding' here */
2476 #if 0 /*JP*/
2477             Sprintf(buf, "%s%s ", anchored ? "you and " : "", steedname);
2478             *buf = highc(*buf);
2479             enl_msg(buf, (anchored ? "are " : "is "),
2480                     (anchored ? "were " : "was "), predicament, "");
2481 #else
2482             Sprintf(buf, "%s%s\82Í", anchored ? "\82 \82È\82½\82Æ" : "", steedname);
2483             enl_msg(buf, "\82¢\82é", "\82¢\82½" , predicament, "");
2484 #endif
2485         } else
2486             you_are(predicament, "");
2487     } /* (u.utrap) */
2488     if (u.uswallow) {
2489 /*JP
2490         Sprintf(buf, "swallowed by %s", a_monnam(u.ustuck));
2491 */
2492         Sprintf(buf, "%s\82É\88ù\82Ý\8d\9e\82Ü\82ê\82Ä", a_monnam(u.ustuck));
2493         if (wizard)
2494             Sprintf(eos(buf), " (%u)", u.uswldtim);
2495         you_are(buf, "");
2496     } else if (u.ustuck) {
2497 #if 0 /*JP*/
2498         Sprintf(buf, "%s %s",
2499                 (Upolyd && sticks(youmonst.data)) ? "holding" : "held by",
2500                 a_monnam(u.ustuck));
2501         you_are(buf, "");
2502 #else
2503         Sprintf(buf, "%s%s",
2504                 a_monnam(u.ustuck),
2505                 (Upolyd && sticks(youmonst.data)) ? "\82ð\95ß\82Ü\82¦\82Ä" : "\82É\95ß\82Ü\82Á\82Ä");
2506         you_are_ing(buf, "");
2507 #endif
2508     }
2509     if (Riding) {
2510         struct obj *saddle = which_armor(u.usteed, W_SADDLE);
2511
2512         if (saddle && saddle->cursed) {
2513 #if 0 /*JP*/
2514             Sprintf(buf, "stuck to %s %s", s_suffix(steedname),
2515                     simpleonames(saddle));
2516             you_are(buf, "");
2517 #else
2518             Sprintf(buf, "%s\82Ì%s\82É\82Â\82©\82Ü\82Á\82Ä", steedname,
2519                     simpleonames(saddle));
2520             you_are_ing(buf, "");
2521 #endif
2522         }
2523     }
2524     if (Wounded_legs) {
2525         /* when mounted, Wounded_legs applies to steed rather than to
2526            hero; we only report steed's wounded legs in wizard mode */
2527         if (u.usteed) { /* not `Riding' here */
2528             if (wizard && steedname) {
2529 #if 0 /*JP*/
2530                 Strcpy(buf, steedname);
2531                 *buf = highc(*buf);
2532                 enl_msg(buf, " has", " had", " wounded legs", "");
2533 #else
2534                 enl_msg(buf, iru, ita, "\82Í\8e\88\82ð\89ö\89ä\82µ\82Ä", "");
2535 #endif
2536             }
2537         } else {
2538 #if 0 /*JP*/
2539             Sprintf(buf, "wounded %s", makeplural(body_part(LEG)));
2540             you_have(buf, "");
2541 #else
2542             Sprintf(buf, "%s\82ð\89ö\89ä\82µ\82Ä", makeplural(body_part(LEG)));
2543             you_are_ing(buf, "");
2544 #endif
2545         }
2546     }
2547     if (Glib) {
2548 #if 0 /*JP*/
2549         Sprintf(buf, "slippery %s", makeplural(body_part(FINGER)));
2550         you_have(buf, "");
2551 #else
2552         Sprintf(buf, "%s\82ª\82Ê\82é\82Ê\82é\82µ\82Ä", body_part(FINGER));
2553         enl_msg(buf, iru, ita, "", "");
2554 #endif
2555     }
2556     if (Fumbling) {
2557         if (magic || cause_known(FUMBLING))
2558 /*JP
2559             enl_msg(You_, "fumble", "fumbled", "", from_what(FUMBLING));
2560 */
2561             you_are_ing("\95s\8aí\97p\82É\82È\82Á\82Ä", from_what(FUMBLING));
2562     }
2563     if (Sleepy) {
2564         if (magic || cause_known(SLEEPY)) {
2565             Strcpy(buf, from_what(SLEEPY));
2566             if (wizard)
2567                 Sprintf(eos(buf), " (%ld)", (HSleepy & TIMEOUT));
2568 /*JP
2569             enl_msg("You ", "fall", "fell", " asleep uncontrollably", buf);
2570 */
2571             you_are_ing("\96°\82Á\82Ä", buf);
2572         }
2573     }
2574     /* hunger/nutrition */
2575     if (Hunger) {
2576         if (magic || cause_known(HUNGER))
2577 #if 0 /*JP*/
2578             enl_msg(You_, "hunger", "hungered", " rapidly",
2579                     from_what(HUNGER));
2580 #else
2581             enl_msg("\82 \82È\82½\82Í\82·\82®\82É\95 \82ª\8c¸\82é\8fó\91Ô", "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
2582 #endif
2583     }
2584     Strcpy(buf, hu_stat[u.uhs]); /* hunger status; omitted if "normal" */
2585     mungspaces(buf);             /* strip trailing spaces */
2586     if (*buf) {
2587 #if 0 /*JP*/
2588         *buf = lowc(*buf); /* override capitalization */
2589         if (!strcmp(buf, "weak"))
2590             Strcat(buf, " from severe hunger");
2591         else if (!strncmp(buf, "faint", 5)) /* fainting, fainted */
2592             Strcat(buf, " due to starvation");
2593         you_are(buf, "");
2594 #else
2595         Strcat(buf, "\8fó\91Ô");
2596         you_are(buf, "");
2597 #endif
2598     }
2599     /* encumbrance */
2600     if ((cap = near_capacity()) > UNENCUMBERED) {
2601 #if 0 /*JP*/
2602         const char *adj = "?_?"; /* (should always get overridden) */
2603
2604         Strcpy(buf, enc_stat[cap]);
2605         *buf = lowc(*buf);
2606         switch (cap) {
2607         case SLT_ENCUMBER:
2608             adj = "slightly";
2609             break; /* burdened */
2610         case MOD_ENCUMBER:
2611             adj = "moderately";
2612             break; /* stressed */
2613         case HVY_ENCUMBER:
2614             adj = "very";
2615             break; /* strained */
2616         case EXT_ENCUMBER:
2617             adj = "extremely";
2618             break; /* overtaxed */
2619         case OVERLOADED:
2620             adj = "not possible";
2621             break;
2622         }
2623         Sprintf(eos(buf), "; movement %s %s%s", !final ? "is" : "was", adj,
2624                 (cap < OVERLOADED) ? " slowed" : "");
2625         you_are(buf, "");
2626 #else
2627         Sprintf(buf, "\89×\95¨\82É\82æ\82Á\82Ä%s\8fó\91Ô", enc_stat[cap]);
2628         you_are(buf, "");
2629 #endif
2630     } else {
2631         /* last resort entry, guarantees Status section is non-empty
2632            (no longer needed for that purpose since weapon status added;
2633            still useful though) */
2634 /*JP
2635         you_are("unencumbered", "");
2636 */
2637         you_are("\89×\95¨\82Í\8e×\96\82\82É\82È\82ç\82È\82¢\8fó\91Ô", "");
2638     }
2639     /* report being weaponless; distinguish whether gloves are worn */
2640     if (!uwep) {
2641 #if 0 /*JP*/
2642         you_are(uarmg ? "empty handed" /* gloves imply hands */
2643                       : humanoid(youmonst.data)
2644                          /* hands but no weapon and no gloves */
2645                          ? "bare handed"
2646                          /* alternate phrasing for paws or lack of hands */
2647                          : "not wielding anything",
2648                 "");
2649 #else
2650         enl_msg(You_, "\82¢", "\82©\82Á\82½", "\95\90\8aí\82ð\91\95\94õ\82µ\82Ä\82¢\82È", "");
2651 #endif
2652     /* two-weaponing implies a weapon (not other odd stuff) in each hand */
2653     } else if (u.twoweap) {
2654 /*JP
2655         you_are("wielding two weapons at once", "");
2656 */
2657         you_are("\93ñ\93\81\97¬", "");
2658     /* report most weapons by their skill class (so a katana will be
2659        described as a long sword, for instance; mattock and hook are
2660        exceptions), or wielded non-weapon item by its object class */
2661     } else {
2662         const char *what = weapon_descr(uwep);
2663
2664 #if 0 /*JP*/
2665         if (!strcmpi(what, "armor") || !strcmpi(what, "food")
2666             || !strcmpi(what, "venom"))
2667             Sprintf(buf, "wielding some %s", what);
2668         else
2669             Sprintf(buf, "wielding %s",
2670                     (uwep->quan == 1L) ? an(what) : makeplural(what));
2671         you_are(buf, "");
2672 #else
2673         Sprintf(buf, "%s\82ð\91\95\94õ\82µ\82Ä", what);
2674         enl_msg(You_, "\82¢\82é", "\82¢\82½", buf, "");
2675 #endif
2676     }
2677     /* report 'nudity' */
2678     if (!uarm && !uarmu && !uarmc && !uarmg && !uarmf && !uarmh) {
2679         if (u.uroleplay.nudist)
2680 #if 0 /*JP*/
2681             enl_msg(You_, "do", "did", " not wear any armor", "");
2682 #else
2683             enl_msg(You_, "\82¢", "\82©\82Á\82½", "\89½\82Ì\8aZ\82à\91\95\94õ\82µ\82È", "");
2684 #endif
2685         else
2686 #if 0 /*JP*/
2687             you_are("not wearing any armor", "");
2688 #else
2689             enl_msg(You_, "\82¢", "\82©\82Á\82½", "\89½\82Ì\8aZ\82à\91\95\94õ\82µ\82Ä\82¢\82È", "");
2690 #endif
2691     }
2692 }
2693
2694 /* attributes: intrinsics and the like, other non-obvious capabilities */
2695 void
2696 attributes_enlightenment(unused_mode, final)
2697 int unused_mode UNUSED;
2698 int final;
2699 {
2700 #if 0 /*JP*/
2701     static NEARDATA const char if_surroundings_permitted[] =
2702         " if surroundings permitted";
2703 #endif
2704     int ltmp, armpro;
2705     char buf[BUFSZ];
2706
2707     /*\
2708      *  Attributes
2709     \*/
2710     putstr(en_win, 0, "");
2711 /*JP
2712     putstr(en_win, 0, final ? "Final Attributes:" : "Current Attributes:");
2713 */
2714     putstr(en_win, 0, final ? "\8dÅ\8fI\91®\90«:" : "\8c»\8dÝ\82Ì\91®\90«:");
2715
2716     if (u.uevent.uhand_of_elbereth) {
2717 #if 0 /*JP*/
2718         static const char *const hofe_titles[3] = { "the Hand of Elbereth",
2719                                                     "the Envoy of Balance",
2720                                                     "the Glory of Arioch" };
2721 #else
2722         static const char *const hofe_titles[3] = { "\83G\83\8b\83x\83\8c\83X\82Ì\8cä\8eè",
2723                                                     "\92²\98a\82Ì\8eg\8eÒ",
2724                                                     "\83A\83\8a\83I\83b\83`\82Ì\96¼\97_" };
2725 #endif
2726         you_are(hofe_titles[u.uevent.uhand_of_elbereth - 1], "");
2727     }
2728
2729 /*JP
2730     Sprintf(buf, "%s", piousness(TRUE, "aligned"));
2731 */
2732     Sprintf(buf, "%s", piousness(TRUE, "\90M\8bÂ\90S"));
2733     if (u.ualign.record >= 0)
2734         you_are(buf, "");
2735     else
2736         you_have(buf, "");
2737
2738     if (wizard) {
2739 #if 0 /*JP*/
2740         Sprintf(buf, " %d", u.ualign.record);
2741         enl_msg("Your alignment ", "is", "was", buf, "");
2742 #else
2743         Sprintf(buf, "\82 \82È\82½\82Ì\91®\90«\92l\82Í%d", u.ualign.record);
2744         enl_msg(buf, "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
2745 #endif
2746     }
2747
2748     /*** Resistances to troubles ***/
2749     if (Invulnerable)
2750 /*JP
2751         you_are("invulnerable", from_what(INVULNERABLE));
2752 */
2753         you_are("\95s\8e\80\90g", from_what(INVULNERABLE));
2754     if (Antimagic)
2755 /*JP
2756         you_are("magic-protected", from_what(ANTIMAGIC));
2757 */
2758         you_have("\96\82\96@\96h\8cä\94\\97Í", from_what(ANTIMAGIC));
2759     if (Fire_resistance)
2760 /*JP
2761         you_are("fire resistant", from_what(FIRE_RES));
2762 */
2763         you_have("\89Î\82Ö\82Ì\91Ï\90«", from_what(FIRE_RES));
2764     if (Cold_resistance)
2765 /*JP
2766         you_are("cold resistant", from_what(COLD_RES));
2767 */
2768         you_have("\8a¦\82³\82Ö\82Ì\91Ï\90«", from_what(COLD_RES));
2769     if (Sleep_resistance)
2770 /*JP
2771         you_are("sleep resistant", from_what(SLEEP_RES));
2772 */
2773         you_have("\96°\82è\82Ö\82Ì\91Ï\90«", from_what(SLEEP_RES));
2774     if (Disint_resistance)
2775 /*JP
2776         you_are("disintegration-resistant", from_what(DISINT_RES));
2777 */
2778         you_have("\95²\8dÓ\82Ö\82Ì\91Ï\90«", from_what(DISINT_RES));
2779     if (Shock_resistance)
2780 /*JP
2781         you_are("shock resistant", from_what(SHOCK_RES));
2782 */
2783         you_have("\93d\8c\82\82Ö\82Ì\91Ï\90«", from_what(SHOCK_RES));
2784     if (Poison_resistance)
2785 /*JP
2786         you_are("poison resistant", from_what(POISON_RES));
2787 */
2788         you_have("\93Å\82Ö\82Ì\91Ï\90«", from_what(POISON_RES));
2789     if (Acid_resistance)
2790 /*JP
2791         you_are("acid resistant", from_what(ACID_RES));
2792 */
2793         you_have("\8e_\82Ö\82Ì\91Ï\90«", from_what(ACID_RES));
2794     if (Drain_resistance)
2795 /*JP
2796         you_are("level-drain resistant", from_what(DRAIN_RES));
2797 */
2798         you_have("\83\8c\83x\83\8b\83_\83E\83\93\82Ö\82Ì\91Ï\90«", from_what(DRAIN_RES));
2799     if (Sick_resistance)
2800 /*JP
2801         you_are("immune to sickness", from_what(SICK_RES));
2802 */
2803         you_have("\95a\8bC\82É\91Î\82·\82é\96Æ\89u", from_what(SICK_RES));
2804     if (Stone_resistance)
2805 /*JP
2806         you_are("petrification resistant", from_what(STONE_RES));
2807 */
2808         you_have("\90Î\89»\82Ö\82Ì\91Ï\90«", from_what(STONE_RES));
2809     if (Halluc_resistance)
2810 #if 0 /*JP*/
2811         enl_msg(You_, "resist", "resisted", " hallucinations",
2812                 from_what(HALLUC_RES));
2813 #else
2814         you_have("\8c\8ao\82Ö\82Ì\91Ï\90«", from_what(HALLUC_RES));
2815 #endif
2816     if (u.uedibility)
2817 /*JP
2818         you_can("recognize detrimental food", "");
2819 */
2820         you_can("\97L\8aQ\82È\90H\97¿\82ð\8e¯\95Ê", "");
2821
2822     /*** Vision and senses ***/
2823     if (!Blind && (Blinded || !haseyes(youmonst.data)))
2824         you_can("see", from_what(-BLINDED)); /* Eyes of the Overworld */
2825     if (See_invisible) {
2826         if (!Blind)
2827 /*JP
2828             enl_msg(You_, "see", "saw", " invisible", from_what(SEE_INVIS));
2829 */
2830             enl_msg("\82 \82È\82½\82Í\93§\96¾\82È\82à\82Ì\82ð\8c©\82ç\82ê", "\82é", "\82½", "", from_what(SEE_INVIS));
2831         else
2832 #if 0 /*JP*/
2833             enl_msg(You_, "will see", "would have seen",
2834                     " invisible when not blind", from_what(SEE_INVIS));
2835 #else
2836             enl_msg(You_, "\82é", "\82½",
2837                     "\96Ó\96Ú\82Å\82È\82¢\82Æ\82«\82É\82Í\93§\96¾\82È\82à\82Ì\82ð\8c©\82ç\82ê", from_what(SEE_INVIS));
2838 #endif
2839     }
2840     if (Blind_telepat)
2841 /*JP
2842         you_are("telepathic", from_what(TELEPAT));
2843 */
2844         you_have("\83e\83\8c\83p\83V\81[", from_what(TELEPAT));
2845     if (Warning)
2846 /*JP
2847         you_are("warned", from_what(WARNING));
2848 */
2849         you_have("\8cx\89ú\94\\97Í", from_what(WARNING));
2850     if (Warn_of_mon && context.warntype.obj) {
2851 #if 0 /*JP*/
2852         Sprintf(buf, "aware of the presence of %s",
2853                 (context.warntype.obj & M2_ORC) ? "orcs"
2854                 : (context.warntype.obj & M2_ELF) ? "elves"
2855                 : (context.warntype.obj & M2_DEMON) ? "demons" : something);
2856         you_are(buf, from_what(WARN_OF_MON));
2857 #else
2858         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2859                 (context.warntype.obj & M2_ORC) ? "\83I\81[\83N"
2860                 : (context.warntype.obj & M2_ELF) ? "\83G\83\8b\83t"
2861                 : (context.warntype.obj & M2_DEMON) ? "\88«\96\82" : something);
2862         you_have(buf, "");
2863 #endif
2864     }
2865     if (Warn_of_mon && context.warntype.polyd) {
2866 #if 0 /*JP*/
2867         Sprintf(buf, "aware of the presence of %s",
2868                 ((context.warntype.polyd & (M2_HUMAN | M2_ELF))
2869                  == (M2_HUMAN | M2_ELF))
2870                     ? "humans and elves"
2871                     : (context.warntype.polyd & M2_HUMAN)
2872                           ? "humans"
2873                           : (context.warntype.polyd & M2_ELF)
2874                                 ? "elves"
2875                                 : (context.warntype.polyd & M2_ORC)
2876                                       ? "orcs"
2877                                       : (context.warntype.polyd & M2_DEMON)
2878                                             ? "demons"
2879                                             : "certain monsters");
2880         you_are(buf, "");
2881 #else
2882         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2883                 ((context.warntype.polyd & (M2_HUMAN | M2_ELF))
2884                  == (M2_HUMAN | M2_ELF))
2885                     ? "\90l\8aÔ\82Æ\83G\83\8b\83t"
2886                     : (context.warntype.polyd & M2_HUMAN)
2887                           ? "\90l\8aÔ"
2888                           : (context.warntype.polyd & M2_ELF)
2889                                 ? "\83G\83\8b\83t"
2890                                 : (context.warntype.polyd & M2_ORC)
2891                                       ? "\83I\81[\83N"
2892                                       : (context.warntype.polyd & M2_DEMON)
2893                                             ? "\88«\96\82"
2894                                             : "\82 \82é\8eí\82Ì\89ö\95¨");
2895         you_have(buf, "");
2896 #endif
2897     }
2898     if (Warn_of_mon && context.warntype.speciesidx >= LOW_PM) {
2899 #if 0 /*JP*/
2900         Sprintf(buf, "aware of the presence of %s",
2901                 makeplural(mons[context.warntype.speciesidx].mname));
2902         you_are(buf, from_what(WARN_OF_MON));
2903 #else
2904         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2905                 mons[context.warntype.speciesidx].mname);
2906         you_have(buf, from_what(WARN_OF_MON));
2907 #endif
2908     }
2909     if (Undead_warning)
2910 /*JP
2911         you_are("warned of undead", from_what(WARN_UNDEAD));
2912 */
2913         you_have("\95s\8e\80\82Ì\90\95¨\82Ö\82Ì\8cx\89ú\94\\97Í", from_what(WARN_UNDEAD));
2914     if (Searching)
2915 /*JP
2916         you_have("automatic searching", from_what(SEARCHING));
2917 */
2918         you_have("\92T\8d¸\94\\97Í", from_what(SEARCHING));
2919     if (Clairvoyant)
2920 /*JP
2921         you_are("clairvoyant", from_what(CLAIRVOYANT));
2922 */
2923         you_have("\90ç\97¢\8aá\94\\97Í", from_what(CLAIRVOYANT));
2924     else if ((HClairvoyant || EClairvoyant) && BClairvoyant) {
2925         Strcpy(buf, from_what(-CLAIRVOYANT));
2926 #if 0 /*JP*/
2927         if (!strncmp(buf, " because of ", 12))
2928             /* overwrite substring; strncpy doesn't add terminator */
2929             (void) strncpy(buf, " if not for ", 12);
2930         enl_msg(You_, "could be", "could have been", " clairvoyant", buf);
2931 #else
2932         /*JP:\81u\81c\82É\82æ\82Á\82Ä\81v*/
2933         if (!strncmp(buf, "\82É\82æ\82Á\82Ä", 8))
2934             /*JP:\81u\81c\82ª\82È\82¯\82ê\82Î\81v\82É\8f\91\82«\8a·\82¦\82é*/
2935             strcpy(eos(buf) - 8, "\82ª\82È\82¯\82ê\82Î");
2936         you_have("\90ç\97¢\8aá\94\\97Í", buf);
2937 #endif
2938     }
2939     if (Infravision)
2940 /*JP
2941         you_have("infravision", from_what(INFRAVISION));
2942 */
2943         you_have("\90Ô\8aO\90ü\82ª\8c©\82¦\82é\8e\8b\8ao", from_what(INFRAVISION));
2944     if (Detect_monsters)
2945 /*JP
2946         you_are("sensing the presence of monsters", "");
2947 */
2948         you_have("\89ö\95¨\82ð\92T\82·\94\\97Í", "");
2949     if (u.umconf)
2950 /*JP
2951         you_are("going to confuse monsters", "");
2952 */
2953         you_have("\89ö\95¨\82ð\8d¬\97\90\82³\82¹\82é\94\\97Í", "");
2954
2955     /*** Appearance and behavior ***/
2956     if (Adornment) {
2957         int adorn = 0;
2958
2959         if (uleft && uleft->otyp == RIN_ADORNMENT)
2960             adorn += uleft->spe;
2961         if (uright && uright->otyp == RIN_ADORNMENT)
2962             adorn += uright->spe;
2963         /* the sum might be 0 (+0 ring or two which negate each other);
2964            that yields "you are charismatic" (which isn't pointless
2965            because it potentially impacts seduction attacks) */
2966 #if 0 /*JP*/
2967         Sprintf(buf, "%scharismatic",
2968                 (adorn > 0) ? "more " : (adorn < 0) ? "less " : "");
2969         you_are(buf, from_what(ADORNED));
2970 #else
2971         Sprintf(buf, "\96£\97Í%s\82Ä",
2972                 (adorn > 0) ? "\82ª\91\9d\89Á\82µ" : (adorn < 0) ? "\82ª\8c¸\8f­\82µ" : "\93I\82É\82È\82Á");
2973         enl_msg(You_, "\82Ä\82¢\82é", "\82½", buf, "");
2974 #endif
2975     }
2976     if (Invisible)
2977 /*JP
2978         you_are("invisible", from_what(INVIS));
2979 */
2980         you_are("\93§\96¾", from_what(INVIS));
2981     else if (Invis)
2982 /*JP
2983         you_are("invisible to others", from_what(INVIS));
2984 */
2985         you_are("\91¼\90l\82É\91Î\82µ\82Ä\93§\96¾", from_what(INVIS));
2986     /* ordinarily "visible" is redundant; this is a special case for
2987        the situation when invisibility would be an expected attribute */
2988     else if ((HInvis || EInvis) && BInvis)
2989 /*JP
2990         you_are("visible", from_what(-INVIS));
2991 */
2992         you_are("\95s\93§\96¾", from_what(-INVIS));
2993     if (Displaced)
2994 /*JP
2995         you_are("displaced", from_what(DISPLACED));
2996 */
2997         you_have("\8c\89e\94\\97Í", from_what(DISPLACED));
2998     if (Stealth)
2999 /*JP
3000         you_are("stealthy", from_what(STEALTH));
3001 */
3002         you_have("\90l\96Ú\82ð\93\90\82Þ\94\\97Í", from_what(STEALTH));
3003     if (Aggravate_monster)
3004 #if 0 /*JP*/
3005         enl_msg("You aggravate", "", "d", " monsters",
3006                 from_what(AGGRAVATE_MONSTER));
3007 #else
3008         you_are_ing("\94½\8a´\82ð\82©\82Á\82Ä", from_what(AGGRAVATE_MONSTER));
3009 #endif
3010     if (Conflict)
3011 /*JP
3012         enl_msg("You cause", "", "d", " conflict", from_what(CONFLICT));
3013 */
3014         you_are_ing("\93¬\91\88\82ð\88ø\82«\8bN\82±\82µ\82Ä", from_what(CONFLICT));
3015
3016     /*** Transportation ***/
3017     if (Jumping)
3018 /*JP
3019         you_can("jump", from_what(JUMPING));
3020 */
3021         you_can("\92µ\96ô\82·\82é\82±\82Æ\82ª", from_what(JUMPING));
3022     if (Teleportation)
3023 /*JP
3024         you_can("teleport", from_what(TELEPORT));
3025 */
3026         you_can("\8fu\8aÔ\88Ú\93®\82ª", from_what(TELEPORT));
3027     if (Teleport_control)
3028 /*JP
3029         you_have("teleport control", from_what(TELEPORT_CONTROL));
3030 */
3031         you_have("\8fu\8aÔ\88Ú\93®\82Ì\90§\8cä\94\\97Í", from_what(TELEPORT_CONTROL));
3032     /* actively levitating handled earlier as a status condition */
3033     if (BLevitation) { /* levitation is blocked */
3034         long save_BLev = BLevitation;
3035
3036         BLevitation = 0L;
3037         if (Levitation)
3038 #if 0 /*JP*/
3039             enl_msg(You_, "would levitate", "would have levitated",
3040                     if_surroundings_permitted, "");
3041 #else
3042             you_are("\8fó\8bµ\82ª\8b\96\82¹\82Î\95\82\97V\82·\82é\8fó\91Ô", "");
3043 #endif
3044         BLevitation = save_BLev;
3045     }
3046     /* actively flying handled earlier as a status condition */
3047     if (BFlying) { /* flight is blocked */
3048         long save_BFly = BFlying;
3049
3050         BFlying = 0L;
3051         if (Flying)
3052 #if 0 /*JP*/
3053             enl_msg(You_, "would fly", "would have flown",
3054                     Levitation
3055                        ? "if you weren't levitating"
3056                        : (save_BFly == FROMOUTSIDE)
3057                           ? if_surroundings_permitted
3058                           /* both surroundings and [latent] levitation */
3059                           : " if circumstances permitted",
3060                     "");
3061 #else
3062             enl_msg(You_, "\82Å\82«\82é", "\82Å\82«\82½",
3063                     "\94ò\82Ô\82±\82Æ\82ª",
3064                     Levitation
3065                        ? "\95\82\97V\82µ\82Ä\82¢\82È\82¯\82ê\82Î"
3066                        : (save_BFly == FROMOUTSIDE)
3067                           ? "\8fó\8bµ\82ª\8b\96\82¹\82Î"
3068                           /* both surroundings and [latent] levitation */
3069                           : "\8e\96\8fî\82ª\8b\96\82¹\82Î");
3070 #endif
3071         BFlying = save_BFly;
3072     }
3073     /* actively walking on water handled earlier as a status condition */
3074     if (Wwalking && !walking_on_water())
3075 /*JP
3076         you_can("walk on water", from_what(WWALKING));
3077 */
3078         you_can("\90\85\82Ì\8fã\82ð\95à\82­\82±\82Æ\82ª", from_what(WWALKING));
3079     /* actively swimming (in water but not under it) handled earlier */
3080     if (Swimming && (Underwater || !u.uinwater))
3081 /*JP
3082         you_can("swim", from_what(SWIMMING));
3083 */
3084         you_can("\89j\82®\82±\82Æ\82ª", from_what(SWIMMING));
3085     if (Breathless)
3086 /*JP
3087         you_can("survive without air", from_what(MAGICAL_BREATHING));
3088 */
3089         you_can("\8bó\8bC\82È\82µ\82Å\90\82«\89\84\82Ñ\82é\82±\82Æ\82ª", from_what(MAGICAL_BREATHING));
3090     else if (Amphibious)
3091 /*JP
3092         you_can("breathe water", from_what(MAGICAL_BREATHING));
3093 */
3094         you_can("\90\85\92\86\82Å\8cÄ\8bz\82ª", from_what(MAGICAL_BREATHING));
3095     if (Passes_walls)
3096 /*JP
3097         you_can("walk through walls", from_what(PASSES_WALLS));
3098 */
3099         you_can("\95Ç\82ð\92Ê\82è\94²\82¯\82é\82±\82Æ\82ª", from_what(PASSES_WALLS));
3100
3101     /*** Physical attributes ***/
3102     if (Regeneration)
3103 /*JP
3104         enl_msg("You regenerate", "", "d", "", from_what(REGENERATION));
3105 */
3106         you_have("\8dÄ\90\94\\97Í", from_what(REGENERATION));
3107     if (Slow_digestion)
3108 /*JP
3109         you_have("slower digestion", from_what(SLOW_DIGESTION));
3110 */
3111         enl_msg("\90H\95¨\82Ì\8fÁ\89»\82ª\92x", "\82¢", "\82©\82Á\82½", "", from_what(SLOW_DIGESTION));
3112     if (u.uhitinc)
3113 /*JP
3114         you_have(enlght_combatinc("to hit", u.uhitinc, final, buf), "");
3115 */
3116         you_have(enlght_combatinc("\96½\92\86\97¦", u.uhitinc, final, buf), "");
3117     if (u.udaminc)
3118 /*JP
3119         you_have(enlght_combatinc("damage", u.udaminc, final, buf), "");
3120 */
3121         you_have(enlght_combatinc("\83_\83\81\81[\83W", u.udaminc, final, buf), "");
3122     if (u.uspellprot || Protection) {
3123         int prot = 0;
3124
3125         if (uleft && uleft->otyp == RIN_PROTECTION)
3126             prot += uleft->spe;
3127         if (uright && uright->otyp == RIN_PROTECTION)
3128             prot += uright->spe;
3129         if (HProtection & INTRINSIC)
3130             prot += u.ublessed;
3131         prot += u.uspellprot;
3132         if (prot)
3133 /*JP
3134             you_have(enlght_combatinc("defense", prot, final, buf), "");
3135 */
3136             you_have(enlght_combatinc("\96h\8cä", prot, final, buf), "");
3137     }
3138     if ((armpro = magic_negation(&youmonst)) > 0) {
3139         /* magic cancellation factor, conferred by worn armor */
3140         static const char *const mc_types[] = {
3141 #if 0 /*JP*/
3142             "" /*ordinary*/, "warded", "guarded", "protected",
3143 #else
3144             "" /*ordinary*/, "\89q\82ç\82ê\82Ä", "\8cì\82ç\82ê\82Ä", "\8eç\82ç\82ê\82Ä",
3145 #endif
3146         };
3147         /* sanity check */
3148         if (armpro >= SIZE(mc_types))
3149             armpro = SIZE(mc_types) - 1;
3150 /*JP
3151         you_are(mc_types[armpro], "");
3152 */
3153         you_are_ing(mc_types[armpro], "");
3154     }
3155     if (Half_physical_damage)
3156         enlght_halfdmg(HALF_PHDAM, final);
3157     if (Half_spell_damage)
3158         enlght_halfdmg(HALF_SPDAM, final);
3159     /* polymorph and other shape change */
3160     if (Protection_from_shape_changers)
3161 #if 0 /*JP*/
3162         you_are("protected from shape changers",
3163                 from_what(PROT_FROM_SHAPE_CHANGERS));
3164 #else
3165         you_have("\95Ï\89»\89ö\95¨\82Ö\82Ì\91Ï\90«", from_what(PROT_FROM_SHAPE_CHANGERS));
3166 #endif
3167     if (Unchanging) {
3168         const char *what = 0;
3169
3170         if (!Upolyd) /* Upolyd handled below after current form */
3171 /*JP
3172             you_can("not change from your current form",
3173 */
3174             you_are("\8c»\8dÝ\82Ì\8ep\82©\82ç\95Ï\89»\82Å\82«\82È\82¢\8fó\91Ô",
3175                     from_what(UNCHANGING));
3176         /* blocked shape changes */
3177         if (Polymorph)
3178 /*JP
3179             what = !final ? "polymorph" : "have polymorphed";
3180 */
3181             what = "\95Ï\89»\82µ\82Ä";
3182         else if (u.ulycn >= LOW_PM)
3183 /*JP
3184             what = !final ? "change shape" : "have changed shape";
3185 */
3186             what = "\8ep\82ð\95Ï\82¦\82Ä";
3187         if (what) {
3188 #if 0 /*JP*/
3189             Sprintf(buf, "would %s periodically", what);
3190             /* omit from_what(UNCHANGING); too verbose */
3191             enl_msg(You_, buf, buf, " if not locked into your current form",
3192                     "");
3193 #else
3194             Sprintf(buf, "\82à\82µ\8c»\8dÝ\82Ì\8ep\82É\8cÅ\92è\82³\82ê\82Ä\82¢\82È\82¯\82ê\82Î\92è\8aú\93I\82É%s", what);
3195             you_are_ing(buf, "");
3196 #endif
3197         }
3198     } else if (Polymorph) {
3199 /*JP
3200         you_are("polymorphing periodically", from_what(POLYMORPH));
3201 */
3202         you_are("\92è\8aú\93I\82É\95Ï\89»\82µ\82Ä", from_what(POLYMORPH));
3203     }
3204     if (Polymorph_control)
3205 /*JP
3206         you_have("polymorph control", from_what(POLYMORPH_CONTROL));
3207 */
3208         you_have("\95Ï\89»\82Ì\90§\8cä\94\\97Í", from_what(POLYMORPH_CONTROL));
3209     if (Upolyd && u.umonnum != u.ulycn) {
3210         /* foreign shape (except were-form which is handled below) */
3211 /*JP
3212         Sprintf(buf, "polymorphed into %s", an(youmonst.data->mname));
3213 */
3214         Sprintf(buf, "%s\82É\95Ï\89»\82µ\82Ä", youmonst.data->mname);
3215         if (wizard)
3216             Sprintf(eos(buf), " (%d)", u.mtimedone);
3217         you_are(buf, "");
3218     }
3219     if (lays_eggs(youmonst.data) && flags.female) /* Upolyd */
3220 /*JP
3221         you_can("lay eggs", "");
3222 */
3223         you_can("\97\91\82ð\8eY\82Þ\82±\82Æ\82ª", "");
3224     if (u.ulycn >= LOW_PM) {
3225 #if 0 /*JP*/
3226         /* "you are a werecreature [in beast form]" */
3227         Strcpy(buf, an(mons[u.ulycn].mname));
3228         if (u.umonnum == u.ulycn) {
3229             Strcat(buf, " in beast form");
3230             if (wizard)
3231                 Sprintf(eos(buf), " (%d)", u.mtimedone);
3232         }
3233 #else
3234         /*JP:\81u\82 \82È\82½\82Í[\8fb\82Ì\8ep\82Ì]\81\9b\81\9b\90l\8aÔ\82Å\82 \82é\81v*/
3235         buf[0] = '\0';
3236         if (u.umonnum == u.ulycn) {
3237             Strcpy(buf, "\8fb\82Ì\8ep\82Ì");
3238             if (wizard)
3239                 Sprintf(eos(buf), " (%d)", u.mtimedone);
3240         }
3241         Strcat(buf, mons[u.ulycn].mname);
3242 #endif
3243         you_are(buf, "");
3244     }
3245     if (Unchanging && Upolyd) /* !Upolyd handled above */
3246 /*JP
3247         you_can("not change from your current form", from_what(UNCHANGING));
3248 */
3249         enl_msg("\8d¡\82Ì\8ep\82©\82ç\95Ï\89»\82·\82é\82±\82Æ\82ª\82Å\82«\82È", "\82¢", "\82©\82Á\82½", "", from_what(UNCHANGING));
3250     if (Hate_silver)
3251 /*JP
3252         you_are("harmed by silver", "");
3253 */
3254         enl_msg("\82 \82È\82½\82Í\8bâ\82É\8eã", "\82¢", "\82©\82Á\82½", "", "");
3255     /* movement and non-armor-based protection */
3256     if (Fast)
3257 /*JP
3258         you_are(Very_fast ? "very fast" : "fast", from_what(FAST));
3259 */
3260         you_have(Very_fast ? "\82Æ\82Ä\82à\91f\91\81\82­\8ds\93®\82·\82é\94\\97Í" : "\91f\91\81\82­\8ds\93®\82·\82é\94\\97Í", from_what(FAST));
3261     if (Reflecting)
3262 /*JP
3263         you_have("reflection", from_what(REFLECTING));
3264 */
3265         you_have("\94½\8eË\94\\97Í", from_what(REFLECTING));
3266     if (Free_action)
3267 /*JP
3268         you_have("free action", from_what(FREE_ACTION));
3269 */
3270         you_have("\8dS\91©\82³\82ê\82È\82¢\94\\97Í", from_what(FREE_ACTION));
3271     if (Fixed_abil)
3272 /*JP
3273         you_have("fixed abilities", from_what(FIXED_ABIL));
3274 */
3275         enl_msg("\94\\97Í\82ª\95Ï\89»\82µ\82È", "\82¢", "\82©\82Á\82½", "", from_what(FIXED_ABIL));
3276     if (Lifesaved)
3277 /*JP
3278         enl_msg("Your life ", "will be", "would have been", " saved", "");
3279 */
3280         enl_msg("\82 \82È\82½\82Ì\90\96½\82Í\95Û\91\82³\82ê\82Ä", iru, ita, "", "");
3281
3282     /*** Miscellany ***/
3283     if (Luck) {
3284         ltmp = abs((int) Luck);
3285 #if 0 /*JP*/
3286         Sprintf(buf, "%s%slucky",
3287                 ltmp >= 10 ? "extremely " : ltmp >= 5 ? "very " : "",
3288                 Luck < 0 ? "un" : "");
3289 #else
3290         Sprintf(buf, "%s%s",
3291                 ltmp >= 10 ? "\96Ò\97ó\82É" : ltmp >= 5 ? "\82Æ\82Ä\82à" : "",
3292                 Luck < 0 ? "\95s\8dK" : "\8dK\95\9f");
3293 #endif
3294         if (wizard)
3295             Sprintf(eos(buf), " (%d)", Luck);
3296         you_are(buf, "");
3297     } else if (wizard)
3298 /*JP
3299         enl_msg("Your luck ", "is", "was", " zero", "");
3300 */
3301         enl_msg("\82 \82È\82½\82Ì\89^\82Í\83[\83\8d", "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
3302     if (u.moreluck > 0)
3303 /*JP
3304         you_have("extra luck", "");
3305 */
3306         you_have("\82³\82ç\82È\82é\8dK\89^", "");
3307     else if (u.moreluck < 0)
3308 /*JP
3309         you_have("reduced luck", "");
3310 */
3311         you_have("\82³\82ç\82È\82é\95s\89^", "");
3312     if (carrying(LUCKSTONE) || stone_luck(TRUE)) {
3313         ltmp = stone_luck(0);
3314         if (ltmp <= 0)
3315 /*JP
3316             enl_msg("Bad luck ", "does", "did", " not time out for you", "");
3317 */
3318             enl_msg("\95s\89^\82Í\8e\9e\8aÔ\90Ø\82ê\82É\82È\82ç\82È", "\82¢", "\82©\82Á\82½", "", "");
3319         if (ltmp >= 0)
3320 /*JP
3321             enl_msg("Good luck ", "does", "did", " not time out for you", "");
3322 */
3323             enl_msg("\8dK\89^\82Í\8e\9e\8aÔ\90Ø\82ê\82É\82È\82ç\82È", "\82¢", "\82©\82Á\82½", "", "");
3324     }
3325
3326     if (u.ugangr) {
3327 #if 0 /*JP*/
3328         Sprintf(buf, " %sangry with you",
3329                 u.ugangr > 6 ? "extremely " : u.ugangr > 3 ? "very " : "");
3330 #else
3331         Sprintf(buf, "%s\82Í%s\93{\82Á\82Ä%s", u_gname(),
3332                 u.ugangr > 6 ? "\96Ò\97ó\82É" : u.ugangr > 3 ? "\82Æ\82Ä\82à" : "", final ? ita : iru);
3333 #endif
3334         if (wizard)
3335             Sprintf(eos(buf), " (%d)", u.ugangr);
3336 #if 0 /*JP*/
3337         enl_msg(u_gname(), " is", " was", buf, "");
3338 #else
3339         enl_msg(buf, "", "", "", "");
3340 #endif
3341     } else {
3342         /*
3343          * We need to suppress this when the game is over, because death
3344          * can change the value calculated by can_pray(), potentially
3345          * resulting in a false claim that you could have prayed safely.
3346          */
3347         if (!final) {
3348 #if 0 /*JP*/
3349 #if 0
3350             /* "can [not] safely pray" vs "could [not] have safely prayed" */
3351             Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ",
3352                     final ? "have " : "", final ? "ed" : "");
3353 #else
3354             Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not ");
3355 #endif
3356             if (wizard)
3357                 Sprintf(eos(buf), " (%d)", u.ublesscnt);
3358             you_can(buf, "");
3359 #else /*JP*/
3360             Sprintf(buf, "\82 \82È\82½\82Í\88À\91S\82É\8bF\82é\82±\82Æ\82ª");
3361             Strcat(buf, can_pray(FALSE) ? can : "\82Å\82«\82È\82¢");
3362             if (wizard)
3363               Sprintf(eos(buf), " (%d)", u.ublesscnt);
3364             enl_msg(buf, "", "", "", "");
3365 #endif
3366         }
3367     }
3368
3369 #ifdef DEBUG
3370     /* named fruit debugging (doesn't really belong here...); to enable,
3371        include 'fruit' in DEBUGFILES list (even though it isn't a file...) */
3372     if (wizard && explicitdebug("fruit")) {
3373         struct fruit *f;
3374
3375         reorder_fruit(TRUE); /* sort by fruit index, from low to high;
3376                               * this modifies the ffruit chain, so could
3377                               * possibly mask or even introduce a problem,
3378                               * but it does useful sanity checking */
3379         for (f = ffruit; f; f = f->nextf) {
3380 /*JP
3381             Sprintf(buf, "Fruit #%d ", f->fid);
3382 */
3383             Sprintf(buf, "fruit $%d \82Í", f->fid);
3384 /*JP
3385             enl_msg(buf, "is ", "was ", f->fname, "");
3386 */
3387             enl_msg(buf, "\82¾", "\82¾\82Á\82½", f->fname, "");
3388         }
3389 /*JP
3390         enl_msg("The current fruit ", "is ", "was ", pl_fruit, "");
3391 */
3392         enl_msg("\8c»\8dÝ\82Ì fruit \82Í", "\82¾", "\82¾\82Á\82½", pl_fruit, "");
3393         Sprintf(buf, "%d", flags.made_fruit);
3394 /*JP
3395         enl_msg("The made fruit flag ", "is ", "was ", buf, "");
3396 */
3397         enl_msg("made fruit flag \82Í", "\82¾", "\82¾\82Á\82½", buf, "");
3398     }
3399 #endif
3400
3401     {
3402         const char *p;
3403
3404         buf[0] = '\0';
3405         if (final < 2) { /* still in progress, or quit/escaped/ascended */
3406 /*JP
3407             p = "survived after being killed ";
3408 */
3409             p = "\8e\80\82ñ\82¾\8cã\95\9c\8a\88\82µ\82Ä\82¢\82½";
3410             switch (u.umortality) {
3411             case 0:
3412 /*JP
3413                 p = !final ? (char *) 0 : "survived";
3414 */
3415                 p = !final ? (char *)0 : "\90\82«\89\84\82Ñ\82½";
3416                 break;
3417             case 1:
3418 /*JP
3419                 Strcpy(buf, "once");
3420 */
3421                 Strcpy(buf, "\88ê\93x");
3422                 break;
3423             case 2:
3424 /*JP
3425                 Strcpy(buf, "twice");
3426 */
3427                 Strcpy(buf, "\93ñ\93x");
3428                 break;
3429             case 3:
3430 /*JP
3431                 Strcpy(buf, "thrice");
3432 */
3433                 Strcpy(buf, "\8eO\93x");
3434                 break;
3435             default:
3436 /*JP
3437                 Sprintf(buf, "%d times", u.umortality);
3438 */
3439                 Sprintf(buf, "%d\89ñ", u.umortality);
3440                 break;
3441             }
3442         } else { /* game ended in character's death */
3443 /*JP
3444             p = "are dead";
3445 */
3446             p = "\8e\80\82ñ\82Å\82¢\82é";
3447             switch (u.umortality) {
3448             case 0:
3449                 impossible("dead without dying?");
3450             case 1:
3451                 break; /* just "are dead" */
3452             default:
3453 #if 0 /*JP*/
3454                 Sprintf(buf, " (%d%s time!)", u.umortality,
3455                         ordin(u.umortality));
3456 #else
3457                  Sprintf(buf, "(%d\89ñ\81I)", u.umortality);
3458 #endif
3459                 break;
3460             }
3461         }
3462         if (p)
3463 /*JP
3464             enl_msg(You_, "have been killed ", p, buf, "");
3465 */
3466             enl_msg(You_, "\8e\80\82ñ\82Å\82¢\82é", p, buf, "");
3467     }
3468 }
3469
3470 #if 0  /* no longer used */
3471 STATIC_DCL boolean NDECL(minimal_enlightenment);
3472
3473 /*
3474  * Courtesy function for non-debug, non-explorer mode players
3475  * to help refresh them about who/what they are.
3476  * Returns FALSE if menu cancelled (dismissed with ESC), TRUE otherwise.
3477  */
3478 STATIC_OVL boolean
3479 minimal_enlightenment()
3480 {
3481     winid tmpwin;
3482     menu_item *selected;
3483     anything any;
3484     int genidx, n;
3485     char buf[BUFSZ], buf2[BUFSZ];
3486     static const char untabbed_fmtstr[] = "%-15s: %-12s";
3487     static const char untabbed_deity_fmtstr[] = "%-17s%s";
3488     static const char tabbed_fmtstr[] = "%s:\t%-12s";
3489     static const char tabbed_deity_fmtstr[] = "%s\t%s";
3490     static const char *fmtstr;
3491     static const char *deity_fmtstr;
3492
3493     fmtstr = iflags.menu_tab_sep ? tabbed_fmtstr : untabbed_fmtstr;
3494     deity_fmtstr = iflags.menu_tab_sep ? tabbed_deity_fmtstr
3495                                        : untabbed_deity_fmtstr;
3496     any = zeroany;
3497     buf[0] = buf2[0] = '\0';
3498     tmpwin = create_nhwindow(NHW_MENU);
3499     start_menu(tmpwin);
3500     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3501 /*JP
3502              "Starting", FALSE);
3503 */
3504              "\8aJ\8en", FALSE);
3505
3506     /* Starting name, race, role, gender */
3507 /*JP
3508     Sprintf(buf, fmtstr, "name", plname);
3509 */
3510     Sprintf(buf, fmtstr, "\96¼\91O", plname);
3511     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3512 /*JP
3513     Sprintf(buf, fmtstr, "race", urace.noun);
3514 */
3515     Sprintf(buf, fmtstr, "\8eí\91°", urace.noun);
3516     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3517 /*JP
3518     Sprintf(buf, fmtstr, "role",
3519 */
3520     Sprintf(buf, fmtstr, "\90E\8bÆ",
3521             (flags.initgend && urole.name.f) ? urole.name.f : urole.name.m);
3522     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3523 /*JP
3524     Sprintf(buf, fmtstr, "gender", genders[flags.initgend].adj);
3525 */
3526     Sprintf(buf, fmtstr, "\90«\95Ê", genders[flags.initgend].adj);
3527     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3528
3529     /* Starting alignment */
3530 /*JP
3531     Sprintf(buf, fmtstr, "alignment", align_str(u.ualignbase[A_ORIGINAL]));
3532 */
3533     Sprintf(buf, fmtstr, "\91®\90«", align_str(u.ualignbase[A_ORIGINAL]));
3534     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3535
3536     /* Current name, race, role, gender */
3537     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
3538     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3539 /*JP
3540              "Current", FALSE);
3541 */
3542              "\8c»\8dÝ", FALSE);
3543 /*JP
3544     Sprintf(buf, fmtstr, "race", Upolyd ? youmonst.data->mname : urace.noun);
3545 */
3546     Sprintf(buf, fmtstr, "\8eí\91°", Upolyd ? youmonst.data->mname : urace.noun);
3547     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3548     if (Upolyd) {
3549 /*JP
3550         Sprintf(buf, fmtstr, "role (base)",
3551 */
3552         Sprintf(buf, fmtstr, "\90E\8bÆ(\8aî\96{)",
3553                 (u.mfemale && urole.name.f) ? urole.name.f
3554                                             : urole.name.m);
3555         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3556     } else {
3557 /*JP
3558         Sprintf(buf, fmtstr, "role",
3559 */
3560         Sprintf(buf, fmtstr, "\90E\8bÆ",
3561                 (flags.female && urole.name.f) ? urole.name.f
3562                                                : urole.name.m);
3563         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3564     }
3565     /* don't want poly_gender() here; it forces `2' for non-humanoids */
3566     genidx = is_neuter(youmonst.data) ? 2 : flags.female;
3567 /*JP
3568     Sprintf(buf, fmtstr, "gender", genders[genidx].adj);
3569 */
3570     Sprintf(buf, fmtstr, "\90«\95Ê", genders[genidx].adj);
3571     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3572     if (Upolyd && (int) u.mfemale != genidx) {
3573 /*JP
3574         Sprintf(buf, fmtstr, "gender (base)", genders[u.mfemale].adj);
3575 */
3576         Sprintf(buf, fmtstr, "\90«\95Ê(\8aî\96{)", genders[u.mfemale].adj);
3577         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3578     }
3579
3580     /* Current alignment */
3581 /*JP
3582     Sprintf(buf, fmtstr, "alignment", align_str(u.ualign.type));
3583 */
3584     Sprintf(buf, fmtstr, "\91®\90«", align_str(u.ualign.type));
3585     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3586
3587     /* Deity list */
3588     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
3589     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3590 /*JP
3591              "Deities", FALSE);
3592 */
3593              "\90_", FALSE);
3594 #if 0 /*JP*/
3595     Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
3596             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3597              && u.ualign.type == A_CHAOTIC)               ? " (s,c)"
3598                 : (u.ualignbase[A_ORIGINAL] == A_CHAOTIC) ? " (s)"
3599                 : (u.ualign.type   == A_CHAOTIC)          ? " (c)" : "");
3600 #else
3601     Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
3602             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3603              && u.ualign.type == A_CHAOTIC)               ? " (\8f\89\81C\8c»)"
3604                 : (u.ualignbase[A_ORIGINAL] == A_CHAOTIC) ? " (\8f\89)"
3605                 : (u.ualign.type   == A_CHAOTIC)          ? " (\8c»)" : "");
3606 #endif
3607 /*JP
3608     Sprintf(buf, fmtstr, "Chaotic", buf2);
3609 */
3610     Sprintf(buf, fmtstr, "\8d¬\93×", buf2);
3611     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3612
3613 #if 0 /*JP*/
3614     Sprintf(buf2, deity_fmtstr, align_gname(A_NEUTRAL),
3615             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3616              && u.ualign.type == A_NEUTRAL)               ? " (s,c)"
3617                 : (u.ualignbase[A_ORIGINAL] == A_NEUTRAL) ? " (s)"
3618                 : (u.ualign.type   == A_NEUTRAL)          ? " (c)" : "");
3619 #else
3620     Sprintf(buf2, deity_fmtstr, align_gname(A_NEUTRAL),
3621             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3622              && u.ualign.type == A_NEUTRAL)               ? " (\8f\89\81C\8c»)"
3623                 : (u.ualignbase[A_ORIGINAL] == A_NEUTRAL) ? " (\8f\89)"
3624                 : (u.ualign.type   == A_NEUTRAL)          ? " (\8c»)" : "");
3625 #endif
3626 /*JP
3627     Sprintf(buf, fmtstr, "Neutral", buf2);
3628 */
3629     Sprintf(buf, fmtstr, "\92\86\97§", buf2);
3630     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3631
3632 #if 0 /*JP*/
3633     Sprintf(buf2, deity_fmtstr, align_gname(A_LAWFUL),
3634             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3635              && u.ualign.type == A_LAWFUL)                ? " (s,c)"
3636                 : (u.ualignbase[A_ORIGINAL] == A_LAWFUL)  ? " (s)"
3637                 : (u.ualign.type   == A_LAWFUL)           ? " (c)" : "");
3638 #else
3639     Sprintf(buf2, deity_fmtstr, align_gname(A_LAWFUL),
3640             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3641              && u.ualign.type == A_LAWFUL)                ? " (\8f\89\81C\8c»)"
3642                 : (u.ualignbase[A_ORIGINAL] == A_LAWFUL)  ? " (\8f\89)"
3643                 : (u.ualign.type   == A_LAWFUL)           ? " (\8c»)" : "");
3644 #endif
3645 /*JP
3646     Sprintf(buf, fmtstr, "Lawful", buf2);
3647 */
3648     Sprintf(buf, fmtstr, "\92\81\8f\98", buf2);
3649     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3650
3651 /*JP
3652     end_menu(tmpwin, "Base Attributes");
3653 */
3654     end_menu(tmpwin, "\8aî\96{\91®\90«");
3655     n = select_menu(tmpwin, PICK_NONE, &selected);
3656     destroy_nhwindow(tmpwin);
3657     return (boolean) (n != -1);
3658 }
3659 #endif /*0*/
3660
3661 /* ^X command */
3662 STATIC_PTR int
3663 doattributes(VOID_ARGS)
3664 {
3665     int mode = BASICENLIGHTENMENT;
3666
3667     /* show more--as if final disclosure--for wizard and explore modes */
3668     if (wizard || discover)
3669         mode |= MAGICENLIGHTENMENT;
3670
3671     enlightenment(mode, ENL_GAMEINPROGRESS);
3672     return 0;
3673 }
3674
3675 void
3676 youhiding(via_enlghtmt, msgflag)
3677 boolean via_enlghtmt; /* englightment line vs topl message */
3678 int msgflag;          /* for variant message phrasing */
3679 {
3680     char *bp, buf[BUFSZ];
3681
3682 /*JP
3683     Strcpy(buf, "hiding");
3684 */
3685     Strcpy(buf, "\89B\82ê");
3686     if (youmonst.m_ap_type != M_AP_NOTHING) {
3687         /* mimic; hero is only able to mimic a strange object or gold
3688            or hallucinatory alternative to gold, so we skip the details
3689            for the hypothetical furniture and monster cases */
3690 #if 0 /*JP*//*\8cã\82ë\82É\89ñ\82·*//* not used */
3691         bp = eos(strcpy(buf, "mimicking"));
3692 #endif
3693         if (youmonst.m_ap_type == M_AP_OBJECT) {
3694 /*JP
3695             Sprintf(bp, " %s", an(simple_typename(youmonst.mappearance)));
3696 */
3697             Strcpy(buf, simple_typename(youmonst.mappearance));
3698         } else if (youmonst.m_ap_type == M_AP_FURNITURE) {
3699 /*JP
3700             Strcpy(bp, " something");
3701 */
3702             Strcpy(buf, "\89½\82©");
3703         } else if (youmonst.m_ap_type == M_AP_MONSTER) {
3704 /*JP
3705             Strcpy(bp, " someone");
3706 */
3707             Strcpy(buf, "\89½\8eÒ\82©");
3708         } else {
3709             ; /* something unexpected; leave 'buf' as-is */
3710         }
3711 #if 1 /*JP*//*\82±\82±\82Å\92Ç\89Á*/
3712         Strcat(buf, "\82Ì\82Ó\82è\82ð\82µ");
3713 #endif
3714     } else if (u.uundetected) {
3715         bp = eos(buf); /* points past "hiding" */
3716         if (youmonst.data->mlet == S_EEL) {
3717             if (is_pool(u.ux, u.uy))
3718 /*JP
3719                 Sprintf(bp, " in the %s", waterbody_name(u.ux, u.uy));
3720 */
3721                 Sprintf(bp, "%s\82Ì\92\86\82É", waterbody_name(u.ux, u.uy));
3722         } else if (hides_under(youmonst.data)) {
3723             struct obj *o = level.objects[u.ux][u.uy];
3724
3725             if (o)
3726 /*JP
3727                 Sprintf(bp, " underneath %s", ansimpleoname(o));
3728 */
3729                 Sprintf(bp, "%s\82Ì\89º\82É", ansimpleoname(o));
3730         } else if (is_clinger(youmonst.data) || Flying) {
3731             /* Flying: 'lurker above' hides on ceiling but doesn't cling */
3732 /*JP
3733             Sprintf(bp, " on the %s", ceiling(u.ux, u.uy));
3734 */
3735             Sprintf(bp, "%s\82É", ceiling(u.ux, u.uy));
3736         } else {
3737             /* on floor; is_hider() but otherwise not special: 'trapper' */
3738             if (u.utrap && u.utraptype == TT_PIT) {
3739                 struct trap *t = t_at(u.ux, u.uy);
3740
3741 #if 0 /*JP*/
3742                 Sprintf(bp, " in a %spit",
3743                         (t && t->ttyp == SPIKED_PIT) ? "spiked " : "");
3744 #else
3745                 Sprintf(bp, "%s\97\8e\82µ\8c\8a\82Ì\92\86\82É",
3746                         (t && t->ttyp == SPIKED_PIT) ? "\83g\83Q\82¾\82ç\82¯\82Ì" : "");
3747 #endif
3748             } else
3749 /*JP
3750                 Sprintf(bp, " on the %s", surface(u.ux, u.uy));
3751 */
3752                 Sprintf(bp, "%s\82É", surface(u.ux, u.uy));
3753         }
3754 #if 1 /*JP*//*\82±\82±\82Å\92Ç\89Á*/
3755         Strcat(buf, "\89B\82ê");
3756 #endif
3757     } else {
3758         ; /* shouldn't happen; will result in generic "you are hiding" */
3759     }
3760
3761     if (via_enlghtmt) {
3762         int final = msgflag; /* 'final' is used by you_are() macro */
3763
3764         you_are(buf, "");
3765     } else {
3766         /* for dohide(), when player uses '#monster' command */
3767 #if 0 /*JP*/
3768         You("are %s %s.", msgflag ? "already" : "now", buf);
3769 #else
3770         if (msgflag) {
3771             You("\82·\82Å\82É%s\82Ä\82¢\82é\81D", buf);
3772         } else {
3773             You("%s\82½\81D", buf);
3774         }
3775 #endif
3776     }
3777 }
3778
3779 /* KMH, #conduct
3780  * (shares enlightenment's tense handling)
3781  */
3782 int
3783 doconduct(VOID_ARGS)
3784 {
3785     show_conduct(0);
3786     return 0;
3787 }
3788
3789 void
3790 show_conduct(final)
3791 int final;
3792 {
3793     char buf[BUFSZ];
3794     int ngenocided;
3795
3796     /* Create the conduct window */
3797     en_win = create_nhwindow(NHW_MENU);
3798 /*JP
3799     putstr(en_win, 0, "Voluntary challenges:");
3800 */
3801     putstr(en_win, 0, "\8e©\94­\93I\92§\90í:");
3802
3803     if (u.uroleplay.blind)
3804 /*JP
3805         you_have_been("blind from birth");
3806 */
3807         you_have_been("\90\82Ü\82ê\82È\82ª\82ç\82É\96Ó\96Ú");
3808     if (u.uroleplay.nudist)
3809 /*JP
3810         you_have_been("faithfully nudist");
3811 */
3812         you_have_been("\92\89\8eÀ\82È\97\87\91°");
3813
3814     if (!u.uconduct.food)
3815 /*JP
3816         enl_msg(You_, "have gone", "went", " without food", "");
3817 */
3818         enl_msg("\82 \82È\82½\82Í\90H\8e\96\82ð\82µ", "\82Ä\82¢\82È\82¢", "\82È\82©\82Á\82½", "", "");
3819         /* but beverages are okay */
3820     else if (!u.uconduct.unvegan)
3821 /*JP
3822         you_have_X("followed a strict vegan diet");
3823 */
3824         you_have_been("\8cµ\8ai\82È\8dØ\90H\8eå\8b`\8eÒ");
3825     else if (!u.uconduct.unvegetarian)
3826 /*JP
3827         you_have_been("vegetarian");
3828 */
3829         you_have_been("\8dØ\90H\8eå\8b`\8eÒ");
3830
3831     if (!u.uconduct.gnostic)
3832 /*JP
3833         you_have_been("an atheist");
3834 */
3835         you_have_been("\96³\90_\98_\8eÒ");
3836
3837     if (!u.uconduct.weaphit) {
3838 /*JP
3839         you_have_never("hit with a wielded weapon");
3840 */
3841         you_have_never("\82 \82È\82½\82Í\91\95\94õ\82µ\82Ä\82¢\82é\95\90\8aí\82Å\8dU\8c\82\82µ");
3842     } else if (wizard) {
3843 #if 0 /*JP*/
3844         Sprintf(buf, "used a wielded weapon %ld time%s", u.uconduct.weaphit,
3845                 plur(u.uconduct.weaphit));
3846         you_have_X(buf);
3847 #else
3848         Sprintf(buf, "\82 \82È\82½\82Í%ld\89ñ\91\95\94õ\82µ\82½\95\90\8aí\82ð\8eg\97p\82µ", u.uconduct.weaphit);
3849         you_have_X(buf);
3850 #endif
3851     }
3852     if (!u.uconduct.killer)
3853 /*JP
3854         you_have_been("a pacifist");
3855 */
3856         you_have_been("\95½\98a\8eå\8b`\8eÒ");
3857
3858     if (!u.uconduct.literate) {
3859 /*JP
3860         you_have_been("illiterate");
3861 */
3862         you_have_never("\82 \82È\82½\82Í\93Ç\82Ý\8f\91\82«\82µ");
3863     } else if (wizard) {
3864 #if 0 /*JP:T*/
3865         Sprintf(buf, "read items or engraved %ld time%s", u.uconduct.literate,
3866                 plur(u.uconduct.literate));
3867         you_have_X(buf);
3868 #else
3869         Sprintf(buf, "%ld\89ñ\93Ç\82ñ\82¾\82è\8f\91\82¢\82½\82è\82µ", u.uconduct.literate);
3870         you_have_X(buf);
3871 #endif
3872     }
3873
3874     ngenocided = num_genocides();
3875     if (ngenocided == 0) {
3876 /*JP
3877         you_have_never("genocided any monsters");
3878 */
3879         you_have_never("\82 \82È\82½\82Í\89ö\95¨\82ð\8bs\8eE\82µ");
3880     } else {
3881 #if 0 /*JP:T*/
3882         Sprintf(buf, "genocided %d type%s of monster%s", ngenocided,
3883                 plur(ngenocided), plur(ngenocided));
3884         you_have_X(buf);
3885 #else
3886         Sprintf(buf, "%d\8eí\82Ì\89ö\95¨\82ð\8bs\8eE\82µ", ngenocided);
3887         you_have_X(buf);
3888 #endif
3889     }
3890
3891     if (!u.uconduct.polypiles) {
3892 /*JP
3893         you_have_never("polymorphed an object");
3894 */
3895         you_have_never("\82 \82È\82½\82Í\95¨\91Ì\82ð\95Ï\89»\82³\82¹");
3896     } else if (wizard) {
3897 #if 0 /*JP:T*/
3898         Sprintf(buf, "polymorphed %ld item%s", u.uconduct.polypiles,
3899                 plur(u.uconduct.polypiles));
3900         you_have_X(buf);
3901 #else
3902         Sprintf(buf, "%ld\8cÂ\82Ì\95¨\82ð\95Ï\89»\82³\82¹", u.uconduct.polypiles);
3903         you_have_X(buf);
3904 #endif
3905     }
3906
3907     if (!u.uconduct.polyselfs) {
3908 /*JP
3909         you_have_never("changed form");
3910 */
3911         you_have_never("\82 \82È\82½\82Í\95Ï\89»\82µ");
3912     } else if (wizard) {
3913 #if 0 /*JP:T*/
3914         Sprintf(buf, "changed form %ld time%s", u.uconduct.polyselfs,
3915                 plur(u.uconduct.polyselfs));
3916         you_have_X(buf);
3917 #else
3918         Sprintf(buf, "%ld\89ñ\8ep\82ð\95Ï\82¦", u.uconduct.polyselfs);
3919         you_have_X(buf);
3920 #endif
3921     }
3922
3923     if (!u.uconduct.wishes) {
3924 /*JP
3925         you_have_X("used no wishes");
3926 */
3927         you_have_never("\82 \82È\82½\82Í\8aè\82¢\8e\96\82ð\82µ");
3928     } else {
3929 #if 0 /*JP*/
3930         Sprintf(buf, "used %ld wish%s", u.uconduct.wishes,
3931                 (u.uconduct.wishes > 1L) ? "es" : "");
3932 #else
3933         Sprintf(buf, "%ld\89ñ\8aè\82¢\8e\96\82ð\82µ", u.uconduct.wishes);
3934 #endif
3935         if (u.uconduct.wisharti) {
3936             /* if wisharti == wishes
3937              *  1 wish (for an artifact)
3938              *  2 wishes (both for artifacts)
3939              *  N wishes (all for artifacts)
3940              * else (N is at least 2 in order to get here; M < N)
3941              *  N wishes (1 for an artifact)
3942              *  N wishes (M for artifacts)
3943              */
3944             if (u.uconduct.wisharti == u.uconduct.wishes)
3945                 Sprintf(eos(buf), " (%s",
3946                         (u.uconduct.wisharti > 2L) ? "all "
3947                           : (u.uconduct.wisharti == 2L) ? "both " : "");
3948             else
3949                 Sprintf(eos(buf), " (%ld ", u.uconduct.wisharti);
3950
3951             Sprintf(eos(buf), "for %s)",
3952                     (u.uconduct.wisharti == 1L) ? "an artifact"
3953                                                 : "artifacts");
3954         }
3955         you_have_X(buf);
3956
3957         if (!u.uconduct.wisharti)
3958 #if 0 /*JP*/
3959             enl_msg(You_, "have not wished", "did not wish",
3960                     " for any artifacts", "");
3961 #else
3962             enl_msg("\82 \82È\82½\82Í\90¹\8aí\82ð\8aè", "\82Á\82Ä\82¢\82È\82¢", "\82í\82È\82©\82Á\82½", "", "");
3963 #endif
3964     }
3965
3966     /* Pop up the window and wait for a key */
3967     display_nhwindow(en_win, TRUE);
3968     destroy_nhwindow(en_win);
3969     en_win = WIN_ERR;
3970 }
3971
3972 /* Macros for meta and ctrl modifiers:
3973  *   M and C return the meta/ctrl code for the given character;
3974  *     e.g., (C('c') is ctrl-c
3975  */
3976 #ifndef M
3977 #ifndef NHSTDC
3978 #define M(c) (0x80 | (c))
3979 #else
3980 #define M(c) ((c) - 128)
3981 #endif /* NHSTDC */
3982 #endif
3983
3984 #ifndef C
3985 #define C(c) (0x1f & (c))
3986 #endif
3987
3988 /* ordered by command name */
3989 struct ext_func_tab extcmdlist[] = {
3990     { '#', "#", "perform an extended command",
3991             doextcmd, IFBURIED | GENERALCMD },
3992 #if 0 /*JP*/
3993     { M('?'), "?", "list all extended commands",
3994 #else
3995     { M('?'), "?", "\82±\82Ì\8ag\92£\83R\83}\83\93\83h\88ê\97\97\82ð\95\\8e¦\82·\82é",
3996 #endif
3997             doextlist, IFBURIED | AUTOCOMPLETE | GENERALCMD },
3998 #if 0 /*JP*/
3999     { M('a'), "adjust", "adjust inventory letters",
4000 #else
4001     { M('a'), "adjust", "\8e\9d\82¿\95¨\88ê\97\97\82Ì\92²\90®",
4002 #endif
4003             doorganize, IFBURIED | AUTOCOMPLETE },
4004 #if 0 /*JP*/
4005     { M('A'), "annotate", "name current level",
4006 #else
4007     { M('A'), "annotate", "\8c»\8dÝ\82Ì\8aK\82É\96¼\91O\82ð\82Â\82¯\82é",
4008 #endif
4009             donamelevel, IFBURIED | AUTOCOMPLETE },
4010     { 'a', "apply", "apply (use) a tool (pick-axe, key, lamp...)",
4011             doapply },
4012     { C('x'), "attributes", "show your attributes",
4013             doattributes, IFBURIED },
4014     { '@', "autopickup", "toggle the pickup option on/off",
4015             dotogglepickup, IFBURIED },
4016     { 'C', "call", "call (name) something", docallcmd, IFBURIED },
4017     { 'Z', "cast", "zap (cast) a spell", docast, IFBURIED },
4018 #if 0 /*JP*/
4019     { M('c'), "chat", "talk to someone", dotalk, IFBURIED | AUTOCOMPLETE },
4020 #else
4021     { M('c'), "chat", "\92N\82©\82Æ\98b\82·", dotalk, IFBURIED | AUTOCOMPLETE },
4022 #endif
4023     { 'c', "close", "close a door", doclose },
4024 #if 0 /*JP*/
4025     { M('C'), "conduct", "list voluntary challenges you have maintained",
4026 #else
4027     { M('C'), "conduct", "\82Ç\82¤\82¢\82¤\8ds\93®\82ð\82Æ\82Á\82½\82©\8c©\82é",
4028 #endif
4029             doconduct, IFBURIED | AUTOCOMPLETE },
4030 #if 0 /*JP*/
4031     { M('d'), "dip", "dip an object into something", dodip, AUTOCOMPLETE },
4032 #else
4033     { M('d'), "dip", "\89½\82©\82É\95¨\82ð\90Z\82·", dodip, AUTOCOMPLETE },
4034 #endif
4035     { '>', "down", "go down a staircase", dodown },
4036     { 'd', "drop", "drop an item", dodrop },
4037     { 'D', "droptype", "drop specific item types", doddrop },
4038     { 'e', "eat", "eat something", doeat },
4039     { 'E', "engrave", "engrave writing on the floor", doengrave },
4040 #if 0 /*JP*/
4041     { M('e'), "enhance", "advance or check weapon and spell skills",
4042 #else
4043     { M('e'), "enhance", "\95\90\8aí\8fn\97û\93x\82ð\8d\82\82ß\82é",
4044 #endif
4045             enhance_weapon_skill, IFBURIED | AUTOCOMPLETE },
4046 #if 0 /*JP*/
4047     { '\0', "exploremode", "enter explore (discovery) mode",
4048 #else
4049     { '\0', "exploremode", "\92T\8c\9f(\94­\8c©)\83\82\81[\83h\82É\93ü\82é",
4050 #endif
4051             enter_explore_mode, IFBURIED },
4052     { 'f', "fire", "fire ammunition from quiver", dofire },
4053 #if 0 /*JP*/
4054     { M('f'), "force", "force a lock", doforce, AUTOCOMPLETE },
4055 #else
4056     { M('f'), "force", "\8c®\82ð\82±\82\82 \82¯\82é", doforce, AUTOCOMPLETE },
4057 #endif
4058     { ';', "glance", "show what type of thing a map symbol corresponds to",
4059             doquickwhatis, IFBURIED | GENERALCMD },
4060     { '?', "help", "give a help message", dohelp, IFBURIED | GENERALCMD },
4061     { '\0', "herecmdmenu", "show menu of commands you can do here",
4062             doherecmdmenu, IFBURIED },
4063     { 'V', "history", "show long version and game history",
4064             dohistory, IFBURIED | GENERALCMD },
4065     { 'i', "inventory", "show your inventory", ddoinv, IFBURIED },
4066     { 'I', "inventtype", "inventory specific item types",
4067             dotypeinv, IFBURIED },
4068 #if 0 /*JP*/
4069     { M('i'), "invoke", "invoke an object's special powers",
4070 #else
4071     { M('i'), "invoke", "\95¨\82Ì\93Á\95Ê\82È\97Í\82ð\8eg\82¤",
4072 #endif
4073             doinvoke, IFBURIED | AUTOCOMPLETE },
4074 #if 0 /*JP*/
4075     { M('j'), "jump", "jump to another location", dojump, AUTOCOMPLETE },
4076 #else
4077     { M('j'), "jump", "\91¼\82Ì\88Ê\92u\82É\94ò\82Ñ\82¤\82Â\82é", dojump, AUTOCOMPLETE },
4078 #endif
4079     { C('d'), "kick", "kick something", dokick },
4080     { '\\', "known", "show what object types have been discovered",
4081             dodiscovered, IFBURIED | GENERALCMD },
4082     { '`', "knownclass", "show discovered types for one class of objects",
4083             doclassdisco, IFBURIED | GENERALCMD },
4084 #if 0 /*JP*/
4085     { '\0', "levelchange", "change experience level",
4086 #else
4087     { '\0', "levelchange", "\8co\8c±\83\8c\83x\83\8b\82ð\95Ï\82¦\82é",
4088 #endif
4089             wiz_level_change, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4090 #if 0 /*JP*/
4091     { '\0', "lightsources", "show mobile light sources",
4092 #else
4093     { '\0', "lightsources", "\88Ú\93®\8cõ\8c¹\82ð\8c©\82é",
4094 #endif
4095             wiz_light_sources, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4096     { ':', "look", "look at what is here", dolook, IFBURIED },
4097 #if 0 /*JP*/
4098     { M('l'), "loot", "loot a box on the floor", doloot, AUTOCOMPLETE },
4099 #else
4100     { M('l'), "loot", "\8f°\82Ì\8fã\82Ì\94 \82ð\8aJ\82¯\82é", doloot, AUTOCOMPLETE },
4101 #endif
4102 #ifdef DEBUG_MIGRATING_MONS
4103 #if 0 /*JP*/
4104     { '\0', "migratemons", "migrate N random monsters",
4105 #else
4106     { '\0', "migratemons", "\83\89\83\93\83_\83\80\82È\89ö\95¨\82ð\89½\91Ì\82©\88Ú\8fZ\82³\82¹\82é",
4107 #endif
4108             wiz_migrate_mons, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4109 #endif
4110 #if 0 /*JP*/
4111     { '\0', "monpolycontrol", "control monster polymorphs",
4112 #else
4113     { '\0', "monpolycontrol", "\89ö\95¨\82Ö\82Ì\95Ï\89»\82ð\90§\8cä\82·\82é",
4114 #endif
4115             wiz_mon_polycontrol, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4116 #if 0 /*JP*/
4117     { M('m'), "monster", "use monster's special ability",
4118 #else
4119     { M('m'), "monster", "\89ö\95¨\82Ì\93Á\95Ê\94\\97Í\82ð\8eg\82¤",
4120 #endif
4121             domonability, IFBURIED | AUTOCOMPLETE },
4122 #if 0 /*JP*/
4123     { 'N', "name", "name a monster or an object",
4124 #else
4125     { 'N', "name", "\83A\83C\83e\83\80\82â\95¨\82É\96¼\91O\82ð\82Â\82¯\82é",
4126 #endif
4127             docallcmd, IFBURIED | AUTOCOMPLETE },
4128 #if 0 /*JP*/
4129     { M('o'), "offer", "offer a sacrifice to the gods",
4130 #else
4131     { M('o'), "offer", "\90_\82É\8b\9f\95¨\82ð\95ù\82°\82é",
4132 #endif
4133             dosacrifice, AUTOCOMPLETE },
4134     { 'o', "open", "open a door", doopen },
4135     { 'O', "options", "show option settings, possibly change them",
4136             doset, IFBURIED | GENERALCMD },
4137 #if 0 /*JP*/
4138     { C('o'), "overview", "show a summary of the explored dungeon",
4139 #else
4140     { C('o'), "overview", "\92T\8dõ\82µ\82½\96À\8b{\82Ì\8aT\97v\82ð\95\\8e¦\82·\82é",
4141 #endif
4142             dooverview, IFBURIED | AUTOCOMPLETE },
4143 #if 0 /*JP*/
4144     { '\0', "panic", "test panic routine (fatal to game)",
4145 #else
4146     { '\0', "panic", "\83p\83j\83b\83N\83\8b\81[\83`\83\93\82ð\83e\83X\83g\82·\82é(\92v\96½\93I)",
4147 #endif
4148             wiz_panic, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4149     { 'p', "pay", "pay your shopping bill", dopay },
4150     { ',', "pickup", "pick up things at the current location", dopickup },
4151 #if 0 /*JP*/
4152     { '\0', "polyself", "polymorph self",
4153 #else
4154     { '\0', "polyself", "\95Ï\89»\82·\82é",
4155 #endif
4156             wiz_polyself, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4157 #ifdef PORT_DEBUG
4158 #if 0 /*JP*/
4159     { '\0', "portdebug", "wizard port debug command",
4160 #else
4161     { '\0', "portdebug", "\83E\83B\83U\81[\83h\83|\81[\83g\83f\83o\83b\83O\83R\83}\83\93\83h",
4162 #endif
4163             wiz_port_debug, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4164 #endif
4165 #if 0 /*JP*/
4166     { M('p'), "pray", "pray to the gods for help",
4167 #else
4168     { M('p'), "pray", "\90_\82É\8bF\82é",
4169 #endif
4170             dopray, IFBURIED | AUTOCOMPLETE },
4171     { C('p'), "prevmsg", "view recent game messages",
4172             doprev_message, IFBURIED | GENERALCMD },
4173     { 'P', "puton", "put on an accessory (ring, amulet, etc)", doputon },
4174     { 'q', "quaff", "quaff (drink) something", dodrink },
4175 #if 0 /*JP*/
4176     { M('q'), "quit", "exit without saving current game",
4177 #else
4178     { M('q'), "quit", "\83Z\81[\83u\82µ\82È\82¢\82Å\8fI\97¹",
4179 #endif
4180             done2, IFBURIED | AUTOCOMPLETE | GENERALCMD },
4181     { 'Q', "quiver", "select ammunition for quiver", dowieldquiver },
4182     { 'r', "read", "read a scroll or spellbook", doread },
4183     { C('r'), "redraw", "redraw screen", doredraw, IFBURIED | GENERALCMD },
4184     { 'R', "remove", "remove an accessory (ring, amulet, etc)", doremring },
4185 #if 0 /*JP*/
4186     { M('R'), "ride", "mount or dismount a saddled steed",
4187 #else
4188     { M('R'), "ride", "\89ö\95¨\82É\8fæ\82é(\82Ü\82½\82Í\8d~\82è\82é)",
4189 #endif
4190             doride, AUTOCOMPLETE },
4191 #if 0 /*JP*/
4192     { M('r'), "rub", "rub a lamp or a stone", dorub, AUTOCOMPLETE },
4193 #else
4194     { M('r'), "rub", "\83\89\83\93\83v\82ð\82±\82·\82é", dorub, AUTOCOMPLETE },
4195 #endif
4196     { 'S', "save", "save the game and exit", dosave, IFBURIED | GENERALCMD },
4197 #if 0 /*JP*/
4198     { 's', "search", "search for traps and secret doors",
4199             dosearch, IFBURIED, "searching" },
4200 #else
4201     { 's', "search", "ã©\82â\89B\82µ\94à\82ð\92T\82·",
4202             dosearch, IFBURIED, "\92T\82·" },
4203 #endif
4204     { '*', "seeall", "show all equipment in use", doprinuse, IFBURIED },
4205     { AMULET_SYM, "seeamulet", "show the amulet currently worn",
4206             dopramulet, IFBURIED },
4207     { ARMOR_SYM, "seearmor", "show the armor currently worn",
4208             doprarm, IFBURIED },
4209     { GOLD_SYM, "seegold", "count your gold", doprgold, IFBURIED },
4210 #if 0 /*JP*/
4211     { '\0', "seenv", "show seen vectors",
4212 #else
4213     { '\0', "seenv", "\8e\8b\90ü\83x\83N\83g\83\8b\82ð\8c©\82é",
4214 #endif
4215             wiz_show_seenv, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4216     { RING_SYM, "seerings", "show the ring(s) currently worn",
4217             doprring, IFBURIED },
4218     { SPBOOK_SYM, "seespells", "list and reorder known spells",
4219             dovspell, IFBURIED },
4220     { TOOL_SYM, "seetools", "show the tools currently in use",
4221             doprtool, IFBURIED },
4222     { '^', "seetrap", "show the type of adjacent trap", doidtrap, IFBURIED },
4223     { WEAPON_SYM, "seeweapon", "show the weapon currently wielded",
4224             doprwep, IFBURIED },
4225 #ifdef SHELL
4226     { '!', "shell", "do a shell escape", dosh, IFBURIED | GENERALCMD },
4227 #endif /* SHELL */
4228 #if 0 /*JP*/
4229     { M('s'), "sit", "sit down", dosit, AUTOCOMPLETE },
4230     { '\0', "stats", "show memory statistics",
4231 #else
4232     { M('s'), "sit", "\8dÀ\82é", dosit, AUTOCOMPLETE },
4233     { '\0', "stats", "\83\81\83\82\83\8a\8fó\91Ô\82ð\8c©\82é",
4234 #endif
4235             wiz_show_stats, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4236 #ifdef SUSPEND
4237     { C('z'), "suspend", "suspend the game",
4238             dosuspend_core, IFBURIED | GENERALCMD },
4239 #endif /* SUSPEND */
4240     { 'x', "swap", "swap wielded and secondary weapons", doswapweapon },
4241     { 'T', "takeoff", "take off one piece of armor", dotakeoff },
4242     { 'A', "takeoffall", "remove all armor", doddoremarm },
4243     { C('t'), "teleport", "teleport around the level", dotele, IFBURIED },
4244 #if 0 /*JP*/
4245     { '\0', "terrain", "show map without obstructions",
4246 #else
4247     { '\0', "terrain", "\8e×\96\82\82³\82ê\82¸\82É\92n\90}\82ð\8c©\82é",
4248 #endif
4249             doterrain, IFBURIED | AUTOCOMPLETE },
4250     { '\0', "therecmdmenu",
4251             "menu of commands you can do from here to adjacent spot",
4252             dotherecmdmenu },
4253     { 't', "throw", "throw something", dothrow },
4254 #if 0 /*JP*/
4255     { '\0', "timeout", "look at timeout queue and hero's timed intrinsics",
4256 #else
4257     { '\0', "timeout", "\8e\9e\8aÔ\90Ø\82ê\83L\83\85\81[\82Æ\83v\83\8c\83C\83\84\81[\82Ì\8e\9e\8aÔ\8co\89ß\82ð\8c©\82é",
4258 #endif
4259             wiz_timeout_queue, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4260 #if 0 /*JP*/
4261     { M('T'), "tip", "empty a container", dotip, AUTOCOMPLETE },
4262 #else
4263     { M('T'), "tip", "\93ü\82ê\95¨\82ð\8bó\82É\82·\82é", dotip, AUTOCOMPLETE },
4264 #endif
4265     { '_', "travel", "travel to a specific location on the map", dotravel },
4266 #if 0 /*JP*/
4267     { M('t'), "turn", "turn undead away", doturn, IFBURIED | AUTOCOMPLETE },
4268 #else
4269     { M('t'), "turn", "\83A\83\93\83f\83b\83g\82ð\93y\82É\95Ô\82·", doturn, IFBURIED | AUTOCOMPLETE },
4270 #endif
4271 #if 0 /*JP*/
4272     { 'X', "twoweapon", "toggle two-weapon combat",
4273 #else
4274     { 'X', "twoweapon", "\97¼\8eè\8e\9d\82¿\82Ì\90Ø\82è\91Ö\82¦",
4275 #endif
4276             dotwoweapon, AUTOCOMPLETE },
4277 #if 0 /*JP*/
4278     { M('u'), "untrap", "untrap something", dountrap, AUTOCOMPLETE },
4279 #else
4280     { M('u'), "untrap", "ã©\82ð\82Í\82¸\82·", dountrap, AUTOCOMPLETE },
4281 #endif
4282     { '<', "up", "go up a staircase", doup },
4283 #if 0 /*JP*/
4284     { '\0', "vanquished", "list vanquished monsters",
4285 #else
4286     { '\0', "vanquished", "\93|\82µ\82½\89ö\95¨\82Ì\88ê\97\97\82ð\8c©\82é",
4287 #endif
4288             dovanquished, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4289     { M('v'), "version",
4290 #if 0 /*JP*/
4291             "list compile time options for this version of NetHack",
4292 #else
4293             "\83R\83\93\83p\83C\83\8b\8e\9e\82Ì\83I\83v\83V\83\87\83\93\82ð\95\\8e¦\82·\82é",
4294 #endif
4295             doextversion, IFBURIED | AUTOCOMPLETE | GENERALCMD },
4296     { 'v', "versionshort", "show version", doversion, IFBURIED | GENERALCMD },
4297 #if 0 /*JP*/
4298     { '\0', "vision", "show vision array",
4299 #else
4300     { '\0', "vision", "\8e\8b\8aE\94z\97ñ\82ð\8c©\82é",
4301 #endif
4302             wiz_show_vision, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4303 #if 0 /*JP*/
4304     { '.', "wait", "rest one move while doing nothing",
4305             donull, IFBURIED, "waiting" },
4306 #else
4307     { '.', "wait", "\88ê\95à\95ª\89½\82à\82µ\82È\82¢",
4308             donull, IFBURIED, "\8bx\8ce\82·\82é" },
4309 #endif
4310     { 'W', "wear", "wear a piece of armor", dowear },
4311     { '&', "whatdoes", "tell what a command does", dowhatdoes, IFBURIED },
4312     { '/', "whatis", "show what type of thing a symbol corresponds to",
4313             dowhatis, IFBURIED | GENERALCMD },
4314     { 'w', "wield", "wield (put in use) a weapon", dowield },
4315 #if 0 /*JP*/
4316     { M('w'), "wipe", "wipe off your face", dowipe, AUTOCOMPLETE },
4317 #else
4318     { M('w'), "wipe", "\8aç\82ð\90@\82¤", dowipe, AUTOCOMPLETE },
4319 #endif
4320 #ifdef DEBUG
4321 #if 0 /*JP*/
4322     { '\0', "wizdebug_bury", "wizard debug: bury objs under and around you",
4323 #else
4324     { '\0', "wizdebug_bury", "\83E\83B\83U\81[\83h\82Å\83o\83b\83O: \95¨\82ð\82 \82È\82½\82Ì\8eü\82è\82É\96\84\82ß\82é",
4325 #endif
4326             wiz_debug_cmd_bury, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4327 #if 0 /*JP*/
4328     { '\0', "wizdebug_traveldisplay", "wizard debug: toggle travel display",
4329 #else
4330     { '\0', "wizdebug_traveldisplay", "\83E\83B\83U\81[\83h\83f\83o\83b\83O: \88Ú\93®\95\\8e¦\82ð\90Ø\82è\91Ö\82¦\82é",
4331 #endif
4332           wiz_debug_cmd_traveldisplay, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4333 #endif
4334     { C('e'), "wizdetect", "reveal hidden things within a small radius",
4335             wiz_detect, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4336     { C('g'), "wizgenesis", "create a monster",
4337             wiz_genesis, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4338     { C('i'), "wizidentify", "identify all items in inventory",
4339             wiz_identify, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4340     { '\0', "wizintrinsic", "set an intrinsic",
4341             wiz_intrinsic, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4342     { C('v'), "wizlevelport", "teleport to another level",
4343             wiz_level_tele, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4344     { '\0', "wizmakemap", "recreate the current level",
4345             wiz_makemap, IFBURIED | WIZMODECMD },
4346     { C('f'), "wizmap", "map the level",
4347             wiz_map, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4348 #if 0 /*JP*/
4349     { '\0', "wizrumorcheck", "verify rumor boundaries",
4350 #else
4351     { '\0', "wizrumorcheck", "\89\\82Ì\8b«\8aE\82ð\8c\9f\8fØ\82·\82é",
4352 #endif
4353             wiz_rumor_check, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4354 #if 0 /*JP*/
4355     { '\0', "wizsmell", "smell monster",
4356 #else
4357     { '\0', "wizsmell", "\89ö\95¨\82Ì\93õ\82¢\82ð\9ak\82®",
4358 #endif
4359             wiz_smell, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4360     { '\0', "wizwhere", "show locations of special levels",
4361             wiz_where, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4362     { C('w'), "wizwish", "wish for something",
4363             wiz_wish, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4364 #if 0 /*JP*/
4365     { '\0', "wmode", "show wall modes",
4366 #else
4367     { '\0', "wmode", "\95Ç\83\82\81[\83h\82ð\8c©\82é",
4368 #endif
4369             wiz_show_wmodes, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4370     { 'z', "zap", "zap a wand", dozap },
4371     { '\0', (char *) 0, (char *) 0, donull, 0, (char *) 0 } /* sentinel */
4372 };
4373
4374 const char *
4375 key2extcmddesc(key)
4376 uchar key;
4377 {
4378     if (Cmd.commands[key] && Cmd.commands[key]->ef_txt)
4379         return Cmd.commands[key]->ef_desc;
4380     return (char *) 0;
4381 }
4382
4383 boolean
4384 bind_key(key, command)
4385 uchar key;
4386 const char *command;
4387 {
4388     struct ext_func_tab *extcmd;
4389
4390     /* special case: "nothing" is reserved for unbinding */
4391     if (!strcmp(command, "nothing")) {
4392         Cmd.commands[key] = (struct ext_func_tab *) 0;
4393         return TRUE;
4394     }
4395
4396     for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++) {
4397         if (strcmp(command, extcmd->ef_txt))
4398             continue;
4399         Cmd.commands[key] = extcmd;
4400         return TRUE;
4401     }
4402
4403     return FALSE;
4404 }
4405
4406 /* initialize all keyboard commands */
4407 void
4408 commands_init()
4409 {
4410     struct ext_func_tab *extcmd;
4411
4412     for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++)
4413         if (extcmd->key)
4414             Cmd.commands[extcmd->key] = extcmd;
4415
4416     (void) bind_key(C('l'), "redraw"); /* if number_pad is set */
4417     /*       'b', 'B' : go sw */
4418     /*       'F' : fight (one time) */
4419     /*       'g', 'G' : multiple go */
4420     /*       'h', 'H' : go west */
4421     (void) bind_key('h',    "help"); /* if number_pad is set */
4422     (void) bind_key('j',    "jump"); /* if number_pad is on */
4423     /*       'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' move commands */
4424     (void) bind_key('k',    "kick"); /* if number_pad is on */
4425     (void) bind_key('l',    "loot"); /* if number_pad is on */
4426     (void) bind_key(C('n'), "annotate"); /* if number_pad is on */
4427     (void) bind_key(M('n'), "name");
4428     (void) bind_key(M('N'), "name");
4429     (void) bind_key('u',    "untrap"); /* if number_pad is on */
4430
4431     /* alt keys: */
4432     (void) bind_key(M('O'), "overview");
4433     (void) bind_key(M('2'), "twoweapon");
4434
4435     /* wait_on_space */
4436     (void) bind_key(' ',    "wait");
4437 }
4438
4439 int
4440 dokeylist_putcmds(datawin, docount, cmdflags, exflags, keys_used)
4441 winid datawin;
4442 boolean docount;
4443 int cmdflags, exflags;
4444 boolean *keys_used; /* boolean keys_used[256] */
4445 {
4446     int i;
4447     char buf[BUFSZ];
4448     char buf2[QBUFSZ];
4449     int count = 0;
4450
4451     for (i = 0; i < 256; i++) {
4452         const struct ext_func_tab *extcmd;
4453         uchar key = (uchar) i;
4454
4455         if (keys_used[i])
4456             continue;
4457         if (key == ' ' && !flags.rest_on_space)
4458             continue;
4459         if ((extcmd = Cmd.commands[i]) != (struct ext_func_tab *) 0) {
4460             if ((cmdflags && !(extcmd->flags & cmdflags))
4461                 || (exflags && (extcmd->flags & exflags)))
4462                 continue;
4463             if (docount) {
4464                 count++;
4465                 continue;
4466             }
4467             Sprintf(buf, "%-8s %-12s %s", key2txt(key, buf2),
4468                     extcmd->ef_txt,
4469                     extcmd->ef_desc);
4470             putstr(datawin, 0, buf);
4471             keys_used[i] = TRUE;
4472         }
4473     }
4474     return count;
4475 }
4476
4477 /* list all keys and their bindings, like dat/hh but dynamic */
4478 void
4479 dokeylist(VOID_ARGS)
4480 {
4481     char buf[BUFSZ], buf2[BUFSZ];
4482     uchar key;
4483     boolean keys_used[256] = {0};
4484     winid datawin;
4485     int i;
4486     static const char
4487         run_desc[] = "Prefix: run until something very interesting is seen",
4488         forcefight_desc[] =
4489                      "Prefix: force fight even if you don't see a monster";
4490     static const struct {
4491         int nhkf;
4492         const char *desc;
4493         boolean numpad;
4494     } misc_keys[] = {
4495         { NHKF_ESC, "escape from the current query/action", FALSE },
4496         { NHKF_RUSH,
4497           "Prefix: rush until something interesting is seen", FALSE },
4498         { NHKF_RUN, run_desc, FALSE },
4499         { NHKF_RUN2, run_desc, TRUE },
4500         { NHKF_FIGHT, forcefight_desc, FALSE },
4501         { NHKF_FIGHT2, forcefight_desc, TRUE } ,
4502         { NHKF_NOPICKUP,
4503           "Prefix: move without picking up objects/fighting", FALSE },
4504         { NHKF_RUN_NOPICKUP,
4505           "Prefix: run without picking up objects/fighting", FALSE },
4506         { NHKF_DOINV, "view inventory", TRUE },
4507         { NHKF_REQMENU, "Prefix: request a menu", FALSE },
4508 #ifdef REDO
4509         { NHKF_DOAGAIN , "re-do: perform the previous command again", FALSE },
4510 #endif
4511         { 0, (const char *) 0, FALSE }
4512     };
4513
4514     datawin = create_nhwindow(NHW_TEXT);
4515     putstr(datawin, 0, "");
4516     putstr(datawin, 0, "            Full Current Key Bindings List");
4517
4518     /* directional keys */
4519     putstr(datawin, 0, "");
4520     putstr(datawin, 0, "Directional keys:");
4521     show_direction_keys(datawin, '.', FALSE); /* '.'==self in direction grid */
4522
4523     keys_used[(uchar) Cmd.move_NW] = keys_used[(uchar) Cmd.move_N]
4524         = keys_used[(uchar) Cmd.move_NE] = keys_used[(uchar) Cmd.move_W]
4525         = keys_used[(uchar) Cmd.move_E] = keys_used[(uchar) Cmd.move_SW]
4526         = keys_used[(uchar) Cmd.move_S] = keys_used[(uchar) Cmd.move_SE]
4527         = TRUE;
4528
4529     if (!iflags.num_pad) {
4530         keys_used[(uchar) highc(Cmd.move_NW)]
4531             = keys_used[(uchar) highc(Cmd.move_N)]
4532             = keys_used[(uchar) highc(Cmd.move_NE)]
4533             = keys_used[(uchar) highc(Cmd.move_W)]
4534             = keys_used[(uchar) highc(Cmd.move_E)]
4535             = keys_used[(uchar) highc(Cmd.move_SW)]
4536             = keys_used[(uchar) highc(Cmd.move_S)]
4537             = keys_used[(uchar) highc(Cmd.move_SE)] = TRUE;
4538         keys_used[(uchar) C(Cmd.move_NW)]
4539             = keys_used[(uchar) C(Cmd.move_N)]
4540             = keys_used[(uchar) C(Cmd.move_NE)]
4541             = keys_used[(uchar) C(Cmd.move_W)]
4542             = keys_used[(uchar) C(Cmd.move_E)]
4543             = keys_used[(uchar) C(Cmd.move_SW)]
4544             = keys_used[(uchar) C(Cmd.move_S)]
4545             = keys_used[(uchar) C(Cmd.move_SE)] = TRUE;
4546         putstr(datawin, 0, "");
4547         putstr(datawin, 0,
4548           "Shift-<direction> will move in specified direction until you hit");
4549         putstr(datawin, 0, "        a wall or run into something.");
4550         putstr(datawin, 0,
4551           "Ctrl-<direction> will run in specified direction until something");
4552         putstr(datawin, 0, "        very interesting is seen.");
4553     }
4554
4555     putstr(datawin, 0, "");
4556     putstr(datawin, 0, "Miscellaneous keys:");
4557     for (i = 0; misc_keys[i].desc; i++) {
4558         key = Cmd.spkeys[misc_keys[i].nhkf];
4559         if (key && ((misc_keys[i].numpad && iflags.num_pad)
4560                     || !misc_keys[i].numpad)) {
4561             keys_used[(uchar) key] = TRUE;
4562             Sprintf(buf, "%-8s %s", key2txt(key, buf2), misc_keys[i].desc);
4563             putstr(datawin, 0, buf);
4564         }
4565     }
4566 #ifndef NO_SIGNAL
4567     putstr(datawin, 0, "^c       break out of NetHack (SIGINT)");
4568     keys_used[(uchar) C('c')] = TRUE;
4569 #endif
4570
4571     putstr(datawin, 0, "");
4572     show_menu_controls(datawin, TRUE);
4573
4574     if (dokeylist_putcmds(datawin, TRUE, GENERALCMD, WIZMODECMD, keys_used)) {
4575         putstr(datawin, 0, "");
4576         putstr(datawin, 0, "General commands:");
4577         (void) dokeylist_putcmds(datawin, FALSE, GENERALCMD, WIZMODECMD,
4578                                  keys_used);
4579     }
4580
4581     if (dokeylist_putcmds(datawin, TRUE, 0, WIZMODECMD, keys_used)) {
4582         putstr(datawin, 0, "");
4583         putstr(datawin, 0, "Game commands:");
4584         (void) dokeylist_putcmds(datawin, FALSE, 0, WIZMODECMD, keys_used);
4585     }
4586
4587     if (wizard
4588         && dokeylist_putcmds(datawin, TRUE, WIZMODECMD, 0, keys_used)) {
4589         putstr(datawin, 0, "");
4590         putstr(datawin, 0, "Wizard-mode commands:");
4591         (void) dokeylist_putcmds(datawin, FALSE, WIZMODECMD, 0, keys_used);
4592     }
4593
4594     display_nhwindow(datawin, FALSE);
4595     destroy_nhwindow(datawin);
4596 }
4597
4598 char
4599 cmd_from_func(fn)
4600 int NDECL((*fn));
4601 {
4602     int i;
4603
4604     for (i = 0; i < 256; ++i)
4605         if (Cmd.commands[i] && Cmd.commands[i]->ef_funct == fn)
4606             return (char) i;
4607     return '\0';
4608 }
4609
4610 /*
4611  * wizard mode sanity_check code
4612  */
4613
4614 static const char template[] = "%-27s  %4ld  %6ld";
4615 static const char stats_hdr[] = "                             count  bytes";
4616 static const char stats_sep[] = "---------------------------  ----- -------";
4617
4618 STATIC_OVL int
4619 size_obj(otmp)
4620 struct obj *otmp;
4621 {
4622     int sz = (int) sizeof(struct obj);
4623
4624     if (otmp->oextra) {
4625         sz += (int) sizeof(struct oextra);
4626         if (ONAME(otmp))
4627             sz += (int) strlen(ONAME(otmp)) + 1;
4628         if (OMONST(otmp))
4629             sz += (int) sizeof(struct monst);
4630         if (OMID(otmp))
4631             sz += (int) sizeof(unsigned);
4632         if (OLONG(otmp))
4633             sz += (int) sizeof(long);
4634         if (OMAILCMD(otmp))
4635             sz += (int) strlen(OMAILCMD(otmp)) + 1;
4636     }
4637     return sz;
4638 }
4639
4640 STATIC_OVL void
4641 count_obj(chain, total_count, total_size, top, recurse)
4642 struct obj *chain;
4643 long *total_count;
4644 long *total_size;
4645 boolean top;
4646 boolean recurse;
4647 {
4648     long count, size;
4649     struct obj *obj;
4650
4651     for (count = size = 0, obj = chain; obj; obj = obj->nobj) {
4652         if (top) {
4653             count++;
4654             size += size_obj(obj);
4655         }
4656         if (recurse && obj->cobj)
4657             count_obj(obj->cobj, total_count, total_size, TRUE, TRUE);
4658     }
4659     *total_count += count;
4660     *total_size += size;
4661 }
4662
4663 STATIC_OVL void
4664 obj_chain(win, src, chain, force, total_count, total_size)
4665 winid win;
4666 const char *src;
4667 struct obj *chain;
4668 boolean force;
4669 long *total_count;
4670 long *total_size;
4671 {
4672     char buf[BUFSZ];
4673     long count = 0L, size = 0L;
4674
4675     count_obj(chain, &count, &size, TRUE, FALSE);
4676
4677     if (count || size || force) {
4678         *total_count += count;
4679         *total_size += size;
4680         Sprintf(buf, template, src, count, size);
4681         putstr(win, 0, buf);
4682     }
4683 }
4684
4685 STATIC_OVL void
4686 mon_invent_chain(win, src, chain, total_count, total_size)
4687 winid win;
4688 const char *src;
4689 struct monst *chain;
4690 long *total_count;
4691 long *total_size;
4692 {
4693     char buf[BUFSZ];
4694     long count = 0, size = 0;
4695     struct monst *mon;
4696
4697     for (mon = chain; mon; mon = mon->nmon)
4698         count_obj(mon->minvent, &count, &size, TRUE, FALSE);
4699
4700     if (count || size) {
4701         *total_count += count;
4702         *total_size += size;
4703         Sprintf(buf, template, src, count, size);
4704         putstr(win, 0, buf);
4705     }
4706 }
4707
4708 STATIC_OVL void
4709 contained_stats(win, src, total_count, total_size)
4710 winid win;
4711 const char *src;
4712 long *total_count;
4713 long *total_size;
4714 {
4715     char buf[BUFSZ];
4716     long count = 0, size = 0;
4717     struct monst *mon;
4718
4719     count_obj(invent, &count, &size, FALSE, TRUE);
4720     count_obj(fobj, &count, &size, FALSE, TRUE);
4721     count_obj(level.buriedobjlist, &count, &size, FALSE, TRUE);
4722     count_obj(migrating_objs, &count, &size, FALSE, TRUE);
4723     /* DEADMONSTER check not required in this loop since they have no
4724      * inventory */
4725     for (mon = fmon; mon; mon = mon->nmon)
4726         count_obj(mon->minvent, &count, &size, FALSE, TRUE);
4727     for (mon = migrating_mons; mon; mon = mon->nmon)
4728         count_obj(mon->minvent, &count, &size, FALSE, TRUE);
4729
4730     if (count || size) {
4731         *total_count += count;
4732         *total_size += size;
4733         Sprintf(buf, template, src, count, size);
4734         putstr(win, 0, buf);
4735     }
4736 }
4737
4738 STATIC_OVL int
4739 size_monst(mtmp, incl_wsegs)
4740 struct monst *mtmp;
4741 boolean incl_wsegs;
4742 {
4743     int sz = (int) sizeof (struct monst);
4744
4745     if (mtmp->wormno && incl_wsegs)
4746         sz += size_wseg(mtmp);
4747
4748     if (mtmp->mextra) {
4749         sz += (int) sizeof (struct mextra);
4750         if (MNAME(mtmp))
4751             sz += (int) strlen(MNAME(mtmp)) + 1;
4752         if (EGD(mtmp))
4753             sz += (int) sizeof (struct egd);
4754         if (EPRI(mtmp))
4755             sz += (int) sizeof (struct epri);
4756         if (ESHK(mtmp))
4757             sz += (int) sizeof (struct eshk);
4758         if (EMIN(mtmp))
4759             sz += (int) sizeof (struct emin);
4760         if (EDOG(mtmp))
4761             sz += (int) sizeof (struct edog);
4762         /* mextra->mcorpsenm doesn't point to more memory */
4763     }
4764     return sz;
4765 }
4766
4767 STATIC_OVL void
4768 mon_chain(win, src, chain, force, total_count, total_size)
4769 winid win;
4770 const char *src;
4771 struct monst *chain;
4772 boolean force;
4773 long *total_count;
4774 long *total_size;
4775 {
4776     char buf[BUFSZ];
4777     long count, size;
4778     struct monst *mon;
4779     /* mon->wormno means something different for migrating_mons and mydogs */
4780     boolean incl_wsegs = !strcmpi(src, "fmon");
4781
4782     count = size = 0L;
4783     for (mon = chain; mon; mon = mon->nmon) {
4784         count++;
4785         size += size_monst(mon, incl_wsegs);
4786     }
4787     if (count || size || force) {
4788         *total_count += count;
4789         *total_size += size;
4790         Sprintf(buf, template, src, count, size);
4791         putstr(win, 0, buf);
4792     }
4793 }
4794
4795 STATIC_OVL void
4796 misc_stats(win, total_count, total_size)
4797 winid win;
4798 long *total_count;
4799 long *total_size;
4800 {
4801     char buf[BUFSZ], hdrbuf[QBUFSZ];
4802     long count, size;
4803     int idx;
4804     struct trap *tt;
4805     struct damage *sd; /* shop damage */
4806     struct cemetery *bi; /* bones info */
4807
4808     /* traps and engravings are output unconditionally;
4809      * others only if nonzero
4810      */
4811     count = size = 0L;
4812     for (tt = ftrap; tt; tt = tt->ntrap) {
4813         ++count;
4814         size += (long) sizeof *tt;
4815     }
4816     *total_count += count;
4817     *total_size += size;
4818     Sprintf(hdrbuf, "traps, size %ld", (long) sizeof (struct trap));
4819     Sprintf(buf, template, hdrbuf, count, size);
4820     putstr(win, 0, buf);
4821
4822     count = size = 0L;
4823     engr_stats("engravings, size %ld+text", hdrbuf, &count, &size);
4824     *total_count += count;
4825     *total_size += size;
4826     Sprintf(buf, template, hdrbuf, count, size);
4827     putstr(win, 0, buf);
4828
4829     count = size = 0L;
4830     light_stats("light sources, size %ld", hdrbuf, &count, &size);
4831     if (count || size) {
4832         *total_count += count;
4833         *total_size += size;
4834         Sprintf(buf, template, hdrbuf, count, size);
4835         putstr(win, 0, buf);
4836     }
4837
4838     count = size = 0L;
4839     timer_stats("timers, size %ld", hdrbuf, &count, &size);
4840     if (count || size) {
4841         *total_count += count;
4842         *total_size += size;
4843         Sprintf(buf, template, hdrbuf, count, size);
4844         putstr(win, 0, buf);
4845     }
4846
4847     count = size = 0L;
4848     for (sd = level.damagelist; sd; sd = sd->next) {
4849         ++count;
4850         size += (long) sizeof *sd;
4851     }
4852     if (count || size) {
4853         *total_count += count;
4854         *total_size += size;
4855         Sprintf(hdrbuf, "shop damage, size %ld",
4856                 (long) sizeof (struct damage));
4857         Sprintf(buf, template, hdrbuf, count, size);
4858         putstr(win, 0, buf);
4859     }
4860
4861     count = size = 0L;
4862     region_stats("regions, size %ld+%ld*rect+N", hdrbuf, &count, &size);
4863     if (count || size) {
4864         *total_count += count;
4865         *total_size += size;
4866         Sprintf(buf, template, hdrbuf, count, size);
4867         putstr(win, 0, buf);
4868     }
4869
4870     count = size = 0L;
4871     for (bi = level.bonesinfo; bi; bi = bi->next) {
4872         ++count;
4873         size += (long) sizeof *bi;
4874     }
4875     if (count || size) {
4876         *total_count += count;
4877         *total_size += size;
4878         Sprintf(hdrbuf, "bones history, size %ld",
4879                 (long) sizeof (struct cemetery));
4880         Sprintf(buf, template, hdrbuf, count, size);
4881         putstr(win, 0, buf);
4882     }
4883
4884     count = size = 0L;
4885     for (idx = 0; idx < NUM_OBJECTS; ++idx)
4886         if (objects[idx].oc_uname) {
4887             ++count;
4888             size += (long) (strlen(objects[idx].oc_uname) + 1);
4889         }
4890     if (count || size) {
4891         *total_count += count;
4892         *total_size += size;
4893         Strcpy(hdrbuf, "object type names, text");
4894         Sprintf(buf, template, hdrbuf, count, size);
4895         putstr(win, 0, buf);
4896     }
4897 }
4898
4899 /*
4900  * Display memory usage of all monsters and objects on the level.
4901  */
4902 static int
4903 wiz_show_stats()
4904 {
4905     char buf[BUFSZ];
4906     winid win;
4907     long total_obj_size, total_obj_count,
4908          total_mon_size, total_mon_count,
4909          total_ovr_size, total_ovr_count,
4910          total_misc_size, total_misc_count;
4911
4912     win = create_nhwindow(NHW_TEXT);
4913     putstr(win, 0, "Current memory statistics:");
4914
4915     total_obj_count = total_obj_size = 0L;
4916     putstr(win, 0, stats_hdr);
4917     Sprintf(buf, "  Objects, base size %ld", (long) sizeof (struct obj));
4918     putstr(win, 0, buf);
4919     obj_chain(win, "invent", invent, TRUE, &total_obj_count, &total_obj_size);
4920     obj_chain(win, "fobj", fobj, TRUE, &total_obj_count, &total_obj_size);
4921     obj_chain(win, "buried", level.buriedobjlist, FALSE,
4922               &total_obj_count, &total_obj_size);
4923     obj_chain(win, "migrating obj", migrating_objs, FALSE,
4924               &total_obj_count, &total_obj_size);
4925     obj_chain(win, "billobjs", billobjs, FALSE,
4926               &total_obj_count, &total_obj_size);
4927     mon_invent_chain(win, "minvent", fmon, &total_obj_count, &total_obj_size);
4928     mon_invent_chain(win, "migrating minvent", migrating_mons,
4929                      &total_obj_count, &total_obj_size);
4930     contained_stats(win, "contained", &total_obj_count, &total_obj_size);
4931     putstr(win, 0, stats_sep);
4932     Sprintf(buf, template, "  Obj total", total_obj_count, total_obj_size);
4933     putstr(win, 0, buf);
4934
4935     total_mon_count = total_mon_size = 0L;
4936     putstr(win, 0, "");
4937     Sprintf(buf, "  Monsters, base size %ld", (long) sizeof (struct monst));
4938     putstr(win, 0, buf);
4939     mon_chain(win, "fmon", fmon, TRUE, &total_mon_count, &total_mon_size);
4940     mon_chain(win, "migrating", migrating_mons, FALSE,
4941               &total_mon_count, &total_mon_size);
4942     /* 'mydogs' is only valid during level change or end of game disclosure,
4943        but conceivably we've been called from within debugger at such time */
4944     if (mydogs) /* monsters accompanying hero */
4945         mon_chain(win, "mydogs", mydogs, FALSE,
4946                   &total_mon_count, &total_mon_size);
4947     putstr(win, 0, stats_sep);
4948     Sprintf(buf, template, "  Mon total", total_mon_count, total_mon_size);
4949     putstr(win, 0, buf);
4950
4951     total_ovr_count = total_ovr_size = 0L;
4952     putstr(win, 0, "");
4953     putstr(win, 0, "  Overview");
4954     overview_stats(win, template, &total_ovr_count, &total_ovr_size);
4955     putstr(win, 0, stats_sep);
4956     Sprintf(buf, template, "  Over total", total_ovr_count, total_ovr_size);
4957     putstr(win, 0, buf);
4958
4959     total_misc_count = total_misc_size = 0L;
4960     putstr(win, 0, "");
4961     putstr(win, 0, "  Miscellaneous");
4962     misc_stats(win, &total_misc_count, &total_misc_size);
4963     putstr(win, 0, stats_sep);
4964     Sprintf(buf, template, "  Misc total", total_misc_count, total_misc_size);
4965     putstr(win, 0, buf);
4966
4967     putstr(win, 0, "");
4968     putstr(win, 0, stats_sep);
4969     Sprintf(buf, template, "  Grand total",
4970             (total_obj_count + total_mon_count
4971              + total_ovr_count + total_misc_count),
4972             (total_obj_size + total_mon_size
4973              + total_ovr_size + total_misc_size));
4974     putstr(win, 0, buf);
4975
4976 #if defined(__BORLANDC__) && !defined(_WIN32)
4977     show_borlandc_stats(win);
4978 #endif
4979
4980     display_nhwindow(win, FALSE);
4981     destroy_nhwindow(win);
4982     return 0;
4983 }
4984
4985 void
4986 sanity_check()
4987 {
4988     obj_sanity_check();
4989     timer_sanity_check();
4990     mon_sanity_check();
4991     light_sources_sanity_check();
4992 }
4993
4994 #ifdef DEBUG_MIGRATING_MONS
4995 static int
4996 wiz_migrate_mons()
4997 {
4998     int mcount = 0;
4999     char inbuf[BUFSZ] = DUMMY;
5000     struct permonst *ptr;
5001     struct monst *mtmp;
5002     d_level tolevel;
5003
5004     getlin("How many random monsters to migrate? [0]", inbuf);
5005     if (*inbuf == '\033')
5006         return 0;
5007     mcount = atoi(inbuf);
5008     if (mcount < 0 || mcount > (COLNO * ROWNO) || Is_botlevel(&u.uz))
5009         return 0;
5010     while (mcount > 0) {
5011         if (Is_stronghold(&u.uz))
5012             assign_level(&tolevel, &valley_level);
5013         else
5014             get_level(&tolevel, depth(&u.uz) + 1);
5015         ptr = rndmonst();
5016         mtmp = makemon(ptr, 0, 0, NO_MM_FLAGS);
5017         if (mtmp)
5018             migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM,
5019                              (coord *) 0);
5020         mcount--;
5021     }
5022     return 0;
5023 }
5024 #endif
5025
5026 #define unctrl(c) ((c) <= C('z') ? (0x60 | (c)) : (c))
5027 #define unmeta(c) (0x7f & (c))
5028
5029 struct {
5030     int nhkf;
5031     char key;
5032     const char *name;
5033 } const spkeys_binds[] = {
5034     { NHKF_ESC,              '\033', (char *) 0 }, /* no binding */
5035     { NHKF_DOAGAIN,          DOAGAIN, "repeat" },
5036     { NHKF_REQMENU,          'm', "reqmenu" },
5037     { NHKF_RUN,              'G', "run" },
5038     { NHKF_RUN2,             '5', "run.numpad" },
5039     { NHKF_RUSH,             'g', "rush" },
5040     { NHKF_FIGHT,            'F', "fight" },
5041     { NHKF_FIGHT2,           '-', "fight.numpad" },
5042     { NHKF_NOPICKUP,         'm', "nopickup" },
5043     { NHKF_RUN_NOPICKUP,     'M', "run.nopickup" },
5044     { NHKF_DOINV,            '0', "doinv" },
5045     { NHKF_TRAVEL,           CMD_TRAVEL, (char *) 0 }, /* no binding */
5046     { NHKF_CLICKLOOK,        CMD_CLICKLOOK, (char *) 0 }, /* no binding */
5047     { NHKF_REDRAW,           C('r'), "redraw" },
5048     { NHKF_REDRAW2,          C('l'), "redraw.numpad" },
5049     { NHKF_GETDIR_SELF,      '.', "getdir.self" },
5050     { NHKF_GETDIR_SELF2,     's', "getdir.self2" },
5051     { NHKF_GETDIR_HELP,      '?', "getdir.help" },
5052     { NHKF_COUNT,            'n', "count" },
5053     { NHKF_GETPOS_SELF,      '@', "getpos.self" },
5054     { NHKF_GETPOS_PICK,      '.', "getpos.pick" },
5055     { NHKF_GETPOS_PICK_Q,    ',', "getpos.pick.quick" },
5056     { NHKF_GETPOS_PICK_O,    ';', "getpos.pick.once" },
5057     { NHKF_GETPOS_PICK_V,    ':', "getpos.pick.verbose" },
5058     { NHKF_GETPOS_SHOWVALID, '$', "getpos.valid" },
5059     { NHKF_GETPOS_AUTODESC,  '#', "getpos.autodescribe" },
5060     { NHKF_GETPOS_MON_NEXT,  'm', "getpos.mon.next" },
5061     { NHKF_GETPOS_MON_PREV,  'M', "getpos.mon.prev" },
5062     { NHKF_GETPOS_OBJ_NEXT,  'o', "getpos.obj.next" },
5063     { NHKF_GETPOS_OBJ_PREV,  'O', "getpos.obj.prev" },
5064     { NHKF_GETPOS_DOOR_NEXT, 'd', "getpos.door.next" },
5065     { NHKF_GETPOS_DOOR_PREV, 'D', "getpos.door.prev" },
5066     { NHKF_GETPOS_UNEX_NEXT, 'x', "getpos.unexplored.next" },
5067     { NHKF_GETPOS_UNEX_PREV, 'X', "getpos.unexplored.prev" },
5068     { NHKF_GETPOS_VALID_NEXT, 'z', "getpos.valid.next" },
5069     { NHKF_GETPOS_VALID_PREV, 'Z', "getpos.valid.prev" },
5070     { NHKF_GETPOS_INTERESTING_NEXT, 'a', "getpos.all.next" },
5071     { NHKF_GETPOS_INTERESTING_PREV, 'A', "getpos.all.prev" },
5072     { NHKF_GETPOS_HELP,      '?', "getpos.help" },
5073     { NHKF_GETPOS_LIMITVIEW, '"', "getpos.filter" },
5074     { NHKF_GETPOS_MOVESKIP,  '*', "getpos.moveskip" },
5075     { NHKF_GETPOS_MENU,      '!', "getpos.menu" }
5076 };
5077
5078 boolean
5079 bind_specialkey(key, command)
5080 uchar key;
5081 const char *command;
5082 {
5083     int i;
5084     for (i = 0; i < SIZE(spkeys_binds); i++) {
5085         if (!spkeys_binds[i].name || strcmp(command, spkeys_binds[i].name))
5086             continue;
5087         Cmd.spkeys[spkeys_binds[i].nhkf] = key;
5088         return TRUE;
5089     }
5090     return FALSE;
5091 }
5092
5093 /* returns a one-byte character from the text (it may massacre the txt
5094  * buffer) */
5095 char
5096 txt2key(txt)
5097 char *txt;
5098 {
5099     txt = trimspaces(txt);
5100     if (!*txt)
5101         return '\0';
5102
5103     /* simple character */
5104     if (!txt[1])
5105         return txt[0];
5106
5107     /* a few special entries */
5108     if (!strcmp(txt, "<enter>"))
5109         return '\n';
5110     if (!strcmp(txt, "<space>"))
5111         return ' ';
5112     if (!strcmp(txt, "<esc>"))
5113         return '\033';
5114
5115     /* control and meta keys */
5116     switch (*txt) {
5117     case 'm': /* can be mx, Mx, m-x, M-x */
5118     case 'M':
5119         txt++;
5120         if (*txt == '-' && txt[1])
5121             txt++;
5122         if (txt[1])
5123             return '\0';
5124         return M(*txt);
5125     case 'c': /* can be cx, Cx, ^x, c-x, C-x, ^-x */
5126     case 'C':
5127     case '^':
5128         txt++;
5129         if (*txt == '-' && txt[1])
5130             txt++;
5131         if (txt[1])
5132             return '\0';
5133         return C(*txt);
5134     }
5135
5136     /* ascii codes: must be three-digit decimal */
5137     if (*txt >= '0' && *txt <= '9') {
5138         uchar key = 0;
5139         int i;
5140
5141         for (i = 0; i < 3; i++) {
5142             if (txt[i] < '0' || txt[i] > '9')
5143                 return '\0';
5144             key = 10 * key + txt[i] - '0';
5145         }
5146         return key;
5147     }
5148
5149     return '\0';
5150 }
5151
5152 /* returns the text for a one-byte encoding;
5153  * must be shorter than a tab for proper formatting */
5154 char *
5155 key2txt(c, txt)
5156 uchar c;
5157 char *txt; /* sufficiently long buffer */
5158 {
5159     /* should probably switch to "SPC", "ESC", "RET"
5160        since nethack's documentation uses ESC for <escape> */
5161     if (c == ' ')
5162         Sprintf(txt, "<space>");
5163     else if (c == '\033')
5164         Sprintf(txt, "<esc>");
5165     else if (c == '\n')
5166         Sprintf(txt, "<enter>");
5167     else if (c == '\177')
5168         Sprintf(txt, "<del>"); /* "<delete>" won't fit */
5169     else
5170         Strcpy(txt, visctrl((char) c));
5171     return txt;
5172 }
5173
5174
5175 void
5176 parseautocomplete(autocomplete, condition)
5177 char *autocomplete;
5178 boolean condition;
5179 {
5180     struct ext_func_tab *efp;
5181     register char *autoc;
5182
5183     /* break off first autocomplete from the rest; parse the rest */
5184     if ((autoc = index(autocomplete, ',')) != 0
5185         || (autoc = index(autocomplete, ':')) != 0) {
5186         *autoc++ = '\0';
5187         parseautocomplete(autoc, condition);
5188     }
5189
5190     /* strip leading and trailing white space */
5191     autocomplete = trimspaces(autocomplete);
5192
5193     if (!*autocomplete)
5194         return;
5195
5196     /* take off negation */
5197     if (*autocomplete == '!') {
5198         /* unlike most options, a leading "no" might actually be a part of
5199          * the extended command.  Thus you have to use ! */
5200         autocomplete++;
5201         autocomplete = trimspaces(autocomplete);
5202         condition = !condition;
5203     }
5204
5205     /* find and modify the extended command */
5206     for (efp = extcmdlist; efp->ef_txt; efp++) {
5207         if (!strcmp(autocomplete, efp->ef_txt)) {
5208             if (condition)
5209                 efp->flags |= AUTOCOMPLETE;
5210             else
5211                 efp->flags &= ~AUTOCOMPLETE;
5212             return;
5213         }
5214     }
5215
5216     /* not a real extended command */
5217     raw_printf("Bad autocomplete: invalid extended command '%s'.",
5218                autocomplete);
5219     wait_synch();
5220 }
5221
5222 /* called at startup and after number_pad is twiddled */
5223 void
5224 reset_commands(initial)
5225 boolean initial;
5226 {
5227     static const char sdir[] = "hykulnjb><",
5228                       sdir_swap_yz[] = "hzkulnjb><",
5229                       ndir[] = "47896321><",
5230                       ndir_phone_layout[] = "41236987><";
5231     static const int ylist[] = {
5232         'y', 'Y', C('y'), M('y'), M('Y'), M(C('y'))
5233     };
5234     static struct ext_func_tab *back_dir_cmd[8];
5235     const struct ext_func_tab *cmdtmp;
5236     boolean flagtemp;
5237     int c, i, updated = 0;
5238     static boolean backed_dir_cmd = FALSE;
5239
5240     if (initial) {
5241         updated = 1;
5242         Cmd.num_pad = FALSE;
5243         Cmd.pcHack_compat = Cmd.phone_layout = Cmd.swap_yz = FALSE;
5244         for (i = 0; i < SIZE(spkeys_binds); i++)
5245             Cmd.spkeys[spkeys_binds[i].nhkf] = spkeys_binds[i].key;
5246         commands_init();
5247     } else {
5248
5249         if (backed_dir_cmd) {
5250             for (i = 0; i < 8; i++) {
5251                 Cmd.commands[(uchar) Cmd.dirchars[i]] = back_dir_cmd[i];
5252             }
5253         }
5254
5255         /* basic num_pad */
5256         flagtemp = iflags.num_pad;
5257         if (flagtemp != Cmd.num_pad) {
5258             Cmd.num_pad = flagtemp;
5259             ++updated;
5260         }
5261         /* swap_yz mode (only applicable for !num_pad); intended for
5262            QWERTZ keyboard used in Central Europe, particularly Germany */
5263         flagtemp = (iflags.num_pad_mode & 1) ? !Cmd.num_pad : FALSE;
5264         if (flagtemp != Cmd.swap_yz) {
5265             Cmd.swap_yz = flagtemp;
5266             ++updated;
5267             /* Cmd.swap_yz has been toggled;
5268                perform the swap (or reverse previous one) */
5269             for (i = 0; i < SIZE(ylist); i++) {
5270                 c = ylist[i] & 0xff;
5271                 cmdtmp = Cmd.commands[c];              /* tmp = [y] */
5272                 Cmd.commands[c] = Cmd.commands[c + 1]; /* [y] = [z] */
5273                 Cmd.commands[c + 1] = cmdtmp;          /* [z] = tmp */
5274             }
5275         }
5276         /* MSDOS compatibility mode (only applicable for num_pad) */
5277         flagtemp = (iflags.num_pad_mode & 1) ? Cmd.num_pad : FALSE;
5278         if (flagtemp != Cmd.pcHack_compat) {
5279             Cmd.pcHack_compat = flagtemp;
5280             ++updated;
5281             /* pcHack_compat has been toggled */
5282             c = M('5') & 0xff;
5283             cmdtmp = Cmd.commands['5'];
5284             Cmd.commands['5'] = Cmd.commands[c];
5285             Cmd.commands[c] = cmdtmp;
5286             c = M('0') & 0xff;
5287             Cmd.commands[c] = Cmd.pcHack_compat ? Cmd.commands['I'] : 0;
5288         }
5289         /* phone keypad layout (only applicable for num_pad) */
5290         flagtemp = (iflags.num_pad_mode & 2) ? Cmd.num_pad : FALSE;
5291         if (flagtemp != Cmd.phone_layout) {
5292             Cmd.phone_layout = flagtemp;
5293             ++updated;
5294             /* phone_layout has been toggled */
5295             for (i = 0; i < 3; i++) {
5296                 c = '1' + i;             /* 1,2,3 <-> 7,8,9 */
5297                 cmdtmp = Cmd.commands[c];              /* tmp = [1] */
5298                 Cmd.commands[c] = Cmd.commands[c + 6]; /* [1] = [7] */
5299                 Cmd.commands[c + 6] = cmdtmp;          /* [7] = tmp */
5300                 c = (M('1') & 0xff) + i; /* M-1,M-2,M-3 <-> M-7,M-8,M-9 */
5301                 cmdtmp = Cmd.commands[c];              /* tmp = [M-1] */
5302                 Cmd.commands[c] = Cmd.commands[c + 6]; /* [M-1] = [M-7] */
5303                 Cmd.commands[c + 6] = cmdtmp;          /* [M-7] = tmp */
5304             }
5305         }
5306     } /*?initial*/
5307
5308     if (updated)
5309         Cmd.serialno++;
5310     Cmd.dirchars = !Cmd.num_pad
5311                        ? (!Cmd.swap_yz ? sdir : sdir_swap_yz)
5312                        : (!Cmd.phone_layout ? ndir : ndir_phone_layout);
5313     Cmd.alphadirchars = !Cmd.num_pad ? Cmd.dirchars : sdir;
5314
5315     Cmd.move_W = Cmd.dirchars[0];
5316     Cmd.move_NW = Cmd.dirchars[1];
5317     Cmd.move_N = Cmd.dirchars[2];
5318     Cmd.move_NE = Cmd.dirchars[3];
5319     Cmd.move_E = Cmd.dirchars[4];
5320     Cmd.move_SE = Cmd.dirchars[5];
5321     Cmd.move_S = Cmd.dirchars[6];
5322     Cmd.move_SW = Cmd.dirchars[7];
5323
5324     if (!initial) {
5325         for (i = 0; i < 8; i++) {
5326             back_dir_cmd[i] =
5327                 (struct ext_func_tab *) Cmd.commands[(uchar) Cmd.dirchars[i]];
5328             Cmd.commands[(uchar) Cmd.dirchars[i]] = (struct ext_func_tab *) 0;
5329         }
5330         backed_dir_cmd = TRUE;
5331         for (i = 0; i < 8; i++)
5332             (void) bind_key(Cmd.dirchars[i], "nothing");
5333     }
5334 }
5335
5336 /* non-movement commands which accept 'm' prefix to request menu operation */
5337 STATIC_OVL boolean
5338 accept_menu_prefix(cmd_func)
5339 int NDECL((*cmd_func));
5340 {
5341     if (cmd_func == dopickup || cmd_func == dotip
5342         /* eat, #offer, and apply tinning-kit all use floorfood() to pick
5343            an item on floor or in invent; 'm' skips picking from floor
5344            (ie, inventory only) rather than request use of menu operation */
5345         || cmd_func == doeat || cmd_func == dosacrifice || cmd_func == doapply
5346         /* 'm' for removing saddle from adjacent monster without checking
5347            for containers at <u.ux,u.uy> */
5348         || cmd_func == doloot
5349         /* travel: pop up a menu of interesting targets in view */
5350         || cmd_func == dotravel
5351         /* wizard mode ^V */
5352         || cmd_func == wiz_level_tele
5353         /* 'm' prefix allowed for some extended commands */
5354         || cmd_func == doextcmd || cmd_func == doextlist)
5355         return TRUE;
5356     return FALSE;
5357 }
5358
5359 int
5360 ch2spkeys(c, start, end)
5361 char c;
5362 int start,end;
5363 {
5364     int i;
5365
5366     for (i = start; i <= end; i++)
5367         if (Cmd.spkeys[i] == c)
5368             return i;
5369     return NHKF_ESC;
5370 }
5371
5372 void
5373 rhack(cmd)
5374 register char *cmd;
5375 {
5376     int spkey;
5377     boolean do_walk, do_rush, prefix_seen, bad_command,
5378         firsttime = (cmd == 0);
5379
5380     iflags.menu_requested = FALSE;
5381 #ifdef SAFERHANGUP
5382     if (program_state.done_hup)
5383         end_of_input();
5384 #endif
5385     if (firsttime) {
5386         context.nopick = 0;
5387         cmd = parse();
5388     }
5389     if (*cmd == Cmd.spkeys[NHKF_ESC]) {
5390         context.move = FALSE;
5391         return;
5392     }
5393     if (*cmd == DOAGAIN && !in_doagain && saveq[0]) {
5394         in_doagain = TRUE;
5395         stail = 0;
5396         rhack((char *) 0); /* read and execute command */
5397         in_doagain = FALSE;
5398         return;
5399     }
5400     /* Special case of *cmd == ' ' handled better below */
5401     if (!*cmd || *cmd == (char) 0377) {
5402         nhbell();
5403         context.move = FALSE;
5404         return; /* probably we just had an interrupt */
5405     }
5406
5407     /* handle most movement commands */
5408     do_walk = do_rush = prefix_seen = FALSE;
5409     context.travel = context.travel1 = 0;
5410     spkey = ch2spkeys(*cmd, NHKF_RUN, NHKF_CLICKLOOK);
5411
5412     switch (spkey) {
5413     case NHKF_RUSH:
5414         if (movecmd(cmd[1])) {
5415             context.run = 2;
5416             do_rush = TRUE;
5417         } else
5418             prefix_seen = TRUE;
5419         break;
5420     case NHKF_RUN2:
5421         if (!Cmd.num_pad)
5422             break;
5423         /*FALLTHRU*/
5424     case NHKF_RUN:
5425         if (movecmd(lowc(cmd[1]))) {
5426             context.run = 3;
5427             do_rush = TRUE;
5428         } else
5429             prefix_seen = TRUE;
5430         break;
5431     case NHKF_FIGHT2:
5432         if (!Cmd.num_pad)
5433             break;
5434         /*FALLTHRU*/
5435     /* Effects of movement commands and invisible monsters:
5436      * m: always move onto space (even if 'I' remembered)
5437      * F: always attack space (even if 'I' not remembered)
5438      * normal movement: attack if 'I', move otherwise.
5439      */
5440     case NHKF_FIGHT:
5441         if (movecmd(cmd[1])) {
5442             context.forcefight = 1;
5443             do_walk = TRUE;
5444         } else
5445             prefix_seen = TRUE;
5446         break;
5447     case NHKF_NOPICKUP:
5448         if (movecmd(cmd[1]) || u.dz) {
5449             context.run = 0;
5450             context.nopick = 1;
5451             if (!u.dz)
5452                 do_walk = TRUE;
5453             else
5454                 cmd[0] = cmd[1]; /* "m<" or "m>" */
5455         } else
5456             prefix_seen = TRUE;
5457         break;
5458     case NHKF_RUN_NOPICKUP:
5459         if (movecmd(lowc(cmd[1]))) {
5460             context.run = 1;
5461             context.nopick = 1;
5462             do_rush = TRUE;
5463         } else
5464             prefix_seen = TRUE;
5465         break;
5466     case NHKF_DOINV:
5467         if (!Cmd.num_pad)
5468             break;
5469         (void) ddoinv(); /* a convenience borrowed from the PC */
5470         context.move = FALSE;
5471         multi = 0;
5472         return;
5473     case NHKF_CLICKLOOK:
5474         if (iflags.clicklook) {
5475             context.move = FALSE;
5476             do_look(2, &clicklook_cc);
5477         }
5478         return;
5479     case NHKF_TRAVEL:
5480         if (flags.travelcmd) {
5481             context.travel = 1;
5482             context.travel1 = 1;
5483             context.run = 8;
5484             context.nopick = 1;
5485             do_rush = TRUE;
5486             break;
5487         }
5488         /*FALLTHRU*/
5489     default:
5490         if (movecmd(*cmd)) { /* ordinary movement */
5491             context.run = 0; /* only matters here if it was 8 */
5492             do_walk = TRUE;
5493         } else if (movecmd(Cmd.num_pad ? unmeta(*cmd) : lowc(*cmd))) {
5494             context.run = 1;
5495             do_rush = TRUE;
5496         } else if (movecmd(unctrl(*cmd))) {
5497             context.run = 3;
5498             do_rush = TRUE;
5499         }
5500         break;
5501     }
5502
5503     /* some special prefix handling */
5504     /* overload 'm' prefix to mean "request a menu" */
5505     if (prefix_seen && cmd[0] == Cmd.spkeys[NHKF_REQMENU]) {
5506         /* (for func_tab cast, see below) */
5507         const struct ext_func_tab *ft = Cmd.commands[cmd[1] & 0xff];
5508         int NDECL((*func)) = ft ? ((struct ext_func_tab *) ft)->ef_funct : 0;
5509
5510         if (func && accept_menu_prefix(func)) {
5511             iflags.menu_requested = TRUE;
5512             ++cmd;
5513         }
5514     }
5515
5516     if ((do_walk || do_rush) && !context.travel && !dxdy_moveok()) {
5517         /* trying to move diagonally as a grid bug;
5518            this used to be treated by movecmd() as not being
5519            a movement attempt, but that didn't provide for any
5520            feedback and led to strangeness if the key pressed
5521            ('u' in particular) was overloaded for num_pad use */
5522 /*JP
5523         You_cant("get there from here...");
5524 */
5525         You_cant("\82±\82±\82©\82ç\82»\82±\82Ö\82Í\8ds\82¯\82Ü\82¹\82ñ\81D\81D\81D");
5526         context.run = 0;
5527         context.nopick = context.forcefight = FALSE;
5528         context.move = context.mv = FALSE;
5529         multi = 0;
5530         return;
5531     }
5532
5533     if (do_walk) {
5534         if (multi)
5535             context.mv = TRUE;
5536         domove();
5537         context.forcefight = 0;
5538         return;
5539     } else if (do_rush) {
5540         if (firsttime) {
5541             if (!multi)
5542                 multi = max(COLNO, ROWNO);
5543             u.last_str_turn = 0;
5544         }
5545         context.mv = TRUE;
5546         domove();
5547         return;
5548     } else if (prefix_seen && cmd[1] == Cmd.spkeys[NHKF_ESC]) {
5549         /* <prefix><escape> */
5550         /* don't report "unknown command" for change of heart... */
5551         bad_command = FALSE;
5552     } else if (*cmd == ' ' && !flags.rest_on_space) {
5553         bad_command = TRUE; /* skip cmdlist[] loop */
5554
5555     /* handle all other commands */
5556     } else {
5557         register const struct ext_func_tab *tlist;
5558         int res, NDECL((*func));
5559
5560         /* current - use *cmd to directly index cmdlist array */
5561         if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) {
5562             if (!wizard && (tlist->flags & WIZMODECMD)) {
5563 /*JP
5564                 You_cant("do that!");
5565 */
5566                 pline("\82»\82ê\82Í\82Å\82«\82Ü\82¹\82ñ\81I");
5567                 res = 0;
5568             } else if (u.uburied && !(tlist->flags & IFBURIED)) {
5569 /*JP
5570                 You_cant("do that while you are buried!");
5571 */
5572                 You("\96\84\82Ü\82Á\82Ä\82¢\82é\8e\9e\82É\82»\82ñ\82È\82±\82Æ\82Í\82Å\82«\82È\82¢\81I");
5573                 res = 0;
5574             } else {
5575                 /* we discard 'const' because some compilers seem to have
5576                    trouble with the pointer passed to set_occupation() */
5577                 func = ((struct ext_func_tab *) tlist)->ef_funct;
5578                 if (tlist->f_text && !occupation && multi)
5579                     set_occupation(func, tlist->f_text, multi);
5580                 res = (*func)(); /* perform the command */
5581             }
5582             if (!res) {
5583                 context.move = FALSE;
5584                 multi = 0;
5585             }
5586             return;
5587         }
5588         /* if we reach here, cmd wasn't found in cmdlist[] */
5589         bad_command = TRUE;
5590     }
5591
5592     if (bad_command) {
5593         char expcmd[20]; /* we expect 'cmd' to point to 1 or 2 chars */
5594         char c, c1 = cmd[1];
5595
5596         expcmd[0] = '\0';
5597         while ((c = *cmd++) != '\0')
5598             Strcat(expcmd, visctrl(c)); /* add 1..4 chars plus terminator */
5599
5600 /*JP
5601         if (!prefix_seen || !help_dir(c1, spkey, "Invalid direction key!"))
5602 */
5603         if (!prefix_seen || !help_dir(c1, spkey, "\96³\8cø\82È\95û\8cü\8ew\92è\82Å\82·\81I"))
5604 /*JP
5605             Norep("Unknown command '%s'.", expcmd);
5606 */
5607             Norep("'%s'\83R\83}\83\93\83h\81H", expcmd);
5608     }
5609     /* didn't move */
5610     context.move = FALSE;
5611     multi = 0;
5612     return;
5613 }
5614
5615 /* convert an x,y pair into a direction code */
5616 int
5617 xytod(x, y)
5618 schar x, y;
5619 {
5620     register int dd;
5621
5622     for (dd = 0; dd < 8; dd++)
5623         if (x == xdir[dd] && y == ydir[dd])
5624             return dd;
5625     return -1;
5626 }
5627
5628 /* convert a direction code into an x,y pair */
5629 void
5630 dtoxy(cc, dd)
5631 coord *cc;
5632 register int dd;
5633 {
5634     cc->x = xdir[dd];
5635     cc->y = ydir[dd];
5636     return;
5637 }
5638
5639 /* also sets u.dz, but returns false for <> */
5640 int
5641 movecmd(sym)
5642 char sym;
5643 {
5644     register const char *dp = index(Cmd.dirchars, sym);
5645
5646     u.dz = 0;
5647     if (!dp || !*dp)
5648         return 0;
5649     u.dx = xdir[dp - Cmd.dirchars];
5650     u.dy = ydir[dp - Cmd.dirchars];
5651     u.dz = zdir[dp - Cmd.dirchars];
5652 #if 0 /* now handled elsewhere */
5653     if (u.dx && u.dy && NODIAG(u.umonnum)) {
5654         u.dx = u.dy = 0;
5655         return 0;
5656     }
5657 #endif
5658     return !u.dz;
5659 }
5660
5661 /* grid bug handling which used to be in movecmd() */
5662 int
5663 dxdy_moveok()
5664 {
5665     if (u.dx && u.dy && NODIAG(u.umonnum))
5666         u.dx = u.dy = 0;
5667     return u.dx || u.dy;
5668 }
5669
5670 /* decide whether a character (user input keystroke) requests screen repaint */
5671 boolean
5672 redraw_cmd(c)
5673 char c;
5674 {
5675     return (boolean) (c == Cmd.spkeys[NHKF_REDRAW]
5676                       || (Cmd.num_pad && c == Cmd.spkeys[NHKF_REDRAW2]));
5677 }
5678
5679 boolean
5680 prefix_cmd(c)
5681 char c;
5682 {
5683     return (c == Cmd.spkeys[NHKF_RUSH]
5684             || c == Cmd.spkeys[NHKF_RUN]
5685             || c == Cmd.spkeys[NHKF_NOPICKUP]
5686             || c == Cmd.spkeys[NHKF_RUN_NOPICKUP]
5687             || c == Cmd.spkeys[NHKF_FIGHT]
5688             || (Cmd.num_pad && (c == Cmd.spkeys[NHKF_RUN2]
5689                                 || c == Cmd.spkeys[NHKF_FIGHT2])));
5690 }
5691
5692 /*
5693  * uses getdir() but unlike getdir() it specifically
5694  * produces coordinates using the direction from getdir()
5695  * and verifies that those coordinates are ok.
5696  *
5697  * If the call to getdir() returns 0, Never_mind is displayed.
5698  * If the resulting coordinates are not okay, emsg is displayed.
5699  *
5700  * Returns non-zero if coordinates in cc are valid.
5701  */
5702 int
5703 get_adjacent_loc(prompt, emsg, x, y, cc)
5704 const char *prompt, *emsg;
5705 xchar x, y;
5706 coord *cc;
5707 {
5708     xchar new_x, new_y;
5709     if (!getdir(prompt)) {
5710         pline1(Never_mind);
5711         return 0;
5712     }
5713     new_x = x + u.dx;
5714     new_y = y + u.dy;
5715     if (cc && isok(new_x, new_y)) {
5716         cc->x = new_x;
5717         cc->y = new_y;
5718     } else {
5719         if (emsg)
5720             pline1(emsg);
5721         return 0;
5722     }
5723     return 1;
5724 }
5725
5726 int
5727 getdir(s)
5728 const char *s;
5729 {
5730     char dirsym;
5731     int is_mov;
5732
5733 retry:
5734     if (in_doagain || *readchar_queue)
5735         dirsym = readchar();
5736     else
5737 /*JP
5738         dirsym = yn_function((s && *s != '^') ? s : "In what direction?",
5739 */
5740         dirsym = yn_function((s && *s != '^') ? s : "\82Ç\82Ì\95û\8cü\81H",
5741                              (char *) 0, '\0');
5742     /* remove the prompt string so caller won't have to */
5743     clear_nhwindow(WIN_MESSAGE);
5744
5745     if (redraw_cmd(dirsym)) { /* ^R */
5746         docrt();              /* redraw */
5747         goto retry;
5748     }
5749     savech(dirsym);
5750
5751     if (dirsym == Cmd.spkeys[NHKF_GETDIR_SELF]
5752         || dirsym == Cmd.spkeys[NHKF_GETDIR_SELF2]) {
5753         u.dx = u.dy = u.dz = 0;
5754     } else if (!(is_mov = movecmd(dirsym)) && !u.dz) {
5755         boolean did_help = FALSE, help_requested;
5756
5757         if (!index(quitchars, dirsym)) {
5758             help_requested = (dirsym == Cmd.spkeys[NHKF_GETDIR_HELP]);
5759             if (help_requested || iflags.cmdassist) {
5760                 did_help = help_dir((s && *s == '^') ? dirsym : '\0',
5761                                     NHKF_ESC,
5762                                     help_requested ? (const char *) 0
5763 /*JP
5764                                             : "Invalid direction key!");
5765 */
5766                                             : "\96³\8cø\82È\95û\8cü\8ew\92è\82Å\82·\81I");
5767                 if (help_requested)
5768                     goto retry;
5769             }
5770             if (!did_help)
5771 /*JP
5772                 pline("What a strange direction!");
5773 */
5774                 pline("\82¸\82¢\82Ô\82ñ\82Æ\8aï\96­\82È\95û\8cü\82¾\81I");
5775         }
5776         return 0;
5777     } else if (is_mov && !dxdy_moveok()) {
5778 /*JP
5779         You_cant("orient yourself that direction.");
5780 */
5781         You_cant("\8cü\82«\82É\8e©\95ª\8e©\90g\82ð\8ew\92è\82Å\82«\82È\82¢\81D");
5782         return 0;
5783     }
5784     if (!u.dz && (Stunned || (Confusion && !rn2(5))))
5785         confdir();
5786     return 1;
5787 }
5788
5789 STATIC_OVL void
5790 show_direction_keys(win, centerchar, nodiag)
5791 winid win; /* should specify a window which is using a fixed-width font... */
5792 char centerchar; /* '.' or '@' or ' ' */
5793 boolean nodiag;
5794 {
5795     char buf[BUFSZ];
5796
5797     if (!centerchar)
5798         centerchar = ' ';
5799
5800     if (nodiag) {
5801         Sprintf(buf, "             %c   ", Cmd.move_N);
5802         putstr(win, 0, buf);
5803         putstr(win, 0, "             |   ");
5804         Sprintf(buf, "          %c- %c -%c",
5805                 Cmd.move_W, centerchar, Cmd.move_E);
5806         putstr(win, 0, buf);
5807         putstr(win, 0, "             |   ");
5808         Sprintf(buf, "             %c   ", Cmd.move_S);
5809         putstr(win, 0, buf);
5810     } else {
5811         Sprintf(buf, "          %c  %c  %c",
5812                 Cmd.move_NW, Cmd.move_N, Cmd.move_NE);
5813         putstr(win, 0, buf);
5814         putstr(win, 0, "           \\ | / ");
5815         Sprintf(buf, "          %c- %c -%c",
5816                 Cmd.move_W, centerchar, Cmd.move_E);
5817         putstr(win, 0, buf);
5818         putstr(win, 0, "           / | \\ ");
5819         Sprintf(buf, "          %c  %c  %c",
5820                 Cmd.move_SW, Cmd.move_S, Cmd.move_SE);
5821         putstr(win, 0, buf);
5822     };
5823 }
5824
5825 /* explain choices if player has asked for getdir() help or has given
5826    an invalid direction after a prefix key ('F', 'g', 'm', &c), which
5827    might be bogus but could be up, down, or self when not applicable */
5828 STATIC_OVL boolean
5829 help_dir(sym, spkey, msg)
5830 char sym;
5831 int spkey; /* NHKF_ code for prefix key, if one was used, or for ESC */
5832 const char *msg;
5833 {
5834     static const char wiz_only_list[] = "EFGIVW";
5835     char ctrl;
5836     winid win;
5837     char buf[BUFSZ], buf2[BUFSZ], *explain;
5838     const char *dothat, *how;
5839     boolean prefixhandling, viawindow;
5840
5841     /* NHKF_ESC indicates that player asked for help at getdir prompt */
5842     viawindow = (spkey == NHKF_ESC || iflags.cmdassist);
5843     prefixhandling = (spkey != NHKF_ESC);
5844     /*
5845      * Handling for prefix keys that don't want special directions.
5846      * Delivered via pline if 'cmdassist' is off, or instead of the
5847      * general message if it's on.
5848      */
5849     dothat = "do that";
5850     how = " at"; /* for "<action> at yourself"; not used for up/down */
5851     switch (spkey) {
5852     case NHKF_NOPICKUP:
5853         dothat = "move";
5854         break;
5855     case NHKF_RUSH:
5856         dothat = "rush";
5857         break;
5858     case NHKF_RUN2:
5859         if (!Cmd.num_pad)
5860             break;
5861         /*FALLTHRU*/
5862     case NHKF_RUN:
5863     case NHKF_RUN_NOPICKUP:
5864         dothat = "run";
5865         break;
5866     case NHKF_FIGHT2:
5867         if (!Cmd.num_pad)
5868             break;
5869         /*FALLTHRU*/
5870     case NHKF_FIGHT:
5871         dothat = "fight";
5872         how = ""; /* avoid "fight at yourself" */
5873         break;
5874     default:
5875         prefixhandling = FALSE;
5876         break;
5877     }
5878
5879     buf[0] = '\0';
5880     /* for movement prefix followed by '.' or (numpad && 's') to mean 'self';
5881        note: '-' for hands (inventory form of 'self') is not handled here */
5882     if (prefixhandling
5883         && (sym == Cmd.spkeys[NHKF_GETDIR_SELF]
5884             || (Cmd.num_pad && sym == Cmd.spkeys[NHKF_GETDIR_SELF2]))) {
5885         Sprintf(buf, "You can't %s%s yourself.", dothat, how);
5886     /* for movement prefix followed by up or down */
5887     } else if (prefixhandling && (sym == '<' || sym == '>')) {
5888         Sprintf(buf, "You can't %s %s.", dothat,
5889                 /* was "upwards" and "downwards", but they're considered
5890                    to be variants of canonical "upward" and "downward" */
5891                 (sym == '<') ? "upward" : "downward");
5892     }
5893
5894     /* if '!cmdassist', display via pline() and we're done (note: asking
5895        for help at getdir() prompt forces cmdassist for this operation) */
5896     if (!viawindow) {
5897         if (prefixhandling) {
5898             if (!*buf)
5899                 Sprintf(buf, "Invalid direction for '%s' prefix.",
5900                         visctrl(Cmd.spkeys[spkey]));
5901             pline("%s", buf);
5902             return TRUE;
5903         }
5904         /* when 'cmdassist' is off and caller doesn't insist, do nothing */
5905         return FALSE;
5906     }
5907
5908     win = create_nhwindow(NHW_TEXT);
5909     if (!win)
5910         return FALSE;
5911
5912     if (*buf) {
5913         /* show bad-prefix message instead of general invalid-direction one */
5914         putstr(win, 0, buf);
5915         putstr(win, 0, "");
5916     } else if (msg) {
5917         Sprintf(buf, "cmdassist: %s", msg);
5918         putstr(win, 0, buf);
5919         putstr(win, 0, "");
5920     }
5921
5922     if (!prefixhandling && (letter(sym) || sym == '[')) {
5923         /* '[': old 'cmdhelp' showed ESC as ^[ */
5924         sym = highc(sym); /* @A-Z[ (note: letter() accepts '@') */
5925         ctrl = (sym - 'A') + 1; /* 0-27 (note: 28-31 aren't applicable) */
5926         if ((explain = dowhatdoes_core(ctrl, buf2)) != 0
5927             && (!index(wiz_only_list, sym) || wizard)) {
5928             Sprintf(buf, "Are you trying to use ^%c%s?", sym,
5929                     index(wiz_only_list, sym) ? ""
5930                         : " as specified in the Guidebook");
5931             putstr(win, 0, buf);
5932             putstr(win, 0, "");
5933             putstr(win, 0, explain);
5934             putstr(win, 0, "");
5935             putstr(win, 0,
5936                   "To use that command, hold down the <Ctrl> key as a shift");
5937             Sprintf(buf, "and press the <%c> key.", sym);
5938             putstr(win, 0, buf);
5939             putstr(win, 0, "");
5940         }
5941     }
5942
5943     Sprintf(buf, "Valid direction keys%s%s%s are:",
5944             prefixhandling ? " to " : "", prefixhandling ? dothat : "",
5945             NODIAG(u.umonnum) ? " in your current form" : "");
5946     putstr(win, 0, buf);
5947     show_direction_keys(win, !prefixhandling ? '.' : ' ', NODIAG(u.umonnum));
5948
5949     if (!prefixhandling || spkey == NHKF_NOPICKUP) {
5950         /* NOPICKUP: unlike the other prefix keys, 'm' allows up/down for
5951            stair traversal; we won't get here when "m<" or "m>" has been
5952            given but we include up and down for 'm'+invalid_direction;
5953            self is excluded as a viable direction for every prefix */
5954         putstr(win, 0, "");
5955         putstr(win, 0, "          <  up");
5956         putstr(win, 0, "          >  down");
5957         if (!prefixhandling) {
5958             int selfi = Cmd.num_pad ? NHKF_GETDIR_SELF2 : NHKF_GETDIR_SELF;
5959
5960             Sprintf(buf,   "       %4s  direct at yourself",
5961                     visctrl(Cmd.spkeys[selfi]));
5962             putstr(win, 0, buf);
5963         }
5964     }
5965
5966     if (msg) {
5967         /* non-null msg means that this wasn't an explicit user request */
5968         putstr(win, 0, "");
5969         putstr(win, 0,
5970 /*JP
5971                "(Suppress this message with !cmdassist in config file.)");
5972 */
5973                "(\82±\82Ì\83\81\83b\83Z\81[\83W\82ð\95\\8e¦\82µ\82½\82­\82È\82¢\8fê\8d\87\82Í\90Ý\92è\83t\83@\83C\83\8b\82É !cmdassist \82ð\90Ý\92è\82µ\82Ä\82­\82¾\82³\82¢\81D)");
5974     }
5975     display_nhwindow(win, FALSE);
5976     destroy_nhwindow(win);
5977     return TRUE;
5978 }
5979
5980 void
5981 confdir()
5982 {
5983     register int x = NODIAG(u.umonnum) ? 2 * rn2(4) : rn2(8);
5984
5985     u.dx = xdir[x];
5986     u.dy = ydir[x];
5987     return;
5988 }
5989
5990 const char *
5991 directionname(dir)
5992 int dir;
5993 {
5994     static NEARDATA const char *const dirnames[] = {
5995         "west",      "northwest", "north",     "northeast", "east",
5996         "southeast", "south",     "southwest", "down",      "up",
5997     };
5998
5999     if (dir < 0 || dir >= SIZE(dirnames))
6000         return "invalid";
6001     return dirnames[dir];
6002 }
6003
6004 int
6005 isok(x, y)
6006 register int x, y;
6007 {
6008     /* x corresponds to curx, so x==1 is the first column. Ach. %% */
6009     return x >= 1 && x <= COLNO - 1 && y >= 0 && y <= ROWNO - 1;
6010 }
6011
6012 /* #herecmdmenu command */
6013 STATIC_PTR int
6014 doherecmdmenu(VOID_ARGS)
6015 {
6016     char ch = here_cmd_menu(TRUE);
6017
6018     return ch ? 1 : 0;
6019 }
6020
6021 /* #therecmdmenu command, a way to test there_cmd_menu without mouse */
6022 STATIC_PTR int
6023 dotherecmdmenu(VOID_ARGS)
6024 {
6025     char ch;
6026
6027     if (!getdir((const char *) 0) || !isok(u.ux + u.dx, u.uy + u.dy))
6028         return 0;
6029
6030     if (u.dx || u.dy)
6031         ch = there_cmd_menu(TRUE, u.ux + u.dx, u.uy + u.dy);
6032     else
6033         ch = here_cmd_menu(TRUE);
6034
6035     return ch ? 1 : 0;
6036 }
6037
6038 STATIC_OVL void
6039 add_herecmd_menuitem(win, func, text)
6040 winid win;
6041 int NDECL((*func));
6042 const char *text;
6043 {
6044     char ch;
6045     anything any;
6046
6047     if ((ch = cmd_from_func(func)) != '\0') {
6048         any = zeroany;
6049         any.a_nfunc = func;
6050         add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, text, MENU_UNSELECTED);
6051     }
6052 }
6053
6054 STATIC_OVL char
6055 there_cmd_menu(doit, x, y)
6056 boolean doit;
6057 int x, y;
6058 {
6059     winid win;
6060     char ch;
6061     char buf[BUFSZ];
6062     schar typ = levl[x][y].typ;
6063     int npick, K = 0;
6064     menu_item *picks = (menu_item *) 0;
6065     struct trap *ttmp;
6066     struct monst *mtmp;
6067
6068     win = create_nhwindow(NHW_MENU);
6069     start_menu(win);
6070
6071     if (IS_DOOR(typ)) {
6072         boolean key_or_pick, card;
6073         int dm = levl[x][y].doormask;
6074
6075         if ((dm & (D_CLOSED | D_LOCKED))) {
6076             add_herecmd_menuitem(win, doopen, "Open the door"), ++K;
6077             /* unfortunately there's no lknown flag for doors to
6078                remember the locked/unlocked state */
6079             key_or_pick = (carrying(SKELETON_KEY) || carrying(LOCK_PICK));
6080             card = (carrying(CREDIT_CARD) != 0);
6081             if (key_or_pick || card) {
6082                 Sprintf(buf, "%sunlock the door",
6083                         key_or_pick ? "lock or " : "");
6084                 add_herecmd_menuitem(win, doapply, upstart(buf)), ++K;
6085             }
6086             /* unfortunately there's no tknown flag for doors (or chests)
6087                to remember whether a trap had been found */
6088             add_herecmd_menuitem(win, dountrap,
6089                                  "Search the door for a trap"), ++K;
6090             /* [what about #force?] */
6091             add_herecmd_menuitem(win, dokick, "Kick the door"), ++K;
6092         } else if ((dm & D_ISOPEN)) {
6093             add_herecmd_menuitem(win, doclose, "Close the door"), ++K;
6094         }
6095     }
6096
6097     if (typ <= SCORR)
6098         add_herecmd_menuitem(win, dosearch, "Search for secret doors"), ++K;
6099
6100     if ((ttmp = t_at(x, y)) != 0 && ttmp->tseen) {
6101         add_herecmd_menuitem(win, doidtrap, "Examine trap"), ++K;
6102         if (ttmp->ttyp != VIBRATING_SQUARE)
6103             add_herecmd_menuitem(win, dountrap, "Attempt to disarm trap"), ++K;
6104     }
6105
6106     mtmp = m_at(x, y);
6107     if (mtmp && !canspotmon(mtmp))
6108         mtmp = 0;
6109     if (mtmp && which_armor(mtmp, W_SADDLE)) {
6110         char *mnam = x_monnam(mtmp, ARTICLE_THE, (char *) 0,
6111                               SUPPRESS_SADDLE, FALSE);
6112
6113         if (!u.usteed) {
6114             Sprintf(buf, "Ride %s", mnam);
6115             add_herecmd_menuitem(win, doride, buf), ++K;
6116         }
6117         Sprintf(buf, "Remove saddle from %s", mnam);
6118         add_herecmd_menuitem(win, doloot, buf), ++K;
6119     }
6120     if (mtmp && can_saddle(mtmp) && !which_armor(mtmp, W_SADDLE)
6121         && carrying(SADDLE)) {
6122         Sprintf(buf, "Put saddle on %s", mon_nam(mtmp)), ++K;
6123         add_herecmd_menuitem(win, doapply, buf);
6124     }
6125 #if 0
6126     if (mtmp || glyph_is_invisible(glyph_at(x, y))) {
6127         /* "Attack %s", mtmp ? mon_nam(mtmp) : "unseen creature" */
6128     } else {
6129         /* "Move %s", direction */
6130     }
6131 #endif
6132
6133     if (K) {
6134         end_menu(win, "What do you want to do?");
6135         npick = select_menu(win, PICK_ONE, &picks);
6136     } else {
6137         pline("No applicable actions.");
6138         npick = 0;
6139     }
6140     destroy_nhwindow(win);
6141     ch = '\0';
6142     if (npick > 0) {
6143         int NDECL((*func)) = picks->item.a_nfunc;
6144         free((genericptr_t) picks);
6145
6146         if (doit) {
6147             int ret = (*func)();
6148
6149             ch = (char) ret;
6150         } else {
6151             ch = cmd_from_func(func);
6152         }
6153     }
6154     return ch;
6155 }
6156
6157 STATIC_OVL char
6158 here_cmd_menu(doit)
6159 boolean doit;
6160 {
6161     winid win;
6162     char ch;
6163     char buf[BUFSZ];
6164     schar typ = levl[u.ux][u.uy].typ;
6165     int npick;
6166     menu_item *picks = (menu_item *) 0;
6167
6168     win = create_nhwindow(NHW_MENU);
6169     start_menu(win);
6170
6171     if (IS_FOUNTAIN(typ) || IS_SINK(typ)) {
6172         Sprintf(buf, "Drink from the %s",
6173                 defsyms[IS_FOUNTAIN(typ) ? S_fountain : S_sink].explanation);
6174         add_herecmd_menuitem(win, dodrink, buf);
6175     }
6176     if (IS_FOUNTAIN(typ))
6177         add_herecmd_menuitem(win, dodip,
6178                              "Dip something into the fountain");
6179     if (IS_THRONE(typ))
6180         add_herecmd_menuitem(win, dosit,
6181                              "Sit on the throne");
6182
6183     if ((u.ux == xupstair && u.uy == yupstair)
6184         || (u.ux == sstairs.sx && u.uy == sstairs.sy && sstairs.up)
6185         || (u.ux == xupladder && u.uy == yupladder)) {
6186         Sprintf(buf, "Go up the %s",
6187                 (u.ux == xupladder && u.uy == yupladder)
6188                 ? "ladder" : "stairs");
6189         add_herecmd_menuitem(win, doup, buf);
6190     }
6191     if ((u.ux == xdnstair && u.uy == ydnstair)
6192         || (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)
6193         || (u.ux == xdnladder && u.uy == ydnladder)) {
6194         Sprintf(buf, "Go down the %s",
6195                 (u.ux == xupladder && u.uy == yupladder)
6196                 ? "ladder" : "stairs");
6197         add_herecmd_menuitem(win, dodown, buf);
6198     }
6199     if (u.usteed) { /* another movement choice */
6200         Sprintf(buf, "Dismount %s",
6201                 x_monnam(u.usteed, ARTICLE_THE, (char *) 0,
6202                          SUPPRESS_SADDLE, FALSE));
6203         add_herecmd_menuitem(win, doride, buf);
6204     }
6205
6206 #if 0
6207     if (Upolyd) { /* before objects */
6208         Sprintf(buf, "Use %s special ability",
6209                 s_suffix(mons[u.umonnum].mname));
6210         add_herecmd_menuitem(win, domonability, buf);
6211     }
6212 #endif
6213
6214     if (OBJ_AT(u.ux, u.uy)) {
6215         struct obj *otmp = level.objects[u.ux][u.uy];
6216
6217         Sprintf(buf, "Pick up %s", otmp->nexthere ? "items" : doname(otmp));
6218         add_herecmd_menuitem(win, dopickup, buf);
6219
6220         if (Is_container(otmp)) {
6221             Sprintf(buf, "Loot %s", doname(otmp));
6222             add_herecmd_menuitem(win, doloot, buf);
6223         }
6224         if (otmp->oclass == FOOD_CLASS) {
6225             Sprintf(buf, "Eat %s", doname(otmp));
6226             add_herecmd_menuitem(win, doeat, buf);
6227         }
6228     }
6229
6230     if (invent)
6231         add_herecmd_menuitem(win, dodrop, "Drop items");
6232
6233     add_herecmd_menuitem(win, donull, "Rest one turn");
6234     add_herecmd_menuitem(win, dosearch, "Search around you");
6235     add_herecmd_menuitem(win, dolook, "Look at what is here");
6236
6237     end_menu(win, "What do you want to do?");
6238     npick = select_menu(win, PICK_ONE, &picks);
6239     destroy_nhwindow(win);
6240     ch = '\0';
6241     if (npick > 0) {
6242         int NDECL((*func)) = picks->item.a_nfunc;
6243         free((genericptr_t) picks);
6244
6245         if (doit) {
6246             int ret = (*func)();
6247
6248             ch = (char) ret;
6249         } else {
6250             ch = cmd_from_func(func);
6251         }
6252     }
6253     return ch;
6254 }
6255
6256
6257 static NEARDATA int last_multi;
6258
6259 /*
6260  * convert a MAP window position into a movecmd
6261  */
6262 const char *
6263 click_to_cmd(x, y, mod)
6264 int x, y, mod;
6265 {
6266     int dir;
6267     static char cmd[4];
6268     cmd[1] = 0;
6269
6270     if (iflags.clicklook && mod == CLICK_2) {
6271         clicklook_cc.x = x;
6272         clicklook_cc.y = y;
6273         cmd[0] = Cmd.spkeys[NHKF_CLICKLOOK];
6274         return cmd;
6275     }
6276
6277     x -= u.ux;
6278     y -= u.uy;
6279
6280     if (flags.travelcmd) {
6281         if (abs(x) <= 1 && abs(y) <= 1) {
6282             x = sgn(x), y = sgn(y);
6283         } else {
6284             u.tx = u.ux + x;
6285             u.ty = u.uy + y;
6286             cmd[0] = Cmd.spkeys[NHKF_TRAVEL];
6287             return cmd;
6288         }
6289
6290         if (x == 0 && y == 0) {
6291             if (iflags.herecmd_menu) {
6292                 cmd[0] = here_cmd_menu(FALSE);
6293                 return cmd;
6294             }
6295
6296             /* here */
6297             if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)
6298                 || IS_SINK(levl[u.ux][u.uy].typ)) {
6299                 cmd[0] = cmd_from_func(mod == CLICK_1 ? dodrink : dodip);
6300                 return cmd;
6301             } else if (IS_THRONE(levl[u.ux][u.uy].typ)) {
6302                 cmd[0] = cmd_from_func(dosit);
6303                 return cmd;
6304             } else if ((u.ux == xupstair && u.uy == yupstair)
6305                        || (u.ux == sstairs.sx && u.uy == sstairs.sy
6306                            && sstairs.up)
6307                        || (u.ux == xupladder && u.uy == yupladder)) {
6308                 cmd[0] = cmd_from_func(doup);
6309                 return cmd;
6310             } else if ((u.ux == xdnstair && u.uy == ydnstair)
6311                        || (u.ux == sstairs.sx && u.uy == sstairs.sy
6312                            && !sstairs.up)
6313                        || (u.ux == xdnladder && u.uy == ydnladder)) {
6314                 cmd[0] = cmd_from_func(dodown);
6315                 return cmd;
6316             } else if (OBJ_AT(u.ux, u.uy)) {
6317                 cmd[0] = cmd_from_func(Is_container(level.objects[u.ux][u.uy])
6318                                        ? doloot : dopickup);
6319                 return cmd;
6320             } else {
6321                 cmd[0] = cmd_from_func(donull); /* just rest */
6322                 return cmd;
6323             }
6324         }
6325
6326         /* directional commands */
6327
6328         dir = xytod(x, y);
6329
6330         if (!m_at(u.ux + x, u.uy + y)
6331             && !test_move(u.ux, u.uy, x, y, TEST_MOVE)) {
6332             cmd[1] = Cmd.dirchars[dir];
6333             cmd[2] = '\0';
6334             if (iflags.herecmd_menu) {
6335                 cmd[0] = there_cmd_menu(FALSE, u.ux + x, u.uy + y);
6336                 if (cmd[0] == '\0')
6337                     cmd[1] = '\0';
6338                 return cmd;
6339             }
6340
6341             if (IS_DOOR(levl[u.ux + x][u.uy + y].typ)) {
6342                 /* slight assistance to the player: choose kick/open for them
6343                  */
6344                 if (levl[u.ux + x][u.uy + y].doormask & D_LOCKED) {
6345                     cmd[0] = cmd_from_func(dokick);
6346                     return cmd;
6347                 }
6348                 if (levl[u.ux + x][u.uy + y].doormask & D_CLOSED) {
6349                     cmd[0] = cmd_from_func(doopen);
6350                     return cmd;
6351                 }
6352             }
6353             if (levl[u.ux + x][u.uy + y].typ <= SCORR) {
6354                 cmd[0] = cmd_from_func(dosearch);
6355                 cmd[1] = 0;
6356                 return cmd;
6357             }
6358         }
6359     } else {
6360         /* convert without using floating point, allowing sloppy clicking */
6361         if (x > 2 * abs(y))
6362             x = 1, y = 0;
6363         else if (y > 2 * abs(x))
6364             x = 0, y = 1;
6365         else if (x < -2 * abs(y))
6366             x = -1, y = 0;
6367         else if (y < -2 * abs(x))
6368             x = 0, y = -1;
6369         else
6370             x = sgn(x), y = sgn(y);
6371
6372         if (x == 0 && y == 0) {
6373             /* map click on player to "rest" command */
6374             cmd[0] = cmd_from_func(donull);
6375             return cmd;
6376         }
6377         dir = xytod(x, y);
6378     }
6379
6380     /* move, attack, etc. */
6381     cmd[1] = 0;
6382     if (mod == CLICK_1) {
6383         cmd[0] = Cmd.dirchars[dir];
6384     } else {
6385         cmd[0] = (Cmd.num_pad
6386                      ? M(Cmd.dirchars[dir])
6387                      : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */
6388     }
6389
6390     return cmd;
6391 }
6392
6393 char
6394 get_count(allowchars, inkey, maxcount, count, historical)
6395 char *allowchars;
6396 char inkey;
6397 long maxcount;
6398 long *count;
6399 boolean historical; /* whether to include in message history: True => yes */
6400 {
6401     char qbuf[QBUFSZ];
6402     int key;
6403     long cnt = 0L;
6404     boolean backspaced = FALSE;
6405     /* this should be done in port code so that we have erase_char
6406        and kill_char available; we can at least fake erase_char */
6407 #define STANDBY_erase_char '\177'
6408
6409     for (;;) {
6410         if (inkey) {
6411             key = inkey;
6412             inkey = '\0';
6413         } else
6414             key = readchar();
6415
6416         if (digit(key)) {
6417             cnt = 10L * cnt + (long) (key - '0');
6418             if (cnt < 0)
6419                 cnt = 0;
6420             else if (maxcount > 0 && cnt > maxcount)
6421                 cnt = maxcount;
6422         } else if (cnt && (key == '\b' || key == STANDBY_erase_char)) {
6423             cnt = cnt / 10;
6424             backspaced = TRUE;
6425         } else if (key == Cmd.spkeys[NHKF_ESC]) {
6426             break;
6427         } else if (!allowchars || index(allowchars, key)) {
6428             *count = cnt;
6429             break;
6430         }
6431
6432         if (cnt > 9 || backspaced) {
6433             clear_nhwindow(WIN_MESSAGE);
6434             if (backspaced && !cnt) {
6435 /*JP
6436                 Sprintf(qbuf, "Count: ");
6437 */
6438                 Sprintf(qbuf, "\90\94: ");
6439             } else {
6440 /*JP
6441                 Sprintf(qbuf, "Count: %ld", cnt);
6442 */
6443                 Sprintf(qbuf, "\90\94: %ld", cnt);
6444                 backspaced = FALSE;
6445             }
6446             /* bypassing pline() keeps intermediate prompt out of
6447                DUMPLOG message history */
6448             putstr(WIN_MESSAGE, 0, qbuf);
6449             mark_synch();
6450         }
6451     }
6452
6453     if (historical) {
6454 /*JP
6455         Sprintf(qbuf, "Count: %ld ", *count);
6456 */
6457         Sprintf(qbuf, "\90\94: %ld ", *count);
6458         (void) key2txt((uchar) key, eos(qbuf));
6459         putmsghistory(qbuf, FALSE);
6460     }
6461
6462     return key;
6463 }
6464
6465
6466 STATIC_OVL char *
6467 parse()
6468 {
6469 #ifdef LINT /* static char in_line[COLNO]; */
6470     char in_line[COLNO];
6471 #else
6472     static char in_line[COLNO];
6473 #endif
6474     register int foo;
6475     boolean prezero = FALSE;
6476
6477     iflags.in_parse = TRUE;
6478     multi = 0;
6479     context.move = 1;
6480     flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */
6481
6482 #ifdef ALTMETA
6483     alt_esc = iflags.altmeta; /* readchar() hack */
6484 #endif
6485     if (!Cmd.num_pad || (foo = readchar()) == Cmd.spkeys[NHKF_COUNT]) {
6486         long tmpmulti = multi;
6487
6488         foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti, FALSE);
6489         last_multi = multi = tmpmulti;
6490     }
6491 #ifdef ALTMETA
6492     alt_esc = FALSE; /* readchar() reset */
6493 #endif
6494
6495     if (foo == Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */
6496         clear_nhwindow(WIN_MESSAGE);
6497         multi = last_multi = 0;
6498     } else if (foo == Cmd.spkeys[NHKF_DOAGAIN] || in_doagain) {
6499         multi = last_multi;
6500     } else {
6501         last_multi = multi;
6502         savech(0); /* reset input queue */
6503         savech((char) foo);
6504     }
6505
6506     if (multi) {
6507         multi--;
6508         save_cm = in_line;
6509     } else {
6510         save_cm = (char *) 0;
6511     }
6512     /* in 3.4.3 this was in rhack(), where it was too late to handle M-5 */
6513     if (Cmd.pcHack_compat) {
6514         /* This handles very old inconsistent DOS/Windows behaviour
6515            in a different way: earlier, the keyboard handler mapped
6516            these, which caused counts to be strange when entered
6517            from the number pad. Now do not map them until here. */
6518         switch (foo) {
6519         case '5':
6520             foo = Cmd.spkeys[NHKF_RUSH];
6521             break;
6522         case M('5'):
6523             foo = Cmd.spkeys[NHKF_RUN];
6524             break;
6525         case M('0'):
6526             foo = Cmd.spkeys[NHKF_DOINV];
6527             break;
6528         default:
6529             break; /* as is */
6530         }
6531     }
6532
6533     in_line[0] = foo;
6534     in_line[1] = '\0';
6535     if (prefix_cmd(foo)) {
6536         foo = readchar();
6537         savech((char) foo);
6538         in_line[1] = foo;
6539         in_line[2] = 0;
6540     }
6541     clear_nhwindow(WIN_MESSAGE);
6542     if (prezero)
6543         in_line[0] = Cmd.spkeys[NHKF_ESC];
6544
6545     iflags.in_parse = FALSE;
6546     return in_line;
6547 }
6548
6549 #ifdef HANGUPHANDLING
6550 /* some very old systems, or descendents of such systems, expect signal
6551    handlers to have return type `int', but they don't actually inspect
6552    the return value so we should be safe using `void' unconditionally */
6553 /*ARGUSED*/
6554 void
6555 hangup(sig_unused) /* called as signal() handler, so sent at least one arg */
6556 int sig_unused UNUSED;
6557 {
6558     if (program_state.exiting)
6559         program_state.in_moveloop = 0;
6560     nhwindows_hangup();
6561 #ifdef SAFERHANGUP
6562     /* When using SAFERHANGUP, the done_hup flag it tested in rhack
6563        and a couple of other places; actual hangup handling occurs then.
6564        This is 'safer' because it disallows certain cheats and also
6565        protects against losing objects in the process of being thrown,
6566        but also potentially riskier because the disconnected program
6567        must continue running longer before attempting a hangup save. */
6568     program_state.done_hup++;
6569     /* defer hangup iff game appears to be in progress */
6570     if (program_state.in_moveloop && program_state.something_worth_saving)
6571         return;
6572 #endif /* SAFERHANGUP */
6573     end_of_input();
6574 }
6575
6576 void
6577 end_of_input()
6578 {
6579 #ifdef NOSAVEONHANGUP
6580 #ifdef INSURANCE
6581     if (flags.ins_chkpt && program_state.something_worth_saving)
6582         program_statue.preserve_locks = 1; /* keep files for recovery */
6583 #endif
6584     program_state.something_worth_saving = 0; /* don't save */
6585 #endif
6586
6587 #ifndef SAFERHANGUP
6588     if (!program_state.done_hup++)
6589 #endif
6590         if (program_state.something_worth_saving)
6591             (void) dosave0();
6592     if (iflags.window_inited)
6593         exit_nhwindows((char *) 0);
6594     clearlocks();
6595     nh_terminate(EXIT_SUCCESS);
6596     /*NOTREACHED*/ /* not necessarily true for vms... */
6597     return;
6598 }
6599 #endif /* HANGUPHANDLING */
6600
6601 char
6602 readchar()
6603 {
6604     register int sym;
6605     int x = u.ux, y = u.uy, mod = 0;
6606
6607     if (*readchar_queue)
6608         sym = *readchar_queue++;
6609     else
6610         sym = in_doagain ? pgetchar() : nh_poskey(&x, &y, &mod);
6611
6612 #ifdef NR_OF_EOFS
6613     if (sym == EOF) {
6614         register int cnt = NR_OF_EOFS;
6615         /*
6616          * Some SYSV systems seem to return EOFs for various reasons
6617          * (?like when one hits break or for interrupted systemcalls?),
6618          * and we must see several before we quit.
6619          */
6620         do {
6621             clearerr(stdin); /* omit if clearerr is undefined */
6622             sym = pgetchar();
6623         } while (--cnt && sym == EOF);
6624     }
6625 #endif /* NR_OF_EOFS */
6626
6627     if (sym == EOF) {
6628 #ifdef HANGUPHANDLING
6629         hangup(0); /* call end_of_input() or set program_state.done_hup */
6630 #endif
6631         sym = '\033';
6632 #ifdef ALTMETA
6633     } else if (sym == '\033' && alt_esc) {
6634         /* iflags.altmeta: treat two character ``ESC c'' as single `M-c' */
6635         sym = *readchar_queue ? *readchar_queue++ : pgetchar();
6636         if (sym == EOF || sym == 0)
6637             sym = '\033';
6638         else if (sym != '\033')
6639             sym |= 0200; /* force 8th bit on */
6640 #endif /*ALTMETA*/
6641     } else if (sym == 0) {
6642         /* click event */
6643         readchar_queue = click_to_cmd(x, y, mod);
6644         sym = *readchar_queue++;
6645     }
6646     return (char) sym;
6647 }
6648
6649 STATIC_PTR int
6650 dotravel(VOID_ARGS)
6651 {
6652     /* Keyboard travel command */
6653     static char cmd[2];
6654     coord cc;
6655
6656     if (!flags.travelcmd)
6657         return 0;
6658     cmd[1] = 0;
6659     cc.x = iflags.travelcc.x;
6660     cc.y = iflags.travelcc.y;
6661     if (cc.x == -1 && cc.y == -1) {
6662         /* No cached destination, start attempt from current position */
6663         cc.x = u.ux;
6664         cc.y = u.uy;
6665     }
6666     iflags.getloc_travelmode = TRUE;
6667     if (iflags.menu_requested) {
6668         int gf = iflags.getloc_filter;
6669         iflags.getloc_filter = GFILTER_VIEW;
6670         if (!getpos_menu(&cc, GLOC_INTERESTING)) {
6671             iflags.getloc_filter = gf;
6672             iflags.getloc_travelmode = FALSE;
6673             return 0;
6674         }
6675         iflags.getloc_filter = gf;
6676     } else {
6677 /*JP
6678     pline("Where do you want to travel to?");
6679 */
6680     pline("\82Ç\82±\82É\88Ú\93®\82·\82é\81H");
6681 /*JP
6682     if (getpos(&cc, TRUE, "the desired destination") < 0) {
6683 */
6684     if (getpos(&cc, TRUE, "\88Ú\93®\90æ") < 0) {
6685             /* user pressed ESC */
6686             iflags.getloc_travelmode = FALSE;
6687             return 0;
6688         }
6689     }
6690     iflags.getloc_travelmode = FALSE;
6691     iflags.travelcc.x = u.tx = cc.x;
6692     iflags.travelcc.y = u.ty = cc.y;
6693     cmd[0] = Cmd.spkeys[NHKF_TRAVEL];
6694     readchar_queue = cmd;
6695     return 0;
6696 }
6697
6698 #ifdef PORT_DEBUG
6699 extern void NDECL(win32con_debug_keystrokes);
6700 extern void NDECL(win32con_handler_info);
6701
6702 int
6703 wiz_port_debug()
6704 {
6705     int n, k;
6706     winid win;
6707     anything any;
6708     int item = 'a';
6709     int num_menu_selections;
6710     struct menu_selection_struct {
6711         char *menutext;
6712         void NDECL((*fn));
6713     } menu_selections[] = {
6714 #ifdef WIN32
6715         { "test win32 keystrokes (tty only)", win32con_debug_keystrokes },
6716         { "show keystroke handler information (tty only)",
6717           win32con_handler_info },
6718 #endif
6719         { (char *) 0, (void NDECL((*))) 0 } /* array terminator */
6720     };
6721
6722     num_menu_selections = SIZE(menu_selections) - 1;
6723     if (num_menu_selections > 0) {
6724         menu_item *pick_list;
6725
6726         win = create_nhwindow(NHW_MENU);
6727         start_menu(win);
6728         for (k = 0; k < num_menu_selections; ++k) {
6729             any.a_int = k + 1;
6730             add_menu(win, NO_GLYPH, &any, item++, 0, ATR_NONE,
6731                      menu_selections[k].menutext, MENU_UNSELECTED);
6732         }
6733         end_menu(win, "Which port debugging feature?");
6734         n = select_menu(win, PICK_ONE, &pick_list);
6735         destroy_nhwindow(win);
6736         if (n > 0) {
6737             n = pick_list[0].item.a_int - 1;
6738             free((genericptr_t) pick_list);
6739             /* execute the function */
6740             (*menu_selections[n].fn)();
6741         }
6742     } else
6743         pline("No port-specific debug capability defined.");
6744     return 0;
6745 }
6746 #endif /*PORT_DEBUG*/
6747
6748 /*
6749  *   Parameter validator for generic yes/no function to prevent
6750  *   the core from sending too long a prompt string to the
6751  *   window port causing a buffer overflow there.
6752  */
6753 char
6754 yn_function(query, resp, def)
6755 const char *query, *resp;
6756 char def;
6757 {
6758     char res, qbuf[QBUFSZ];
6759 #ifdef DUMPLOG
6760     extern unsigned saved_pline_index; /* pline.c */
6761     unsigned idx = saved_pline_index;
6762     /* buffer to hold query+space+formatted_single_char_response */
6763     char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */
6764 #endif
6765
6766     iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
6767
6768     /* maximum acceptable length is QBUFSZ-1 */
6769     if (strlen(query) >= QBUFSZ) {
6770         /* caller shouldn't have passed anything this long */
6771         paniclog("Query truncated: ", query);
6772         (void) strncpy(qbuf, query, QBUFSZ - 1 - 3);
6773         Strcpy(&qbuf[QBUFSZ - 1 - 3], "...");
6774         query = qbuf;
6775     }
6776     res = (*windowprocs.win_yn_function)(query, resp, def);
6777 #ifdef DUMPLOG
6778     if (idx == saved_pline_index) {
6779         /* when idx is still the same as saved_pline_index, the interface
6780            didn't put the prompt into saved_plines[]; we put a simplified
6781            version in there now (without response choices or default) */
6782         Sprintf(dumplog_buf, "%s ", query);
6783         (void) key2txt((uchar) res, eos(dumplog_buf));
6784         dumplogmsg(dumplog_buf);
6785     }
6786 #endif
6787     return res;
6788 }
6789
6790 /* for paranoid_confirm:quit,die,attack prompting */
6791 boolean
6792 paranoid_query(be_paranoid, prompt)
6793 boolean be_paranoid;
6794 const char *prompt;
6795 {
6796     boolean confirmed_ok;
6797
6798     /* when paranoid, player must respond with "yes" rather than just 'y'
6799        to give the go-ahead for this query; default is "no" unless the
6800        ParanoidConfirm flag is set in which case there's no default */
6801     if (be_paranoid) {
6802         char qbuf[QBUFSZ], ans[BUFSZ] = DUMMY;
6803         const char *promptprefix = "", *responsetype = ParanoidConfirm
6804                                                            ? "(yes|no)"
6805                                                            : "(yes) [no]";
6806         int trylimit = 6; /* 1 normal, 5 more with "Yes or No:" prefix */
6807
6808         /* in addition to being paranoid about this particular
6809            query, we might be even more paranoid about all paranoia
6810            responses (ie, ParanoidConfirm is set) in which case we
6811            require "no" to reject in addition to "yes" to confirm
6812            (except we won't loop if response is ESC; it means no) */
6813         do {
6814             Sprintf(qbuf, "%s%s %s", promptprefix, prompt, responsetype);
6815             getlin(qbuf, ans);
6816             (void) mungspaces(ans);
6817             confirmed_ok = !strcmpi(ans, "yes");
6818             if (confirmed_ok || *ans == '\033')
6819                 break;
6820             promptprefix = "\"Yes\" or \"No\": ";
6821         } while (ParanoidConfirm && strcmpi(ans, "no") && --trylimit);
6822     } else
6823         confirmed_ok = (yn(prompt) == 'y');
6824
6825     return confirmed_ok;
6826 }
6827
6828 int
6829 dosuspend_core()
6830 {
6831 #ifdef SUSPEND
6832     /* Does current window system support suspend? */
6833     if ((*windowprocs.win_can_suspend)()) {
6834         /* NB: SYSCF SHELLERS handled in port code. */
6835         dosuspend();
6836     } else
6837 #endif
6838 /*JP
6839         Norep("Suspend command not available.");
6840 */
6841         Norep("\92\86\92f\83R\83}\83\93\83h\82Í\97\98\97p\82Å\82«\82Ü\82¹\82ñ\81D");
6842     return 0;
6843 }
6844
6845 /*cmd.c*/