OSDN Git Service

update year to 2018
[jnethack/source.git] / src / wizard.c
1 /* NetHack 3.6  wizard.c        $NHDT-Date: 1456618999 2016/02/28 00:23:19 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.48 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2016. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2018            */
9 /* JNetHack may be freely redistributed.  See license for details. */
10
11 /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
12 /*             - heavily modified to give the wiz balls.  (genat!mike)   */
13 /*             - dewimped and given some maledictions. -3. */
14 /*             - generalized for 3.1 (mike@bullns.on01.bull.ca) */
15
16 #include "hack.h"
17 #include "qtext.h"
18
19 extern const int monstr[];
20
21 STATIC_DCL short FDECL(which_arti, (int));
22 STATIC_DCL boolean FDECL(mon_has_arti, (struct monst *, SHORT_P));
23 STATIC_DCL struct monst *FDECL(other_mon_has_arti, (struct monst *, SHORT_P));
24 STATIC_DCL struct obj *FDECL(on_ground, (SHORT_P));
25 STATIC_DCL boolean FDECL(you_have, (int));
26 STATIC_DCL unsigned long FDECL(target_on, (int, struct monst *));
27 STATIC_DCL unsigned long FDECL(strategy, (struct monst *));
28
29 /* adding more neutral creatures will tend to reduce the number of monsters
30    summoned by nasty(); adding more lawful creatures will reduce the number
31    of monsters summoned by lawfuls; adding more chaotic creatures will reduce
32    the number of monsters summoned by chaotics; prior to 3.6.1, there were
33    only four lawful candidates, so lawful summoners tended to summon more
34    (trying to get lawful or neutral but obtaining chaotic instead) than
35    their chaotic counterparts */
36 static NEARDATA const int nasties[] = {
37     /* neutral */
38     PM_COCKATRICE, PM_ETTIN, PM_STALKER, PM_MINOTAUR,
39     PM_OWLBEAR, PM_PURPLE_WORM, PM_XAN, PM_UMBER_HULK,
40     PM_XORN, PM_ZRUTY, PM_LEOCROTTA, PM_BALUCHITHERIUM,
41     PM_CARNIVOROUS_APE, PM_FIRE_ELEMENTAL, PM_JABBERWOCK,
42     PM_IRON_GOLEM, PM_OCHRE_JELLY, PM_GREEN_SLIME,
43     /* chaotic */
44     PM_BLACK_DRAGON, PM_RED_DRAGON, PM_ARCH_LICH, PM_VAMPIRE_LORD,
45     PM_MASTER_MIND_FLAYER, PM_DISENCHANTER, PM_WINGED_GARGOYLE,
46     PM_STORM_GIANT, PM_OLOG_HAI, PM_ELF_LORD, PM_ELVENKING,
47     PM_OGRE_KING, PM_CAPTAIN, PM_GREMLIN,
48     /* lawful */
49     PM_SILVER_DRAGON, PM_ORANGE_DRAGON, PM_GREEN_DRAGON,
50     PM_YELLOW_DRAGON, PM_GUARDIAN_NAGA, PM_FIRE_GIANT,
51     PM_ALEAX, PM_COUATL, PM_HORNED_DEVIL, PM_BARBED_DEVIL,
52     /* (titans, ki-rin, and golden nagas are suitably nasty, but
53        they're summoners so would aggravate excessive summoning) */
54 };
55
56 static NEARDATA const unsigned wizapp[] = {
57     PM_HUMAN,      PM_WATER_DEMON,  PM_VAMPIRE,       PM_RED_DRAGON,
58     PM_TROLL,      PM_UMBER_HULK,   PM_XORN,          PM_XAN,
59     PM_COCKATRICE, PM_FLOATING_EYE, PM_GUARDIAN_NAGA, PM_TRAPPER,
60 };
61
62 /* If you've found the Amulet, make the Wizard appear after some time */
63 /* Also, give hints about portal locations, if amulet is worn/wielded -dlc */
64 void
65 amulet()
66 {
67     struct monst *mtmp;
68     struct trap *ttmp;
69     struct obj *amu;
70
71 #if 0 /* caller takes care of this check */
72     if (!u.uhave.amulet)
73         return;
74 #endif
75     if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR)
76          || ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
77         && !rn2(15)) {
78         for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) {
79             if (ttmp->ttyp == MAGIC_PORTAL) {
80                 int du = distu(ttmp->tx, ttmp->ty);
81                 if (du <= 9)
82 /*JP
83                     pline("%s hot!", Tobjnam(amu, "feel"));
84 */
85                     pline("%s\82Í\94M\82­\8a´\82\82½\81I", xname(amu));
86                 else if (du <= 64)
87 /*JP
88                     pline("%s very warm.", Tobjnam(amu, "feel"));
89 */
90                     pline("%s\82Í\82Æ\82Ä\82à\92g\82©\82­\8a´\82\82½\81D", xname(amu));
91                 else if (du <= 144)
92 /*JP
93                     pline("%s warm.", Tobjnam(amu, "feel"));
94 */
95                     pline("%s\82Í\92g\82©\82­\8a´\82\82½\81D", xname(amu));
96                 /* else, the amulet feels normal */
97                 break;
98             }
99         }
100     }
101
102     if (!context.no_of_wizards)
103         return;
104     /* find Wizard, and wake him if necessary */
105     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
106         if (DEADMONSTER(mtmp))
107             continue;
108         if (mtmp->iswiz && mtmp->msleeping && !rn2(40)) {
109             mtmp->msleeping = 0;
110             if (distu(mtmp->mx, mtmp->my) > 2)
111                 You(
112 /*JP
113       "get the creepy feeling that somebody noticed your taking the Amulet.");
114 */
115       "\82 \82È\82½\82ª\96\82\8f\9c\82¯\82ð\8e\9d\82Á\82Ä\82¢\82é\82±\82Æ\82ª\92N\82©\82É\92m\82ç\82ê\82½\82Æ\8a´\82\82Ä\82¼\82Á\82Æ\82µ\82½\81D");
116             return;
117         }
118     }
119 }
120
121 int
122 mon_has_amulet(mtmp)
123 register struct monst *mtmp;
124 {
125     register struct obj *otmp;
126
127     for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
128         if (otmp->otyp == AMULET_OF_YENDOR)
129             return 1;
130     return 0;
131 }
132
133 int
134 mon_has_special(mtmp)
135 register struct monst *mtmp;
136 {
137     register struct obj *otmp;
138
139     for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
140         if (otmp->otyp == AMULET_OF_YENDOR
141             || any_quest_artifact(otmp)
142             || otmp->otyp == BELL_OF_OPENING
143             || otmp->otyp == CANDELABRUM_OF_INVOCATION
144             || otmp->otyp == SPE_BOOK_OF_THE_DEAD)
145             return 1;
146     return 0;
147 }
148
149 /*
150  *      New for 3.1  Strategy / Tactics for the wiz, as well as other
151  *      monsters that are "after" something (defined via mflag3).
152  *
153  *      The strategy section decides *what* the monster is going
154  *      to attempt, the tactics section implements the decision.
155  */
156 #define STRAT(w, x, y, typ)                            \
157     ((unsigned long) (w) | ((unsigned long) (x) << 16) \
158      | ((unsigned long) (y) << 8) | (unsigned long) (typ))
159
160 #define M_Wants(mask) (mtmp->data->mflags3 & (mask))
161
162 STATIC_OVL short
163 which_arti(mask)
164 register int mask;
165 {
166     switch (mask) {
167     case M3_WANTSAMUL:
168         return AMULET_OF_YENDOR;
169     case M3_WANTSBELL:
170         return BELL_OF_OPENING;
171     case M3_WANTSCAND:
172         return CANDELABRUM_OF_INVOCATION;
173     case M3_WANTSBOOK:
174         return SPE_BOOK_OF_THE_DEAD;
175     default:
176         break; /* 0 signifies quest artifact */
177     }
178     return 0;
179 }
180
181 /*
182  *      If "otyp" is zero, it triggers a check for the quest_artifact,
183  *      since bell, book, candle, and amulet are all objects, not really
184  *      artifacts right now.  [MRS]
185  */
186 STATIC_OVL boolean
187 mon_has_arti(mtmp, otyp)
188 register struct monst *mtmp;
189 register short otyp;
190 {
191     register struct obj *otmp;
192
193     for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
194         if (otyp) {
195             if (otmp->otyp == otyp)
196                 return 1;
197         } else if (any_quest_artifact(otmp))
198             return 1;
199     }
200     return 0;
201 }
202
203 STATIC_OVL struct monst *
204 other_mon_has_arti(mtmp, otyp)
205 register struct monst *mtmp;
206 register short otyp;
207 {
208     register struct monst *mtmp2;
209
210     for (mtmp2 = fmon; mtmp2; mtmp2 = mtmp2->nmon)
211         /* no need for !DEADMONSTER check here since they have no inventory */
212         if (mtmp2 != mtmp)
213             if (mon_has_arti(mtmp2, otyp))
214                 return mtmp2;
215
216     return (struct monst *) 0;
217 }
218
219 STATIC_OVL struct obj *
220 on_ground(otyp)
221 register short otyp;
222 {
223     register struct obj *otmp;
224
225     for (otmp = fobj; otmp; otmp = otmp->nobj)
226         if (otyp) {
227             if (otmp->otyp == otyp)
228                 return otmp;
229         } else if (any_quest_artifact(otmp))
230             return otmp;
231     return (struct obj *) 0;
232 }
233
234 STATIC_OVL boolean
235 you_have(mask)
236 register int mask;
237 {
238     switch (mask) {
239     case M3_WANTSAMUL:
240         return (boolean) u.uhave.amulet;
241     case M3_WANTSBELL:
242         return (boolean) u.uhave.bell;
243     case M3_WANTSCAND:
244         return (boolean) u.uhave.menorah;
245     case M3_WANTSBOOK:
246         return (boolean) u.uhave.book;
247     case M3_WANTSARTI:
248         return (boolean) u.uhave.questart;
249     default:
250         break;
251     }
252     return 0;
253 }
254
255 STATIC_OVL unsigned long
256 target_on(mask, mtmp)
257 register int mask;
258 register struct monst *mtmp;
259 {
260     register short otyp;
261     register struct obj *otmp;
262     register struct monst *mtmp2;
263
264     if (!M_Wants(mask))
265         return (unsigned long) STRAT_NONE;
266
267     otyp = which_arti(mask);
268     if (!mon_has_arti(mtmp, otyp)) {
269         if (you_have(mask))
270             return STRAT(STRAT_PLAYER, u.ux, u.uy, mask);
271         else if ((otmp = on_ground(otyp)))
272             return STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask);
273         else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0
274                  /* when seeking the Amulet, avoid targetting the Wizard
275                     or temple priests (to protect Moloch's high priest) */
276                  && (otyp != AMULET_OF_YENDOR
277                      || (!mtmp2->iswiz && !inhistemple(mtmp2))))
278             return STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask);
279     }
280     return (unsigned long) STRAT_NONE;
281 }
282
283 STATIC_OVL unsigned long
284 strategy(mtmp)
285 register struct monst *mtmp;
286 {
287     unsigned long strat, dstrat;
288
289     if (!is_covetous(mtmp->data)
290         /* perhaps a shopkeeper has been polymorphed into a master
291            lich; we don't want it teleporting to the stairs to heal
292            because that will leave its shop untended */
293         || (mtmp->isshk && inhishop(mtmp))
294         /* likewise for temple priests */
295         || (mtmp->ispriest && inhistemple(mtmp)))
296         return (unsigned long) STRAT_NONE;
297
298     switch ((mtmp->mhp * 3) / mtmp->mhpmax) { /* 0-3 */
299
300     default:
301     case 0: /* panic time - mtmp is almost snuffed */
302         return (unsigned long) STRAT_HEAL;
303
304     case 1: /* the wiz is less cautious */
305         if (mtmp->data != &mons[PM_WIZARD_OF_YENDOR])
306             return (unsigned long) STRAT_HEAL;
307     /* else fall through */
308
309     case 2:
310         dstrat = STRAT_HEAL;
311         break;
312
313     case 3:
314         dstrat = STRAT_NONE;
315         break;
316     }
317
318     if (context.made_amulet)
319         if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE)
320             return strat;
321
322     if (u.uevent.invoked) { /* priorities change once gate opened */
323         if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
324             return strat;
325         if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
326             return strat;
327         if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
328             return strat;
329         if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
330             return strat;
331     } else {
332         if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
333             return strat;
334         if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
335             return strat;
336         if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
337             return strat;
338         if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
339             return strat;
340     }
341     return dstrat;
342 }
343
344 void
345 choose_stairs(sx, sy)
346 xchar *sx;
347 xchar *sy;
348 {
349     xchar x = 0, y = 0;
350
351     if (builds_up(&u.uz)) {
352         if (xdnstair) {
353             x = xdnstair;
354             y = ydnstair;
355         } else if (xdnladder) {
356             x = xdnladder;
357             y = ydnladder;
358         }
359     } else {
360         if (xupstair) {
361             x = xupstair;
362             y = yupstair;
363         } else if (xupladder) {
364             x = xupladder;
365             y = yupladder;
366         }
367     }
368
369     if (!x && sstairs.sx) {
370         x = sstairs.sx;
371         y = sstairs.sy;
372     }
373
374     if (x && y) {
375         *sx = x;
376         *sy = y;
377     }
378
379 }
380
381 int
382 tactics(mtmp)
383 register struct monst *mtmp;
384 {
385     unsigned long strat = strategy(mtmp);
386     xchar sx = 0, sy = 0;
387
388     mtmp->mstrategy =
389         (mtmp->mstrategy & (STRAT_WAITMASK | STRAT_APPEARMSG)) | strat;
390
391     switch (strat) {
392     case STRAT_HEAL: /* hide and recover */
393         /* if wounded, hole up on or near the stairs (to block them) */
394         choose_stairs(&sx, &sy);
395         mtmp->mavenge = 1; /* covetous monsters attack while fleeing */
396         if (In_W_tower(mtmp->mx, mtmp->my, &u.uz)
397             || (mtmp->iswiz && !sx && !mon_has_amulet(mtmp))) {
398             if (!rn2(3 + mtmp->mhp / 10))
399                 (void) rloc(mtmp, TRUE);
400         } else if (sx && (mtmp->mx != sx || mtmp->my != sy)) {
401             if (!mnearto(mtmp, sx, sy, TRUE)) {
402                 m_into_limbo(mtmp);
403                 return 0;
404             }
405         }
406         /* if you're not around, cast healing spells */
407         if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM))
408             if (mtmp->mhp <= mtmp->mhpmax - 8) {
409                 mtmp->mhp += rnd(8);
410                 return 1;
411             }
412         /*FALLTHRU*/
413
414     case STRAT_NONE: /* harass */
415         if (!rn2(!mtmp->mflee ? 5 : 33))
416             mnexto(mtmp);
417         return 0;
418
419     default: /* kill, maim, pillage! */
420     {
421         long where = (strat & STRAT_STRATMASK);
422         xchar tx = STRAT_GOALX(strat), ty = STRAT_GOALY(strat);
423         int targ = (int) (strat & STRAT_GOAL);
424         struct obj *otmp;
425
426         if (!targ) { /* simply wants you to close */
427             return 0;
428         }
429         if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
430             /* player is standing on it (or has it) */
431             mnexto(mtmp);
432             return 0;
433         }
434         if (where == STRAT_GROUND) {
435             if (!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) {
436                 /* teleport to it and pick it up */
437                 rloc_to(mtmp, tx, ty); /* clean old pos */
438
439                 if ((otmp = on_ground(which_arti(targ))) != 0) {
440                     if (cansee(mtmp->mx, mtmp->my))
441 #if 0 /*JP*/
442                         pline("%s picks up %s.", Monnam(mtmp),
443                               (distu(mtmp->mx, mtmp->my) <= 5)
444                                   ? doname(otmp)
445                                   : distant_name(otmp, doname));
446 #else
447                         pline("%s\82Í%s\82ð\8fE\82Á\82½\81D", Monnam(mtmp),
448                               (distu(mtmp->mx, mtmp->my) <= 5)
449                                   ? doname(otmp)
450                                   : distant_name(otmp, doname));
451 #endif
452                     obj_extract_self(otmp);
453                     (void) mpickobj(mtmp, otmp);
454                     return 1;
455                 } else
456                     return 0;
457             } else {
458                 /* a monster is standing on it - cause some trouble */
459                 if (!rn2(5))
460                     mnexto(mtmp);
461                 return 0;
462             }
463         } else { /* a monster has it - 'port beside it. */
464             if (!mnearto(mtmp, tx, ty, FALSE))
465                 m_into_limbo(mtmp);
466             return 0;
467         }
468     }
469     }
470     /*NOTREACHED*/
471     return 0;
472 }
473
474 /* are there any monsters mon could aggravate? */
475 boolean
476 has_aggravatables(mon)
477 struct monst *mon;
478 {
479     struct monst *mtmp;
480     boolean in_w_tower = In_W_tower(mon->mx, mon->my, &u.uz);
481
482     if (in_w_tower != In_W_tower(u.ux, u.uy, &u.uz))
483         return FALSE;
484
485     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
486         if (DEADMONSTER(mtmp))
487             continue;
488         if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
489             continue;
490         if ((mtmp->mstrategy & STRAT_WAITFORU) != 0
491             || mtmp->msleeping || !mtmp->mcanmove)
492             return TRUE;
493     }
494     return FALSE;
495 }
496
497 void
498 aggravate()
499 {
500     register struct monst *mtmp;
501     boolean in_w_tower = In_W_tower(u.ux, u.uy, &u.uz);
502
503     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
504         if (DEADMONSTER(mtmp))
505             continue;
506         if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
507             continue;
508         mtmp->mstrategy &= ~(STRAT_WAITFORU | STRAT_APPEARMSG);
509         mtmp->msleeping = 0;
510         if (!mtmp->mcanmove && !rn2(5)) {
511             mtmp->mfrozen = 0;
512             mtmp->mcanmove = 1;
513         }
514     }
515 }
516
517 void
518 clonewiz()
519 {
520     register struct monst *mtmp2;
521
522     if ((mtmp2 = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, NO_MM_FLAGS))
523         != 0) {
524         mtmp2->msleeping = mtmp2->mtame = mtmp2->mpeaceful = 0;
525         if (!u.uhave.amulet && rn2(2)) { /* give clone a fake */
526             (void) add_to_minv(mtmp2,
527                                mksobj(FAKE_AMULET_OF_YENDOR, TRUE, FALSE));
528         }
529         mtmp2->m_ap_type = M_AP_MONSTER;
530         mtmp2->mappearance = wizapp[rn2(SIZE(wizapp))];
531         newsym(mtmp2->mx, mtmp2->my);
532     }
533 }
534
535 /* also used by newcham() */
536 int
537 pick_nasty()
538 {
539     int res = nasties[rn2(SIZE(nasties))];
540
541     /* To do?  Possibly should filter for appropriate forms when
542      * in the elemental planes or surrounded by water or lava.
543      *
544      * We want monsters represented by uppercase on rogue level,
545      * but we don't try very hard.
546      */
547     if (Is_rogue_level(&u.uz)
548         && !('A' <= mons[res].mlet && mons[res].mlet <= 'Z'))
549         res = nasties[rn2(SIZE(nasties))];
550
551     return res;
552 }
553
554 /* create some nasty monsters, aligned with the caster or neutral; chaotic
555    and unaligned are treated as equivalent; if summoner is Null, this is
556    for late-game harassment (after the Wizard has been killed at least once
557    or the invocation ritual has been performed), in which case we treat
558    'summoner' as neutral, since that will produce the greatest number of
559    creatures on average (in 3.6.0 and earlier, Null was treated as chaotic);
560    returns the number of monsters created */
561 int
562 nasty(summoner)
563 struct monst *summoner;
564 {
565     register struct monst *mtmp;
566     register int i, j;
567     int castalign = (summoner ? sgn(summoner->data->maligntyp) : 0);
568     coord bypos;
569     int count, census, tmp, makeindex, s_cls, m_cls;
570
571 #define MAXNASTIES 10 /* more than this can be created */
572
573     /* some candidates may be created in groups, so simple count
574        of non-null makemon() return is inadequate */
575     census = monster_census(FALSE);
576
577     if (!rn2(10) && Inhell) {
578         /* this might summon a demon prince or lord */
579         count = msummon((struct monst *) 0); /* summons like WoY */
580     } else {
581         count = 0;
582         s_cls = summoner ? summoner->data->mlet : 0;
583         tmp = (u.ulevel > 3) ? u.ulevel / 3 : 1;
584         /* if we don't have a casting monster, nasties appear around hero,
585            otherwise they'll appear around spot summoner thinks she's at */
586         bypos.x = u.ux;
587         bypos.y = u.uy;
588         for (i = rnd(tmp); i > 0 && count < MAXNASTIES; --i)
589             /* Of the 42 nasties[], 10 are lawful, 14 are chaotic,
590              * and 18 are neutral.
591              *
592              * Neutral caster, used for late-game harrassment,
593              * has 18/42 chance to stop the inner loop on each
594              * critter, 24/42 chance for another iteration.
595              * Lawful caster has 28/42 chance to stop unless the
596              * summoner is an angel or demon, in which case the
597              * chance is 26/42.
598              * Chaotic or unaligned caster has 32/42 chance to
599              * stop, so will summon fewer creatures on average.
600              *
601              * The outer loop potentially gives chaotic/unaligned
602              * a chance to even things up since others will hit
603              * MAXNASTIES sooner, but its number of iterations is
604              * randomized so it won't always do so.
605              */
606             for (j = 0; j < 20; j++) {
607                 /* Don't create more spellcasters of the monsters' level or
608                  * higher--avoids chain summoners filling up the level.
609                  */
610                 do {
611                     makeindex = pick_nasty();
612                     m_cls = mons[makeindex].mlet;
613                 } while (summoner
614                          && ((attacktype(&mons[makeindex], AT_MAGC)
615                               && monstr[makeindex] >= monstr[summoner->mnum])
616                              || (s_cls == S_DEMON && m_cls == S_ANGEL)
617                              || (s_cls == S_ANGEL && m_cls == S_DEMON)));
618                 /* do this after picking the monster to place */
619                 if (summoner && !enexto(&bypos, summoner->mux, summoner->muy,
620                                         &mons[makeindex]))
621                     continue;
622                 /* this honors genocide but overrides extinction; it ignores
623                    inside-hell-only (G_HELL) & outside-hell-only (G_NOHELL) */
624                 if ((mtmp = makemon(&mons[makeindex], bypos.x, bypos.y,
625                                     NO_MM_FLAGS)) != 0) {
626                     mtmp->msleeping = mtmp->mpeaceful = mtmp->mtame = 0;
627                     set_malign(mtmp);
628                 } else /* random monster to substitute for geno'd selection */
629                     mtmp = makemon((struct permonst *) 0, bypos.x, bypos.y,
630                                    NO_MM_FLAGS);
631                 if (mtmp) {
632                     /* delay first use of spell or breath attack */
633                     mtmp->mspec_used = rnd(4);
634                     if (++count >= MAXNASTIES
635                         || mtmp->data->maligntyp == 0
636                         || sgn(mtmp->data->maligntyp) == castalign)
637                         break;
638                 }
639             }
640     }
641
642     if (count)
643         count = monster_census(FALSE) - census;
644     return count;
645 }
646
647 /* Let's resurrect the wizard, for some unexpected fun. */
648 void
649 resurrect()
650 {
651     struct monst *mtmp, **mmtmp;
652     long elapsed;
653     const char *verb;
654
655     if (!context.no_of_wizards) {
656         /* make a new Wizard */
657 /*JP
658         verb = "kill";
659 */
660         verb = "\82ð\93¢\82Ä\82µ";
661         mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, MM_NOWAIT);
662         /* affects experience; he's not coming back from a corpse
663            but is subject to repeated killing like a revived corpse */
664         if (mtmp) mtmp->mrevived = 1;
665     } else {
666         /* look for a migrating Wizard */
667 /*JP
668         verb = "elude";
669 */
670         verb = "\82æ\82è\93¦\82ê\82ñ";
671         mmtmp = &migrating_mons;
672         while ((mtmp = *mmtmp) != 0) {
673             if (mtmp->iswiz
674                 /* if he has the Amulet, he won't bring it to you */
675                 && !mon_has_amulet(mtmp)
676                 && (elapsed = monstermoves - mtmp->mlstmv) > 0L) {
677                 mon_catchup_elapsed_time(mtmp, elapsed);
678                 if (elapsed >= LARGEST_INT)
679                     elapsed = LARGEST_INT - 1;
680                 elapsed /= 50L;
681                 if (mtmp->msleeping && rn2((int) elapsed + 1))
682                     mtmp->msleeping = 0;
683                 if (mtmp->mfrozen == 1) /* would unfreeze on next move */
684                     mtmp->mfrozen = 0, mtmp->mcanmove = 1;
685                 if (mtmp->mcanmove && !mtmp->msleeping) {
686                     *mmtmp = mtmp->nmon;
687                     mon_arrive(mtmp, TRUE);
688                     /* note: there might be a second Wizard; if so,
689                        he'll have to wait til the next resurrection */
690                     break;
691                 }
692             }
693             mmtmp = &mtmp->nmon;
694         }
695     }
696
697     if (mtmp) {
698         mtmp->mtame = mtmp->mpeaceful = 0; /* paranoia */
699         set_malign(mtmp);
700         if (!Deaf) {
701 /*JP
702             pline("A voice booms out...");
703 */
704             pline("\90º\82ª\8d\82\82­\96Â\82è\8b¿\82¢\82½\81D\81D\81D");
705 /*JP
706             verbalize("So thou thought thou couldst %s me, fool.", verb);
707 */
708             verbalize("\97]%s\82Æ\8ev\82¢\82µ\82©\81C\92s\82ê\8eÒ\82ª\81D", verb);
709         }
710     }
711 }
712
713 /* Here, we make trouble for the poor shmuck who actually
714    managed to do in the Wizard. */
715 void
716 intervene()
717 {
718     int which = Is_astralevel(&u.uz) ? rnd(4) : rn2(6);
719     /* cases 0 and 5 don't apply on the Astral level */
720     switch (which) {
721     case 0:
722     case 1:
723 /*JP
724         You_feel("vaguely nervous.");
725 */
726         You("\89½\82Æ\82È\82­\95s\88À\82É\82È\82Á\82½\81D");
727         break;
728     case 2:
729         if (!Blind)
730 /*JP
731             You("notice a %s glow surrounding you.", hcolor(NH_BLACK));
732 */
733             pline("%s\8cõ\82ª\82 \82È\82½\82ð\82Æ\82è\82Ü\82¢\82Ä\82¢\82é\82Ì\82É\8bC\82ª\82Â\82¢\82½\81D", hcolor(NH_BLACK));
734         rndcurse();
735         break;
736     case 3:
737         aggravate();
738         break;
739     case 4:
740         (void) nasty((struct monst *) 0);
741         break;
742     case 5:
743         resurrect();
744         break;
745     }
746 }
747
748 void
749 wizdead()
750 {
751     context.no_of_wizards--;
752     if (!u.uevent.udemigod) {
753         u.uevent.udemigod = TRUE;
754         u.udg_cnt = rn1(250, 50);
755     }
756 }
757
758 const char *const random_insult[] = {
759 #if 0 /*JP*/
760     "antic",      "blackguard",   "caitiff",    "chucklehead",
761     "coistrel",   "craven",       "cretin",     "cur",
762     "dastard",    "demon fodder", "dimwit",     "dolt",
763     "fool",       "footpad",      "imbecile",   "knave",
764     "maledict",   "miscreant",    "niddering",  "poltroon",
765     "rattlepate", "reprobate",    "scapegrace", "varlet",
766     "villein", /* (sic.) */
767     "wittol",     "worm",         "wretch",
768 #else
769     "\82Ó\82´\82¯\82½\96ì\98Y", "\88«\93}",       "\82­\82»\82Á\82½\82ê", "\82Ì\82ë\82Ü",
770     "\82 \82ñ\82Û\82ñ\82½\82ñ", "\89°\95a\8eÒ",     "\94\92\92s",       "\82ë\82­\82Å\82È\82µ",
771     "\82¤\82Â\82¯",       "\88«\96\82\82Ì\89a\90H", "\82¤\82·\82Ì\82ë",   "\82Ü\82Ê\82¯",
772     "\94n\8e­",         "\82¨\82¢\82Í\82¬",   "\8bð\82©\8eÒ",     "\82È\82ç\82¸\8eÒ",
773     "\88«\90l",         "\8bÉ\88«\90l",     "\94n\8e­\82½\82ê",   "\94Ú\8b¯\8eÒ",
774     "\95\97\91D\93ª",       "\93¹\8ay\8eÒ",     "\96ï\89î\8eÒ",     "\89º\98Y",
775     "\93z\97ê", /* (sic.) */
776     "\82Ó\82È\82Þ\82µ",     "åv\92\8e",       "\90l\82Å\82È\82µ",
777 #endif
778 };
779
780 const char *const random_malediction[] = {
781 #if 0 /*JP*/
782     "Hell shall soon claim thy remains,", "I chortle at thee, thou pathetic",
783     "Prepare to die, thou", "Resistance is useless,",
784     "Surrender or die, thou", "There shall be no mercy, thou",
785     "Thou shalt repent of thy cunning,", "Thou art as a flea to me,",
786     "Thou art doomed,", "Thy fate is sealed,",
787     "Verily, thou shalt be one dead"
788 #else
789     "\92n\8d\96\82Í\82¢\82Ã\82ê\81C\93ð\82Ì\96S\8a[\82ð\97v\8b\81\82·\82é\82Å\82 \82ë\82¤\81C",
790     "\88£\82ê\82È\82â\82Â\82æ\82Ì\82¤\81D\97]\82Í\96\9e\91«\82\82á",
791     "\93ð\81C\8e\80\82É\94õ\82¦\82æ",
792     "\92ï\8dR\82µ\82Ä\82à\96³\91Ê\82\82á\81C",
793     "\8d~\8eQ\82¹\82æ\81D\82³\82à\82È\82­\82Î\8e\80\82\82á\81D",
794     "\8e\9c\94ß\82Í\96³\82©\82ç\82ñ",
795     "\93ð\81C\82¸\82é\82ð\8cã\89÷\82·\82×\82µ\81C",
796     "\93ð\82Í\97]\82É\82Æ\82Á\82Ä\83m\83~\82Ì\82æ\82¤\82È\82à\82Ì\82\82á\81C",
797     "\93ð\82Í\8eô\82í\82ê\82Ä\82¨\82é\81C",
798     "\93ð\82Ì\89^\96½\82Í\95\95\88ó\82³\82ê\82Ä\82¨\82é\81C",
799     "\82Ü\82±\82Æ\82É\93ð\82Í\8e\80\82É\82½\82é\8eÒ\82È\82è"
800 #endif
801 };
802
803 /* Insult or intimidate the player */
804 void
805 cuss(mtmp)
806 register struct monst *mtmp;
807 {
808     if (Deaf)
809         return;
810     if (mtmp->iswiz) {
811         if (!rn2(5)) /* typical bad guy action */
812 /*JP
813             pline("%s laughs fiendishly.", Monnam(mtmp));
814 */
815             pline("%s\82Í\88«\96\82\82Ì\82æ\82¤\82É\8fÎ\82Á\82½\81D", Monnam(mtmp));
816         else if (u.uhave.amulet && !rn2(SIZE(random_insult)))
817 /*JP
818             verbalize("Relinquish the amulet, %s!",
819 */
820             verbalize("\96\82\82æ\82¯\82ð\8eè\95ú\82¹\81C%s\81I",
821                       random_insult[rn2(SIZE(random_insult))]);
822         else if (u.uhp < 5 && !rn2(2)) /* Panic */
823 #if 0 /*JP*/
824             verbalize(rn2(2) ? "Even now thy life force ebbs, %s!"
825                              : "Savor thy breath, %s, it be thy last!",
826                       random_insult[rn2(SIZE(random_insult))]);
827 #else
828             verbalize(rn2(2) ? "\8d¡\82Æ\82È\82Á\82Ä\82à\82È\82¨\93ð\82Ì\96½\82Í\82 \82¦\82Ä\90\8a\82¦\82é\82Ì\82¾\81C%s\81I"
829                              : "\96³\91Ê\82È\82±\82Æ\82ð\82·\82é\82È\81C%s\81C\93ð\82Ì\8dÅ\8aú\82Ì\8e\9e\82¾\81I",
830                       random_insult[rn2(SIZE(random_insult))]);
831 #endif
832         else if (mtmp->mhp < 5 && !rn2(2)) /* Parthian shot */
833 /*JP
834             verbalize(rn2(2) ? "I shall return." : "I'll be back.");
835 */
836             verbalize(rn2(2) ? "\97]\82Í\95K\82¸\8bA\82Á\82Ä\82­\82é\81D" : "\97]\82Í\96ß\82Á\82Ä\82­\82é\81D");
837         else
838 #if 0 /*JP*/
839             verbalize("%s %s!",
840                       random_malediction[rn2(SIZE(random_malediction))],
841                       random_insult[rn2(SIZE(random_insult))]);
842 #else
843             verbalize("%s\81C%s\81I",
844                       random_malediction[rn2(SIZE(random_malediction))],
845                       random_insult[rn2(SIZE(random_insult))]);
846 #endif
847     } else if (is_lminion(mtmp)
848                && !(mtmp->isminion && EMIN(mtmp)->renegade)) {
849         com_pager(rn2(QTN_ANGELIC - 1 + (Hallucination ? 1 : 0))
850                   + QT_ANGELIC);
851     } else {
852         if (!rn2(is_minion(mtmp->data) ? 100 : 5))
853 /*JP
854             pline("%s casts aspersions on your ancestry.", Monnam(mtmp));
855 */
856                 pline("%s\82Í\82 \82È\82½\82Ì\89Æ\95¿\82ð\92\86\8f\9d\82µ\82½\81D", Monnam(mtmp));
857         else
858             com_pager(rn2(QTN_DEMONIC) + QT_DEMONIC);
859     }
860 }
861
862 /*wizard.c*/