NHDT->ANH, nethack->anethack, nhdat->anhdat
[aNetHack.git] / src / wizard.c
blob0ba6cc54d39dc80164d6bfe1bb35a1462f494a0e
1 /* aNetHack 0.0.1 wizard.c $ANH-Date: 1456618999 2016/02/28 00:23:19 $ $ANH-Branch: master $:$ANH-Revision: 1.48 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* aNetHack may be freely redistributed. See license for details. */
5 /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
6 /* - heavily modified to give the wiz balls. (genat!mike) */
7 /* - dewimped and given some maledictions. -3. */
8 /* - generalized for 3.1 (mike@bullns.on01.bull.ca) */
10 #include "hack.h"
11 #include "qtext.h"
13 extern const int monstr[];
15 STATIC_DCL short FDECL(which_arti, (int));
16 STATIC_DCL boolean FDECL(mon_has_arti, (struct monst *, SHORT_P));
17 STATIC_DCL struct monst *FDECL(other_mon_has_arti, (struct monst *, SHORT_P));
18 STATIC_DCL struct obj *FDECL(on_ground, (SHORT_P));
19 STATIC_DCL boolean FDECL(you_have, (int));
20 STATIC_DCL unsigned long FDECL(target_on, (int, struct monst *));
21 STATIC_DCL unsigned long FDECL(strategy, (struct monst *));
23 /* adding more neutral creatures will tend to reduce the number of monsters
24 summoned by nasty(); adding more lawful creatures will reduce the number
25 of monsters summoned by lawfuls; adding more chaotic creatures will reduce
26 the number of monsters summoned by chaotics; prior to 3.6.1, there were
27 only four lawful candidates, so lawful summoners tended to summon more
28 (trying to get lawful or neutral but obtaining chaotic instead) than
29 their chaotic counterparts */
30 static NEARDATA const int nasties[] = {
31 /* neutral */
32 PM_COCKATRICE, PM_ETTIN, PM_STALKER, PM_MINOTAUR,
33 PM_OWLBEAR, PM_PURPLE_WORM, PM_XAN, PM_UMBER_HULK,
34 PM_XORN, PM_ZRUTY, PM_LEOCROTTA, PM_BALUCHITHERIUM,
35 PM_CARNIVOROUS_APE, PM_FIRE_ELEMENTAL, PM_JABBERWOCK,
36 PM_IRON_GOLEM, PM_OCHRE_JELLY, PM_GREEN_SLIME,
37 /* chaotic */
38 PM_BLACK_DRAGON, PM_RED_DRAGON, PM_ARCH_LICH, PM_VAMPIRE_LORD,
39 PM_MASTER_MIND_FLAYER, PM_DISENCHANTER, PM_WINGED_GARGOYLE,
40 PM_STORM_GIANT, PM_OLOG_HAI, PM_ELF_LORD, PM_ELVENKING,
41 PM_OGRE_KING, PM_CAPTAIN, PM_GREMLIN,
42 /* lawful */
43 PM_SILVER_DRAGON, PM_ORANGE_DRAGON, PM_GREEN_DRAGON,
44 PM_YELLOW_DRAGON, PM_GUARDIAN_NAGA, PM_FIRE_GIANT,
45 PM_ALEAX, PM_COUATL, PM_HORNED_DEVIL, PM_BARBED_DEVIL,
46 /* (titans, ki-rin, and golden nagas are suitably nasty, but
47 they're summoners so would aggravate excessive summoning) */
50 static NEARDATA const unsigned wizapp[] = {
51 PM_HUMAN, PM_WATER_DEMON, PM_VAMPIRE, PM_RED_DRAGON,
52 PM_TROLL, PM_UMBER_HULK, PM_XORN, PM_XAN,
53 PM_COCKATRICE, PM_FLOATING_EYE, PM_GUARDIAN_NAGA, PM_TRAPPER,
56 /* If you've found the Amulet, make the Wizard appear after some time */
57 /* Also, give hints about portal locations, if amulet is worn/wielded -dlc */
58 void
59 amulet()
61 struct monst *mtmp;
62 struct trap *ttmp;
63 struct obj *amu;
65 #if 0 /* caller takes care of this check */
66 if (!u.uhave.amulet)
67 return;
68 #endif
69 if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR)
70 || ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
71 && !rn2(15)) {
72 for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) {
73 if (ttmp->ttyp == MAGIC_PORTAL) {
74 int du = distu(ttmp->tx, ttmp->ty);
75 if (du <= 9)
76 pline("%s hot!", Tobjnam(amu, "feel"));
77 else if (du <= 64)
78 pline("%s very warm.", Tobjnam(amu, "feel"));
79 else if (du <= 144)
80 pline("%s warm.", Tobjnam(amu, "feel"));
81 /* else, the amulet feels normal */
82 break;
87 if (!context.no_of_wizards)
88 return;
89 /* find Wizard, and wake him if necessary */
90 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
91 if (DEADMONSTER(mtmp))
92 continue;
93 if (mtmp->iswiz && mtmp->msleeping && !rn2(40)) {
94 mtmp->msleeping = 0;
95 if (distu(mtmp->mx, mtmp->my) > 2)
96 You(
97 "get the creepy feeling that somebody noticed your taking the Amulet.");
98 return;
104 mon_has_amulet(mtmp)
105 register struct monst *mtmp;
107 register struct obj *otmp;
109 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
110 if (otmp->otyp == AMULET_OF_YENDOR)
111 return 1;
112 return 0;
116 mon_has_special(mtmp)
117 register struct monst *mtmp;
119 register struct obj *otmp;
121 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
122 if (otmp->otyp == AMULET_OF_YENDOR
123 || any_quest_artifact(otmp)
124 || otmp->otyp == BELL_OF_OPENING
125 || otmp->otyp == CANDELABRUM_OF_INVOCATION
126 || otmp->otyp == SPE_BOOK_OF_THE_DEAD)
127 return 1;
128 return 0;
132 * New for 3.1 Strategy / Tactics for the wiz, as well as other
133 * monsters that are "after" something (defined via mflag3).
135 * The strategy section decides *what* the monster is going
136 * to attempt, the tactics section implements the decision.
138 #define STRAT(w, x, y, typ) \
139 ((unsigned long) (w) | ((unsigned long) (x) << 16) \
140 | ((unsigned long) (y) << 8) | (unsigned long) (typ))
142 #define M_Wants(mask) (mtmp->data->mflags3 & (mask))
144 STATIC_OVL short
145 which_arti(mask)
146 register int mask;
148 switch (mask) {
149 case M3_WANTSAMUL:
150 return AMULET_OF_YENDOR;
151 case M3_WANTSBELL:
152 return BELL_OF_OPENING;
153 case M3_WANTSCAND:
154 return CANDELABRUM_OF_INVOCATION;
155 case M3_WANTSBOOK:
156 return SPE_BOOK_OF_THE_DEAD;
157 default:
158 break; /* 0 signifies quest artifact */
160 return 0;
164 * If "otyp" is zero, it triggers a check for the quest_artifact,
165 * since bell, book, candle, and amulet are all objects, not really
166 * artifacts right now. [MRS]
168 STATIC_OVL boolean
169 mon_has_arti(mtmp, otyp)
170 register struct monst *mtmp;
171 register short otyp;
173 register struct obj *otmp;
175 for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
176 if (otyp) {
177 if (otmp->otyp == otyp)
178 return 1;
179 } else if (any_quest_artifact(otmp))
180 return 1;
182 return 0;
185 STATIC_OVL struct monst *
186 other_mon_has_arti(mtmp, otyp)
187 register struct monst *mtmp;
188 register short otyp;
190 register struct monst *mtmp2;
192 for (mtmp2 = fmon; mtmp2; mtmp2 = mtmp2->nmon)
193 /* no need for !DEADMONSTER check here since they have no inventory */
194 if (mtmp2 != mtmp)
195 if (mon_has_arti(mtmp2, otyp))
196 return mtmp2;
198 return (struct monst *) 0;
201 STATIC_OVL struct obj *
202 on_ground(otyp)
203 register short otyp;
205 register struct obj *otmp;
207 for (otmp = fobj; otmp; otmp = otmp->nobj)
208 if (otyp) {
209 if (otmp->otyp == otyp)
210 return otmp;
211 } else if (any_quest_artifact(otmp))
212 return otmp;
213 return (struct obj *) 0;
216 STATIC_OVL boolean
217 you_have(mask)
218 register int mask;
220 switch (mask) {
221 case M3_WANTSAMUL:
222 return (boolean) u.uhave.amulet;
223 case M3_WANTSBELL:
224 return (boolean) u.uhave.bell;
225 case M3_WANTSCAND:
226 return (boolean) u.uhave.menorah;
227 case M3_WANTSBOOK:
228 return (boolean) u.uhave.book;
229 case M3_WANTSARTI:
230 return (boolean) u.uhave.questart;
231 default:
232 break;
234 return 0;
237 STATIC_OVL unsigned long
238 target_on(mask, mtmp)
239 register int mask;
240 register struct monst *mtmp;
242 register short otyp;
243 register struct obj *otmp;
244 register struct monst *mtmp2;
246 if (!M_Wants(mask))
247 return (unsigned long) STRAT_NONE;
249 otyp = which_arti(mask);
250 if (!mon_has_arti(mtmp, otyp)) {
251 if (you_have(mask))
252 return STRAT(STRAT_PLAYER, u.ux, u.uy, mask);
253 else if ((otmp = on_ground(otyp)))
254 return STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask);
255 else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0
256 /* when seeking the Amulet, avoid targetting the Wizard
257 or temple priests (to protect Moloch's high priest) */
258 && (otyp != AMULET_OF_YENDOR
259 || (!mtmp2->iswiz && !inhistemple(mtmp2))))
260 return STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask);
262 return (unsigned long) STRAT_NONE;
265 STATIC_OVL unsigned long
266 strategy(mtmp)
267 register struct monst *mtmp;
269 unsigned long strat, dstrat;
271 if (!is_covetous(mtmp->data)
272 /* perhaps a shopkeeper has been polymorphed into a master
273 lich; we don't want it teleporting to the stairs to heal
274 because that will leave its shop untended */
275 || (mtmp->isshk && inhishop(mtmp))
276 /* likewise for temple priests */
277 || (mtmp->ispriest && inhistemple(mtmp)))
278 return (unsigned long) STRAT_NONE;
280 switch ((mtmp->mhp * 3) / mtmp->mhpmax) { /* 0-3 */
282 default:
283 case 0: /* panic time - mtmp is almost snuffed */
284 return (unsigned long) STRAT_HEAL;
286 case 1: /* the wiz is less cautious */
287 if (mtmp->data != &mons[PM_WIZARD_OF_YENDOR])
288 return (unsigned long) STRAT_HEAL;
289 /* else fall through */
291 case 2:
292 dstrat = STRAT_HEAL;
293 break;
295 case 3:
296 dstrat = STRAT_NONE;
297 break;
300 if (context.made_amulet)
301 if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE)
302 return strat;
304 if (u.uevent.invoked) { /* priorities change once gate opened */
305 if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
306 return strat;
307 if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
308 return strat;
309 if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
310 return strat;
311 if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
312 return strat;
313 } else {
314 if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
315 return strat;
316 if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
317 return strat;
318 if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
319 return strat;
320 if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
321 return strat;
323 return dstrat;
326 void
327 choose_stairs(sx, sy)
328 xchar *sx;
329 xchar *sy;
331 xchar x = 0, y = 0;
333 if (builds_up(&u.uz)) {
334 if (xdnstair) {
335 x = xdnstair;
336 y = ydnstair;
337 } else if (xdnladder) {
338 x = xdnladder;
339 y = ydnladder;
341 } else {
342 if (xupstair) {
343 x = xupstair;
344 y = yupstair;
345 } else if (xupladder) {
346 x = xupladder;
347 y = yupladder;
351 if (!x && sstairs.sx) {
352 x = sstairs.sx;
353 y = sstairs.sy;
356 if (x && y) {
357 *sx = x;
358 *sy = y;
364 tactics(mtmp)
365 register struct monst *mtmp;
367 unsigned long strat = strategy(mtmp);
368 xchar sx = 0, sy = 0;
370 mtmp->mstrategy =
371 (mtmp->mstrategy & (STRAT_WAITMASK | STRAT_APPEARMSG)) | strat;
373 switch (strat) {
374 case STRAT_HEAL: /* hide and recover */
375 /* if wounded, hole up on or near the stairs (to block them) */
376 choose_stairs(&sx, &sy);
377 mtmp->mavenge = 1; /* covetous monsters attack while fleeing */
378 if (In_W_tower(mtmp->mx, mtmp->my, &u.uz)
379 || (mtmp->iswiz && !sx && !mon_has_amulet(mtmp))) {
380 if (!rn2(3 + mtmp->mhp / 10))
381 (void) rloc(mtmp, TRUE);
382 } else if (sx && (mtmp->mx != sx || mtmp->my != sy)) {
383 if (!mnearto(mtmp, sx, sy, TRUE)) {
384 m_into_limbo(mtmp);
385 return 0;
388 /* if you're not around, cast healing spells */
389 if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM))
390 if (mtmp->mhp <= mtmp->mhpmax - 8) {
391 mtmp->mhp += rnd(8);
392 return 1;
394 /* fall through :-) */
396 case STRAT_NONE: /* harass */
397 if (!rn2(!mtmp->mflee ? 5 : 33))
398 mnexto(mtmp);
399 return 0;
401 default: /* kill, maim, pillage! */
403 long where = (strat & STRAT_STRATMASK);
404 xchar tx = STRAT_GOALX(strat), ty = STRAT_GOALY(strat);
405 int targ = (int) (strat & STRAT_GOAL);
406 struct obj *otmp;
408 if (!targ) { /* simply wants you to close */
409 return 0;
411 if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
412 /* player is standing on it (or has it) */
413 mnexto(mtmp);
414 return 0;
416 if (where == STRAT_GROUND) {
417 if (!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) {
418 /* teleport to it and pick it up */
419 rloc_to(mtmp, tx, ty); /* clean old pos */
421 if ((otmp = on_ground(which_arti(targ))) != 0) {
422 if (cansee(mtmp->mx, mtmp->my))
423 pline("%s picks up %s.", Monnam(mtmp),
424 (distu(mtmp->mx, mtmp->my) <= 5)
425 ? doname(otmp)
426 : distant_name(otmp, doname));
427 obj_extract_self(otmp);
428 (void) mpickobj(mtmp, otmp);
429 return 1;
430 } else
431 return 0;
432 } else {
433 /* a monster is standing on it - cause some trouble */
434 if (!rn2(5))
435 mnexto(mtmp);
436 return 0;
438 } else { /* a monster has it - 'port beside it. */
439 if (!mnearto(mtmp, tx, ty, FALSE))
440 m_into_limbo(mtmp);
441 return 0;
445 /*NOTREACHED*/
446 return 0;
449 /* are there any monsters mon could aggravate? */
450 boolean
451 has_aggravatables(mon)
452 struct monst *mon;
454 struct monst *mtmp;
455 boolean in_w_tower = In_W_tower(mon->mx, mon->my, &u.uz);
457 if (in_w_tower != In_W_tower(u.ux, u.uy, &u.uz))
458 return FALSE;
460 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
461 if (DEADMONSTER(mtmp))
462 continue;
463 if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
464 continue;
465 if ((mtmp->mstrategy & STRAT_WAITFORU) != 0
466 || mtmp->msleeping || !mtmp->mcanmove)
467 return TRUE;
469 return FALSE;
472 void
473 aggravate()
475 register struct monst *mtmp;
476 boolean in_w_tower = In_W_tower(u.ux, u.uy, &u.uz);
478 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
479 if (DEADMONSTER(mtmp))
480 continue;
481 if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
482 continue;
483 mtmp->mstrategy &= ~(STRAT_WAITFORU | STRAT_APPEARMSG);
484 mtmp->msleeping = 0;
485 if (!mtmp->mcanmove && !rn2(5)) {
486 mtmp->mfrozen = 0;
487 mtmp->mcanmove = 1;
492 void
493 clonewiz()
495 register struct monst *mtmp2;
497 if ((mtmp2 = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, NO_MM_FLAGS))
498 != 0) {
499 mtmp2->msleeping = mtmp2->mtame = mtmp2->mpeaceful = 0;
500 if (!u.uhave.amulet && rn2(2)) { /* give clone a fake */
501 (void) add_to_minv(mtmp2,
502 mksobj(FAKE_AMULET_OF_YENDOR, TRUE, FALSE));
504 mtmp2->m_ap_type = M_AP_MONSTER;
505 mtmp2->mappearance = wizapp[rn2(SIZE(wizapp))];
506 newsym(mtmp2->mx, mtmp2->my);
510 /* also used by newcham() */
512 pick_nasty()
514 int res = nasties[rn2(SIZE(nasties))];
516 /* To do? Possibly should filter for appropriate forms when
517 * in the elemental planes or surrounded by water or lava.
519 * We want monsters represented by uppercase on rogue level,
520 * but we don't try very hard.
522 if (Is_rogue_level(&u.uz)
523 && !('A' <= mons[res].mlet && mons[res].mlet <= 'Z'))
524 res = nasties[rn2(SIZE(nasties))];
526 return res;
529 /* create some nasty monsters, aligned with the caster or neutral; chaotic
530 and unaligned are treated as equivalent; if summoner is Null, this is
531 for late-game harassment (after the Wizard has been killed at least once
532 or the invocation ritual has been performed), in which case we treat
533 'summoner' as neutral, since that will produce the greatest number of
534 creatures on average (in 3.6.0 and earlier, Null was treated as chaotic);
535 returns the number of monsters created */
537 nasty(summoner)
538 struct monst *summoner;
540 register struct monst *mtmp;
541 register int i, j;
542 int castalign = (summoner ? sgn(summoner->data->maligntyp) : 0);
543 coord bypos;
544 int count, census, tmp, makeindex, s_cls, m_cls;
546 #define MAXNASTIES 10 /* more than this can be created */
548 /* some candidates may be created in groups, so simple count
549 of non-null makemon() return is inadequate */
550 census = monster_census(FALSE);
552 if (!rn2(10) && Inhell) {
553 /* this might summon a demon prince or lord */
554 count = msummon((struct monst *) 0); /* summons like WoY */
555 } else {
556 count = 0;
557 s_cls = summoner ? summoner->data->mlet : 0;
558 tmp = (u.ulevel > 3) ? u.ulevel / 3 : 1;
559 /* if we don't have a casting monster, nasties appear around hero,
560 otherwise they'll appear around spot summoner thinks she's at */
561 bypos.x = u.ux;
562 bypos.y = u.uy;
563 for (i = rnd(tmp); i > 0 && count < MAXNASTIES; --i)
564 /* Of the 42 nasties[], 10 are lawful, 14 are chaotic,
565 * and 18 are neutral.
567 * Neutral caster, used for late-game harrassment,
568 * has 18/42 chance to stop the inner loop on each
569 * critter, 24/42 chance for another iteration.
570 * Lawful caster has 28/42 chance to stop unless the
571 * summoner is an angel or demon, in which case the
572 * chance is 26/42.
573 * Chaotic or unaligned caster has 32/42 chance to
574 * stop, so will summon fewer creatures on average.
576 * The outer loop potentially gives chaotic/unaligned
577 * a chance to even things up since others will hit
578 * MAXNASTIES sooner, but its number of iterations is
579 * randomized so it won't always do so.
581 for (j = 0; j < 20; j++) {
582 /* Don't create more spellcasters of the monsters' level or
583 * higher--avoids chain summoners filling up the level.
585 do {
586 makeindex = pick_nasty();
587 m_cls = mons[makeindex].mlet;
588 } while (summoner
589 && ((attacktype(&mons[makeindex], AT_MAGC)
590 && monstr[makeindex] >= monstr[summoner->mnum])
591 || (s_cls == S_DEMON && m_cls == S_ANGEL)
592 || (s_cls == S_ANGEL && m_cls == S_DEMON)));
593 /* do this after picking the monster to place */
594 if (summoner && !enexto(&bypos, summoner->mux, summoner->muy,
595 &mons[makeindex]))
596 continue;
597 /* this honors genocide but overrides extinction; it ignores
598 inside-hell-only (G_HELL) & outside-hell-only (G_NOHELL) */
599 if ((mtmp = makemon(&mons[makeindex], bypos.x, bypos.y,
600 NO_MM_FLAGS)) != 0) {
601 mtmp->msleeping = mtmp->mpeaceful = mtmp->mtame = 0;
602 set_malign(mtmp);
603 } else /* random monster to substitute for geno'd selection */
604 mtmp = makemon((struct permonst *) 0, bypos.x, bypos.y,
605 NO_MM_FLAGS);
606 if (mtmp) {
607 /* delay first use of spell or breath attack */
608 mtmp->mspec_used = rnd(4);
609 if (++count >= MAXNASTIES
610 || mtmp->data->maligntyp == 0
611 || sgn(mtmp->data->maligntyp) == castalign)
612 break;
617 if (count)
618 count = monster_census(FALSE) - census;
619 return count;
622 /* Let's resurrect the wizard, for some unexpected fun. */
623 void
624 resurrect()
626 struct monst *mtmp, **mmtmp;
627 long elapsed;
628 const char *verb;
630 if (!context.no_of_wizards) {
631 /* make a new Wizard */
632 verb = "kill";
633 mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, MM_NOWAIT);
634 /* affects experience; he's not coming back from a corpse
635 but is subject to repeated killing like a revived corpse */
636 if (mtmp) mtmp->mrevived = 1;
637 } else {
638 /* look for a migrating Wizard */
639 verb = "elude";
640 mmtmp = &migrating_mons;
641 while ((mtmp = *mmtmp) != 0) {
642 if (mtmp->iswiz
643 /* if he has the Amulet, he won't bring it to you */
644 && !mon_has_amulet(mtmp)
645 && (elapsed = monstermoves - mtmp->mlstmv) > 0L) {
646 mon_catchup_elapsed_time(mtmp, elapsed);
647 if (elapsed >= LARGEST_INT)
648 elapsed = LARGEST_INT - 1;
649 elapsed /= 50L;
650 if (mtmp->msleeping && rn2((int) elapsed + 1))
651 mtmp->msleeping = 0;
652 if (mtmp->mfrozen == 1) /* would unfreeze on next move */
653 mtmp->mfrozen = 0, mtmp->mcanmove = 1;
654 if (mtmp->mcanmove && !mtmp->msleeping) {
655 *mmtmp = mtmp->nmon;
656 mon_arrive(mtmp, TRUE);
657 /* note: there might be a second Wizard; if so,
658 he'll have to wait til the next resurrection */
659 break;
662 mmtmp = &mtmp->nmon;
666 if (mtmp) {
667 mtmp->mtame = mtmp->mpeaceful = 0; /* paranoia */
668 set_malign(mtmp);
669 if (!Deaf) {
670 pline("A voice booms out...");
671 verbalize("So thou thought thou couldst %s me, fool.", verb);
676 /* Here, we make trouble for the poor shmuck who actually
677 managed to do in the Wizard. */
678 void
679 intervene()
681 int which = Is_astralevel(&u.uz) ? rnd(4) : rn2(6);
682 /* cases 0 and 5 don't apply on the Astral level */
683 switch (which) {
684 case 0:
685 case 1:
686 You_feel("vaguely nervous.");
687 break;
688 case 2:
689 if (!Blind)
690 You("notice a %s glow surrounding you.", hcolor(NH_BLACK));
691 rndcurse();
692 break;
693 case 3:
694 aggravate();
695 break;
696 case 4:
697 (void) nasty((struct monst *) 0);
698 break;
699 case 5:
700 resurrect();
701 break;
705 void
706 wizdead()
708 context.no_of_wizards--;
709 if (!u.uevent.udemigod) {
710 u.uevent.udemigod = TRUE;
711 u.udg_cnt = rn1(250, 50);
715 const char *const random_insult[] = {
716 "antic", "blackguard", "caitiff", "chucklehead",
717 "coistrel", "craven", "cretin", "cur",
718 "dastard", "demon fodder", "dimwit", "dolt",
719 "fool", "footpad", "imbecile", "knave",
720 "maledict", "miscreant", "niddering", "poltroon",
721 "rattlepate", "reprobate", "scapegrace", "varlet",
722 "villein", /* (sic.) */
723 "wittol", "worm", "wretch",
726 const char *const random_malediction[] = {
727 "Hell shall soon claim thy remains,", "I chortle at thee, thou pathetic",
728 "Prepare to die, thou", "Resistance is useless,",
729 "Surrender or die, thou", "There shall be no mercy, thou",
730 "Thou shalt repent of thy cunning,", "Thou art as a flea to me,",
731 "Thou art doomed,", "Thy fate is sealed,",
732 "Verily, thou shalt be one dead"
735 /* Insult or intimidate the player */
736 void
737 cuss(mtmp)
738 register struct monst *mtmp;
740 if (Deaf)
741 return;
742 if (mtmp->iswiz) {
743 if (!rn2(5)) /* typical bad guy action */
744 pline("%s laughs fiendishly.", Monnam(mtmp));
745 else if (u.uhave.amulet && !rn2(SIZE(random_insult)))
746 verbalize("Relinquish the amulet, %s!",
747 random_insult[rn2(SIZE(random_insult))]);
748 else if (u.uhp < 5 && !rn2(2)) /* Panic */
749 verbalize(rn2(2) ? "Even now thy life force ebbs, %s!"
750 : "Savor thy breath, %s, it be thy last!",
751 random_insult[rn2(SIZE(random_insult))]);
752 else if (mtmp->mhp < 5 && !rn2(2)) /* Parthian shot */
753 verbalize(rn2(2) ? "I shall return." : "I'll be back.");
754 else
755 verbalize("%s %s!",
756 random_malediction[rn2(SIZE(random_malediction))],
757 random_insult[rn2(SIZE(random_insult))]);
758 } else if (is_lminion(mtmp)
759 && !(mtmp->isminion && EMIN(mtmp)->renegade)) {
760 com_pager(rn2(QTN_ANGELIC - 1 + (Hallucination ? 1 : 0))
761 + QT_ANGELIC);
762 } else {
763 if (!rn2(is_minion(mtmp->data) ? 100 : 5))
764 pline("%s casts aspersions on your ancestry.", Monnam(mtmp));
765 else
766 com_pager(rn2(QTN_DEMONIC) + QT_DEMONIC);
770 /*wizard.c*/