Source:NetHack 3.6.0/src/wizard.c

From NetHackWiki
(Redirected from Source:Wizard.c)
Jump to: navigation, search

Below is the full text to wizard.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/wizard.c#line123]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

Top of file

  1.  /* NetHack 3.6	wizard.c	$NHDT-Date: 1446078768 2015/10/29 00:32:48 $  $NHDT-Branch: master $:$NHDT-Revision: 1.42 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  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) */
  9.  
  10.  #include "hack.h"
  11.  #include "qtext.h"
  12.  
  13.  extern const int monstr[];
  14.  
  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 *));
  22.  
  23.  static NEARDATA const int nasties[] = {
  24.      PM_COCKATRICE, PM_ETTIN, PM_STALKER, PM_MINOTAUR, PM_RED_DRAGON,
  25.      PM_BLACK_DRAGON, PM_GREEN_DRAGON, PM_OWLBEAR, PM_PURPLE_WORM,
  26.      PM_ROCK_TROLL, PM_XAN, PM_GREMLIN, PM_UMBER_HULK, PM_VAMPIRE_LORD,
  27.      PM_XORN, PM_ZRUTY, PM_ELF_LORD, PM_ELVENKING, PM_YELLOW_DRAGON,
  28.      PM_LEOCROTTA, PM_BALUCHITHERIUM, PM_CARNIVOROUS_APE, PM_FIRE_GIANT,
  29.      PM_COUATL, PM_CAPTAIN, PM_WINGED_GARGOYLE, PM_MASTER_MIND_FLAYER,
  30.      PM_FIRE_ELEMENTAL, PM_JABBERWOCK, PM_ARCH_LICH, PM_OGRE_KING, PM_OLOG_HAI,
  31.      PM_IRON_GOLEM, PM_OCHRE_JELLY, PM_GREEN_SLIME, PM_DISENCHANTER
  32.  };
  33.  
  34.  static NEARDATA const unsigned wizapp[] = {
  35.      PM_HUMAN,      PM_WATER_DEMON,  PM_VAMPIRE,       PM_RED_DRAGON,
  36.      PM_TROLL,      PM_UMBER_HULK,   PM_XORN,          PM_XAN,
  37.      PM_COCKATRICE, PM_FLOATING_EYE, PM_GUARDIAN_NAGA, PM_TRAPPER
  38.  };
  39.  

amulet

  1.  /* If you've found the Amulet, make the Wizard appear after some time */
  2.  /* Also, give hints about portal locations, if amulet is worn/wielded -dlc */
  3.  void
  4.  amulet()
  5.  {
  6.      struct monst *mtmp;
  7.      struct trap *ttmp;
  8.      struct obj *amu;
  9.  
  10.  #if 0 /* caller takes care of this check */
  11.      if (!u.uhave.amulet)
  12.          return;
  13.  #endif
  14.      if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR)
  15.           || ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
  16.          && !rn2(15)) {
  17.          for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) {
  18.              if (ttmp->ttyp == MAGIC_PORTAL) {
  19.                  int du = distu(ttmp->tx, ttmp->ty);
  20.                  if (du <= 9)
  21.                      pline("%s hot!", Tobjnam(amu, "feel"));
  22.                  else if (du <= 64)
  23.                      pline("%s very warm.", Tobjnam(amu, "feel"));
  24.                  else if (du <= 144)
  25.                      pline("%s warm.", Tobjnam(amu, "feel"));
  26.                  /* else, the amulet feels normal */
  27.                  break;
  28.              }
  29.          }
  30.      }
  31.  
  32.      if (!context.no_of_wizards)
  33.          return;
  34.      /* find Wizard, and wake him if necessary */
  35.      for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  36.          if (DEADMONSTER(mtmp))
  37.              continue;
  38.          if (mtmp->iswiz && mtmp->msleeping && !rn2(40)) {
  39.              mtmp->msleeping = 0;
  40.              if (distu(mtmp->mx, mtmp->my) > 2)
  41.                  You(
  42.        "get the creepy feeling that somebody noticed your taking the Amulet.");
  43.              return;
  44.          }
  45.      }
  46.  }
  47.  

mon_has_amulet

  1.  int
  2.  mon_has_amulet(mtmp)
  3.  register struct monst *mtmp;
  4.  {
  5.      register struct obj *otmp;
  6.  
  7.      for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
  8.          if (otmp->otyp == AMULET_OF_YENDOR)
  9.              return 1;
  10.      return 0;
  11.  }
  12.  

mon_has_special

  1.  int
  2.  mon_has_special(mtmp)
  3.  register struct monst *mtmp;
  4.  {
  5.      register struct obj *otmp;
  6.  
  7.      for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
  8.          if (otmp->otyp == AMULET_OF_YENDOR || is_quest_artifact(otmp)
  9.              || otmp->otyp == BELL_OF_OPENING
  10.              || otmp->otyp == CANDELABRUM_OF_INVOCATION
  11.              || otmp->otyp == SPE_BOOK_OF_THE_DEAD)
  12.              return 1;
  13.      return 0;
  14.  }
  15.  


  1.  /*
  2.   *      New for 3.1  Strategy / Tactics for the wiz, as well as other
  3.   *      monsters that are "after" something (defined via mflag3).
  4.   *
  5.   *      The strategy section decides *what* the monster is going
  6.   *      to attempt, the tactics section implements the decision.
  7.   */
  8.  #define STRAT(w, x, y, typ)                            \
  9.      ((unsigned long) (w) | ((unsigned long) (x) << 16) \
  10.       | ((unsigned long) (y) << 8) | (unsigned long) (typ))
  11.  
  12.  #define M_Wants(mask) (mtmp->data->mflags3 & (mask))
  13.  

which_arti

  1.  STATIC_OVL short
  2.  which_arti(mask)
  3.  register int mask;
  4.  {
  5.      switch (mask) {
  6.      case M3_WANTSAMUL:
  7.          return AMULET_OF_YENDOR;
  8.      case M3_WANTSBELL:
  9.          return BELL_OF_OPENING;
  10.      case M3_WANTSCAND:
  11.          return CANDELABRUM_OF_INVOCATION;
  12.      case M3_WANTSBOOK:
  13.          return SPE_BOOK_OF_THE_DEAD;
  14.      default:
  15.          break; /* 0 signifies quest artifact */
  16.      }
  17.      return 0;
  18.  }
  19.  

mon_has_arti

  1.  /*
  2.   *      If "otyp" is zero, it triggers a check for the quest_artifact,
  3.   *      since bell, book, candle, and amulet are all objects, not really
  4.   *      artifacts right now.  [MRS]
  5.   */
  6.  STATIC_OVL boolean
  7.  mon_has_arti(mtmp, otyp)
  8.  register struct monst *mtmp;
  9.  register short otyp;
  10.  {
  11.      register struct obj *otmp;
  12.  
  13.      for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
  14.          if (otyp) {
  15.              if (otmp->otyp == otyp)
  16.                  return 1;
  17.          } else if (is_quest_artifact(otmp))
  18.              return 1;
  19.      }
  20.      return 0;
  21.  }
  22.  

other_mon_has_arti

  1.  STATIC_OVL struct monst *
  2.  other_mon_has_arti(mtmp, otyp)
  3.  register struct monst *mtmp;
  4.  register short otyp;
  5.  {
  6.      register struct monst *mtmp2;
  7.  
  8.      for (mtmp2 = fmon; mtmp2; mtmp2 = mtmp2->nmon)
  9.          /* no need for !DEADMONSTER check here since they have no inventory */
  10.          if (mtmp2 != mtmp)
  11.              if (mon_has_arti(mtmp2, otyp))
  12.                  return mtmp2;
  13.  
  14.      return (struct monst *) 0;
  15.  }
  16.  

on_ground

  1.  STATIC_OVL struct obj *
  2.  on_ground(otyp)
  3.  register short otyp;
  4.  {
  5.      register struct obj *otmp;
  6.  
  7.      for (otmp = fobj; otmp; otmp = otmp->nobj)
  8.          if (otyp) {
  9.              if (otmp->otyp == otyp)
  10.                  return otmp;
  11.          } else if (is_quest_artifact(otmp))
  12.              return otmp;
  13.      return (struct obj *) 0;
  14.  }
  15.  

you_have

  1.  STATIC_OVL boolean
  2.  you_have(mask)
  3.  register int mask;
  4.  {
  5.      switch (mask) {
  6.      case M3_WANTSAMUL:
  7.          return (boolean) u.uhave.amulet;
  8.      case M3_WANTSBELL:
  9.          return (boolean) u.uhave.bell;
  10.      case M3_WANTSCAND:
  11.          return (boolean) u.uhave.menorah;
  12.      case M3_WANTSBOOK:
  13.          return (boolean) u.uhave.book;
  14.      case M3_WANTSARTI:
  15.          return (boolean) u.uhave.questart;
  16.      default:
  17.          break;
  18.      }
  19.      return 0;
  20.  }
  21.  

target_on

  1.  STATIC_OVL unsigned long
  2.  target_on(mask, mtmp)
  3.  register int mask;
  4.  register struct monst *mtmp;
  5.  {
  6.      register short otyp;
  7.      register struct obj *otmp;
  8.      register struct monst *mtmp2;
  9.  
  10.      if (!M_Wants(mask))
  11.          return (unsigned long) STRAT_NONE;
  12.  
  13.      otyp = which_arti(mask);
  14.      if (!mon_has_arti(mtmp, otyp)) {
  15.          if (you_have(mask))
  16.              return STRAT(STRAT_PLAYER, u.ux, u.uy, mask);
  17.          else if ((otmp = on_ground(otyp)))
  18.              return STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask);
  19.          else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0
  20.                   /* when seeking the Amulet, avoid targetting the Wizard
  21.                      or temple priests (to protect Moloch's high priest) */
  22.                   && (otyp != AMULET_OF_YENDOR
  23.                       || (!mtmp2->iswiz && !inhistemple(mtmp2))))
  24.              return STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask);
  25.      }
  26.      return (unsigned long) STRAT_NONE;
  27.  }
  28.  

strategy

  1.  STATIC_OVL unsigned long
  2.  strategy(mtmp)
  3.  register struct monst *mtmp;
  4.  {
  5.      unsigned long strat, dstrat;
  6.  
  7.      if (!is_covetous(mtmp->data)
  8.          /* perhaps a shopkeeper has been polymorphed into a master
  9.             lich; we don't want it teleporting to the stairs to heal
  10.             because that will leave its shop untended */
  11.          || (mtmp->isshk && inhishop(mtmp))
  12.          /* likewise for temple priests */
  13.          || (mtmp->ispriest && inhistemple(mtmp)))
  14.          return (unsigned long) STRAT_NONE;
  15.  
  16.      switch ((mtmp->mhp * 3) / mtmp->mhpmax) { /* 0-3 */
  17.  
  18.      default:
  19.      case 0: /* panic time - mtmp is almost snuffed */
  20.          return (unsigned long) STRAT_HEAL;
  21.  
  22.      case 1: /* the wiz is less cautious */
  23.          if (mtmp->data != &mons[PM_WIZARD_OF_YENDOR])
  24.              return (unsigned long) STRAT_HEAL;
  25.      /* else fall through */
  26.  
  27.      case 2:
  28.          dstrat = STRAT_HEAL;
  29.          break;
  30.  
  31.      case 3:
  32.          dstrat = STRAT_NONE;
  33.          break;
  34.      }
  35.  
  36.      if (context.made_amulet)
  37.          if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE)
  38.              return strat;
  39.  
  40.      if (u.uevent.invoked) { /* priorities change once gate opened */
  41.          if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
  42.              return strat;
  43.          if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
  44.              return strat;
  45.          if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
  46.              return strat;
  47.          if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
  48.              return strat;
  49.      } else {
  50.          if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
  51.              return strat;
  52.          if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
  53.              return strat;
  54.          if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
  55.              return strat;
  56.          if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
  57.              return strat;
  58.      }
  59.      return dstrat;
  60.  }
  61.  

tactics

  1.  int
  2.  tactics(mtmp)
  3.  register struct monst *mtmp;
  4.  {
  5.      unsigned long strat = strategy(mtmp);
  6.  
  7.      mtmp->mstrategy =
  8.          (mtmp->mstrategy & (STRAT_WAITMASK | STRAT_APPEARMSG)) | strat;
  9.  
  10.      switch (strat) {
  11.      case STRAT_HEAL: /* hide and recover */
  12.          /* if wounded, hole up on or near the stairs (to block them) */
  13.          /* unless, of course, there are no stairs (e.g. endlevel) */
  14.          mtmp->mavenge = 1; /* covetous monsters attack while fleeing */
  15.          if (In_W_tower(mtmp->mx, mtmp->my, &u.uz)
  16.              || (mtmp->iswiz && !xupstair && !mon_has_amulet(mtmp))) {
  17.              if (!rn2(3 + mtmp->mhp / 10))
  18.                  (void) rloc(mtmp, TRUE);
  19.          } else if (xupstair
  20.                     && (mtmp->mx != xupstair || mtmp->my != yupstair)) {
  21.              (void) mnearto(mtmp, xupstair, yupstair, TRUE);
  22.          }
  23.          /* if you're not around, cast healing spells */
  24.          if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM))
  25.              if (mtmp->mhp <= mtmp->mhpmax - 8) {
  26.                  mtmp->mhp += rnd(8);
  27.                  return 1;
  28.              }
  29.      /* fall through :-) */
  30.  
  31.      case STRAT_NONE: /* harass */
  32.          if (!rn2(!mtmp->mflee ? 5 : 33))
  33.              mnexto(mtmp);
  34.          return 0;
  35.  
  36.      default: /* kill, maim, pillage! */
  37.      {
  38.          long where = (strat & STRAT_STRATMASK);
  39.          xchar tx = STRAT_GOALX(strat), ty = STRAT_GOALY(strat);
  40.          int targ = (int) (strat & STRAT_GOAL);
  41.          struct obj *otmp;
  42.  
  43.          if (!targ) { /* simply wants you to close */
  44.              return 0;
  45.          }
  46.          if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
  47.              /* player is standing on it (or has it) */
  48.              mnexto(mtmp);
  49.              return 0;
  50.          }
  51.          if (where == STRAT_GROUND) {
  52.              if (!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) {
  53.                  /* teleport to it and pick it up */
  54.                  rloc_to(mtmp, tx, ty); /* clean old pos */
  55.  
  56.                  if ((otmp = on_ground(which_arti(targ))) != 0) {
  57.                      if (cansee(mtmp->mx, mtmp->my))
  58.                          pline("%s picks up %s.", Monnam(mtmp),
  59.                                (distu(mtmp->mx, mtmp->my) <= 5)
  60.                                    ? doname(otmp)
  61.                                    : distant_name(otmp, doname));
  62.                      obj_extract_self(otmp);
  63.                      (void) mpickobj(mtmp, otmp);
  64.                      return 1;
  65.                  } else
  66.                      return 0;
  67.              } else {
  68.                  /* a monster is standing on it - cause some trouble */
  69.                  if (!rn2(5))
  70.                      mnexto(mtmp);
  71.                  return 0;
  72.              }
  73.          } else { /* a monster has it - 'port beside it. */
  74.              (void) mnearto(mtmp, tx, ty, FALSE);
  75.              return 0;
  76.          }
  77.      }
  78.      }
  79.      /*NOTREACHED*/
  80.      return 0;
  81.  }
  82.  

aggravate

  1.  void
  2.  aggravate()
  3.  {
  4.      register struct monst *mtmp;
  5.  
  6.      for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  7.          if (DEADMONSTER(mtmp))
  8.              continue;
  9.          mtmp->mstrategy &= ~(STRAT_WAITFORU | STRAT_APPEARMSG);
  10.          mtmp->msleeping = 0;
  11.          if (!mtmp->mcanmove && !rn2(5)) {
  12.              mtmp->mfrozen = 0;
  13.              mtmp->mcanmove = 1;
  14.          }
  15.      }
  16.  }
  17.  

clonewiz

  1.  void
  2.  clonewiz()
  3.  {
  4.      register struct monst *mtmp2;
  5.  
  6.      if ((mtmp2 = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, NO_MM_FLAGS))
  7.          != 0) {
  8.          mtmp2->msleeping = mtmp2->mtame = mtmp2->mpeaceful = 0;
  9.          if (!u.uhave.amulet && rn2(2)) { /* give clone a fake */
  10.              (void) add_to_minv(mtmp2,
  11.                                 mksobj(FAKE_AMULET_OF_YENDOR, TRUE, FALSE));
  12.          }
  13.          mtmp2->m_ap_type = M_AP_MONSTER;
  14.          mtmp2->mappearance = wizapp[rn2(SIZE(wizapp))];
  15.          newsym(mtmp2->mx, mtmp2->my);
  16.      }
  17.  }
  18.  

pick_nasty

  1.  /* also used by newcham() */
  2.  int
  3.  pick_nasty()
  4.  {
  5.      int res = nasties[rn2(SIZE(nasties))];
  6.  
  7.      /* To do?  Possibly should filter for appropriate forms when
  8.       * in the elemental planes or surrounded by water or lava.
  9.       *
  10.       * We want monsters represented by uppercase on rogue level,
  11.       * but we don't try very hard.
  12.       */
  13.      if (Is_rogue_level(&u.uz)
  14.          && !('A' <= mons[res].mlet && mons[res].mlet <= 'Z'))
  15.          res = nasties[rn2(SIZE(nasties))];
  16.  
  17.      return res;
  18.  }
  19.  

nasty

  1.  /* create some nasty monsters, aligned or neutral with the caster */
  2.  /* a null caster defaults to a chaotic caster (e.g. the wizard) */
  3.  int
  4.  nasty(mcast)
  5.  struct monst *mcast;
  6.  {
  7.      register struct monst *mtmp;
  8.      register int i, j, tmp;
  9.      int castalign = (mcast ? sgn(mcast->data->maligntyp) : -1);
  10.      coord bypos;
  11.      int count, census;
  12.  
  13.      /* some candidates may be created in groups, so simple count
  14.         of non-null makemon() return is inadequate */
  15.      census = monster_census(FALSE);
  16.  
  17.      if (!rn2(10) && Inhell) {
  18.          count = msummon((struct monst *) 0); /* summons like WoY */
  19.      } else {
  20.          count = 0;
  21.          tmp = (u.ulevel > 3) ? u.ulevel / 3 : 1; /* just in case -- rph */
  22.          /* if we don't have a casting monster, the nasties appear around you
  23.           */
  24.          bypos.x = u.ux;
  25.          bypos.y = u.uy;
  26.          for (i = rnd(tmp); i > 0; --i)
  27.              for (j = 0; j < 20; j++) {
  28.                  int makeindex;
  29.  
  30.                  /* Don't create more spellcasters of the monsters' level or
  31.                   * higher--avoids chain summoners filling up the level.
  32.                   */
  33.                  do {
  34.                      makeindex = pick_nasty();
  35.                  } while (mcast && attacktype(&mons[makeindex], AT_MAGC)
  36.                           && monstr[makeindex] >= monstr[mcast->mnum]);
  37.                  /* do this after picking the monster to place */
  38.                  if (mcast
  39.                      && !enexto(&bypos, mcast->mux, mcast->muy,
  40.                                 &mons[makeindex]))
  41.                      continue;
  42.                  if ((mtmp = makemon(&mons[makeindex], bypos.x, bypos.y,
  43.                                      NO_MM_FLAGS)) != 0) {
  44.                      mtmp->msleeping = mtmp->mpeaceful = mtmp->mtame = 0;
  45.                      set_malign(mtmp);
  46.                  } else /* GENOD? */
  47.                      mtmp = makemon((struct permonst *) 0, bypos.x, bypos.y,
  48.                                     NO_MM_FLAGS);
  49.                  if (mtmp) {
  50.                      count++;
  51.                      if (mtmp->data->maligntyp == 0
  52.                          || sgn(mtmp->data->maligntyp) == castalign)
  53.                          break;
  54.                  }
  55.              }
  56.      }
  57.  
  58.      if (count)
  59.          count = monster_census(FALSE) - census;
  60.      return count;
  61.  }
  62.  

resurrect

  1.  /* Let's resurrect the wizard, for some unexpected fun. */
  2.  void
  3.  resurrect()
  4.  {
  5.      struct monst *mtmp, **mmtmp;
  6.      long elapsed;
  7.      const char *verb;
  8.  
  9.      if (!context.no_of_wizards) {
  10.          /* make a new Wizard */
  11.          verb = "kill";
  12.          mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, MM_NOWAIT);
  13.          /* affects experience; he's not coming back from a corpse
  14.             but is subject to repeated killing like a revived corpse */
  15.          if (mtmp) mtmp->mrevived = 1;
  16.      } else {
  17.          /* look for a migrating Wizard */
  18.          verb = "elude";
  19.          mmtmp = &migrating_mons;
  20.          while ((mtmp = *mmtmp) != 0) {
  21.              if (mtmp->iswiz
  22.                  /* if he has the Amulet, he won't bring it to you */
  23.                  && !mon_has_amulet(mtmp)
  24.                  && (elapsed = monstermoves - mtmp->mlstmv) > 0L) {
  25.                  mon_catchup_elapsed_time(mtmp, elapsed);
  26.                  if (elapsed >= LARGEST_INT)
  27.                      elapsed = LARGEST_INT - 1;
  28.                  elapsed /= 50L;
  29.                  if (mtmp->msleeping && rn2((int) elapsed + 1))
  30.                      mtmp->msleeping = 0;
  31.                  if (mtmp->mfrozen == 1) /* would unfreeze on next move */
  32.                      mtmp->mfrozen = 0, mtmp->mcanmove = 1;
  33.                  if (mtmp->mcanmove && !mtmp->msleeping) {
  34.                      *mmtmp = mtmp->nmon;
  35.                      mon_arrive(mtmp, TRUE);
  36.                      /* note: there might be a second Wizard; if so,
  37.                         he'll have to wait til the next resurrection */
  38.                      break;
  39.                  }
  40.              }
  41.              mmtmp = &mtmp->nmon;
  42.          }
  43.      }
  44.  
  45.      if (mtmp) {
  46.          mtmp->mtame = mtmp->mpeaceful = 0; /* paranoia */
  47.          set_malign(mtmp);
  48.          if (!Deaf) {
  49.              pline("A voice booms out...");
  50.              verbalize("So thou thought thou couldst %s me, fool.", verb);
  51.          }
  52.      }
  53.  }
  54.  

intervene

  1.  /* Here, we make trouble for the poor shmuck who actually
  2.     managed to do in the Wizard. */
  3.  void
  4.  intervene()
  5.  {
  6.      int which = Is_astralevel(&u.uz) ? rnd(4) : rn2(6);
  7.      /* cases 0 and 5 don't apply on the Astral level */
  8.      switch (which) {
  9.      case 0:
  10.      case 1:
  11.          You_feel("vaguely nervous.");
  12.          break;
  13.      case 2:
  14.          if (!Blind)
  15.              You("notice a %s glow surrounding you.", hcolor(NH_BLACK));
  16.          rndcurse();
  17.          break;
  18.      case 3:
  19.          aggravate();
  20.          break;
  21.      case 4:
  22.          (void) nasty((struct monst *) 0);
  23.          break;
  24.      case 5:
  25.          resurrect();
  26.          break;
  27.      }
  28.  }
  29.  

wizdead

  1.  void
  2.  wizdead()
  3.  {
  4.      context.no_of_wizards--;
  5.      if (!u.uevent.udemigod) {
  6.          u.uevent.udemigod = TRUE;
  7.          u.udg_cnt = rn1(250, 50);
  8.      }
  9.  }
  10.  

cuss

  1.  const char *const random_insult[] = {
  2.      "antic",      "blackguard",   "caitiff",    "chucklehead",
  3.      "coistrel",   "craven",       "cretin",     "cur",
  4.      "dastard",    "demon fodder", "dimwit",     "dolt",
  5.      "fool",       "footpad",      "imbecile",   "knave",
  6.      "maledict",   "miscreant",    "niddering",  "poltroon",
  7.      "rattlepate", "reprobate",    "scapegrace", "varlet",
  8.      "villein", /* (sic.) */
  9.      "wittol",     "worm",         "wretch",
  10.  };
  11.  
  12.  const char *const random_malediction[] = {
  13.      "Hell shall soon claim thy remains,", "I chortle at thee, thou pathetic",
  14.      "Prepare to die, thou", "Resistance is useless,",
  15.      "Surrender or die, thou", "There shall be no mercy, thou",
  16.      "Thou shalt repent of thy cunning,", "Thou art as a flea to me,",
  17.      "Thou art doomed,", "Thy fate is sealed,",
  18.      "Verily, thou shalt be one dead"
  19.  };
  20.  
  21.  /* Insult or intimidate the player */
  22.  void
  23.  cuss(mtmp)
  24.  register struct monst *mtmp;
  25.  {
  26.      if (Deaf)
  27.          return;
  28.      if (mtmp->iswiz) {
  29.          if (!rn2(5)) /* typical bad guy action */
  30.              pline("%s laughs fiendishly.", Monnam(mtmp));
  31.          else if (u.uhave.amulet && !rn2(SIZE(random_insult)))
  32.              verbalize("Relinquish the amulet, %s!",
  33.                        random_insult[rn2(SIZE(random_insult))]);
  34.          else if (u.uhp < 5 && !rn2(2)) /* Panic */
  35.              verbalize(rn2(2) ? "Even now thy life force ebbs, %s!"
  36.                               : "Savor thy breath, %s, it be thy last!",
  37.                        random_insult[rn2(SIZE(random_insult))]);
  38.          else if (mtmp->mhp < 5 && !rn2(2)) /* Parthian shot */
  39.              verbalize(rn2(2) ? "I shall return." : "I'll be back.");
  40.          else
  41.              verbalize("%s %s!",
  42.                        random_malediction[rn2(SIZE(random_malediction))],
  43.                        random_insult[rn2(SIZE(random_insult))]);
  44.      } else if (is_lminion(mtmp)) {
  45.          com_pager(rn2(QTN_ANGELIC - 1 + (Hallucination ? 1 : 0))
  46.                    + QT_ANGELIC);
  47.      } else {
  48.          if (!rn2(5))
  49.              pline("%s casts aspersions on your ancestry.", Monnam(mtmp));
  50.          else
  51.              com_pager(rn2(QTN_DEMONIC) + QT_DEMONIC);
  52.      }
  53.  }
  54.  
  55.  /*wizard.c*/