OSDN Git Service

add translation
[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-2018            */
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     boolean invrt;
1597     int absamt;
1598
1599     absamt = abs(incamt);
1600     /* Protection amount is typically larger than damage or to-hit;
1601        reduce magnitude by a third in order to stretch modifier ranges
1602        (small:1..5, moderate:6..10, large:11..19, huge:20+) */
1603 #if 0 /*JP*/
1604     if (!strcmp(inctyp, "defense"))
1605 #else
1606     if (!strcmp(inctyp, "\96h\8cä"))
1607 #endif
1608         absamt = (absamt * 2) / 3;
1609
1610     if (absamt <= 3)
1611 /*JP
1612         modif = "small";
1613 */
1614         modif = "\8bÍ\82©\82È";
1615     else if (absamt <= 6)
1616 /*JP
1617         modif = "moderate";
1618 */
1619         modif = "\92\86\92ö\93x\82Ì";
1620     else if (absamt <= 12)
1621 /*JP
1622         modif = "large";
1623 */
1624         modif = "\91å\82«\82È";
1625     else
1626 /*JP
1627         modif = "huge";
1628 */
1629         modif = "\8b­\91å\82È";
1630
1631 #if 0 /*JP*/
1632     modif = !incamt ? "no" : an(modif); /* ("no" case shouldn't happen) */
1633 #endif
1634 /*JP
1635     bonus = (incamt >= 0) ? "bonus" : "penalty";
1636 */
1637     bonus = (incamt > 0) ? "\83{\81[\83i\83X" : "\83y\83i\83\8b\83e\83B";
1638     /* "bonus <foo>" (to hit) vs "<bar> bonus" (damage, defense) */
1639 #if 0 /*JP*/
1640     invrt = strcmp(inctyp, "to hit") ? TRUE : FALSE;
1641 #else
1642     invrt = strcmp(inctyp, "\96½\92\86\97¦") ? 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     static NEARDATA const char if_surroundings_permitted[] =
2701         " if surroundings permitted";
2702     int ltmp, armpro;
2703     char buf[BUFSZ];
2704
2705     /*\
2706      *  Attributes
2707     \*/
2708     putstr(en_win, 0, "");
2709 /*JP
2710     putstr(en_win, 0, final ? "Final Attributes:" : "Current Attributes:");
2711 */
2712     putstr(en_win, 0, final ? "\8dÅ\8fI\91®\90«:" : "\8c»\8dÝ\82Ì\91®\90«:");
2713
2714     if (u.uevent.uhand_of_elbereth) {
2715 #if 0 /*JP*/
2716         static const char *const hofe_titles[3] = { "the Hand of Elbereth",
2717                                                     "the Envoy of Balance",
2718                                                     "the Glory of Arioch" };
2719 #else
2720         static const char *const hofe_titles[3] = { "\83G\83\8b\83x\83\8c\83X\82Ì\8cä\8eè",
2721                                                     "\92²\98a\82Ì\8eg\8eÒ",
2722                                                     "\83A\83\8a\83I\83b\83`\82Ì\96¼\97_" };
2723 #endif
2724         you_are(hofe_titles[u.uevent.uhand_of_elbereth - 1], "");
2725     }
2726
2727 /*JP
2728     Sprintf(buf, "%s", piousness(TRUE, "aligned"));
2729 */
2730     Sprintf(buf, "%s", piousness(TRUE, "\90M\8bÂ\90S"));
2731     if (u.ualign.record >= 0)
2732         you_are(buf, "");
2733     else
2734         you_have(buf, "");
2735
2736     if (wizard) {
2737 #if 0 /*JP*/
2738         Sprintf(buf, " %d", u.ualign.record);
2739         enl_msg("Your alignment ", "is", "was", buf, "");
2740 #else
2741         Sprintf(buf, "\82 \82È\82½\82Ì\91®\90«\92l\82Í%d", u.ualign.record);
2742         enl_msg(buf, "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
2743 #endif
2744     }
2745
2746     /*** Resistances to troubles ***/
2747     if (Invulnerable)
2748 /*JP
2749         you_are("invulnerable", from_what(INVULNERABLE));
2750 */
2751         you_are("\95s\8e\80\90g", from_what(INVULNERABLE));
2752     if (Antimagic)
2753 /*JP
2754         you_are("magic-protected", from_what(ANTIMAGIC));
2755 */
2756         you_have("\96\82\96@\96h\8cä\94\\97Í", from_what(ANTIMAGIC));
2757     if (Fire_resistance)
2758 /*JP
2759         you_are("fire resistant", from_what(FIRE_RES));
2760 */
2761         you_have("\89Î\82Ö\82Ì\91Ï\90«", from_what(FIRE_RES));
2762     if (Cold_resistance)
2763 /*JP
2764         you_are("cold resistant", from_what(COLD_RES));
2765 */
2766         you_have("\8a¦\82³\82Ö\82Ì\91Ï\90«", from_what(COLD_RES));
2767     if (Sleep_resistance)
2768 /*JP
2769         you_are("sleep resistant", from_what(SLEEP_RES));
2770 */
2771         you_have("\96°\82è\82Ö\82Ì\91Ï\90«", from_what(SLEEP_RES));
2772     if (Disint_resistance)
2773 /*JP
2774         you_are("disintegration-resistant", from_what(DISINT_RES));
2775 */
2776         you_have("\95²\8dÓ\82Ö\82Ì\91Ï\90«", from_what(DISINT_RES));
2777     if (Shock_resistance)
2778 /*JP
2779         you_are("shock resistant", from_what(SHOCK_RES));
2780 */
2781         you_have("\93d\8c\82\82Ö\82Ì\91Ï\90«", from_what(SHOCK_RES));
2782     if (Poison_resistance)
2783 /*JP
2784         you_are("poison resistant", from_what(POISON_RES));
2785 */
2786         you_have("\93Å\82Ö\82Ì\91Ï\90«", from_what(POISON_RES));
2787     if (Acid_resistance)
2788 /*JP
2789         you_are("acid resistant", from_what(ACID_RES));
2790 */
2791         you_have("\8e_\82Ö\82Ì\91Ï\90«", from_what(ACID_RES));
2792     if (Drain_resistance)
2793 /*JP
2794         you_are("level-drain resistant", from_what(DRAIN_RES));
2795 */
2796         you_have("\83\8c\83x\83\8b\83_\83E\83\93\82Ö\82Ì\91Ï\90«", from_what(DRAIN_RES));
2797     if (Sick_resistance)
2798 /*JP
2799         you_are("immune to sickness", from_what(SICK_RES));
2800 */
2801         you_have("\95a\8bC\82É\91Î\82·\82é\96Æ\89u", from_what(SICK_RES));
2802     if (Stone_resistance)
2803 /*JP
2804         you_are("petrification resistant", from_what(STONE_RES));
2805 */
2806         you_have("\90Î\89»\82Ö\82Ì\91Ï\90«", from_what(STONE_RES));
2807     if (Halluc_resistance)
2808 #if 0 /*JP*/
2809         enl_msg(You_, "resist", "resisted", " hallucinations",
2810                 from_what(HALLUC_RES));
2811 #else
2812         you_have("\8c\8ao\82Ö\82Ì\91Ï\90«", from_what(HALLUC_RES));
2813 #endif
2814     if (u.uedibility)
2815 /*JP
2816         you_can("recognize detrimental food", "");
2817 */
2818         you_can("\97L\8aQ\82È\90H\97¿\82ð\8e¯\95Ê", "");
2819
2820     /*** Vision and senses ***/
2821     if (!Blind && (Blinded || !haseyes(youmonst.data)))
2822         you_can("see", from_what(-BLINDED)); /* Eyes of the Overworld */
2823     if (See_invisible) {
2824         if (!Blind)
2825 /*JP
2826             enl_msg(You_, "see", "saw", " invisible", from_what(SEE_INVIS));
2827 */
2828             enl_msg("\82 \82È\82½\82Í\93§\96¾\82È\82à\82Ì\82ð\8c©\82ç\82ê", "\82é", "\82½", "", from_what(SEE_INVIS));
2829         else
2830 #if 0 /*JP*/
2831             enl_msg(You_, "will see", "would have seen",
2832                     " invisible when not blind", from_what(SEE_INVIS));
2833 #else
2834             enl_msg(You_, "\82é", "\82½",
2835                     "\96Ó\96Ú\82Å\82È\82¢\82Æ\82«\82É\82Í\93§\96¾\82È\82à\82Ì\82ð\8c©\82ç\82ê", from_what(SEE_INVIS));
2836 #endif
2837     }
2838     if (Blind_telepat)
2839 /*JP
2840         you_are("telepathic", from_what(TELEPAT));
2841 */
2842         you_have("\83e\83\8c\83p\83V\81[", from_what(TELEPAT));
2843     if (Warning)
2844 /*JP
2845         you_are("warned", from_what(WARNING));
2846 */
2847         you_have("\8cx\89ú\94\\97Í", from_what(WARNING));
2848     if (Warn_of_mon && context.warntype.obj) {
2849 #if 0 /*JP*/
2850         Sprintf(buf, "aware of the presence of %s",
2851                 (context.warntype.obj & M2_ORC) ? "orcs"
2852                 : (context.warntype.obj & M2_ELF) ? "elves"
2853                 : (context.warntype.obj & M2_DEMON) ? "demons" : something);
2854         you_are(buf, from_what(WARN_OF_MON));
2855 #else
2856         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2857                 (context.warntype.obj & M2_ORC) ? "\83I\81[\83N"
2858                 : (context.warntype.obj & M2_ELF) ? "\83G\83\8b\83t"
2859                 : (context.warntype.obj & M2_DEMON) ? "\88«\96\82" : something);
2860         you_have(buf, "");
2861 #endif
2862     }
2863     if (Warn_of_mon && context.warntype.polyd) {
2864 #if 0 /*JP*/
2865         Sprintf(buf, "aware of the presence of %s",
2866                 ((context.warntype.polyd & (M2_HUMAN | M2_ELF))
2867                  == (M2_HUMAN | M2_ELF))
2868                     ? "humans and elves"
2869                     : (context.warntype.polyd & M2_HUMAN)
2870                           ? "humans"
2871                           : (context.warntype.polyd & M2_ELF)
2872                                 ? "elves"
2873                                 : (context.warntype.polyd & M2_ORC)
2874                                       ? "orcs"
2875                                       : (context.warntype.polyd & M2_DEMON)
2876                                             ? "demons"
2877                                             : "certain monsters");
2878         you_are(buf, "");
2879 #else
2880         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2881                 ((context.warntype.polyd & (M2_HUMAN | M2_ELF))
2882                  == (M2_HUMAN | M2_ELF))
2883                     ? "\90l\8aÔ\82Æ\83G\83\8b\83t"
2884                     : (context.warntype.polyd & M2_HUMAN)
2885                           ? "\90l\8aÔ"
2886                           : (context.warntype.polyd & M2_ELF)
2887                                 ? "\83G\83\8b\83t"
2888                                 : (context.warntype.polyd & M2_ORC)
2889                                       ? "\83I\81[\83N"
2890                                       : (context.warntype.polyd & M2_DEMON)
2891                                             ? "\88«\96\82"
2892                                             : "\82 \82é\8eí\82Ì\89ö\95¨");
2893         you_have(buf, "");
2894 #endif
2895     }
2896     if (Warn_of_mon && context.warntype.speciesidx >= LOW_PM) {
2897 #if 0 /*JP*/
2898         Sprintf(buf, "aware of the presence of %s",
2899                 makeplural(mons[context.warntype.speciesidx].mname));
2900         you_are(buf, from_what(WARN_OF_MON));
2901 #else
2902         Sprintf(buf, "%s\82Ì\91\8dÝ\82ð\8a´\82\82é\94\\97Í",
2903                 mons[context.warntype.speciesidx].mname);
2904         you_have(buf, from_what(WARN_OF_MON));
2905 #endif
2906     }
2907     if (Undead_warning)
2908 /*JP
2909         you_are("warned of undead", from_what(WARN_UNDEAD));
2910 */
2911         you_have("\95s\8e\80\82Ì\90\95¨\82Ö\82Ì\8cx\89ú\94\\97Í", from_what(WARN_UNDEAD));
2912     if (Searching)
2913 /*JP
2914         you_have("automatic searching", from_what(SEARCHING));
2915 */
2916         you_have("\92T\8d¸\94\\97Í", from_what(SEARCHING));
2917     if (Clairvoyant)
2918 /*JP
2919         you_are("clairvoyant", from_what(CLAIRVOYANT));
2920 */
2921         you_have("\90ç\97¢\8aá\94\\97Í", from_what(CLAIRVOYANT));
2922     else if ((HClairvoyant || EClairvoyant) && BClairvoyant) {
2923         Strcpy(buf, from_what(-CLAIRVOYANT));
2924 #if 0 /*JP*/
2925         if (!strncmp(buf, " because of ", 12))
2926             /* overwrite substring; strncpy doesn't add terminator */
2927             (void) strncpy(buf, " if not for ", 12);
2928         enl_msg(You_, "could be", "could have been", " clairvoyant", buf);
2929 #else
2930         /*JP:\81u\81c\82É\82æ\82Á\82Ä\81v*/
2931         if (!strncmp(buf, "\82É\82æ\82Á\82Ä", 8))
2932             /*JP:\81u\81c\82ª\82È\82¯\82ê\82Î\81v\82É\8f\91\82«\8a·\82¦\82é*/
2933             strcpy(eos(buf) - 8, "\82ª\82È\82¯\82ê\82Î");
2934         you_have("\90ç\97¢\8aá\94\\97Í", buf);
2935 #endif
2936     }
2937     if (Infravision)
2938 /*JP
2939         you_have("infravision", from_what(INFRAVISION));
2940 */
2941         you_have("\90Ô\8aO\90ü\82ª\8c©\82¦\82é\8e\8b\8ao", from_what(INFRAVISION));
2942     if (Detect_monsters)
2943 /*JP
2944         you_are("sensing the presence of monsters", "");
2945 */
2946         you_have("\89ö\95¨\82ð\92T\82·\94\\97Í", "");
2947     if (u.umconf)
2948 /*JP
2949         you_are("going to confuse monsters", "");
2950 */
2951         you_have("\89ö\95¨\82ð\8d¬\97\90\82³\82¹\82é\94\\97Í", "");
2952
2953     /*** Appearance and behavior ***/
2954     if (Adornment) {
2955         int adorn = 0;
2956
2957         if (uleft && uleft->otyp == RIN_ADORNMENT)
2958             adorn += uleft->spe;
2959         if (uright && uright->otyp == RIN_ADORNMENT)
2960             adorn += uright->spe;
2961         /* the sum might be 0 (+0 ring or two which negate each other);
2962            that yields "you are charismatic" (which isn't pointless
2963            because it potentially impacts seduction attacks) */
2964 #if 0 /*JP*/
2965         Sprintf(buf, "%scharismatic",
2966                 (adorn > 0) ? "more " : (adorn < 0) ? "less " : "");
2967         you_are(buf, from_what(ADORNED));
2968 #else
2969         Sprintf(buf, "\96£\97Í%s\82Ä",
2970                 (adorn > 0) ? "\82ª\91\9d\89Á\82µ" : (adorn < 0) ? "\82ª\8c¸\8f­\82µ" : "\93I\82É\82È\82Á");
2971         enl_msg(You_, "\82Ä\82¢\82é", "\82½", buf, "");
2972 #endif
2973     }
2974     if (Invisible)
2975 /*JP
2976         you_are("invisible", from_what(INVIS));
2977 */
2978         you_are("\93§\96¾", from_what(INVIS));
2979     else if (Invis)
2980 /*JP
2981         you_are("invisible to others", from_what(INVIS));
2982 */
2983         you_are("\91¼\90l\82É\91Î\82µ\82Ä\93§\96¾", from_what(INVIS));
2984     /* ordinarily "visible" is redundant; this is a special case for
2985        the situation when invisibility would be an expected attribute */
2986     else if ((HInvis || EInvis) && BInvis)
2987 /*JP
2988         you_are("visible", from_what(-INVIS));
2989 */
2990         you_are("\95s\93§\96¾", from_what(-INVIS));
2991     if (Displaced)
2992 /*JP
2993         you_are("displaced", from_what(DISPLACED));
2994 */
2995         you_have("\8c\89e\94\\97Í", from_what(DISPLACED));
2996     if (Stealth)
2997 /*JP
2998         you_are("stealthy", from_what(STEALTH));
2999 */
3000         you_have("\90l\96Ú\82ð\93\90\82Þ\94\\97Í", from_what(STEALTH));
3001     if (Aggravate_monster)
3002 #if 0 /*JP*/
3003         enl_msg("You aggravate", "", "d", " monsters",
3004                 from_what(AGGRAVATE_MONSTER));
3005 #else
3006         you_are_ing("\94½\8a´\82ð\82©\82Á\82Ä", from_what(AGGRAVATE_MONSTER));
3007 #endif
3008     if (Conflict)
3009 /*JP
3010         enl_msg("You cause", "", "d", " conflict", from_what(CONFLICT));
3011 */
3012         you_are_ing("\93¬\91\88\82ð\88ø\82«\8bN\82±\82µ\82Ä", from_what(CONFLICT));
3013
3014     /*** Transportation ***/
3015     if (Jumping)
3016 /*JP
3017         you_can("jump", from_what(JUMPING));
3018 */
3019         you_can("\92µ\96ô\82·\82é\82±\82Æ\82ª", from_what(JUMPING));
3020     if (Teleportation)
3021 /*JP
3022         you_can("teleport", from_what(TELEPORT));
3023 */
3024         you_can("\8fu\8aÔ\88Ú\93®\82ª", from_what(TELEPORT));
3025     if (Teleport_control)
3026 /*JP
3027         you_have("teleport control", from_what(TELEPORT_CONTROL));
3028 */
3029         you_have("\8fu\8aÔ\88Ú\93®\82Ì\90§\8cä\94\\97Í", from_what(TELEPORT_CONTROL));
3030     /* actively levitating handled earlier as a status condition */
3031     if (BLevitation) { /* levitation is blocked */
3032         long save_BLev = BLevitation;
3033
3034         BLevitation = 0L;
3035         if (Levitation)
3036 #if 0 /*JP*/
3037             enl_msg(You_, "would levitate", "would have levitated",
3038                     if_surroundings_permitted, "");
3039 #else
3040             you_are("\95\82\97V\8fó\91Ô", "");
3041 #endif
3042         BLevitation = save_BLev;
3043     }
3044     /* actively flying handled earlier as a status condition */
3045     if (BFlying) { /* flight is blocked */
3046         long save_BFly = BFlying;
3047
3048         BFlying = 0L;
3049         if (Flying)
3050 #if 0 /*JP*/
3051             enl_msg(You_, "would fly", "would have flown",
3052                     Levitation
3053                        ? "if you weren't levitating"
3054                        : (save_BFly == FROMOUTSIDE)
3055                           ? if_surroundings_permitted
3056                           /* both surroundings and [latent] levitation */
3057                           : " if circumstances permitted",
3058                     "");
3059 #else
3060             you_can("\94ò\82Ô\82±\82Æ\82ª", "");
3061 #endif
3062         BFlying = save_BFly;
3063     }
3064     /* actively walking on water handled earlier as a status condition */
3065     if (Wwalking && !walking_on_water())
3066 /*JP
3067         you_can("walk on water", from_what(WWALKING));
3068 */
3069         you_can("\90\85\82Ì\8fã\82ð\95à\82­\82±\82Æ\82ª", from_what(WWALKING));
3070     /* actively swimming (in water but not under it) handled earlier */
3071     if (Swimming && (Underwater || !u.uinwater))
3072 /*JP
3073         you_can("swim", from_what(SWIMMING));
3074 */
3075         you_can("\89j\82®\82±\82Æ\82ª", from_what(SWIMMING));
3076     if (Breathless)
3077 /*JP
3078         you_can("survive without air", from_what(MAGICAL_BREATHING));
3079 */
3080         you_can("\8bó\8bC\82È\82µ\82Å\90\82«\89\84\82Ñ\82é\82±\82Æ\82ª", from_what(MAGICAL_BREATHING));
3081     else if (Amphibious)
3082 /*JP
3083         you_can("breathe water", from_what(MAGICAL_BREATHING));
3084 */
3085         you_can("\90\85\92\86\82Å\8cÄ\8bz\82ª", from_what(MAGICAL_BREATHING));
3086     if (Passes_walls)
3087 /*JP
3088         you_can("walk through walls", from_what(PASSES_WALLS));
3089 */
3090         you_can("\95Ç\82ð\92Ê\82è\94²\82¯\82é\82±\82Æ\82ª", from_what(PASSES_WALLS));
3091
3092     /*** Physical attributes ***/
3093     if (Regeneration)
3094 /*JP
3095         enl_msg("You regenerate", "", "d", "", from_what(REGENERATION));
3096 */
3097         you_have("\8dÄ\90\94\\97Í", from_what(REGENERATION));
3098     if (Slow_digestion)
3099 /*JP
3100         you_have("slower digestion", from_what(SLOW_DIGESTION));
3101 */
3102         enl_msg("\90H\95¨\82Ì\8fÁ\89»\82ª\92x", "\82¢", "\82©\82Á\82½", "", from_what(SLOW_DIGESTION));
3103     if (u.uhitinc)
3104 /*JP
3105         you_have(enlght_combatinc("to hit", u.uhitinc, final, buf), "");
3106 */
3107         you_have(enlght_combatinc("\96½\92\86\97¦", u.uhitinc, final, buf), "");
3108     if (u.udaminc)
3109 /*JP
3110         you_have(enlght_combatinc("damage", u.udaminc, final, buf), "");
3111 */
3112         you_have(enlght_combatinc("\83_\83\81\81[\83W", u.udaminc, final, buf), "");
3113     if (u.uspellprot || Protection) {
3114         int prot = 0;
3115
3116         if (uleft && uleft->otyp == RIN_PROTECTION)
3117             prot += uleft->spe;
3118         if (uright && uright->otyp == RIN_PROTECTION)
3119             prot += uright->spe;
3120         if (HProtection & INTRINSIC)
3121             prot += u.ublessed;
3122         prot += u.uspellprot;
3123         if (prot)
3124 /*JP
3125             you_have(enlght_combatinc("defense", prot, final, buf), "");
3126 */
3127             you_have(enlght_combatinc("\96h\8cä", prot, final, buf), "");
3128     }
3129     if ((armpro = magic_negation(&youmonst)) > 0) {
3130         /* magic cancellation factor, conferred by worn armor */
3131         static const char *const mc_types[] = {
3132 #if 0 /*JP*/
3133             "" /*ordinary*/, "warded", "guarded", "protected",
3134 #else
3135             "" /*ordinary*/, "\89q\82ç\82ê\82Ä", "\8cì\82ç\82ê\82Ä", "\8eç\82ç\82ê\82Ä",
3136 #endif
3137         };
3138         /* sanity check */
3139         if (armpro >= SIZE(mc_types))
3140             armpro = SIZE(mc_types) - 1;
3141 /*JP
3142         you_are(mc_types[armpro], "");
3143 */
3144         you_are_ing(mc_types[armpro], "");
3145     }
3146     if (Half_physical_damage)
3147         enlght_halfdmg(HALF_PHDAM, final);
3148     if (Half_spell_damage)
3149         enlght_halfdmg(HALF_SPDAM, final);
3150     /* polymorph and other shape change */
3151     if (Protection_from_shape_changers)
3152 #if 0 /*JP*/
3153         you_are("protected from shape changers",
3154                 from_what(PROT_FROM_SHAPE_CHANGERS));
3155 #else
3156         you_have("\95Ï\89»\89ö\95¨\82Ö\82Ì\91Ï\90«", from_what(PROT_FROM_SHAPE_CHANGERS));
3157 #endif
3158     if (Unchanging) {
3159         const char *what = 0;
3160
3161         if (!Upolyd) /* Upolyd handled below after current form */
3162 /*JP
3163             you_can("not change from your current form",
3164 */
3165             you_are("\8c»\8dÝ\82Ì\8ep\82©\82ç\95Ï\89»\82Å\82«\82È\82¢\8fó\91Ô",
3166                     from_what(UNCHANGING));
3167         /* blocked shape changes */
3168         if (Polymorph)
3169 /*JP
3170             what = !final ? "polymorph" : "have polymorphed";
3171 */
3172             what = "\95Ï\89»\82µ\82Ä";
3173         else if (u.ulycn >= LOW_PM)
3174 /*JP
3175             what = !final ? "change shape" : "have changed shape";
3176 */
3177             what = "\8ep\82ð\95Ï\82¦\82Ä";
3178         if (what) {
3179 #if 0 /*JP*/
3180             Sprintf(buf, "would %s periodically", what);
3181             /* omit from_what(UNCHANGING); too verbose */
3182             enl_msg(You_, buf, buf, " if not locked into your current form",
3183                     "");
3184 #else
3185             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);
3186             you_are_ing(buf, "");
3187 #endif
3188         }
3189     } else if (Polymorph) {
3190 /*JP
3191         you_are("polymorphing periodically", from_what(POLYMORPH));
3192 */
3193         you_are("\92è\8aú\93I\82É\95Ï\89»\82µ\82Ä", from_what(POLYMORPH));
3194     }
3195     if (Polymorph_control)
3196 /*JP
3197         you_have("polymorph control", from_what(POLYMORPH_CONTROL));
3198 */
3199         you_have("\95Ï\89»\82Ì\90§\8cä\94\\97Í", from_what(POLYMORPH_CONTROL));
3200     if (Upolyd && u.umonnum != u.ulycn) {
3201         /* foreign shape (except were-form which is handled below) */
3202 /*JP
3203         Sprintf(buf, "polymorphed into %s", an(youmonst.data->mname));
3204 */
3205         Sprintf(buf, "%s\82É\95Ï\89»\82µ\82Ä", youmonst.data->mname);
3206         if (wizard)
3207             Sprintf(eos(buf), " (%d)", u.mtimedone);
3208         you_are(buf, "");
3209     }
3210     if (lays_eggs(youmonst.data) && flags.female) /* Upolyd */
3211 /*JP
3212         you_can("lay eggs", "");
3213 */
3214         you_can("\97\91\82ð\8eY\82Þ\82±\82Æ\82ª", "");
3215     if (u.ulycn >= LOW_PM) {
3216 #if 0 /*JP*/
3217         /* "you are a werecreature [in beast form]" */
3218         Strcpy(buf, an(mons[u.ulycn].mname));
3219         if (u.umonnum == u.ulycn) {
3220             Strcat(buf, " in beast form");
3221             if (wizard)
3222                 Sprintf(eos(buf), " (%d)", u.mtimedone);
3223         }
3224 #else
3225         /*JP:\81u\82 \82È\82½\82Í[\8fb\82Ì\8ep\82Ì]\81\9b\81\9b\90l\8aÔ\82Å\82 \82é\81v*/
3226         buf[0] = '\0';
3227         if (u.umonnum == u.ulycn) {
3228             Strcpy(buf, "\8fb\82Ì\8ep\82Ì");
3229             if (wizard)
3230                 Sprintf(eos(buf), " (%d)", u.mtimedone);
3231         }
3232         Strcat(buf, mons[u.ulycn].mname);
3233 #endif
3234         you_are(buf, "");
3235     }
3236     if (Unchanging && Upolyd) /* !Upolyd handled above */
3237 /*JP
3238         you_can("not change from your current form", from_what(UNCHANGING));
3239 */
3240         enl_msg("\8d¡\82Ì\8ep\82©\82ç\95Ï\89»\82·\82é\82±\82Æ\82ª\82Å\82«\82È", "\82¢", "\82©\82Á\82½", "", from_what(UNCHANGING));
3241     if (Hate_silver)
3242 /*JP
3243         you_are("harmed by silver", "");
3244 */
3245         enl_msg("\82 \82È\82½\82Í\8bâ\82É\8eã", "\82¢", "\82©\82Á\82½", "", "");
3246     /* movement and non-armor-based protection */
3247     if (Fast)
3248 /*JP
3249         you_are(Very_fast ? "very fast" : "fast", from_what(FAST));
3250 */
3251         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));
3252     if (Reflecting)
3253 /*JP
3254         you_have("reflection", from_what(REFLECTING));
3255 */
3256         you_have("\94½\8eË\94\\97Í", from_what(REFLECTING));
3257     if (Free_action)
3258 /*JP
3259         you_have("free action", from_what(FREE_ACTION));
3260 */
3261         you_have("\8dS\91©\82³\82ê\82È\82¢\94\\97Í", from_what(FREE_ACTION));
3262     if (Fixed_abil)
3263 /*JP
3264         you_have("fixed abilities", from_what(FIXED_ABIL));
3265 */
3266         enl_msg("\94\\97Í\82ª\95Ï\89»\82µ\82È", "\82¢", "\82©\82Á\82½", "", from_what(FIXED_ABIL));
3267     if (Lifesaved)
3268 /*JP
3269         enl_msg("Your life ", "will be", "would have been", " saved", "");
3270 */
3271         enl_msg("\82 \82È\82½\82Ì\90\96½\82Í\95Û\91\82³\82ê\82Ä", iru, ita, "", "");
3272
3273     /*** Miscellany ***/
3274     if (Luck) {
3275         ltmp = abs((int) Luck);
3276 #if 0 /*JP*/
3277         Sprintf(buf, "%s%slucky",
3278                 ltmp >= 10 ? "extremely " : ltmp >= 5 ? "very " : "",
3279                 Luck < 0 ? "un" : "");
3280 #else
3281         Sprintf(buf, "%s%s",
3282                 ltmp >= 10 ? "\96Ò\97ó\82É" : ltmp >= 5 ? "\82Æ\82Ä\82à" : "",
3283                 Luck < 0 ? "\95s\8dK" : "\8dK\95\9f");
3284 #endif
3285         if (wizard)
3286             Sprintf(eos(buf), " (%d)", Luck);
3287         you_are(buf, "");
3288     } else if (wizard)
3289 /*JP
3290         enl_msg("Your luck ", "is", "was", " zero", "");
3291 */
3292         enl_msg("\82 \82È\82½\82Ì\89^\82Í\83[\83\8d", "\82Å\82 \82é", "\82¾\82Á\82½", "", "");
3293     if (u.moreluck > 0)
3294 /*JP
3295         you_have("extra luck", "");
3296 */
3297         you_have("\82³\82ç\82È\82é\8dK\89^", "");
3298     else if (u.moreluck < 0)
3299 /*JP
3300         you_have("reduced luck", "");
3301 */
3302         you_have("\82³\82ç\82È\82é\95s\89^", "");
3303     if (carrying(LUCKSTONE) || stone_luck(TRUE)) {
3304         ltmp = stone_luck(0);
3305         if (ltmp <= 0)
3306 /*JP
3307             enl_msg("Bad luck ", "does", "did", " not time out for you", "");
3308 */
3309             enl_msg("\95s\89^\82Í\8e\9e\8aÔ\90Ø\82ê\82É\82È\82ç\82È", "\82¢", "\82©\82Á\82½", "", "");
3310         if (ltmp >= 0)
3311 /*JP
3312             enl_msg("Good luck ", "does", "did", " not time out for you", "");
3313 */
3314             enl_msg("\8dK\89^\82Í\8e\9e\8aÔ\90Ø\82ê\82É\82È\82ç\82È", "\82¢", "\82©\82Á\82½", "", "");
3315     }
3316
3317     if (u.ugangr) {
3318 #if 0 /*JP*/
3319         Sprintf(buf, " %sangry with you",
3320                 u.ugangr > 6 ? "extremely " : u.ugangr > 3 ? "very " : "");
3321 #else
3322         Sprintf(buf, "%s\82Í%s\93{\82Á\82Ä%s", u_gname(),
3323                 u.ugangr > 6 ? "\96Ò\97ó\82É" : u.ugangr > 3 ? "\82Æ\82Ä\82à" : "", final ? ita : iru);
3324 #endif
3325         if (wizard)
3326             Sprintf(eos(buf), " (%d)", u.ugangr);
3327 #if 0 /*JP*/
3328         enl_msg(u_gname(), " is", " was", buf, "");
3329 #else
3330         enl_msg(buf, "", "", "", "");
3331 #endif
3332     } else {
3333         /*
3334          * We need to suppress this when the game is over, because death
3335          * can change the value calculated by can_pray(), potentially
3336          * resulting in a false claim that you could have prayed safely.
3337          */
3338         if (!final) {
3339 #if 0 /*JP*/
3340 #if 0
3341             /* "can [not] safely pray" vs "could [not] have safely prayed" */
3342             Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ",
3343                     final ? "have " : "", final ? "ed" : "");
3344 #else
3345             Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not ");
3346 #endif
3347             if (wizard)
3348                 Sprintf(eos(buf), " (%d)", u.ublesscnt);
3349             you_can(buf, "");
3350 #else /*JP*/
3351             Sprintf(buf, "\82 \82È\82½\82Í\88À\91S\82É\8bF\82é\82±\82Æ\82ª");
3352             Strcat(buf, can_pray(FALSE) ? can : "\82Å\82«\82È\82¢");
3353             if (wizard)
3354               Sprintf(eos(buf), " (%d)", u.ublesscnt);
3355             enl_msg(buf, "", "", "", "");
3356 #endif
3357         }
3358     }
3359
3360 #ifdef DEBUG
3361     /* named fruit debugging (doesn't really belong here...); to enable,
3362        include 'fruit' in DEBUGFILES list (even though it isn't a file...) */
3363     if (wizard && explicitdebug("fruit")) {
3364         struct fruit *f;
3365
3366         reorder_fruit(TRUE); /* sort by fruit index, from low to high;
3367                               * this modifies the ffruit chain, so could
3368                               * possibly mask or even introduce a problem,
3369                               * but it does useful sanity checking */
3370         for (f = ffruit; f; f = f->nextf) {
3371 /*JP
3372             Sprintf(buf, "Fruit #%d ", f->fid);
3373 */
3374             Sprintf(buf, "fruit $%d \82Í", f->fid);
3375 /*JP
3376             enl_msg(buf, "is ", "was ", f->fname, "");
3377 */
3378             enl_msg(buf, "\82¾", "\82¾\82Á\82½", f->fname, "");
3379         }
3380 /*JP
3381         enl_msg("The current fruit ", "is ", "was ", pl_fruit, "");
3382 */
3383         enl_msg("\8c»\8dÝ\82Ì fruit \82Í", "\82¾", "\82¾\82Á\82½", pl_fruit, "");
3384         Sprintf(buf, "%d", flags.made_fruit);
3385 /*JP
3386         enl_msg("The made fruit flag ", "is ", "was ", buf, "");
3387 */
3388         enl_msg("made fruit flag \82Í", "\82¾", "\82¾\82Á\82½", buf, "");
3389     }
3390 #endif
3391
3392     {
3393         const char *p;
3394
3395         buf[0] = '\0';
3396         if (final < 2) { /* still in progress, or quit/escaped/ascended */
3397 /*JP
3398             p = "survived after being killed ";
3399 */
3400             p = "\8e\80\82ñ\82¾\8cã\95\9c\8a\88\82µ\82Ä\82¢\82½";
3401             switch (u.umortality) {
3402             case 0:
3403 /*JP
3404                 p = !final ? (char *) 0 : "survived";
3405 */
3406                 p = !final ? (char *)0 : "\90\82«\89\84\82Ñ\82½";
3407                 break;
3408             case 1:
3409 /*JP
3410                 Strcpy(buf, "once");
3411 */
3412                 Strcpy(buf, "\88ê\93x");
3413                 break;
3414             case 2:
3415 /*JP
3416                 Strcpy(buf, "twice");
3417 */
3418                 Strcpy(buf, "\93ñ\93x");
3419                 break;
3420             case 3:
3421 /*JP
3422                 Strcpy(buf, "thrice");
3423 */
3424                 Strcpy(buf, "\8eO\93x");
3425                 break;
3426             default:
3427 /*JP
3428                 Sprintf(buf, "%d times", u.umortality);
3429 */
3430                 Sprintf(buf, "%d\89ñ", u.umortality);
3431                 break;
3432             }
3433         } else { /* game ended in character's death */
3434 /*JP
3435             p = "are dead";
3436 */
3437             p = "\8e\80\82ñ\82Å\82¢\82é";
3438             switch (u.umortality) {
3439             case 0:
3440                 impossible("dead without dying?");
3441             case 1:
3442                 break; /* just "are dead" */
3443             default:
3444 #if 0 /*JP*/
3445                 Sprintf(buf, " (%d%s time!)", u.umortality,
3446                         ordin(u.umortality));
3447 #else
3448                  Sprintf(buf, "(%d\89ñ\81I)", u.umortality);
3449 #endif
3450                 break;
3451             }
3452         }
3453         if (p)
3454 /*JP
3455             enl_msg(You_, "have been killed ", p, buf, "");
3456 */
3457             enl_msg(You_, "\8e\80\82ñ\82Å\82¢\82é", p, buf, "");
3458     }
3459 }
3460
3461 #if 0  /* no longer used */
3462 STATIC_DCL boolean NDECL(minimal_enlightenment);
3463
3464 /*
3465  * Courtesy function for non-debug, non-explorer mode players
3466  * to help refresh them about who/what they are.
3467  * Returns FALSE if menu cancelled (dismissed with ESC), TRUE otherwise.
3468  */
3469 STATIC_OVL boolean
3470 minimal_enlightenment()
3471 {
3472     winid tmpwin;
3473     menu_item *selected;
3474     anything any;
3475     int genidx, n;
3476     char buf[BUFSZ], buf2[BUFSZ];
3477     static const char untabbed_fmtstr[] = "%-15s: %-12s";
3478     static const char untabbed_deity_fmtstr[] = "%-17s%s";
3479     static const char tabbed_fmtstr[] = "%s:\t%-12s";
3480     static const char tabbed_deity_fmtstr[] = "%s\t%s";
3481     static const char *fmtstr;
3482     static const char *deity_fmtstr;
3483
3484     fmtstr = iflags.menu_tab_sep ? tabbed_fmtstr : untabbed_fmtstr;
3485     deity_fmtstr = iflags.menu_tab_sep ? tabbed_deity_fmtstr
3486                                        : untabbed_deity_fmtstr;
3487     any = zeroany;
3488     buf[0] = buf2[0] = '\0';
3489     tmpwin = create_nhwindow(NHW_MENU);
3490     start_menu(tmpwin);
3491     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3492 /*JP
3493              "Starting", FALSE);
3494 */
3495              "\8aJ\8en", FALSE);
3496
3497     /* Starting name, race, role, gender */
3498 /*JP
3499     Sprintf(buf, fmtstr, "name", plname);
3500 */
3501     Sprintf(buf, fmtstr, "\96¼\91O", plname);
3502     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3503 /*JP
3504     Sprintf(buf, fmtstr, "race", urace.noun);
3505 */
3506     Sprintf(buf, fmtstr, "\8eí\91°", urace.noun);
3507     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3508 /*JP
3509     Sprintf(buf, fmtstr, "role",
3510 */
3511     Sprintf(buf, fmtstr, "\90E\8bÆ",
3512             (flags.initgend && urole.name.f) ? urole.name.f : urole.name.m);
3513     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3514 /*JP
3515     Sprintf(buf, fmtstr, "gender", genders[flags.initgend].adj);
3516 */
3517     Sprintf(buf, fmtstr, "\90«\95Ê", genders[flags.initgend].adj);
3518     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3519
3520     /* Starting alignment */
3521 /*JP
3522     Sprintf(buf, fmtstr, "alignment", align_str(u.ualignbase[A_ORIGINAL]));
3523 */
3524     Sprintf(buf, fmtstr, "\91®\90«", align_str(u.ualignbase[A_ORIGINAL]));
3525     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3526
3527     /* Current name, race, role, gender */
3528     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
3529     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3530 /*JP
3531              "Current", FALSE);
3532 */
3533              "\8c»\8dÝ", FALSE);
3534 /*JP
3535     Sprintf(buf, fmtstr, "race", Upolyd ? youmonst.data->mname : urace.noun);
3536 */
3537     Sprintf(buf, fmtstr, "\8eí\91°", Upolyd ? youmonst.data->mname : urace.noun);
3538     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3539     if (Upolyd) {
3540 /*JP
3541         Sprintf(buf, fmtstr, "role (base)",
3542 */
3543         Sprintf(buf, fmtstr, "\90E\8bÆ(\8aî\96{)",
3544                 (u.mfemale && urole.name.f) ? urole.name.f
3545                                             : urole.name.m);
3546         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3547     } else {
3548 /*JP
3549         Sprintf(buf, fmtstr, "role",
3550 */
3551         Sprintf(buf, fmtstr, "\90E\8bÆ",
3552                 (flags.female && urole.name.f) ? urole.name.f
3553                                                : urole.name.m);
3554         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3555     }
3556     /* don't want poly_gender() here; it forces `2' for non-humanoids */
3557     genidx = is_neuter(youmonst.data) ? 2 : flags.female;
3558 /*JP
3559     Sprintf(buf, fmtstr, "gender", genders[genidx].adj);
3560 */
3561     Sprintf(buf, fmtstr, "\90«\95Ê", genders[genidx].adj);
3562     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3563     if (Upolyd && (int) u.mfemale != genidx) {
3564 /*JP
3565         Sprintf(buf, fmtstr, "gender (base)", genders[u.mfemale].adj);
3566 */
3567         Sprintf(buf, fmtstr, "\90«\95Ê(\8aî\96{)", genders[u.mfemale].adj);
3568         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3569     }
3570
3571     /* Current alignment */
3572 /*JP
3573     Sprintf(buf, fmtstr, "alignment", align_str(u.ualign.type));
3574 */
3575     Sprintf(buf, fmtstr, "\91®\90«", align_str(u.ualign.type));
3576     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3577
3578     /* Deity list */
3579     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
3580     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
3581 /*JP
3582              "Deities", FALSE);
3583 */
3584              "\90_", FALSE);
3585 #if 0 /*JP*/
3586     Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
3587             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3588              && u.ualign.type == A_CHAOTIC)               ? " (s,c)"
3589                 : (u.ualignbase[A_ORIGINAL] == A_CHAOTIC) ? " (s)"
3590                 : (u.ualign.type   == A_CHAOTIC)          ? " (c)" : "");
3591 #else
3592     Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
3593             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3594              && u.ualign.type == A_CHAOTIC)               ? " (\8f\89\81C\8c»)"
3595                 : (u.ualignbase[A_ORIGINAL] == A_CHAOTIC) ? " (\8f\89)"
3596                 : (u.ualign.type   == A_CHAOTIC)          ? " (\8c»)" : "");
3597 #endif
3598 /*JP
3599     Sprintf(buf, fmtstr, "Chaotic", buf2);
3600 */
3601     Sprintf(buf, fmtstr, "\8d¬\93×", buf2);
3602     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3603
3604 #if 0 /*JP*/
3605     Sprintf(buf2, deity_fmtstr, align_gname(A_NEUTRAL),
3606             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3607              && u.ualign.type == A_NEUTRAL)               ? " (s,c)"
3608                 : (u.ualignbase[A_ORIGINAL] == A_NEUTRAL) ? " (s)"
3609                 : (u.ualign.type   == A_NEUTRAL)          ? " (c)" : "");
3610 #else
3611     Sprintf(buf2, deity_fmtstr, align_gname(A_NEUTRAL),
3612             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3613              && u.ualign.type == A_NEUTRAL)               ? " (\8f\89\81C\8c»)"
3614                 : (u.ualignbase[A_ORIGINAL] == A_NEUTRAL) ? " (\8f\89)"
3615                 : (u.ualign.type   == A_NEUTRAL)          ? " (\8c»)" : "");
3616 #endif
3617 /*JP
3618     Sprintf(buf, fmtstr, "Neutral", buf2);
3619 */
3620     Sprintf(buf, fmtstr, "\92\86\97§", buf2);
3621     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3622
3623 #if 0 /*JP*/
3624     Sprintf(buf2, deity_fmtstr, align_gname(A_LAWFUL),
3625             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3626              && u.ualign.type == A_LAWFUL)                ? " (s,c)"
3627                 : (u.ualignbase[A_ORIGINAL] == A_LAWFUL)  ? " (s)"
3628                 : (u.ualign.type   == A_LAWFUL)           ? " (c)" : "");
3629 #else
3630     Sprintf(buf2, deity_fmtstr, align_gname(A_LAWFUL),
3631             (u.ualignbase[A_ORIGINAL] == u.ualign.type
3632              && u.ualign.type == A_LAWFUL)                ? " (\8f\89\81C\8c»)"
3633                 : (u.ualignbase[A_ORIGINAL] == A_LAWFUL)  ? " (\8f\89)"
3634                 : (u.ualign.type   == A_LAWFUL)           ? " (\8c»)" : "");
3635 #endif
3636 /*JP
3637     Sprintf(buf, fmtstr, "Lawful", buf2);
3638 */
3639     Sprintf(buf, fmtstr, "\92\81\8f\98", buf2);
3640     add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
3641
3642 /*JP
3643     end_menu(tmpwin, "Base Attributes");
3644 */
3645     end_menu(tmpwin, "\8aî\96{\91®\90«");
3646     n = select_menu(tmpwin, PICK_NONE, &selected);
3647     destroy_nhwindow(tmpwin);
3648     return (boolean) (n != -1);
3649 }
3650 #endif /*0*/
3651
3652 /* ^X command */
3653 STATIC_PTR int
3654 doattributes(VOID_ARGS)
3655 {
3656     int mode = BASICENLIGHTENMENT;
3657
3658     /* show more--as if final disclosure--for wizard and explore modes */
3659     if (wizard || discover)
3660         mode |= MAGICENLIGHTENMENT;
3661
3662     enlightenment(mode, ENL_GAMEINPROGRESS);
3663     return 0;
3664 }
3665
3666 void
3667 youhiding(via_enlghtmt, msgflag)
3668 boolean via_enlghtmt; /* englightment line vs topl message */
3669 int msgflag;          /* for variant message phrasing */
3670 {
3671     char *bp, buf[BUFSZ];
3672
3673 /*JP
3674     Strcpy(buf, "hiding");
3675 */
3676     Strcpy(buf, "\89B\82ê");
3677     if (youmonst.m_ap_type != M_AP_NOTHING) {
3678         /* mimic; hero is only able to mimic a strange object or gold
3679            or hallucinatory alternative to gold, so we skip the details
3680            for the hypothetical furniture and monster cases */
3681 #if 0 /*JP*//*\8cã\82ë\82É\89ñ\82·*//* not used */
3682         bp = eos(strcpy(buf, "mimicking"));
3683 #endif
3684         if (youmonst.m_ap_type == M_AP_OBJECT) {
3685 /*JP
3686             Sprintf(bp, " %s", an(simple_typename(youmonst.mappearance)));
3687 */
3688             Strcpy(buf, simple_typename(youmonst.mappearance));
3689         } else if (youmonst.m_ap_type == M_AP_FURNITURE) {
3690 /*JP
3691             Strcpy(bp, " something");
3692 */
3693             Strcpy(buf, "\89½\82©");
3694         } else if (youmonst.m_ap_type == M_AP_MONSTER) {
3695 /*JP
3696             Strcpy(bp, " someone");
3697 */
3698             Strcpy(buf, "\89½\8eÒ\82©");
3699         } else {
3700             ; /* something unexpected; leave 'buf' as-is */
3701         }
3702 #if 1 /*JP*//*\82±\82±\82Å\92Ç\89Á*/
3703         Strcat(buf, "\82Ì\82Ó\82è\82ð\82µ");
3704 #endif
3705     } else if (u.uundetected) {
3706         bp = eos(buf); /* points past "hiding" */
3707         if (youmonst.data->mlet == S_EEL) {
3708             if (is_pool(u.ux, u.uy))
3709 /*JP
3710                 Sprintf(bp, " in the %s", waterbody_name(u.ux, u.uy));
3711 */
3712                 Sprintf(bp, "%s\82Ì\92\86\82É", waterbody_name(u.ux, u.uy));
3713         } else if (hides_under(youmonst.data)) {
3714             struct obj *o = level.objects[u.ux][u.uy];
3715
3716             if (o)
3717 /*JP
3718                 Sprintf(bp, " underneath %s", ansimpleoname(o));
3719 */
3720                 Sprintf(bp, "%s\82Ì\89º\82É", ansimpleoname(o));
3721         } else if (is_clinger(youmonst.data) || Flying) {
3722             /* Flying: 'lurker above' hides on ceiling but doesn't cling */
3723 /*JP
3724             Sprintf(bp, " on the %s", ceiling(u.ux, u.uy));
3725 */
3726             Sprintf(bp, "%s\82É", ceiling(u.ux, u.uy));
3727         } else {
3728             /* on floor; is_hider() but otherwise not special: 'trapper' */
3729             if (u.utrap && u.utraptype == TT_PIT) {
3730                 struct trap *t = t_at(u.ux, u.uy);
3731
3732 #if 0 /*JP*/
3733                 Sprintf(bp, " in a %spit",
3734                         (t && t->ttyp == SPIKED_PIT) ? "spiked " : "");
3735 #else
3736                 Sprintf(bp, "%s\97\8e\82µ\8c\8a\82Ì\92\86\82É",
3737                         (t && t->ttyp == SPIKED_PIT) ? "\83g\83Q\82¾\82ç\82¯\82Ì" : "");
3738 #endif
3739             } else
3740 /*JP
3741                 Sprintf(bp, " on the %s", surface(u.ux, u.uy));
3742 */
3743                 Sprintf(bp, "%s\82É", surface(u.ux, u.uy));
3744         }
3745 #if 1 /*JP*//*\82±\82±\82Å\92Ç\89Á*/
3746         Strcat(buf, "\89B\82ê");
3747 #endif
3748     } else {
3749         ; /* shouldn't happen; will result in generic "you are hiding" */
3750     }
3751
3752     if (via_enlghtmt) {
3753         int final = msgflag; /* 'final' is used by you_are() macro */
3754
3755         you_are(buf, "");
3756     } else {
3757         /* for dohide(), when player uses '#monster' command */
3758 #if 0 /*JP*/
3759         You("are %s %s.", msgflag ? "already" : "now", buf);
3760 #else
3761         if (msgflag) {
3762             You("\82·\82Å\82É%s\82Ä\82¢\82é\81D", buf);
3763         } else {
3764             You("%s\82½\81D", buf);
3765         }
3766 #endif
3767     }
3768 }
3769
3770 /* KMH, #conduct
3771  * (shares enlightenment's tense handling)
3772  */
3773 int
3774 doconduct(VOID_ARGS)
3775 {
3776     show_conduct(0);
3777     return 0;
3778 }
3779
3780 void
3781 show_conduct(final)
3782 int final;
3783 {
3784     char buf[BUFSZ];
3785     int ngenocided;
3786
3787     /* Create the conduct window */
3788     en_win = create_nhwindow(NHW_MENU);
3789 /*JP
3790     putstr(en_win, 0, "Voluntary challenges:");
3791 */
3792     putstr(en_win, 0, "\8e©\94­\93I\92§\90í:");
3793
3794     if (u.uroleplay.blind)
3795 /*JP
3796         you_have_been("blind from birth");
3797 */
3798         you_have_been("\90\82Ü\82ê\82È\82ª\82ç\82É\96Ó\96Ú");
3799     if (u.uroleplay.nudist)
3800 /*JP
3801         you_have_been("faithfully nudist");
3802 */
3803         you_have_been("\92\89\8eÀ\82È\97\87\91°");
3804
3805     if (!u.uconduct.food)
3806 /*JP
3807         enl_msg(You_, "have gone", "went", " without food", "");
3808 */
3809         enl_msg("\82 \82È\82½\82Í\90H\8e\96\82ð\82µ", "\82Ä\82¢\82È\82¢", "\82È\82©\82Á\82½", "", "");
3810         /* but beverages are okay */
3811     else if (!u.uconduct.unvegan)
3812 /*JP
3813         you_have_X("followed a strict vegan diet");
3814 */
3815         you_have_been("\8cµ\8ai\82È\8dØ\90H\8eå\8b`\8eÒ");
3816     else if (!u.uconduct.unvegetarian)
3817 /*JP
3818         you_have_been("vegetarian");
3819 */
3820         you_have_been("\8dØ\90H\8eå\8b`\8eÒ");
3821
3822     if (!u.uconduct.gnostic)
3823 /*JP
3824         you_have_been("an atheist");
3825 */
3826         you_have_been("\96³\90_\98_\8eÒ");
3827
3828     if (!u.uconduct.weaphit) {
3829 /*JP
3830         you_have_never("hit with a wielded weapon");
3831 */
3832         you_have_never("\82 \82È\82½\82Í\91\95\94õ\82µ\82Ä\82¢\82é\95\90\8aí\82Å\8dU\8c\82\82µ");
3833     } else if (wizard) {
3834 #if 0 /*JP*/
3835         Sprintf(buf, "used a wielded weapon %ld time%s", u.uconduct.weaphit,
3836                 plur(u.uconduct.weaphit));
3837         you_have_X(buf);
3838 #else
3839         Sprintf(buf, "\82 \82È\82½\82Í%ld\89ñ\91\95\94õ\82µ\82½\95\90\8aí\82ð\8eg\97p\82µ", u.uconduct.weaphit);
3840         you_have_X(buf);
3841 #endif
3842     }
3843     if (!u.uconduct.killer)
3844 /*JP
3845         you_have_been("a pacifist");
3846 */
3847         you_have_been("\95½\98a\8eå\8b`\8eÒ");
3848
3849     if (!u.uconduct.literate) {
3850 /*JP
3851         you_have_been("illiterate");
3852 */
3853         you_have_never("\82 \82È\82½\82Í\93Ç\82Ý\8f\91\82«\82µ");
3854     } else if (wizard) {
3855 #if 0 /*JP:T*/
3856         Sprintf(buf, "read items or engraved %ld time%s", u.uconduct.literate,
3857                 plur(u.uconduct.literate));
3858         you_have_X(buf);
3859 #else
3860         Sprintf(buf, "%ld\89ñ\93Ç\82ñ\82¾\82è\8f\91\82¢\82½\82è\82µ", u.uconduct.literate);
3861         you_have_X(buf);
3862 #endif
3863     }
3864
3865     ngenocided = num_genocides();
3866     if (ngenocided == 0) {
3867 /*JP
3868         you_have_never("genocided any monsters");
3869 */
3870         you_have_never("\82 \82È\82½\82Í\89ö\95¨\82ð\8bs\8eE\82µ");
3871     } else {
3872 #if 0 /*JP:T*/
3873         Sprintf(buf, "genocided %d type%s of monster%s", ngenocided,
3874                 plur(ngenocided), plur(ngenocided));
3875         you_have_X(buf);
3876 #else
3877         Sprintf(buf, "%d\8eí\82Ì\89ö\95¨\82ð\8bs\8eE\82µ", ngenocided);
3878         you_have_X(buf);
3879 #endif
3880     }
3881
3882     if (!u.uconduct.polypiles) {
3883 /*JP
3884         you_have_never("polymorphed an object");
3885 */
3886         you_have_never("\82 \82È\82½\82Í\95¨\91Ì\82ð\95Ï\89»\82³\82¹");
3887     } else if (wizard) {
3888 #if 0 /*JP:T*/
3889         Sprintf(buf, "polymorphed %ld item%s", u.uconduct.polypiles,
3890                 plur(u.uconduct.polypiles));
3891         you_have_X(buf);
3892 #else
3893         Sprintf(buf, "%ld\8cÂ\82Ì\95¨\82ð\95Ï\89»\82³\82¹", u.uconduct.polypiles);
3894         you_have_X(buf);
3895 #endif
3896     }
3897
3898     if (!u.uconduct.polyselfs) {
3899 /*JP
3900         you_have_never("changed form");
3901 */
3902         you_have_never("\82 \82È\82½\82Í\95Ï\89»\82µ");
3903     } else if (wizard) {
3904 #if 0 /*JP:T*/
3905         Sprintf(buf, "changed form %ld time%s", u.uconduct.polyselfs,
3906                 plur(u.uconduct.polyselfs));
3907         you_have_X(buf);
3908 #else
3909         Sprintf(buf, "%ld\89ñ\8ep\82ð\95Ï\82¦", u.uconduct.polyselfs);
3910         you_have_X(buf);
3911 #endif
3912     }
3913
3914     if (!u.uconduct.wishes) {
3915 /*JP
3916         you_have_X("used no wishes");
3917 */
3918         you_have_never("\82 \82È\82½\82Í\8aè\82¢\8e\96\82ð\82µ");
3919     } else {
3920 #if 0 /*JP*/
3921         Sprintf(buf, "used %ld wish%s", u.uconduct.wishes,
3922                 (u.uconduct.wishes > 1L) ? "es" : "");
3923 #else
3924         Sprintf(buf, "%ld\89ñ\8aè\82¢\8e\96\82ð\82µ", u.uconduct.wishes);
3925 #endif
3926         if (u.uconduct.wisharti) {
3927             /* if wisharti == wishes
3928              *  1 wish (for an artifact)
3929              *  2 wishes (both for artifacts)
3930              *  N wishes (all for artifacts)
3931              * else (N is at least 2 in order to get here; M < N)
3932              *  N wishes (1 for an artifact)
3933              *  N wishes (M for artifacts)
3934              */
3935             if (u.uconduct.wisharti == u.uconduct.wishes)
3936                 Sprintf(eos(buf), " (%s",
3937                         (u.uconduct.wisharti > 2L) ? "all "
3938                           : (u.uconduct.wisharti == 2L) ? "both " : "");
3939             else
3940                 Sprintf(eos(buf), " (%ld ", u.uconduct.wisharti);
3941
3942             Sprintf(eos(buf), "for %s)",
3943                     (u.uconduct.wisharti == 1L) ? "an artifact"
3944                                                 : "artifacts");
3945         }
3946         you_have_X(buf);
3947
3948         if (!u.uconduct.wisharti)
3949 #if 0 /*JP*/
3950             enl_msg(You_, "have not wished", "did not wish",
3951                     " for any artifacts", "");
3952 #else
3953             enl_msg("\82 \82È\82½\82Í\90¹\8aí\82ð\8aè", "\82Á\82Ä\82¢\82È\82¢", "\82í\82È\82©\82Á\82½", "", "");
3954 #endif
3955     }
3956
3957     /* Pop up the window and wait for a key */
3958     display_nhwindow(en_win, TRUE);
3959     destroy_nhwindow(en_win);
3960     en_win = WIN_ERR;
3961 }
3962
3963 /* Macros for meta and ctrl modifiers:
3964  *   M and C return the meta/ctrl code for the given character;
3965  *     e.g., (C('c') is ctrl-c
3966  */
3967 #ifndef M
3968 #ifndef NHSTDC
3969 #define M(c) (0x80 | (c))
3970 #else
3971 #define M(c) ((c) - 128)
3972 #endif /* NHSTDC */
3973 #endif
3974
3975 #ifndef C
3976 #define C(c) (0x1f & (c))
3977 #endif
3978
3979 /* ordered by command name */
3980 struct ext_func_tab extcmdlist[] = {
3981     { '#', "#", "perform an extended command",
3982             doextcmd, IFBURIED | GENERALCMD },
3983 #if 0 /*JP*/
3984     { M('?'), "?", "list all extended commands",
3985 #else
3986     { M('?'), "?", "\82±\82Ì\8ag\92£\83R\83}\83\93\83h\88ê\97\97\82ð\95\\8e¦\82·\82é",
3987 #endif
3988             doextlist, IFBURIED | AUTOCOMPLETE | GENERALCMD },
3989 #if 0 /*JP*/
3990     { M('a'), "adjust", "adjust inventory letters",
3991 #else
3992     { M('a'), "adjust", "\8e\9d\82¿\95¨\88ê\97\97\82Ì\92²\90®",
3993 #endif
3994             doorganize, IFBURIED | AUTOCOMPLETE },
3995 #if 0 /*JP*/
3996     { M('A'), "annotate", "name current level",
3997 #else
3998     { M('A'), "annotate", "\8c»\8dÝ\82Ì\8aK\82É\96¼\91O\82ð\82Â\82¯\82é",
3999 #endif
4000             donamelevel, IFBURIED | AUTOCOMPLETE },
4001     { 'a', "apply", "apply (use) a tool (pick-axe, key, lamp...)",
4002             doapply },
4003     { C('x'), "attributes", "show your attributes",
4004             doattributes, IFBURIED },
4005     { '@', "autopickup", "toggle the pickup option on/off",
4006             dotogglepickup, IFBURIED },
4007     { 'C', "call", "call (name) something", docallcmd, IFBURIED },
4008     { 'Z', "cast", "zap (cast) a spell", docast, IFBURIED },
4009 #if 0 /*JP*/
4010     { M('c'), "chat", "talk to someone", dotalk, IFBURIED | AUTOCOMPLETE },
4011 #else
4012     { M('c'), "chat", "\92N\82©\82Æ\98b\82·", dotalk, IFBURIED | AUTOCOMPLETE },
4013 #endif
4014     { 'c', "close", "close a door", doclose },
4015 #if 0 /*JP*/
4016     { M('C'), "conduct", "list voluntary challenges you have maintained",
4017 #else
4018     { M('C'), "conduct", "\82Ç\82¤\82¢\82¤\8ds\93®\82ð\82Æ\82Á\82½\82©\8c©\82é",
4019 #endif
4020             doconduct, IFBURIED | AUTOCOMPLETE },
4021 #if 0 /*JP*/
4022     { M('d'), "dip", "dip an object into something", dodip, AUTOCOMPLETE },
4023 #else
4024     { M('d'), "dip", "\89½\82©\82É\95¨\82ð\90Z\82·", dodip, AUTOCOMPLETE },
4025 #endif
4026     { '>', "down", "go down a staircase", dodown },
4027     { 'd', "drop", "drop an item", dodrop },
4028     { 'D', "droptype", "drop specific item types", doddrop },
4029     { 'e', "eat", "eat something", doeat },
4030     { 'E', "engrave", "engrave writing on the floor", doengrave },
4031 #if 0 /*JP*/
4032     { M('e'), "enhance", "advance or check weapon and spell skills",
4033 #else
4034     { M('e'), "enhance", "\95\90\8aí\8fn\97û\93x\82ð\8d\82\82ß\82é",
4035 #endif
4036             enhance_weapon_skill, IFBURIED | AUTOCOMPLETE },
4037 #if 0 /*JP*/
4038     { '\0', "exploremode", "enter explore (discovery) mode",
4039 #else
4040     { '\0', "exploremode", "\92T\8c\9f(\94­\8c©)\83\82\81[\83h\82É\93ü\82é",
4041 #endif
4042             enter_explore_mode, IFBURIED },
4043     { 'f', "fire", "fire ammunition from quiver", dofire },
4044 #if 0 /*JP*/
4045     { M('f'), "force", "force a lock", doforce, AUTOCOMPLETE },
4046 #else
4047     { M('f'), "force", "\8c®\82ð\82±\82\82 \82¯\82é", doforce, AUTOCOMPLETE },
4048 #endif
4049     { ';', "glance", "show what type of thing a map symbol corresponds to",
4050             doquickwhatis, IFBURIED | GENERALCMD },
4051     { '?', "help", "give a help message", dohelp, IFBURIED | GENERALCMD },
4052     { '\0', "herecmdmenu", "show menu of commands you can do here",
4053             doherecmdmenu, IFBURIED },
4054     { 'V', "history", "show long version and game history",
4055             dohistory, IFBURIED | GENERALCMD },
4056     { 'i', "inventory", "show your inventory", ddoinv, IFBURIED },
4057     { 'I', "inventtype", "inventory specific item types",
4058             dotypeinv, IFBURIED },
4059 #if 0 /*JP*/
4060     { M('i'), "invoke", "invoke an object's special powers",
4061 #else
4062     { M('i'), "invoke", "\95¨\82Ì\93Á\95Ê\82È\97Í\82ð\8eg\82¤",
4063 #endif
4064             doinvoke, IFBURIED | AUTOCOMPLETE },
4065 #if 0 /*JP*/
4066     { M('j'), "jump", "jump to another location", dojump, AUTOCOMPLETE },
4067 #else
4068     { M('j'), "jump", "\91¼\82Ì\88Ê\92u\82É\94ò\82Ñ\82¤\82Â\82é", dojump, AUTOCOMPLETE },
4069 #endif
4070     { C('d'), "kick", "kick something", dokick },
4071     { '\\', "known", "show what object types have been discovered",
4072             dodiscovered, IFBURIED | GENERALCMD },
4073     { '`', "knownclass", "show discovered types for one class of objects",
4074             doclassdisco, IFBURIED | GENERALCMD },
4075 #if 0 /*JP*/
4076     { '\0', "levelchange", "change experience level",
4077 #else
4078     { '\0', "levelchange", "\8co\8c±\83\8c\83x\83\8b\82ð\95Ï\82¦\82é",
4079 #endif
4080             wiz_level_change, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4081 #if 0 /*JP*/
4082     { '\0', "lightsources", "show mobile light sources",
4083 #else
4084     { '\0', "lightsources", "\88Ú\93®\8cõ\8c¹\82ð\8c©\82é",
4085 #endif
4086             wiz_light_sources, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4087     { ':', "look", "look at what is here", dolook, IFBURIED },
4088 #if 0 /*JP*/
4089     { M('l'), "loot", "loot a box on the floor", doloot, AUTOCOMPLETE },
4090 #else
4091     { M('l'), "loot", "\8f°\82Ì\8fã\82Ì\94 \82ð\8aJ\82¯\82é", doloot, AUTOCOMPLETE },
4092 #endif
4093 #ifdef DEBUG_MIGRATING_MONS
4094 #if 0 /*JP*/
4095     { '\0', "migratemons", "migrate N random monsters",
4096 #else
4097     { '\0', "migratemons", "\83\89\83\93\83_\83\80\82È\89ö\95¨\82ð\89½\91Ì\82©\88Ú\8fZ\82³\82¹\82é",
4098 #endif
4099             wiz_migrate_mons, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4100 #endif
4101 #if 0 /*JP*/
4102     { '\0', "monpolycontrol", "control monster polymorphs",
4103 #else
4104     { '\0', "monpolycontrol", "\89ö\95¨\82Ö\82Ì\95Ï\89»\82ð\90§\8cä\82·\82é",
4105 #endif
4106             wiz_mon_polycontrol, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4107 #if 0 /*JP*/
4108     { M('m'), "monster", "use monster's special ability",
4109 #else
4110     { M('m'), "monster", "\89ö\95¨\82Ì\93Á\95Ê\94\\97Í\82ð\8eg\82¤",
4111 #endif
4112             domonability, IFBURIED | AUTOCOMPLETE },
4113 #if 0 /*JP*/
4114     { 'N', "name", "name a monster or an object",
4115 #else
4116     { 'N', "name", "\83A\83C\83e\83\80\82â\95¨\82É\96¼\91O\82ð\82Â\82¯\82é",
4117 #endif
4118             docallcmd, IFBURIED | AUTOCOMPLETE },
4119 #if 0 /*JP*/
4120     { M('o'), "offer", "offer a sacrifice to the gods",
4121 #else
4122     { M('o'), "offer", "\90_\82É\8b\9f\95¨\82ð\95ù\82°\82é",
4123 #endif
4124             dosacrifice, AUTOCOMPLETE },
4125     { 'o', "open", "open a door", doopen },
4126     { 'O', "options", "show option settings, possibly change them",
4127             doset, IFBURIED | GENERALCMD },
4128 #if 0 /*JP*/
4129     { C('o'), "overview", "show a summary of the explored dungeon",
4130 #else
4131     { C('o'), "overview", "\92T\8dõ\82µ\82½\96À\8b{\82Ì\8aT\97v\82ð\95\\8e¦\82·\82é",
4132 #endif
4133             dooverview, IFBURIED | AUTOCOMPLETE },
4134 #if 0 /*JP*/
4135     { '\0', "panic", "test panic routine (fatal to game)",
4136 #else
4137     { '\0', "panic", "\83p\83j\83b\83N\83\8b\81[\83`\83\93\82ð\83e\83X\83g\82·\82é(\92v\96½\93I)",
4138 #endif
4139             wiz_panic, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4140     { 'p', "pay", "pay your shopping bill", dopay },
4141     { ',', "pickup", "pick up things at the current location", dopickup },
4142 #if 0 /*JP*/
4143     { '\0', "polyself", "polymorph self",
4144 #else
4145     { '\0', "polyself", "\95Ï\89»\82·\82é",
4146 #endif
4147             wiz_polyself, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4148 #ifdef PORT_DEBUG
4149 #if 0 /*JP*/
4150     { '\0', "portdebug", "wizard port debug command",
4151 #else
4152     { '\0', "portdebug", "\83E\83B\83U\81[\83h\83|\81[\83g\83f\83o\83b\83O\83R\83}\83\93\83h",
4153 #endif
4154             wiz_port_debug, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4155 #endif
4156 #if 0 /*JP*/
4157     { M('p'), "pray", "pray to the gods for help",
4158 #else
4159     { M('p'), "pray", "\90_\82É\8bF\82é",
4160 #endif
4161             dopray, IFBURIED | AUTOCOMPLETE },
4162     { C('p'), "prevmsg", "view recent game messages",
4163             doprev_message, IFBURIED | GENERALCMD },
4164     { 'P', "puton", "put on an accessory (ring, amulet, etc)", doputon },
4165     { 'q', "quaff", "quaff (drink) something", dodrink },
4166 #if 0 /*JP*/
4167     { M('q'), "quit", "exit without saving current game",
4168 #else
4169     { M('q'), "quit", "\83Z\81[\83u\82µ\82È\82¢\82Å\8fI\97¹",
4170 #endif
4171             done2, IFBURIED | AUTOCOMPLETE | GENERALCMD },
4172     { 'Q', "quiver", "select ammunition for quiver", dowieldquiver },
4173     { 'r', "read", "read a scroll or spellbook", doread },
4174     { C('r'), "redraw", "redraw screen", doredraw, IFBURIED | GENERALCMD },
4175     { 'R', "remove", "remove an accessory (ring, amulet, etc)", doremring },
4176 #if 0 /*JP*/
4177     { M('R'), "ride", "mount or dismount a saddled steed",
4178 #else
4179     { M('R'), "ride", "\89ö\95¨\82É\8fæ\82é(\82Ü\82½\82Í\8d~\82è\82é)",
4180 #endif
4181             doride, AUTOCOMPLETE },
4182 #if 0 /*JP*/
4183     { M('r'), "rub", "rub a lamp or a stone", dorub, AUTOCOMPLETE },
4184 #else
4185     { M('r'), "rub", "\83\89\83\93\83v\82ð\82±\82·\82é", dorub, AUTOCOMPLETE },
4186 #endif
4187     { 'S', "save", "save the game and exit", dosave, IFBURIED | GENERALCMD },
4188 #if 0 /*JP*/
4189     { 's', "search", "search for traps and secret doors",
4190             dosearch, IFBURIED, "searching" },
4191 #else
4192     { 's', "search", "ã©\82â\89B\82µ\94à\82ð\92T\82·",
4193             dosearch, IFBURIED, "\92T\82·" },
4194 #endif
4195     { '*', "seeall", "show all equipment in use", doprinuse, IFBURIED },
4196     { AMULET_SYM, "seeamulet", "show the amulet currently worn",
4197             dopramulet, IFBURIED },
4198     { ARMOR_SYM, "seearmor", "show the armor currently worn",
4199             doprarm, IFBURIED },
4200     { GOLD_SYM, "seegold", "count your gold", doprgold, IFBURIED },
4201 #if 0 /*JP*/
4202     { '\0', "seenv", "show seen vectors",
4203 #else
4204     { '\0', "seenv", "\8e\8b\90ü\83x\83N\83g\83\8b\82ð\8c©\82é",
4205 #endif
4206             wiz_show_seenv, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4207     { RING_SYM, "seerings", "show the ring(s) currently worn",
4208             doprring, IFBURIED },
4209     { SPBOOK_SYM, "seespells", "list and reorder known spells",
4210             dovspell, IFBURIED },
4211     { TOOL_SYM, "seetools", "show the tools currently in use",
4212             doprtool, IFBURIED },
4213     { '^', "seetrap", "show the type of adjacent trap", doidtrap, IFBURIED },
4214     { WEAPON_SYM, "seeweapon", "show the weapon currently wielded",
4215             doprwep, IFBURIED },
4216 #ifdef SHELL
4217     { '!', "shell", "do a shell escape", dosh, IFBURIED | GENERALCMD },
4218 #endif /* SHELL */
4219 #if 0 /*JP*/
4220     { M('s'), "sit", "sit down", dosit, AUTOCOMPLETE },
4221     { '\0', "stats", "show memory statistics",
4222 #else
4223     { M('s'), "sit", "\8dÀ\82é", dosit, AUTOCOMPLETE },
4224     { '\0', "stats", "\83\81\83\82\83\8a\8fó\91Ô\82ð\8c©\82é",
4225 #endif
4226             wiz_show_stats, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4227 #ifdef SUSPEND
4228     { C('z'), "suspend", "suspend the game",
4229             dosuspend_core, IFBURIED | GENERALCMD },
4230 #endif /* SUSPEND */
4231     { 'x', "swap", "swap wielded and secondary weapons", doswapweapon },
4232     { 'T', "takeoff", "take off one piece of armor", dotakeoff },
4233     { 'A', "takeoffall", "remove all armor", doddoremarm },
4234     { C('t'), "teleport", "teleport around the level", dotele, IFBURIED },
4235 #if 0 /*JP*/
4236     { '\0', "terrain", "show map without obstructions",
4237 #else
4238     { '\0', "terrain", "\8e×\96\82\82³\82ê\82¸\82É\92n\90}\82ð\8c©\82é",
4239 #endif
4240             doterrain, IFBURIED | AUTOCOMPLETE },
4241     { '\0', "therecmdmenu",
4242             "menu of commands you can do from here to adjacent spot",
4243             dotherecmdmenu },
4244     { 't', "throw", "throw something", dothrow },
4245 #if 0 /*JP*/
4246     { '\0', "timeout", "look at timeout queue and hero's timed intrinsics",
4247 #else
4248     { '\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é",
4249 #endif
4250             wiz_timeout_queue, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4251 #if 0 /*JP*/
4252     { M('T'), "tip", "empty a container", dotip, AUTOCOMPLETE },
4253 #else
4254     { M('T'), "tip", "\93ü\82ê\95¨\82ð\8bó\82É\82·\82é", dotip, AUTOCOMPLETE },
4255 #endif
4256     { '_', "travel", "travel to a specific location on the map", dotravel },
4257 #if 0 /*JP*/
4258     { M('t'), "turn", "turn undead away", doturn, IFBURIED | AUTOCOMPLETE },
4259 #else
4260     { M('t'), "turn", "\83A\83\93\83f\83b\83g\82ð\93y\82É\95Ô\82·", doturn, IFBURIED | AUTOCOMPLETE },
4261 #endif
4262 #if 0 /*JP*/
4263     { 'X', "twoweapon", "toggle two-weapon combat",
4264 #else
4265     { 'X', "twoweapon", "\97¼\8eè\8e\9d\82¿\82Ì\90Ø\82è\91Ö\82¦",
4266 #endif
4267             dotwoweapon, AUTOCOMPLETE },
4268 #if 0 /*JP*/
4269     { M('u'), "untrap", "untrap something", dountrap, AUTOCOMPLETE },
4270 #else
4271     { M('u'), "untrap", "ã©\82ð\82Í\82¸\82·", dountrap, AUTOCOMPLETE },
4272 #endif
4273     { '<', "up", "go up a staircase", doup },
4274 #if 0 /*JP*/
4275     { '\0', "vanquished", "list vanquished monsters",
4276 #else
4277     { '\0', "vanquished", "\93|\82µ\82½\89ö\95¨\82Ì\88ê\97\97\82ð\8c©\82é",
4278 #endif
4279             dovanquished, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4280     { M('v'), "version",
4281 #if 0 /*JP*/
4282             "list compile time options for this version of NetHack",
4283 #else
4284             "\83R\83\93\83p\83C\83\8b\8e\9e\82Ì\83I\83v\83V\83\87\83\93\82ð\95\\8e¦\82·\82é",
4285 #endif
4286             doextversion, IFBURIED | AUTOCOMPLETE | GENERALCMD },
4287     { 'v', "versionshort", "show version", doversion, IFBURIED | GENERALCMD },
4288 #if 0 /*JP*/
4289     { '\0', "vision", "show vision array",
4290 #else
4291     { '\0', "vision", "\8e\8b\8aE\94z\97ñ\82ð\8c©\82é",
4292 #endif
4293             wiz_show_vision, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4294 #if 0 /*JP*/
4295     { '.', "wait", "rest one move while doing nothing",
4296             donull, IFBURIED, "waiting" },
4297 #else
4298     { '.', "wait", "\88ê\95à\95ª\89½\82à\82µ\82È\82¢",
4299             donull, IFBURIED, "\8bx\8ce\82·\82é" },
4300 #endif
4301     { 'W', "wear", "wear a piece of armor", dowear },
4302     { '&', "whatdoes", "tell what a command does", dowhatdoes, IFBURIED },
4303     { '/', "whatis", "show what type of thing a symbol corresponds to",
4304             dowhatis, IFBURIED | GENERALCMD },
4305     { 'w', "wield", "wield (put in use) a weapon", dowield },
4306 #if 0 /*JP*/
4307     { M('w'), "wipe", "wipe off your face", dowipe, AUTOCOMPLETE },
4308 #else
4309     { M('w'), "wipe", "\8aç\82ð\90@\82¤", dowipe, AUTOCOMPLETE },
4310 #endif
4311 #ifdef DEBUG
4312 #if 0 /*JP*/
4313     { '\0', "wizdebug_bury", "wizard debug: bury objs under and around you",
4314 #else
4315     { '\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é",
4316 #endif
4317             wiz_debug_cmd_bury, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4318 #if 0 /*JP*/
4319     { '\0', "wizdebug_traveldisplay", "wizard debug: toggle travel display",
4320 #else
4321     { '\0', "wizdebug_traveldisplay", "\83E\83B\83U\81[\83h\83f\83o\83b\83O: \88Ú\93®\95\\8e¦\82ð\90Ø\82è\91Ö\82¦\82é",
4322 #endif
4323           wiz_debug_cmd_traveldisplay, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4324 #endif
4325     { C('e'), "wizdetect", "reveal hidden things within a small radius",
4326             wiz_detect, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4327     { C('g'), "wizgenesis", "create a monster",
4328             wiz_genesis, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4329     { C('i'), "wizidentify", "identify all items in inventory",
4330             wiz_identify, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4331     { '\0', "wizintrinsic", "set an intrinsic",
4332             wiz_intrinsic, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4333     { C('v'), "wizlevelport", "teleport to another level",
4334             wiz_level_tele, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4335     { '\0', "wizmakemap", "recreate the current level",
4336             wiz_makemap, IFBURIED | WIZMODECMD },
4337     { C('f'), "wizmap", "map the level",
4338             wiz_map, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4339 #if 0 /*JP*/
4340     { '\0', "wizrumorcheck", "verify rumor boundaries",
4341 #else
4342     { '\0', "wizrumorcheck", "\89\\82Ì\8b«\8aE\82ð\8c\9f\8fØ\82·\82é",
4343 #endif
4344             wiz_rumor_check, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4345 #if 0 /*JP*/
4346     { '\0', "wizsmell", "smell monster",
4347 #else
4348     { '\0', "wizsmell", "\89ö\95¨\82Ì\93õ\82¢\82ð\9ak\82®",
4349 #endif
4350             wiz_smell, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4351     { '\0', "wizwhere", "show locations of special levels",
4352             wiz_where, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4353     { C('w'), "wizwish", "wish for something",
4354             wiz_wish, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4355 #if 0 /*JP*/
4356     { '\0', "wmode", "show wall modes",
4357 #else
4358     { '\0', "wmode", "\95Ç\83\82\81[\83h\82ð\8c©\82é",
4359 #endif
4360             wiz_show_wmodes, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
4361     { 'z', "zap", "zap a wand", dozap },
4362     { '\0', (char *) 0, (char *) 0, donull, 0, (char *) 0 } /* sentinel */
4363 };
4364
4365 const char *
4366 key2extcmddesc(key)
4367 uchar key;
4368 {
4369     if (Cmd.commands[key] && Cmd.commands[key]->ef_txt)
4370         return Cmd.commands[key]->ef_desc;
4371     return (char *) 0;
4372 }
4373
4374 boolean
4375 bind_key(key, command)
4376 uchar key;
4377 const char *command;
4378 {
4379     struct ext_func_tab *extcmd;
4380
4381     /* special case: "nothing" is reserved for unbinding */
4382     if (!strcmp(command, "nothing")) {
4383         Cmd.commands[key] = (struct ext_func_tab *) 0;
4384         return TRUE;
4385     }
4386
4387     for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++) {
4388         if (strcmp(command, extcmd->ef_txt))
4389             continue;
4390         Cmd.commands[key] = extcmd;
4391         return TRUE;
4392     }
4393
4394     return FALSE;
4395 }
4396
4397 /* initialize all keyboard commands */
4398 void
4399 commands_init()
4400 {
4401     struct ext_func_tab *extcmd;
4402
4403     for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++)
4404         if (extcmd->key)
4405             Cmd.commands[extcmd->key] = extcmd;
4406
4407     (void) bind_key(C('l'), "redraw"); /* if number_pad is set */
4408     /*       'b', 'B' : go sw */
4409     /*       'F' : fight (one time) */
4410     /*       'g', 'G' : multiple go */
4411     /*       'h', 'H' : go west */
4412     (void) bind_key('h',    "help"); /* if number_pad is set */
4413     (void) bind_key('j',    "jump"); /* if number_pad is on */
4414     /*       'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' move commands */
4415     (void) bind_key('k',    "kick"); /* if number_pad is on */
4416     (void) bind_key('l',    "loot"); /* if number_pad is on */
4417     (void) bind_key(C('n'), "annotate"); /* if number_pad is on */
4418     (void) bind_key(M('n'), "name");
4419     (void) bind_key(M('N'), "name");
4420     (void) bind_key('u',    "untrap"); /* if number_pad is on */
4421
4422     /* alt keys: */
4423     (void) bind_key(M('O'), "overview");
4424     (void) bind_key(M('2'), "twoweapon");
4425
4426     /* wait_on_space */
4427     (void) bind_key(' ',    "wait");
4428 }
4429
4430 int
4431 dokeylist_putcmds(datawin, docount, cmdflags, exflags, keys_used)
4432 winid datawin;
4433 boolean docount;
4434 int cmdflags, exflags;
4435 boolean *keys_used; /* boolean keys_used[256] */
4436 {
4437     int i;
4438     char buf[BUFSZ];
4439     char buf2[QBUFSZ];
4440     int count = 0;
4441
4442     for (i = 0; i < 256; i++) {
4443         const struct ext_func_tab *extcmd;
4444         uchar key = (uchar) i;
4445
4446         if (keys_used[i])
4447             continue;
4448         if (key == ' ' && !flags.rest_on_space)
4449             continue;
4450         if ((extcmd = Cmd.commands[i]) != (struct ext_func_tab *) 0) {
4451             if ((cmdflags && !(extcmd->flags & cmdflags))
4452                 || (exflags && (extcmd->flags & exflags)))
4453                 continue;
4454             if (docount) {
4455                 count++;
4456                 continue;
4457             }
4458             Sprintf(buf, "%-8s %-12s %s", key2txt(key, buf2),
4459                     extcmd->ef_txt,
4460                     extcmd->ef_desc);
4461             putstr(datawin, 0, buf);
4462             keys_used[i] = TRUE;
4463         }
4464     }
4465     return count;
4466 }
4467
4468 /* list all keys and their bindings, like dat/hh but dynamic */
4469 void
4470 dokeylist(VOID_ARGS)
4471 {
4472     char buf[BUFSZ], buf2[BUFSZ];
4473     uchar key;
4474     boolean keys_used[256] = {0};
4475     winid datawin;
4476     int i;
4477     static const char
4478         run_desc[] = "Prefix: run until something very interesting is seen",
4479         forcefight_desc[] =
4480                      "Prefix: force fight even if you don't see a monster";
4481     static const struct {
4482         int nhkf;
4483         const char *desc;
4484         boolean numpad;
4485     } misc_keys[] = {
4486         { NHKF_ESC, "escape from the current query/action", FALSE },
4487         { NHKF_RUSH,
4488           "Prefix: rush until something interesting is seen", FALSE },
4489         { NHKF_RUN, run_desc, FALSE },
4490         { NHKF_RUN2, run_desc, TRUE },
4491         { NHKF_FIGHT, forcefight_desc, FALSE },
4492         { NHKF_FIGHT2, forcefight_desc, TRUE } ,
4493         { NHKF_NOPICKUP,
4494           "Prefix: move without picking up objects/fighting", FALSE },
4495         { NHKF_RUN_NOPICKUP,
4496           "Prefix: run without picking up objects/fighting", FALSE },
4497         { NHKF_DOINV, "view inventory", TRUE },
4498         { NHKF_REQMENU, "Prefix: request a menu", FALSE },
4499 #ifdef REDO
4500         { NHKF_DOAGAIN , "re-do: perform the previous command again", FALSE },
4501 #endif
4502         { 0, (const char *) 0, FALSE }
4503     };
4504
4505     datawin = create_nhwindow(NHW_TEXT);
4506     putstr(datawin, 0, "");
4507     putstr(datawin, 0, "            Full Current Key Bindings List");
4508
4509     /* directional keys */
4510     putstr(datawin, 0, "");
4511     putstr(datawin, 0, "Directional keys:");
4512     show_direction_keys(datawin, '.', FALSE); /* '.'==self in direction grid */
4513
4514     keys_used[(uchar) Cmd.move_NW] = keys_used[(uchar) Cmd.move_N]
4515         = keys_used[(uchar) Cmd.move_NE] = keys_used[(uchar) Cmd.move_W]
4516         = keys_used[(uchar) Cmd.move_E] = keys_used[(uchar) Cmd.move_SW]
4517         = keys_used[(uchar) Cmd.move_S] = keys_used[(uchar) Cmd.move_SE]
4518         = TRUE;
4519
4520     if (!iflags.num_pad) {
4521         keys_used[(uchar) highc(Cmd.move_NW)]
4522             = keys_used[(uchar) highc(Cmd.move_N)]
4523             = keys_used[(uchar) highc(Cmd.move_NE)]
4524             = keys_used[(uchar) highc(Cmd.move_W)]
4525             = keys_used[(uchar) highc(Cmd.move_E)]
4526             = keys_used[(uchar) highc(Cmd.move_SW)]
4527             = keys_used[(uchar) highc(Cmd.move_S)]
4528             = keys_used[(uchar) highc(Cmd.move_SE)] = TRUE;
4529         keys_used[(uchar) C(Cmd.move_NW)]
4530             = keys_used[(uchar) C(Cmd.move_N)]
4531             = keys_used[(uchar) C(Cmd.move_NE)]
4532             = keys_used[(uchar) C(Cmd.move_W)]
4533             = keys_used[(uchar) C(Cmd.move_E)]
4534             = keys_used[(uchar) C(Cmd.move_SW)]
4535             = keys_used[(uchar) C(Cmd.move_S)]
4536             = keys_used[(uchar) C(Cmd.move_SE)] = TRUE;
4537         putstr(datawin, 0, "");
4538         putstr(datawin, 0,
4539           "Shift-<direction> will move in specified direction until you hit");
4540         putstr(datawin, 0, "        a wall or run into something.");
4541         putstr(datawin, 0,
4542           "Ctrl-<direction> will run in specified direction until something");
4543         putstr(datawin, 0, "        very interesting is seen.");
4544     }
4545
4546     putstr(datawin, 0, "");
4547     putstr(datawin, 0, "Miscellaneous keys:");
4548     for (i = 0; misc_keys[i].desc; i++) {
4549         key = Cmd.spkeys[misc_keys[i].nhkf];
4550         if (key && ((misc_keys[i].numpad && iflags.num_pad)
4551                     || !misc_keys[i].numpad)) {
4552             keys_used[(uchar) key] = TRUE;
4553             Sprintf(buf, "%-8s %s", key2txt(key, buf2), misc_keys[i].desc);
4554             putstr(datawin, 0, buf);
4555         }
4556     }
4557 #ifndef NO_SIGNAL
4558     putstr(datawin, 0, "^c       break out of NetHack (SIGINT)");
4559     keys_used[(uchar) C('c')] = TRUE;
4560 #endif
4561
4562     putstr(datawin, 0, "");
4563     show_menu_controls(datawin, TRUE);
4564
4565     if (dokeylist_putcmds(datawin, TRUE, GENERALCMD, WIZMODECMD, keys_used)) {
4566         putstr(datawin, 0, "");
4567         putstr(datawin, 0, "General commands:");
4568         (void) dokeylist_putcmds(datawin, FALSE, GENERALCMD, WIZMODECMD,
4569                                  keys_used);
4570     }
4571
4572     if (dokeylist_putcmds(datawin, TRUE, 0, WIZMODECMD, keys_used)) {
4573         putstr(datawin, 0, "");
4574         putstr(datawin, 0, "Game commands:");
4575         (void) dokeylist_putcmds(datawin, FALSE, 0, WIZMODECMD, keys_used);
4576     }
4577
4578     if (wizard
4579         && dokeylist_putcmds(datawin, TRUE, WIZMODECMD, 0, keys_used)) {
4580         putstr(datawin, 0, "");
4581         putstr(datawin, 0, "Wizard-mode commands:");
4582         (void) dokeylist_putcmds(datawin, FALSE, WIZMODECMD, 0, keys_used);
4583     }
4584
4585     display_nhwindow(datawin, FALSE);
4586     destroy_nhwindow(datawin);
4587 }
4588
4589 char
4590 cmd_from_func(fn)
4591 int NDECL((*fn));
4592 {
4593     int i;
4594
4595     for (i = 0; i < 256; ++i)
4596         if (Cmd.commands[i] && Cmd.commands[i]->ef_funct == fn)
4597             return (char) i;
4598     return '\0';
4599 }
4600
4601 /*
4602  * wizard mode sanity_check code
4603  */
4604
4605 static const char template[] = "%-27s  %4ld  %6ld";
4606 static const char stats_hdr[] = "                             count  bytes";
4607 static const char stats_sep[] = "---------------------------  ----- -------";
4608
4609 STATIC_OVL int
4610 size_obj(otmp)
4611 struct obj *otmp;
4612 {
4613     int sz = (int) sizeof(struct obj);
4614
4615     if (otmp->oextra) {
4616         sz += (int) sizeof(struct oextra);
4617         if (ONAME(otmp))
4618             sz += (int) strlen(ONAME(otmp)) + 1;
4619         if (OMONST(otmp))
4620             sz += (int) sizeof(struct monst);
4621         if (OMID(otmp))
4622             sz += (int) sizeof(unsigned);
4623         if (OLONG(otmp))
4624             sz += (int) sizeof(long);
4625         if (OMAILCMD(otmp))
4626             sz += (int) strlen(OMAILCMD(otmp)) + 1;
4627     }
4628     return sz;
4629 }
4630
4631 STATIC_OVL void
4632 count_obj(chain, total_count, total_size, top, recurse)
4633 struct obj *chain;
4634 long *total_count;
4635 long *total_size;
4636 boolean top;
4637 boolean recurse;
4638 {
4639     long count, size;
4640     struct obj *obj;
4641
4642     for (count = size = 0, obj = chain; obj; obj = obj->nobj) {
4643         if (top) {
4644             count++;
4645             size += size_obj(obj);
4646         }
4647         if (recurse && obj->cobj)
4648             count_obj(obj->cobj, total_count, total_size, TRUE, TRUE);
4649     }
4650     *total_count += count;
4651     *total_size += size;
4652 }
4653
4654 STATIC_OVL void
4655 obj_chain(win, src, chain, force, total_count, total_size)
4656 winid win;
4657 const char *src;
4658 struct obj *chain;
4659 boolean force;
4660 long *total_count;
4661 long *total_size;
4662 {
4663     char buf[BUFSZ];
4664     long count = 0L, size = 0L;
4665
4666     count_obj(chain, &count, &size, TRUE, FALSE);
4667
4668     if (count || size || force) {
4669         *total_count += count;
4670         *total_size += size;
4671         Sprintf(buf, template, src, count, size);
4672         putstr(win, 0, buf);
4673     }
4674 }
4675
4676 STATIC_OVL void
4677 mon_invent_chain(win, src, chain, total_count, total_size)
4678 winid win;
4679 const char *src;
4680 struct monst *chain;
4681 long *total_count;
4682 long *total_size;
4683 {
4684     char buf[BUFSZ];
4685     long count = 0, size = 0;
4686     struct monst *mon;
4687
4688     for (mon = chain; mon; mon = mon->nmon)
4689         count_obj(mon->minvent, &count, &size, TRUE, FALSE);
4690
4691     if (count || size) {
4692         *total_count += count;
4693         *total_size += size;
4694         Sprintf(buf, template, src, count, size);
4695         putstr(win, 0, buf);
4696     }
4697 }
4698
4699 STATIC_OVL void
4700 contained_stats(win, src, total_count, total_size)
4701 winid win;
4702 const char *src;
4703 long *total_count;
4704 long *total_size;
4705 {
4706     char buf[BUFSZ];
4707     long count = 0, size = 0;
4708     struct monst *mon;
4709
4710     count_obj(invent, &count, &size, FALSE, TRUE);
4711     count_obj(fobj, &count, &size, FALSE, TRUE);
4712     count_obj(level.buriedobjlist, &count, &size, FALSE, TRUE);
4713     count_obj(migrating_objs, &count, &size, FALSE, TRUE);
4714     /* DEADMONSTER check not required in this loop since they have no
4715      * inventory */
4716     for (mon = fmon; mon; mon = mon->nmon)
4717         count_obj(mon->minvent, &count, &size, FALSE, TRUE);
4718     for (mon = migrating_mons; mon; mon = mon->nmon)
4719         count_obj(mon->minvent, &count, &size, FALSE, TRUE);
4720
4721     if (count || size) {
4722         *total_count += count;
4723         *total_size += size;
4724         Sprintf(buf, template, src, count, size);
4725         putstr(win, 0, buf);
4726     }
4727 }
4728
4729 STATIC_OVL int
4730 size_monst(mtmp, incl_wsegs)
4731 struct monst *mtmp;
4732 boolean incl_wsegs;
4733 {
4734     int sz = (int) sizeof (struct monst);
4735
4736     if (mtmp->wormno && incl_wsegs)
4737         sz += size_wseg(mtmp);
4738
4739     if (mtmp->mextra) {
4740         sz += (int) sizeof (struct mextra);
4741         if (MNAME(mtmp))
4742             sz += (int) strlen(MNAME(mtmp)) + 1;
4743         if (EGD(mtmp))
4744             sz += (int) sizeof (struct egd);
4745         if (EPRI(mtmp))
4746             sz += (int) sizeof (struct epri);
4747         if (ESHK(mtmp))
4748             sz += (int) sizeof (struct eshk);
4749         if (EMIN(mtmp))
4750             sz += (int) sizeof (struct emin);
4751         if (EDOG(mtmp))
4752             sz += (int) sizeof (struct edog);
4753         /* mextra->mcorpsenm doesn't point to more memory */
4754     }
4755     return sz;
4756 }
4757
4758 STATIC_OVL void
4759 mon_chain(win, src, chain, force, total_count, total_size)
4760 winid win;
4761 const char *src;
4762 struct monst *chain;
4763 boolean force;
4764 long *total_count;
4765 long *total_size;
4766 {
4767     char buf[BUFSZ];
4768     long count, size;
4769     struct monst *mon;
4770     /* mon->wormno means something different for migrating_mons and mydogs */
4771     boolean incl_wsegs = !strcmpi(src, "fmon");
4772
4773     count = size = 0L;
4774     for (mon = chain; mon; mon = mon->nmon) {
4775         count++;
4776         size += size_monst(mon, incl_wsegs);
4777     }
4778     if (count || size || force) {
4779         *total_count += count;
4780         *total_size += size;
4781         Sprintf(buf, template, src, count, size);
4782         putstr(win, 0, buf);
4783     }
4784 }
4785
4786 STATIC_OVL void
4787 misc_stats(win, total_count, total_size)
4788 winid win;
4789 long *total_count;
4790 long *total_size;
4791 {
4792     char buf[BUFSZ], hdrbuf[QBUFSZ];
4793     long count, size;
4794     int idx;
4795     struct trap *tt;
4796     struct damage *sd; /* shop damage */
4797     struct cemetery *bi; /* bones info */
4798
4799     /* traps and engravings are output unconditionally;
4800      * others only if nonzero
4801      */
4802     count = size = 0L;
4803     for (tt = ftrap; tt; tt = tt->ntrap) {
4804         ++count;
4805         size += (long) sizeof *tt;
4806     }
4807     *total_count += count;
4808     *total_size += size;
4809     Sprintf(hdrbuf, "traps, size %ld", (long) sizeof (struct trap));
4810     Sprintf(buf, template, hdrbuf, count, size);
4811     putstr(win, 0, buf);
4812
4813     count = size = 0L;
4814     engr_stats("engravings, size %ld+text", hdrbuf, &count, &size);
4815     *total_count += count;
4816     *total_size += size;
4817     Sprintf(buf, template, hdrbuf, count, size);
4818     putstr(win, 0, buf);
4819
4820     count = size = 0L;
4821     light_stats("light sources, size %ld", hdrbuf, &count, &size);
4822     if (count || size) {
4823         *total_count += count;
4824         *total_size += size;
4825         Sprintf(buf, template, hdrbuf, count, size);
4826         putstr(win, 0, buf);
4827     }
4828
4829     count = size = 0L;
4830     timer_stats("timers, 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     for (sd = level.damagelist; sd; sd = sd->next) {
4840         ++count;
4841         size += (long) sizeof *sd;
4842     }
4843     if (count || size) {
4844         *total_count += count;
4845         *total_size += size;
4846         Sprintf(hdrbuf, "shop damage, size %ld",
4847                 (long) sizeof (struct damage));
4848         Sprintf(buf, template, hdrbuf, count, size);
4849         putstr(win, 0, buf);
4850     }
4851
4852     count = size = 0L;
4853     region_stats("regions, size %ld+%ld*rect+N", hdrbuf, &count, &size);
4854     if (count || size) {
4855         *total_count += count;
4856         *total_size += size;
4857         Sprintf(buf, template, hdrbuf, count, size);
4858         putstr(win, 0, buf);
4859     }
4860
4861     count = size = 0L;
4862     for (bi = level.bonesinfo; bi; bi = bi->next) {
4863         ++count;
4864         size += (long) sizeof *bi;
4865     }
4866     if (count || size) {
4867         *total_count += count;
4868         *total_size += size;
4869         Sprintf(hdrbuf, "bones history, size %ld",
4870                 (long) sizeof (struct cemetery));
4871         Sprintf(buf, template, hdrbuf, count, size);
4872         putstr(win, 0, buf);
4873     }
4874
4875     count = size = 0L;
4876     for (idx = 0; idx < NUM_OBJECTS; ++idx)
4877         if (objects[idx].oc_uname) {
4878             ++count;
4879             size += (long) (strlen(objects[idx].oc_uname) + 1);
4880         }
4881     if (count || size) {
4882         *total_count += count;
4883         *total_size += size;
4884         Strcpy(hdrbuf, "object type names, text");
4885         Sprintf(buf, template, hdrbuf, count, size);
4886         putstr(win, 0, buf);
4887     }
4888 }
4889
4890 /*
4891  * Display memory usage of all monsters and objects on the level.
4892  */
4893 static int
4894 wiz_show_stats()
4895 {
4896     char buf[BUFSZ];
4897     winid win;
4898     long total_obj_size, total_obj_count,
4899          total_mon_size, total_mon_count,
4900          total_ovr_size, total_ovr_count,
4901          total_misc_size, total_misc_count;
4902
4903     win = create_nhwindow(NHW_TEXT);
4904     putstr(win, 0, "Current memory statistics:");
4905
4906     total_obj_count = total_obj_size = 0L;
4907     putstr(win, 0, stats_hdr);
4908     Sprintf(buf, "  Objects, base size %ld", (long) sizeof (struct obj));
4909     putstr(win, 0, buf);
4910     obj_chain(win, "invent", invent, TRUE, &total_obj_count, &total_obj_size);
4911     obj_chain(win, "fobj", fobj, TRUE, &total_obj_count, &total_obj_size);
4912     obj_chain(win, "buried", level.buriedobjlist, FALSE,
4913               &total_obj_count, &total_obj_size);
4914     obj_chain(win, "migrating obj", migrating_objs, FALSE,
4915               &total_obj_count, &total_obj_size);
4916     obj_chain(win, "billobjs", billobjs, FALSE,
4917               &total_obj_count, &total_obj_size);
4918     mon_invent_chain(win, "minvent", fmon, &total_obj_count, &total_obj_size);
4919     mon_invent_chain(win, "migrating minvent", migrating_mons,
4920                      &total_obj_count, &total_obj_size);
4921     contained_stats(win, "contained", &total_obj_count, &total_obj_size);
4922     putstr(win, 0, stats_sep);
4923     Sprintf(buf, template, "  Obj total", total_obj_count, total_obj_size);
4924     putstr(win, 0, buf);
4925
4926     total_mon_count = total_mon_size = 0L;
4927     putstr(win, 0, "");
4928     Sprintf(buf, "  Monsters, base size %ld", (long) sizeof (struct monst));
4929     putstr(win, 0, buf);
4930     mon_chain(win, "fmon", fmon, TRUE, &total_mon_count, &total_mon_size);
4931     mon_chain(win, "migrating", migrating_mons, FALSE,
4932               &total_mon_count, &total_mon_size);
4933     /* 'mydogs' is only valid during level change or end of game disclosure,
4934        but conceivably we've been called from within debugger at such time */
4935     if (mydogs) /* monsters accompanying hero */
4936         mon_chain(win, "mydogs", mydogs, FALSE,
4937                   &total_mon_count, &total_mon_size);
4938     putstr(win, 0, stats_sep);
4939     Sprintf(buf, template, "  Mon total", total_mon_count, total_mon_size);
4940     putstr(win, 0, buf);
4941
4942     total_ovr_count = total_ovr_size = 0L;
4943     putstr(win, 0, "");
4944     putstr(win, 0, "  Overview");
4945     overview_stats(win, template, &total_ovr_count, &total_ovr_size);
4946     putstr(win, 0, stats_sep);
4947     Sprintf(buf, template, "  Over total", total_ovr_count, total_ovr_size);
4948     putstr(win, 0, buf);
4949
4950     total_misc_count = total_misc_size = 0L;
4951     putstr(win, 0, "");
4952     putstr(win, 0, "  Miscellaneous");
4953     misc_stats(win, &total_misc_count, &total_misc_size);
4954     putstr(win, 0, stats_sep);
4955     Sprintf(buf, template, "  Misc total", total_misc_count, total_misc_size);
4956     putstr(win, 0, buf);
4957
4958     putstr(win, 0, "");
4959     putstr(win, 0, stats_sep);
4960     Sprintf(buf, template, "  Grand total",
4961             (total_obj_count + total_mon_count
4962              + total_ovr_count + total_misc_count),
4963             (total_obj_size + total_mon_size
4964              + total_ovr_size + total_misc_size));
4965     putstr(win, 0, buf);
4966
4967 #if defined(__BORLANDC__) && !defined(_WIN32)
4968     show_borlandc_stats(win);
4969 #endif
4970
4971     display_nhwindow(win, FALSE);
4972     destroy_nhwindow(win);
4973     return 0;
4974 }
4975
4976 void
4977 sanity_check()
4978 {
4979     obj_sanity_check();
4980     timer_sanity_check();
4981     mon_sanity_check();
4982     light_sources_sanity_check();
4983 }
4984
4985 #ifdef DEBUG_MIGRATING_MONS
4986 static int
4987 wiz_migrate_mons()
4988 {
4989     int mcount = 0;
4990     char inbuf[BUFSZ] = DUMMY;
4991     struct permonst *ptr;
4992     struct monst *mtmp;
4993     d_level tolevel;
4994
4995     getlin("How many random monsters to migrate? [0]", inbuf);
4996     if (*inbuf == '\033')
4997         return 0;
4998     mcount = atoi(inbuf);
4999     if (mcount < 0 || mcount > (COLNO * ROWNO) || Is_botlevel(&u.uz))
5000         return 0;
5001     while (mcount > 0) {
5002         if (Is_stronghold(&u.uz))
5003             assign_level(&tolevel, &valley_level);
5004         else
5005             get_level(&tolevel, depth(&u.uz) + 1);
5006         ptr = rndmonst();
5007         mtmp = makemon(ptr, 0, 0, NO_MM_FLAGS);
5008         if (mtmp)
5009             migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM,
5010                              (coord *) 0);
5011         mcount--;
5012     }
5013     return 0;
5014 }
5015 #endif
5016
5017 #define unctrl(c) ((c) <= C('z') ? (0x60 | (c)) : (c))
5018 #define unmeta(c) (0x7f & (c))
5019
5020 struct {
5021     int nhkf;
5022     char key;
5023     const char *name;
5024 } const spkeys_binds[] = {
5025     { NHKF_ESC,              '\033', (char *) 0 }, /* no binding */
5026     { NHKF_DOAGAIN,          DOAGAIN, "repeat" },
5027     { NHKF_REQMENU,          'm', "reqmenu" },
5028     { NHKF_RUN,              'G', "run" },
5029     { NHKF_RUN2,             '5', "run.numpad" },
5030     { NHKF_RUSH,             'g', "rush" },
5031     { NHKF_FIGHT,            'F', "fight" },
5032     { NHKF_FIGHT2,           '-', "fight.numpad" },
5033     { NHKF_NOPICKUP,         'm', "nopickup" },
5034     { NHKF_RUN_NOPICKUP,     'M', "run.nopickup" },
5035     { NHKF_DOINV,            '0', "doinv" },
5036     { NHKF_TRAVEL,           CMD_TRAVEL, (char *) 0 }, /* no binding */
5037     { NHKF_CLICKLOOK,        CMD_CLICKLOOK, (char *) 0 }, /* no binding */
5038     { NHKF_REDRAW,           C('r'), "redraw" },
5039     { NHKF_REDRAW2,          C('l'), "redraw.numpad" },
5040     { NHKF_GETDIR_SELF,      '.', "getdir.self" },
5041     { NHKF_GETDIR_SELF2,     's', "getdir.self2" },
5042     { NHKF_GETDIR_HELP,      '?', "getdir.help" },
5043     { NHKF_COUNT,            'n', "count" },
5044     { NHKF_GETPOS_SELF,      '@', "getpos.self" },
5045     { NHKF_GETPOS_PICK,      '.', "getpos.pick" },
5046     { NHKF_GETPOS_PICK_Q,    ',', "getpos.pick.quick" },
5047     { NHKF_GETPOS_PICK_O,    ';', "getpos.pick.once" },
5048     { NHKF_GETPOS_PICK_V,    ':', "getpos.pick.verbose" },
5049     { NHKF_GETPOS_SHOWVALID, '$', "getpos.valid" },
5050     { NHKF_GETPOS_AUTODESC,  '#', "getpos.autodescribe" },
5051     { NHKF_GETPOS_MON_NEXT,  'm', "getpos.mon.next" },
5052     { NHKF_GETPOS_MON_PREV,  'M', "getpos.mon.prev" },
5053     { NHKF_GETPOS_OBJ_NEXT,  'o', "getpos.obj.next" },
5054     { NHKF_GETPOS_OBJ_PREV,  'O', "getpos.obj.prev" },
5055     { NHKF_GETPOS_DOOR_NEXT, 'd', "getpos.door.next" },
5056     { NHKF_GETPOS_DOOR_PREV, 'D', "getpos.door.prev" },
5057     { NHKF_GETPOS_UNEX_NEXT, 'x', "getpos.unexplored.next" },
5058     { NHKF_GETPOS_UNEX_PREV, 'X', "getpos.unexplored.prev" },
5059     { NHKF_GETPOS_VALID_NEXT, 'z', "getpos.valid.next" },
5060     { NHKF_GETPOS_VALID_PREV, 'Z', "getpos.valid.prev" },
5061     { NHKF_GETPOS_INTERESTING_NEXT, 'a', "getpos.all.next" },
5062     { NHKF_GETPOS_INTERESTING_PREV, 'A', "getpos.all.prev" },
5063     { NHKF_GETPOS_HELP,      '?', "getpos.help" },
5064     { NHKF_GETPOS_LIMITVIEW, '"', "getpos.filter" },
5065     { NHKF_GETPOS_MOVESKIP,  '*', "getpos.moveskip" },
5066     { NHKF_GETPOS_MENU,      '!', "getpos.menu" }
5067 };
5068
5069 boolean
5070 bind_specialkey(key, command)
5071 uchar key;
5072 const char *command;
5073 {
5074     int i;
5075     for (i = 0; i < SIZE(spkeys_binds); i++) {
5076         if (!spkeys_binds[i].name || strcmp(command, spkeys_binds[i].name))
5077             continue;
5078         Cmd.spkeys[spkeys_binds[i].nhkf] = key;
5079         return TRUE;
5080     }
5081     return FALSE;
5082 }
5083
5084 /* returns a one-byte character from the text (it may massacre the txt
5085  * buffer) */
5086 char
5087 txt2key(txt)
5088 char *txt;
5089 {
5090     txt = trimspaces(txt);
5091     if (!*txt)
5092         return '\0';
5093
5094     /* simple character */
5095     if (!txt[1])
5096         return txt[0];
5097
5098     /* a few special entries */
5099     if (!strcmp(txt, "<enter>"))
5100         return '\n';
5101     if (!strcmp(txt, "<space>"))
5102         return ' ';
5103     if (!strcmp(txt, "<esc>"))
5104         return '\033';
5105
5106     /* control and meta keys */
5107     switch (*txt) {
5108     case 'm': /* can be mx, Mx, m-x, M-x */
5109     case 'M':
5110         txt++;
5111         if (*txt == '-' && txt[1])
5112             txt++;
5113         if (txt[1])
5114             return '\0';
5115         return M(*txt);
5116     case 'c': /* can be cx, Cx, ^x, c-x, C-x, ^-x */
5117     case 'C':
5118     case '^':
5119         txt++;
5120         if (*txt == '-' && txt[1])
5121             txt++;
5122         if (txt[1])
5123             return '\0';
5124         return C(*txt);
5125     }
5126
5127     /* ascii codes: must be three-digit decimal */
5128     if (*txt >= '0' && *txt <= '9') {
5129         uchar key = 0;
5130         int i;
5131
5132         for (i = 0; i < 3; i++) {
5133             if (txt[i] < '0' || txt[i] > '9')
5134                 return '\0';
5135             key = 10 * key + txt[i] - '0';
5136         }
5137         return key;
5138     }
5139
5140     return '\0';
5141 }
5142
5143 /* returns the text for a one-byte encoding;
5144  * must be shorter than a tab for proper formatting */
5145 char *
5146 key2txt(c, txt)
5147 uchar c;
5148 char *txt; /* sufficiently long buffer */
5149 {
5150     /* should probably switch to "SPC", "ESC", "RET"
5151        since nethack's documentation uses ESC for <escape> */
5152     if (c == ' ')
5153         Sprintf(txt, "<space>");
5154     else if (c == '\033')
5155         Sprintf(txt, "<esc>");
5156     else if (c == '\n')
5157         Sprintf(txt, "<enter>");
5158     else if (c == '\177')
5159         Sprintf(txt, "<del>"); /* "<delete>" won't fit */
5160     else
5161         Strcpy(txt, visctrl((char) c));
5162     return txt;
5163 }
5164
5165
5166 void
5167 parseautocomplete(autocomplete, condition)
5168 char *autocomplete;
5169 boolean condition;
5170 {
5171     struct ext_func_tab *efp;
5172     register char *autoc;
5173
5174     /* break off first autocomplete from the rest; parse the rest */
5175     if ((autoc = index(autocomplete, ',')) != 0
5176         || (autoc = index(autocomplete, ':')) != 0) {
5177         *autoc++ = '\0';
5178         parseautocomplete(autoc, condition);
5179     }
5180
5181     /* strip leading and trailing white space */
5182     autocomplete = trimspaces(autocomplete);
5183
5184     if (!*autocomplete)
5185         return;
5186
5187     /* take off negation */
5188     if (*autocomplete == '!') {
5189         /* unlike most options, a leading "no" might actually be a part of
5190          * the extended command.  Thus you have to use ! */
5191         autocomplete++;
5192         autocomplete = trimspaces(autocomplete);
5193         condition = !condition;
5194     }
5195
5196     /* find and modify the extended command */
5197     for (efp = extcmdlist; efp->ef_txt; efp++) {
5198         if (!strcmp(autocomplete, efp->ef_txt)) {
5199             if (condition)
5200                 efp->flags |= AUTOCOMPLETE;
5201             else
5202                 efp->flags &= ~AUTOCOMPLETE;
5203             return;
5204         }
5205     }
5206
5207     /* not a real extended command */
5208     raw_printf("Bad autocomplete: invalid extended command '%s'.",
5209                autocomplete);
5210     wait_synch();
5211 }
5212
5213 /* called at startup and after number_pad is twiddled */
5214 void
5215 reset_commands(initial)
5216 boolean initial;
5217 {
5218     static const char sdir[] = "hykulnjb><",
5219                       sdir_swap_yz[] = "hzkulnjb><",
5220                       ndir[] = "47896321><",
5221                       ndir_phone_layout[] = "41236987><";
5222     static const int ylist[] = {
5223         'y', 'Y', C('y'), M('y'), M('Y'), M(C('y'))
5224     };
5225     static struct ext_func_tab *back_dir_cmd[8];
5226     const struct ext_func_tab *cmdtmp;
5227     boolean flagtemp;
5228     int c, i, updated = 0;
5229     static boolean backed_dir_cmd = FALSE;
5230
5231     if (initial) {
5232         updated = 1;
5233         Cmd.num_pad = FALSE;
5234         Cmd.pcHack_compat = Cmd.phone_layout = Cmd.swap_yz = FALSE;
5235         for (i = 0; i < SIZE(spkeys_binds); i++)
5236             Cmd.spkeys[spkeys_binds[i].nhkf] = spkeys_binds[i].key;
5237         commands_init();
5238     } else {
5239
5240         if (backed_dir_cmd) {
5241             for (i = 0; i < 8; i++) {
5242                 Cmd.commands[(uchar) Cmd.dirchars[i]] = back_dir_cmd[i];
5243             }
5244         }
5245
5246         /* basic num_pad */
5247         flagtemp = iflags.num_pad;
5248         if (flagtemp != Cmd.num_pad) {
5249             Cmd.num_pad = flagtemp;
5250             ++updated;
5251         }
5252         /* swap_yz mode (only applicable for !num_pad); intended for
5253            QWERTZ keyboard used in Central Europe, particularly Germany */
5254         flagtemp = (iflags.num_pad_mode & 1) ? !Cmd.num_pad : FALSE;
5255         if (flagtemp != Cmd.swap_yz) {
5256             Cmd.swap_yz = flagtemp;
5257             ++updated;
5258             /* Cmd.swap_yz has been toggled;
5259                perform the swap (or reverse previous one) */
5260             for (i = 0; i < SIZE(ylist); i++) {
5261                 c = ylist[i] & 0xff;
5262                 cmdtmp = Cmd.commands[c];              /* tmp = [y] */
5263                 Cmd.commands[c] = Cmd.commands[c + 1]; /* [y] = [z] */
5264                 Cmd.commands[c + 1] = cmdtmp;          /* [z] = tmp */
5265             }
5266         }
5267         /* MSDOS compatibility mode (only applicable for num_pad) */
5268         flagtemp = (iflags.num_pad_mode & 1) ? Cmd.num_pad : FALSE;
5269         if (flagtemp != Cmd.pcHack_compat) {
5270             Cmd.pcHack_compat = flagtemp;
5271             ++updated;
5272             /* pcHack_compat has been toggled */
5273             c = M('5') & 0xff;
5274             cmdtmp = Cmd.commands['5'];
5275             Cmd.commands['5'] = Cmd.commands[c];
5276             Cmd.commands[c] = cmdtmp;
5277             c = M('0') & 0xff;
5278             Cmd.commands[c] = Cmd.pcHack_compat ? Cmd.commands['I'] : 0;
5279         }
5280         /* phone keypad layout (only applicable for num_pad) */
5281         flagtemp = (iflags.num_pad_mode & 2) ? Cmd.num_pad : FALSE;
5282         if (flagtemp != Cmd.phone_layout) {
5283             Cmd.phone_layout = flagtemp;
5284             ++updated;
5285             /* phone_layout has been toggled */
5286             for (i = 0; i < 3; i++) {
5287                 c = '1' + i;             /* 1,2,3 <-> 7,8,9 */
5288                 cmdtmp = Cmd.commands[c];              /* tmp = [1] */
5289                 Cmd.commands[c] = Cmd.commands[c + 6]; /* [1] = [7] */
5290                 Cmd.commands[c + 6] = cmdtmp;          /* [7] = tmp */
5291                 c = (M('1') & 0xff) + i; /* M-1,M-2,M-3 <-> M-7,M-8,M-9 */
5292                 cmdtmp = Cmd.commands[c];              /* tmp = [M-1] */
5293                 Cmd.commands[c] = Cmd.commands[c + 6]; /* [M-1] = [M-7] */
5294                 Cmd.commands[c + 6] = cmdtmp;          /* [M-7] = tmp */
5295             }
5296         }
5297     } /*?initial*/
5298
5299     if (updated)
5300         Cmd.serialno++;
5301     Cmd.dirchars = !Cmd.num_pad
5302                        ? (!Cmd.swap_yz ? sdir : sdir_swap_yz)
5303                        : (!Cmd.phone_layout ? ndir : ndir_phone_layout);
5304     Cmd.alphadirchars = !Cmd.num_pad ? Cmd.dirchars : sdir;
5305
5306     Cmd.move_W = Cmd.dirchars[0];
5307     Cmd.move_NW = Cmd.dirchars[1];
5308     Cmd.move_N = Cmd.dirchars[2];
5309     Cmd.move_NE = Cmd.dirchars[3];
5310     Cmd.move_E = Cmd.dirchars[4];
5311     Cmd.move_SE = Cmd.dirchars[5];
5312     Cmd.move_S = Cmd.dirchars[6];
5313     Cmd.move_SW = Cmd.dirchars[7];
5314
5315     if (!initial) {
5316         for (i = 0; i < 8; i++) {
5317             back_dir_cmd[i] =
5318                 (struct ext_func_tab *) Cmd.commands[(uchar) Cmd.dirchars[i]];
5319             Cmd.commands[(uchar) Cmd.dirchars[i]] = (struct ext_func_tab *) 0;
5320         }
5321         backed_dir_cmd = TRUE;
5322         for (i = 0; i < 8; i++)
5323             (void) bind_key(Cmd.dirchars[i], "nothing");
5324     }
5325 }
5326
5327 /* non-movement commands which accept 'm' prefix to request menu operation */
5328 STATIC_OVL boolean
5329 accept_menu_prefix(cmd_func)
5330 int NDECL((*cmd_func));
5331 {
5332     if (cmd_func == dopickup || cmd_func == dotip
5333         /* eat, #offer, and apply tinning-kit all use floorfood() to pick
5334            an item on floor or in invent; 'm' skips picking from floor
5335            (ie, inventory only) rather than request use of menu operation */
5336         || cmd_func == doeat || cmd_func == dosacrifice || cmd_func == doapply
5337         /* 'm' for removing saddle from adjacent monster without checking
5338            for containers at <u.ux,u.uy> */
5339         || cmd_func == doloot
5340         /* travel: pop up a menu of interesting targets in view */
5341         || cmd_func == dotravel
5342         /* wizard mode ^V */
5343         || cmd_func == wiz_level_tele
5344         /* 'm' prefix allowed for some extended commands */
5345         || cmd_func == doextcmd || cmd_func == doextlist)
5346         return TRUE;
5347     return FALSE;
5348 }
5349
5350 int
5351 ch2spkeys(c, start, end)
5352 char c;
5353 int start,end;
5354 {
5355     int i;
5356
5357     for (i = start; i <= end; i++)
5358         if (Cmd.spkeys[i] == c)
5359             return i;
5360     return NHKF_ESC;
5361 }
5362
5363 void
5364 rhack(cmd)
5365 register char *cmd;
5366 {
5367     int spkey;
5368     boolean do_walk, do_rush, prefix_seen, bad_command,
5369         firsttime = (cmd == 0);
5370
5371     iflags.menu_requested = FALSE;
5372 #ifdef SAFERHANGUP
5373     if (program_state.done_hup)
5374         end_of_input();
5375 #endif
5376     if (firsttime) {
5377         context.nopick = 0;
5378         cmd = parse();
5379     }
5380     if (*cmd == Cmd.spkeys[NHKF_ESC]) {
5381         context.move = FALSE;
5382         return;
5383     }
5384     if (*cmd == DOAGAIN && !in_doagain && saveq[0]) {
5385         in_doagain = TRUE;
5386         stail = 0;
5387         rhack((char *) 0); /* read and execute command */
5388         in_doagain = FALSE;
5389         return;
5390     }
5391     /* Special case of *cmd == ' ' handled better below */
5392     if (!*cmd || *cmd == (char) 0377) {
5393         nhbell();
5394         context.move = FALSE;
5395         return; /* probably we just had an interrupt */
5396     }
5397
5398     /* handle most movement commands */
5399     do_walk = do_rush = prefix_seen = FALSE;
5400     context.travel = context.travel1 = 0;
5401     spkey = ch2spkeys(*cmd, NHKF_RUN, NHKF_CLICKLOOK);
5402
5403     switch (spkey) {
5404     case NHKF_RUSH:
5405         if (movecmd(cmd[1])) {
5406             context.run = 2;
5407             do_rush = TRUE;
5408         } else
5409             prefix_seen = TRUE;
5410         break;
5411     case NHKF_RUN2:
5412         if (!Cmd.num_pad)
5413             break;
5414         /*FALLTHRU*/
5415     case NHKF_RUN:
5416         if (movecmd(lowc(cmd[1]))) {
5417             context.run = 3;
5418             do_rush = TRUE;
5419         } else
5420             prefix_seen = TRUE;
5421         break;
5422     case NHKF_FIGHT2:
5423         if (!Cmd.num_pad)
5424             break;
5425         /*FALLTHRU*/
5426     /* Effects of movement commands and invisible monsters:
5427      * m: always move onto space (even if 'I' remembered)
5428      * F: always attack space (even if 'I' not remembered)
5429      * normal movement: attack if 'I', move otherwise.
5430      */
5431     case NHKF_FIGHT:
5432         if (movecmd(cmd[1])) {
5433             context.forcefight = 1;
5434             do_walk = TRUE;
5435         } else
5436             prefix_seen = TRUE;
5437         break;
5438     case NHKF_NOPICKUP:
5439         if (movecmd(cmd[1]) || u.dz) {
5440             context.run = 0;
5441             context.nopick = 1;
5442             if (!u.dz)
5443                 do_walk = TRUE;
5444             else
5445                 cmd[0] = cmd[1]; /* "m<" or "m>" */
5446         } else
5447             prefix_seen = TRUE;
5448         break;
5449     case NHKF_RUN_NOPICKUP:
5450         if (movecmd(lowc(cmd[1]))) {
5451             context.run = 1;
5452             context.nopick = 1;
5453             do_rush = TRUE;
5454         } else
5455             prefix_seen = TRUE;
5456         break;
5457     case NHKF_DOINV:
5458         if (!Cmd.num_pad)
5459             break;
5460         (void) ddoinv(); /* a convenience borrowed from the PC */
5461         context.move = FALSE;
5462         multi = 0;
5463         return;
5464     case NHKF_CLICKLOOK:
5465         if (iflags.clicklook) {
5466             context.move = FALSE;
5467             do_look(2, &clicklook_cc);
5468         }
5469         return;
5470     case NHKF_TRAVEL:
5471         if (flags.travelcmd) {
5472             context.travel = 1;
5473             context.travel1 = 1;
5474             context.run = 8;
5475             context.nopick = 1;
5476             do_rush = TRUE;
5477             break;
5478         }
5479         /*FALLTHRU*/
5480     default:
5481         if (movecmd(*cmd)) { /* ordinary movement */
5482             context.run = 0; /* only matters here if it was 8 */
5483             do_walk = TRUE;
5484         } else if (movecmd(Cmd.num_pad ? unmeta(*cmd) : lowc(*cmd))) {
5485             context.run = 1;
5486             do_rush = TRUE;
5487         } else if (movecmd(unctrl(*cmd))) {
5488             context.run = 3;
5489             do_rush = TRUE;
5490         }
5491         break;
5492     }
5493
5494     /* some special prefix handling */
5495     /* overload 'm' prefix to mean "request a menu" */
5496     if (prefix_seen && cmd[0] == Cmd.spkeys[NHKF_REQMENU]) {
5497         /* (for func_tab cast, see below) */
5498         const struct ext_func_tab *ft = Cmd.commands[cmd[1] & 0xff];
5499         int NDECL((*func)) = ft ? ((struct ext_func_tab *) ft)->ef_funct : 0;
5500
5501         if (func && accept_menu_prefix(func)) {
5502             iflags.menu_requested = TRUE;
5503             ++cmd;
5504         }
5505     }
5506
5507     if ((do_walk || do_rush) && !context.travel && !dxdy_moveok()) {
5508         /* trying to move diagonally as a grid bug;
5509            this used to be treated by movecmd() as not being
5510            a movement attempt, but that didn't provide for any
5511            feedback and led to strangeness if the key pressed
5512            ('u' in particular) was overloaded for num_pad use */
5513 /*JP
5514         You_cant("get there from here...");
5515 */
5516         You_cant("\82±\82±\82©\82ç\82»\82±\82Ö\82Í\8ds\82¯\82Ü\82¹\82ñ\81D\81D\81D");
5517         context.run = 0;
5518         context.nopick = context.forcefight = FALSE;
5519         context.move = context.mv = FALSE;
5520         multi = 0;
5521         return;
5522     }
5523
5524     if (do_walk) {
5525         if (multi)
5526             context.mv = TRUE;
5527         domove();
5528         context.forcefight = 0;
5529         return;
5530     } else if (do_rush) {
5531         if (firsttime) {
5532             if (!multi)
5533                 multi = max(COLNO, ROWNO);
5534             u.last_str_turn = 0;
5535         }
5536         context.mv = TRUE;
5537         domove();
5538         return;
5539     } else if (prefix_seen && cmd[1] == Cmd.spkeys[NHKF_ESC]) {
5540         /* <prefix><escape> */
5541         /* don't report "unknown command" for change of heart... */
5542         bad_command = FALSE;
5543     } else if (*cmd == ' ' && !flags.rest_on_space) {
5544         bad_command = TRUE; /* skip cmdlist[] loop */
5545
5546     /* handle all other commands */
5547     } else {
5548         register const struct ext_func_tab *tlist;
5549         int res, NDECL((*func));
5550
5551         /* current - use *cmd to directly index cmdlist array */
5552         if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) {
5553             if (!wizard && (tlist->flags & WIZMODECMD)) {
5554 /*JP
5555                 You_cant("do that!");
5556 */
5557                 pline("\82»\82ê\82Í\82Å\82«\82Ü\82¹\82ñ\81I");
5558                 res = 0;
5559             } else if (u.uburied && !(tlist->flags & IFBURIED)) {
5560 /*JP
5561                 You_cant("do that while you are buried!");
5562 */
5563                 You("\96\84\82Ü\82Á\82Ä\82¢\82é\8e\9e\82É\82»\82ñ\82È\82±\82Æ\82Í\82Å\82«\82È\82¢\81I");
5564                 res = 0;
5565             } else {
5566                 /* we discard 'const' because some compilers seem to have
5567                    trouble with the pointer passed to set_occupation() */
5568                 func = ((struct ext_func_tab *) tlist)->ef_funct;
5569                 if (tlist->f_text && !occupation && multi)
5570                     set_occupation(func, tlist->f_text, multi);
5571                 res = (*func)(); /* perform the command */
5572             }
5573             if (!res) {
5574                 context.move = FALSE;
5575                 multi = 0;
5576             }
5577             return;
5578         }
5579         /* if we reach here, cmd wasn't found in cmdlist[] */
5580         bad_command = TRUE;
5581     }
5582
5583     if (bad_command) {
5584         char expcmd[20]; /* we expect 'cmd' to point to 1 or 2 chars */
5585         char c, c1 = cmd[1];
5586
5587         expcmd[0] = '\0';
5588         while ((c = *cmd++) != '\0')
5589             Strcat(expcmd, visctrl(c)); /* add 1..4 chars plus terminator */
5590
5591 /*JP
5592         if (!prefix_seen || !help_dir(c1, spkey, "Invalid direction key!"))
5593 */
5594         if (!prefix_seen || !help_dir(c1, spkey, "\96³\8cø\82È\95û\8cü\8ew\92è\82Å\82·\81I"))
5595 /*JP
5596             Norep("Unknown command '%s'.", expcmd);
5597 */
5598             Norep("'%s'\83R\83}\83\93\83h\81H", expcmd);
5599     }
5600     /* didn't move */
5601     context.move = FALSE;
5602     multi = 0;
5603     return;
5604 }
5605
5606 /* convert an x,y pair into a direction code */
5607 int
5608 xytod(x, y)
5609 schar x, y;
5610 {
5611     register int dd;
5612
5613     for (dd = 0; dd < 8; dd++)
5614         if (x == xdir[dd] && y == ydir[dd])
5615             return dd;
5616     return -1;
5617 }
5618
5619 /* convert a direction code into an x,y pair */
5620 void
5621 dtoxy(cc, dd)
5622 coord *cc;
5623 register int dd;
5624 {
5625     cc->x = xdir[dd];
5626     cc->y = ydir[dd];
5627     return;
5628 }
5629
5630 /* also sets u.dz, but returns false for <> */
5631 int
5632 movecmd(sym)
5633 char sym;
5634 {
5635     register const char *dp = index(Cmd.dirchars, sym);
5636
5637     u.dz = 0;
5638     if (!dp || !*dp)
5639         return 0;
5640     u.dx = xdir[dp - Cmd.dirchars];
5641     u.dy = ydir[dp - Cmd.dirchars];
5642     u.dz = zdir[dp - Cmd.dirchars];
5643 #if 0 /* now handled elsewhere */
5644     if (u.dx && u.dy && NODIAG(u.umonnum)) {
5645         u.dx = u.dy = 0;
5646         return 0;
5647     }
5648 #endif
5649     return !u.dz;
5650 }
5651
5652 /* grid bug handling which used to be in movecmd() */
5653 int
5654 dxdy_moveok()
5655 {
5656     if (u.dx && u.dy && NODIAG(u.umonnum))
5657         u.dx = u.dy = 0;
5658     return u.dx || u.dy;
5659 }
5660
5661 /* decide whether a character (user input keystroke) requests screen repaint */
5662 boolean
5663 redraw_cmd(c)
5664 char c;
5665 {
5666     return (boolean) (c == Cmd.spkeys[NHKF_REDRAW]
5667                       || (Cmd.num_pad && c == Cmd.spkeys[NHKF_REDRAW2]));
5668 }
5669
5670 boolean
5671 prefix_cmd(c)
5672 char c;
5673 {
5674     return (c == Cmd.spkeys[NHKF_RUSH]
5675             || c == Cmd.spkeys[NHKF_RUN]
5676             || c == Cmd.spkeys[NHKF_NOPICKUP]
5677             || c == Cmd.spkeys[NHKF_RUN_NOPICKUP]
5678             || c == Cmd.spkeys[NHKF_FIGHT]
5679             || (Cmd.num_pad && (c == Cmd.spkeys[NHKF_RUN2]
5680                                 || c == Cmd.spkeys[NHKF_FIGHT2])));
5681 }
5682
5683 /*
5684  * uses getdir() but unlike getdir() it specifically
5685  * produces coordinates using the direction from getdir()
5686  * and verifies that those coordinates are ok.
5687  *
5688  * If the call to getdir() returns 0, Never_mind is displayed.
5689  * If the resulting coordinates are not okay, emsg is displayed.
5690  *
5691  * Returns non-zero if coordinates in cc are valid.
5692  */
5693 int
5694 get_adjacent_loc(prompt, emsg, x, y, cc)
5695 const char *prompt, *emsg;
5696 xchar x, y;
5697 coord *cc;
5698 {
5699     xchar new_x, new_y;
5700     if (!getdir(prompt)) {
5701         pline1(Never_mind);
5702         return 0;
5703     }
5704     new_x = x + u.dx;
5705     new_y = y + u.dy;
5706     if (cc && isok(new_x, new_y)) {
5707         cc->x = new_x;
5708         cc->y = new_y;
5709     } else {
5710         if (emsg)
5711             pline1(emsg);
5712         return 0;
5713     }
5714     return 1;
5715 }
5716
5717 int
5718 getdir(s)
5719 const char *s;
5720 {
5721     char dirsym;
5722     int is_mov;
5723
5724 retry:
5725     if (in_doagain || *readchar_queue)
5726         dirsym = readchar();
5727     else
5728 /*JP
5729         dirsym = yn_function((s && *s != '^') ? s : "In what direction?",
5730 */
5731         dirsym = yn_function((s && *s != '^') ? s : "\82Ç\82Ì\95û\8cü\81H",
5732                              (char *) 0, '\0');
5733     /* remove the prompt string so caller won't have to */
5734     clear_nhwindow(WIN_MESSAGE);
5735
5736     if (redraw_cmd(dirsym)) { /* ^R */
5737         docrt();              /* redraw */
5738         goto retry;
5739     }
5740     savech(dirsym);
5741
5742     if (dirsym == Cmd.spkeys[NHKF_GETDIR_SELF]
5743         || dirsym == Cmd.spkeys[NHKF_GETDIR_SELF2]) {
5744         u.dx = u.dy = u.dz = 0;
5745     } else if (!(is_mov = movecmd(dirsym)) && !u.dz) {
5746         boolean did_help = FALSE, help_requested;
5747
5748         if (!index(quitchars, dirsym)) {
5749             help_requested = (dirsym == Cmd.spkeys[NHKF_GETDIR_HELP]);
5750             if (help_requested || iflags.cmdassist) {
5751                 did_help = help_dir((s && *s == '^') ? dirsym : '\0',
5752                                     NHKF_ESC,
5753                                     help_requested ? (const char *) 0
5754 /*JP
5755                                             : "Invalid direction key!");
5756 */
5757                                             : "\96³\8cø\82È\95û\8cü\8ew\92è\82Å\82·\81I");
5758                 if (help_requested)
5759                     goto retry;
5760             }
5761             if (!did_help)
5762 /*JP
5763                 pline("What a strange direction!");
5764 */
5765                 pline("\82¸\82¢\82Ô\82ñ\82Æ\8aï\96­\82È\95û\8cü\82¾\81I");
5766         }
5767         return 0;
5768     } else if (is_mov && !dxdy_moveok()) {
5769 /*JP
5770         You_cant("orient yourself that direction.");
5771 */
5772         You_cant("\8cü\82«\82É\8e©\95ª\8e©\90g\82ð\8ew\92è\82Å\82«\82È\82¢\81D");
5773         return 0;
5774     }
5775     if (!u.dz && (Stunned || (Confusion && !rn2(5))))
5776         confdir();
5777     return 1;
5778 }
5779
5780 STATIC_OVL void
5781 show_direction_keys(win, centerchar, nodiag)
5782 winid win; /* should specify a window which is using a fixed-width font... */
5783 char centerchar; /* '.' or '@' or ' ' */
5784 boolean nodiag;
5785 {
5786     char buf[BUFSZ];
5787
5788     if (!centerchar)
5789         centerchar = ' ';
5790
5791     if (nodiag) {
5792         Sprintf(buf, "             %c   ", Cmd.move_N);
5793         putstr(win, 0, buf);
5794         putstr(win, 0, "             |   ");
5795         Sprintf(buf, "          %c- %c -%c",
5796                 Cmd.move_W, centerchar, Cmd.move_E);
5797         putstr(win, 0, buf);
5798         putstr(win, 0, "             |   ");
5799         Sprintf(buf, "             %c   ", Cmd.move_S);
5800         putstr(win, 0, buf);
5801     } else {
5802         Sprintf(buf, "          %c  %c  %c",
5803                 Cmd.move_NW, Cmd.move_N, Cmd.move_NE);
5804         putstr(win, 0, buf);
5805         putstr(win, 0, "           \\ | / ");
5806         Sprintf(buf, "          %c- %c -%c",
5807                 Cmd.move_W, centerchar, Cmd.move_E);
5808         putstr(win, 0, buf);
5809         putstr(win, 0, "           / | \\ ");
5810         Sprintf(buf, "          %c  %c  %c",
5811                 Cmd.move_SW, Cmd.move_S, Cmd.move_SE);
5812         putstr(win, 0, buf);
5813     };
5814 }
5815
5816 /* explain choices if player has asked for getdir() help or has given
5817    an invalid direction after a prefix key ('F', 'g', 'm', &c), which
5818    might be bogus but could be up, down, or self when not applicable */
5819 STATIC_OVL boolean
5820 help_dir(sym, spkey, msg)
5821 char sym;
5822 int spkey; /* NHKF_ code for prefix key, if one was used, or for ESC */
5823 const char *msg;
5824 {
5825     static const char wiz_only_list[] = "EFGIVW";
5826     char ctrl;
5827     winid win;
5828     char buf[BUFSZ], buf2[BUFSZ], *explain;
5829     const char *dothat, *how;
5830     boolean prefixhandling, viawindow;
5831
5832     /* NHKF_ESC indicates that player asked for help at getdir prompt */
5833     viawindow = (spkey == NHKF_ESC || iflags.cmdassist);
5834     prefixhandling = (spkey != NHKF_ESC);
5835     /*
5836      * Handling for prefix keys that don't want special directions.
5837      * Delivered via pline if 'cmdassist' is off, or instead of the
5838      * general message if it's on.
5839      */
5840     dothat = "do that";
5841     how = " at"; /* for "<action> at yourself"; not used for up/down */
5842     switch (spkey) {
5843     case NHKF_NOPICKUP:
5844         dothat = "move";
5845         break;
5846     case NHKF_RUSH:
5847         dothat = "rush";
5848         break;
5849     case NHKF_RUN2:
5850         if (!Cmd.num_pad)
5851             break;
5852         /*FALLTHRU*/
5853     case NHKF_RUN:
5854     case NHKF_RUN_NOPICKUP:
5855         dothat = "run";
5856         break;
5857     case NHKF_FIGHT2:
5858         if (!Cmd.num_pad)
5859             break;
5860         /*FALLTHRU*/
5861     case NHKF_FIGHT:
5862         dothat = "fight";
5863         how = ""; /* avoid "fight at yourself" */
5864         break;
5865     default:
5866         prefixhandling = FALSE;
5867         break;
5868     }
5869
5870     buf[0] = '\0';
5871     /* for movement prefix followed by '.' or (numpad && 's') to mean 'self';
5872        note: '-' for hands (inventory form of 'self') is not handled here */
5873     if (prefixhandling
5874         && (sym == Cmd.spkeys[NHKF_GETDIR_SELF]
5875             || (Cmd.num_pad && sym == Cmd.spkeys[NHKF_GETDIR_SELF2]))) {
5876         Sprintf(buf, "You can't %s%s yourself.", dothat, how);
5877     /* for movement prefix followed by up or down */
5878     } else if (prefixhandling && (sym == '<' || sym == '>')) {
5879         Sprintf(buf, "You can't %s %s.", dothat,
5880                 /* was "upwards" and "downwards", but they're considered
5881                    to be variants of canonical "upward" and "downward" */
5882                 (sym == '<') ? "upward" : "downward");
5883     }
5884
5885     /* if '!cmdassist', display via pline() and we're done (note: asking
5886        for help at getdir() prompt forces cmdassist for this operation) */
5887     if (!viawindow) {
5888         if (prefixhandling) {
5889             if (!*buf)
5890                 Sprintf(buf, "Invalid direction for '%s' prefix.",
5891                         visctrl(Cmd.spkeys[spkey]));
5892             pline("%s", buf);
5893             return TRUE;
5894         }
5895         /* when 'cmdassist' is off and caller doesn't insist, do nothing */
5896         return FALSE;
5897     }
5898
5899     win = create_nhwindow(NHW_TEXT);
5900     if (!win)
5901         return FALSE;
5902
5903     if (*buf) {
5904         /* show bad-prefix message instead of general invalid-direction one */
5905         putstr(win, 0, buf);
5906         putstr(win, 0, "");
5907     } else if (msg) {
5908         Sprintf(buf, "cmdassist: %s", msg);
5909         putstr(win, 0, buf);
5910         putstr(win, 0, "");
5911     }
5912
5913     if (!prefixhandling && (letter(sym) || sym == '[')) {
5914         /* '[': old 'cmdhelp' showed ESC as ^[ */
5915         sym = highc(sym); /* @A-Z[ (note: letter() accepts '@') */
5916         ctrl = (sym - 'A') + 1; /* 0-27 (note: 28-31 aren't applicable) */
5917         if ((explain = dowhatdoes_core(ctrl, buf2)) != 0
5918             && (!index(wiz_only_list, sym) || wizard)) {
5919             Sprintf(buf, "Are you trying to use ^%c%s?", sym,
5920                     index(wiz_only_list, sym) ? ""
5921                         : " as specified in the Guidebook");
5922             putstr(win, 0, buf);
5923             putstr(win, 0, "");
5924             putstr(win, 0, explain);
5925             putstr(win, 0, "");
5926             putstr(win, 0,
5927                   "To use that command, hold down the <Ctrl> key as a shift");
5928             Sprintf(buf, "and press the <%c> key.", sym);
5929             putstr(win, 0, buf);
5930             putstr(win, 0, "");
5931         }
5932     }
5933
5934     Sprintf(buf, "Valid direction keys%s%s%s are:",
5935             prefixhandling ? " to " : "", prefixhandling ? dothat : "",
5936             NODIAG(u.umonnum) ? " in your current form" : "");
5937     putstr(win, 0, buf);
5938     show_direction_keys(win, !prefixhandling ? '.' : ' ', NODIAG(u.umonnum));
5939
5940     if (!prefixhandling || spkey == NHKF_NOPICKUP) {
5941         /* NOPICKUP: unlike the other prefix keys, 'm' allows up/down for
5942            stair traversal; we won't get here when "m<" or "m>" has been
5943            given but we include up and down for 'm'+invalid_direction;
5944            self is excluded as a viable direction for every prefix */
5945         putstr(win, 0, "");
5946         putstr(win, 0, "          <  up");
5947         putstr(win, 0, "          >  down");
5948         if (!prefixhandling) {
5949             int selfi = Cmd.num_pad ? NHKF_GETDIR_SELF2 : NHKF_GETDIR_SELF;
5950
5951             Sprintf(buf,   "       %4s  direct at yourself",
5952                     visctrl(Cmd.spkeys[selfi]));
5953             putstr(win, 0, buf);
5954         }
5955     }
5956
5957     if (msg) {
5958         /* non-null msg means that this wasn't an explicit user request */
5959         putstr(win, 0, "");
5960         putstr(win, 0,
5961 /*JP
5962                "(Suppress this message with !cmdassist in config file.)");
5963 */
5964                "(\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)");
5965     }
5966     display_nhwindow(win, FALSE);
5967     destroy_nhwindow(win);
5968     return TRUE;
5969 }
5970
5971 void
5972 confdir()
5973 {
5974     register int x = NODIAG(u.umonnum) ? 2 * rn2(4) : rn2(8);
5975
5976     u.dx = xdir[x];
5977     u.dy = ydir[x];
5978     return;
5979 }
5980
5981 const char *
5982 directionname(dir)
5983 int dir;
5984 {
5985     static NEARDATA const char *const dirnames[] = {
5986         "west",      "northwest", "north",     "northeast", "east",
5987         "southeast", "south",     "southwest", "down",      "up",
5988     };
5989
5990     if (dir < 0 || dir >= SIZE(dirnames))
5991         return "invalid";
5992     return dirnames[dir];
5993 }
5994
5995 int
5996 isok(x, y)
5997 register int x, y;
5998 {
5999     /* x corresponds to curx, so x==1 is the first column. Ach. %% */
6000     return x >= 1 && x <= COLNO - 1 && y >= 0 && y <= ROWNO - 1;
6001 }
6002
6003 /* #herecmdmenu command */
6004 STATIC_PTR int
6005 doherecmdmenu(VOID_ARGS)
6006 {
6007     char ch = here_cmd_menu(TRUE);
6008
6009     return ch ? 1 : 0;
6010 }
6011
6012 /* #therecmdmenu command, a way to test there_cmd_menu without mouse */
6013 STATIC_PTR int
6014 dotherecmdmenu(VOID_ARGS)
6015 {
6016     char ch;
6017
6018     if (!getdir((const char *) 0) || !isok(u.ux + u.dx, u.uy + u.dy))
6019         return 0;
6020
6021     if (u.dx || u.dy)
6022         ch = there_cmd_menu(TRUE, u.ux + u.dx, u.uy + u.dy);
6023     else
6024         ch = here_cmd_menu(TRUE);
6025
6026     return ch ? 1 : 0;
6027 }
6028
6029 STATIC_OVL void
6030 add_herecmd_menuitem(win, func, text)
6031 winid win;
6032 int NDECL((*func));
6033 const char *text;
6034 {
6035     char ch;
6036     anything any;
6037
6038     if ((ch = cmd_from_func(func)) != '\0') {
6039         any = zeroany;
6040         any.a_nfunc = func;
6041         add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, text, MENU_UNSELECTED);
6042     }
6043 }
6044
6045 STATIC_OVL char
6046 there_cmd_menu(doit, x, y)
6047 boolean doit;
6048 int x, y;
6049 {
6050     winid win;
6051     char ch;
6052     char buf[BUFSZ];
6053     schar typ = levl[x][y].typ;
6054     int npick, K = 0;
6055     menu_item *picks = (menu_item *) 0;
6056     struct trap *ttmp;
6057     struct monst *mtmp;
6058
6059     win = create_nhwindow(NHW_MENU);
6060     start_menu(win);
6061
6062     if (IS_DOOR(typ)) {
6063         boolean key_or_pick, card;
6064         int dm = levl[x][y].doormask;
6065
6066         if ((dm & (D_CLOSED | D_LOCKED))) {
6067             add_herecmd_menuitem(win, doopen, "Open the door"), ++K;
6068             /* unfortunately there's no lknown flag for doors to
6069                remember the locked/unlocked state */
6070             key_or_pick = (carrying(SKELETON_KEY) || carrying(LOCK_PICK));
6071             card = (carrying(CREDIT_CARD) != 0);
6072             if (key_or_pick || card) {
6073                 Sprintf(buf, "%sunlock the door",
6074                         key_or_pick ? "lock or " : "");
6075                 add_herecmd_menuitem(win, doapply, upstart(buf)), ++K;
6076             }
6077             /* unfortunately there's no tknown flag for doors (or chests)
6078                to remember whether a trap had been found */
6079             add_herecmd_menuitem(win, dountrap,
6080                                  "Search the door for a trap"), ++K;
6081             /* [what about #force?] */
6082             add_herecmd_menuitem(win, dokick, "Kick the door"), ++K;
6083         } else if ((dm & D_ISOPEN)) {
6084             add_herecmd_menuitem(win, doclose, "Close the door"), ++K;
6085         }
6086     }
6087
6088     if (typ <= SCORR)
6089         add_herecmd_menuitem(win, dosearch, "Search for secret doors"), ++K;
6090
6091     if ((ttmp = t_at(x, y)) != 0 && ttmp->tseen) {
6092         add_herecmd_menuitem(win, doidtrap, "Examine trap"), ++K;
6093         if (ttmp->ttyp != VIBRATING_SQUARE)
6094             add_herecmd_menuitem(win, dountrap, "Attempt to disarm trap"), ++K;
6095     }
6096
6097     mtmp = m_at(x, y);
6098     if (mtmp && !canspotmon(mtmp))
6099         mtmp = 0;
6100     if (mtmp && which_armor(mtmp, W_SADDLE)) {
6101         char *mnam = x_monnam(mtmp, ARTICLE_THE, (char *) 0,
6102                               SUPPRESS_SADDLE, FALSE);
6103
6104         if (!u.usteed) {
6105             Sprintf(buf, "Ride %s", mnam);
6106             add_herecmd_menuitem(win, doride, buf), ++K;
6107         }
6108         Sprintf(buf, "Remove saddle from %s", mnam);
6109         add_herecmd_menuitem(win, doloot, buf), ++K;
6110     }
6111     if (mtmp && can_saddle(mtmp) && !which_armor(mtmp, W_SADDLE)
6112         && carrying(SADDLE)) {
6113         Sprintf(buf, "Put saddle on %s", mon_nam(mtmp)), ++K;
6114         add_herecmd_menuitem(win, doapply, buf);
6115     }
6116 #if 0
6117     if (mtmp || glyph_is_invisible(glyph_at(x, y))) {
6118         /* "Attack %s", mtmp ? mon_nam(mtmp) : "unseen creature" */
6119     } else {
6120         /* "Move %s", direction */
6121     }
6122 #endif
6123
6124     if (K) {
6125         end_menu(win, "What do you want to do?");
6126         npick = select_menu(win, PICK_ONE, &picks);
6127     } else {
6128         pline("No applicable actions.");
6129         npick = 0;
6130     }
6131     destroy_nhwindow(win);
6132     ch = '\0';
6133     if (npick > 0) {
6134         int NDECL((*func)) = picks->item.a_nfunc;
6135         free((genericptr_t) picks);
6136
6137         if (doit) {
6138             int ret = (*func)();
6139
6140             ch = (char) ret;
6141         } else {
6142             ch = cmd_from_func(func);
6143         }
6144     }
6145     return ch;
6146 }
6147
6148 STATIC_OVL char
6149 here_cmd_menu(doit)
6150 boolean doit;
6151 {
6152     winid win;
6153     char ch;
6154     char buf[BUFSZ];
6155     schar typ = levl[u.ux][u.uy].typ;
6156     int npick;
6157     menu_item *picks = (menu_item *) 0;
6158
6159     win = create_nhwindow(NHW_MENU);
6160     start_menu(win);
6161
6162     if (IS_FOUNTAIN(typ) || IS_SINK(typ)) {
6163         Sprintf(buf, "Drink from the %s",
6164                 defsyms[IS_FOUNTAIN(typ) ? S_fountain : S_sink].explanation);
6165         add_herecmd_menuitem(win, dodrink, buf);
6166     }
6167     if (IS_FOUNTAIN(typ))
6168         add_herecmd_menuitem(win, dodip,
6169                              "Dip something into the fountain");
6170     if (IS_THRONE(typ))
6171         add_herecmd_menuitem(win, dosit,
6172                              "Sit on the throne");
6173
6174     if ((u.ux == xupstair && u.uy == yupstair)
6175         || (u.ux == sstairs.sx && u.uy == sstairs.sy && sstairs.up)
6176         || (u.ux == xupladder && u.uy == yupladder)) {
6177         Sprintf(buf, "Go up the %s",
6178                 (u.ux == xupladder && u.uy == yupladder)
6179                 ? "ladder" : "stairs");
6180         add_herecmd_menuitem(win, doup, buf);
6181     }
6182     if ((u.ux == xdnstair && u.uy == ydnstair)
6183         || (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)
6184         || (u.ux == xdnladder && u.uy == ydnladder)) {
6185         Sprintf(buf, "Go down the %s",
6186                 (u.ux == xupladder && u.uy == yupladder)
6187                 ? "ladder" : "stairs");
6188         add_herecmd_menuitem(win, dodown, buf);
6189     }
6190     if (u.usteed) { /* another movement choice */
6191         Sprintf(buf, "Dismount %s",
6192                 x_monnam(u.usteed, ARTICLE_THE, (char *) 0,
6193                          SUPPRESS_SADDLE, FALSE));
6194         add_herecmd_menuitem(win, doride, buf);
6195     }
6196
6197 #if 0
6198     if (Upolyd) { /* before objects */
6199         Sprintf(buf, "Use %s special ability",
6200                 s_suffix(mons[u.umonnum].mname));
6201         add_herecmd_menuitem(win, domonability, buf);
6202     }
6203 #endif
6204
6205     if (OBJ_AT(u.ux, u.uy)) {
6206         struct obj *otmp = level.objects[u.ux][u.uy];
6207
6208         Sprintf(buf, "Pick up %s", otmp->nexthere ? "items" : doname(otmp));
6209         add_herecmd_menuitem(win, dopickup, buf);
6210
6211         if (Is_container(otmp)) {
6212             Sprintf(buf, "Loot %s", doname(otmp));
6213             add_herecmd_menuitem(win, doloot, buf);
6214         }
6215         if (otmp->oclass == FOOD_CLASS) {
6216             Sprintf(buf, "Eat %s", doname(otmp));
6217             add_herecmd_menuitem(win, doeat, buf);
6218         }
6219     }
6220
6221     if (invent)
6222         add_herecmd_menuitem(win, dodrop, "Drop items");
6223
6224     add_herecmd_menuitem(win, donull, "Rest one turn");
6225     add_herecmd_menuitem(win, dosearch, "Search around you");
6226     add_herecmd_menuitem(win, dolook, "Look at what is here");
6227
6228     end_menu(win, "What do you want to do?");
6229     npick = select_menu(win, PICK_ONE, &picks);
6230     destroy_nhwindow(win);
6231     ch = '\0';
6232     if (npick > 0) {
6233         int NDECL((*func)) = picks->item.a_nfunc;
6234         free((genericptr_t) picks);
6235
6236         if (doit) {
6237             int ret = (*func)();
6238
6239             ch = (char) ret;
6240         } else {
6241             ch = cmd_from_func(func);
6242         }
6243     }
6244     return ch;
6245 }
6246
6247
6248 static NEARDATA int last_multi;
6249
6250 /*
6251  * convert a MAP window position into a movecmd
6252  */
6253 const char *
6254 click_to_cmd(x, y, mod)
6255 int x, y, mod;
6256 {
6257     int dir;
6258     static char cmd[4];
6259     cmd[1] = 0;
6260
6261     if (iflags.clicklook && mod == CLICK_2) {
6262         clicklook_cc.x = x;
6263         clicklook_cc.y = y;
6264         cmd[0] = Cmd.spkeys[NHKF_CLICKLOOK];
6265         return cmd;
6266     }
6267
6268     x -= u.ux;
6269     y -= u.uy;
6270
6271     if (flags.travelcmd) {
6272         if (abs(x) <= 1 && abs(y) <= 1) {
6273             x = sgn(x), y = sgn(y);
6274         } else {
6275             u.tx = u.ux + x;
6276             u.ty = u.uy + y;
6277             cmd[0] = Cmd.spkeys[NHKF_TRAVEL];
6278             return cmd;
6279         }
6280
6281         if (x == 0 && y == 0) {
6282             if (iflags.herecmd_menu) {
6283                 cmd[0] = here_cmd_menu(FALSE);
6284                 return cmd;
6285             }
6286
6287             /* here */
6288             if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)
6289                 || IS_SINK(levl[u.ux][u.uy].typ)) {
6290                 cmd[0] = cmd_from_func(mod == CLICK_1 ? dodrink : dodip);
6291                 return cmd;
6292             } else if (IS_THRONE(levl[u.ux][u.uy].typ)) {
6293                 cmd[0] = cmd_from_func(dosit);
6294                 return cmd;
6295             } else if ((u.ux == xupstair && u.uy == yupstair)
6296                        || (u.ux == sstairs.sx && u.uy == sstairs.sy
6297                            && sstairs.up)
6298                        || (u.ux == xupladder && u.uy == yupladder)) {
6299                 cmd[0] = cmd_from_func(doup);
6300                 return cmd;
6301             } else if ((u.ux == xdnstair && u.uy == ydnstair)
6302                        || (u.ux == sstairs.sx && u.uy == sstairs.sy
6303                            && !sstairs.up)
6304                        || (u.ux == xdnladder && u.uy == ydnladder)) {
6305                 cmd[0] = cmd_from_func(dodown);
6306                 return cmd;
6307             } else if (OBJ_AT(u.ux, u.uy)) {
6308                 cmd[0] = cmd_from_func(Is_container(level.objects[u.ux][u.uy])
6309                                        ? doloot : dopickup);
6310                 return cmd;
6311             } else {
6312                 cmd[0] = cmd_from_func(donull); /* just rest */
6313                 return cmd;
6314             }
6315         }
6316
6317         /* directional commands */
6318
6319         dir = xytod(x, y);
6320
6321         if (!m_at(u.ux + x, u.uy + y)
6322             && !test_move(u.ux, u.uy, x, y, TEST_MOVE)) {
6323             cmd[1] = Cmd.dirchars[dir];
6324             cmd[2] = '\0';
6325             if (iflags.herecmd_menu) {
6326                 cmd[0] = there_cmd_menu(FALSE, u.ux + x, u.uy + y);
6327                 if (cmd[0] == '\0')
6328                     cmd[1] = '\0';
6329                 return cmd;
6330             }
6331
6332             if (IS_DOOR(levl[u.ux + x][u.uy + y].typ)) {
6333                 /* slight assistance to the player: choose kick/open for them
6334                  */
6335                 if (levl[u.ux + x][u.uy + y].doormask & D_LOCKED) {
6336                     cmd[0] = cmd_from_func(dokick);
6337                     return cmd;
6338                 }
6339                 if (levl[u.ux + x][u.uy + y].doormask & D_CLOSED) {
6340                     cmd[0] = cmd_from_func(doopen);
6341                     return cmd;
6342                 }
6343             }
6344             if (levl[u.ux + x][u.uy + y].typ <= SCORR) {
6345                 cmd[0] = cmd_from_func(dosearch);
6346                 cmd[1] = 0;
6347                 return cmd;
6348             }
6349         }
6350     } else {
6351         /* convert without using floating point, allowing sloppy clicking */
6352         if (x > 2 * abs(y))
6353             x = 1, y = 0;
6354         else if (y > 2 * abs(x))
6355             x = 0, y = 1;
6356         else if (x < -2 * abs(y))
6357             x = -1, y = 0;
6358         else if (y < -2 * abs(x))
6359             x = 0, y = -1;
6360         else
6361             x = sgn(x), y = sgn(y);
6362
6363         if (x == 0 && y == 0) {
6364             /* map click on player to "rest" command */
6365             cmd[0] = cmd_from_func(donull);
6366             return cmd;
6367         }
6368         dir = xytod(x, y);
6369     }
6370
6371     /* move, attack, etc. */
6372     cmd[1] = 0;
6373     if (mod == CLICK_1) {
6374         cmd[0] = Cmd.dirchars[dir];
6375     } else {
6376         cmd[0] = (Cmd.num_pad
6377                      ? M(Cmd.dirchars[dir])
6378                      : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */
6379     }
6380
6381     return cmd;
6382 }
6383
6384 char
6385 get_count(allowchars, inkey, maxcount, count, historical)
6386 char *allowchars;
6387 char inkey;
6388 long maxcount;
6389 long *count;
6390 boolean historical; /* whether to include in message history: True => yes */
6391 {
6392     char qbuf[QBUFSZ];
6393     int key;
6394     long cnt = 0L;
6395     boolean backspaced = FALSE;
6396     /* this should be done in port code so that we have erase_char
6397        and kill_char available; we can at least fake erase_char */
6398 #define STANDBY_erase_char '\177'
6399
6400     for (;;) {
6401         if (inkey) {
6402             key = inkey;
6403             inkey = '\0';
6404         } else
6405             key = readchar();
6406
6407         if (digit(key)) {
6408             cnt = 10L * cnt + (long) (key - '0');
6409             if (cnt < 0)
6410                 cnt = 0;
6411             else if (maxcount > 0 && cnt > maxcount)
6412                 cnt = maxcount;
6413         } else if (cnt && (key == '\b' || key == STANDBY_erase_char)) {
6414             cnt = cnt / 10;
6415             backspaced = TRUE;
6416         } else if (key == Cmd.spkeys[NHKF_ESC]) {
6417             break;
6418         } else if (!allowchars || index(allowchars, key)) {
6419             *count = cnt;
6420             break;
6421         }
6422
6423         if (cnt > 9 || backspaced) {
6424             clear_nhwindow(WIN_MESSAGE);
6425             if (backspaced && !cnt) {
6426 /*JP
6427                 Sprintf(qbuf, "Count: ");
6428 */
6429                 Sprintf(qbuf, "\90\94: ");
6430             } else {
6431 /*JP
6432                 Sprintf(qbuf, "Count: %ld", cnt);
6433 */
6434                 Sprintf(qbuf, "\90\94: %ld", cnt);
6435                 backspaced = FALSE;
6436             }
6437             /* bypassing pline() keeps intermediate prompt out of
6438                DUMPLOG message history */
6439             putstr(WIN_MESSAGE, 0, qbuf);
6440             mark_synch();
6441         }
6442     }
6443
6444     if (historical) {
6445 /*JP
6446         Sprintf(qbuf, "Count: %ld ", *count);
6447 */
6448         Sprintf(qbuf, "\90\94: %ld ", *count);
6449         (void) key2txt((uchar) key, eos(qbuf));
6450         putmsghistory(qbuf, FALSE);
6451     }
6452
6453     return key;
6454 }
6455
6456
6457 STATIC_OVL char *
6458 parse()
6459 {
6460 #ifdef LINT /* static char in_line[COLNO]; */
6461     char in_line[COLNO];
6462 #else
6463     static char in_line[COLNO];
6464 #endif
6465     register int foo;
6466     boolean prezero = FALSE;
6467
6468     iflags.in_parse = TRUE;
6469     multi = 0;
6470     context.move = 1;
6471     flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */
6472
6473 #ifdef ALTMETA
6474     alt_esc = iflags.altmeta; /* readchar() hack */
6475 #endif
6476     if (!Cmd.num_pad || (foo = readchar()) == Cmd.spkeys[NHKF_COUNT]) {
6477         long tmpmulti = multi;
6478
6479         foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti, FALSE);
6480         last_multi = multi = tmpmulti;
6481     }
6482 #ifdef ALTMETA
6483     alt_esc = FALSE; /* readchar() reset */
6484 #endif
6485
6486     if (foo == Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */
6487         clear_nhwindow(WIN_MESSAGE);
6488         multi = last_multi = 0;
6489     } else if (foo == Cmd.spkeys[NHKF_DOAGAIN] || in_doagain) {
6490         multi = last_multi;
6491     } else {
6492         last_multi = multi;
6493         savech(0); /* reset input queue */
6494         savech((char) foo);
6495     }
6496
6497     if (multi) {
6498         multi--;
6499         save_cm = in_line;
6500     } else {
6501         save_cm = (char *) 0;
6502     }
6503     /* in 3.4.3 this was in rhack(), where it was too late to handle M-5 */
6504     if (Cmd.pcHack_compat) {
6505         /* This handles very old inconsistent DOS/Windows behaviour
6506            in a different way: earlier, the keyboard handler mapped
6507            these, which caused counts to be strange when entered
6508            from the number pad. Now do not map them until here. */
6509         switch (foo) {
6510         case '5':
6511             foo = Cmd.spkeys[NHKF_RUSH];
6512             break;
6513         case M('5'):
6514             foo = Cmd.spkeys[NHKF_RUN];
6515             break;
6516         case M('0'):
6517             foo = Cmd.spkeys[NHKF_DOINV];
6518             break;
6519         default:
6520             break; /* as is */
6521         }
6522     }
6523
6524     in_line[0] = foo;
6525     in_line[1] = '\0';
6526     if (prefix_cmd(foo)) {
6527         foo = readchar();
6528         savech((char) foo);
6529         in_line[1] = foo;
6530         in_line[2] = 0;
6531     }
6532     clear_nhwindow(WIN_MESSAGE);
6533     if (prezero)
6534         in_line[0] = Cmd.spkeys[NHKF_ESC];
6535
6536     iflags.in_parse = FALSE;
6537     return in_line;
6538 }
6539
6540 #ifdef HANGUPHANDLING
6541 /* some very old systems, or descendents of such systems, expect signal
6542    handlers to have return type `int', but they don't actually inspect
6543    the return value so we should be safe using `void' unconditionally */
6544 /*ARGUSED*/
6545 void
6546 hangup(sig_unused) /* called as signal() handler, so sent at least one arg */
6547 int sig_unused UNUSED;
6548 {
6549     if (program_state.exiting)
6550         program_state.in_moveloop = 0;
6551     nhwindows_hangup();
6552 #ifdef SAFERHANGUP
6553     /* When using SAFERHANGUP, the done_hup flag it tested in rhack
6554        and a couple of other places; actual hangup handling occurs then.
6555        This is 'safer' because it disallows certain cheats and also
6556        protects against losing objects in the process of being thrown,
6557        but also potentially riskier because the disconnected program
6558        must continue running longer before attempting a hangup save. */
6559     program_state.done_hup++;
6560     /* defer hangup iff game appears to be in progress */
6561     if (program_state.in_moveloop && program_state.something_worth_saving)
6562         return;
6563 #endif /* SAFERHANGUP */
6564     end_of_input();
6565 }
6566
6567 void
6568 end_of_input()
6569 {
6570 #ifdef NOSAVEONHANGUP
6571 #ifdef INSURANCE
6572     if (flags.ins_chkpt && program_state.something_worth_saving)
6573         program_statue.preserve_locks = 1; /* keep files for recovery */
6574 #endif
6575     program_state.something_worth_saving = 0; /* don't save */
6576 #endif
6577
6578 #ifndef SAFERHANGUP
6579     if (!program_state.done_hup++)
6580 #endif
6581         if (program_state.something_worth_saving)
6582             (void) dosave0();
6583     if (iflags.window_inited)
6584         exit_nhwindows((char *) 0);
6585     clearlocks();
6586     nh_terminate(EXIT_SUCCESS);
6587     /*NOTREACHED*/ /* not necessarily true for vms... */
6588     return;
6589 }
6590 #endif /* HANGUPHANDLING */
6591
6592 char
6593 readchar()
6594 {
6595     register int sym;
6596     int x = u.ux, y = u.uy, mod = 0;
6597
6598     if (*readchar_queue)
6599         sym = *readchar_queue++;
6600     else
6601         sym = in_doagain ? pgetchar() : nh_poskey(&x, &y, &mod);
6602
6603 #ifdef NR_OF_EOFS
6604     if (sym == EOF) {
6605         register int cnt = NR_OF_EOFS;
6606         /*
6607          * Some SYSV systems seem to return EOFs for various reasons
6608          * (?like when one hits break or for interrupted systemcalls?),
6609          * and we must see several before we quit.
6610          */
6611         do {
6612             clearerr(stdin); /* omit if clearerr is undefined */
6613             sym = pgetchar();
6614         } while (--cnt && sym == EOF);
6615     }
6616 #endif /* NR_OF_EOFS */
6617
6618     if (sym == EOF) {
6619 #ifdef HANGUPHANDLING
6620         hangup(0); /* call end_of_input() or set program_state.done_hup */
6621 #endif
6622         sym = '\033';
6623 #ifdef ALTMETA
6624     } else if (sym == '\033' && alt_esc) {
6625         /* iflags.altmeta: treat two character ``ESC c'' as single `M-c' */
6626         sym = *readchar_queue ? *readchar_queue++ : pgetchar();
6627         if (sym == EOF || sym == 0)
6628             sym = '\033';
6629         else if (sym != '\033')
6630             sym |= 0200; /* force 8th bit on */
6631 #endif /*ALTMETA*/
6632     } else if (sym == 0) {
6633         /* click event */
6634         readchar_queue = click_to_cmd(x, y, mod);
6635         sym = *readchar_queue++;
6636     }
6637     return (char) sym;
6638 }
6639
6640 STATIC_PTR int
6641 dotravel(VOID_ARGS)
6642 {
6643     /* Keyboard travel command */
6644     static char cmd[2];
6645     coord cc;
6646
6647     if (!flags.travelcmd)
6648         return 0;
6649     cmd[1] = 0;
6650     cc.x = iflags.travelcc.x;
6651     cc.y = iflags.travelcc.y;
6652     if (cc.x == -1 && cc.y == -1) {
6653         /* No cached destination, start attempt from current position */
6654         cc.x = u.ux;
6655         cc.y = u.uy;
6656     }
6657     iflags.getloc_travelmode = TRUE;
6658     if (iflags.menu_requested) {
6659         int gf = iflags.getloc_filter;
6660         iflags.getloc_filter = GFILTER_VIEW;
6661         if (!getpos_menu(&cc, GLOC_INTERESTING)) {
6662             iflags.getloc_filter = gf;
6663             iflags.getloc_travelmode = FALSE;
6664             return 0;
6665         }
6666         iflags.getloc_filter = gf;
6667     } else {
6668 /*JP
6669     pline("Where do you want to travel to?");
6670 */
6671     pline("\82Ç\82±\82É\88Ú\93®\82·\82é\81H");
6672 /*JP
6673     if (getpos(&cc, TRUE, "the desired destination") < 0) {
6674 */
6675     if (getpos(&cc, TRUE, "\88Ú\93®\90æ") < 0) {
6676             /* user pressed ESC */
6677             iflags.getloc_travelmode = FALSE;
6678             return 0;
6679         }
6680     }
6681     iflags.getloc_travelmode = FALSE;
6682     iflags.travelcc.x = u.tx = cc.x;
6683     iflags.travelcc.y = u.ty = cc.y;
6684     cmd[0] = Cmd.spkeys[NHKF_TRAVEL];
6685     readchar_queue = cmd;
6686     return 0;
6687 }
6688
6689 #ifdef PORT_DEBUG
6690 extern void NDECL(win32con_debug_keystrokes);
6691 extern void NDECL(win32con_handler_info);
6692
6693 int
6694 wiz_port_debug()
6695 {
6696     int n, k;
6697     winid win;
6698     anything any;
6699     int item = 'a';
6700     int num_menu_selections;
6701     struct menu_selection_struct {
6702         char *menutext;
6703         void NDECL((*fn));
6704     } menu_selections[] = {
6705 #ifdef WIN32
6706         { "test win32 keystrokes (tty only)", win32con_debug_keystrokes },
6707         { "show keystroke handler information (tty only)",
6708           win32con_handler_info },
6709 #endif
6710         { (char *) 0, (void NDECL((*))) 0 } /* array terminator */
6711     };
6712
6713     num_menu_selections = SIZE(menu_selections) - 1;
6714     if (num_menu_selections > 0) {
6715         menu_item *pick_list;
6716
6717         win = create_nhwindow(NHW_MENU);
6718         start_menu(win);
6719         for (k = 0; k < num_menu_selections; ++k) {
6720             any.a_int = k + 1;
6721             add_menu(win, NO_GLYPH, &any, item++, 0, ATR_NONE,
6722                      menu_selections[k].menutext, MENU_UNSELECTED);
6723         }
6724         end_menu(win, "Which port debugging feature?");
6725         n = select_menu(win, PICK_ONE, &pick_list);
6726         destroy_nhwindow(win);
6727         if (n > 0) {
6728             n = pick_list[0].item.a_int - 1;
6729             free((genericptr_t) pick_list);
6730             /* execute the function */
6731             (*menu_selections[n].fn)();
6732         }
6733     } else
6734         pline("No port-specific debug capability defined.");
6735     return 0;
6736 }
6737 #endif /*PORT_DEBUG*/
6738
6739 /*
6740  *   Parameter validator for generic yes/no function to prevent
6741  *   the core from sending too long a prompt string to the
6742  *   window port causing a buffer overflow there.
6743  */
6744 char
6745 yn_function(query, resp, def)
6746 const char *query, *resp;
6747 char def;
6748 {
6749     char res, qbuf[QBUFSZ];
6750 #ifdef DUMPLOG
6751     extern unsigned saved_pline_index; /* pline.c */
6752     unsigned idx = saved_pline_index;
6753     /* buffer to hold query+space+formatted_single_char_response */
6754     char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */
6755 #endif
6756
6757     iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
6758
6759     /* maximum acceptable length is QBUFSZ-1 */
6760     if (strlen(query) >= QBUFSZ) {
6761         /* caller shouldn't have passed anything this long */
6762         paniclog("Query truncated: ", query);
6763         (void) strncpy(qbuf, query, QBUFSZ - 1 - 3);
6764         Strcpy(&qbuf[QBUFSZ - 1 - 3], "...");
6765         query = qbuf;
6766     }
6767     res = (*windowprocs.win_yn_function)(query, resp, def);
6768 #ifdef DUMPLOG
6769     if (idx == saved_pline_index) {
6770         /* when idx is still the same as saved_pline_index, the interface
6771            didn't put the prompt into saved_plines[]; we put a simplified
6772            version in there now (without response choices or default) */
6773         Sprintf(dumplog_buf, "%s ", query);
6774         (void) key2txt((uchar) res, eos(dumplog_buf));
6775         dumplogmsg(dumplog_buf);
6776     }
6777 #endif
6778     return res;
6779 }
6780
6781 /* for paranoid_confirm:quit,die,attack prompting */
6782 boolean
6783 paranoid_query(be_paranoid, prompt)
6784 boolean be_paranoid;
6785 const char *prompt;
6786 {
6787     boolean confirmed_ok;
6788
6789     /* when paranoid, player must respond with "yes" rather than just 'y'
6790        to give the go-ahead for this query; default is "no" unless the
6791        ParanoidConfirm flag is set in which case there's no default */
6792     if (be_paranoid) {
6793         char qbuf[QBUFSZ], ans[BUFSZ] = DUMMY;
6794         const char *promptprefix = "", *responsetype = ParanoidConfirm
6795                                                            ? "(yes|no)"
6796                                                            : "(yes) [no]";
6797         int trylimit = 6; /* 1 normal, 5 more with "Yes or No:" prefix */
6798
6799         /* in addition to being paranoid about this particular
6800            query, we might be even more paranoid about all paranoia
6801            responses (ie, ParanoidConfirm is set) in which case we
6802            require "no" to reject in addition to "yes" to confirm
6803            (except we won't loop if response is ESC; it means no) */
6804         do {
6805             Sprintf(qbuf, "%s%s %s", promptprefix, prompt, responsetype);
6806             getlin(qbuf, ans);
6807             (void) mungspaces(ans);
6808             confirmed_ok = !strcmpi(ans, "yes");
6809             if (confirmed_ok || *ans == '\033')
6810                 break;
6811             promptprefix = "\"Yes\" or \"No\": ";
6812         } while (ParanoidConfirm && strcmpi(ans, "no") && --trylimit);
6813     } else
6814         confirmed_ok = (yn(prompt) == 'y');
6815
6816     return confirmed_ok;
6817 }
6818
6819 int
6820 dosuspend_core()
6821 {
6822 #ifdef SUSPEND
6823     /* Does current window system support suspend? */
6824     if ((*windowprocs.win_can_suspend)()) {
6825         /* NB: SYSCF SHELLERS handled in port code. */
6826         dosuspend();
6827     } else
6828 #endif
6829 /*JP
6830         Norep("Suspend command not available.");
6831 */
6832         Norep("\92\86\92f\83R\83}\83\93\83h\82Í\97\98\97p\82Å\82«\82Ü\82¹\82ñ\81D");
6833     return 0;
6834 }
6835
6836 /*cmd.c*/