OSDN Git Service

patch src/
[jnethack/source.git] / src / read.c
1 /* NetHack 3.6  read.c  $NHDT-Date: 1448862378 2015/11/30 05:46:18 $  $NHDT-Branch: master $:$NHDT-Revision: 1.125 $ */
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
12 #define Your_Own_Role(mndx)  \
13     ((mndx) == urole.malenum \
14      || (urole.femalenum != NON_PM && (mndx) == urole.femalenum))
15 #define Your_Own_Race(mndx)  \
16     ((mndx) == urace.malenum \
17      || (urace.femalenum != NON_PM && (mndx) == urace.femalenum))
18
19 boolean known;
20
21 static NEARDATA const char readable[] = { ALL_CLASSES, SCROLL_CLASS,
22                                           SPBOOK_CLASS, 0 };
23 static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 };
24
25 STATIC_DCL boolean FDECL(learnscrolltyp, (SHORT_P));
26 STATIC_DCL char * FDECL(erode_obj_text, (struct obj *, char *));
27 STATIC_DCL void NDECL(do_class_genocide);
28 STATIC_DCL void FDECL(stripspe, (struct obj *));
29 STATIC_DCL void FDECL(p_glow1, (struct obj *));
30 STATIC_DCL void FDECL(p_glow2, (struct obj *, const char *));
31 STATIC_DCL void FDECL(randomize, (int *, int));
32 STATIC_DCL void FDECL(forget_single_object, (int));
33 STATIC_DCL void FDECL(forget, (int));
34 STATIC_DCL int FDECL(maybe_tame, (struct monst *, struct obj *));
35 STATIC_DCL boolean FDECL(is_valid_stinking_cloud_pos, (int, int, BOOLEAN_P));
36 STATIC_DCL void FDECL(display_stinking_cloud_positions, (int));
37 STATIC_PTR void FDECL(set_lit, (int, int, genericptr));
38
39 STATIC_OVL boolean
40 learnscrolltyp(scrolltyp)
41 short scrolltyp;
42 {
43     if (!objects[scrolltyp].oc_name_known) {
44         makeknown(scrolltyp);
45         more_experienced(0, 10);
46         return TRUE;
47     } else
48         return FALSE;
49 }
50
51 /* also called from teleport.c for scroll of teleportation */
52 void
53 learnscroll(sobj)
54 struct obj *sobj;
55 {
56     /* it's implied that sobj->dknown is set;
57        we couldn't be reading this scroll otherwise */
58     if (sobj->oclass != SPBOOK_CLASS)
59         (void) learnscrolltyp(sobj->otyp);
60 }
61
62 char *
63 erode_obj_text(otmp, buf)
64 struct obj *otmp;
65 char *buf;
66 {
67     int erosion = greatest_erosion(otmp);
68     if (erosion)
69         wipeout_text(buf, (int) (strlen(buf) * erosion / (2 * MAX_ERODE)),
70                      otmp->o_id ^ (unsigned) ubirthday);
71     return buf;
72 }
73
74 char *
75 tshirt_text(tshirt, buf)
76 struct obj *tshirt;
77 char *buf;
78 {
79     static const char *shirt_msgs[] = {
80         /* Scott Bigham */
81       "I explored the Dungeons of Doom and all I got was this lousy T-shirt!",
82         "Is that Mjollnir in your pocket or are you just happy to see me?",
83       "It's not the size of your sword, it's how #enhance'd you are with it.",
84         "Madame Elvira's House O' Succubi Lifetime Customer",
85         "Madame Elvira's House O' Succubi Employee of the Month",
86         "Ludios Vault Guards Do It In Small, Dark Rooms",
87         "Yendor Military Soldiers Do It In Large Groups",
88         "I survived Yendor Military Boot Camp",
89         "Ludios Accounting School Intra-Mural Lacrosse Team",
90         "Oracle(TM) Fountains 10th Annual Wet T-Shirt Contest",
91         "Hey, black dragon!  Disintegrate THIS!",
92         "I'm With Stupid -->",
93         "Don't blame me, I voted for Izchak!",
94         "Don't Panic", /* HHGTTG */
95         "Furinkan High School Athletic Dept.",                /* Ranma 1/2 */
96         "Hel-LOOO, Nurse!",                                   /* Animaniacs */
97         "=^.^=",
98         "100% goblin hair - do not wash",
99         "Aberzombie and Fitch",
100         "cK -- Cockatrice touches the Kop",
101         "Don't ask me, I only adventure here",
102         "Down with pants!",
103         "d, your dog or a killer?",
104         "FREE PUG AND NEWT!",
105         "Go team ant!",
106         "Got newt?",
107         "Hello, my darlings!", /* Charlie Drake */
108         "Hey! Nymphs! Steal This T-Shirt!",
109         "I <3 Dungeon of Doom",
110         "I <3 Maud",
111         "I am a Valkyrie. If you see me running, try to keep up.",
112         "I am not a pack rat - I am a collector",
113         "I bounced off a rubber tree",         /* Monkey Island */
114         "Plunder Island Brimstone Beach Club", /* Monkey Island */
115         "If you can read this, I can hit you with my polearm",
116         "I'm confused!",
117         "I scored with the princess",
118         "I want to live forever or die in the attempt.",
119         "Lichen Park",
120         "LOST IN THOUGHT - please send search party",
121         "Meat is Mordor",
122         "Minetown Better Business Bureau",
123         "Minetown Watch",
124  "Ms. Palm's House of Negotiable Affection -- A Very Reputable House Of Disrepute",
125         "Protection Racketeer",
126         "Real men love Crom",
127         "Somebody stole my Mojo!",
128         "The Hellhound Gang",
129         "The Werewolves",
130         "They Might Be Storm Giants",
131         "Weapons don't kill people, I kill people",
132         "White Zombie",
133         "You're killing me!",
134         "Anhur State University - Home of the Fighting Fire Ants!",
135         "FREE HUGS",
136         "Serial Ascender",
137         "Real men are valkyries",
138         "Young Men's Cavedigging Association",
139         "Occupy Fort Ludios",
140         "I couldn't afford this T-shirt so I stole it!",
141         "Mind flayers suck",
142         "I'm not wearing any pants",
143         "Down with the living!",
144         "Pudding farmer",
145         "Vegetarian",
146         "Hello, I'm War!",
147     };
148
149     Strcpy(buf, shirt_msgs[tshirt->o_id % SIZE(shirt_msgs)]);
150     return erode_obj_text(tshirt, buf);
151 }
152
153 char *
154 apron_text(apron, buf)
155 struct obj *apron;
156 char *buf;
157 {
158     static const char *apron_msgs[] = {
159         "Kiss the cook",
160         "I'm making SCIENCE!",
161         "Don't mess with the chef",
162         "Don't make me poison you",
163         "Gehennom's Kitchen",
164         "Rat: The other white meat",
165         "If you can't stand the heat, get out of Gehennom!",
166         "If we weren't meant to eat animals, why are they made out of meat?",
167         "If you don't like the food, I'll stab you",
168     };
169
170     Strcpy(buf, apron_msgs[apron->o_id % SIZE(apron_msgs)]);
171     return erode_obj_text(apron, buf);
172 }
173
174 int
175 doread()
176 {
177     register struct obj *scroll;
178     boolean confused, nodisappear;
179
180     known = FALSE;
181     if (check_capacity((char *) 0))
182         return 0;
183     scroll = getobj(readable, "read");
184     if (!scroll)
185         return 0;
186
187     /* outrumor has its own blindness check */
188     if (scroll->otyp == FORTUNE_COOKIE) {
189         if (flags.verbose)
190 /*JP
191             You("break up the cookie and throw away the pieces.");
192 */
193             You("\83N\83b\83L\81[\82ð\8a\84\82è\81C\82©\82¯\82ç\82ð\93\8a\82°\82·\82Ä\82½\81D");
194         outrumor(bcsign(scroll), BY_COOKIE);
195         if (!Blind)
196             u.uconduct.literate++;
197         useup(scroll);
198         return 1;
199     } else if (scroll->otyp == T_SHIRT || scroll->otyp == ALCHEMY_SMOCK) {
200         char buf[BUFSZ];
201         if (Blind) {
202 /*JP
203             You_cant("feel any Braille writing.");
204 */
205             You("\93_\8e\9a\82Í\82Ç\82¤\82à\8f\91\82¢\82Ä\82È\82¢\82æ\82¤\82¾\81D");
206             return 0;
207         }
208         /* can't read shirt worn under suit (under cloak is ok though) */
209         if (scroll->otyp == T_SHIRT && uarm && scroll == uarmu) {
210 #if 0 /*JP*/
211             pline("%s shirt is obscured by %s%s.",
212                   scroll->unpaid ? "That" : "Your", shk_your(buf, uarm),
213                   suit_simple_name(uarm));
214 #else
215             pline("\83V\83\83\83c\82Í%s\82Å\89B\82³\82ê\82Ä\82¢\82é\81D",
216                   suit_simple_name(uarm));
217 #endif
218             return 0;
219         }
220         u.uconduct.literate++;
221         if (flags.verbose)
222 /*JP
223             pline("It reads:");
224 */
225             pline("\82»\82ê\82ð\93Ç\82ñ\82¾\81F");
226 #if 0 /*JP*/
227         pline("\"%s\"", (scroll->otyp == T_SHIRT) ? tshirt_text(scroll, buf)
228                                                   : apron_text(scroll, buf));
229 #else
230         pline("\81u%s\81v", (scroll->otyp == T_SHIRT) ? tshirt_text(scroll, buf)
231                                                   : apron_text(scroll, buf));
232 #endif
233         return 1;
234     } else if (scroll->otyp == CREDIT_CARD) {
235         static const char *card_msgs[] = {
236             "Leprechaun Gold Tru$t - Shamrock Card",
237             "Magic Memory Vault Charge Card", "Larn National Bank", /* Larn */
238             "First Bank of Omega",               /* Omega */
239             "Bank of Zork - Frobozz Magic Card", /* Zork */
240             "Ankh-Morpork Merchant's Guild Barter Card",
241             "Ankh-Morpork Thieves' Guild Unlimited Transaction Card",
242             "Ransmannsby Moneylenders Association",
243             "Bank of Gehennom - 99% Interest Card",
244             "Yendorian Express - Copper Card",
245             "Yendorian Express - Silver Card",
246             "Yendorian Express - Gold Card",
247             "Yendorian Express - Mithril Card",
248             "Yendorian Express - Platinum Card", /* must be last */
249         };
250
251         if (Blind) {
252 /*JP
253             You("feel the embossed numbers:");
254 */
255             You("\95\82\82«\92¤\82è\82É\82³\82ê\82Ä\82¢\82é\94Ô\8d\86\82ð\8a´\82\82½:");
256         } else {
257             if (flags.verbose)
258 /*JP
259                 pline("It reads:");
260 */
261                 pline("\82»\82ê\82ð\93Ç\82ñ\82¾\81F");
262 /*JP
263             pline("\"%s\"",
264 */
265             pline("\81u%s\81v",
266                   scroll->oartifact
267                       ? card_msgs[SIZE(card_msgs) - 1]
268                       : card_msgs[scroll->o_id % (SIZE(card_msgs) - 1)]);
269         }
270         /* Make a credit card number */
271         pline("\"%d0%d %d%d1 0%d%d0\"", ((scroll->o_id % 89) + 10),
272               (scroll->o_id % 4), (((scroll->o_id * 499) % 899999) + 100000),
273               (scroll->o_id % 10), (!(scroll->o_id % 3)),
274               ((scroll->o_id * 7) % 10));
275         u.uconduct.literate++;
276         return 1;
277     } else if (scroll->otyp == CAN_OF_GREASE) {
278 /*JP
279         pline("This %s has no label.", singular(scroll, xname));
280 */
281         pline("\82±\82Ì%s\82É\82Í\83\89\83x\83\8b\82ª\82È\82¢\81D", singular(scroll, xname));
282         return 0;
283     } else if (scroll->otyp == MAGIC_MARKER) {
284         if (Blind) {
285 /*JP
286             You_cant("feel any Braille writing.");
287 */
288             You("\93_\8e\9a\82Í\82Ç\82¤\82à\8f\91\82¢\82Ä\82È\82¢\82æ\82¤\82¾\81D");
289             return 0;
290         }
291         if (flags.verbose)
292 /*JP
293             pline("It reads:");
294 */
295             pline("\82»\82ê\82ð\93Ç\82ñ\82¾\81F");
296 /*JP
297         pline("\"Magic Marker(TM) Red Ink Marker Pen. Water Soluble.\"");
298 */
299         pline("\81u\96\82\96@\82Ì\83}\81[\83J(TM) \90Ô\83C\83\93\83N\83}\81[\83J\83y\83\93\81D\90\85\90«\81D\81v");
300         u.uconduct.literate++;
301         return 1;
302     } else if (scroll->oclass == COIN_CLASS) {
303         if (Blind)
304 /*JP
305             You("feel the embossed words:");
306 */
307             You("\95\82\82«\92¤\82è\82É\82³\82ê\82Ä\82¢\82é\95\8e\9a\82ð\8a´\82\82½:");
308         else if (flags.verbose)
309 /*JP
310             You("read:");
311 */
312             pline("\82»\82ê\82ð\93Ç\82ñ\82¾\81F");
313         pline("\"1 Zorkmid. 857 GUE. In Frobs We Trust.\"");
314         u.uconduct.literate++;
315         return 1;
316     } else if (scroll->oartifact == ART_ORB_OF_FATE) {
317         if (Blind)
318 /*JP
319             You("feel the engraved signature:");
320 */
321             You("\92¤\82è\8d\9e\82Ü\82ê\82Ä\82¢\82é\83T\83C\83\93\82ð\8a´\82\82½\81F");
322         else
323 /*JP
324             pline("It is signed:");
325 */
326             pline("\83T\83C\83\93\82ª\82 \82é\81F");
327 /*JP
328         pline("\"Odin.\"");
329 */
330         pline("\81u\83I\81[\83f\83B\83\93\81v");
331         u.uconduct.literate++;
332         return 1;
333     } else if (scroll->otyp == CANDY_BAR) {
334         static const char *wrapper_msgs[] = {
335             "Apollo",       /* Lost */
336             "Moon Crunchy", /* South Park */
337             "Snacky Cake",    "Chocolate Nuggie", "The Small Bar",
338             "Crispy Yum Yum", "Nilla Crunchie",   "Berry Bar",
339             "Choco Nummer",   "Om-nom", /* Cat Macro */
340             "Fruity Oaty",              /* Serenity */
341             "Wonka Bar" /* Charlie and the Chocolate Factory */
342         };
343
344         if (Blind) {
345 /*JP
346             You_cant("feel any Braille writing.");
347 */
348             You("\93_\8e\9a\82Í\82Ç\82¤\82à\8f\91\82¢\82Ä\82È\82¢\82æ\82¤\82¾\81D");
349             return 0;
350         }
351 /*JP
352         pline("The wrapper reads: \"%s\"",
353 */
354         pline("\95ï\82Ý\8e\86\82Ì\95\8e\9a\82ð\93Ç\82ñ\82¾\81F\81u%s\81v",
355               wrapper_msgs[scroll->o_id % SIZE(wrapper_msgs)]);
356         u.uconduct.literate++;
357         return 1;
358     } else if (scroll->oclass != SCROLL_CLASS
359                && scroll->oclass != SPBOOK_CLASS) {
360 /*JP
361         pline(silly_thing_to, "read");
362 */
363         pline(silly_thing_to, "\93Ç\82Þ");
364         return 0;
365     } else if (Blind && (scroll->otyp != SPE_BOOK_OF_THE_DEAD)) {
366         const char *what = 0;
367         if (scroll->oclass == SPBOOK_CLASS)
368 /*JP
369             what = "mystic runes";
370 */
371             what = "\90_\94é\93I\82È\83\8b\81[\83\93\95\8e\9a";
372         else if (!scroll->dknown)
373 /*JP
374             what = "formula on the scroll";
375 */
376             what = "\8aª\95¨\82Ì\8eô\95¶";
377         if (what) {
378 /*JP
379             pline("Being blind, you cannot read the %s.", what);
380 */
381             pline("\96Ú\82ª\8c©\82¦\82È\82¢\82Ì\82Å\81C\82 \82È\82½\82Í%s\82ð\93Ç\82Þ\82±\82Æ\82ª\82Å\82«\82È\82¢\81D", what);
382             return 0;
383         }
384     }
385
386     confused = (Confusion != 0);
387 #ifdef MAIL
388     if (scroll->otyp == SCR_MAIL) {
389         confused = FALSE; /* override */
390         /* reading mail is a convenience for the player and takes
391            place outside the game, so shouldn't affect gameplay;
392            on the other hand, it starts by explicitly making the
393            hero actively read something, which is pretty hard
394            to simply ignore; as a compromise, if the player has
395            maintained illiterate conduct so far, and this mail
396            scroll didn't come from bones, ask for confirmation */
397         if (!u.uconduct.literate) {
398             if (!scroll->spe && yn(
399              "Reading mail will violate \"illiterate\" conduct.  Read anyway?"
400                                    ) != 'y')
401                 return 0;
402         }
403     }
404 #endif
405
406     /* Actions required to win the game aren't counted towards conduct */
407     /* Novel conduct is handled in read_tribute so exclude it too*/
408     if (scroll->otyp != SPE_BOOK_OF_THE_DEAD
409         && scroll->otyp != SPE_BLANK_PAPER && scroll->otyp != SCR_BLANK_PAPER
410         && scroll->otyp != SPE_NOVEL)
411         u.uconduct.literate++;
412
413     if (scroll->oclass == SPBOOK_CLASS) {
414         return study_book(scroll);
415     }
416     scroll->in_use = TRUE; /* scroll, not spellbook, now being read */
417     if (scroll->otyp != SCR_BLANK_PAPER) {
418         /* a few scroll feedback messages describe something happening
419            to the scroll itself, so avoid "it disappears" for those */
420         nodisappear = (scroll->otyp == SCR_FIRE
421                        || (scroll->otyp == SCR_REMOVE_CURSE
422                            && scroll->cursed));
423         if (Blind)
424 #if 0 /*JP*/
425             pline(nodisappear
426                       ? "You %s the formula on the scroll."
427                       : "As you %s the formula on it, the scroll disappears.",
428                   is_silent(youmonst.data) ? "cogitate" : "pronounce");
429 #else
430             pline(nodisappear
431                       ? "\82 \82È\82½\82Í\8eô\95\82ð%s\82½\81D"
432                       : "\8eô\95\82ð%s\82é\82Æ\81C\8aª\95¨\82Í\8fÁ\82¦\82½\81D",
433                   is_silent(youmonst.data) ? "\94O\82¶" : "\8f¥\82¦");
434 #endif
435         else
436 #if 0 /*JP*/
437             pline(nodisappear ? "You read the scroll."
438                               : "As you read the scroll, it disappears.");
439 #else
440             pline(nodisappear ? "\82 \82È\82½\82Í\8aª\95¨\82ð\93Ç\82ñ\82¾\81D"
441                               : "\8aª\95¨\82ð\93Ç\82Þ\82Æ\81C\82»\82ê\82Í\8fÁ\82¦\82½\81D");
442 #endif
443         if (confused) {
444             if (Hallucination)
445 /*JP
446                 pline("Being so trippy, you screw up...");
447 */
448                 pline("\82Æ\82Ä\82à\82Ö\82ë\82Ö\82ë\82È\82Ì\82Å\81C\82­\82µ\82á\82­\82µ\82á\82É\82µ\82Ä\82µ\82Ü\82Á\82½\81D\81D\81D");
449             else
450 #if 0 /*JP*/
451                 pline("Being confused, you %s the magic words...",
452                       is_silent(youmonst.data) ? "misunderstand"
453                                                : "mispronounce");
454 #else
455                 pline("\8d¬\97\90\82µ\82Ä\82¢\82é\82Ì\82Å\81C\8eô\95\82ð\8aÔ\88á\82Á\82Ä\82µ\82Ü\82Á\82½\81D\81D\81D");
456 #endif
457         }
458     }
459     if (!seffects(scroll)) {
460         if (!objects[scroll->otyp].oc_name_known) {
461             if (known)
462                 learnscroll(scroll);
463             else if (!objects[scroll->otyp].oc_uname)
464                 docall(scroll);
465         }
466         scroll->in_use = FALSE;
467         if (scroll->otyp != SCR_BLANK_PAPER)
468             useup(scroll);
469     }
470     return 1;
471 }
472
473 STATIC_OVL void
474 stripspe(obj)
475 register struct obj *obj;
476 {
477     if (obj->blessed || obj->spe <= 0) {
478         pline1(nothing_happens);
479     } else {
480         /* order matters: message, shop handling, actual transformation */
481 /*JP
482         pline("%s briefly.", Yobjnam2(obj, "vibrate"));
483 */
484         Your("%s\82Í\8f¬\8d\8f\82Ý\82É\90U\93®\82µ\82½\81D",xname(obj));
485         costly_alteration(obj, COST_UNCHRG);
486         obj->spe = 0;
487         if (obj->otyp == OIL_LAMP || obj->otyp == BRASS_LANTERN)
488             obj->age = 0;
489     }
490 }
491
492 STATIC_OVL void
493 p_glow1(otmp)
494 register struct obj *otmp;
495 {
496 /*JP
497     pline("%s briefly.", Yobjnam2(otmp, Blind ? "vibrate" : "glow"));
498 */
499     Your("%s\82Í\8f¬\8d\8f\82Ý\82É%s\81D", xname(otmp), Blind ? "\90U\93®\82µ\82½" : "\8bP\82¢\82½");
500 }
501
502 STATIC_OVL void
503 p_glow2(otmp, color)
504 register struct obj *otmp;
505 register const char *color;
506 {
507 #if 0 /*JP*/
508     pline("%s%s%s for a moment.", Yobjnam2(otmp, Blind ? "vibrate" : "glow"),
509           Blind ? "" : " ", Blind ? "" : hcolor(color));
510 #else
511     Your("%s\82Í\88ê\8fu%s%s\81D", xname(otmp),
512          Blind ? "" : jconj_adj(hcolor(color)),
513          Blind ? "\90U\93®\82µ\82½" : "\8bP\82¢\82½");
514 #endif
515 }
516
517 /* Is the object chargeable?  For purposes of inventory display; it is
518    possible to be able to charge things for which this returns FALSE. */
519 boolean
520 is_chargeable(obj)
521 struct obj *obj;
522 {
523     if (obj->oclass == WAND_CLASS)
524         return TRUE;
525     /* known && !oc_name_known is possible after amnesia/mind flayer */
526     if (obj->oclass == RING_CLASS)
527         return (boolean) (objects[obj->otyp].oc_charged
528                           && (obj->known
529                               || (obj->dknown
530                                   && objects[obj->otyp].oc_name_known)));
531     if (is_weptool(obj)) /* specific check before general tools */
532         return FALSE;
533     if (obj->oclass == TOOL_CLASS)
534         return (boolean) objects[obj->otyp].oc_charged;
535     return FALSE; /* why are weapons/armor considered charged anyway? */
536 }
537
538 /* recharge an object; curse_bless is -1 if the recharging implement
539    was cursed, +1 if blessed, 0 otherwise. */
540 void
541 recharge(obj, curse_bless)
542 struct obj *obj;
543 int curse_bless;
544 {
545     register int n;
546     boolean is_cursed, is_blessed;
547
548     is_cursed = curse_bless < 0;
549     is_blessed = curse_bless > 0;
550
551     if (obj->oclass == WAND_CLASS) {
552         int lim = (obj->otyp == WAN_WISHING)
553                       ? 3
554                       : (objects[obj->otyp].oc_dir != NODIR) ? 8 : 15;
555
556         /* undo any prior cancellation, even when is_cursed */
557         if (obj->spe == -1)
558             obj->spe = 0;
559
560         /*
561          * Recharging might cause wands to explode.
562          *      v = number of previous recharges
563          *            v = percentage chance to explode on this attempt
564          *                    v = cumulative odds for exploding
565          *      0 :   0       0
566          *      1 :   0.29    0.29
567          *      2 :   2.33    2.62
568          *      3 :   7.87   10.28
569          *      4 :  18.66   27.02
570          *      5 :  36.44   53.62
571          *      6 :  62.97   82.83
572          *      7 : 100     100
573          */
574         n = (int) obj->recharged;
575         if (n > 0 && (obj->otyp == WAN_WISHING
576                       || (n * n * n > rn2(7 * 7 * 7)))) { /* recharge_limit */
577             wand_explode(obj, rnd(lim));
578             return;
579         }
580         /* didn't explode, so increment the recharge count */
581         obj->recharged = (unsigned) (n + 1);
582
583         /* now handle the actual recharging */
584         if (is_cursed) {
585             stripspe(obj);
586         } else {
587             n = (lim == 3) ? 3 : rn1(5, lim + 1 - 5);
588             if (!is_blessed)
589                 n = rnd(n);
590
591             if (obj->spe < n)
592                 obj->spe = n;
593             else
594                 obj->spe++;
595             if (obj->otyp == WAN_WISHING && obj->spe > 3) {
596                 wand_explode(obj, 1);
597                 return;
598             }
599             if (obj->spe >= lim)
600                 p_glow2(obj, NH_BLUE);
601             else
602                 p_glow1(obj);
603 #if 0 /*[shop price doesn't vary by charge count]*/
604             /* update shop bill to reflect new higher price */
605             if (obj->unpaid)
606                 alter_cost(obj, 0L);
607 #endif
608         }
609
610     } else if (obj->oclass == RING_CLASS && objects[obj->otyp].oc_charged) {
611         /* charging does not affect ring's curse/bless status */
612         int s = is_blessed ? rnd(3) : is_cursed ? -rnd(2) : 1;
613         boolean is_on = (obj == uleft || obj == uright);
614
615         /* destruction depends on current state, not adjustment */
616         if (obj->spe > rn2(7) || obj->spe <= -5) {
617 #if 0 /*JP*/
618             pline("%s momentarily, then %s!", Yobjnam2(obj, "pulsate"),
619                   otense(obj, "explode"));
620 #else
621             Your("%s\82Í\88ê\8fu\96¬\93®\82µ\81C\94\9a\94­\82µ\82½\81I", xname(obj));
622 #endif
623             if (is_on)
624                 Ring_gone(obj);
625             s = rnd(3 * abs(obj->spe)); /* amount of damage */
626             useup(obj);
627 /*JP
628             losehp(Maybe_Half_Phys(s), "exploding ring", KILLED_BY_AN);
629 */
630             losehp(Maybe_Half_Phys(s), "\8ew\97Ö\82Ì\94\9a\94­\82Å", KILLED_BY_AN);
631         } else {
632             long mask = is_on ? (obj == uleft ? LEFT_RING : RIGHT_RING) : 0L;
633
634 #if 0 /*JP*/
635             pline("%s spins %sclockwise for a moment.", Yname2(obj),
636                   s < 0 ? "counter" : "");
637 #else
638             Your("%s\82Í\88ê\8fu%s\8e\9e\8cv\89ñ\82è\82É\89ñ\93]\82µ\82½\81D", xname(obj),
639                  s < 0 ? "\94½" : "");
640 #endif
641             if (s < 0)
642                 costly_alteration(obj, COST_DECHNT);
643             /* cause attributes and/or properties to be updated */
644             if (is_on)
645                 Ring_off(obj);
646             obj->spe += s; /* update the ring while it's off */
647             if (is_on)
648                 setworn(obj, mask), Ring_on(obj);
649             /* oartifact: if a touch-sensitive artifact ring is
650                ever created the above will need to be revised  */
651             /* update shop bill to reflect new higher price */
652             if (s > 0 && obj->unpaid)
653                 alter_cost(obj, 0L);
654         }
655
656     } else if (obj->oclass == TOOL_CLASS) {
657         int rechrg = (int) obj->recharged;
658
659         if (objects[obj->otyp].oc_charged) {
660             /* tools don't have a limit, but the counter used does */
661             if (rechrg < 7) /* recharge_limit */
662                 obj->recharged++;
663         }
664         switch (obj->otyp) {
665         case BELL_OF_OPENING:
666             if (is_cursed)
667                 stripspe(obj);
668             else if (is_blessed)
669                 obj->spe += rnd(3);
670             else
671                 obj->spe += 1;
672             if (obj->spe > 5)
673                 obj->spe = 5;
674             break;
675         case MAGIC_MARKER:
676         case TINNING_KIT:
677         case EXPENSIVE_CAMERA:
678             if (is_cursed)
679                 stripspe(obj);
680             else if (rechrg
681                      && obj->otyp
682                             == MAGIC_MARKER) { /* previously recharged */
683                 obj->recharged = 1; /* override increment done above */
684                 if (obj->spe < 3)
685 /*JP
686                     Your("marker seems permanently dried out.");
687 */
688                     Your("\83}\81[\83J\82Í\8a®\91S\82É\8a£\82«\82«\82Á\82Ä\82µ\82Ü\82Á\82½\81D");
689                 else
690                     pline1(nothing_happens);
691             } else if (is_blessed) {
692                 n = rn1(16, 15); /* 15..30 */
693                 if (obj->spe + n <= 50)
694                     obj->spe = 50;
695                 else if (obj->spe + n <= 75)
696                     obj->spe = 75;
697                 else {
698                     int chrg = (int) obj->spe;
699                     if ((chrg + n) > 127)
700                         obj->spe = 127;
701                     else
702                         obj->spe += n;
703                 }
704                 p_glow2(obj, NH_BLUE);
705             } else {
706                 n = rn1(11, 10); /* 10..20 */
707                 if (obj->spe + n <= 50)
708                     obj->spe = 50;
709                 else {
710                     int chrg = (int) obj->spe;
711                     if ((chrg + n) > 127)
712                         obj->spe = 127;
713                     else
714                         obj->spe += n;
715                 }
716                 p_glow2(obj, NH_WHITE);
717             }
718             break;
719         case OIL_LAMP:
720         case BRASS_LANTERN:
721             if (is_cursed) {
722                 stripspe(obj);
723                 if (obj->lamplit) {
724                     if (!Blind)
725 #if 0 /*JP*/
726                         pline("%s out!", Tobjnam(obj, "go"));
727 #else
728                         pline("%s\82Í\8fÁ\82¦\82½\81I", xname(obj));
729 #endif
730                     end_burn(obj, TRUE);
731                 }
732             } else if (is_blessed) {
733                 obj->spe = 1;
734                 obj->age = 1500;
735                 p_glow2(obj, NH_BLUE);
736             } else {
737                 obj->spe = 1;
738                 obj->age += 750;
739                 if (obj->age > 1500)
740                     obj->age = 1500;
741                 p_glow1(obj);
742             }
743             break;
744         case CRYSTAL_BALL:
745             if (is_cursed) {
746                 stripspe(obj);
747             } else if (is_blessed) {
748                 obj->spe = 6;
749                 p_glow2(obj, NH_BLUE);
750             } else {
751                 if (obj->spe < 5) {
752                     obj->spe++;
753                     p_glow1(obj);
754                 } else
755                     pline1(nothing_happens);
756             }
757             break;
758         case HORN_OF_PLENTY:
759         case BAG_OF_TRICKS:
760         case CAN_OF_GREASE:
761             if (is_cursed) {
762                 stripspe(obj);
763             } else if (is_blessed) {
764                 if (obj->spe <= 10)
765                     obj->spe += rn1(10, 6);
766                 else
767                     obj->spe += rn1(5, 6);
768                 if (obj->spe > 50)
769                     obj->spe = 50;
770                 p_glow2(obj, NH_BLUE);
771             } else {
772                 obj->spe += rnd(5);
773                 if (obj->spe > 50)
774                     obj->spe = 50;
775                 p_glow1(obj);
776             }
777             break;
778         case MAGIC_FLUTE:
779         case MAGIC_HARP:
780         case FROST_HORN:
781         case FIRE_HORN:
782         case DRUM_OF_EARTHQUAKE:
783             if (is_cursed) {
784                 stripspe(obj);
785             } else if (is_blessed) {
786                 obj->spe += d(2, 4);
787                 if (obj->spe > 20)
788                     obj->spe = 20;
789                 p_glow2(obj, NH_BLUE);
790             } else {
791                 obj->spe += rnd(4);
792                 if (obj->spe > 20)
793                     obj->spe = 20;
794                 p_glow1(obj);
795             }
796             break;
797         default:
798             goto not_chargable;
799             /*NOTREACHED*/
800             break;
801         } /* switch */
802
803     } else {
804     not_chargable:
805 /*JP
806         You("have a feeling of loss.");
807 */
808         You("\82È\82É\82©\91¹\82µ\82½\8bC\95ª\82É\82È\82Á\82½\81D");
809     }
810 }
811
812 /* Forget known information about this object type. */
813 STATIC_OVL void
814 forget_single_object(obj_id)
815 int obj_id;
816 {
817     objects[obj_id].oc_name_known = 0;
818     objects[obj_id].oc_pre_discovered = 0; /* a discovery when relearned */
819     if (objects[obj_id].oc_uname) {
820         free((genericptr_t) objects[obj_id].oc_uname);
821         objects[obj_id].oc_uname = 0;
822     }
823     undiscover_object(obj_id); /* after clearing oc_name_known */
824
825     /* clear & free object names from matching inventory items too? */
826 }
827
828 #if 0 /* here if anyone wants it.... */
829 /* Forget everything known about a particular object class. */
830 STATIC_OVL void
831 forget_objclass(oclass)
832 int oclass;
833 {
834     int i;
835
836     for (i = bases[oclass];
837          i < NUM_OBJECTS && objects[i].oc_class == oclass; i++)
838         forget_single_object(i);
839 }
840 #endif
841
842 /* randomize the given list of numbers  0 <= i < count */
843 STATIC_OVL void
844 randomize(indices, count)
845 int *indices;
846 int count;
847 {
848     int i, iswap, temp;
849
850     for (i = count - 1; i > 0; i--) {
851         if ((iswap = rn2(i + 1)) == i)
852             continue;
853         temp = indices[i];
854         indices[i] = indices[iswap];
855         indices[iswap] = temp;
856     }
857 }
858
859 /* Forget % of known objects. */
860 void
861 forget_objects(percent)
862 int percent;
863 {
864     int i, count;
865     int indices[NUM_OBJECTS];
866
867     if (percent == 0)
868         return;
869     if (percent <= 0 || percent > 100) {
870         impossible("forget_objects: bad percent %d", percent);
871         return;
872     }
873
874     indices[0] = 0; /* lint suppression */
875     for (count = 0, i = 1; i < NUM_OBJECTS; i++)
876         if (OBJ_DESCR(objects[i])
877             && (objects[i].oc_name_known || objects[i].oc_uname))
878             indices[count++] = i;
879
880     if (count > 0) {
881         randomize(indices, count);
882
883         /* forget first % of randomized indices */
884         count = ((count * percent) + rn2(100)) / 100;
885         for (i = 0; i < count; i++)
886             forget_single_object(indices[i]);
887     }
888 }
889
890 /* Forget some or all of map (depends on parameters). */
891 void
892 forget_map(howmuch)
893 int howmuch;
894 {
895     register int zx, zy;
896
897     if (Sokoban)
898         return;
899
900     known = TRUE;
901     for (zx = 0; zx < COLNO; zx++)
902         for (zy = 0; zy < ROWNO; zy++)
903             if (howmuch & ALL_MAP || rn2(7)) {
904                 /* Zonk all memory of this location. */
905                 levl[zx][zy].seenv = 0;
906                 levl[zx][zy].waslit = 0;
907                 levl[zx][zy].glyph = cmap_to_glyph(S_stone);
908                 lastseentyp[zx][zy] = STONE;
909             }
910     /* forget overview data for this level */
911     forget_mapseen(ledger_no(&u.uz));
912 }
913
914 /* Forget all traps on the level. */
915 void
916 forget_traps()
917 {
918     register struct trap *trap;
919
920     /* forget all traps (except the one the hero is in :-) */
921     for (trap = ftrap; trap; trap = trap->ntrap)
922         if ((trap->tx != u.ux || trap->ty != u.uy) && (trap->ttyp != HOLE))
923             trap->tseen = 0;
924 }
925
926 /*
927  * Forget given % of all levels that the hero has visited and not forgotten,
928  * except this one.
929  */
930 void
931 forget_levels(percent)
932 int percent;
933 {
934     int i, count;
935     xchar maxl, this_lev;
936     int indices[MAXLINFO];
937
938     if (percent == 0)
939         return;
940
941     if (percent <= 0 || percent > 100) {
942         impossible("forget_levels: bad percent %d", percent);
943         return;
944     }
945
946     this_lev = ledger_no(&u.uz);
947     maxl = maxledgerno();
948
949     /* count & save indices of non-forgotten visited levels */
950     /* Sokoban levels are pre-mapped for the player, and should stay
951      * so, or they become nearly impossible to solve.  But try to
952      * shift the forgetting elsewhere by fiddling with percent
953      * instead of forgetting fewer levels.
954      */
955     indices[0] = 0; /* lint suppression */
956     for (count = 0, i = 0; i <= maxl; i++)
957         if ((level_info[i].flags & VISITED)
958             && !(level_info[i].flags & FORGOTTEN) && i != this_lev) {
959             if (ledger_to_dnum(i) == sokoban_dnum)
960                 percent += 2;
961             else
962                 indices[count++] = i;
963         }
964
965     if (percent > 100)
966         percent = 100;
967
968     if (count > 0) {
969         randomize(indices, count);
970
971         /* forget first % of randomized indices */
972         count = ((count * percent) + 50) / 100;
973         for (i = 0; i < count; i++) {
974             level_info[indices[i]].flags |= FORGOTTEN;
975             forget_mapseen(indices[i]);
976         }
977     }
978 }
979
980 /*
981  * Forget some things (e.g. after reading a scroll of amnesia).  When called,
982  * the following are always forgotten:
983  *      - felt ball & chain
984  *      - traps
985  *      - part (6 out of 7) of the map
986  *
987  * Other things are subject to flags:
988  *      howmuch & ALL_MAP       = forget whole map
989  *      howmuch & ALL_SPELLS    = forget all spells
990  */
991 STATIC_OVL void
992 forget(howmuch)
993 int howmuch;
994 {
995     if (Punished)
996         u.bc_felt = 0; /* forget felt ball&chain */
997
998     forget_map(howmuch);
999     forget_traps();
1000
1001     /* 1 in 3 chance of forgetting some levels */
1002     if (!rn2(3))
1003         forget_levels(rn2(25));
1004
1005     /* 1 in 3 chance of forgetting some objects */
1006     if (!rn2(3))
1007         forget_objects(rn2(25));
1008
1009     if (howmuch & ALL_SPELLS)
1010         losespells();
1011     /*
1012      * Make sure that what was seen is restored correctly.  To do this,
1013      * we need to go blind for an instant --- turn off the display,
1014      * then restart it.  All this work is needed to correctly handle
1015      * walls which are stone on one side and wall on the other.  Turning
1016      * off the seen bits above will make the wall revert to stone,  but
1017      * there are cases where we don't want this to happen.  The easiest
1018      * thing to do is to run it through the vision system again, which
1019      * is always correct.
1020      */
1021     docrt(); /* this correctly will reset vision */
1022 }
1023
1024 /* monster is hit by scroll of taming's effect */
1025 STATIC_OVL int
1026 maybe_tame(mtmp, sobj)
1027 struct monst *mtmp;
1028 struct obj *sobj;
1029 {
1030     int was_tame = mtmp->mtame;
1031     unsigned was_peaceful = mtmp->mpeaceful;
1032
1033     if (sobj->cursed) {
1034         setmangry(mtmp);
1035         if (was_peaceful && !mtmp->mpeaceful)
1036             return -1;
1037     } else {
1038         if (mtmp->isshk)
1039             make_happy_shk(mtmp, FALSE);
1040         else if (!resist(mtmp, sobj->oclass, 0, NOTELL))
1041             (void) tamedog(mtmp, (struct obj *) 0);
1042         if ((!was_peaceful && mtmp->mpeaceful) || (!was_tame && mtmp->mtame))
1043             return 1;
1044     }
1045     return 0;
1046 }
1047
1048 boolean
1049 is_valid_stinking_cloud_pos(x, y, showmsg)
1050 int x, y;
1051 boolean showmsg;
1052 {
1053     if (!cansee(x, y) || !ACCESSIBLE(levl[x][y].typ) || distu(x, y) >= 32) {
1054         if (showmsg)
1055 /*JP
1056             You("smell rotten eggs.");
1057 */
1058             pline("\82­\82³\82Á\82½\97\91\82Ì\82É\82¨\82¢\82ª\82µ\82½\81D");
1059         return FALSE;
1060     }
1061     return TRUE;
1062 }
1063
1064 void
1065 display_stinking_cloud_positions(state)
1066 int state;
1067 {
1068     if (state == 0) {
1069         tmp_at(DISP_BEAM, cmap_to_glyph(S_goodpos));
1070     } else if (state == 1) {
1071         int x, y, dx, dy;
1072         int dist = 6;
1073
1074         for (dx = -dist; dx <= dist; dx++)
1075             for (dy = -dist; dy <= dist; dy++) {
1076                 x = u.ux + dx;
1077                 y = u.uy + dy;
1078                 if (isok(x, y) && is_valid_stinking_cloud_pos(x, y, FALSE))
1079                     tmp_at(x, y);
1080             }
1081     } else {
1082         tmp_at(DISP_END, 0);
1083     }
1084 }
1085
1086 /* scroll effects; return 1 if we use up the scroll and possibly make it
1087    become discovered, 0 if caller should take care of those side-effects */
1088 int
1089 seffects(sobj)
1090 struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
1091 {
1092     int cval, otyp = sobj->otyp;
1093     boolean confused = (Confusion != 0), sblessed = sobj->blessed,
1094             scursed = sobj->cursed, already_known, old_erodeproof,
1095             new_erodeproof;
1096     struct obj *otmp;
1097
1098     if (objects[otyp].oc_magic)
1099         exercise(A_WIS, TRUE);                       /* just for trying */
1100     already_known = (sobj->oclass == SPBOOK_CLASS /* spell */
1101                      || objects[otyp].oc_name_known);
1102
1103     switch (otyp) {
1104 #ifdef MAIL
1105     case SCR_MAIL:
1106         known = TRUE;
1107         if (sobj->spe)
1108             pline(
1109 /*JP
1110     "This seems to be junk mail addressed to the finder of the Eye of Larn.");
1111 */
1112     "Eye of Larn\82Ì\94­\8c©\8eÒ\82É\88\82Ä\82ç\82ê\82½\83S\83~\83\81\83C\83\8b\82Ì\82æ\82¤\82¾\81D");
1113         /* note to the puzzled: the game Larn actually sends you junk
1114          * mail if you win!
1115          */
1116         else
1117             readmail(sobj);
1118         break;
1119 #endif
1120     case SCR_ENCHANT_ARMOR: {
1121         register schar s;
1122         boolean special_armor;
1123         boolean same_color;
1124
1125         otmp = some_armor(&youmonst);
1126         if (!otmp) {
1127 #if 0 /*JP*/
1128             strange_feeling(sobj, !Blind
1129                                       ? "Your skin glows then fades."
1130                                       : "Your skin feels warm for a moment.");
1131 #else
1132             strange_feeling(sobj, !Blind
1133                             ? "\82 \82È\82½\82Ì\91Ì\82Í\88ê\8fu\8bP\82¢\82½\81D"
1134                             : "\82 \82È\82½\82Ì\91Ì\82Í\88ê\8fu\92g\82©\82­\82È\82Á\82½\81D");
1135 #endif
1136             sobj = 0; /* useup() in strange_feeling() */
1137             exercise(A_CON, !scursed);
1138             exercise(A_STR, !scursed);
1139             break;
1140         }
1141         if (confused) {
1142             old_erodeproof = (otmp->oerodeproof != 0);
1143             new_erodeproof = !scursed;
1144             otmp->oerodeproof = 0; /* for messages */
1145             if (Blind) {
1146                 otmp->rknown = FALSE;
1147 /*JP
1148                 pline("%s warm for a moment.", Yobjnam2(otmp, "feel"));
1149 */
1150                 Your("%s\82Í\88ê\8fu\92g\82©\82­\82È\82Á\82½\81D", xname(otmp));
1151             } else {
1152                 otmp->rknown = TRUE;
1153 #if 0 /*JP*/
1154                 pline("%s covered by a %s %s %s!", Yobjnam2(otmp, "are"),
1155                       scursed ? "mottled" : "shimmering",
1156                       hcolor(scursed ? NH_BLACK : NH_GOLDEN),
1157                       scursed ? "glow"
1158                               : (is_shield(otmp) ? "layer" : "shield"));
1159 #else
1160                 Your("%s\82Í%s%s%s\82Å\95¢\82í\82ê\82½\81I", xname(otmp),
1161                      jconj_adj(hcolor(scursed ? NH_BLACK : NH_GOLDEN)),
1162                      scursed ? "\8cõ\82é\82Ü\82¾\82ç\82Ì" : "\82ä\82ç\82ß\82­",
1163                      scursed ? "\8bP\82«"
1164                              : "\83o\83\8a\83A");
1165 #endif
1166             }
1167             if (new_erodeproof && (otmp->oeroded || otmp->oeroded2)) {
1168                 otmp->oeroded = otmp->oeroded2 = 0;
1169 #if 0 /*JP*/
1170                 pline("%s as good as new!",
1171                       Yobjnam2(otmp, Blind ? "feel" : "look"));
1172 #else
1173                 Your("%s\82Í\90V\95i\93¯\97l\82É\82È\82Á\82½\81I",
1174                      xname(otmp));
1175 #endif
1176             }
1177             if (old_erodeproof && !new_erodeproof) {
1178                 /* restore old_erodeproof before shop charges */
1179                 otmp->oerodeproof = 1;
1180                 costly_alteration(otmp, COST_DEGRD);
1181             }
1182             otmp->oerodeproof = new_erodeproof ? 1 : 0;
1183             break;
1184         }
1185         /* elven armor vibrates warningly when enchanted beyond a limit */
1186         special_armor = is_elven_armor(otmp)
1187                         || (Role_if(PM_WIZARD) && otmp->otyp == CORNUTHAUM);
1188         if (scursed)
1189             same_color = (otmp->otyp == BLACK_DRAGON_SCALE_MAIL
1190                           || otmp->otyp == BLACK_DRAGON_SCALES);
1191         else
1192             same_color = (otmp->otyp == SILVER_DRAGON_SCALE_MAIL
1193                           || otmp->otyp == SILVER_DRAGON_SCALES
1194                           || otmp->otyp == SHIELD_OF_REFLECTION);
1195         if (Blind)
1196             same_color = FALSE;
1197
1198         /* KMH -- catch underflow */
1199         s = scursed ? -otmp->spe : otmp->spe;
1200         if (s > (special_armor ? 5 : 3) && rn2(s)) {
1201             otmp->in_use = TRUE;
1202 #if 0 /*JP*/
1203             pline("%s violently %s%s%s for a while, then %s.", Yname2(otmp),
1204                   otense(otmp, Blind ? "vibrate" : "glow"),
1205                   (!Blind && !same_color) ? " " : "",
1206                   (Blind || same_color) ? "" : hcolor(scursed ? NH_BLACK
1207                                                               : NH_SILVER),
1208                   otense(otmp, "evaporate"));
1209 #else
1210             Your("%s\82Í\82µ\82Î\82ç\82­\82Ì\8aÔ\8c\83\82µ\82­%s%s\81C\8fö\94­\82µ\82½\81D", xname(otmp),
1211                  (Blind || same_color) ? "" : jconj_adj(hcolor(scursed ? NH_BLACK : NH_SILVER)),
1212                  Blind ? "\90U\93®\82µ" : "\8bP\82«");
1213 #endif
1214             remove_worn_item(otmp, FALSE);
1215             useup(otmp);
1216             break;
1217         }
1218         s = scursed ? -1 : otmp->spe >= 9
1219                                ? (rn2(otmp->spe) == 0)
1220                                : sblessed ? rnd(3 - otmp->spe / 3) : 1;
1221         if (s >= 0 && Is_dragon_scales(otmp)) {
1222             /* dragon scales get turned into dragon scale mail */
1223 /*JP
1224             pline("%s merges and hardens!", Yname2(otmp));
1225 */
1226             Your("%s\82Í\97Z\8d\87\82µ\8cÅ\82­\82È\82Á\82½\81I", xname(otmp));
1227             setworn((struct obj *) 0, W_ARM);
1228             /* assumes same order */
1229             otmp->otyp += GRAY_DRAGON_SCALE_MAIL - GRAY_DRAGON_SCALES;
1230             if (sblessed) {
1231                 otmp->spe++;
1232                 if (!otmp->blessed)
1233                     bless(otmp);
1234             } else if (otmp->cursed)
1235                 uncurse(otmp);
1236             otmp->known = 1;
1237             setworn(otmp, W_ARM);
1238             if (otmp->unpaid)
1239                 alter_cost(otmp, 0L); /* shop bill */
1240             break;
1241         }
1242 #if 0 /*JP*/
1243         pline("%s %s%s%s%s for a %s.", Yname2(otmp),
1244               s == 0 ? "violently " : "",
1245               otense(otmp, Blind ? "vibrate" : "glow"),
1246               (!Blind && !same_color) ? " " : "",
1247               (Blind || same_color) ? ""
1248                                     : hcolor(scursed ? NH_BLACK : NH_SILVER),
1249               (s * s > 1) ? "while" : "moment");
1250 #else
1251         Your("%s\82Í%s%s%s%s\81D", xname(otmp),
1252              (s * s > 1) ? "\82µ\82Î\82ç\82­\82Ì\8aÔ" : "\88ê\8fu",
1253              s == 0 ? "\8c\83\82µ\82­" : "",
1254              (Blind || same_color) ? ""
1255                                    : jconj_adj(hcolor(sobj->cursed ? NH_BLACK : NH_SILVER)),
1256              Blind ? "\90U\93®\82µ\82½" : "\8bP\82¢\82½");
1257 #endif
1258         /* [this cost handling will need updating if shop pricing is
1259            ever changed to care about curse/bless status of armor] */
1260         if (s < 0)
1261             costly_alteration(otmp, COST_DECHNT);
1262         if (scursed && !otmp->cursed)
1263             curse(otmp);
1264         else if (sblessed && !otmp->blessed)
1265             bless(otmp);
1266         if (s) {
1267             otmp->spe += s;
1268             adj_abon(otmp, s);
1269             known = otmp->known;
1270             /* update shop bill to reflect new higher price */
1271             if (s > 0 && otmp->unpaid)
1272                 alter_cost(otmp, 0L);
1273         }
1274
1275         if ((otmp->spe > (special_armor ? 5 : 3))
1276             && (special_armor || !rn2(7)))
1277 #if 0 /*JP*/
1278             pline("%s %s.", Yobjnam2(otmp, "suddenly vibrate"),
1279                   Blind ? "again" : "unexpectedly");
1280 #else
1281             Your("%s\82Í\93Ë\91R%s\90U\93®\82µ\82½\81D", xname(otmp),
1282                  Blind ? "\82Ü\82½" : "\8ev\82¢\82à\82æ\82ç\82¸");
1283 #endif
1284         break;
1285     }
1286     case SCR_DESTROY_ARMOR: {
1287         otmp = some_armor(&youmonst);
1288         if (confused) {
1289             if (!otmp) {
1290 /*JP
1291                 strange_feeling(sobj, "Your bones itch.");
1292 */
1293                 strange_feeling(sobj, "\8d\9c\82ª\83\80\83Y\83\80\83Y\82·\82é\81D");
1294                 sobj = 0; /* useup() in strange_feeling() */
1295                 exercise(A_STR, FALSE);
1296                 exercise(A_CON, FALSE);
1297                 break;
1298             }
1299             old_erodeproof = (otmp->oerodeproof != 0);
1300             new_erodeproof = scursed;
1301             otmp->oerodeproof = 0; /* for messages */
1302             p_glow2(otmp, NH_PURPLE);
1303             if (old_erodeproof && !new_erodeproof) {
1304                 /* restore old_erodeproof before shop charges */
1305                 otmp->oerodeproof = 1;
1306                 costly_alteration(otmp, COST_DEGRD);
1307             }
1308             otmp->oerodeproof = new_erodeproof ? 1 : 0;
1309             break;
1310         }
1311         if (!scursed || !otmp || !otmp->cursed) {
1312             if (!destroy_arm(otmp)) {
1313 /*JP
1314                 strange_feeling(sobj, "Your skin itches.");
1315 */
1316                 strange_feeling(sobj,"\94ç\95\86\82ª\83\80\83Y\83\80\83Y\82·\82é\81D");
1317                 sobj = 0; /* useup() in strange_feeling() */
1318                 exercise(A_STR, FALSE);
1319                 exercise(A_CON, FALSE);
1320                 break;
1321             } else
1322                 known = TRUE;
1323         } else { /* armor and scroll both cursed */
1324 /*JP
1325             pline("%s.", Yobjnam2(otmp, "vibrate"));
1326 */
1327             Your("%s\82Í\90U\93®\82µ\82½\81D", xname(otmp));
1328             if (otmp->spe >= -6) {
1329                 otmp->spe += -1;
1330                 adj_abon(otmp, -1);
1331             }
1332             make_stunned((HStun & TIMEOUT) + (long) rn1(10, 10), TRUE);
1333         }
1334     } break;
1335     case SCR_CONFUSE_MONSTER:
1336     case SPE_CONFUSE_MONSTER:
1337         if (youmonst.data->mlet != S_HUMAN || scursed) {
1338             if (!HConfusion)
1339 /*JP
1340                 You_feel("confused.");
1341 */
1342                 You_feel("confused.");
1343             make_confused(HConfusion + rnd(100), FALSE);
1344         } else if (confused) {
1345             if (!sblessed) {
1346 #if 0 /*JP*/
1347                 Your("%s begin to %s%s.", makeplural(body_part(HAND)),
1348                      Blind ? "tingle" : "glow ",
1349                      Blind ? "" : hcolor(NH_PURPLE));
1350 #else
1351                 Your("%s\82Í%s%s\82Í\82\82ß\82½\81D", makeplural(body_part(HAND)),
1352                      Blind ? "" : jconj_adj(hcolor(NH_PURPLE)),
1353                      Blind ? "\83q\83\8a\83q\83\8a\82µ" : "\8bP\82«");
1354 #endif
1355                 make_confused(HConfusion + rnd(100), FALSE);
1356             } else {
1357 #if 0 /*JP*/
1358                 pline("A %s%s surrounds your %s.",
1359                       Blind ? "" : hcolor(NH_RED),
1360                       Blind ? "faint buzz" : " glow", body_part(HEAD));
1361 #else
1362                 pline("%s%s\82ª\82 \82È\82½\82Ì%s\82ð\8eæ\82è\8aª\82¢\82½\81D",
1363                       Blind ? "" : jconj_adj(hcolor(NH_RED)),
1364                       Blind ? "\82©\82·\82©\82É\83u\81[\83\93\82Æ\96Â\82é\82à\82Ì" : "\8bP\82­\82à\82Ì",
1365                       body_part(HEAD));
1366 #endif
1367                 make_confused(0L, TRUE);
1368             }
1369         } else {
1370             if (!sblessed) {
1371 #if 0 /*JP*/
1372                 Your("%s%s %s%s.", makeplural(body_part(HAND)),
1373                      Blind ? "" : " begin to glow",
1374                      Blind ? (const char *) "tingle" : hcolor(NH_RED),
1375                      u.umconf ? " even more" : "");
1376 #else
1377                 Your("%s\82Í%s%s%s\81D", makeplural(body_part(HAND)),
1378                      u.umconf ? "\8f­\82µ" : "",
1379                      Blind ? (const char *) "\83q\83\8a\83q\83\8a\82µ\82½" : jconj_adj(hcolor(NH_RED)),
1380                      Blind ? "" : "\8bP\82«\82Í\82\82ß\82½");
1381 #endif
1382                 u.umconf++;
1383             } else {
1384                 if (Blind)
1385 #if 0 /*JP*/
1386                     Your("%s tingle %s sharply.", makeplural(body_part(HAND)),
1387                          u.umconf ? "even more" : "very");
1388 #else
1389                     Your("%s\82Í%s\83s\83\8a\83s\83\8a\82·\82é\81D", makeplural(body_part(HAND)),
1390                          u.umconf ? "\8f­\82µ" : "\82Æ\82Ä\82à");
1391 #endif
1392                 else
1393 #if 0 /*JP*/
1394                     Your("%s glow a%s brilliant %s.",
1395                          makeplural(body_part(HAND)),
1396                          u.umconf ? "n even more" : "", hcolor(NH_RED));
1397 #else
1398                     Your("%s\82Í%s%s\96¾\82é\82­\8bP\82¢\82½\81D",
1399                          makeplural(body_part(HAND)),
1400                          u.umconf ? "\8f­\82µ" : "", jconj_adj(hcolor(NH_RED)));
1401 #endif
1402                 /* after a while, repeated uses become less effective */
1403                 if (u.umconf >= 40)
1404                     u.umconf++;
1405                 else
1406                     u.umconf += rn1(8, 2);
1407             }
1408         }
1409         break;
1410     case SCR_SCARE_MONSTER:
1411     case SPE_CAUSE_FEAR: {
1412         register int ct = 0;
1413         register struct monst *mtmp;
1414
1415         for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
1416             if (DEADMONSTER(mtmp))
1417                 continue;
1418             if (cansee(mtmp->mx, mtmp->my)) {
1419                 if (confused || scursed) {
1420                     mtmp->mflee = mtmp->mfrozen = mtmp->msleeping = 0;
1421                     mtmp->mcanmove = 1;
1422                 } else if (!resist(mtmp, sobj->oclass, 0, NOTELL))
1423                     monflee(mtmp, 0, FALSE, FALSE);
1424                 if (!mtmp->mtame)
1425                     ct++; /* pets don't laugh at you */
1426             }
1427         }
1428         if (otyp == SCR_SCARE_MONSTER || !ct)
1429 #if 0 /*JP*/
1430             You_hear("%s %s.", (confused || scursed) ? "sad wailing"
1431                                                      : "maniacal laughter",
1432                      !ct ? "in the distance" : "close by");
1433 #else
1434             You_hear("\89\93\82­\82Å%s\82ð\95·\82¢\82½\81D",
1435                      (confused || sobj->cursed) ? "\94ß\82µ\82­\8b\83\82«\8b©\82Ô\90º"
1436                                                 : "\8b\82Á\82½\82æ\82¤\82É\8fÎ\82¤\90º");
1437 #endif
1438         break;
1439     }
1440     case SCR_BLANK_PAPER:
1441         if (Blind)
1442 /*JP
1443             You("don't remember there being any magic words on this scroll.");
1444 */
1445             You("\8aª\95¨\82É\8eô\95\82ª\8f\91\82¢\82Ä\82È\82©\82Á\82½\82±\82Æ\82ð\8ev\82¢\82¾\82µ\82½\81D");
1446         else
1447 /*JP
1448             pline("This scroll seems to be blank.");
1449 */
1450             pline("\82±\82Ì\8aª\95¨\82É\82Í\89½\82à\8f\91\82¢\82Ä\82È\82¢\82æ\82¤\82É\8c©\82¦\82é\81D");
1451         known = TRUE;
1452         break;
1453     case SCR_REMOVE_CURSE:
1454     case SPE_REMOVE_CURSE: {
1455         register struct obj *obj;
1456
1457 #if 0 /*JP*/
1458         You_feel(!Hallucination
1459                      ? (!confused ? "like someone is helping you."
1460                                   : "like you need some help.")
1461                      : (!confused ? "in touch with the Universal Oneness."
1462                                   : "the power of the Force against you!"));
1463 #else
1464         You(!Hallucination
1465             ? (!confused ? "\92N\82©\82ª\82 \82È\82½\82ð\8f\95\82¯\82Ä\82¢\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D"
1466                          : "\8e©\95ª\82ª\8f\95\82¯\82ð\95K\97v\82Æ\82µ\82Ä\82¢\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D")
1467             : (!confused ? "\89F\92\88\92²\98a\82Ì\8c´\97\9d\82É\90G\82ê\82Ä\82¢\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D"
1468                          : "\83t\83H\81[\83X\82Ì\97Í\82ª\82 \82È\82½\82É\82Í\82Þ\82©\82Á\82Ä\82¢\82é\82æ\82¤\82É\8a´\82\82½\81I"));
1469 #endif
1470
1471         if (scursed) {
1472 /*JP
1473             pline_The("scroll disintegrates.");
1474 */
1475             pline("\8aª\95¨\82Í\95²\81X\82É\82È\82Á\82½\81D");
1476         } else {
1477             for (obj = invent; obj; obj = obj->nobj) {
1478                 long wornmask;
1479                 /* gold isn't subject to cursing and blessing */
1480                 if (obj->oclass == COIN_CLASS)
1481                     continue;
1482                 wornmask = (obj->owornmask & ~(W_BALL | W_ART | W_ARTI));
1483                 if (wornmask && !sblessed) {
1484                     /* handle a couple of special cases; we don't
1485                        allow auxiliary weapon slots to be used to
1486                        artificially increase number of worn items */
1487                     if (obj == uswapwep) {
1488                         if (!u.twoweap)
1489                             wornmask = 0L;
1490                     } else if (obj == uquiver) {
1491                         if (obj->oclass == WEAPON_CLASS) {
1492                             /* mergeable weapon test covers ammo,
1493                                missiles, spears, daggers & knives */
1494                             if (!objects[obj->otyp].oc_merge)
1495                                 wornmask = 0L;
1496                         } else if (obj->oclass == GEM_CLASS) {
1497                             /* possibly ought to check whether
1498                                alternate weapon is a sling... */
1499                             if (!uslinging())
1500                                 wornmask = 0L;
1501                         } else {
1502                             /* weptools don't merge and aren't
1503                                reasonable quivered weapons */
1504                             wornmask = 0L;
1505                         }
1506                     }
1507                 }
1508                 if (sblessed || wornmask || obj->otyp == LOADSTONE
1509                     || (obj->otyp == LEASH && obj->leashmon)) {
1510                     /* water price varies by curse/bless status */
1511                     boolean shop_h2o =
1512                         (obj->unpaid && obj->otyp == POT_WATER);
1513
1514                     if (confused) {
1515                         blessorcurse(obj, 2);
1516                         /* lose knowledge of this object's curse/bless
1517                            state (even if it didn't actually change) */
1518                         obj->bknown = 0;
1519                         /* blessorcurse() only affects uncursed items
1520                            so no need to worry about price of water
1521                            going down (hence no costly_alteration) */
1522                         if (shop_h2o && (obj->cursed || obj->blessed))
1523                             alter_cost(obj, 0L); /* price goes up */
1524                     } else if (obj->cursed) {
1525                         if (shop_h2o)
1526                             costly_alteration(obj, COST_UNCURS);
1527                         uncurse(obj);
1528                     }
1529                 }
1530             }
1531         }
1532         if (Punished && !confused)
1533             unpunish();
1534         if (u.utrap && u.utraptype == TT_BURIEDBALL) {
1535             buried_ball_to_freedom();
1536 /*JP
1537             pline_The("clasp on your %s vanishes.", body_part(LEG));
1538 */
1539             pline_The("%s\82Ì\8bà\8bï\82ª\8fÁ\82¦\82½\81D", body_part(LEG));
1540         }
1541         update_inventory();
1542         break;
1543     }
1544     case SCR_CREATE_MONSTER:
1545     case SPE_CREATE_MONSTER:
1546         if (create_critters(1 + ((confused || scursed) ? 12 : 0)
1547                                 + ((sblessed || rn2(73)) ? 0 : rnd(4)),
1548                             confused ? &mons[PM_ACID_BLOB]
1549                                      : (struct permonst *) 0,
1550                             FALSE))
1551             known = TRUE;
1552         /* no need to flush monsters; we ask for identification only if the
1553          * monsters are not visible
1554          */
1555         break;
1556     case SCR_ENCHANT_WEAPON:
1557         if (confused && uwep
1558             && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))) {
1559             old_erodeproof = (uwep->oerodeproof != 0);
1560             new_erodeproof = !scursed;
1561             uwep->oerodeproof = 0; /* for messages */
1562             if (Blind) {
1563                 uwep->rknown = FALSE;
1564 /*JP
1565                 Your("weapon feels warm for a moment.");
1566 */
1567                 pline("\95\90\8aí\82ª\88ê\8fu\92g\82©\82­\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
1568             } else {
1569                 uwep->rknown = TRUE;
1570 #if 0 /*JP*/
1571                 pline("%s covered by a %s %s %s!", Yobjnam2(uwep, "are"),
1572                       scursed ? "mottled" : "shimmering",
1573                       hcolor(scursed ? NH_PURPLE : NH_GOLDEN),
1574                       scursed ? "glow" : "shield");
1575 #else
1576                 Your("%s\82Í%s%s%s\82Å\95¢\82í\82ê\82½\81I", xname(uwep),
1577                      jconj_adj(hcolor(scursed ? NH_PURPLE : NH_GOLDEN)),
1578                      scursed ? "\8cõ\82é\82Ü\82¾\82ç\82Ì" : "\82ä\82ç\82ß\82­",
1579                      scursed ? "\8bP\82«" : "\83o\83\8a\83A");
1580 #endif
1581             }
1582             if (new_erodeproof && (uwep->oeroded || uwep->oeroded2)) {
1583                 uwep->oeroded = uwep->oeroded2 = 0;
1584 #if 0 /*JP*/
1585                 pline("%s as good as new!",
1586                       Yobjnam2(uwep, Blind ? "feel" : "look"));
1587 #else
1588                 pline("%s\82Í\90V\95i\93¯\97l\82É\82È\82Á\82½\81I", xname(uwep));
1589 #endif
1590             }
1591             if (old_erodeproof && !new_erodeproof) {
1592                 /* restore old_erodeproof before shop charges */
1593                 uwep->oerodeproof = 1;
1594                 costly_alteration(uwep, COST_DEGRD);
1595             }
1596             uwep->oerodeproof = new_erodeproof ? 1 : 0;
1597             break;
1598         }
1599         if (!chwepon(sobj,
1600                      scursed
1601                          ? -1
1602                          : !uwep ? 1 : (uwep->spe >= 9)
1603                                            ? !rn2(uwep->spe)
1604                                            : sblessed ? rnd(3 - uwep->spe / 3)
1605                                                       : 1))
1606             sobj = 0; /* nothing enchanted: strange_feeling -> useup */
1607         break;
1608     case SCR_TAMING:
1609     case SPE_CHARM_MONSTER: {
1610         int candidates, res, results, vis_results;
1611
1612         if (u.uswallow) {
1613             candidates = 1;
1614             results = vis_results = maybe_tame(u.ustuck, sobj);
1615         } else {
1616             int i, j, bd = confused ? 5 : 1;
1617             struct monst *mtmp;
1618
1619             /* note: maybe_tame() can return either positive or
1620                negative values, but not both for the same scroll */
1621             candidates = results = vis_results = 0;
1622             for (i = -bd; i <= bd; i++)
1623                 for (j = -bd; j <= bd; j++) {
1624                     if (!isok(u.ux + i, u.uy + j))
1625                         continue;
1626                     if ((mtmp = m_at(u.ux + i, u.uy + j)) != 0
1627                         || (!i && !j && (mtmp = u.usteed) != 0)) {
1628                         ++candidates;
1629                         res = maybe_tame(mtmp, sobj);
1630                         results += res;
1631                         if (canspotmon(mtmp))
1632                             vis_results += res;
1633                     }
1634                 }
1635         }
1636         if (!results) {
1637             pline("Nothing interesting %s.",
1638                   !candidates ? "happens" : "seems to happen");
1639         } else {
1640             pline_The("neighborhood %s %sfriendlier.",
1641                       vis_results ? "is" : "seems",
1642                       (results < 0) ? "un" : "");
1643             if (vis_results > 0)
1644                 known = TRUE;
1645         }
1646     } break;
1647     case SCR_GENOCIDE:
1648         if (!already_known)
1649 /*JP
1650             You("have found a scroll of genocide!");
1651 */
1652             pline("\82±\82ê\82Í\8bs\8eE\82Ì\8aª\95¨\82¾\81I");
1653         known = TRUE;
1654         if (sblessed)
1655             do_class_genocide();
1656         else
1657             do_genocide(!scursed | (2 * !!Confusion));
1658         break;
1659     case SCR_LIGHT:
1660         if (!confused || rn2(5)) {
1661             if (!Blind)
1662                 known = TRUE;
1663             litroom(!confused && !scursed, sobj);
1664             if (!confused && !scursed) {
1665                 if (lightdamage(sobj, TRUE, 5))
1666                     known = TRUE;
1667             }
1668         } else {
1669             /* could be scroll of create monster, don't set known ...*/
1670             (void) create_critters(1, !scursed ? &mons[PM_YELLOW_LIGHT]
1671                                                : &mons[PM_BLACK_LIGHT],
1672                                    TRUE);
1673             if (!objects[sobj->otyp].oc_uname)
1674                 docall(sobj);
1675         }
1676         break;
1677     case SCR_TELEPORTATION:
1678         if (confused || scursed) {
1679             level_tele();
1680         } else {
1681             known = scrolltele(sobj);
1682         }
1683         break;
1684     case SCR_GOLD_DETECTION:
1685         if ((confused || scursed) ? trap_detect(sobj) : gold_detect(sobj))
1686             sobj = 0; /* failure: strange_feeling() -> useup() */
1687         break;
1688     case SCR_FOOD_DETECTION:
1689     case SPE_DETECT_FOOD:
1690         if (food_detect(sobj))
1691             sobj = 0; /* nothing detected: strange_feeling -> useup */
1692         break;
1693     case SCR_IDENTIFY:
1694         /* known = TRUE; -- handled inline here */
1695         /* use up the scroll first, before makeknown() performs a
1696            perm_invent update; also simplifies empty invent check */
1697         useup(sobj);
1698         sobj = 0; /* it's gone */
1699         if (confused)
1700 /*JP
1701             You("identify this as an identify scroll.");
1702 */
1703             You("\82±\82ê\82Í\8e¯\95Ê\82Ì\8aª\95¨\82¾\82Æ\8e¯\95Ê\82µ\82½\81D");
1704         else if (!already_known || !invent)
1705             /* force feedback now if invent became
1706                empty after using up this scroll */
1707 /*JP
1708             pline("This is an identify scroll.");
1709 */
1710             pline("\82±\82ê\82Í\8e¯\95Ê\82Ì\8aª\95¨\82¾\81D");
1711         if (!already_known)
1712             (void) learnscrolltyp(SCR_IDENTIFY);
1713         /*FALLTHRU*/
1714     case SPE_IDENTIFY:
1715         cval = 1;
1716         if (sblessed || (!scursed && !rn2(5))) {
1717             cval = rn2(5);
1718             /* note: if cval==0, identify all items */
1719             if (cval == 1 && sblessed && Luck > 0)
1720                 ++cval;
1721         }
1722         if (invent && !confused) {
1723             identify_pack(cval, !already_known);
1724         } else if (otyp == SPE_IDENTIFY) {
1725             /* when casting a spell we know we're not confused,
1726                so inventory must be empty (another message has
1727                already been given above if reading a scroll) */
1728             pline("You're not carrying anything to be identified.");
1729         }
1730         break;
1731     case SCR_CHARGING:
1732         if (confused) {
1733             if (scursed) {
1734 /*JP
1735                 You_feel("discharged.");
1736 */
1737                 You_feel("\95ú\8fo\82³\82ê\82½\8bC\82ª\82·\82é\81D");
1738                 u.uen = 0;
1739             } else {
1740 /*JP
1741                 You_feel("charged up!");
1742 */
1743                 You_feel("\8f[\93U\82³\82ê\82½\82æ\82¤\82È\8bC\82ª\82·\82é\81I");
1744                 u.uen += d(sblessed ? 6 : 4, 4);
1745                 if (u.uen > u.uenmax) /* if current energy is already at   */
1746                     u.uenmax = u.uen; /* or near maximum, increase maximum */
1747                 else
1748                     u.uen = u.uenmax; /* otherwise restore current to max  */
1749             }
1750             context.botl = 1;
1751             break;
1752         }
1753         /* known = TRUE; -- handled inline here */
1754         if (!already_known) {
1755 /*JP
1756             pline("This is a charging scroll.");
1757 */
1758             pline("\82±\82ê\82Í\8f[\93U\82Ì\8aª\95¨\82¾\81I");
1759             learnscroll(sobj);
1760         }
1761         /* use it up now to prevent it from showing in the
1762            getobj picklist because the "disappears" message
1763            was already delivered */
1764         useup(sobj);
1765         sobj = 0; /* it's gone */
1766         otmp = getobj(all_count, "charge");
1767         if (otmp)
1768             recharge(otmp, scursed ? -1 : sblessed ? 1 : 0);
1769         break;
1770     case SCR_MAGIC_MAPPING:
1771         if (level.flags.nommap) {
1772 /*JP
1773             Your("mind is filled with crazy lines!");
1774 */
1775             Your("\90S\82É\82½\82¾\82È\82ç\82Ê\90ü\81I\90ü\81I\90ü\81I\82ª\95\82\82Ñ\82 \82ª\82Á\82½\81I");
1776             if (Hallucination)
1777 /*JP
1778                 pline("Wow!  Modern art.");
1779 */
1780                 pline("\83\8f\83H\81I\83\82\83_\83\93\83A\81[\83g\82¾\81I");
1781             else
1782 /*JP
1783                 Your("%s spins in bewilderment.", body_part(HEAD));
1784 */
1785                 You("\93\96\98f\82µ\82Ä\96Ú\82ª\82Ü\82í\82Á\82½\81D");
1786             make_confused(HConfusion + rnd(30), FALSE);
1787             break;
1788         }
1789         if (sblessed) {
1790             register int x, y;
1791
1792             for (x = 1; x < COLNO; x++)
1793                 for (y = 0; y < ROWNO; y++)
1794                     if (levl[x][y].typ == SDOOR)
1795                         cvt_sdoor_to_door(&levl[x][y]);
1796             /* do_mapping() already reveals secret passages */
1797         }
1798         known = TRUE;
1799     case SPE_MAGIC_MAPPING:
1800         if (level.flags.nommap) {
1801 #if 0 /*JP*/
1802             Your("%s spins as %s blocks the spell!", body_part(HEAD),
1803                  something);
1804 #else
1805             You("\89½\82©\82ª\8eô\95\82ð\82³\82¦\82¬\82è\81C\96Ú\82ª\82Ü\82í\82Á\82½\81I");
1806 #endif
1807             make_confused(HConfusion + rnd(30), FALSE);
1808             break;
1809         }
1810 /*JP
1811         pline("A map coalesces in your mind!");
1812 */
1813         pline("\92n\90}\82ª\82 \82È\82½\82Ì\90S\82É\97Z\8d\87\82µ\82½\81I");
1814         cval = (scursed && !confused);
1815         if (cval)
1816             HConfusion = 1; /* to screw up map */
1817         do_mapping();
1818         if (cval) {
1819             HConfusion = 0; /* restore */
1820 /*JP
1821             pline("Unfortunately, you can't grasp the details.");
1822 */
1823             pline("\8ec\94O\82È\82ª\82ç\81C\82 \82È\82½\82Í\8fÚ\8d×\82ð\93¾\82é\82±\82Æ\82ª\82Å\82«\82È\82©\82Á\82½\81D");
1824         }
1825         break;
1826     case SCR_AMNESIA:
1827         known = TRUE;
1828         forget((!sblessed ? ALL_SPELLS : 0)
1829                | (!confused || scursed ? ALL_MAP : 0));
1830         if (Hallucination) /* Ommmmmm! */
1831 /*JP
1832             Your("mind releases itself from mundane concerns.");
1833 */
1834             Your("\90S\82Í\95½\96}\82È\97\98\8aQ\8aÖ\8cW\82©\82ç\89ð\95ú\82³\82ê\82½\81D");
1835         else if (!strncmpi(plname, "Maud", 4))
1836             pline(
1837 /*JP
1838           "As your mind turns inward on itself, you forget everything else.");
1839 */
1840           "\82 \82È\82½\82Ì\90S\82Í\93à\91¤\82É\8cü\82«\81C\91S\82Ä\82ð\96Y\82ê\82Ä\82µ\82Ü\82Á\82½\81D");
1841         else if (rn2(2))
1842 /*JP
1843             pline("Who was that Maud person anyway?");
1844 */
1845             pline("Maud\82Á\82Ä\96º\82Í\82¢\82Á\82½\82¢\92N\82¾\82¢\81H");
1846         else
1847 /*JP
1848             pline("Thinking of Maud you forget everything else.");
1849 */
1850             pline("Maud\82ð\8dl\82¦\82é\82±\82Æ\88È\8aO\81C\82 \82È\82½\82Í\91S\82Ä\82ð\96Y\82ê\82Ä\82µ\82Ü\82Á\82½\81D");
1851         exercise(A_WIS, FALSE);
1852         break;
1853     case SCR_FIRE:
1854         cval = bcsign(sobj);
1855         useup(sobj);
1856         sobj = 0; /* it's gone */
1857         if (!already_known)
1858             (void) learnscrolltyp(SCR_FIRE);
1859         if (confused) {
1860             if (Fire_resistance) {
1861                 shieldeff(u.ux, u.uy);
1862                 if (!Blind)
1863 /*JP
1864                     pline("Oh, look, what a pretty fire in your %s.",
1865 */
1866                     pline("\82í\82\9f\82²\82ç\82ñ\81D\8f¬\82³\82È\89Î\82ª%s\82É\82 \82é\81D",
1867                           makeplural(body_part(HAND)));
1868                 else
1869 /*JP
1870                     You_feel("a pleasant warmth in your %s.",
1871 */
1872                     You_feel("%s\82Ì\92\86\82É\89õ\93K\82È\92g\82©\82³\82ð\8a´\82\82½\81D",
1873                              makeplural(body_part(HAND)));
1874             } else {
1875 /*JP
1876                 pline_The("scroll catches fire and you burn your %s.",
1877 */
1878                 pline("\8aª\95¨\82É\89Î\82ª\94R\82¦\82¤\82Â\82è\81C\82 \82È\82½\82Ì%s\82ð\8fÄ\82¢\82½\81D",
1879                           makeplural(body_part(HAND)));
1880 /*JP
1881                 losehp(1, "scroll of fire", KILLED_BY_AN);
1882 */
1883                 losehp(1, "\89\8a\82Ì\8aª\95¨\82Å", KILLED_BY_AN);
1884             }
1885             break;
1886         }
1887         if (Underwater) {
1888 /*JP
1889             pline_The("water around you vaporizes violently!");
1890 */
1891             pline("\82 \82È\82½\82Ì\89ñ\82è\82Ì\90\85\82Í\95¦\93«\82µ\82½\81I");
1892         } else {
1893 /*JP
1894             pline_The("scroll erupts in a tower of flame!");
1895 */
1896             pline("\8aª\95¨\82©\82ç\89Î\92\8c\82ª\97§\82¿\8f¸\82Á\82½\81I");
1897             iflags.last_msg = PLNMSG_TOWER_OF_FLAME; /* for explode() */
1898             burn_away_slime();
1899         }
1900         explode(u.ux, u.uy, 11, (2 * (rn1(3, 3) + 2 * cval) + 1) / 3,
1901                 SCROLL_CLASS, EXPL_FIERY);
1902         break;
1903     case SCR_EARTH:
1904         /* TODO: handle steeds */
1905         if (!Is_rogue_level(&u.uz) && has_ceiling(&u.uz)
1906             && (!In_endgame(&u.uz) || Is_earthlevel(&u.uz))) {
1907             register int x, y;
1908             int nboulders = 0;
1909
1910             /* Identify the scroll */
1911             if (u.uswallow)
1912 /*JP
1913                 You_hear("rumbling.");
1914 */
1915                 You_hear("\83S\83\8d\83S\83\8d\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81D");
1916             else
1917 #if 0 /*JP*/
1918                 pline_The("%s rumbles %s you!", ceiling(u.ux, u.uy),
1919                           sblessed ? "around" : "above");
1920 #else
1921                 pline("\82 \82È\82½\82Ì%s\82Ì%s\82©\82ç\83S\83\8d\83S\83\8d\82Æ\89¹\82ª\95·\82±\82¦\82Ä\82«\82½\81I",
1922                       sblessed ? "\82Ü\82í\82è" : "\90^\8fã", ceiling(u.ux,u.uy));
1923 #endif
1924             known = 1;
1925             sokoban_guilt();
1926
1927             /* Loop through the surrounding squares */
1928             if (!scursed)
1929                 for (x = u.ux - 1; x <= u.ux + 1; x++) {
1930                     for (y = u.uy - 1; y <= u.uy + 1; y++) {
1931                         /* Is this a suitable spot? */
1932                         if (isok(x, y) && !closed_door(x, y)
1933                             && !IS_ROCK(levl[x][y].typ)
1934                             && !IS_AIR(levl[x][y].typ)
1935                             && (x != u.ux || y != u.uy)) {
1936                             nboulders +=
1937                                 drop_boulder_on_monster(x, y, confused, TRUE);
1938                         }
1939                     }
1940                 }
1941             /* Attack the player */
1942             if (!sblessed) {
1943                 drop_boulder_on_player(confused, !scursed, TRUE, FALSE);
1944             } else if (!nboulders)
1945                 pline("But nothing else happens.");
1946         }
1947         break;
1948     case SCR_PUNISHMENT:
1949         known = TRUE;
1950         if (confused || sblessed) {
1951 /*JP
1952             You_feel("guilty.");
1953 */
1954             You("\8dß\82ð\8a´\82\82½\81D");
1955             break;
1956         }
1957         punish(sobj);
1958         break;
1959     case SCR_STINKING_CLOUD: {
1960         coord cc;
1961
1962         if (!already_known)
1963 /*JP
1964             You("have found a scroll of stinking cloud!");
1965 */
1966             You("\88«\8fL\89_\82Ì\8aª\95¨\82ð\94­\8c©\82µ\82½\81I");
1967         known = TRUE;
1968 #if 0 /*JP*/
1969         pline("Where do you want to center the %scloud?",
1970               already_known ? "stinking " : "");
1971 #else
1972         pline("\89_\82Ì\92\86\90S\82ð\82Ç\82±\82É\82µ\82Ü\82·\82©\81H");
1973 #endif
1974         cc.x = u.ux;
1975         cc.y = u.uy;
1976         getpos_sethilite(display_stinking_cloud_positions);
1977 /*JP
1978         if (getpos(&cc, TRUE, "the desired position") < 0) {
1979 */
1980         if (getpos(&cc, TRUE, "\91_\82¤\8fê\8f\8a") < 0) {
1981             pline1(Never_mind);
1982             break;
1983         }
1984         if (!is_valid_stinking_cloud_pos(cc.x, cc.y, TRUE))
1985             break;
1986         (void) create_gas_cloud(cc.x, cc.y, 3 + bcsign(sobj),
1987                                 8 + 4 * bcsign(sobj));
1988         break;
1989     }
1990     default:
1991         impossible("What weird effect is this? (%u)", otyp);
1992     }
1993     return sobj ? 0 : 1;
1994 }
1995
1996 void
1997 drop_boulder_on_player(confused, helmet_protects, byu, skip_uswallow)
1998 boolean confused, helmet_protects, byu, skip_uswallow;
1999 {
2000     int dmg;
2001     struct obj *otmp2;
2002
2003     /* hit monster if swallowed */
2004     if (u.uswallow && !skip_uswallow) {
2005         drop_boulder_on_monster(u.ux, u.uy, confused, byu);
2006         return;
2007     }
2008
2009     otmp2 = mksobj(confused ? ROCK : BOULDER, FALSE, FALSE);
2010     if (!otmp2)
2011         return;
2012     otmp2->quan = confused ? rn1(5, 2) : 1;
2013     otmp2->owt = weight(otmp2);
2014     if (!amorphous(youmonst.data) && !Passes_walls
2015         && !noncorporeal(youmonst.data) && !unsolid(youmonst.data)) {
2016 /*JP
2017         You("are hit by %s!", doname(otmp2));
2018 */
2019         pline("%s\82ª\96½\92\86\82µ\82½\81I", doname(otmp2));
2020         dmg = dmgval(otmp2, &youmonst) * otmp2->quan;
2021         if (uarmh && helmet_protects) {
2022             if (is_metallic(uarmh)) {
2023 /*JP
2024                 pline("Fortunately, you are wearing a hard helmet.");
2025 */
2026                 pline("\8dK\89^\82É\82à\81C\82 \82È\82½\82Í\8cÅ\82¢\8a\95\82ð\90g\82É\82Â\82¯\82Ä\82¢\82é\81D");
2027                 if (dmg > 2)
2028                     dmg = 2;
2029             } else if (flags.verbose) {
2030 /*JP
2031                 pline("%s does not protect you.", Yname2(uarmh));
2032 */
2033                 Your("%s\82Å\82Í\8eç\82ê\82È\82¢\81D", xname(uarmh));
2034             }
2035         }
2036     } else
2037         dmg = 0;
2038     /* Must be before the losehp(), for bones files */
2039 /*JP
2040     if (!flooreffects(otmp2, u.ux, u.uy, "fall")) {
2041 */
2042     if (!flooreffects(otmp2, u.ux, u.uy, "\97\8e\82¿\82é")) {
2043         place_object(otmp2, u.ux, u.uy);
2044         stackobj(otmp2);
2045         newsym(u.ux, u.uy);
2046     }
2047     if (dmg)
2048 /*JP
2049         losehp(Maybe_Half_Phys(dmg), "scroll of earth", KILLED_BY_AN);
2050 */
2051         losehp(Maybe_Half_Phys(dmg), "\91å\92n\82Ì\8aª\95¨\82Å", KILLED_BY_AN);
2052 }
2053
2054 boolean
2055 drop_boulder_on_monster(x, y, confused, byu)
2056 int x, y;
2057 boolean confused, byu;
2058 {
2059     register struct obj *otmp2;
2060     register struct monst *mtmp;
2061
2062     /* Make the object(s) */
2063     otmp2 = mksobj(confused ? ROCK : BOULDER, FALSE, FALSE);
2064     if (!otmp2)
2065         return FALSE; /* Shouldn't happen */
2066     otmp2->quan = confused ? rn1(5, 2) : 1;
2067     otmp2->owt = weight(otmp2);
2068
2069     /* Find the monster here (won't be player) */
2070     mtmp = m_at(x, y);
2071     if (mtmp && !amorphous(mtmp->data) && !passes_walls(mtmp->data)
2072         && !noncorporeal(mtmp->data) && !unsolid(mtmp->data)) {
2073         struct obj *helmet = which_armor(mtmp, W_ARMH);
2074         int mdmg;
2075
2076         if (cansee(mtmp->mx, mtmp->my)) {
2077 /*JP
2078             pline("%s is hit by %s!", Monnam(mtmp), doname(otmp2));
2079 */
2080             pline("%s\82ª%s\82É\96½\92\86\82µ\82½\81I", doname(otmp2), Monnam(mtmp));
2081             if (mtmp->minvis && !canspotmon(mtmp))
2082                 map_invisible(mtmp->mx, mtmp->my);
2083         } else if (u.uswallow && mtmp == u.ustuck)
2084             You_hear("something hit %s %s over your %s!",
2085                      s_suffix(mon_nam(mtmp)), mbodypart(mtmp, STOMACH),
2086                      body_part(HEAD));
2087
2088         mdmg = dmgval(otmp2, mtmp) * otmp2->quan;
2089         if (helmet) {
2090             if (is_metallic(helmet)) {
2091                 if (canspotmon(mtmp))
2092 /*JP
2093                     pline("Fortunately, %s is wearing a hard helmet.",
2094 */
2095                     pline("\8dK\89^\82É\82à\81C%s\82Í\8cÅ\82¢\8a\95\82ð\90g\82É\82Â\82¯\82Ä\82¢\82é\81D",
2096                           mon_nam(mtmp));
2097                 else if (!Deaf)
2098 /*JP
2099                     You_hear("a clanging sound.");
2100 */
2101                     You_hear("\83K\83\89\83\93\83K\83\89\83\93\82Æ\82¢\82¤\89¹\82ð\95·\82¢\82½\81D");
2102                 if (mdmg > 2)
2103                     mdmg = 2;
2104             } else {
2105                 if (canspotmon(mtmp))
2106 #if 0 /*JP*/
2107                     pline("%s's %s does not protect %s.", Monnam(mtmp),
2108                           xname(helmet), mhim(mtmp));
2109 #else
2110                     pline("%s\82Ì%s\82Å\82Í\8eç\82ê\82È\82¢\81D", Monnam(mtmp),
2111                           xname(helmet));
2112 #endif
2113             }
2114         }
2115         mtmp->mhp -= mdmg;
2116         if (mtmp->mhp <= 0) {
2117             if (byu)
2118                 xkilled(mtmp, 1);
2119             else {
2120                 pline("%s is killed.", Monnam(mtmp));
2121                 mondied(mtmp);
2122             }
2123         }
2124     } else if (u.uswallow && mtmp == u.ustuck) {
2125         obfree(otmp2, (struct obj *) 0);
2126         /* fall through to player */
2127         drop_boulder_on_player(confused, TRUE, FALSE, TRUE);
2128         return 1;
2129     }
2130     /* Drop the rock/boulder to the floor */
2131 /*JP
2132     if (!flooreffects(otmp2, x, y, "fall")) {
2133 */
2134     if (!flooreffects(otmp2, x, y, "\97\8e\82¿\82é")) {
2135         place_object(otmp2, x, y);
2136         stackobj(otmp2);
2137         newsym(x, y); /* map the rock */
2138     }
2139     return TRUE;
2140 }
2141
2142 /* overcharging any wand or zapping/engraving cursed wand */
2143 void
2144 wand_explode(obj, chg)
2145 struct obj *obj;
2146 int chg; /* recharging */
2147 {
2148 /*JP
2149     const char *expl = !chg ? "suddenly" : "vibrates violently and";
2150 */
2151     const char *expl = !chg ? "\93Ë\91R" : "\8c\83\82µ\82­\90U\93®\82µ\81C";
2152     int dmg, n, k;
2153
2154     /* number of damage dice */
2155     if (!chg)
2156         chg = 2; /* zap/engrave adjustment */
2157     n = obj->spe + chg;
2158     if (n < 2)
2159         n = 2; /* arbitrary minimum */
2160     /* size of damage dice */
2161     switch (obj->otyp) {
2162     case WAN_WISHING:
2163         k = 12;
2164         break;
2165     case WAN_CANCELLATION:
2166     case WAN_DEATH:
2167     case WAN_POLYMORPH:
2168     case WAN_UNDEAD_TURNING:
2169         k = 10;
2170         break;
2171     case WAN_COLD:
2172     case WAN_FIRE:
2173     case WAN_LIGHTNING:
2174     case WAN_MAGIC_MISSILE:
2175         k = 8;
2176         break;
2177     case WAN_NOTHING:
2178         k = 4;
2179         break;
2180     default:
2181         k = 6;
2182         break;
2183     }
2184     /* inflict damage and destroy the wand */
2185     dmg = d(n, k);
2186     obj->in_use = TRUE; /* in case losehp() is fatal (or --More--^C) */
2187 #if 0 /*JP*/
2188     pline("%s %s explodes!", Yname2(obj), expl);
2189 #else
2190     pline("%s\82Í%s\94\9a\94­\82µ\82½\81I", xname(obj), expl);
2191 #endif
2192 /*JP
2193     losehp(Maybe_Half_Phys(dmg), "exploding wand", KILLED_BY_AN);
2194 */
2195     losehp(Maybe_Half_Phys(dmg), "\8fñ\82Ì\94\9a\94­\82Å", KILLED_BY_AN);
2196     useup(obj);
2197     /* obscure side-effect */
2198     exercise(A_STR, FALSE);
2199 }
2200
2201 /* used to collect gremlins being hit by light so that they can be processed
2202    after vision for the entire lit area has been brought up to date */
2203 struct litmon {
2204     struct monst *mon;
2205     struct litmon *nxt;
2206 };
2207 STATIC_VAR struct litmon *gremlins = 0;
2208
2209 /*
2210  * Low-level lit-field update routine.
2211  */
2212 STATIC_PTR void
2213 set_lit(x, y, val)
2214 int x, y;
2215 genericptr_t val;
2216 {
2217     struct monst *mtmp;
2218     struct litmon *gremlin;
2219
2220     if (val) {
2221         levl[x][y].lit = 1;
2222         if ((mtmp = m_at(x, y)) != 0 && mtmp->data == &mons[PM_GREMLIN]) {
2223             gremlin = (struct litmon *) alloc(sizeof *gremlin);
2224             gremlin->mon = mtmp;
2225             gremlin->nxt = gremlins;
2226             gremlins = gremlin;
2227         }
2228     } else {
2229         levl[x][y].lit = 0;
2230         snuff_light_source(x, y);
2231     }
2232 }
2233
2234 void
2235 litroom(on, obj)
2236 register boolean on;
2237 struct obj *obj;
2238 {
2239     char is_lit; /* value is irrelevant; we use its address
2240                     as a `not null' flag for set_lit() */
2241
2242     /* first produce the text (provided you're not blind) */
2243     if (!on) {
2244         register struct obj *otmp;
2245
2246         if (!Blind) {
2247             if (u.uswallow) {
2248 /*JP
2249                 pline("It seems even darker in here than before.");
2250 */
2251                 pline("\91O\82æ\82è\88Ã\82­\82È\82Á\82½\82æ\82¤\82É\8c©\82¦\82é\81D");
2252             } else {
2253                 if (uwep && artifact_light(uwep) && uwep->lamplit)
2254 /*JP
2255                     pline("Suddenly, the only light left comes from %s!",
2256 */
2257                     pline("\93Ë\91R\81C\96¾\82©\82è\82ª%s\82¾\82¯\82É\82È\82Á\82½\81I",
2258                           the(xname(uwep)));
2259                 else
2260 /*JP
2261                     You("are surrounded by darkness!");
2262 */
2263                     You("\88Ã\88Å\82É\95¢\82í\82ê\82½\81I");
2264             }
2265         }
2266
2267         /* the magic douses lamps, et al, too */
2268         for (otmp = invent; otmp; otmp = otmp->nobj)
2269             if (otmp->lamplit)
2270                 (void) snuff_lit(otmp);
2271     } else { /* on */
2272         if (u.uswallow) {
2273             if (Blind)
2274                 ; /* no feedback */
2275             else if (is_animal(u.ustuck->data))
2276 #if 0 /*JP*/
2277                 pline("%s %s is lit.", s_suffix(Monnam(u.ustuck)),
2278                       mbodypart(u.ustuck, STOMACH));
2279 #else
2280                 pline("%s\82Ì%s\82Í\96¾\82é\82­\82È\82Á\82½\81D", Monnam(u.ustuck),
2281                       mbodypart(u.ustuck, STOMACH));
2282 #endif
2283             else if (is_whirly(u.ustuck->data))
2284 /*JP
2285                 pline("%s shines briefly.", Monnam(u.ustuck));
2286 */
2287                 pline("%s\82Í\82¿\82å\82Á\82Æ\8bP\82¢\82½\81D", Monnam(u.ustuck));
2288             else
2289 /*JP
2290                 pline("%s glistens.", Monnam(u.ustuck));
2291 */
2292                 pline("%s\82Í\82«\82ç\82«\82ç\8bP\82¢\82½\81D", Monnam(u.ustuck));
2293         } else if (!Blind)
2294 /*JP
2295             pline("A lit field surrounds you!");
2296 */
2297             pline("\93\94\82è\82ª\82 \82È\82½\82ð\8eæ\82è\88Í\82ñ\82¾\81I");
2298     }
2299
2300     /* No-op when swallowed or in water */
2301     if (u.uswallow || Underwater || Is_waterlevel(&u.uz))
2302         return;
2303     /*
2304      *  If we are darkening the room and the hero is punished but not
2305      *  blind, then we have to pick up and replace the ball and chain so
2306      *  that we don't remember them if they are out of sight.
2307      */
2308     if (Punished && !on && !Blind)
2309         move_bc(1, 0, uball->ox, uball->oy, uchain->ox, uchain->oy);
2310
2311     if (Is_rogue_level(&u.uz)) {
2312         /* Can't use do_clear_area because MAX_RADIUS is too small */
2313         /* rogue lighting must light the entire room */
2314         int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET;
2315         int rx, ry;
2316
2317         if (rnum >= 0) {
2318             for (rx = rooms[rnum].lx - 1; rx <= rooms[rnum].hx + 1; rx++)
2319                 for (ry = rooms[rnum].ly - 1; ry <= rooms[rnum].hy + 1; ry++)
2320                     set_lit(rx, ry,
2321                             (genericptr_t) (on ? &is_lit : (char *) 0));
2322             rooms[rnum].rlit = on;
2323         }
2324         /* hallways remain dark on the rogue level */
2325     } else
2326         do_clear_area(u.ux, u.uy,
2327                       (obj && obj->oclass == SCROLL_CLASS && obj->blessed)
2328                          ? 9 : 5,
2329                       set_lit, (genericptr_t) (on ? &is_lit : (char *) 0));
2330
2331     /*
2332      *  If we are not blind, then force a redraw on all positions in sight
2333      *  by temporarily blinding the hero.  The vision recalculation will
2334      *  correctly update all previously seen positions *and* correctly
2335      *  set the waslit bit [could be messed up from above].
2336      */
2337     if (!Blind) {
2338         vision_recalc(2);
2339
2340         /* replace ball&chain */
2341         if (Punished && !on)
2342             move_bc(0, 0, uball->ox, uball->oy, uchain->ox, uchain->oy);
2343     }
2344
2345     vision_full_recalc = 1; /* delayed vision recalculation */
2346     if (gremlins) {
2347         struct litmon *gremlin;
2348
2349         /* can't delay vision recalc after all */
2350         vision_recalc(0);
2351         /* after vision has been updated, monsters who are affected
2352            when hit by light can now be hit by it */
2353         do {
2354             gremlin = gremlins;
2355             gremlins = gremlin->nxt;
2356             light_hits_gremlin(gremlin->mon, rnd(5));
2357             free((genericptr_t) gremlin);
2358         } while (gremlins);
2359     }
2360 }
2361
2362 STATIC_OVL void
2363 do_class_genocide()
2364 {
2365     int i, j, immunecnt, gonecnt, goodcnt, class, feel_dead = 0;
2366     char buf[BUFSZ];
2367     boolean gameover = FALSE; /* true iff killed self */
2368
2369     for (j = 0;; j++) {
2370         if (j >= 5) {
2371             pline1(thats_enough_tries);
2372             return;
2373         }
2374         do {
2375 /*JP
2376             getlin("What class of monsters do you wish to genocide?", buf);
2377 */
2378             getlin("\82Ç\82Ì\83N\83\89\83X\82É\91®\82·\82é\89ö\95¨\82ð\8bs\8eE\82µ\82Ü\82·\82©\81H[\95\8e\9a\82ð\93ü\82ê\82Ä\82Ë]", buf);
2379             (void) mungspaces(buf);
2380         } while (!*buf);
2381         /* choosing "none" preserves genocideless conduct */
2382 #if 0 /*JP*/
2383         if (*buf == '\033' || !strcmpi(buf, "none")
2384             || !strcmpi(buf, "nothing"))
2385 #else
2386         if (*buf == '\033' || !strcmpi(buf, "\82È\82µ")
2387             || !strcmpi(buf, "\96³\82µ"))
2388 #endif
2389             return;
2390
2391         class = name_to_monclass(buf, (int *) 0);
2392         if (class == 0 && (i = name_to_mon(buf)) != NON_PM)
2393             class = mons[i].mlet;
2394         immunecnt = gonecnt = goodcnt = 0;
2395         for (i = LOW_PM; i < NUMMONS; i++) {
2396             if (mons[i].mlet == class) {
2397                 if (!(mons[i].geno & G_GENO))
2398                     immunecnt++;
2399                 else if (mvitals[i].mvflags & G_GENOD)
2400                     gonecnt++;
2401                 else
2402                     goodcnt++;
2403             }
2404         }
2405         if (!goodcnt && class != mons[urole.malenum].mlet
2406             && class != mons[urace.malenum].mlet) {
2407             if (gonecnt)
2408 /*JP
2409                 pline("All such monsters are already nonexistent.");
2410 */
2411                 pline("\82»\82Ì\89ö\95¨\82Í\82à\82¤\82¢\82È\82¢\81D");
2412             else if (immunecnt || class == S_invisible)
2413 /*JP
2414                 You("aren't permitted to genocide such monsters.");
2415 */
2416                 You("\82»\82Ì\89ö\95¨\82ð\8bs\8eE\82·\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
2417             else if (wizard && buf[0] == '*') {
2418                 register struct monst *mtmp, *mtmp2;
2419
2420                 gonecnt = 0;
2421                 for (mtmp = fmon; mtmp; mtmp = mtmp2) {
2422                     mtmp2 = mtmp->nmon;
2423                     if (DEADMONSTER(mtmp))
2424                         continue;
2425                     mongone(mtmp);
2426                     gonecnt++;
2427                 }
2428 /*JP
2429                 pline("Eliminated %d monster%s.", gonecnt, plur(gonecnt));
2430 */
2431                 pline("%d\82Ì\89ö\95¨\82ð\8f\9c\82¢\82½\81D", gonecnt);
2432                 return;
2433             } else
2434 #if 0 /*JP*/
2435                 pline("That %s does not represent any monster.",
2436                       strlen(buf) == 1 ? "symbol" : "response");
2437 #else
2438                 pline("\82»\82Ì\82æ\82¤\82È\89ö\95¨\82Í\82¢\82È\82¢\81D");
2439 #endif
2440             continue;
2441         }
2442
2443         for (i = LOW_PM; i < NUMMONS; i++) {
2444             if (mons[i].mlet == class) {
2445                 char nam[BUFSZ];
2446
2447                 Strcpy(nam, makeplural(mons[i].mname));
2448                 /* Although "genus" is Latin for race, the hero benefits
2449                  * from both race and role; thus genocide affects either.
2450                  */
2451                 if (Your_Own_Role(i) || Your_Own_Race(i)
2452                     || ((mons[i].geno & G_GENO)
2453                         && !(mvitals[i].mvflags & G_GENOD))) {
2454                     /* This check must be first since player monsters might
2455                      * have G_GENOD or !G_GENO.
2456                      */
2457                     mvitals[i].mvflags |= (G_GENOD | G_NOCORPSE);
2458                     reset_rndmonst(i);
2459                     kill_genocided_monsters();
2460                     update_inventory(); /* eggs & tins */
2461 /*JP
2462                     pline("Wiped out all %s.", nam);
2463 */
2464                     pline("%s\82ð\91S\82Ä\94r\8f\9c\82µ\82½\81D", nam);
2465                     if (Upolyd && i == u.umonnum) {
2466                         u.mh = -1;
2467                         if (Unchanging) {
2468                             if (!feel_dead++)
2469 /*JP
2470                                 You("die.");
2471 */
2472                                 You("\8e\80\82É\82Ü\82µ\82½\81D\81D\81D");
2473                             /* finish genociding this class of
2474                                monsters before ultimately dying */
2475                             gameover = TRUE;
2476                         } else
2477                             rehumanize();
2478                     }
2479                     /* Self-genocide if it matches either your race
2480                        or role.  Assumption:  male and female forms
2481                        share same monster class. */
2482                     if (i == urole.malenum || i == urace.malenum) {
2483                         u.uhp = -1;
2484                         if (Upolyd) {
2485                             if (!feel_dead++)
2486 /*JP
2487                                 You_feel("dead inside.");
2488 */
2489                                 You("\8d°\82ª\8e\80\82ñ\82¾\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
2490                         } else {
2491                             if (!feel_dead++)
2492 /*JP
2493                                 You("die.");
2494 */
2495                                 You("\8e\80\82É\82Ü\82µ\82½\81D\81D\81D");
2496                             gameover = TRUE;
2497                         }
2498                     }
2499                 } else if (mvitals[i].mvflags & G_GENOD) {
2500                     if (!gameover)
2501 /*JP
2502                         pline("All %s are already nonexistent.", nam);
2503 */
2504                         pline("%s\82Í\8aù\82É\82¢\82È\82¢\81D", nam);
2505                 } else if (!gameover) {
2506                     /* suppress feedback about quest beings except
2507                        for those applicable to our own role */
2508                     if ((mons[i].msound != MS_LEADER
2509                          || quest_info(MS_LEADER) == i)
2510                         && (mons[i].msound != MS_NEMESIS
2511                             || quest_info(MS_NEMESIS) == i)
2512                         && (mons[i].msound != MS_GUARDIAN
2513                             || quest_info(MS_GUARDIAN) == i)
2514                         /* non-leader/nemesis/guardian role-specific monster
2515                            */
2516                         && (i != PM_NINJA /* nuisance */
2517                             || Role_if(PM_SAMURAI))) {
2518                         boolean named, uniq;
2519
2520                         named = type_is_pname(&mons[i]) ? TRUE : FALSE;
2521                         uniq = (mons[i].geno & G_UNIQ) ? TRUE : FALSE;
2522                         /* one special case */
2523                         if (i == PM_HIGH_PRIEST)
2524                             uniq = FALSE;
2525
2526 #if 0 /*JP*/
2527                         You("aren't permitted to genocide %s%s.",
2528                             (uniq && !named) ? "the " : "",
2529                             (uniq || named) ? mons[i].mname : nam);
2530 #else
2531                         You("%s\82ð\8bs\8eE\82Å\82«\82È\82¢\81D",
2532                             (uniq || named) ? mons[i].mname : nam);
2533 #endif
2534                     }
2535                 }
2536             }
2537         }
2538         if (gameover || u.uhp == -1) {
2539             killer.format = KILLED_BY_AN;
2540 /*JP
2541             Strcpy(killer.name, "scroll of genocide");
2542 */
2543             Strcpy(killer.name, "\8bs\8eE\82Ì\8aª\95¨\82Å");
2544             if (gameover)
2545                 done(GENOCIDED);
2546         }
2547         return;
2548     }
2549 }
2550
2551 #define REALLY 1
2552 #define PLAYER 2
2553 #define ONTHRONE 4
2554 void
2555 do_genocide(how)
2556 int how;
2557 /* 0 = no genocide; create monsters (cursed scroll) */
2558 /* 1 = normal genocide */
2559 /* 3 = forced genocide of player */
2560 /* 5 (4 | 1) = normal genocide from throne */
2561 {
2562     char buf[BUFSZ];
2563     register int i, killplayer = 0;
2564     register int mndx;
2565     register struct permonst *ptr;
2566     const char *which;
2567
2568     if (how & PLAYER) {
2569         mndx = u.umonster; /* non-polymorphed mon num */
2570         ptr = &mons[mndx];
2571         Strcpy(buf, ptr->mname);
2572         killplayer++;
2573     } else {
2574         for (i = 0;; i++) {
2575             if (i >= 5) {
2576                 pline1(thats_enough_tries);
2577                 return;
2578             }
2579 /*JP
2580             getlin("What monster do you want to genocide? [type the name]",
2581 */
2582             getlin("\82Ç\82Ì\89ö\95¨\82ð\8bs\8eE\82µ\82Ü\82·\82©\81H[\96¼\91O\82ð\93ü\82ê\82Ä\82Ë]",
2583                    buf);
2584             (void) mungspaces(buf);
2585             /* choosing "none" preserves genocideless conduct */
2586 /*JP
2587             if (!strcmpi(buf, "none") || !strcmpi(buf, "nothing")) {
2588 */
2589             if (!strcmpi(buf, "\82È\82µ") || !strcmpi(buf, "\96³\82µ")) {
2590                 /* ... but no free pass if cursed */
2591                 if (!(how & REALLY)) {
2592                     ptr = rndmonst();
2593                     if (!ptr)
2594                         return; /* no message, like normal case */
2595                     mndx = monsndx(ptr);
2596                     break; /* remaining checks don't apply */
2597                 } else
2598                     return;
2599             }
2600
2601             mndx = name_to_mon(buf);
2602             if (mndx == NON_PM || (mvitals[mndx].mvflags & G_GENOD)) {
2603 #if 0 /*JP*/
2604                 pline("Such creatures %s exist in this world.",
2605                       (mndx == NON_PM) ? "do not" : "no longer");
2606 #else
2607                 pline("\82»\82Ì\82æ\82¤\82È\90\82«\95¨\82Í%s\82±\82Ì\90¢\8aE\82É\91\8dÝ\82µ\82È\82¢\81D",
2608                       (mndx == NON_PM) ? "" : "\82à\82Í\82â");
2609 #endif
2610                 continue;
2611             }
2612             ptr = &mons[mndx];
2613             /* Although "genus" is Latin for race, the hero benefits
2614              * from both race and role; thus genocide affects either.
2615              */
2616             if (Your_Own_Role(mndx) || Your_Own_Race(mndx)) {
2617                 killplayer++;
2618                 break;
2619             }
2620             if (is_human(ptr))
2621                 adjalign(-sgn(u.ualign.type));
2622             if (is_demon(ptr))
2623                 adjalign(sgn(u.ualign.type));
2624
2625             if (!(ptr->geno & G_GENO)) {
2626                 if (!Deaf) {
2627                     /* fixme: unconditional "caverns" will be silly in some
2628                      * circumstances */
2629                     if (flags.verbose)
2630                         pline(
2631 /*JP
2632                             "A thunderous voice booms through the caverns:");
2633 */
2634                             "\97\8b\82Ì\82æ\82¤\82È\90º\82ª\93´\8cA\82É\8b¿\82¢\82½\81F");
2635 /*JP
2636                     verbalize("No, mortal!  That will not be done.");
2637 */
2638                     pline("\81u\92è\96½\82Ì\8eÒ\82æ\81I\82»\82Ì\96]\82Ý\82Í\82©\82È\82¤\82Ü\82¢\81D\81v");
2639                 }
2640                 continue;
2641             }
2642             /* KMH -- Unchanging prevents rehumanization */
2643             if (Unchanging && ptr == youmonst.data)
2644                 killplayer++;
2645             break;
2646         }
2647     }
2648
2649 /*JP
2650     which = "all ";
2651 */
2652     which = "\91S\82Ä";
2653     if (Hallucination) {
2654         if (Upolyd)
2655             Strcpy(buf, youmonst.data->mname);
2656         else {
2657             Strcpy(buf, (flags.female && urole.name.f) ? urole.name.f
2658                                                        : urole.name.m);
2659             buf[0] = lowc(buf[0]);
2660         }
2661     } else {
2662         Strcpy(buf, ptr->mname); /* make sure we have standard singular */
2663         if ((ptr->geno & G_UNIQ) && ptr != &mons[PM_HIGH_PRIEST])
2664 /*JP
2665             which = !type_is_pname(ptr) ? "the " : "";
2666 */
2667             which = !type_is_pname(ptr) ? "" : "";
2668     }
2669     if (how & REALLY) {
2670         /* setting no-corpse affects wishing and random tin generation */
2671         mvitals[mndx].mvflags |= (G_GENOD | G_NOCORPSE);
2672 #if 0 /*JP*/
2673         pline("Wiped out %s%s.", which,
2674               (*which != 'a') ? buf : makeplural(buf));
2675 #else
2676         pline("%s\82ð%s\88ê\91|\82µ\82½\81D", buf, which);
2677 #endif
2678
2679         if (killplayer) {
2680             /* might need to wipe out dual role */
2681             if (urole.femalenum != NON_PM && mndx == urole.malenum)
2682                 mvitals[urole.femalenum].mvflags |= (G_GENOD | G_NOCORPSE);
2683             if (urole.femalenum != NON_PM && mndx == urole.femalenum)
2684                 mvitals[urole.malenum].mvflags |= (G_GENOD | G_NOCORPSE);
2685             if (urace.femalenum != NON_PM && mndx == urace.malenum)
2686                 mvitals[urace.femalenum].mvflags |= (G_GENOD | G_NOCORPSE);
2687             if (urace.femalenum != NON_PM && mndx == urace.femalenum)
2688                 mvitals[urace.malenum].mvflags |= (G_GENOD | G_NOCORPSE);
2689
2690             u.uhp = -1;
2691             if (how & PLAYER) {
2692                 killer.format = KILLED_BY;
2693 /*JP
2694                 Strcpy(killer.name, "genocidal confusion");
2695 */
2696                 Strcpy(killer.name, "\8d¬\97\90\82É\82æ\82é\8e©\8bs\93I\8bs\8eE\82Å");
2697             } else if (how & ONTHRONE) {
2698                 /* player selected while on a throne */
2699                 killer.format = KILLED_BY_AN;
2700 /*JP
2701                 Strcpy(killer.name, "imperious order");
2702 */
2703                 Strcpy(killer.name, "\98ü\96\9d\82È\96½\97ß\82Å");
2704             } else { /* selected player deliberately, not confused */
2705                 killer.format = KILLED_BY_AN;
2706 /*JP
2707                 Strcpy(killer.name, "scroll of genocide");
2708 */
2709                 Strcpy(killer.name, "\8bs\8eE\82Ì\8aª\95¨\82Å");
2710             }
2711
2712             /* Polymorphed characters will die as soon as they're rehumanized.
2713              */
2714             /* KMH -- Unchanging prevents rehumanization */
2715             if (Upolyd && ptr != youmonst.data) {
2716                 delayed_killer(POLYMORPH, killer.format, killer.name);
2717 /*JP
2718                 You_feel("dead inside.");
2719 */
2720                 You("\8d°\82ª\8e\80\82ñ\82¾\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
2721             } else
2722                 done(GENOCIDED);
2723         } else if (ptr == youmonst.data) {
2724             rehumanize();
2725         }
2726         reset_rndmonst(mndx);
2727         kill_genocided_monsters();
2728         update_inventory(); /* in case identified eggs were affected */
2729     } else {
2730         int cnt = 0, census = monster_census(FALSE);
2731
2732         if (!(mons[mndx].geno & G_UNIQ)
2733             && !(mvitals[mndx].mvflags & (G_GENOD | G_EXTINCT)))
2734             for (i = rn1(3, 4); i > 0; i--) {
2735                 if (!makemon(ptr, u.ux, u.uy, NO_MINVENT))
2736                     break; /* couldn't make one */
2737                 ++cnt;
2738                 if (mvitals[mndx].mvflags & G_EXTINCT)
2739                     break; /* just made last one */
2740             }
2741         if (cnt) {
2742             /* accumulated 'cnt' doesn't take groups into account;
2743                assume bringing in new mon(s) didn't remove any old ones */
2744             cnt = monster_census(FALSE) - census;
2745 #if 0 /*JP*/
2746             pline("Sent in %s%s.", (cnt > 1) ? "some " : "",
2747                   (cnt > 1) ? makeplural(buf) : an(buf));
2748 #else
2749             pline("%s\82ª\91\97\82ç\82ê\82Ä\82«\82½\81D", buf);
2750 #endif
2751         } else
2752             pline1(nothing_happens);
2753     }
2754 }
2755
2756 void
2757 punish(sobj)
2758 struct obj *sobj;
2759 {
2760     struct obj *reuse_ball = (sobj && sobj->otyp == HEAVY_IRON_BALL)
2761                                 ? sobj : (struct obj *) 0;
2762
2763     /* KMH -- Punishment is still okay when you are riding */
2764     if (!reuse_ball)
2765 /*JP
2766         You("are being punished for your misbehavior!");
2767 */
2768         You("\95s\8dì\96@\82Ì\82½\82ß\94±\82ð\8eó\82¯\82½\81I");
2769     if (Punished) {
2770 /*JP
2771         Your("iron ball gets heavier.");
2772 */
2773         Your("\93S\8b\85\82Í\82³\82ç\82É\8fd\82­\82È\82Á\82½\81D");
2774         uball->owt += 160 * (1 + sobj->cursed);
2775         return;
2776     }
2777     if (amorphous(youmonst.data) || is_whirly(youmonst.data)
2778         || unsolid(youmonst.data)) {
2779         if (!reuse_ball) {
2780 /*JP
2781             pline("A ball and chain appears, then falls away.");
2782 */
2783             pline("\93S\8b\85\82Æ\8d½\82ª\8c»\82í\82ê\82½\82ª\81C\82·\82é\82Á\82Æ\94²\82¯\82½\81D");
2784             dropy(mkobj(BALL_CLASS, TRUE));
2785         } else {
2786             dropy(reuse_ball);
2787         }
2788         return;
2789     }
2790     setworn(mkobj(CHAIN_CLASS, TRUE), W_CHAIN);
2791     if (!reuse_ball)
2792         setworn(mkobj(BALL_CLASS, TRUE), W_BALL);
2793     else
2794         setworn(reuse_ball, W_BALL);
2795     uball->spe = 1; /* special ball (see save) */
2796
2797     /*
2798      *  Place ball & chain if not swallowed.  If swallowed, the ball &
2799      *  chain variables will be set at the next call to placebc().
2800      */
2801     if (!u.uswallow) {
2802         placebc();
2803         if (Blind)
2804             set_bc(1);      /* set up ball and chain variables */
2805         newsym(u.ux, u.uy); /* see ball&chain if can't see self */
2806     }
2807 }
2808
2809 /* remove the ball and chain */
2810 void
2811 unpunish()
2812 {
2813     struct obj *savechain = uchain;
2814
2815     obj_extract_self(uchain);
2816     newsym(uchain->ox, uchain->oy);
2817     setworn((struct obj *) 0, W_CHAIN);
2818     dealloc_obj(savechain);
2819     uball->spe = 0;
2820     setworn((struct obj *) 0, W_BALL);
2821 }
2822
2823 /* some creatures have special data structures that only make sense in their
2824  * normal locations -- if the player tries to create one elsewhere, or to
2825  * revive one, the disoriented creature becomes a zombie
2826  */
2827 boolean
2828 cant_revive(mtype, revival, from_obj)
2829 int *mtype;
2830 boolean revival;
2831 struct obj *from_obj;
2832 {
2833     /* SHOPKEEPERS can be revived now */
2834     if (*mtype == PM_GUARD || (*mtype == PM_SHOPKEEPER && !revival)
2835         || *mtype == PM_HIGH_PRIEST || *mtype == PM_ALIGNED_PRIEST
2836         || *mtype == PM_ANGEL) {
2837         *mtype = PM_HUMAN_ZOMBIE;
2838         return TRUE;
2839     } else if (*mtype == PM_LONG_WORM_TAIL) { /* for create_particular() */
2840         *mtype = PM_LONG_WORM;
2841         return TRUE;
2842     } else if (unique_corpstat(&mons[*mtype])
2843                && (!from_obj || !has_omonst(from_obj))) {
2844         /* unique corpses (from bones or wizard mode wish) or
2845            statues (bones or any wish) end up as shapechangers */
2846         *mtype = PM_DOPPELGANGER;
2847         return TRUE;
2848     }
2849     return FALSE;
2850 }
2851
2852 /*
2853  * Make a new monster with the type controlled by the user.
2854  *
2855  * Note:  when creating a monster by class letter, specifying the
2856  * "strange object" (']') symbol produces a random monster rather
2857  * than a mimic.  This behavior quirk is useful so don't "fix" it
2858  * (use 'm'--or "mimic"--to create a random mimic).
2859  *
2860  * Used in wizard mode only (for ^G command and for scroll or spell
2861  * of create monster).  Once upon a time, an earlier incarnation of
2862  * this code was also used for the scroll/spell in explore mode.
2863  */
2864 boolean
2865 create_particular()
2866 {
2867     char buf[BUFSZ], *bufp, monclass;
2868     int which, tryct, i, firstchoice = NON_PM;
2869     struct permonst *whichpm = NULL;
2870     struct monst *mtmp;
2871     boolean madeany = FALSE;
2872     boolean maketame, makepeaceful, makehostile;
2873     boolean randmonst = FALSE;
2874
2875     tryct = 5;
2876     do {
2877         monclass = MAXMCLASSES;
2878         which = urole.malenum; /* an arbitrary index into mons[] */
2879         maketame = makepeaceful = makehostile = FALSE;
2880 /*JP
2881         getlin("Create what kind of monster? [type the name or symbol]", buf);
2882 */
2883         getlin("\82Ç\82Ì\8eí\82Ì\89ö\95¨\82ð\8dì\82è\82Ü\82·\82©\81H[\96¼\91O\82ð\93ü\82ê\82Ä\82Ë]", buf);
2884         bufp = mungspaces(buf);
2885         if (*bufp == '\033')
2886             return FALSE;
2887         /* allow the initial disposition to be specified */
2888 #if 0 /*JP*/
2889         if (!strncmpi(bufp, "tame ", 5)) {
2890             bufp += 5;
2891 #else
2892         if (!strncmpi(bufp, "\8eè\82È\82¸\82¯\82ç\82ê\82½", 14)) {
2893             bufp += 14;
2894 #endif
2895             maketame = TRUE;
2896 #if 0 /*JP*/
2897         } else if (!strncmpi(bufp, "peaceful ", 9)) {
2898             bufp += 9;
2899 #else
2900         } else if (!strncmpi(bufp, "\97F\8dD\93I\82È", 8)) {
2901             bufp += 8;
2902 #endif
2903             makepeaceful = TRUE;
2904 #if 0 /*JP*/
2905         } else if (!strncmpi(bufp, "hostile ", 8)) {
2906             bufp += 8;
2907 #else
2908         } else if (!strncmpi(bufp, "\93G\91Î\93I\82È", 8)) {
2909             bufp += 8;
2910 #endif
2911             makehostile = TRUE;
2912         }
2913         /* decide whether a valid monster was chosen */
2914 /*JP
2915         if (wizard && (!strcmp(bufp, "*") || !strcmp(bufp, "random"))) {
2916 */
2917         if (wizard && (!strcmp(bufp, "*") || !strcmp(bufp, "\83\89\83\93\83_\83\80"))) {
2918             randmonst = TRUE;
2919             break;
2920         }
2921         which = name_to_mon(bufp);
2922         if (which >= LOW_PM)
2923             break; /* got one */
2924         monclass = name_to_monclass(bufp, &which);
2925         if (which >= LOW_PM) {
2926             monclass = MAXMCLASSES; /* matters below */
2927             break;
2928         } else if (monclass > 0) {
2929             which = urole.malenum; /* reset from NON_PM */
2930             break;
2931         }
2932         /* no good; try again... */
2933 /*JP
2934         pline("I've never heard of such monsters.");
2935 */
2936         pline("\82»\82Ì\82æ\82¤\82È\89ö\95¨\82Í\95·\82¢\82½\82±\82Æ\82ª\82È\82¢\81D");
2937     } while (--tryct > 0);
2938
2939     if (!tryct) {
2940         pline1(thats_enough_tries);
2941     } else {
2942         if (!randmonst) {
2943             firstchoice = which;
2944             if (cant_revive(&which, FALSE, (struct obj *) 0)) {
2945                 /* wizard mode can override handling of special monsters */
2946 #if 0 /*JP*/
2947                 Sprintf(buf, "Creating %s instead; force %s?",
2948                         mons[which].mname, mons[firstchoice].mname);
2949 #else
2950                 Sprintf(buf, "\91ã\82í\82è\82É%s\82ª\8dì\82ç\82ê\82Ü\82·\81G%s\82É\82·\82é\81H",
2951                         mons[which].mname, mons[firstchoice].mname);
2952 #endif
2953                 if (yn(buf) == 'y')
2954                     which = firstchoice;
2955             }
2956             whichpm = &mons[which];
2957         }
2958         for (i = 0; i <= multi; i++) {
2959             if (monclass != MAXMCLASSES)
2960                 whichpm = mkclass(monclass, 0);
2961             else if (randmonst)
2962                 whichpm = rndmonst();
2963             mtmp = makemon(whichpm, u.ux, u.uy, NO_MM_FLAGS);
2964             if (!mtmp) {
2965                 /* quit trying if creation failed and is going to repeat */
2966                 if (monclass == MAXMCLASSES && !randmonst)
2967                     break;
2968                 /* otherwise try again */
2969                 continue;
2970             }
2971             if (maketame) {
2972                 (void) tamedog(mtmp, (struct obj *) 0);
2973             } else if (makepeaceful || makehostile) {
2974                 mtmp->mtame = 0; /* sanity precaution */
2975                 mtmp->mpeaceful = makepeaceful ? 1 : 0;
2976                 set_malign(mtmp);
2977             }
2978             madeany = TRUE;
2979             /* in case we got a doppelganger instead of what was asked
2980                for, make it start out looking like what was asked for */
2981             if (mtmp->cham != NON_PM && firstchoice != NON_PM
2982                 && mtmp->cham != firstchoice)
2983                 (void) newcham(mtmp, &mons[firstchoice], FALSE, FALSE);
2984         }
2985     }
2986     return madeany;
2987 }
2988
2989 /*read.c*/