Source:NetHack 3.6.0/src/were.c

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

Below is the full text to were.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/were.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	were.c	$NHDT-Date: 1432512763 2015/05/25 00:12:43 $  $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5.  #include "hack.h"
  6.  

were_change

  1.  void
  2.  were_change(mon)
  3.  register struct monst *mon;
  4.  {
  5.      if (!is_were(mon->data))
  6.          return;
  7.  
  8.      if (is_human(mon->data)) {
  9.          if (!Protection_from_shape_changers
  10.              && !rn2(night() ? (flags.moonphase == FULL_MOON ? 3 : 30)
  11.                              : (flags.moonphase == FULL_MOON ? 10 : 50))) {
  12.              new_were(mon); /* change into animal form */
  13.              if (!Deaf && !canseemon(mon)) {
  14.                  const char *howler;
  15.  
  16.                  switch (monsndx(mon->data)) {
  17.                  case PM_WEREWOLF:
  18.                      howler = "wolf";
  19.                      break;
  20.                  case PM_WEREJACKAL:
  21.                      howler = "jackal";
  22.                      break;
  23.                  default:
  24.                      howler = (char *) 0;
  25.                      break;
  26.                  }
  27.                  if (howler)
  28.                      You_hear("a %s howling at the moon.", howler);
  29.              }
  30.          }
  31.      } else if (!rn2(30) || Protection_from_shape_changers) {
  32.          new_were(mon); /* change back into human form */
  33.      }
  34.  }
  35.  

counter_were

  1.  int
  2.  counter_were(pm)
  3.  int pm;
  4.  {
  5.      switch (pm) {
  6.      case PM_WEREWOLF:
  7.          return (PM_HUMAN_WEREWOLF);
  8.      case PM_HUMAN_WEREWOLF:
  9.          return (PM_WEREWOLF);
  10.      case PM_WEREJACKAL:
  11.          return (PM_HUMAN_WEREJACKAL);
  12.      case PM_HUMAN_WEREJACKAL:
  13.          return (PM_WEREJACKAL);
  14.      case PM_WERERAT:
  15.          return (PM_HUMAN_WERERAT);
  16.      case PM_HUMAN_WERERAT:
  17.          return (PM_WERERAT);
  18.      default:
  19.          return NON_PM;
  20.      }
  21.  }
  22.  

were_beastie

  1.  /* convert monsters similar to werecritters into appropriate werebeast */
  2.  int
  3.  were_beastie(pm)
  4.  int pm;
  5.  {
  6.      switch (pm) {
  7.      case PM_WERERAT:
  8.      case PM_SEWER_RAT:
  9.      case PM_GIANT_RAT:
  10.      case PM_RABID_RAT:
  11.          return PM_WERERAT;
  12.      case PM_WEREJACKAL:
  13.      case PM_JACKAL:
  14.      case PM_FOX:
  15.      case PM_COYOTE:
  16.          return PM_WEREJACKAL;
  17.      case PM_WEREWOLF:
  18.      case PM_WOLF:
  19.      case PM_WARG:
  20.      case PM_WINTER_WOLF:
  21.          return PM_WEREWOLF;
  22.      default:
  23.          break;
  24.      }
  25.      return NON_PM;
  26.  }
  27.  

new_were

  1.  void
  2.  new_were(mon)
  3.  register struct monst *mon;
  4.  {
  5.      register int pm;
  6.  
  7.      pm = counter_were(monsndx(mon->data));
  8.      if (pm < LOW_PM) {
  9.          impossible("unknown lycanthrope %s.", mon->data->mname);
  10.          return;
  11.      }
  12.  
  13.      if (canseemon(mon) && !Hallucination)
  14.          pline("%s changes into a %s.", Monnam(mon),
  15.                is_human(&mons[pm]) ? "human" : mons[pm].mname + 4);
  16.  
  17.      set_mon_data(mon, &mons[pm], 0);
  18.      if (mon->msleeping || !mon->mcanmove) {
  19.          /* transformation wakens and/or revitalizes */
  20.          mon->msleeping = 0;
  21.          mon->mfrozen = 0; /* not asleep or paralyzed */
  22.          mon->mcanmove = 1;
  23.      }
  24.      /* regenerate by 1/4 of the lost hit points */
  25.      mon->mhp += (mon->mhpmax - mon->mhp) / 4;
  26.      newsym(mon->mx, mon->my);
  27.      mon_break_armor(mon, FALSE);
  28.      possibly_unwield(mon, FALSE);
  29.  }
  30.  

were_summon

  1.  int were_summon(ptr, yours, visible,
  2.                  genbuf) /* were-creature (even you) summons a horde */
  3.  register struct permonst *ptr;
  4.  register boolean yours;
  5.  int *visible; /* number of visible helpers created */
  6.  char *genbuf;
  7.  {
  8.      register int i, typ, pm = monsndx(ptr);
  9.      register struct monst *mtmp;
  10.      int total = 0;
  11.  
  12.      *visible = 0;
  13.      if (Protection_from_shape_changers && !yours)
  14.          return 0;
  15.      for (i = rnd(5); i > 0; i--) {
  16.          switch (pm) {
  17.          case PM_WERERAT:
  18.          case PM_HUMAN_WERERAT:
  19.              typ =
  20.                  rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT;
  21.              if (genbuf)
  22.                  Strcpy(genbuf, "rat");
  23.              break;
  24.          case PM_WEREJACKAL:
  25.          case PM_HUMAN_WEREJACKAL:
  26.              typ = PM_JACKAL;
  27.              if (genbuf)
  28.                  Strcpy(genbuf, "jackal");
  29.              break;
  30.          case PM_WEREWOLF:
  31.          case PM_HUMAN_WEREWOLF:
  32.              typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF;
  33.              if (genbuf)
  34.                  Strcpy(genbuf, "wolf");
  35.              break;
  36.          default:
  37.              continue;
  38.          }
  39.          mtmp = makemon(&mons[typ], u.ux, u.uy, NO_MM_FLAGS);
  40.          if (mtmp) {
  41.              total++;
  42.              if (canseemon(mtmp))
  43.                  *visible += 1;
  44.          }
  45.          if (yours && mtmp)
  46.              (void) tamedog(mtmp, (struct obj *) 0);
  47.      }
  48.      return total;
  49.  }
  50.  

you_were

  1.  void
  2.  you_were()
  3.  {
  4.      char qbuf[QBUFSZ];
  5.      boolean controllable_poly = Polymorph_control && !(Stunned || Unaware);
  6.  
  7.      if (Unchanging || (u.umonnum == u.ulycn))
  8.          return;
  9.      if (controllable_poly) {
  10.          /* `+4' => skip "were" prefix to get name of beast */
  11.          Sprintf(qbuf, "Do you want to change into %s?",
  12.                  an(mons[u.ulycn].mname + 4));
  13.          if (yn(qbuf) == 'n')
  14.              return;
  15.      }
  16.      (void) polymon(u.ulycn);
  17.  }
  18.  

you_unwere

  1.  void
  2.  you_unwere(purify)
  3.  boolean purify;
  4.  {
  5.      boolean controllable_poly = Polymorph_control && !(Stunned || Unaware);
  6.  
  7.      if (purify) {
  8.          You_feel("purified.");
  9.          u.ulycn = NON_PM; /* cure lycanthropy */
  10.      }
  11.      if (!Unchanging && is_were(youmonst.data)
  12.          && (!controllable_poly || yn("Remain in beast form?") == 'n'))
  13.          rehumanize();
  14.  }
  15.  
  16.  /*were.c*/