Source:NetHack 3.6.1/src/were.c

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

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

Top of file

  1.  /* NetHack 3.6	were.c	$NHDT-Date: 1505214877 2017/09/12 11:14:37 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.21 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /*-Copyright (c) Robert Patrick Rankin, 2011. */
  4.  /* NetHack may be freely redistributed.  See license for details. */

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.

  1.  
  2.  #include "hack.h"
  3.  

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.      /* update innate intrinsics (mainly Drain_resistance) */
  35.      set_uasmon(); /* new_were() doesn't do this */
  36.  }
  37.  

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

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 (!paranoid_query(ParanoidWerechange, qbuf))
  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.          set_ulycn(NON_PM); /* cure lycanthropy */
  10.      }
  11.      if (!Unchanging && is_were(youmonst.data)
  12.          && (!controllable_poly
  13.              || !paranoid_query(ParanoidWerechange, "Remain in beast form?")))
  14.          rehumanize();
  15.      else if (is_were(youmonst.data) && !u.mtimedone)
  16.          u.mtimedone = rn1(200, 200); /* 40% of initial were change */
  17.  }
  18.  

set_ulycn

  1.  /* lycanthropy is being caught or cured, but no shape change is involved */
  2.  void
  3.  set_ulycn(which)
  4.  int which;
  5.  {
  6.      u.ulycn = which;
  7.      /* add or remove lycanthrope's innate intrinsics (Drain_resistance) */
  8.      set_uasmon();
  9.  }
  10.  
  11.  /*were.c*/