OSDN Git Service

patch src/
[jnethack/source.git] / src / engrave.c
1 /* NetHack 3.6  engrave.c       $NHDT-Date: 1445388915 2015/10/21 00:55:15 $  $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
8 /* JNetHack may be freely redistributed.  See license for details. */
9
10 #include "hack.h"
11 #include "lev.h"
12
13 STATIC_VAR NEARDATA struct engr *head_engr;
14
15 char *
16 random_engraving(outbuf)
17 char *outbuf;
18 {
19     const char *rumor;
20
21     /* a random engraving may come from the "rumors" file,
22        or from the "engrave" file (formerly in an array here) */
23     if (!rn2(4) || !(rumor = getrumor(0, outbuf, TRUE)) || !*rumor)
24         (void) get_rnd_text(ENGRAVEFILE, outbuf);
25
26     wipeout_text(outbuf, (int) (strlen(outbuf) / 4), 0);
27     return outbuf;
28 }
29
30 /* Partial rubouts for engraving characters. -3. */
31 static const struct {
32     char wipefrom;
33     const char *wipeto;
34 } rubouts[] = { { 'A', "^" },
35                 { 'B', "Pb[" },
36                 { 'C', "(" },
37                 { 'D', "|)[" },
38                 { 'E', "|FL[_" },
39                 { 'F', "|-" },
40                 { 'G', "C(" },
41                 { 'H', "|-" },
42                 { 'I', "|" },
43                 { 'K', "|<" },
44                 { 'L', "|_" },
45                 { 'M', "|" },
46                 { 'N', "|\\" },
47                 { 'O', "C(" },
48                 { 'P', "F" },
49                 { 'Q', "C(" },
50                 { 'R', "PF" },
51                 { 'T', "|" },
52                 { 'U', "J" },
53                 { 'V', "/\\" },
54                 { 'W', "V/\\" },
55                 { 'Z', "/" },
56                 { 'b', "|" },
57                 { 'd', "c|" },
58                 { 'e', "c" },
59                 { 'g', "c" },
60                 { 'h', "n" },
61                 { 'j', "i" },
62                 { 'k', "|" },
63                 { 'l', "|" },
64                 { 'm', "nr" },
65                 { 'n', "r" },
66                 { 'o', "c" },
67                 { 'q', "c" },
68                 { 'w', "v" },
69                 { 'y', "v" },
70                 { ':', "." },
71                 { ';', ",:" },
72                 { ',', "." },
73                 { '=', "-" },
74                 { '+', "-|" },
75                 { '*', "+" },
76                 { '@', "0" },
77                 { '0', "C(" },
78                 { '1', "|" },
79                 { '6', "o" },
80                 { '7', "/" },
81                 { '8', "3o" } };
82
83 /* degrade some of the characters in a string */
84 void
85 wipeout_text(engr, cnt, seed)
86 char *engr;
87 int cnt;
88 unsigned seed; /* for semi-controlled randomization */
89 {
90 #if 0 /*JP*/
91     char *s;
92 #else
93     unsigned char *s;
94 #endif
95     int i, j, nxt, use_rubout, lth = (int) strlen(engr);
96
97     if (lth && cnt > 0) {
98         while (cnt--) {
99             /* pick next character */
100             if (!seed) {
101                 /* random */
102                 nxt = rn2(lth);
103                 use_rubout = rn2(4);
104             } else {
105                 /* predictable; caller can reproduce the same sequence by
106                    supplying the same arguments later, or a pseudo-random
107                    sequence by varying any of them */
108                 nxt = seed % lth;
109                 seed *= 31, seed %= (BUFSZ - 1);
110                 use_rubout = seed & 3;
111             }
112 #if 0 /*JP*/
113             s = &engr[nxt];
114 #else /*JP: \93ú\96{\8cê\82Ì\8fê\8d\87\82Íjrubout()\82ð\8eg\82Á\82Ä\8fÁ\82·*/
115             if (!seed)
116                 j = rn2(2);
117             else {
118                 seed *= 31,  seed %= (BUFSZ-1);
119                 j = seed % 2;
120             }
121
122             if(jrubout(engr, nxt, use_rubout, j)){
123                 continue;
124             }
125
126             s = (unsigned char *)&engr[nxt];
127 #endif
128             if (*s == ' ')
129                 continue;
130
131             /* rub out unreadable & small punctuation marks */
132             if (index("?.,'`-|_", *s)) {
133                 *s = ' ';
134                 continue;
135             }
136
137             if (!use_rubout)
138                 i = SIZE(rubouts);
139             else
140                 for (i = 0; i < SIZE(rubouts); i++)
141                     if (*s == rubouts[i].wipefrom) {
142                         /*
143                          * Pick one of the substitutes at random.
144                          */
145                         if (!seed)
146                             j = rn2(strlen(rubouts[i].wipeto));
147                         else {
148                             seed *= 31, seed %= (BUFSZ - 1);
149                             j = seed % (strlen(rubouts[i].wipeto));
150                         }
151                         *s = rubouts[i].wipeto[j];
152                         break;
153                     }
154
155             /* didn't pick rubout; use '?' for unreadable character */
156             if (i == SIZE(rubouts))
157                 *s = '?';
158         }
159     }
160
161     /* trim trailing spaces */
162     while (lth && engr[lth - 1] == ' ')
163         engr[--lth] = '\0';
164 }
165
166 /* check whether hero can reach something at ground level */
167 boolean
168 can_reach_floor(check_pit)
169 boolean check_pit;
170 {
171     struct trap *t;
172
173     if (u.uswallow)
174         return FALSE;
175     /* Restricted/unskilled riders can't reach the floor */
176     if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
177         return FALSE;
178     if (check_pit && !Flying
179         && (t = t_at(u.ux, u.uy)) != 0 && uteetering_at_seen_pit(t))
180         return FALSE;
181
182     return (boolean) ((!Levitation || Is_airlevel(&u.uz)
183                        || Is_waterlevel(&u.uz))
184                       && (!u.uundetected || !is_hider(youmonst.data)
185                           || u.umonnum == PM_TRAPPER));
186 }
187
188 /* give a message after caller has determined that hero can't reach */
189 void
190 cant_reach_floor(x, y, up, check_pit)
191 int x, y;
192 boolean up, check_pit;
193 {
194     You("can't reach the %s.",
195         up ? ceiling(x, y)
196            : (check_pit && can_reach_floor(FALSE))
197                ? "bottom of the pit"
198                : surface(x, y));
199 }
200
201 const char *
202 surface(x, y)
203 register int x, y;
204 {
205     register struct rm *lev = &levl[x][y];
206
207     if (x == u.ux && y == u.uy && u.uswallow && is_animal(u.ustuck->data))
208 /*JP
209         return "maw";
210 */
211         return "\88Ý\91Ü";
212     else if (IS_AIR(lev->typ) && Is_airlevel(&u.uz))
213 /*JP
214         return "air";
215 */
216         return "\8bó\92\86";
217     else if (is_pool(x, y))
218 /*JP
219         return (Underwater && !Is_waterlevel(&u.uz)) ? "bottom" : "water";
220 */
221         return (Underwater && !Is_waterlevel(&u.uz)) ? "\90\85\82Ì\92ê" : "\90\85\92\86";
222     else if (is_ice(x, y))
223 /*JP
224         return "ice";
225 */
226         return "\95X";
227     else if (is_lava(x, y))
228 /*JP
229         return "lava";
230 */
231         return "\97n\8aâ";
232     else if (lev->typ == DRAWBRIDGE_DOWN)
233 /*JP
234         return "bridge";
235 */
236         return "\8b´";
237     else if (IS_ALTAR(levl[x][y].typ))
238 /*JP
239         return "altar";
240 */
241         return "\8dÕ\92d";
242     else if (IS_GRAVE(levl[x][y].typ))
243 /*JP
244         return "headstone";
245 */
246         return "\95æ\90Î";
247     else if (IS_FOUNTAIN(levl[x][y].typ))
248 /*JP
249         return "fountain";
250 */
251         return "\90ò";
252     else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz))
253              || IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR)
254 /*JP
255         return "floor";
256 */
257         return "\8f°";
258     else
259 /*JP
260         return "ground";
261 */
262         return "\92n\96Ê";
263 }
264
265 const char *
266 ceiling(x, y)
267 register int x, y;
268 {
269     register struct rm *lev = &levl[x][y];
270     const char *what;
271
272     /* other room types will no longer exist when we're interested --
273      * see check_special_room()
274      */
275     if (*in_rooms(x, y, VAULT))
276 /*JP
277         what = "vault's ceiling";
278 */
279         what = "\91q\8cÉ\82Ì\93V\88ä";
280     else if (*in_rooms(x, y, TEMPLE))
281 /*JP
282         what = "temple's ceiling";
283 */
284         what = "\8e\9b\89@\82Ì\93V\88ä";
285     else if (*in_rooms(x, y, SHOPBASE))
286 /*JP
287         what = "shop's ceiling";
288 */
289         what = "\93X\82Ì\93V\88ä";
290     else if (Is_waterlevel(&u.uz))
291         /* water plane has no surface; its air bubbles aren't below sky */
292 /*JP
293         what = "water above";
294 */
295         what = "\90\85\82Ì\8fã\95û";
296     else if (IS_AIR(lev->typ))
297 /*JP
298         what = "sky";
299 */
300         what = "\8bó";
301     else if (Underwater)
302 /*JP
303         what = "water's surface";
304 */
305         what = "\90\85\96Ê";
306     else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz))
307              || IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR)
308 /*JP
309         what = "ceiling";
310 */
311         what = "\93V\88ä";
312     else
313 /*JP
314         what = "rock cavern";
315 */
316         what = "\93´\8cA\82Ì\93V\88ä";
317
318     return what;
319 }
320
321 struct engr *
322 engr_at(x, y)
323 xchar x, y;
324 {
325     register struct engr *ep = head_engr;
326
327     while (ep) {
328         if (x == ep->engr_x && y == ep->engr_y)
329             return ep;
330         ep = ep->nxt_engr;
331     }
332     return (struct engr *) 0;
333 }
334
335 /* Decide whether a particular string is engraved at a specified
336  * location; a case-insensitive substring match is used.
337  * Ignore headstones, in case the player names herself "Elbereth".
338  *
339  * If strict checking is requested, the word is only considered to be
340  * present if it is intact and is the first word in the engraving.
341  * ("Elbereth burrito" matches; "o Elbereth" does not.)
342  */
343 int
344 sengr_at(s, x, y, strict)
345 const char *s;
346 xchar x, y;
347 boolean strict;
348 {
349     register struct engr *ep = engr_at(x, y);
350
351     if (ep && ep->engr_type != HEADSTONE && ep->engr_time <= moves) {
352         return strict ? (strncmpi(ep->engr_txt, s, strlen(s)) == 0)
353                       : (strstri(ep->engr_txt, s) != 0);
354     }
355     return FALSE;
356 }
357
358 void
359 u_wipe_engr(cnt)
360 int cnt;
361 {
362     if (can_reach_floor(TRUE))
363         wipe_engr_at(u.ux, u.uy, cnt, FALSE);
364 }
365
366 void
367 wipe_engr_at(x, y, cnt, magical)
368 xchar x, y, cnt, magical;
369 {
370     register struct engr *ep = engr_at(x, y);
371
372     /* Headstones are indelible */
373     if (ep && ep->engr_type != HEADSTONE) {
374         debugpline1("asked to erode %d characters", cnt);
375         if (ep->engr_type != BURN || is_ice(x, y) || (magical && !rn2(2))) {
376             if (ep->engr_type != DUST && ep->engr_type != ENGR_BLOOD) {
377                 cnt = rn2(1 + 50 / (cnt + 1)) ? 0 : 1;
378                 debugpline1("actually eroding %d characters", cnt);
379             }
380             wipeout_text(ep->engr_txt, (int) cnt, 0);
381             while (ep->engr_txt[0] == ' ')
382                 ep->engr_txt++;
383             if (!ep->engr_txt[0])
384                 del_engr(ep);
385         }
386     }
387 }
388
389 void
390 read_engr_at(x, y)
391 int x, y;
392 {
393     register struct engr *ep = engr_at(x, y);
394     int sensed = 0;
395     char buf[BUFSZ];
396
397     /* Sensing an engraving does not require sight,
398      * nor does it necessarily imply comprehension (literacy).
399      */
400     if (ep && ep->engr_txt[0]) {
401         switch (ep->engr_type) {
402         case DUST:
403             if (!Blind) {
404                 sensed = 1;
405 #if 0 /*JP*/
406                 pline("%s is written here in the %s.", Something,
407                       is_ice(x, y) ? "frost" : "dust");
408 #else
409                 pline("\89½\82©\82Ì\95\8e\9a\82ª%s\82É\8f\91\82¢\82Ä\82 \82é\81D",
410                       is_ice(x, y) ? "\91\9a" : "\82Ù\82±\82è");
411 #endif
412             }
413             break;
414         case ENGRAVE:
415         case HEADSTONE:
416             if (!Blind || can_reach_floor(TRUE)) {
417                 sensed = 1;
418 /*JP
419                 pline("%s is engraved here on the %s.", Something,
420 */
421                 pline("\89½\82©\82Ì\95\8e\9a\82ª%s\82É\8d\8f\82Ü\82ê\82Ä\82¢\82é\81D",
422                       surface(x, y));
423             }
424             break;
425         case BURN:
426             if (!Blind || can_reach_floor(TRUE)) {
427                 sensed = 1;
428 #if 0 /*JP*/
429                 pline("Some text has been %s into the %s here.",
430                       is_ice(x, y) ? "melted" : "burned", surface(x, y));
431 #else
432                 pline("\89½\82©\82Ì\95\8e\9a\82ª%s%s\82¢\82é\81D",
433                       surface(x,y),
434                       is_ice(x,y) ? "\82É\8d\8f\82Ü\82ê\82Ä" : "\82É\8fÄ\82«\95t\82¯\82ç\82ê\82Ä");
435 #endif
436             }
437             break;
438         case MARK:
439             if (!Blind) {
440                 sensed = 1;
441 /*JP
442                 pline("There's some graffiti on the %s here.", surface(x, y));
443 */
444                 pline("%s\82É\97\8e\8f\91\82ª\82 \82é\81D", surface(x,y));
445             }
446             break;
447         case ENGR_BLOOD:
448             /* "It's a message!  Scrawled in blood!"
449              * "What's it say?"
450              * "It says... `See you next Wednesday.'" -- Thriller
451              */
452             if (!Blind) {
453                 sensed = 1;
454 /*JP
455                 You_see("a message scrawled in blood here.");
456 */
457                 You("\8c\8c\95\8e\9a\82ª\82È\82®\82è\8f\91\82«\82³\82ê\82Ä\82¢\82é\82Ì\82ð\8c©\82Â\82¯\82½\81D");
458             }
459             break;
460         default:
461             impossible("%s is written in a very strange way.", Something);
462             sensed = 1;
463         }
464         if (sensed) {
465             char *et;
466 /*JP
467             unsigned maxelen = BUFSZ - sizeof("You feel the words: \"\". ");
468 */
469             unsigned maxelen = BUFSZ - sizeof("\82 \82È\82½\82Í\8e\9f\82Ì\82æ\82¤\82É\8a´\82\82½\81F\81u\81v");
470             if (strlen(ep->engr_txt) > maxelen) {
471                 (void) strncpy(buf, ep->engr_txt, (int) maxelen);
472                 buf[maxelen] = '\0';
473                 et = buf;
474             } else
475                 et = ep->engr_txt;
476 /*JP
477             You("%s: \"%s\".", (Blind) ? "feel the words" : "read", et);
478 */
479             You("%s\81F\81u%s\81v", (Blind) ? "\8e\9f\82Ì\82æ\82¤\82É\8a´\82\82½" : "\93Ç\82ñ\82¾",  et);
480             if (context.run > 1)
481                 nomul(0);
482         }
483     }
484 }
485
486 void
487 make_engr_at(x, y, s, e_time, e_type)
488 int x, y;
489 const char *s;
490 long e_time;
491 xchar e_type;
492 {
493     struct engr *ep;
494
495     if ((ep = engr_at(x, y)) != 0)
496         del_engr(ep);
497     ep = newengr(strlen(s) + 1);
498     ep->nxt_engr = head_engr;
499     head_engr = ep;
500     ep->engr_x = x;
501     ep->engr_y = y;
502     ep->engr_txt = (char *) (ep + 1);
503     Strcpy(ep->engr_txt, s);
504     /* engraving Elbereth shows wisdom */
505     if (!in_mklev && !strcmp(s, "Elbereth"))
506         exercise(A_WIS, TRUE);
507     ep->engr_time = e_time;
508     ep->engr_type = e_type > 0 ? e_type : rnd(N_ENGRAVE - 1);
509     ep->engr_lth = strlen(s) + 1;
510 }
511
512 /* delete any engraving at location <x,y> */
513 void
514 del_engr_at(x, y)
515 int x, y;
516 {
517     register struct engr *ep = engr_at(x, y);
518
519     if (ep)
520         del_engr(ep);
521 }
522
523 /*
524  *      freehand - returns true if player has a free hand
525  */
526 int
527 freehand()
528 {
529     return (!uwep || !welded(uwep)
530             || (!bimanual(uwep) && (!uarms || !uarms->cursed)));
531 }
532
533 static NEARDATA const char styluses[] = { ALL_CLASSES, ALLOW_NONE,
534                                           TOOL_CLASS,  WEAPON_CLASS,
535                                           WAND_CLASS,  GEM_CLASS,
536                                           RING_CLASS,  0 };
537
538 /* Mohs' Hardness Scale:
539  *  1 - Talc             6 - Orthoclase
540  *  2 - Gypsum           7 - Quartz
541  *  3 - Calcite          8 - Topaz
542  *  4 - Fluorite         9 - Corundum
543  *  5 - Apatite         10 - Diamond
544  *
545  * Since granite is an igneous rock hardness ~ 7, anything >= 8 should
546  * probably be able to scratch the rock.
547  * Devaluation of less hard gems is not easily possible because obj struct
548  * does not contain individual oc_cost currently. 7/91
549  *
550  * steel     -  5-8.5   (usu. weapon)
551  * diamond    - 10                      * jade       -  5-6      (nephrite)
552  * ruby       -  9      (corundum)      * turquoise  -  5-6
553  * sapphire   -  9      (corundum)      * opal       -  5-6
554  * topaz      -  8                      * glass      - ~5.5
555  * emerald    -  7.5-8  (beryl)         * dilithium  -  4-5??
556  * aquamarine -  7.5-8  (beryl)         * iron       -  4-5
557  * garnet     -  7.25   (var. 6.5-8)    * fluorite   -  4
558  * agate      -  7      (quartz)        * brass      -  3-4
559  * amethyst   -  7      (quartz)        * gold       -  2.5-3
560  * jasper     -  7      (quartz)        * silver     -  2.5-3
561  * onyx       -  7      (quartz)        * copper     -  2.5-3
562  * moonstone  -  6      (orthoclase)    * amber      -  2-2.5
563  */
564
565 /* return 1 if action took 1 (or more) moves, 0 if error or aborted */
566 int
567 doengrave()
568 {
569     boolean dengr = FALSE;    /* TRUE if we wipe out the current engraving */
570     boolean doblind = FALSE;  /* TRUE if engraving blinds the player */
571     boolean doknown = FALSE;  /* TRUE if we identify the stylus */
572     boolean eow = FALSE;      /* TRUE if we are overwriting oep */
573     boolean jello = FALSE;    /* TRUE if we are engraving in slime */
574     boolean ptext = TRUE;     /* TRUE if we must prompt for engrave text */
575     boolean teleengr = FALSE; /* TRUE if we move the old engraving */
576     boolean zapwand = FALSE;  /* TRUE if we remove a wand charge */
577     xchar type = DUST;        /* Type of engraving made */
578     char buf[BUFSZ];          /* Buffer for final/poly engraving text */
579     char ebuf[BUFSZ];         /* Buffer for initial engraving text */
580     char fbuf[BUFSZ];         /* Buffer for "your fingers" */
581     char qbuf[QBUFSZ];        /* Buffer for query text */
582     char post_engr_text[BUFSZ]; /* Text displayed after engraving prompt */
583     const char *everb;          /* Present tense of engraving type */
584     const char *eloc; /* Where the engraving is (ie dust/floor/...) */
585     char *sp;         /* Place holder for space count of engr text */
586     int len;          /* # of nonspace chars of new engraving text */
587     int maxelen;      /* Max allowable length of engraving text */
588     struct engr *oep = engr_at(u.ux, u.uy);
589     /* The current engraving */
590     struct obj *otmp; /* Object selected with which to engrave */
591     char *writer;
592
593     multi = 0;              /* moves consumed */
594     nomovemsg = (char *) 0; /* occupation end message */
595
596     buf[0] = (char) 0;
597     ebuf[0] = (char) 0;
598     post_engr_text[0] = (char) 0;
599     maxelen = BUFSZ - 1;
600     if (is_demon(youmonst.data) || youmonst.data->mlet == S_VAMPIRE)
601         type = ENGR_BLOOD;
602
603     /* Can the adventurer engrave at all? */
604
605     if (u.uswallow) {
606         if (is_animal(u.ustuck->data)) {
607 /*JP
608             pline("What would you write?  \"Jonah was here\"?");
609 */
610             pline("\89½\82ð\8f\91\82­\82ñ\82¾\82¢\81H\81u\83\88\83i\82Í\82±\82±\82É\82¢\82é\81v\81H");
611             return 0;
612         } else if (is_whirly(u.ustuck->data)) {
613             cant_reach_floor(u.ux, u.uy, FALSE, FALSE);
614             return 0;
615         } else
616             jello = TRUE;
617     } else if (is_lava(u.ux, u.uy)) {
618 /*JP
619         You_cant("write on the %s!", surface(u.ux, u.uy));
620 */
621         You("%s\82É\93Í\82©\82È\82¢\81D", surface(u.ux,u.uy));
622         return 0;
623     } else if (is_pool(u.ux, u.uy) || IS_FOUNTAIN(levl[u.ux][u.uy].typ)) {
624 /*JP
625         You_cant("write on the %s!", surface(u.ux, u.uy));
626 */
627         You("%s\82É\82Í\8f\91\82¯\82È\82¢\81I", surface(u.ux, u.uy));
628         return 0;
629     }
630     if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) /* in bubble */) {
631 /*JP
632         You_cant("write in thin air!");
633 */
634         You("\8bó\92\86\82É\82Í\8f\91\82¯\82È\82¢\81I");
635         return 0;
636     } else if (!accessible(u.ux, u.uy)) {
637         /* stone, tree, wall, secret corridor, pool, lava, bars */
638 /*JP
639         You_cant("write here.");
640 */
641         You_cant("\82±\82±\82É\82Í\8f\91\82¯\82È\82¢\81D");
642         return 0;
643     }
644     if (cantwield(youmonst.data)) {
645 /*JP
646         You_cant("even hold anything!");
647 */
648         You("\89½\82©\82ð\8e\9d\82Â\82±\82Æ\82·\82ç\82Å\82«\82È\82¢\81I");
649         return 0;
650     }
651     if (check_capacity((char *) 0))
652         return 0;
653
654     /* One may write with finger, or weapon, or wand, or..., or...
655      * Edited by GAN 10/20/86 so as not to change weapon wielded.
656      */
657
658     otmp = getobj(styluses, "write with");
659     if (!otmp) /* otmp == zeroobj if fingers */
660         return 0;
661
662     if (otmp == &zeroobj) {
663         Strcat(strcpy(fbuf, "your "), makeplural(body_part(FINGER)));
664         writer = fbuf;
665     } else
666         writer = yname(otmp);
667
668     /* There's no reason you should be able to write with a wand
669      * while both your hands are tied up.
670      */
671     if (!freehand() && otmp != uwep && !otmp->owornmask) {
672 /*JP
673         You("have no free %s to write with!", body_part(HAND));
674 */
675         pline("%s\82Ì\8e©\97R\82ª\8cø\82©\82È\82¢\82Ì\82Å\8f\91\82¯\82È\82¢\81I", body_part(HAND));
676         return 0;
677     }
678
679     if (jello) {
680 /*JP
681         You("tickle %s with %s.", mon_nam(u.ustuck), writer);
682 */
683                 You("%s\82Å%s\82ð\82­\82·\82®\82Á\82½\81D", writer, mon_nam(u.ustuck));
684 /*JP
685         Your("message dissolves...");
686 */
687                 Your("\83\81\83b\83Z\81[\83W\82Í\8fÁ\82¦\82½\81D\81D\81D");
688         return 0;
689     }
690     if (otmp->oclass != WAND_CLASS && !can_reach_floor(TRUE)) {
691         cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
692         return 0;
693     }
694     if (IS_ALTAR(levl[u.ux][u.uy].typ)) {
695 /*JP
696         You("make a motion towards the altar with %s.", writer);
697 */
698         You("%s\82ð\8eg\82Á\82Ä\8dÕ\92d\82É\8f\91\82±\82¤\82Æ\82µ\82½\81D", writer);
699         altar_wrath(u.ux, u.uy);
700         return 0;
701     }
702     if (IS_GRAVE(levl[u.ux][u.uy].typ)) {
703         if (otmp == &zeroobj) { /* using only finger */
704 /*JP
705             You("would only make a small smudge on the %s.",
706 */
707             You("\82Í%s\82É\8f¬\82³\82È\82µ\82Ý\82ð\82Â\82¯\82é\82±\82Æ\82µ\82©\82Å\82«\82È\82©\82Á\82½\81D",
708                 surface(u.ux, u.uy));
709             return 0;
710         } else if (!levl[u.ux][u.uy].disturbed) {
711 /*JP
712             You("disturb the undead!");
713 */
714             You("\95s\8e\80\82Ì\8eÒ\82Ì\96°\82è\82ð\96W\82°\82½\81I");
715             levl[u.ux][u.uy].disturbed = 1;
716             (void) makemon(&mons[PM_GHOUL], u.ux, u.uy, NO_MM_FLAGS);
717             exercise(A_WIS, FALSE);
718             return 1;
719         }
720     }
721
722     /* SPFX for items */
723
724     switch (otmp->oclass) {
725     default:
726     case AMULET_CLASS:
727     case CHAIN_CLASS:
728     case POTION_CLASS:
729     case COIN_CLASS:
730         break;
731     case RING_CLASS:
732         /* "diamond" rings and others should work */
733     case GEM_CLASS:
734         /* diamonds & other hard gems should work */
735         if (objects[otmp->otyp].oc_tough) {
736             type = ENGRAVE;
737             break;
738         }
739         break;
740     case ARMOR_CLASS:
741         if (is_boots(otmp)) {
742             type = DUST;
743             break;
744         }
745         /*FALLTHRU*/
746     /* Objects too large to engrave with */
747     case BALL_CLASS:
748     case ROCK_CLASS:
749 /*JP
750         You_cant("engrave with such a large object!");
751 */
752         pline("\82»\82ñ\82È\91å\82«\82È\82à\82Ì\82ð\8eg\82Á\82Ä\95\8e\9a\82ð\8d\8f\82ß\82È\82¢\81I");
753         ptext = FALSE;
754         break;
755     /* Objects too silly to engrave with */
756     case FOOD_CLASS:
757     case SCROLL_CLASS:
758     case SPBOOK_CLASS:
759 #if 0 /*JP*/
760         pline("%s would get %s.", Yname2(otmp),
761               is_ice(u.ux, u.uy) ? "all frosty" : "too dirty");
762 #else
763         Your("%s\82Í%s\82È\82Á\82½\81D", xname(otmp),
764              is_ice(u.ux,u.uy) ? "\91\9a\82¾\82ç\82¯\82É" : "\89\98\82È\82­");
765 #endif
766         ptext = FALSE;
767         break;
768     case RANDOM_CLASS: /* This should mean fingers */
769         break;
770
771     /* The charge is removed from the wand before prompting for
772      * the engraving text, because all kinds of setup decisions
773      * and pre-engraving messages are based upon knowing what type
774      * of engraving the wand is going to do.  Also, the player
775      * will have potentially seen "You wrest .." message, and
776      * therefore will know they are using a charge.
777      */
778     case WAND_CLASS:
779         if (zappable(otmp)) {
780             check_unpaid(otmp);
781             if (otmp->cursed && !rn2(WAND_BACKFIRE_CHANCE)) {
782                 wand_explode(otmp, 0);
783                 return 1;
784             }
785             zapwand = TRUE;
786             if (!can_reach_floor(TRUE))
787                 ptext = FALSE;
788
789             switch (otmp->otyp) {
790             /* DUST wands */
791             default:
792                 break;
793             /* NODIR wands */
794             case WAN_LIGHT:
795             case WAN_SECRET_DOOR_DETECTION:
796             case WAN_CREATE_MONSTER:
797             case WAN_WISHING:
798             case WAN_ENLIGHTENMENT:
799                 zapnodir(otmp);
800                 break;
801             /* IMMEDIATE wands */
802             /* If wand is "IMMEDIATE", remember to affect the
803              * previous engraving even if turning to dust.
804              */
805             case WAN_STRIKING:
806                 Strcpy(post_engr_text,
807 /*JP
808                     "The wand unsuccessfully fights your attempt to write!");
809 */
810                        "\82 \82È\82½\82ª\8f\91\82±\82¤\82Æ\82·\82é\82Æ\8fñ\82Í\92ï\8dR\82µ\82½\81I");
811                 break;
812             case WAN_SLOW_MONSTER:
813                 if (!Blind) {
814 /*JP
815                     Sprintf(post_engr_text, "The bugs on the %s slow down!",
816 */
817                     Sprintf(post_engr_text, "%s\82Ì\8fã\82Ì\92\8e\82Ì\93®\82«\82ª\92x\82­\82È\82Á\82½\81I",
818                             surface(u.ux, u.uy));
819                 }
820                 break;
821             case WAN_SPEED_MONSTER:
822                 if (!Blind) {
823 /*JP
824                     Sprintf(post_engr_text, "The bugs on the %s speed up!",
825 */
826                     Sprintf(post_engr_text, "%s\82Ì\8fã\82Ì\92\8e\82Ì\93®\82«\82ª\91¬\82­\82È\82Á\82½\81I",
827                             surface(u.ux, u.uy));
828                 }
829                 break;
830             case WAN_POLYMORPH:
831                 if (oep) {
832                     if (!Blind) {
833                         type = (xchar) 0; /* random */
834                         (void) random_engraving(buf);
835                     }
836                     dengr = TRUE;
837                 }
838                 break;
839             case WAN_NOTHING:
840             case WAN_UNDEAD_TURNING:
841             case WAN_OPENING:
842             case WAN_LOCKING:
843             case WAN_PROBING:
844                 break;
845             /* RAY wands */
846             case WAN_MAGIC_MISSILE:
847                 ptext = TRUE;
848                 if (!Blind) {
849                     Sprintf(post_engr_text,
850 /*JP
851                             "The %s is riddled by bullet holes!",
852 */
853                             "%s\82Í\8eU\92e\82Å\8d×\82©\82¢\8c\8a\82¾\82ç\82¯\82É\82È\82Á\82½\81I",
854                             surface(u.ux, u.uy));
855                 }
856                 break;
857             /* can't tell sleep from death - Eric Backus */
858             case WAN_SLEEP:
859             case WAN_DEATH:
860                 if (!Blind) {
861 /*JP
862                     Sprintf(post_engr_text, "The bugs on the %s stop moving!",
863 */
864                     Sprintf(post_engr_text, "%s\82Ì\8fã\82Ì\92\8e\82Ì\93®\82«\82ª\8e~\82Ü\82Á\82½\81I",
865                             surface(u.ux, u.uy));
866                 }
867                 break;
868             case WAN_COLD:
869                 if (!Blind)
870                     Strcpy(post_engr_text,
871 /*JP
872                            "A few ice cubes drop from the wand.");
873 */
874                            "\95X\82Ì\82©\82¯\82ç\82ª\8fñ\82©\82ç\82±\82Ú\82ê\97\8e\82¿\82½\81D");
875                 if (!oep || (oep->engr_type != BURN))
876                     break;
877             case WAN_CANCELLATION:
878             case WAN_MAKE_INVISIBLE:
879                 if (oep && oep->engr_type != HEADSTONE) {
880                     if (!Blind)
881 /*JP
882                         pline_The("engraving on the %s vanishes!",
883 */
884                         pline("%s\82Ì\8fã\82Ì\95\8e\9a\82Í\8fÁ\82¦\82½\81I",
885                                   surface(u.ux, u.uy));
886                     dengr = TRUE;
887                 }
888                 break;
889             case WAN_TELEPORTATION:
890                 if (oep && oep->engr_type != HEADSTONE) {
891                     if (!Blind)
892 /*JP
893                         pline_The("engraving on the %s vanishes!",
894 */
895                         pline("%s\82Ì\8fã\82Ì\95\8e\9a\82Í\8fÁ\82¦\82½\81I",
896                                   surface(u.ux, u.uy));
897                     teleengr = TRUE;
898                 }
899                 break;
900             /* type = ENGRAVE wands */
901             case WAN_DIGGING:
902                 ptext = TRUE;
903                 type = ENGRAVE;
904                 if (!objects[otmp->otyp].oc_name_known) {
905                     if (flags.verbose)
906 /*JP
907                         pline("This %s is a wand of digging!", xname(otmp));
908 */
909                         pline("\82±\82ê\82Í\8c\8a\8c@\82è\82Ì\8fñ\82¾\81I");
910                     doknown = TRUE;
911                 }
912 #if 0 /*JP*/
913                 Strcpy(post_engr_text,
914                        Blind
915                           ? "You hear drilling!"
916                           : IS_GRAVE(levl[u.ux][u.uy].typ)
917                              ? "Chips fly out from the headstone."
918                              : is_ice(u.ux, u.uy)
919                                 ? "Ice chips fly up from the ice surface!"
920                                 : (level.locations[u.ux][u.uy].typ
921                                    == DRAWBRIDGE_DOWN)
922                                    ? "Splinters fly up from the bridge."
923                                    : "Gravel flies up from the floor.");
924 #else
925                 Strcpy(post_engr_text,
926                        Blind
927                           ? "\8c\8a\82ª\8aJ\82­\89¹\82ð\95·\82¢\82½\81I"
928                           : IS_GRAVE(levl[u.ux][u.uy].typ)
929                              ? "\95æ\90Î\82©\82ç\94j\95Ð\82ª\94ò\82Ñ\8eU\82Á\82½\81D"
930                              : is_ice(u.ux,u.uy)
931                                 ? "\95X\82Ì\95\\96Ê\82©\82ç\95X\82Ì\82©\82¯\82ç\82ª\94ò\82Ñ\8eU\82Á\82½\81D"
932                                 : (level.locations[u.ux][u.uy].typ
933                                    == DRAWBRIDGE_DOWN)
934                                    ? "\94j\95Ð\82ª\8b´\82©\82ç\95\91\82¢\82 \82ª\82Á\82½\81D"
935                                    : "\8d»\97\98\82ª\8f°\82©\82ç\94ò\82Ñ\8eU\82Á\82½\81D");
936 #endif
937                 break;
938             /* type = BURN wands */
939             case WAN_FIRE:
940                 ptext = TRUE;
941                 type = BURN;
942                 if (!objects[otmp->otyp].oc_name_known) {
943                     if (flags.verbose)
944 /*JP
945                         pline("This %s is a wand of fire!", xname(otmp));
946 */
947                         pline("\82±\82ê\82Í\89\8a\82Ì\8fñ\82¾\81I");
948                     doknown = TRUE;
949                 }
950 #if 0 /*JP*/
951                 Strcpy(post_engr_text, Blind ? "You feel the wand heat up."
952                                              : "Flames fly from the wand.");
953 #else
954                 Strcpy(post_engr_text, Blind ? "\8fñ\82ª\92g\82©\82­\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D"
955                                              : "\89\8a\82ª\8fñ\82©\82ç\94ò\82Ñ\8eU\82Á\82½\81D");
956 #endif
957                 break;
958             case WAN_LIGHTNING:
959                 ptext = TRUE;
960                 type = BURN;
961                 if (!objects[otmp->otyp].oc_name_known) {
962                     if (flags.verbose)
963 /*JP
964                         pline("This %s is a wand of lightning!", xname(otmp));
965 */
966                         pline("\82±\82ê\82Í\97\8b\82Ì\8fñ\82¾\81I");
967                     doknown = TRUE;
968                 }
969                 if (!Blind) {
970 /*JP
971                     Strcpy(post_engr_text, "Lightning arcs from the wand.");
972 */
973                     Strcpy(post_engr_text, "\89Î\89Ô\82ª\8fñ\82©\82ç\94ò\82Ñ\8eU\82Á\82½\81D");
974                     doblind = TRUE;
975                 } else
976 /*JP
977                     Strcpy(post_engr_text, "You hear crackling!");
978 */
979                     Strcpy(post_engr_text, "\83p\83`\83p\83`\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81I");
980                 break;
981
982             /* type = MARK wands */
983             /* type = ENGR_BLOOD wands */
984             }
985         } else { /* end if zappable */
986             /* failing to wrest one last charge takes time */
987             ptext = FALSE; /* use "early exit" below, return 1 */
988             /* give feedback here if we won't be getting the
989                "can't reach floor" message below */
990             if (can_reach_floor(TRUE)) {
991                 /* cancelled wand turns to dust */
992                 if (otmp->spe < 0)
993                     zapwand = TRUE;
994                 /* empty wand just doesn't write */
995                 else
996 /*JP
997                     pline_The("wand is too worn out to engrave.");
998 */
999                     pline_The("\8fñ\82Í\95\8e\9a\82ð\8d\8f\82Þ\82É\82Í\8eg\82¢\82·\82¬\82Ä\82¢\82é\81D");
1000             }
1001         }
1002         break;
1003
1004     case WEAPON_CLASS:
1005         if (is_blade(otmp)) {
1006             if ((int) otmp->spe > -3)
1007                 type = ENGRAVE;
1008             else
1009 /*JP
1010                 pline("%s too dull for engraving.", Yobjnam2(otmp, "are"));
1011 */
1012                 pline("%s\82Í\90n\82ª\83{\83\8d\83{\83\8d\82Å\81C\95\8e\9a\82ð\92¤\82ê\82È\82¢\81D", xname(otmp));
1013         }
1014         break;
1015
1016     case TOOL_CLASS:
1017         if (otmp == ublindf) {
1018             pline(
1019 /*JP
1020                 "That is a bit difficult to engrave with, don't you think?");
1021 */
1022                 "\82¿\82å\82Á\82Æ\82»\82ê\82Å\92¤\82é\82Ì\82Í\91å\95Ï\82¾\82ë\82¤\81C\82»\82¤\8ev\82í\82È\82¢\81H");
1023             return 0;
1024         }
1025         switch (otmp->otyp) {
1026         case MAGIC_MARKER:
1027             if (otmp->spe <= 0)
1028 /*JP
1029                 Your("marker has dried out.");
1030 */
1031                 Your("\83}\81[\83J\82Í\8a£\82«\82«\82Á\82½\81D");
1032             else
1033                 type = MARK;
1034             break;
1035         case TOWEL:
1036             /* Can't really engrave with a towel */
1037             ptext = FALSE;
1038             if (oep)
1039                 if (oep->engr_type == DUST
1040                     || oep->engr_type == ENGR_BLOOD
1041                     || oep->engr_type == MARK) {
1042                     if (is_wet_towel(otmp))
1043                         dry_a_towel(otmp, -1, TRUE);
1044                     if (!Blind)
1045 /*JP
1046                         You("wipe out the message here.");
1047 */
1048                         You("\83\81\83b\83Z\81[\83W\82ð\90@\82«\82Æ\82Á\82½\81D");
1049                     else
1050 #if 0 /*JP*/
1051                         pline("%s %s.", Yobjnam2(otmp, "get"),
1052                               is_ice(u.ux, u.uy) ? "frosty" : "dusty");
1053 #else
1054                         pline("%s\82Í%s\82É\82È\82Á\82½\81D", xname(otmp),
1055                               is_ice(u.ux,u.uy) ? "\91\9a\82¾\82ç\82¯" : "\82Ù\82±\82è\82Ü\82Ý\82ê");
1056 #endif
1057                     dengr = TRUE;
1058                 } else
1059 /*JP
1060                     pline("%s can't wipe out this engraving.", Yname2(otmp));
1061 */
1062                     pline("\82±\82Ì\95\8e\9a\82Í%s\82Å\82Í\90@\82«\82Æ\82ê\82È\82¢\81D", xname(otmp));
1063             else
1064 #if 0 /*JP*/
1065                 pline("%s %s.", Yobjnam2(otmp, "get"),
1066                       is_ice(u.ux, u.uy) ? "frosty" : "dusty");
1067 #else
1068                 pline("%s\82Í%s\82É\82È\82Á\82½\81D", xname(otmp),
1069                       is_ice(u.ux,u.uy) ? "\91\9a\82¾\82ç\82¯" : "\82Ù\82±\82è\82Ü\82Ý\82ê");
1070 #endif
1071             break;
1072         default:
1073             break;
1074         }
1075         break;
1076
1077     case VENOM_CLASS:
1078         if (wizard) {
1079 /*JP
1080             pline("Writing a poison pen letter??");
1081 */
1082             pline("\82Ó\82Þ\81D\82±\82ê\82±\82»\96{\93\96\82Ì\93Å\90ã\82¾\81D");
1083             break;
1084         }
1085         /*FALLTHRU*/
1086     case ILLOBJ_CLASS:
1087         impossible("You're engraving with an illegal object!");
1088         break;
1089     }
1090
1091     if (IS_GRAVE(levl[u.ux][u.uy].typ)) {
1092         if (type == ENGRAVE || type == 0) {
1093             type = HEADSTONE;
1094         } else {
1095             /* ensures the "cannot wipe out" case */
1096             type = DUST;
1097             dengr = FALSE;
1098             teleengr = FALSE;
1099             buf[0] = '\0';
1100         }
1101     }
1102
1103     /*
1104      * End of implement setup
1105      */
1106
1107     /* Identify stylus */
1108     if (doknown) {
1109         learnwand(otmp);
1110         if (objects[otmp->otyp].oc_name_known)
1111             more_experienced(0, 10);
1112     }
1113     if (teleengr) {
1114         rloc_engr(oep);
1115         oep = (struct engr *) 0;
1116     }
1117     if (dengr) {
1118         del_engr(oep);
1119         oep = (struct engr *) 0;
1120     }
1121     /* Something has changed the engraving here */
1122     if (*buf) {
1123         make_engr_at(u.ux, u.uy, buf, moves, type);
1124 /*JP
1125         pline_The("engraving now reads: \"%s\".", buf);
1126 */
1127         pline("\8d\8f\82Ü\82ê\82½\95\8e\9a\82ð\93Ç\82ñ\82¾\81F\81u%s\81v\81D", buf);
1128         ptext = FALSE;
1129     }
1130     if (zapwand && (otmp->spe < 0)) {
1131 #if 0 /*JP*/
1132         pline("%s %sturns to dust.", The(xname(otmp)),
1133               Blind ? "" : "glows violently, then ");
1134 #else
1135         pline("%s\82Í%s\82¿\82è\82Æ\82È\82Á\82½\81D", xname(otmp),
1136               Blind ? "" : "\8c\83\82µ\82­\8bP\82«\81C");
1137 #endif
1138         if (!IS_GRAVE(levl[u.ux][u.uy].typ))
1139 #if 0 /*JP*/
1140             You(
1141     "are not going to get anywhere trying to write in the %s with your dust.",
1142                 is_ice(u.ux, u.uy) ? "frost" : "dust");
1143 #else
1144             You(
1145                 "\90o\82Å%s\82É\89½\82©\8f\91\82±\82¤\82Æ\82µ\82½\82ª\81C\82Å\82«\82È\82©\82Á\82½\81D",
1146                 is_ice(u.ux,u.uy) ? "\95X" : "\82Ù\82±\82è");
1147 #endif
1148         useup(otmp);
1149         otmp = 0; /* wand is now gone */
1150         ptext = FALSE;
1151     }
1152     /* Early exit for some implements. */
1153     if (!ptext) {
1154         if (otmp && otmp->oclass == WAND_CLASS && !can_reach_floor(TRUE))
1155             cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
1156         return 1;
1157     }
1158     /*
1159      * Special effects should have deleted the current engraving (if
1160      * possible) by now.
1161      */
1162     if (oep) {
1163         register char c = 'n';
1164
1165         /* Give player the choice to add to engraving. */
1166         if (type == HEADSTONE) {
1167             /* no choice, only append */
1168             c = 'y';
1169         } else if (type == oep->engr_type
1170                    && (!Blind || oep->engr_type == BURN
1171                        || oep->engr_type == ENGRAVE)) {
1172 /*JP
1173             c = yn_function("Do you want to add to the current engraving?",
1174 */
1175             c = yn_function("\89½\82©\8f\91\82«\89Á\82¦\82Ü\82·\82©\81H",
1176                             ynqchars, 'y');
1177             if (c == 'q') {
1178                 pline1(Never_mind);
1179                 return 0;
1180             }
1181         }
1182
1183         if (c == 'n' || Blind) {
1184             if (oep->engr_type == DUST
1185                 || oep->engr_type == ENGR_BLOOD
1186                 || oep->engr_type == MARK) {
1187                 if (!Blind) {
1188 #if 0 /*JP*/
1189                     You("wipe out the message that was %s here.",
1190                         (oep->engr_type == DUST)
1191                             ? "written in the dust"
1192                             : (oep->engr_type == ENGR_BLOOD)
1193                                 ? "scrawled in blood"
1194                                 : "written");
1195 #else
1196                     You("%s\83\81\83b\83Z\81[\83W\82ð\90@\82«\82Æ\82Á\82½\81D",
1197                         (oep->engr_type == DUST)
1198                             ? "\82Ù\82±\82è\82É\8f\91\82©\82ê\82Ä\82¢\82é"
1199                             : (oep->engr_type == BLOOD)
1200                                 ? "\8c\8c\95\8e\9a\82Å\82È\82®\82è\8f\91\82«\82³\82ê\82Ä\82¢\82é"
1201                                 : "\8f\91\82©\82ê\82Ä\82¢\82é");
1202 #endif
1203                     del_engr(oep);
1204                     oep = (struct engr *) 0;
1205                 } else
1206                     /* Don't delete engr until after we *know* we're engraving
1207                      */
1208                     eow = TRUE;
1209             } else if (type == DUST || type == MARK || type == ENGR_BLOOD) {
1210 #if 0 /*JP*/
1211                 You("cannot wipe out the message that is %s the %s here.",
1212                     oep->engr_type == BURN
1213                         ? (is_ice(u.ux, u.uy) ? "melted into" : "burned into")
1214                         : "engraved in",
1215                     surface(u.ux, u.uy));
1216 #else
1217                 You("%s\83\81\83b\83Z\81[\83W\82ð\90@\82«\82Æ\82ê\82È\82©\82Á\82½\81D",
1218                     oep->engr_type == BURN
1219                         ? (is_ice(u.ux, u.uy) ? "\8d\8f\82Ü\82ê\82Ä\82¢\82é" : "\8fÄ\82«\95t\82¯\82ç\82ê\82Ä\82¢\82é")
1220                         : "\8d\8f\82Ü\82ê\82Ä\82¢\82é");
1221 #endif
1222                 return 1;
1223             } else if (type != oep->engr_type || c == 'n') {
1224                 if (!Blind || can_reach_floor(TRUE))
1225 /*JP
1226                     You("will overwrite the current message.");
1227 */
1228                     You("\83\81\83b\83Z\81[\83W\82ð\8fã\8f\91\82«\82µ\82æ\82¤\82Æ\82µ\82½\81D");
1229                 eow = TRUE;
1230             }
1231         }
1232     }
1233
1234     eloc = surface(u.ux, u.uy);
1235     switch (type) {
1236     default:
1237 /*JP
1238         everb = (oep && !eow ? "add to the weird writing on"
1239 */
1240         everb = (oep && !eow ? "\8aï\96­\82È\95\8e\9a\97ñ\82É\8f\91\82«\89Á\82¦\82é"
1241 /*JP
1242                              : "write strangely on");
1243 */
1244                              : "\8aï\96­\82È\95\8e\9a\97ñ\82ð\8f\91\82­");
1245         break;
1246     case DUST:
1247 /*JP
1248         everb = (oep && !eow ? "add to the writing in" : "write in");
1249 */
1250         everb = (oep && !eow ? "\8f\91\82«\89Á\82¦\82é" : "\8f\91\82­");
1251 /*JP
1252         eloc = is_ice(u.ux, u.uy) ? "frost" : "dust";
1253 */
1254         eloc = is_ice(u.ux,u.uy) ? "\91\9a" : "\82Ù\82±\82è";
1255         break;
1256     case HEADSTONE:
1257 /*JP
1258         everb = (oep && !eow ? "add to the epitaph on" : "engrave on");
1259 */
1260         everb = (oep && !eow ? "\95æ\94è\96Á\82ð\8d\8f\82Ý\89Á\82¦\82é" : "\95æ\94è\96Á\82ð\8d\8f\82Þ");
1261         break;
1262     case ENGRAVE:
1263 /*JP
1264         everb = (oep && !eow ? "add to the engraving in" : "engrave in");
1265 */
1266         everb = (oep && !eow ? "\8d\8f\82Ý\89Á\82¦\82é" : "\8d\8f\82Þ");
1267         break;
1268     case BURN:
1269 #if 0 /*JP*/
1270         everb = (oep && !eow
1271                      ? (is_ice(u.ux, u.uy) ? "add to the text melted into"
1272                                            : "add to the text burned into")
1273                      : (is_ice(u.ux, u.uy) ? "melt into" : "burn into"));
1274 #else
1275         everb = (oep && !eow
1276                  ? ( is_ice(u.ux,u.uy) ? "\8d\8f\82Ý\89Á\82¦\82é"
1277                                        : "\94R\82¦\82Ä\82¢\82é\95\8e\9a\82É\8f\91\82«\89Á\82¦\82é")
1278                  : ( is_ice(u.ux,u.uy) ? "\8d\8f\82Þ" : "\8fÄ\88ó\82ð\82¢\82ê\82é"));
1279 #endif
1280         break;
1281     case MARK:
1282 /*JP
1283         everb = (oep && !eow ? "add to the graffiti on" : "scribble on");
1284 */
1285         everb = (oep && !eow ? "\97\8e\8f\91\82É\8f\91\82«\89Á\82¦\82é" : "\82Í\82µ\82è\8f\91\82«\82·\82é");
1286         break;
1287     case ENGR_BLOOD:
1288 /*JP
1289         everb = (oep && !eow ? "add to the scrawl on" : "scrawl on");
1290 */
1291         everb = (oep && !eow ? "\82È\82®\82è\8f\91\82«\82É\8f\91\82«\89Á\82¦\82é" : "\82È\82®\82è\8f\91\82«\82·\82é");
1292         break;
1293     }
1294
1295     /* Tell adventurer what is going on */
1296     if (otmp != &zeroobj)
1297 /*JP
1298         You("%s the %s with %s.", everb, eloc, doname(otmp));
1299 */
1300         You("%s\82Å%s\82É%s\81D", doname(otmp), eloc, jpast(everb));
1301     else
1302 #if 0 /*JP*/
1303         You("%s the %s with your %s.", everb, eloc,
1304             makeplural(body_part(FINGER)));
1305 #else
1306         You("%s\82Å%s\82É%s\81D", body_part(FINGER),
1307             eloc, jpast(everb));
1308 #endif
1309
1310     /* Prompt for engraving! */
1311 /*JP
1312     Sprintf(qbuf, "What do you want to %s the %s here?", everb, eloc);
1313 */
1314     Sprintf(qbuf,"%s\82É\89½\82Æ%s\82©\81H", eloc, jpolite(everb));
1315     getlin(qbuf, ebuf);
1316     /* convert tabs to spaces and condense consecutive spaces to one */
1317     mungspaces(ebuf);
1318
1319     /* Count the actual # of chars engraved not including spaces */
1320     len = strlen(ebuf);
1321     for (sp = ebuf; *sp; sp++)
1322         if (*sp == ' ')
1323             len -= 1;
1324
1325     if (len == 0 || index(ebuf, '\033')) {
1326         if (zapwand) {
1327             if (!Blind)
1328 #if 0 /*JP*/
1329                 pline("%s, then %s.", Tobjnam(otmp, "glow"),
1330                       otense(otmp, "fade"));
1331 #else
1332                 pline("%s\82Í\8bP\82¢\82½\82ª\81C\82·\82®\82É\8fÁ\82¦\82½\81D", xname(otmp));
1333 #endif
1334             return 1;
1335         } else {
1336             pline1(Never_mind);
1337             return 0;
1338         }
1339     }
1340
1341     /* A single `x' is the traditional signature of an illiterate person */
1342     if (len != 1 || (!index(ebuf, 'x') && !index(ebuf, 'X')))
1343         u.uconduct.literate++;
1344
1345     /* Mix up engraving if surface or state of mind is unsound.
1346        Note: this won't add or remove any spaces. */
1347     for (sp = ebuf; *sp; sp++) {
1348         if (*sp == ' ')
1349             continue;
1350         if (((type == DUST || type == ENGR_BLOOD) && !rn2(25))
1351             || (Blind && !rn2(11)) || (Confusion && !rn2(7))
1352             || (Stunned && !rn2(4)) || (Hallucination && !rn2(2)))
1353 #if 0 /*JP*/
1354             *sp = ' ' + rnd(96 - 2); /* ASCII '!' thru '~'
1355                                         (excludes ' ' and DEL) */
1356 #else /*JP:\93ú\96{\8cê\82Å\83\89\83\93\83_\83\80\89» */
1357             {
1358                 if(is_kanji1(ebuf, sp-ebuf))
1359                     jrndm_replace(sp);
1360                 else if(is_kanji2(ebuf, sp-ebuf))
1361                     jrndm_replace(sp-1);
1362                 else
1363                     *sp = '!' + rn2(93); /* ASCII-code only */
1364             }
1365 #endif
1366     }
1367
1368     /* Previous engraving is overwritten */
1369     if (eow) {
1370         del_engr(oep);
1371         oep = (struct engr *) 0;
1372     }
1373
1374     /* Figure out how long it took to engrave, and if player has
1375      * engraved too much.
1376      */
1377     switch (type) {
1378     default:
1379         multi = -(len / 10);
1380         if (multi)
1381 /*JP
1382             nomovemsg = "You finish your weird engraving.";
1383 */
1384             nomovemsg = "\82 \82È\82½\82Í\8aï\96­\82È\8d\8f\82Ý\82ð\8fI\82¦\82½\81D";
1385         break;
1386     case DUST:
1387         multi = -(len / 10);
1388         if (multi)
1389 /*JP
1390             nomovemsg = "You finish writing in the dust.";
1391 */
1392             nomovemsg = "\82 \82È\82½\82Í\82Ù\82±\82è\82É\8f\91\82«\8fI\82¦\82½\81D";
1393         break;
1394     case HEADSTONE:
1395     case ENGRAVE:
1396         multi = -(len / 10);
1397         if (otmp->oclass == WEAPON_CLASS
1398             && (otmp->otyp != ATHAME || otmp->cursed)) {
1399             multi = -len;
1400             maxelen = ((otmp->spe + 3) * 2) + 1;
1401             /* -2 => 3, -1 => 5, 0 => 7, +1 => 9, +2 => 11
1402              * Note: this does not allow a +0 anything (except an athame)
1403              * to engrave "Elbereth" all at once.
1404              * However, you can engrave "Elb", then "ere", then "th".
1405              */
1406 /*JP
1407             pline("%s dull.", Yobjnam2(otmp, "get"));
1408 */
1409             Your("%s\82Í\90n\82±\82Ú\82ê\82µ\82½\81D", xname(otmp));
1410             costly_alteration(otmp, COST_DEGRD);
1411             if (len > maxelen) {
1412                 multi = -maxelen;
1413                 otmp->spe = -3;
1414             } else if (len > 1)
1415                 otmp->spe -= len >> 1;
1416             else
1417                 otmp->spe -= 1; /* Prevent infinite engraving */
1418         } else if (otmp->oclass == RING_CLASS || otmp->oclass == GEM_CLASS) {
1419             multi = -len;
1420         }
1421         if (multi)
1422 /*JP
1423             nomovemsg = "You finish engraving.";
1424 */
1425             nomovemsg = "\82 \82È\82½\82Í\8d\8f\82Ý\8fI\82¦\82½\81D";
1426         break;
1427     case BURN:
1428         multi = -(len / 10);
1429         if (multi)
1430             nomovemsg = is_ice(u.ux, u.uy)
1431 /*JP
1432                           ? "You finish melting your message into the ice."
1433 */
1434                           ? "\95X\82Ö\83\81\83b\83Z\81[\83W\82ð\8d\8f\82Ý\8fI\82¦\82½\81D"
1435 /*JP
1436                           : "You finish burning your message into the floor.";
1437 */
1438                           : "\8f°\82Ö\83\81\83b\83Z\81[\83W\82ð\8fÄ\82«\82¢\82ê\8fI\82¦\82½\81D";
1439         break;
1440     case MARK:
1441         multi = -(len / 10);
1442         if (otmp->otyp == MAGIC_MARKER) {
1443             maxelen = otmp->spe * 2; /* one charge / 2 letters */
1444             if (len > maxelen) {
1445 /*JP
1446                 Your("marker dries out.");
1447 */
1448                 Your("\83}\81[\83J\82Í\8a£\82«\82«\82Á\82½\81D");
1449                 otmp->spe = 0;
1450                 multi = -(maxelen / 10);
1451             } else if (len > 1)
1452                 otmp->spe -= len >> 1;
1453             else
1454                 otmp->spe -= 1; /* Prevent infinite graffiti */
1455         }
1456         if (multi)
1457 /*JP
1458             nomovemsg = "You finish defacing the dungeon.";
1459 */
1460             nomovemsg = "\82 \82È\82½\82Í\96À\8b{\82Ö\82Ì\97\8e\8f\91\82ð\8f\91\82«\8fI\82¦\82½\81D";
1461         break;
1462     case ENGR_BLOOD:
1463         multi = -(len / 10);
1464         if (multi)
1465 /*JP
1466             nomovemsg = "You finish scrawling.";
1467 */
1468             nomovemsg = "\82Í\82µ\82è\8f\91\82«\82ð\8f\91\82«\8fI\82¦\82½\81D";
1469         break;
1470     }
1471
1472     /* Chop engraving down to size if necessary */
1473     if (len > maxelen) {
1474         for (sp = ebuf; maxelen && *sp; sp++)
1475             if (*sp == ' ')
1476                 maxelen--;
1477         if (!maxelen && *sp) {
1478 #if 1 /*JP*//*\8a¿\8e\9a\82Ì1\83o\83C\83g\96Ú\82¾\82¯\82ª\8ec\82ç\82È\82¢\82æ\82¤\82É*/
1479             if(is_kanji2(ebuf, sp - ebuf))
1480                 --sp;
1481 #endif
1482             *sp = '\0';
1483             if (multi)
1484 /*JP
1485                 nomovemsg = "You cannot write any more.";
1486 */
1487                 nomovemsg = "\82±\82ê\88È\8fã\89½\82à\8f\91\82¯\82È\82©\82Á\82½\81D";
1488 /*JP
1489             You("are only able to write \"%s\".", ebuf);
1490 */
1491             You("\81u%s\81v\82Æ\82Ü\82Å\82µ\82©\8f\91\82¯\82È\82©\82Á\82½\81D", ebuf);
1492         }
1493     }
1494
1495     if (oep) /* add to existing engraving */
1496         Strcpy(buf, oep->engr_txt);
1497     (void) strncat(buf, ebuf, BUFSZ - (int) strlen(buf) - 1);
1498     /* Put the engraving onto the map */
1499     make_engr_at(u.ux, u.uy, buf, moves - multi, type);
1500
1501     if (post_engr_text[0])
1502         pline("%s", post_engr_text);
1503     if (doblind && !resists_blnd(&youmonst)) {
1504 /*JP
1505         You("are blinded by the flash!");
1506 */
1507         You("\82Ü\82Î\82ä\82¢\8cõ\82Å\96Ú\82ª\82­\82ç\82ñ\82¾\81I");
1508         make_blinded((long) rnd(50), FALSE);
1509         if (!Blind)
1510             Your1(vision_clears);
1511     }
1512     return 1;
1513 }
1514
1515 /* while loading bones, clean up text which might accidentally
1516    or maliciously disrupt player's terminal when displayed */
1517 void
1518 sanitize_engravings()
1519 {
1520     struct engr *ep;
1521
1522     for (ep = head_engr; ep; ep = ep->nxt_engr) {
1523         sanitize_name(ep->engr_txt);
1524     }
1525 }
1526
1527 void
1528 save_engravings(fd, mode)
1529 int fd, mode;
1530 {
1531     struct engr *ep, *ep2;
1532     unsigned no_more_engr = 0;
1533
1534     for (ep = head_engr; ep; ep = ep2) {
1535         ep2 = ep->nxt_engr;
1536         if (ep->engr_lth && ep->engr_txt[0] && perform_bwrite(mode)) {
1537             bwrite(fd, (genericptr_t) &ep->engr_lth, sizeof ep->engr_lth);
1538             bwrite(fd, (genericptr_t) ep, sizeof (struct engr) + ep->engr_lth);
1539         }
1540         if (release_data(mode))
1541             dealloc_engr(ep);
1542     }
1543     if (perform_bwrite(mode))
1544         bwrite(fd, (genericptr_t) &no_more_engr, sizeof no_more_engr);
1545     if (release_data(mode))
1546         head_engr = 0;
1547 }
1548
1549 void
1550 rest_engravings(fd)
1551 int fd;
1552 {
1553     struct engr *ep;
1554     unsigned lth;
1555
1556     head_engr = 0;
1557     while (1) {
1558         mread(fd, (genericptr_t) &lth, sizeof lth);
1559         if (lth == 0)
1560             return;
1561         ep = newengr(lth);
1562         mread(fd, (genericptr_t) ep, sizeof (struct engr) + lth);
1563         ep->nxt_engr = head_engr;
1564         head_engr = ep;
1565         ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
1566         /* Mark as finished for bones levels -- no problem for
1567          * normal levels as the player must have finished engraving
1568          * to be able to move again.
1569          */
1570         ep->engr_time = moves;
1571     }
1572 }
1573
1574 void
1575 del_engr(ep)
1576 register struct engr *ep;
1577 {
1578     if (ep == head_engr) {
1579         head_engr = ep->nxt_engr;
1580     } else {
1581         register struct engr *ept;
1582
1583         for (ept = head_engr; ept; ept = ept->nxt_engr)
1584             if (ept->nxt_engr == ep) {
1585                 ept->nxt_engr = ep->nxt_engr;
1586                 break;
1587             }
1588         if (!ept) {
1589             impossible("Error in del_engr?");
1590             return;
1591         }
1592     }
1593     dealloc_engr(ep);
1594 }
1595
1596 /* randomly relocate an engraving */
1597 void
1598 rloc_engr(ep)
1599 struct engr *ep;
1600 {
1601     int tx, ty, tryct = 200;
1602
1603     do {
1604         if (--tryct < 0)
1605             return;
1606         tx = rn1(COLNO - 3, 2);
1607         ty = rn2(ROWNO);
1608     } while (engr_at(tx, ty) || !goodpos(tx, ty, (struct monst *) 0, 0));
1609
1610     ep->engr_x = tx;
1611     ep->engr_y = ty;
1612 }
1613
1614 /* Create a headstone at the given location.
1615  * The caller is responsible for newsym(x, y).
1616  */
1617 void
1618 make_grave(x, y, str)
1619 int x, y;
1620 const char *str;
1621 {
1622     char buf[BUFSZ];
1623
1624     /* Can we put a grave here? */
1625     if ((levl[x][y].typ != ROOM && levl[x][y].typ != GRAVE) || t_at(x, y))
1626         return;
1627     /* Make the grave */
1628     levl[x][y].typ = GRAVE;
1629     /* Engrave the headstone */
1630     del_engr_at(x, y);
1631     if (!str)
1632         str = get_rnd_text(EPITAPHFILE, buf);
1633     make_engr_at(x, y, str, 0L, HEADSTONE);
1634     return;
1635 }
1636
1637 /*engrave.c*/