Move getpos return values to header
[aNetHack.git] / src / wizard.c
blob6ab8e57bd869c06ef03ff7486fcf0a5fa6e61c0c
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 /* NetHack 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 (void) mnearto(mtmp, sx, sy, TRUE);
385 /* if you're not around, cast healing spells */
386 if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM))
387 if (mtmp->mhp <= mtmp->mhpmax - 8) {
388 mtmp->mhp += rnd(8);
389 return 1;
391 /* fall through :-) */
393 case STRAT_NONE: /* harass */
394 if (!rn2(!mtmp->mflee ? 5 : 33))
395 mnexto(mtmp);
396 return 0;
398 default: /* kill, maim, pillage! */
400 long where = (strat & STRAT_STRATMASK);
401 xchar tx = STRAT_GOALX(strat), ty = STRAT_GOALY(strat);
402 int targ = (int) (strat & STRAT_GOAL);
403 struct obj *otmp;
405 if (!targ) { /* simply wants you to close */
406 return 0;
408 if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
409 /* player is standing on it (or has it) */
410 mnexto(mtmp);
411 return 0;
413 if (where == STRAT_GROUND) {
414 if (!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) {
415 /* teleport to it and pick it up */
416 rloc_to(mtmp, tx, ty); /* clean old pos */
418 if ((otmp = on_ground(which_arti(targ))) != 0) {
419 if (cansee(mtmp->mx, mtmp->my))
420 pline("%s picks up %s.", Monnam(mtmp),
421 (distu(mtmp->mx, mtmp->my) <= 5)
422 ? doname(otmp)
423 : distant_name(otmp, doname));
424 obj_extract_self(otmp);
425 (void) mpickobj(mtmp, otmp);
426 return 1;
427 } else
428 return 0;
429 } else {
430 /* a monster is standing on it - cause some trouble */
431 if (!rn2(5))
432 mnexto(mtmp);
433 return 0;
435 } else { /* a monster has it - 'port beside it. */
436 (void) mnearto(mtmp, tx, ty, FALSE);
437 return 0;
441 /*NOTREACHED*/
442 return 0;
445 /* are there any monsters mon could aggravate? */
446 boolean
447 has_aggravatables(mon)
448 struct monst *mon;
450 struct monst *mtmp;
451 boolean in_w_tower = In_W_tower(mon->mx, mon->my, &u.uz);
453 if (in_w_tower != In_W_tower(u.ux, u.uy, &u.uz))
454 return FALSE;
456 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
457 if (DEADMONSTER(mtmp))
458 continue;
459 if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
460 continue;
461 if ((mtmp->mstrategy & STRAT_WAITFORU) != 0
462 || mtmp->msleeping || !mtmp->mcanmove)
463 return TRUE;
465 return FALSE;
468 void
469 aggravate()
471 register struct monst *mtmp;
472 boolean in_w_tower = In_W_tower(u.ux, u.uy, &u.uz);
474 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
475 if (DEADMONSTER(mtmp))
476 continue;
477 if (in_w_tower != In_W_tower(mtmp->mx, mtmp->my, &u.uz))
478 continue;
479 mtmp->mstrategy &= ~(STRAT_WAITFORU | STRAT_APPEARMSG);
480 mtmp->msleeping = 0;
481 if (!mtmp->mcanmove && !rn2(5)) {
482 mtmp->mfrozen = 0;
483 mtmp->mcanmove = 1;
488 void
489 clonewiz()
491 register struct monst *mtmp2;
493 if ((mtmp2 = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, NO_MM_FLAGS))
494 != 0) {
495 mtmp2->msleeping = mtmp2->mtame = mtmp2->mpeaceful = 0;
496 if (!u.uhave.amulet && rn2(2)) { /* give clone a fake */
497 (void) add_to_minv(mtmp2,
498 mksobj(FAKE_AMULET_OF_YENDOR, TRUE, FALSE));
500 mtmp2->m_ap_type = M_AP_MONSTER;
501 mtmp2->mappearance = wizapp[rn2(SIZE(wizapp))];
502 newsym(mtmp2->mx, mtmp2->my);
506 /* also used by newcham() */
508 pick_nasty()
510 int res = nasties[rn2(SIZE(nasties))];
512 /* To do? Possibly should filter for appropriate forms when
513 * in the elemental planes or surrounded by water or lava.
515 * We want monsters represented by uppercase on rogue level,
516 * but we don't try very hard.
518 if (Is_rogue_level(&u.uz)
519 && !('A' <= mons[res].mlet && mons[res].mlet <= 'Z'))
520 res = nasties[rn2(SIZE(nasties))];
522 return res;
525 /* create some nasty monsters, aligned with the caster or neutral; chaotic
526 and unaligned are treated as equivalent; if summoner is Null, this is
527 for late-game harassment (after the Wizard has been killed at least once
528 or the invocation ritual has been performed), in which case we treat
529 'summoner' as neutral, since that will produce the greatest number of
530 creatures on average (in 3.6.0 and earlier, Null was treated as chaotic);
531 returns the number of monsters created */
533 nasty(summoner)
534 struct monst *summoner;
536 register struct monst *mtmp;
537 register int i, j;
538 int castalign = (summoner ? sgn(summoner->data->maligntyp) : 0);
539 coord bypos;
540 int count, census, tmp, makeindex, s_cls, m_cls;
542 #define MAXNASTIES 10 /* more than this can be created */
544 /* some candidates may be created in groups, so simple count
545 of non-null makemon() return is inadequate */
546 census = monster_census(FALSE);
548 if (!rn2(10) && Inhell) {
549 /* this might summon a demon prince or lord */
550 count = msummon((struct monst *) 0); /* summons like WoY */
551 } else {
552 count = 0;
553 s_cls = summoner ? summoner->data->mlet : 0;
554 tmp = (u.ulevel > 3) ? u.ulevel / 3 : 1;
555 /* if we don't have a casting monster, nasties appear around hero,
556 otherwise they'll appear around spot summoner thinks she's at */
557 bypos.x = u.ux;
558 bypos.y = u.uy;
559 for (i = rnd(tmp); i > 0 && count < MAXNASTIES; --i)
560 /* Of the 42 nasties[], 10 are lawful, 14 are chaotic,
561 * and 18 are neutral.
563 * Neutral caster, used for late-game harrassment,
564 * has 18/42 chance to stop the inner loop on each
565 * critter, 24/42 chance for another iteration.
566 * Lawful caster has 28/42 chance to stop unless the
567 * summoner is an angel or demon, in which case the
568 * chance is 26/42.
569 * Chaotic or unaligned caster has 32/42 chance to
570 * stop, so will summon fewer creatures on average.
572 * The outer loop potentially gives chaotic/unaligned
573 * a chance to even things up since others will hit
574 * MAXNASTIES sooner, but its number of iterations is
575 * randomized so it won't always do so.
577 for (j = 0; j < 20; j++) {
578 /* Don't create more spellcasters of the monsters' level or
579 * higher--avoids chain summoners filling up the level.
581 do {
582 makeindex = pick_nasty();
583 m_cls = mons[makeindex].mlet;
584 } while (summoner
585 && ((attacktype(&mons[makeindex], AT_MAGC)
586 && monstr[makeindex] >= monstr[summoner->mnum])
587 || (s_cls == S_DEMON && m_cls == S_ANGEL)
588 || (s_cls == S_ANGEL && m_cls == S_DEMON)));
589 /* do this after picking the monster to place */
590 if (summoner && !enexto(&bypos, summoner->mux, summoner->muy,
591 &mons[makeindex]))
592 continue;
593 /* this honors genocide but overrides extinction; it ignores
594 inside-hell-only (G_HELL) & outside-hell-only (G_NOHELL) */
595 if ((mtmp = makemon(&mons[makeindex], bypos.x, bypos.y,
596 NO_MM_FLAGS)) != 0) {
597 mtmp->msleeping = mtmp->mpeaceful = mtmp->mtame = 0;
598 set_malign(mtmp);
599 } else /* random monster to substitute for geno'd selection */
600 mtmp = makemon((struct permonst *) 0, bypos.x, bypos.y,
601 NO_MM_FLAGS);
602 if (mtmp) {
603 /* delay first use of spell or breath attack */
604 mtmp->mspec_used = rnd(4);
605 if (++count >= MAXNASTIES
606 || mtmp->data->maligntyp == 0
607 || sgn(mtmp->data->maligntyp) == castalign)
608 break;
613 if (count)
614 count = monster_census(FALSE) - census;
615 return count;
618 /* Let's resurrect the wizard, for some unexpected fun. */
619 void
620 resurrect()
622 struct monst *mtmp, **mmtmp;
623 long elapsed;
624 const char *verb;
626 if (!context.no_of_wizards) {
627 /* make a new Wizard */
628 verb = "kill";
629 mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, MM_NOWAIT);
630 /* affects experience; he's not coming back from a corpse
631 but is subject to repeated killing like a revived corpse */
632 if (mtmp) mtmp->mrevived = 1;
633 } else {
634 /* look for a migrating Wizard */
635 verb = "elude";
636 mmtmp = &migrating_mons;
637 while ((mtmp = *mmtmp) != 0) {
638 if (mtmp->iswiz
639 /* if he has the Amulet, he won't bring it to you */
640 && !mon_has_amulet(mtmp)
641 && (elapsed = monstermoves - mtmp->mlstmv) > 0L) {
642 mon_catchup_elapsed_time(mtmp, elapsed);
643 if (elapsed >= LARGEST_INT)
644 elapsed = LARGEST_INT - 1;
645 elapsed /= 50L;
646 if (mtmp->msleeping && rn2((int) elapsed + 1))
647 mtmp->msleeping = 0;
648 if (mtmp->mfrozen == 1) /* would unfreeze on next move */
649 mtmp->mfrozen = 0, mtmp->mcanmove = 1;
650 if (mtmp->mcanmove && !mtmp->msleeping) {
651 *mmtmp = mtmp->nmon;
652 mon_arrive(mtmp, TRUE);
653 /* note: there might be a second Wizard; if so,
654 he'll have to wait til the next resurrection */
655 break;
658 mmtmp = &mtmp->nmon;
662 if (mtmp) {
663 mtmp->mtame = mtmp->mpeaceful = 0; /* paranoia */
664 set_malign(mtmp);
665 if (!Deaf) {
666 pline("A voice booms out...");
667 verbalize("So thou thought thou couldst %s me, fool.", verb);
672 /* Here, we make trouble for the poor shmuck who actually
673 managed to do in the Wizard. */
674 void
675 intervene()
677 int which = Is_astralevel(&u.uz) ? rnd(4) : rn2(6);
678 /* cases 0 and 5 don't apply on the Astral level */
679 switch (which) {
680 case 0:
681 case 1:
682 You_feel("vaguely nervous.");
683 break;
684 case 2:
685 if (!Blind)
686 You("notice a %s glow surrounding you.", hcolor(NH_BLACK));
687 rndcurse();
688 break;
689 case 3:
690 aggravate();
691 break;
692 case 4:
693 (void) nasty((struct monst *) 0);
694 break;
695 case 5:
696 resurrect();
697 break;
701 void
702 wizdead()
704 context.no_of_wizards--;
705 if (!u.uevent.udemigod) {
706 u.uevent.udemigod = TRUE;
707 u.udg_cnt = rn1(250, 50);
711 const char *const random_insult[] = {
712 "antic", "blackguard", "caitiff", "chucklehead",
713 "coistrel", "craven", "cretin", "cur",
714 "dastard", "demon fodder", "dimwit", "dolt",
715 "fool", "footpad", "imbecile", "knave",
716 "maledict", "miscreant", "niddering", "poltroon",
717 "rattlepate", "reprobate", "scapegrace", "varlet",
718 "villein", /* (sic.) */
719 "wittol", "worm", "wretch",
722 const char *const random_malediction[] = {
723 "Hell shall soon claim thy remains,", "I chortle at thee, thou pathetic",
724 "Prepare to die, thou", "Resistance is useless,",
725 "Surrender or die, thou", "There shall be no mercy, thou",
726 "Thou shalt repent of thy cunning,", "Thou art as a flea to me,",
727 "Thou art doomed,", "Thy fate is sealed,",
728 "Verily, thou shalt be one dead"
731 /* Insult or intimidate the player */
732 void
733 cuss(mtmp)
734 register struct monst *mtmp;
736 if (Deaf)
737 return;
738 if (mtmp->iswiz) {
739 if (!rn2(5)) /* typical bad guy action */
740 pline("%s laughs fiendishly.", Monnam(mtmp));
741 else if (u.uhave.amulet && !rn2(SIZE(random_insult)))
742 verbalize("Relinquish the amulet, %s!",
743 random_insult[rn2(SIZE(random_insult))]);
744 else if (u.uhp < 5 && !rn2(2)) /* Panic */
745 verbalize(rn2(2) ? "Even now thy life force ebbs, %s!"
746 : "Savor thy breath, %s, it be thy last!",
747 random_insult[rn2(SIZE(random_insult))]);
748 else if (mtmp->mhp < 5 && !rn2(2)) /* Parthian shot */
749 verbalize(rn2(2) ? "I shall return." : "I'll be back.");
750 else
751 verbalize("%s %s!",
752 random_malediction[rn2(SIZE(random_malediction))],
753 random_insult[rn2(SIZE(random_insult))]);
754 } else if (is_lminion(mtmp)
755 && !(mtmp->isminion && EMIN(mtmp)->renegade)) {
756 com_pager(rn2(QTN_ANGELIC - 1 + (Hallucination ? 1 : 0))
757 + QT_ANGELIC);
758 } else {
759 if (!rn2(is_minion(mtmp->data) ? 100 : 5))
760 pline("%s casts aspersions on your ancestry.", Monnam(mtmp));
761 else
762 com_pager(rn2(QTN_DEMONIC) + QT_DEMONIC);
766 /*wizard.c*/