Source:NetHack 3.6.0/src/mhitu.c

From NetHackWiki
Jump to: navigation, search

Below is the full text to mhitu.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/mhitu.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	mhitu.c	$NHDT-Date: 1446854230 2015/11/06 23:57:10 $  $NHDT-Branch: master $:$NHDT-Revision: 1.130 $ */
  2.  /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5.  #include "hack.h"
  6.  #include "artifact.h"
  7.  
  8.  STATIC_VAR NEARDATA struct obj *otmp;
  9.  
  10.  STATIC_DCL boolean FDECL(u_slip_free, (struct monst *, struct attack *));
  11.  STATIC_DCL int FDECL(passiveum,
  12.                       (struct permonst *, struct monst *, struct attack *));
  13.  
  14.  STATIC_DCL void FDECL(mayberem, (struct obj *, const char *));
  15.  
  16.  STATIC_DCL boolean FDECL(diseasemu, (struct permonst *));
  17.  STATIC_DCL int FDECL(hitmu, (struct monst *, struct attack *));
  18.  STATIC_DCL int FDECL(gulpmu, (struct monst *, struct attack *));
  19.  STATIC_DCL int FDECL(explmu, (struct monst *, struct attack *, BOOLEAN_P));
  20.  STATIC_DCL void FDECL(missmu, (struct monst *, BOOLEAN_P, struct attack *));
  21.  STATIC_DCL void FDECL(mswings, (struct monst *, struct obj *));
  22.  STATIC_DCL void FDECL(wildmiss, (struct monst *, struct attack *));
  23.  
  24.  STATIC_DCL void FDECL(hitmsg, (struct monst *, struct attack *));
  25.  
  26.  /* See comment in mhitm.c.  If we use this a lot it probably should be */
  27.  /* changed to a parameter to mhitu. */
  28.  static int dieroll;
  29.  

hitmsg

  1.  STATIC_OVL void
  2.  hitmsg(mtmp, mattk)
  3.  register struct monst *mtmp;
  4.  register struct attack *mattk;
  5.  {
  6.      int compat;
  7.  
  8.      /* Note: if opposite gender, "seductively" */
  9.      /* If same gender, "engagingly" for nymph, normal msg for others */
  10.      if ((compat = could_seduce(mtmp, &youmonst, mattk)) && !mtmp->mcan
  11.          && !mtmp->mspec_used) {
  12.          pline("%s %s you %s.", Monnam(mtmp), Blind ? "talks to" : "smiles at",
  13.                compat == 2 ? "engagingly" : "seductively");
  14.      } else
  15.          switch (mattk->aatyp) {
  16.          case AT_BITE:
  17.              pline("%s bites!", Monnam(mtmp));
  18.              break;
  19.          case AT_KICK:
  20.              pline("%s kicks%c", Monnam(mtmp),
  21.                    thick_skinned(youmonst.data) ? '.' : '!');
  22.              break;
  23.          case AT_STNG:
  24.              pline("%s stings!", Monnam(mtmp));
  25.              break;
  26.          case AT_BUTT:
  27.              pline("%s butts!", Monnam(mtmp));
  28.              break;
  29.          case AT_TUCH:
  30.              pline("%s touches you!", Monnam(mtmp));
  31.              break;
  32.          case AT_TENT:
  33.              pline("%s tentacles suck you!", s_suffix(Monnam(mtmp)));
  34.              break;
  35.          case AT_EXPL:
  36.          case AT_BOOM:
  37.              pline("%s explodes!", Monnam(mtmp));
  38.              break;
  39.          default:
  40.              pline("%s hits!", Monnam(mtmp));
  41.          }
  42.  }
  43.  

missmu

  1.  /* monster missed you */
  2.  STATIC_OVL void
  3.  missmu(mtmp, nearmiss, mattk)
  4.  struct monst *mtmp;
  5.  boolean nearmiss;
  6.  struct attack *mattk;
  7.  {
  8.      if (!canspotmon(mtmp))
  9.          map_invisible(mtmp->mx, mtmp->my);
  10.  
  11.      if (could_seduce(mtmp, &youmonst, mattk) && !mtmp->mcan)
  12.          pline("%s pretends to be friendly.", Monnam(mtmp));
  13.      else
  14.          pline("%s %smisses!", Monnam(mtmp),
  15.                (nearmiss && flags.verbose) ? "just " : "");
  16.  
  17.      stop_occupation();
  18.  }
  19.  

mswings

  1.  /* monster swings obj */
  2.  STATIC_OVL void
  3.  mswings(mtmp, otemp)
  4.  struct monst *mtmp;
  5.  struct obj *otemp;
  6.  {
  7.      if (flags.verbose && !Blind && mon_visible(mtmp)) {
  8.          pline("%s %s %s%s %s.", Monnam(mtmp),
  9.                (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings",
  10.                (otemp->quan > 1L) ? "one of " : "", mhis(mtmp), xname(otemp));
  11.      }
  12.  }
  13.  

mpoisons_subj

  1.  /* return how a poison attack was delivered */
  2.  const char *
  3.  mpoisons_subj(mtmp, mattk)
  4.  struct monst *mtmp;
  5.  struct attack *mattk;
  6.  {
  7.      if (mattk->aatyp == AT_WEAP) {
  8.          struct obj *mwep = (mtmp == &youmonst) ? uwep : MON_WEP(mtmp);
  9.          /* "Foo's attack was poisoned." is pretty lame, but at least
  10.             it's better than "sting" when not a stinging attack... */
  11.          return (!mwep || !mwep->opoisoned) ? "attack" : "weapon";
  12.      } else {
  13.          return (mattk->aatyp == AT_TUCH) ? "contact"
  14.                    : (mattk->aatyp == AT_GAZE) ? "gaze"
  15.                         : (mattk->aatyp == AT_BITE) ? "bite" : "sting";
  16.      }
  17.  }
  18.  

u_slow_down

  1.  /* called when your intrinsic speed is taken away */
  2.  void
  3.  u_slow_down()
  4.  {
  5.      HFast = 0L;
  6.      if (!Fast)
  7.          You("slow down.");
  8.      else /* speed boots */
  9.          Your("quickness feels less natural.");
  10.      exercise(A_DEX, FALSE);
  11.  }
  12.  

wildmiss

  1.  /* monster attacked your displaced image */
  2.  STATIC_OVL void
  3.  wildmiss(mtmp, mattk)
  4.  register struct monst *mtmp;
  5.  register struct attack *mattk;
  6.  {
  7.      int compat;
  8.  
  9.      /* no map_invisible() -- no way to tell where _this_ is coming from */
  10.  
  11.      if (!flags.verbose)
  12.          return;
  13.      if (!cansee(mtmp->mx, mtmp->my))
  14.          return;
  15.      /* maybe it's attacking an image around the corner? */
  16.  
  17.      compat = ((mattk->adtyp == AD_SEDU || mattk->adtyp == AD_SSEX)
  18.                && could_seduce(mtmp, &youmonst, (struct attack *) 0));
  19.  
  20.      if (!mtmp->mcansee || (Invis && !perceives(mtmp->data))) {
  21.          const char *swings =
  22.              mattk->aatyp == AT_BITE
  23.                  ? "snaps"
  24.                  : mattk->aatyp == AT_KICK
  25.                        ? "kicks"
  26.                        : (mattk->aatyp == AT_STNG || mattk->aatyp == AT_BUTT
  27.                           || nolimbs(mtmp->data))
  28.                              ? "lunges"
  29.                              : "swings";
  30.  
  31.          if (compat)
  32.              pline("%s tries to touch you and misses!", Monnam(mtmp));
  33.          else
  34.              switch (rn2(3)) {
  35.              case 0:
  36.                  pline("%s %s wildly and misses!", Monnam(mtmp), swings);
  37.                  break;
  38.              case 1:
  39.                  pline("%s attacks a spot beside you.", Monnam(mtmp));
  40.                  break;
  41.              case 2:
  42.                  pline("%s strikes at %s!", Monnam(mtmp),
  43.                        levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water"
  44.                                                                : "thin air");
  45.                  break;
  46.              default:
  47.                  pline("%s %s wildly!", Monnam(mtmp), swings);
  48.                  break;
  49.              }
  50.  
  51.      } else if (Displaced) {
  52.          if (compat)
  53.              pline("%s smiles %s at your %sdisplaced image...", Monnam(mtmp),
  54.                    compat == 2 ? "engagingly" : "seductively",
  55.                    Invis ? "invisible " : "");
  56.          else
  57.              pline("%s strikes at your %sdisplaced image and misses you!",
  58.                    /* Note: if you're both invisible and displaced,
  59.                     * only monsters which see invisible will attack your
  60.                     * displaced image, since the displaced image is also
  61.                     * invisible.
  62.                     */
  63.                    Monnam(mtmp), Invis ? "invisible " : "");
  64.  
  65.      } else if (Underwater) {
  66.          /* monsters may miss especially on water level where
  67.             bubbles shake the player here and there */
  68.          if (compat)
  69.              pline("%s reaches towards your distorted image.", Monnam(mtmp));
  70.          else
  71.              pline("%s is fooled by water reflections and misses!",
  72.                    Monnam(mtmp));
  73.  
  74.      } else
  75.          impossible("%s attacks you without knowing your location?",
  76.                     Monnam(mtmp));
  77.  }
  78.  

expels

  1.  void
  2.  expels(mtmp, mdat, message)
  3.  struct monst *mtmp;
  4.  struct permonst *mdat; /* if mtmp is polymorphed, mdat != mtmp->data */
  5.  boolean message;
  6.  {
  7.      if (message) {
  8.          if (is_animal(mdat))
  9.              You("get regurgitated!");
  10.          else {
  11.              char blast[40];
  12.              register int i;
  13.  
  14.              blast[0] = '\0';
  15.              for (i = 0; i < NATTK; i++)
  16.                  if (mdat->mattk[i].aatyp == AT_ENGL)
  17.                      break;
  18.              if (mdat->mattk[i].aatyp != AT_ENGL)
  19.                  impossible("Swallower has no engulfing attack?");
  20.              else {
  21.                  if (is_whirly(mdat)) {
  22.                      switch (mdat->mattk[i].adtyp) {
  23.                      case AD_ELEC:
  24.                          Strcpy(blast, " in a shower of sparks");
  25.                          break;
  26.                      case AD_COLD:
  27.                          Strcpy(blast, " in a blast of frost");
  28.                          break;
  29.                      }
  30.                  } else
  31.                      Strcpy(blast, " with a squelch");
  32.                  You("get expelled from %s%s!", mon_nam(mtmp), blast);
  33.              }
  34.          }
  35.      }
  36.      unstuck(mtmp); /* ball&chain returned in unstuck() */
  37.      mnexto(mtmp);
  38.      newsym(u.ux, u.uy);
  39.      spoteffects(TRUE);
  40.      /* to cover for a case where mtmp is not in a next square */
  41.      if (um_dist(mtmp->mx, mtmp->my, 1))
  42.          pline("Brrooaa...  You land hard at some distance.");
  43.  }
  44.  

getmattk

  1.  /* select a monster's next attack, possibly substituting for its usual one */
  2.  struct attack *
  3.  getmattk(mptr, indx, prev_result, alt_attk_buf)
  4.  struct permonst *mptr;
  5.  int indx, prev_result[];
  6.  struct attack *alt_attk_buf;
  7.  {
  8.      struct attack *attk = &mptr->mattk[indx];
  9.  
  10.      /* prevent a monster with two consecutive disease or hunger attacks
  11.         from hitting with both of them on the same turn; if the first has
  12.         already hit, switch to a stun attack for the second */
  13.      if (indx > 0 && prev_result[indx - 1] > 0
  14.          && (attk->adtyp == AD_DISE || attk->adtyp == AD_PEST
  15.              || attk->adtyp == AD_FAMN)
  16.          && attk->adtyp == mptr->mattk[indx - 1].adtyp) {
  17.          *alt_attk_buf = *attk;
  18.          attk = alt_attk_buf;
  19.          attk->adtyp = AD_STUN;
  20.      }
  21.      return attk;
  22.  }
  23.  

mattacku

  1.  /*
  2.   * mattacku: monster attacks you
  3.   *      returns 1 if monster dies (e.g. "yellow light"), 0 otherwise
  4.   *      Note: if you're displaced or invisible the monster might attack the
  5.   *              wrong position...
  6.   *      Assumption: it's attacking you or an empty square; if there's another
  7.   *              monster which it attacks by mistake, the caller had better
  8.   *              take care of it...
  9.   */
  10.  int
  11.  mattacku(mtmp)
  12.  register struct monst *mtmp;
  13.  {
  14.      struct attack *mattk, alt_attk;
  15.      int i, j, tmp, sum[NATTK];
  16.      struct permonst *mdat = mtmp->data;
  17.      boolean ranged = (distu(mtmp->mx, mtmp->my) > 3);
  18.      /* Is it near you?  Affects your actions */
  19.      boolean range2 = !monnear(mtmp, mtmp->mux, mtmp->muy);
  20.      /* Does it think it's near you?  Affects its actions */
  21.      boolean foundyou = (mtmp->mux == u.ux && mtmp->muy == u.uy);
  22.      /* Is it attacking you or your image? */
  23.      boolean youseeit = canseemon(mtmp);
  24.      /* Might be attacking your image around the corner, or
  25.       * invisible, or you might be blind....
  26.       */
  27.      boolean skipnonmagc = FALSE;
  28.      /* Are further physical attack attempts useless? */
  29.  
  30.      if (!ranged)
  31.          nomul(0);
  32.      if (mtmp->mhp <= 0 || (Underwater && !is_swimmer(mtmp->data)))
  33.          return 0;
  34.  
  35.      /* If swallowed, can only be affected by u.ustuck */
  36.      if (u.uswallow) {
  37.          if (mtmp != u.ustuck)
  38.              return 0;
  39.          u.ustuck->mux = u.ux;
  40.          u.ustuck->muy = u.uy;
  41.          range2 = 0;
  42.          foundyou = 1;
  43.          if (u.uinvulnerable)
  44.              return 0; /* stomachs can't hurt you! */
  45.  
  46.      } else if (u.usteed) {
  47.          if (mtmp == u.usteed)
  48.              /* Your steed won't attack you */
  49.              return 0;
  50.          /* Orcs like to steal and eat horses and the like */
  51.          if (!rn2(is_orc(mtmp->data) ? 2 : 4)
  52.              && distu(mtmp->mx, mtmp->my) <= 2) {
  53.              /* Attack your steed instead */
  54.              i = mattackm(mtmp, u.usteed);
  55.              if ((i & MM_AGR_DIED))
  56.                  return 1;
  57.              /* make sure steed is still alive and within range */
  58.              if ((i & MM_DEF_DIED) || !u.usteed
  59.                  || distu(mtmp->mx, mtmp->my) > 2)
  60.                  return 0;
  61.              /* Let your steed retaliate */
  62.              return !!(mattackm(u.usteed, mtmp) & MM_DEF_DIED);
  63.          }
  64.      }
  65.  
  66.      if (u.uundetected && !range2 && foundyou && !u.uswallow) {
  67.          if (!canspotmon(mtmp))
  68.              map_invisible(mtmp->mx, mtmp->my);
  69.          u.uundetected = 0;
  70.          if (is_hider(youmonst.data) && u.umonnum != PM_TRAPPER) {
  71.              /* ceiling hider */
  72.              coord cc; /* maybe we need a unexto() function? */
  73.              struct obj *obj;
  74.  
  75.              You("fall from the %s!", ceiling(u.ux, u.uy));
  76.              /* take monster off map now so that its location
  77.                 is eligible for placing hero; we assume that a
  78.                 removed monster remembers its old spot <mx,my> */
  79.              remove_monster(mtmp->mx, mtmp->my);
  80.              if (!enexto(&cc, u.ux, u.uy, youmonst.data)
  81.                  /* a fish won't voluntarily swap positions
  82.                     when it's in water and hero is over land */
  83.                  || (mtmp->data->mlet == S_EEL
  84.                      && is_pool(mtmp->mx, mtmp->my)
  85.                      && !is_pool(u.ux, u.uy))) {
  86.                  /* couldn't find any spot for hero; this used to
  87.                     kill off attacker, but now we just give a "miss"
  88.                     message and keep both mtmp and hero at their
  89.                     original positions; hero has become unconcealed
  90.                     so mtmp's next move will be a regular attack */
  91.                  place_monster(mtmp, mtmp->mx, mtmp->my); /* put back */
  92.                  newsym(u.ux, u.uy); /* u.uundetected was toggled */
  93.                  pline("%s draws back as you drop!", Monnam(mtmp));
  94.                  return 0;
  95.              }
  96.  
  97.              /* put mtmp at hero's spot and move hero to <cc.x,.y> */
  98.              newsym(mtmp->mx, mtmp->my); /* finish removal */
  99.              place_monster(mtmp, u.ux, u.uy);
  100.              if (mtmp->wormno) {
  101.                  worm_move(mtmp);
  102.                  /* tail hasn't grown, so if it now occupies <cc.x,.y>
  103.                     then one of its original spots must be free */
  104.                  if (m_at(cc.x, cc.y))
  105.                      (void) enexto(&cc, u.ux, u.uy, youmonst.data);
  106.              }
  107.              teleds(cc.x, cc.y, TRUE); /* move hero */
  108.              set_apparxy(mtmp);
  109.              newsym(u.ux, u.uy);
  110.  
  111.              if (youmonst.data->mlet != S_PIERCER)
  112.                  return 0; /* lurkers don't attack */
  113.  
  114.              obj = which_armor(mtmp, WORN_HELMET);
  115.              if (obj && is_metallic(obj)) {
  116.                  Your("blow glances off %s %s.", s_suffix(mon_nam(mtmp)),
  117.                       helm_simple_name(obj));
  118.              } else {
  119.                  if (3 + find_mac(mtmp) <= rnd(20)) {
  120.                      pline("%s is hit by a falling piercer (you)!",
  121.                            Monnam(mtmp));
  122.                      if ((mtmp->mhp -= d(3, 6)) < 1)
  123.                          killed(mtmp);
  124.                  } else
  125.                      pline("%s is almost hit by a falling piercer (you)!",
  126.                            Monnam(mtmp));
  127.              }
  128.  
  129.          } else {
  130.              /* surface hider */
  131.              if (!youseeit) {
  132.                  pline("It tries to move where you are hiding.");
  133.              } else {
  134.                  /* Ugly kludge for eggs.  The message is phrased so as
  135.                   * to be directed at the monster, not the player,
  136.                   * which makes "laid by you" wrong.  For the
  137.                   * parallelism to work, we can't rephrase it, so we
  138.                   * zap the "laid by you" momentarily instead.
  139.                   */
  140.                  struct obj *obj = level.objects[u.ux][u.uy];
  141.  
  142.                  if (obj || u.umonnum == PM_TRAPPER
  143.                      || (youmonst.data->mlet == S_EEL
  144.                          && is_pool(u.ux, u.uy))) {
  145.                      int save_spe = 0; /* suppress warning */
  146.  
  147.                      if (obj) {
  148.                          save_spe = obj->spe;
  149.                          if (obj->otyp == EGG)
  150.                              obj->spe = 0;
  151.                      }
  152.                      if (youmonst.data->mlet == S_EEL
  153.                          || u.umonnum == PM_TRAPPER)
  154.                          pline(
  155.                               "Wait, %s!  There's a hidden %s named %s there!",
  156.                                m_monnam(mtmp), youmonst.data->mname, plname);
  157.                      else
  158.                          pline(
  159.                            "Wait, %s!  There's a %s named %s hiding under %s!",
  160.                                m_monnam(mtmp), youmonst.data->mname, plname,
  161.                                doname(level.objects[u.ux][u.uy]));
  162.                      if (obj)
  163.                          obj->spe = save_spe;
  164.                  } else
  165.                      impossible("hiding under nothing?");
  166.              }
  167.              newsym(u.ux, u.uy);
  168.          }
  169.          return 0;
  170.      }
  171.  
  172.      /* hero might be a mimic, concealed via #monster */
  173.      if (youmonst.data->mlet == S_MIMIC && youmonst.m_ap_type && !range2
  174.          && foundyou && !u.uswallow) {
  175.          boolean sticky = sticks(youmonst.data);
  176.  
  177.          if (!canspotmon(mtmp))
  178.              map_invisible(mtmp->mx, mtmp->my);
  179.          if (sticky && !youseeit)
  180.              pline("It gets stuck on you.");
  181.          else
  182.              pline("Wait, %s!  That's a %s named %s!", m_monnam(mtmp),
  183.                    youmonst.data->mname, plname);
  184.          if (sticky)
  185.              u.ustuck = mtmp;
  186.          youmonst.m_ap_type = M_AP_NOTHING;
  187.          youmonst.mappearance = 0;
  188.          newsym(u.ux, u.uy);
  189.          return 0;
  190.      }
  191.  
  192.      /* non-mimic hero might be mimicking an object after eating m corpse */
  193.      if (youmonst.m_ap_type == M_AP_OBJECT && !range2 && foundyou
  194.          && !u.uswallow) {
  195.          if (!canspotmon(mtmp))
  196.              map_invisible(mtmp->mx, mtmp->my);
  197.          if (!youseeit)
  198.              pline("%s %s!", Something, (likes_gold(mtmp->data)
  199.                                          && youmonst.mappearance == GOLD_PIECE)
  200.                                             ? "tries to pick you up"
  201.                                             : "disturbs you");
  202.          else
  203.              pline("Wait, %s!  That %s is really %s named %s!", m_monnam(mtmp),
  204.                    mimic_obj_name(&youmonst), an(mons[u.umonnum].mname),
  205.                    plname);
  206.          if (multi < 0) { /* this should always be the case */
  207.              char buf[BUFSZ];
  208.  
  209.              Sprintf(buf, "You appear to be %s again.",
  210.                      Upolyd ? (const char *) an(youmonst.data->mname)
  211.                             : (const char *) "yourself");
  212.              unmul(buf); /* immediately stop mimicking */
  213.          }
  214.          return 0;
  215.      }
  216.  
  217.      /*  Work out the armor class differential   */
  218.      tmp = AC_VALUE(u.uac) + 10; /* tmp ~= 0 - 20 */
  219.      tmp += mtmp->m_lev;
  220.      if (multi < 0)
  221.          tmp += 4;
  222.      if ((Invis && !perceives(mdat)) || !mtmp->mcansee)
  223.          tmp -= 2;
  224.      if (mtmp->mtrapped)
  225.          tmp -= 2;
  226.      if (tmp <= 0)
  227.          tmp = 1;
  228.  
  229.      /* make eels visible the moment they hit/miss us */
  230.      if (mdat->mlet == S_EEL && mtmp->minvis && cansee(mtmp->mx, mtmp->my)) {
  231.          mtmp->minvis = 0;
  232.          newsym(mtmp->mx, mtmp->my);
  233.      }
  234.  
  235.      /*  Special demon handling code */
  236.      if ((mtmp->cham == NON_PM) && is_demon(mdat) && !range2
  237.          && mtmp->data != &mons[PM_BALROG] && mtmp->data != &mons[PM_SUCCUBUS]
  238.          && mtmp->data != &mons[PM_INCUBUS])
  239.          if (!mtmp->mcan && !rn2(13))
  240.              (void) msummon(mtmp);
  241.  
  242.      /*  Special lycanthrope handling code */
  243.      if ((mtmp->cham == NON_PM) && is_were(mdat) && !range2) {
  244.          if (is_human(mdat)) {
  245.              if (!rn2(5 - (night() * 2)) && !mtmp->mcan)
  246.                  new_were(mtmp);
  247.          } else if (!rn2(30) && !mtmp->mcan)
  248.              new_were(mtmp);
  249.          mdat = mtmp->data;
  250.  
  251.          if (!rn2(10) && !mtmp->mcan) {
  252.              int numseen, numhelp;
  253.              char buf[BUFSZ], genericwere[BUFSZ];
  254.  
  255.              Strcpy(genericwere, "creature");
  256.              numhelp = were_summon(mdat, FALSE, &numseen, genericwere);
  257.              if (youseeit) {
  258.                  pline("%s summons help!", Monnam(mtmp));
  259.                  if (numhelp > 0) {
  260.                      if (numseen == 0)
  261.                          You_feel("hemmed in.");
  262.                  } else
  263.                      pline("But none comes.");
  264.              } else {
  265.                  const char *from_nowhere;
  266.  
  267.                  if (!Deaf) {
  268.                      pline("%s %s!", Something, makeplural(growl_sound(mtmp)));
  269.                      from_nowhere = "";
  270.                  } else
  271.                      from_nowhere = " from nowhere";
  272.                  if (numhelp > 0) {
  273.                      if (numseen < 1)
  274.                          You_feel("hemmed in.");
  275.                      else {
  276.                          if (numseen == 1)
  277.                              Sprintf(buf, "%s appears", an(genericwere));
  278.                          else
  279.                              Sprintf(buf, "%s appear",
  280.                                      makeplural(genericwere));
  281.                          pline("%s%s!", upstart(buf), from_nowhere);
  282.                      }
  283.                  } /* else no help came; but you didn't know it tried */
  284.              }
  285.          }
  286.      }
  287.  
  288.      if (u.uinvulnerable) {
  289.          /* monsters won't attack you */
  290.          if (mtmp == u.ustuck)
  291.              pline("%s loosens its grip slightly.", Monnam(mtmp));
  292.          else if (!range2) {
  293.              if (youseeit || sensemon(mtmp))
  294.                  pline("%s starts to attack you, but pulls back.",
  295.                        Monnam(mtmp));
  296.              else
  297.                  You_feel("%s move nearby.", something);
  298.          }
  299.          return 0;
  300.      }
  301.  
  302.      /* Unlike defensive stuff, don't let them use item _and_ attack. */
  303.      if (find_offensive(mtmp)) {
  304.          int foo = use_offensive(mtmp);
  305.  
  306.          if (foo != 0)
  307.              return (foo == 1);
  308.      }
  309.  
  310.      for (i = 0; i < NATTK; i++) {
  311.          sum[i] = 0;
  312.          mattk = getmattk(mdat, i, sum, &alt_attk);
  313.          if ((u.uswallow && mattk->aatyp != AT_ENGL)
  314.              || (skipnonmagc && mattk->aatyp != AT_MAGC))
  315.              continue;
  316.  
  317.          switch (mattk->aatyp) {
  318.          case AT_CLAW: /* "hand to hand" attacks */
  319.          case AT_KICK:
  320.          case AT_BITE:
  321.          case AT_STNG:
  322.          case AT_TUCH:
  323.          case AT_BUTT:
  324.          case AT_TENT:
  325.              if (!range2 && (!MON_WEP(mtmp) || mtmp->mconf || Conflict
  326.                              || !touch_petrifies(youmonst.data))) {
  327.                  if (foundyou) {
  328.                      if (tmp > (j = rnd(20 + i))) {
  329.                          if (mattk->aatyp != AT_KICK
  330.                              || !thick_skinned(youmonst.data))
  331.                              sum[i] = hitmu(mtmp, mattk);
  332.                      } else
  333.                          missmu(mtmp, (tmp == j), mattk);
  334.                  } else {
  335.                      wildmiss(mtmp, mattk);
  336.                      /* skip any remaining non-spell attacks */
  337.                      skipnonmagc = TRUE;
  338.                  }
  339.              }
  340.              break;
  341.  
  342.          case AT_HUGS: /* automatic if prev two attacks succeed */
  343.              /* Note: if displaced, prev attacks never succeeded */
  344.              if ((!range2 && i >= 2 && sum[i - 1] && sum[i - 2])
  345.                  || mtmp == u.ustuck)
  346.                  sum[i] = hitmu(mtmp, mattk);
  347.              break;
  348.  
  349.          case AT_GAZE: /* can affect you either ranged or not */
  350.              /* Medusa gaze already operated through m_respond in
  351.                 dochug(); don't gaze more than once per round. */
  352.              if (mdat != &mons[PM_MEDUSA])
  353.                  sum[i] = gazemu(mtmp, mattk);
  354.              break;
  355.  
  356.          case AT_EXPL: /* automatic hit if next to, and aimed at you */
  357.              if (!range2)
  358.                  sum[i] = explmu(mtmp, mattk, foundyou);
  359.              break;
  360.  
  361.          case AT_ENGL:
  362.              if (!range2) {
  363.                  if (foundyou) {
  364.                      if (u.uswallow || tmp > (j = rnd(20 + i))) {
  365.                          /* Force swallowing monster to be
  366.                           * displayed even when player is
  367.                           * moving away */
  368.                          flush_screen(1);
  369.                          sum[i] = gulpmu(mtmp, mattk);
  370.                      } else {
  371.                          missmu(mtmp, (tmp == j), mattk);
  372.                      }
  373.                  } else if (is_animal(mtmp->data)) {
  374.                      pline("%s gulps some air!", Monnam(mtmp));
  375.                  } else {
  376.                      if (youseeit)
  377.                          pline("%s lunges forward and recoils!", Monnam(mtmp));
  378.                      else
  379.                          You_hear("a %s nearby.",
  380.                                   is_whirly(mtmp->data) ? "rushing noise"
  381.                                                         : "splat");
  382.                  }
  383.              }
  384.              break;
  385.          case AT_BREA:
  386.              if (range2)
  387.                  sum[i] = breamu(mtmp, mattk);
  388.              /* Note: breamu takes care of displacement */
  389.              break;
  390.          case AT_SPIT:
  391.              if (range2)
  392.                  sum[i] = spitmu(mtmp, mattk);
  393.              /* Note: spitmu takes care of displacement */
  394.              break;
  395.          case AT_WEAP:
  396.              if (range2) {
  397.                  if (!Is_rogue_level(&u.uz))
  398.                      thrwmu(mtmp);
  399.              } else {
  400.                  int hittmp = 0;
  401.  
  402.                  /* Rare but not impossible.  Normally the monster
  403.                   * wields when 2 spaces away, but it can be
  404.                   * teleported or whatever....
  405.                   */
  406.                  if (mtmp->weapon_check == NEED_WEAPON || !MON_WEP(mtmp)) {
  407.                      mtmp->weapon_check = NEED_HTH_WEAPON;
  408.                      /* mon_wield_item resets weapon_check as appropriate */
  409.                      if (mon_wield_item(mtmp) != 0)
  410.                          break;
  411.                  }
  412.                  if (foundyou) {
  413.                      otmp = MON_WEP(mtmp);
  414.                      if (otmp) {
  415.                          hittmp = hitval(otmp, &youmonst);
  416.                          tmp += hittmp;
  417.                          mswings(mtmp, otmp);
  418.                      }
  419.                      if (tmp > (j = dieroll = rnd(20 + i)))
  420.                          sum[i] = hitmu(mtmp, mattk);
  421.                      else
  422.                          missmu(mtmp, (tmp == j), mattk);
  423.                      /* KMH -- Don't accumulate to-hit bonuses */
  424.                      if (otmp)
  425.                          tmp -= hittmp;
  426.                  } else {
  427.                      wildmiss(mtmp, mattk);
  428.                      /* skip any remaining non-spell attacks */
  429.                      skipnonmagc = TRUE;
  430.                  }
  431.              }
  432.              break;
  433.          case AT_MAGC:
  434.              if (range2)
  435.                  sum[i] = buzzmu(mtmp, mattk);
  436.              else
  437.                  sum[i] = castmu(mtmp, mattk, TRUE, foundyou);
  438.              break;
  439.  
  440.          default: /* no attack */
  441.              break;
  442.          }
  443.          if (context.botl)
  444.              bot();
  445.          /* give player a chance of waking up before dying -kaa */
  446.          if (sum[i] == 1) { /* successful attack */
  447.              if (u.usleep && u.usleep < monstermoves && !rn2(10)) {
  448.                  multi = -1;
  449.                  nomovemsg = "The combat suddenly awakens you.";
  450.              }
  451.          }
  452.          if (sum[i] == 2)
  453.              return 1; /* attacker dead */
  454.          if (sum[i] == 3)
  455.              break; /* attacker teleported, no more attacks */
  456.          /* sum[i] == 0: unsuccessful attack */
  457.      }
  458.      return 0;
  459.  }
  460.  

diseasemu

  1.  STATIC_OVL boolean
  2.  diseasemu(mdat)
  3.  struct permonst *mdat;
  4.  {
  5.      if (Sick_resistance) {
  6.          You_feel("a slight illness.");
  7.          return FALSE;
  8.      } else {
  9.          make_sick(Sick ? Sick / 3L + 1L : (long) rn1(ACURR(A_CON), 20),
  10.                    mdat->mname, TRUE, SICK_NONVOMITABLE);
  11.          return TRUE;
  12.      }
  13.  }
  14.  

u_slip_free

  1.  /* check whether slippery clothing protects from hug or wrap attack */
  2.  STATIC_OVL boolean
  3.  u_slip_free(mtmp, mattk)
  4.  struct monst *mtmp;
  5.  struct attack *mattk;
  6.  {
  7.      struct obj *obj = (uarmc ? uarmc : uarm);
  8.  
  9.      if (!obj)
  10.          obj = uarmu;
  11.      if (mattk->adtyp == AD_DRIN)
  12.          obj = uarmh;
  13.  
  14.      /* if your cloak/armor is greased, monster slips off; this
  15.         protection might fail (33% chance) when the armor is cursed */
  16.      if (obj && (obj->greased || obj->otyp == OILSKIN_CLOAK)
  17.          && (!obj->cursed || rn2(3))) {
  18.          pline("%s %s your %s %s!", Monnam(mtmp),
  19.                (mattk->adtyp == AD_WRAP) ? "slips off of"
  20.                                          : "grabs you, but cannot hold onto",
  21.                obj->greased ? "greased" : "slippery",
  22.                /* avoid "slippery slippery cloak"
  23.                   for undiscovered oilskin cloak */
  24.                (obj->greased || objects[obj->otyp].oc_name_known)
  25.                    ? xname(obj)
  26.                    : cloak_simple_name(obj));
  27.  
  28.          if (obj->greased && !rn2(2)) {
  29.              pline_The("grease wears off.");
  30.              obj->greased = 0;
  31.              update_inventory();
  32.          }
  33.          return TRUE;
  34.      }
  35.      return FALSE;
  36.  }
  37.  

magic_negation

  1.  /* armor that sufficiently covers the body might be able to block magic */
  2.  int
  3.  magic_negation(mon)
  4.  struct monst *mon;
  5.  {
  6.      struct obj *o;
  7.      long wearmask;
  8.      int armpro, mc = 0;
  9.      boolean is_you = (mon == &youmonst),
  10.              gotprot = is_you ? (EProtection != 0L)
  11.                               /* high priests have innate protection */
  12.                               : (mon->data == &mons[PM_HIGH_PRIEST]);
  13.  
  14.      for (o = is_you ? invent : mon->minvent; o; o = o->nobj) {
  15.          /* a_can field is only applicable for armor (which must be worn) */
  16.          if ((o->owornmask & W_ARMOR) != 0L) {
  17.              armpro = objects[o->otyp].a_can;
  18.              if (armpro > mc)
  19.                  mc = armpro;
  20.          }
  21.          /* if we've already confirmed Protection, skip additional checks */
  22.          if (is_you || gotprot)
  23.              continue;
  24.  
  25.          /* omit W_SWAPWEP+W_QUIVER; W_ART+W_ARTI handled by protects() */
  26.          wearmask = W_ARMOR | W_ACCESSORY;
  27.          if (o->oclass == WEAPON_CLASS || is_weptool(o))
  28.              wearmask |= W_WEP;
  29.          if (protects(o, ((o->owornmask & wearmask) != 0L) ? TRUE : FALSE))
  30.              gotprot = TRUE;
  31.      }
  32.  
  33.      if (gotprot) {
  34.          /* extrinsic Protection increases mc by 1 */
  35.          if (mc < 3)
  36.              mc += 1;
  37.      } else if (mc < 1) {
  38.          /* intrinsic Protection is weaker (play balance; obtaining divine
  39.             protection is too easy); it confers minimum mc 1 instead of 0 */
  40.          if ((is_you && ((HProtection && u.ublessed) || u.uspellprot))
  41.              /* aligned priests and angels have innate intrinsic Protection */
  42.              || (mon->data == &mons[PM_ALIGNED_PRIEST] || is_minion(mon->data)))
  43.              mc = 1;
  44.      }
  45.      return mc;
  46.  }
  47.  

hitmu

  1.  /*
  2.   * hitmu: monster hits you
  3.   *        returns 2 if monster dies (e.g. "yellow light"), 1 otherwise
  4.   *        3 if the monster lives but teleported/paralyzed, so it can't keep
  5.   *             attacking you
  6.   */
  7.  STATIC_OVL int
  8.  hitmu(mtmp, mattk)
  9.  register struct monst *mtmp;
  10.  register struct attack *mattk;
  11.  {
  12.      register struct permonst *mdat = mtmp->data;
  13.      register int uncancelled, ptmp;
  14.      int dmg, armpro, permdmg;
  15.      char buf[BUFSZ];
  16.      struct permonst *olduasmon = youmonst.data;
  17.      int res;
  18.  
  19.      if (!canspotmon(mtmp))
  20.          map_invisible(mtmp->mx, mtmp->my);
  21.  
  22.      /*  If the monster is undetected & hits you, you should know where
  23.       *  the attack came from.
  24.       */
  25.      if (mtmp->mundetected && (hides_under(mdat) || mdat->mlet == S_EEL)) {
  26.          mtmp->mundetected = 0;
  27.          if (!(Blind ? Blind_telepat : Unblind_telepat)) {
  28.              struct obj *obj;
  29.              const char *what;
  30.  
  31.              if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0) {
  32.                  if (Blind && !obj->dknown)
  33.                      what = something;
  34.                  else if (is_pool(mtmp->mx, mtmp->my) && !Underwater)
  35.                      what = "the water";
  36.                  else
  37.                      what = doname(obj);
  38.  
  39.                  pline("%s was hidden under %s!", Amonnam(mtmp), what);
  40.              }
  41.              newsym(mtmp->mx, mtmp->my);
  42.          }
  43.      }
  44.  
  45.      /*  First determine the base damage done */
  46.      dmg = d((int) mattk->damn, (int) mattk->damd);
  47.      if ((is_undead(mdat) || is_vampshifter(mtmp)) && midnight())
  48.          dmg += d((int) mattk->damn, (int) mattk->damd); /* extra damage */
  49.  
  50.      /*  Next a cancellation factor.
  51.       *  Use uncancelled when cancellation factor takes into account certain
  52.       *  armor's special magic protection.  Otherwise just use !mtmp->mcan.
  53.       */
  54.      armpro = magic_negation(&youmonst);
  55.      uncancelled = !mtmp->mcan && (rn2(10) >= 3 * armpro);
  56.  
  57.      permdmg = 0;
  58.      /*  Now, adjust damages via resistances or specific attacks */
  59.      switch (mattk->adtyp) {
  60.      case AD_PHYS:
  61.          if (mattk->aatyp == AT_HUGS && !sticks(youmonst.data)) {
  62.              if (!u.ustuck && rn2(2)) {
  63.                  if (u_slip_free(mtmp, mattk)) {
  64.                      dmg = 0;
  65.                  } else {
  66.                      u.ustuck = mtmp;
  67.                      pline("%s grabs you!", Monnam(mtmp));
  68.                  }
  69.              } else if (u.ustuck == mtmp) {
  70.                  exercise(A_STR, FALSE);
  71.                  You("are being %s.", (mtmp->data == &mons[PM_ROPE_GOLEM])
  72.                                           ? "choked"
  73.                                           : "crushed");
  74.              }
  75.          } else { /* hand to hand weapon */
  76.              if (mattk->aatyp == AT_WEAP && otmp) {
  77.                  int tmp;
  78.  
  79.                  if (otmp->otyp == CORPSE
  80.                      && touch_petrifies(&mons[otmp->corpsenm])) {
  81.                      dmg = 1;
  82.                      pline("%s hits you with the %s corpse.", Monnam(mtmp),
  83.                            mons[otmp->corpsenm].mname);
  84.                      if (!Stoned)
  85.                          goto do_stone;
  86.                  }
  87.                  dmg += dmgval(otmp, &youmonst);
  88.                  if (dmg <= 0)
  89.                      dmg = 1;
  90.                  if (!(otmp->oartifact
  91.                        && artifact_hit(mtmp, &youmonst, otmp, &dmg, dieroll)))
  92.                      hitmsg(mtmp, mattk);
  93.                  if (!dmg)
  94.                      break;
  95.                  if (objects[otmp->otyp].oc_material == SILVER
  96.                      && Hate_silver) {
  97.                      pline_The("silver sears your flesh!");
  98.                      exercise(A_CON, FALSE);
  99.                  }
  100.                  /* this redundancy necessary because you have
  101.                     to take the damage _before_ being cloned;
  102.                     need to have at least 2 hp left to split */
  103.                  tmp = dmg;
  104.                  if (u.uac < 0)
  105.                      tmp -= rnd(-u.uac);
  106.                  if (tmp < 1)
  107.                      tmp = 1;
  108.                  if (u.mh - tmp > 1 && objects[otmp->otyp].oc_material == IRON
  109.                      && (u.umonnum == PM_BLACK_PUDDING
  110.                          || u.umonnum == PM_BROWN_PUDDING)) {
  111.                      if (tmp > 1)
  112.                          exercise(A_STR, FALSE);
  113.                      /* inflict damage now; we know it can't be fatal */
  114.                      u.mh -= tmp;
  115.                      context.botl = 1;
  116.                      dmg = 0; /* don't inflict more damage below */
  117.                      if (cloneu())
  118.                          You("divide as %s hits you!", mon_nam(mtmp));
  119.                  }
  120.                  rustm(&youmonst, otmp);
  121.              } else if (mattk->aatyp != AT_TUCH || dmg != 0
  122.                         || mtmp != u.ustuck)
  123.                  hitmsg(mtmp, mattk);
  124.          }
  125.          break;
  126.      case AD_DISE:
  127.          hitmsg(mtmp, mattk);
  128.          if (!diseasemu(mdat))
  129.              dmg = 0;
  130.          break;
  131.      case AD_FIRE:
  132.          hitmsg(mtmp, mattk);
  133.          if (uncancelled) {
  134.              pline("You're %s!", on_fire(youmonst.data, mattk));
  135.              if (youmonst.data == &mons[PM_STRAW_GOLEM]
  136.                  || youmonst.data == &mons[PM_PAPER_GOLEM]) {
  137.                  You("roast!");
  138.                  /* KMH -- this is okay with unchanging */
  139.                  rehumanize();
  140.                  break;
  141.              } else if (Fire_resistance) {
  142.                  pline_The("fire doesn't feel hot!");
  143.                  dmg = 0;
  144.              }
  145.              if ((int) mtmp->m_lev > rn2(20))
  146.                  destroy_item(SCROLL_CLASS, AD_FIRE);
  147.              if ((int) mtmp->m_lev > rn2(20))
  148.                  destroy_item(POTION_CLASS, AD_FIRE);
  149.              if ((int) mtmp->m_lev > rn2(25))
  150.                  destroy_item(SPBOOK_CLASS, AD_FIRE);
  151.              burn_away_slime();
  152.          } else
  153.              dmg = 0;
  154.          break;
  155.      case AD_COLD:
  156.          hitmsg(mtmp, mattk);
  157.          if (uncancelled) {
  158.              pline("You're covered in frost!");
  159.              if (Cold_resistance) {
  160.                  pline_The("frost doesn't seem cold!");
  161.                  dmg = 0;
  162.              }
  163.              if ((int) mtmp->m_lev > rn2(20))
  164.                  destroy_item(POTION_CLASS, AD_COLD);
  165.          } else
  166.              dmg = 0;
  167.          break;
  168.      case AD_ELEC:
  169.          hitmsg(mtmp, mattk);
  170.          if (uncancelled) {
  171.              You("get zapped!");
  172.              if (Shock_resistance) {
  173.                  pline_The("zap doesn't shock you!");
  174.                  dmg = 0;
  175.              }
  176.              if ((int) mtmp->m_lev > rn2(20))
  177.                  destroy_item(WAND_CLASS, AD_ELEC);
  178.              if ((int) mtmp->m_lev > rn2(20))
  179.                  destroy_item(RING_CLASS, AD_ELEC);
  180.          } else
  181.              dmg = 0;
  182.          break;
  183.      case AD_SLEE:
  184.          hitmsg(mtmp, mattk);
  185.          if (uncancelled && multi >= 0 && !rn2(5)) {
  186.              if (Sleep_resistance)
  187.                  break;
  188.              fall_asleep(-rnd(10), TRUE);
  189.              if (Blind)
  190.                  You("are put to sleep!");
  191.              else
  192.                  You("are put to sleep by %s!", mon_nam(mtmp));
  193.          }
  194.          break;
  195.      case AD_BLND:
  196.          if (can_blnd(mtmp, &youmonst, mattk->aatyp, (struct obj *) 0)) {
  197.              if (!Blind)
  198.                  pline("%s blinds you!", Monnam(mtmp));
  199.              make_blinded(Blinded + (long) dmg, FALSE);
  200.              if (!Blind)
  201.                  Your1(vision_clears);
  202.          }
  203.          dmg = 0;
  204.          break;
  205.      case AD_DRST:
  206.          ptmp = A_STR;
  207.          goto dopois;
  208.      case AD_DRDX:
  209.          ptmp = A_DEX;
  210.          goto dopois;
  211.      case AD_DRCO:
  212.          ptmp = A_CON;
  213.      dopois:
  214.          hitmsg(mtmp, mattk);
  215.          if (uncancelled && !rn2(8)) {
  216.              Sprintf(buf, "%s %s", s_suffix(Monnam(mtmp)),
  217.                      mpoisons_subj(mtmp, mattk));
  218.              poisoned(buf, ptmp, mdat->mname, 30, FALSE);
  219.          }
  220.          break;
  221.      case AD_DRIN:
  222.          hitmsg(mtmp, mattk);
  223.          if (defends(AD_DRIN, uwep) || !has_head(youmonst.data)) {
  224.              You("don't seem harmed.");
  225.              /* Not clear what to do for green slimes */
  226.              break;
  227.          }
  228.          if (u_slip_free(mtmp, mattk))
  229.              break;
  230.  
  231.          if (uarmh && rn2(8)) {
  232.              /* not body_part(HEAD) */
  233.              Your("%s blocks the attack to your head.",
  234.                   helm_simple_name(uarmh));
  235.              break;
  236.          }
  237.          if (Half_physical_damage)
  238.              dmg = (dmg + 1) / 2;
  239.          mdamageu(mtmp, dmg);
  240.  
  241.          if (!uarmh || uarmh->otyp != DUNCE_CAP) {
  242.              /* eat_brains() will miss if target is mindless (won't
  243.                 happen here; hero is considered to retain his mind
  244.                 regardless of current shape) or is noncorporeal
  245.                 (can't happen here; no one can poly into a ghost
  246.                 or shade) so this check for missing is academic */
  247.              if (eat_brains(mtmp, &youmonst, TRUE, (int *) 0) == MM_MISS)
  248.                  break;
  249.          }
  250.          /* adjattrib gives dunce cap message when appropriate */
  251.          (void) adjattrib(A_INT, -rnd(2), FALSE);
  252.          forget_levels(25);  /* lose memory of 25% of levels */
  253.          forget_objects(25); /* lose memory of 25% of objects */
  254.          break;
  255.      case AD_PLYS:
  256.          hitmsg(mtmp, mattk);
  257.          if (uncancelled && multi >= 0 && !rn2(3)) {
  258.              if (Free_action) {
  259.                  You("momentarily stiffen.");
  260.              } else {
  261.                  if (Blind)
  262.                      You("are frozen!");
  263.                  else
  264.                      You("are frozen by %s!", mon_nam(mtmp));
  265.                  nomovemsg = You_can_move_again;
  266.                  nomul(-rnd(10));
  267.                  multi_reason = "paralyzed by a monster";
  268.                  exercise(A_DEX, FALSE);
  269.              }
  270.          }
  271.          break;
  272.      case AD_DRLI:
  273.          hitmsg(mtmp, mattk);
  274.          if (uncancelled && !rn2(3) && !Drain_resistance) {
  275.              losexp("life drainage");
  276.          }
  277.          break;
  278.      case AD_LEGS: {
  279.          register long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE;
  280.          const char *sidestr = (side == RIGHT_SIDE) ? "right" : "left";
  281.  
  282.          /* This case is too obvious to ignore, but Nethack is not in
  283.           * general very good at considering height--most short monsters
  284.           * still _can_ attack you when you're flying or mounted.
  285.           * [FIXME: why can't a flying attacker overcome this?]
  286.           */
  287.          if (u.usteed || Levitation || Flying) {
  288.              pline("%s tries to reach your %s %s!", Monnam(mtmp), sidestr,
  289.                    body_part(LEG));
  290.              dmg = 0;
  291.          } else if (mtmp->mcan) {
  292.              pline("%s nuzzles against your %s %s!", Monnam(mtmp), sidestr,
  293.                    body_part(LEG));
  294.              dmg = 0;
  295.          } else {
  296.              if (uarmf) {
  297.                  if (rn2(2) && (uarmf->otyp == LOW_BOOTS
  298.                                 || uarmf->otyp == IRON_SHOES))
  299.                      pline("%s pricks the exposed part of your %s %s!",
  300.                            Monnam(mtmp), sidestr, body_part(LEG));
  301.                  else if (!rn2(5))
  302.                      pline("%s pricks through your %s boot!", Monnam(mtmp),
  303.                            sidestr);
  304.                  else {
  305.                      pline("%s scratches your %s boot!", Monnam(mtmp),
  306.                            sidestr);
  307.                      dmg = 0;
  308.                      break;
  309.                  }
  310.              } else
  311.                  pline("%s pricks your %s %s!", Monnam(mtmp), sidestr,
  312.                        body_part(LEG));
  313.              set_wounded_legs(side, rnd(60 - ACURR(A_DEX)));
  314.              exercise(A_STR, FALSE);
  315.              exercise(A_DEX, FALSE);
  316.          }
  317.          break;
  318.      }
  319.      case AD_STON: /* cockatrice */
  320.          hitmsg(mtmp, mattk);
  321.          if (!rn2(3)) {
  322.              if (mtmp->mcan) {
  323.                  if (!Deaf)
  324.                      You_hear("a cough from %s!", mon_nam(mtmp));
  325.              } else {
  326.                  if (!Deaf)
  327.                      You_hear("%s hissing!", s_suffix(mon_nam(mtmp)));
  328.                  if (!rn2(10)
  329.                      || (flags.moonphase == NEW_MOON && !have_lizard())) {
  330.                  do_stone:
  331.                      if (!Stoned && !Stone_resistance
  332.                          && !(poly_when_stoned(youmonst.data)
  333.                               && polymon(PM_STONE_GOLEM))) {
  334.                          int kformat = KILLED_BY_AN;
  335.                          const char *kname = mtmp->data->mname;
  336.  
  337.                          if (mtmp->data->geno & G_UNIQ) {
  338.                              if (!type_is_pname(mtmp->data))
  339.                                  kname = the(kname);
  340.                              kformat = KILLED_BY;
  341.                          }
  342.                          make_stoned(5L, (char *) 0, kformat, kname);
  343.                          return 1;
  344.                          /* done_in_by(mtmp, STONING); */
  345.                      }
  346.                  }
  347.              }
  348.          }
  349.          break;
  350.      case AD_STCK:
  351.          hitmsg(mtmp, mattk);
  352.          if (uncancelled && !u.ustuck && !sticks(youmonst.data))
  353.              u.ustuck = mtmp;
  354.          break;
  355.      case AD_WRAP:
  356.          if ((!mtmp->mcan || u.ustuck == mtmp) && !sticks(youmonst.data)) {
  357.              if (!u.ustuck && !rn2(10)) {
  358.                  if (u_slip_free(mtmp, mattk)) {
  359.                      dmg = 0;
  360.                  } else {
  361.                      pline("%s swings itself around you!", Monnam(mtmp));
  362.                      u.ustuck = mtmp;
  363.                  }
  364.              } else if (u.ustuck == mtmp) {
  365.                  if (is_pool(mtmp->mx, mtmp->my) && !Swimming && !Amphibious) {
  366.                      boolean moat = (levl[mtmp->mx][mtmp->my].typ != POOL)
  367.                                     && (levl[mtmp->mx][mtmp->my].typ != WATER)
  368.                                     && !Is_medusa_level(&u.uz)
  369.                                     && !Is_waterlevel(&u.uz);
  370.  
  371.                      pline("%s drowns you...", Monnam(mtmp));
  372.                      killer.format = KILLED_BY_AN;
  373.                      Sprintf(killer.name, "%s by %s",
  374.                              moat ? "moat" : "pool of water",
  375.                              an(mtmp->data->mname));
  376.                      done(DROWNING);
  377.                  } else if (mattk->aatyp == AT_HUGS)
  378.                      You("are being crushed.");
  379.              } else {
  380.                  dmg = 0;
  381.                  if (flags.verbose)
  382.                      pline("%s brushes against your %s.", Monnam(mtmp),
  383.                            body_part(LEG));
  384.              }
  385.          } else
  386.              dmg = 0;
  387.          break;
  388.      case AD_WERE:
  389.          hitmsg(mtmp, mattk);
  390.          if (uncancelled && !rn2(4) && u.ulycn == NON_PM
  391.              && !Protection_from_shape_changers && !defends(AD_WERE, uwep)) {
  392.              You_feel("feverish.");
  393.              exercise(A_CON, FALSE);
  394.              u.ulycn = monsndx(mdat);
  395.              retouch_equipment(2);
  396.          }
  397.          break;
  398.      case AD_SGLD:
  399.          hitmsg(mtmp, mattk);
  400.          if (youmonst.data->mlet == mdat->mlet)
  401.              break;
  402.          if (!mtmp->mcan)
  403.              stealgold(mtmp);
  404.          break;
  405.  
  406.      case AD_SSEX:
  407.          if (SYSOPT_SEDUCE) {
  408.              if (could_seduce(mtmp, &youmonst, mattk) == 1 && !mtmp->mcan)
  409.                  if (doseduce(mtmp))
  410.                      return 3;
  411.              break;
  412.          }
  413.      /* else FALLTHRU */
  414.      case AD_SITM: /* for now these are the same */
  415.      case AD_SEDU:
  416.          if (is_animal(mtmp->data)) {
  417.              hitmsg(mtmp, mattk);
  418.              if (mtmp->mcan)
  419.                  break;
  420.              /* Continue below */
  421.          } else if (dmgtype(youmonst.data, AD_SEDU)
  422.                     || (SYSOPT_SEDUCE && dmgtype(youmonst.data, AD_SSEX))) {
  423.              pline("%s %s.", Monnam(mtmp),
  424.                    mtmp->minvent
  425.                        ? "brags about the goods some dungeon explorer provided"
  426.                    : "makes some remarks about how difficult theft is lately");
  427.              if (!tele_restrict(mtmp))
  428.                  (void) rloc(mtmp, TRUE);
  429.              return 3;
  430.          } else if (mtmp->mcan) {
  431.              if (!Blind) {
  432.                  pline("%s tries to %s you, but you seem %s.",
  433.                        Adjmonnam(mtmp, "plain"),
  434.                        flags.female ? "charm" : "seduce",
  435.                        flags.female ? "unaffected" : "uninterested");
  436.              }
  437.              if (rn2(3)) {
  438.                  if (!tele_restrict(mtmp))
  439.                      (void) rloc(mtmp, TRUE);
  440.                  return 3;
  441.              }
  442.              break;
  443.          }
  444.          buf[0] = '\0';
  445.          switch (steal(mtmp, buf)) {
  446.          case -1:
  447.              return 2;
  448.          case 0:
  449.              break;
  450.          default:
  451.              if (!is_animal(mtmp->data) && !tele_restrict(mtmp))
  452.                  (void) rloc(mtmp, TRUE);
  453.              if (is_animal(mtmp->data) && *buf) {
  454.                  if (canseemon(mtmp))
  455.                      pline("%s tries to %s away with %s.", Monnam(mtmp),
  456.                            locomotion(mtmp->data, "run"), buf);
  457.              }
  458.              monflee(mtmp, 0, FALSE, FALSE);
  459.              return 3;
  460.          }
  461.          break;
  462.  
  463.      case AD_SAMU:
  464.          hitmsg(mtmp, mattk);
  465.          /* when the Wiz hits, 1/20 steals the amulet */
  466.          if (u.uhave.amulet || u.uhave.bell || u.uhave.book || u.uhave.menorah
  467.              || u.uhave.questart) /* carrying the Quest Artifact */
  468.              if (!rn2(20))
  469.                  stealamulet(mtmp);
  470.          break;
  471.  
  472.      case AD_TLPT:
  473.          hitmsg(mtmp, mattk);
  474.          if (uncancelled) {
  475.              if (flags.verbose)
  476.                  Your("position suddenly seems very uncertain!");
  477.              tele();
  478.          }
  479.          break;
  480.      case AD_RUST:
  481.          hitmsg(mtmp, mattk);
  482.          if (mtmp->mcan)
  483.              break;
  484.          if (u.umonnum == PM_IRON_GOLEM) {
  485.              You("rust!");
  486.              /* KMH -- this is okay with unchanging */
  487.              rehumanize();
  488.              break;
  489.          }
  490.          erode_armor(&youmonst, ERODE_RUST);
  491.          break;
  492.      case AD_CORR:
  493.          hitmsg(mtmp, mattk);
  494.          if (mtmp->mcan)
  495.              break;
  496.          erode_armor(&youmonst, ERODE_CORRODE);
  497.          break;
  498.      case AD_DCAY:
  499.          hitmsg(mtmp, mattk);
  500.          if (mtmp->mcan)
  501.              break;
  502.          if (u.umonnum == PM_WOOD_GOLEM || u.umonnum == PM_LEATHER_GOLEM) {
  503.              You("rot!");
  504.              /* KMH -- this is okay with unchanging */
  505.              rehumanize();
  506.              break;
  507.          }
  508.          erode_armor(&youmonst, ERODE_ROT);
  509.          break;
  510.      case AD_HEAL:
  511.          /* a cancelled nurse is just an ordinary monster,
  512.           * nurses don't heal those that cause petrification */
  513.          if (mtmp->mcan || (Upolyd && touch_petrifies(youmonst.data))) {
  514.              hitmsg(mtmp, mattk);
  515.              break;
  516.          }
  517.          if (!uwep && !uarmu && !uarm && !uarmh && !uarms && !uarmg && !uarmc
  518.              && !uarmf) {
  519.              boolean goaway = FALSE;
  520.              pline("%s hits!  (I hope you don't mind.)", Monnam(mtmp));
  521.              if (Upolyd) {
  522.                  u.mh += rnd(7);
  523.                  if (!rn2(7)) {
  524.                      /* no upper limit necessary; effect is temporary */
  525.                      u.mhmax++;
  526.                      if (!rn2(13))
  527.                          goaway = TRUE;
  528.                  }
  529.                  if (u.mh > u.mhmax)
  530.                      u.mh = u.mhmax;
  531.              } else {
  532.                  u.uhp += rnd(7);
  533.                  if (!rn2(7)) {
  534.                      /* hard upper limit via nurse care: 25 * ulevel */
  535.                      if (u.uhpmax < 5 * u.ulevel + d(2 * u.ulevel, 10))
  536.                          u.uhpmax++;
  537.                      if (!rn2(13))
  538.                          goaway = TRUE;
  539.                  }
  540.                  if (u.uhp > u.uhpmax)
  541.                      u.uhp = u.uhpmax;
  542.              }
  543.              if (!rn2(3))
  544.                  exercise(A_STR, TRUE);
  545.              if (!rn2(3))
  546.                  exercise(A_CON, TRUE);
  547.              if (Sick)
  548.                  make_sick(0L, (char *) 0, FALSE, SICK_ALL);
  549.              context.botl = 1;
  550.              if (goaway) {
  551.                  mongone(mtmp);
  552.                  return 2;
  553.              } else if (!rn2(33)) {
  554.                  if (!tele_restrict(mtmp))
  555.                      (void) rloc(mtmp, TRUE);
  556.                  monflee(mtmp, d(3, 6), TRUE, FALSE);
  557.                  return 3;
  558.              }
  559.              dmg = 0;
  560.          } else {
  561.              if (Role_if(PM_HEALER)) {
  562.                  if (!Deaf && !(moves % 5))
  563.                      verbalize("Doc, I can't help you unless you cooperate.");
  564.                  dmg = 0;
  565.              } else
  566.                  hitmsg(mtmp, mattk);
  567.          }
  568.          break;
  569.      case AD_CURS:
  570.          hitmsg(mtmp, mattk);
  571.          if (!night() && mdat == &mons[PM_GREMLIN])
  572.              break;
  573.          if (!mtmp->mcan && !rn2(10)) {
  574.              if (!Deaf) {
  575.                  if (Blind)
  576.                      You_hear("laughter.");
  577.                  else
  578.                      pline("%s chuckles.", Monnam(mtmp));
  579.              }
  580.              if (u.umonnum == PM_CLAY_GOLEM) {
  581.                  pline("Some writing vanishes from your head!");
  582.                  /* KMH -- this is okay with unchanging */
  583.                  rehumanize();
  584.                  break;
  585.              }
  586.              attrcurse();
  587.          }
  588.          break;
  589.      case AD_STUN:
  590.          hitmsg(mtmp, mattk);
  591.          if (!mtmp->mcan && !rn2(4)) {
  592.              make_stunned((HStun & TIMEOUT) + (long) dmg, TRUE);
  593.              dmg /= 2;
  594.          }
  595.          break;
  596.      case AD_ACID:
  597.          hitmsg(mtmp, mattk);
  598.          if (!mtmp->mcan && !rn2(3))
  599.              if (Acid_resistance) {
  600.                  pline("You're covered in acid, but it seems harmless.");
  601.                  dmg = 0;
  602.              } else {
  603.                  pline("You're covered in acid!  It burns!");
  604.                  exercise(A_STR, FALSE);
  605.              }
  606.          else
  607.              dmg = 0;
  608.          break;
  609.      case AD_SLOW:
  610.          hitmsg(mtmp, mattk);
  611.          if (uncancelled && HFast && !defends(AD_SLOW, uwep) && !rn2(4))
  612.              u_slow_down();
  613.          break;
  614.      case AD_DREN:
  615.          hitmsg(mtmp, mattk);
  616.          if (uncancelled && !rn2(4))
  617.              drain_en(dmg);
  618.          dmg = 0;
  619.          break;
  620.      case AD_CONF:
  621.          hitmsg(mtmp, mattk);
  622.          if (!mtmp->mcan && !rn2(4) && !mtmp->mspec_used) {
  623.              mtmp->mspec_used = mtmp->mspec_used + (dmg + rn2(6));
  624.              if (Confusion)
  625.                  You("are getting even more confused.");
  626.              else
  627.                  You("are getting confused.");
  628.              make_confused(HConfusion + dmg, FALSE);
  629.          }
  630.          dmg = 0;
  631.          break;
  632.      case AD_DETH:
  633.          pline("%s reaches out with its deadly touch.", Monnam(mtmp));
  634.          if (is_undead(youmonst.data)) {
  635.              /* Still does normal damage */
  636.              pline("Was that the touch of death?");
  637.              break;
  638.          }
  639.          switch (rn2(20)) {
  640.          case 19:
  641.          case 18:
  642.          case 17:
  643.              if (!Antimagic) {
  644.                  killer.format = KILLED_BY_AN;
  645.                  Strcpy(killer.name, "touch of death");
  646.                  done(DIED);
  647.                  dmg = 0;
  648.                  break;
  649.              }    /* else FALLTHRU */
  650.          default: /* case 16: ... case 5: */
  651.              You_feel("your life force draining away...");
  652.              permdmg = 1; /* actual damage done below */
  653.              break;
  654.          case 4:
  655.          case 3:
  656.          case 2:
  657.          case 1:
  658.          case 0:
  659.              if (Antimagic)
  660.                  shieldeff(u.ux, u.uy);
  661.              pline("Lucky for you, it didn't work!");
  662.              dmg = 0;
  663.              break;
  664.          }
  665.          break;
  666.      case AD_PEST:
  667.          pline("%s reaches out, and you feel fever and chills.", Monnam(mtmp));
  668.          (void) diseasemu(mdat); /* plus the normal damage */
  669.          break;
  670.      case AD_FAMN:
  671.          pline("%s reaches out, and your body shrivels.", Monnam(mtmp));
  672.          exercise(A_CON, FALSE);
  673.          if (!is_fainted())
  674.              morehungry(rn1(40, 40));
  675.          /* plus the normal damage */
  676.          break;
  677.      case AD_SLIM:
  678.          hitmsg(mtmp, mattk);
  679.          if (!uncancelled)
  680.              break;
  681.          if (flaming(youmonst.data)) {
  682.              pline_The("slime burns away!");
  683.              dmg = 0;
  684.          } else if (Unchanging || noncorporeal(youmonst.data)
  685.                     || youmonst.data == &mons[PM_GREEN_SLIME]) {
  686.              You("are unaffected.");
  687.              dmg = 0;
  688.          } else if (!Slimed) {
  689.              You("don't feel very well.");
  690.              make_slimed(10L, (char *) 0);
  691.              delayed_killer(SLIMED, KILLED_BY_AN, mtmp->data->mname);
  692.          } else
  693.              pline("Yuck!");
  694.          break;
  695.      case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
  696.          hitmsg(mtmp, mattk);
  697.          /* uncancelled is sufficient enough; please
  698.             don't make this attack less frequent */
  699.          if (uncancelled) {
  700.              struct obj *obj = some_armor(&youmonst);
  701.  
  702.              if (drain_item(obj)) {
  703.                  pline("%s less effective.", Yobjnam2(obj, "seem"));
  704.              }
  705.          }
  706.          break;
  707.      default:
  708.          dmg = 0;
  709.          break;
  710.      }
  711.      if (u.uhp < 1)
  712.          done_in_by(mtmp, DIED);
  713.  
  714.      /*  Negative armor class reduces damage done instead of fully protecting
  715.       *  against hits.
  716.       */
  717.      if (dmg && u.uac < 0) {
  718.          dmg -= rnd(-u.uac);
  719.          if (dmg < 1)
  720.              dmg = 1;
  721.      }
  722.  
  723.      if (dmg) {
  724.          if (Half_physical_damage
  725.              /* Mitre of Holiness */
  726.              || (Role_if(PM_PRIEST) && uarmh && is_quest_artifact(uarmh)
  727.                  && (is_undead(mtmp->data) || is_demon(mtmp->data)
  728.                      || is_vampshifter(mtmp))))
  729.              dmg = (dmg + 1) / 2;
  730.  
  731.          if (permdmg) { /* Death's life force drain */
  732.              int lowerlimit, *hpmax_p;
  733.              /*
  734.               * Apply some of the damage to permanent hit points:
  735.               *  polymorphed         100% against poly'd hpmax
  736.               *  hpmax > 25*lvl      100% against normal hpmax
  737.               *  hpmax > 10*lvl  50..100%
  738.               *  hpmax >  5*lvl  25..75%
  739.               *  otherwise        0..50%
  740.               * Never reduces hpmax below 1 hit point per level.
  741.               */
  742.              permdmg = rn2(dmg / 2 + 1);
  743.              if (Upolyd || u.uhpmax > 25 * u.ulevel)
  744.                  permdmg = dmg;
  745.              else if (u.uhpmax > 10 * u.ulevel)
  746.                  permdmg += dmg / 2;
  747.              else if (u.uhpmax > 5 * u.ulevel)
  748.                  permdmg += dmg / 4;
  749.  
  750.              if (Upolyd) {
  751.                  hpmax_p = &u.mhmax;
  752.                  /* [can't use youmonst.m_lev] */
  753.                  lowerlimit = min((int) youmonst.data->mlevel, u.ulevel);
  754.              } else {
  755.                  hpmax_p = &u.uhpmax;
  756.                  lowerlimit = u.ulevel;
  757.              }
  758.              if (*hpmax_p - permdmg > lowerlimit)
  759.                  *hpmax_p -= permdmg;
  760.              else if (*hpmax_p > lowerlimit)
  761.                  *hpmax_p = lowerlimit;
  762.              /* else unlikely...
  763.               * already at or below minimum threshold; do nothing */
  764.              context.botl = 1;
  765.          }
  766.  
  767.          mdamageu(mtmp, dmg);
  768.      }
  769.  
  770.      if (dmg)
  771.          res = passiveum(olduasmon, mtmp, mattk);
  772.      else
  773.          res = 1;
  774.      stop_occupation();
  775.      return res;
  776.  }
  777.  

gulp_blnd_check

  1.  /* An interface for use when taking a blindfold off, for example,
  2.   * to see if an engulfing attack should immediately take affect, like
  3.   * a passive attack. TRUE if engulfing blindness occurred */
  4.  boolean
  5.  gulp_blnd_check()
  6.  {
  7.      struct attack *mattk;
  8.  
  9.      if (!Blinded && u.uswallow
  10.          && (mattk = attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND))
  11.          && can_blnd(u.ustuck, &youmonst, mattk->aatyp, (struct obj *) 0)) {
  12.          ++u.uswldtim; /* compensate for gulpmu change */
  13.          (void) gulpmu(u.ustuck, mattk);
  14.          return TRUE;
  15.      }
  16.      return FALSE;
  17.  }
  18.  

gulpmu

  1.  /* monster swallows you, or damage if u.uswallow */
  2.  STATIC_OVL int
  3.  gulpmu(mtmp, mattk)
  4.  register struct monst *mtmp;
  5.  register struct attack *mattk;
  6.  {
  7.      struct trap *t = t_at(u.ux, u.uy);
  8.      int tmp = d((int) mattk->damn, (int) mattk->damd);
  9.      int tim_tmp;
  10.      register struct obj *otmp2;
  11.      int i;
  12.      boolean physical_damage = FALSE;
  13.  
  14.      if (!u.uswallow) { /* swallows you */
  15.          int omx = mtmp->mx, omy = mtmp->my;
  16.  
  17.          if (!engulf_target(mtmp, &youmonst))
  18.              return 0;
  19.          if ((t && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT)))
  20.              && sobj_at(BOULDER, u.ux, u.uy))
  21.              return 0;
  22.  
  23.          if (Punished)
  24.              unplacebc(); /* ball&chain go away */
  25.          remove_monster(omx, omy);
  26.          mtmp->mtrapped = 0; /* no longer on old trap */
  27.          place_monster(mtmp, u.ux, u.uy);
  28.          u.ustuck = mtmp;
  29.          newsym(mtmp->mx, mtmp->my);
  30.          if (is_animal(mtmp->data) && u.usteed) {
  31.              char buf[BUFSZ];
  32.              /* Too many quirks presently if hero and steed
  33.               * are swallowed. Pretend purple worms don't
  34.               * like horses for now :-)
  35.               */
  36.              Strcpy(buf, mon_nam(u.usteed));
  37.              pline("%s lunges forward and plucks you off %s!", Monnam(mtmp),
  38.                    buf);
  39.              dismount_steed(DISMOUNT_ENGULFED);
  40.          } else
  41.              pline("%s engulfs you!", Monnam(mtmp));
  42.          stop_occupation();
  43.          reset_occupations(); /* behave as if you had moved */
  44.  
  45.          if (u.utrap) {
  46.              You("are released from the %s!",
  47.                  u.utraptype == TT_WEB ? "web" : "trap");
  48.              u.utrap = 0;
  49.          }
  50.  
  51.          i = number_leashed();
  52.          if (i > 0) {
  53.              const char *s = (i > 1) ? "leashes" : "leash";
  54.              pline_The("%s %s loose.", s, vtense(s, "snap"));
  55.              unleash_all();
  56.          }
  57.  
  58.          if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) {
  59.              /* put the attacker back where it started;
  60.                 the resulting statue will end up there */
  61.              remove_monster(mtmp->mx, mtmp->my); /* u.ux,u.uy */
  62.              place_monster(mtmp, omx, omy);
  63.              minstapetrify(mtmp, TRUE);
  64.              /* normally unstuck() would do this, but we're not
  65.                 fully swallowed yet so that won't work here */
  66.              if (Punished)
  67.                  placebc();
  68.              u.ustuck = 0;
  69.              return (mtmp->mhp > 0) ? 0 : 2;
  70.          }
  71.  
  72.          display_nhwindow(WIN_MESSAGE, FALSE);
  73.          vision_recalc(2); /* hero can't see anything */
  74.          u.uswallow = 1;
  75.          /* for digestion, shorter time is more dangerous;
  76.             for other swallowings, longer time means more
  77.             chances for the swallower to attack */
  78.          if (mattk->adtyp == AD_DGST) {
  79.              tim_tmp = 25 - (int) mtmp->m_lev;
  80.              if (tim_tmp > 0)
  81.                  tim_tmp = rnd(tim_tmp) / 2;
  82.              else if (tim_tmp < 0)
  83.                  tim_tmp = -(rnd(-tim_tmp) / 2);
  84.              /* having good armor & high constitution makes
  85.                 it take longer for you to be digested, but
  86.                 you'll end up trapped inside for longer too */
  87.              tim_tmp += -u.uac + 10 + (ACURR(A_CON) / 3 - 1);
  88.          } else {
  89.              /* higher level attacker takes longer to eject hero */
  90.              tim_tmp = rnd((int) mtmp->m_lev + 10 / 2);
  91.          }
  92.          /* u.uswldtim always set > 1 */
  93.          u.uswldtim = (unsigned) ((tim_tmp < 2) ? 2 : tim_tmp);
  94.          swallowed(1);
  95.          for (otmp2 = invent; otmp2; otmp2 = otmp2->nobj)
  96.              (void) snuff_lit(otmp2);
  97.      }
  98.  
  99.      if (mtmp != u.ustuck)
  100.          return 0;
  101.      if (u.uswldtim > 0)
  102.          u.uswldtim -= 1;
  103.  
  104.      switch (mattk->adtyp) {
  105.      case AD_DGST:
  106.          physical_damage = TRUE;
  107.          if (Slow_digestion) {
  108.              /* Messages are handled below */
  109.              u.uswldtim = 0;
  110.              tmp = 0;
  111.          } else if (u.uswldtim == 0) {
  112.              pline("%s totally digests you!", Monnam(mtmp));
  113.              tmp = u.uhp;
  114.              if (Half_physical_damage)
  115.                  tmp *= 2; /* sorry */
  116.          } else {
  117.              pline("%s%s digests you!", Monnam(mtmp),
  118.                    (u.uswldtim == 2) ? " thoroughly"
  119.                                      : (u.uswldtim == 1) ? " utterly" : "");
  120.              exercise(A_STR, FALSE);
  121.          }
  122.          break;
  123.      case AD_PHYS:
  124.          physical_damage = TRUE;
  125.          if (mtmp->data == &mons[PM_FOG_CLOUD]) {
  126.              You("are laden with moisture and %s",
  127.                  flaming(youmonst.data)
  128.                      ? "are smoldering out!"
  129.                      : Breathless ? "find it mildly uncomfortable."
  130.                                   : amphibious(youmonst.data)
  131.                                         ? "feel comforted."
  132.                                         : "can barely breathe!");
  133.              /* NB: Amphibious includes Breathless */
  134.              if (Amphibious && !flaming(youmonst.data))
  135.                  tmp = 0;
  136.          } else {
  137.              You("are pummeled with debris!");
  138.              exercise(A_STR, FALSE);
  139.          }
  140.          break;
  141.      case AD_ACID:
  142.          if (Acid_resistance) {
  143.              You("are covered with a seemingly harmless goo.");
  144.              tmp = 0;
  145.          } else {
  146.              if (Hallucination)
  147.                  pline("Ouch!  You've been slimed!");
  148.              else
  149.                  You("are covered in slime!  It burns!");
  150.              exercise(A_STR, FALSE);
  151.          }
  152.          break;
  153.      case AD_BLND:
  154.          if (can_blnd(mtmp, &youmonst, mattk->aatyp, (struct obj *) 0)) {
  155.              if (!Blind) {
  156.                  long was_blinded = Blinded;
  157.                  if (!Blinded)
  158.                      You_cant("see in here!");
  159.                  make_blinded((long) tmp, FALSE);
  160.                  if (!was_blinded && !Blind)
  161.                      Your1(vision_clears);
  162.              } else
  163.                  /* keep him blind until disgorged */
  164.                  make_blinded(Blinded + 1, FALSE);
  165.          }
  166.          tmp = 0;
  167.          break;
  168.      case AD_ELEC:
  169.          if (!mtmp->mcan && rn2(2)) {
  170.              pline_The("air around you crackles with electricity.");
  171.              if (Shock_resistance) {
  172.                  shieldeff(u.ux, u.uy);
  173.                  You("seem unhurt.");
  174.                  ugolemeffects(AD_ELEC, tmp);
  175.                  tmp = 0;
  176.              }
  177.          } else
  178.              tmp = 0;
  179.          break;
  180.      case AD_COLD:
  181.          if (!mtmp->mcan && rn2(2)) {
  182.              if (Cold_resistance) {
  183.                  shieldeff(u.ux, u.uy);
  184.                  You_feel("mildly chilly.");
  185.                  ugolemeffects(AD_COLD, tmp);
  186.                  tmp = 0;
  187.              } else
  188.                  You("are freezing to death!");
  189.          } else
  190.              tmp = 0;
  191.          break;
  192.      case AD_FIRE:
  193.          if (!mtmp->mcan && rn2(2)) {
  194.              if (Fire_resistance) {
  195.                  shieldeff(u.ux, u.uy);
  196.                  You_feel("mildly hot.");
  197.                  ugolemeffects(AD_FIRE, tmp);
  198.                  tmp = 0;
  199.              } else
  200.                  You("are burning to a crisp!");
  201.              burn_away_slime();
  202.          } else
  203.              tmp = 0;
  204.          break;
  205.      case AD_DISE:
  206.          if (!diseasemu(mtmp->data))
  207.              tmp = 0;
  208.          break;
  209.      case AD_DREN:
  210.          /* AC magic cancellation doesn't help when engulfed */
  211.          if (!mtmp->mcan && rn2(4))
  212.              drain_en(tmp);
  213.          tmp = 0;
  214.          break;
  215.      default:
  216.          physical_damage = TRUE;
  217.          tmp = 0;
  218.          break;
  219.      }
  220.  
  221.      if (physical_damage)
  222.          tmp = Maybe_Half_Phys(tmp);
  223.  
  224.      mdamageu(mtmp, tmp);
  225.      if (tmp)
  226.          stop_occupation();
  227.  
  228.      if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) {
  229.          pline("%s very hurriedly %s you!", Monnam(mtmp),
  230.                is_animal(mtmp->data) ? "regurgitates" : "expels");
  231.          expels(mtmp, mtmp->data, FALSE);
  232.      } else if (!u.uswldtim || youmonst.data->msize >= MZ_HUGE) {
  233.          You("get %s!", is_animal(mtmp->data) ? "regurgitated" : "expelled");
  234.          if (flags.verbose
  235.              && (is_animal(mtmp->data)
  236.                  || (dmgtype(mtmp->data, AD_DGST) && Slow_digestion)))
  237.              pline("Obviously %s doesn't like your taste.", mon_nam(mtmp));
  238.          expels(mtmp, mtmp->data, FALSE);
  239.      }
  240.      return 1;
  241.  }
  242.  

explmu

  1.  /* monster explodes in your face */
  2.  STATIC_OVL int
  3.  explmu(mtmp, mattk, ufound)
  4.  register struct monst *mtmp;
  5.  register struct attack *mattk;
  6.  boolean ufound;
  7.  {
  8.      boolean physical_damage = TRUE, kill_agr = TRUE;
  9.  
  10.      if (mtmp->mcan)
  11.          return 0;
  12.  
  13.      if (!ufound)
  14.          pline("%s explodes at a spot in %s!",
  15.                canseemon(mtmp) ? Monnam(mtmp) : "It",
  16.                levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water"
  17.                                                        : "thin air");
  18.      else {
  19.          register int tmp = d((int) mattk->damn, (int) mattk->damd);
  20.          register boolean not_affected = defends((int) mattk->adtyp, uwep);
  21.  
  22.          hitmsg(mtmp, mattk);
  23.  
  24.          switch (mattk->adtyp) {
  25.          case AD_COLD:
  26.              physical_damage = FALSE;
  27.              not_affected |= Cold_resistance;
  28.              goto common;
  29.          case AD_FIRE:
  30.              physical_damage = FALSE;
  31.              not_affected |= Fire_resistance;
  32.              goto common;
  33.          case AD_ELEC:
  34.              physical_damage = FALSE;
  35.              not_affected |= Shock_resistance;
  36.          common:
  37.  
  38.              if (!not_affected) {
  39.                  if (ACURR(A_DEX) > rnd(20)) {
  40.                      You("duck some of the blast.");
  41.                      tmp = (tmp + 1) / 2;
  42.                  } else {
  43.                      if (flags.verbose)
  44.                          You("get blasted!");
  45.                  }
  46.                  if (mattk->adtyp == AD_FIRE)
  47.                      burn_away_slime();
  48.                  if (physical_damage)
  49.                      tmp = Maybe_Half_Phys(tmp);
  50.                  mdamageu(mtmp, tmp);
  51.              }
  52.              break;
  53.  
  54.          case AD_BLND:
  55.              not_affected = resists_blnd(&youmonst);
  56.              if (!not_affected) {
  57.                  /* sometimes you're affected even if it's invisible */
  58.                  if (mon_visible(mtmp) || (rnd(tmp /= 2) > u.ulevel)) {
  59.                      You("are blinded by a blast of light!");
  60.                      make_blinded((long) tmp, FALSE);
  61.                      if (!Blind)
  62.                          Your1(vision_clears);
  63.                  } else if (flags.verbose)
  64.                      You("get the impression it was not terribly bright.");
  65.              }
  66.              break;
  67.  
  68.          case AD_HALU:
  69.              not_affected |= Blind || (u.umonnum == PM_BLACK_LIGHT
  70.                                        || u.umonnum == PM_VIOLET_FUNGUS
  71.                                        || dmgtype(youmonst.data, AD_STUN));
  72.              if (!not_affected) {
  73.                  boolean chg;
  74.                  if (!Hallucination)
  75.                      You("are caught in a blast of kaleidoscopic light!");
  76.                  /* avoid hallucinating the black light as it dies */
  77.                  mondead(mtmp);    /* remove it from map now */
  78.                  kill_agr = FALSE; /* already killed (maybe lifesaved) */
  79.                  chg =
  80.                      make_hallucinated(HHallucination + (long) tmp, FALSE, 0L);
  81.                  You("%s.", chg ? "are freaked out" : "seem unaffected");
  82.              }
  83.              break;
  84.  
  85.          default:
  86.              break;
  87.          }
  88.          if (not_affected) {
  89.              You("seem unaffected by it.");
  90.              ugolemeffects((int) mattk->adtyp, tmp);
  91.          }
  92.      }
  93.      if (kill_agr)
  94.          mondead(mtmp);
  95.      wake_nearto(mtmp->mx, mtmp->my, 7 * 7);
  96.      return (mtmp->mhp > 0) ? 0 : 2;
  97.  }
  98.  

gazemu

  1.  /* monster gazes at you */
  2.  int
  3.  gazemu(mtmp, mattk)
  4.  register struct monst *mtmp;
  5.  register struct attack *mattk;
  6.  {
  7.      static const char *const reactions[] = {
  8.          "confused",              /* [0] */
  9.          "stunned",               /* [1] */
  10.          "puzzled",   "dazzled",  /* [2,3] */
  11.          "irritated", "inflamed", /* [4,5] */
  12.          "tired",                 /* [6] */
  13.          "dulled",                /* [7] */
  14.      };
  15.      int react = -1;
  16.      boolean cancelled = (mtmp->mcan != 0), already = FALSE;
  17.  
  18.      /* assumes that hero has to see monster's gaze in order to be
  19.         affected, rather than monster just having to look at hero;
  20.         when hallucinating, hero's brain doesn't register what
  21.         it's seeing correctly so the gaze is usually ineffective
  22.         [this could be taken a lot farther and select a gaze effect
  23.         appropriate to what's currently being displayed, giving
  24.         ordinary monsters a gaze attack when hero thinks he or she
  25.         is facing a gazing creature, but let's not go that far...] */
  26.      if (Hallucination && rn2(4))
  27.          cancelled = TRUE;
  28.  
  29.      switch (mattk->adtyp) {
  30.      case AD_STON:
  31.          if (cancelled || !mtmp->mcansee) {
  32.              if (!canseemon(mtmp))
  33.                  break; /* silently */
  34.              pline("%s %s.", Monnam(mtmp),
  35.                    (mtmp->data == &mons[PM_MEDUSA] && mtmp->mcan)
  36.                        ? "doesn't look all that ugly"
  37.                        : "gazes ineffectually");
  38.              break;
  39.          }
  40.          if (Reflecting && couldsee(mtmp->mx, mtmp->my)
  41.              && mtmp->data == &mons[PM_MEDUSA]) {
  42.              /* hero has line of sight to Medusa and she's not blind */
  43.              boolean useeit = canseemon(mtmp);
  44.  
  45.              if (useeit)
  46.                  (void) ureflects("%s gaze is reflected by your %s.",
  47.                                   s_suffix(Monnam(mtmp)));
  48.              if (mon_reflects(
  49.                      mtmp, !useeit ? (char *) 0
  50.                                    : "The gaze is reflected away by %s %s!"))
  51.                  break;
  52.              if (!m_canseeu(mtmp)) { /* probably you're invisible */
  53.                  if (useeit)
  54.                      pline(
  55.                        "%s doesn't seem to notice that %s gaze was reflected.",
  56.                            Monnam(mtmp), mhis(mtmp));
  57.                  break;
  58.              }
  59.              if (useeit)
  60.                  pline("%s is turned to stone!", Monnam(mtmp));
  61.              stoned = TRUE;
  62.              killed(mtmp);
  63.  
  64.              if (mtmp->mhp > 0)
  65.                  break;
  66.              return 2;
  67.          }
  68.          if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)
  69.              && !Stone_resistance) {
  70.              You("meet %s gaze.", s_suffix(mon_nam(mtmp)));
  71.              stop_occupation();
  72.              if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))
  73.                  break;
  74.              You("turn to stone...");
  75.              killer.format = KILLED_BY;
  76.              Strcpy(killer.name, mtmp->data->mname);
  77.              done(STONING);
  78.          }
  79.          break;
  80.      case AD_CONF:
  81.          if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee
  82.              && !mtmp->mspec_used && rn2(5)) {
  83.              if (cancelled) {
  84.                  react = 0; /* "confused" */
  85.                  already = (mtmp->mconf != 0);
  86.              } else {
  87.                  int conf = d(3, 4);
  88.  
  89.                  mtmp->mspec_used = mtmp->mspec_used + (conf + rn2(6));
  90.                  if (!Confusion)
  91.                      pline("%s gaze confuses you!", s_suffix(Monnam(mtmp)));
  92.                  else
  93.                      You("are getting more and more confused.");
  94.                  make_confused(HConfusion + conf, FALSE);
  95.                  stop_occupation();
  96.              }
  97.          }
  98.          break;
  99.      case AD_STUN:
  100.          if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee
  101.              && !mtmp->mspec_used && rn2(5)) {
  102.              if (cancelled) {
  103.                  react = 1; /* "stunned" */
  104.                  already = (mtmp->mstun != 0);
  105.              } else {
  106.                  int stun = d(2, 6);
  107.  
  108.                  mtmp->mspec_used = mtmp->mspec_used + (stun + rn2(6));
  109.                  pline("%s stares piercingly at you!", Monnam(mtmp));
  110.                  make_stunned((HStun & TIMEOUT) + (long) stun, TRUE);
  111.                  stop_occupation();
  112.              }
  113.          }
  114.          break;
  115.      case AD_BLND:
  116.          if (canseemon(mtmp) && !resists_blnd(&youmonst)
  117.              && distu(mtmp->mx, mtmp->my) <= BOLT_LIM * BOLT_LIM) {
  118.              if (cancelled) {
  119.                  react = rn1(2, 2); /* "puzzled" || "dazzled" */
  120.                  already = (mtmp->mcansee == 0);
  121.                  /* Archons gaze every round; we don't want cancelled ones
  122.                     giving the "seems puzzled/dazzled" message that often */
  123.                  if (mtmp->mcan && mtmp->data == &mons[PM_ARCHON] && rn2(5))
  124.                      react = -1;
  125.              } else {
  126.                  int blnd = d((int) mattk->damn, (int) mattk->damd);
  127.  
  128.                  You("are blinded by %s radiance!", s_suffix(mon_nam(mtmp)));
  129.                  make_blinded((long) blnd, FALSE);
  130.                  stop_occupation();
  131.                  /* not blind at this point implies you're wearing
  132.                     the Eyes of the Overworld; make them block this
  133.                     particular stun attack too */
  134.                  if (!Blind)
  135.                      Your1(vision_clears);
  136.                  else
  137.                      make_stunned((long) d(1, 3), TRUE);
  138.              }
  139.          }
  140.          break;
  141.      case AD_FIRE:
  142.          if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee
  143.              && !mtmp->mspec_used && rn2(5)) {
  144.              if (cancelled) {
  145.                  react = rn1(2, 4); /* "irritated" || "inflamed" */
  146.              } else {
  147.                  int dmg = d(2, 6), lev = (int) mtmp->m_lev;
  148.  
  149.                  pline("%s attacks you with a fiery gaze!", Monnam(mtmp));
  150.                  stop_occupation();
  151.                  if (Fire_resistance) {
  152.                      pline_The("fire doesn't feel hot!");
  153.                      dmg = 0;
  154.                  }
  155.                  burn_away_slime();
  156.                  if (lev > rn2(20))
  157.                      destroy_item(SCROLL_CLASS, AD_FIRE);
  158.                  if (lev > rn2(20))
  159.                      destroy_item(POTION_CLASS, AD_FIRE);
  160.                  if (lev > rn2(25))
  161.                      destroy_item(SPBOOK_CLASS, AD_FIRE);
  162.                  if (dmg)
  163.                      mdamageu(mtmp, dmg);
  164.              }
  165.          }
  166.          break;
  167.  #ifdef PM_BEHOLDER /* work in progress */
  168.      case AD_SLEE:
  169.          if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee
  170.              && multi >= 0 && !rn2(5) && !Sleep_resistance) {
  171.              if (cancelled) {
  172.                  react = 6;                      /* "tired" */
  173.                  already = (mtmp->mfrozen != 0); /* can't happen... */
  174.              } else {
  175.                  fall_asleep(-rnd(10), TRUE);
  176.                  pline("%s gaze makes you very sleepy...",
  177.                        s_suffix(Monnam(mtmp)));
  178.              }
  179.          }
  180.          break;
  181.      case AD_SLOW:
  182.          if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee
  183.              && (HFast & (INTRINSIC | TIMEOUT)) && !defends(AD_SLOW, uwep)
  184.              && !rn2(4)) {
  185.              if (cancelled) {
  186.                  react = 7; /* "dulled" */
  187.                  already = (mtmp->mspeed == MSLOW);
  188.              } else {
  189.                  u_slow_down();
  190.                  stop_occupation();
  191.              }
  192.          }
  193.          break;
  194.  #endif /* BEHOLDER */
  195.      default:
  196.          impossible("Gaze attack %d?", mattk->adtyp);
  197.          break;
  198.      }
  199.      if (react >= 0) {
  200.          if (Hallucination && rn2(3))
  201.              react = rn2(SIZE(reactions));
  202.          /* cancelled/hallucinatory feedback; monster might look "confused",
  203.             "stunned",&c but we don't actually set corresponding attribute */
  204.          pline("%s looks %s%s.", Monnam(mtmp),
  205.                !rn2(3) ? "" : already ? "quite "
  206.                                       : (!rn2(2) ? "a bit " : "somewhat "),
  207.                reactions[react]);
  208.      }
  209.      return 0;
  210.  }
  211.  

mdamageu

  1.  /* mtmp hits you for n points damage */
  2.  void
  3.  mdamageu(mtmp, n)
  4.  register struct monst *mtmp;
  5.  register int n;
  6.  {
  7.      context.botl = 1;
  8.      if (Upolyd) {
  9.          u.mh -= n;
  10.          if (u.mh < 1)
  11.              rehumanize();
  12.      } else {
  13.          u.uhp -= n;
  14.          if (u.uhp < 1)
  15.              done_in_by(mtmp, DIED);
  16.      }
  17.  }
  18.  

could_seduce

  1.  /* returns 0 if seduction impossible,
  2.   *         1 if fine,
  3.   *         2 if wrong gender for nymph
  4.   */
  5.  int
  6.  could_seduce(magr, mdef, mattk)
  7.  struct monst *magr, *mdef;
  8.  struct attack *mattk;
  9.  {
  10.      register struct permonst *pagr;
  11.      boolean agrinvis, defperc;
  12.      xchar genagr, gendef;
  13.  
  14.      if (is_animal(magr->data))
  15.          return 0;
  16.      if (magr == &youmonst) {
  17.          pagr = youmonst.data;
  18.          agrinvis = (Invis != 0);
  19.          genagr = poly_gender();
  20.      } else {
  21.          pagr = magr->data;
  22.          agrinvis = magr->minvis;
  23.          genagr = gender(magr);
  24.      }
  25.      if (mdef == &youmonst) {
  26.          defperc = (See_invisible != 0);
  27.          gendef = poly_gender();
  28.      } else {
  29.          defperc = perceives(mdef->data);
  30.          gendef = gender(mdef);
  31.      }
  32.  
  33.      if (agrinvis && !defperc
  34.          && (!SYSOPT_SEDUCE || (mattk && mattk->adtyp != AD_SSEX)))
  35.          return 0;
  36.  
  37.      if (pagr->mlet != S_NYMPH
  38.          && ((pagr != &mons[PM_INCUBUS] && pagr != &mons[PM_SUCCUBUS])
  39.              || (SYSOPT_SEDUCE && mattk && mattk->adtyp != AD_SSEX)))
  40.          return 0;
  41.  
  42.      if (genagr == 1 - gendef)
  43.          return 1;
  44.      else
  45.          return (pagr->mlet == S_NYMPH) ? 2 : 0;
  46.  }
  47.  

doseduce

  1.  /* Returns 1 if monster teleported */
  2.  int
  3.  doseduce(mon)
  4.  register struct monst *mon;
  5.  {
  6.      register struct obj *ring, *nring;
  7.      boolean fem = (mon->data == &mons[PM_SUCCUBUS]); /* otherwise incubus */
  8.      int tried_gloves = 0;
  9.      char qbuf[QBUFSZ];
  10.  
  11.      if (mon->mcan || mon->mspec_used) {
  12.          pline("%s acts as though %s has got a %sheadache.", Monnam(mon),
  13.                mhe(mon), mon->mcan ? "severe " : "");
  14.          return 0;
  15.      }
  16.  
  17.      if (unconscious()) {
  18.          pline("%s seems dismayed at your lack of response.", Monnam(mon));
  19.          return 0;
  20.      }
  21.  
  22.      if (Blind)
  23.          pline("It caresses you...");
  24.      else
  25.          You_feel("very attracted to %s.", mon_nam(mon));
  26.      /* if in the process of putting armor on or taking armor off,
  27.         interrupt that activity now */
  28.      (void) stop_donning((struct obj *) 0);
  29.      /* don't try to take off gloves if cursed weapon blocks them */
  30.      if (welded(uwep))
  31.          tried_gloves = 1;
  32.  
  33.      for (ring = invent; ring; ring = nring) {
  34.          nring = ring->nobj;
  35.          if (ring->otyp != RIN_ADORNMENT)
  36.              continue;
  37.          if (fem) {
  38.              if (ring->owornmask && uarmg) {
  39.                  /* don't take off worn ring if gloves are in the way */
  40.                  if (!tried_gloves++)
  41.                      mayberem(uarmg, "gloves");
  42.                  if (uarmg)
  43.                      continue; /* next ring might not be worn */
  44.              }
  45.              if (rn2(20) < ACURR(A_CHA)) {
  46.                  (void) safe_qbuf(qbuf, "\"That ",
  47.                                   " looks pretty.  May I have it?\"", ring,
  48.                                   xname, simpleonames, "ring");
  49.                  makeknown(RIN_ADORNMENT);
  50.                  if (yn(qbuf) == 'n')
  51.                      continue;
  52.              } else
  53.                  pline("%s decides she'd like %s, and takes it.",
  54.                        Blind ? "She" : Monnam(mon), yname(ring));
  55.              makeknown(RIN_ADORNMENT);
  56.              if (ring == uleft || ring == uright)
  57.                  Ring_gone(ring);
  58.              if (ring == uwep)
  59.                  setuwep((struct obj *) 0);
  60.              if (ring == uswapwep)
  61.                  setuswapwep((struct obj *) 0);
  62.              if (ring == uquiver)
  63.                  setuqwep((struct obj *) 0);
  64.              freeinv(ring);
  65.              (void) mpickobj(mon, ring);
  66.          } else {
  67.              if (uleft && uright && uleft->otyp == RIN_ADORNMENT
  68.                  && uright->otyp == RIN_ADORNMENT)
  69.                  break;
  70.              if (ring == uleft || ring == uright)
  71.                  continue;
  72.              if (uarmg) {
  73.                  /* don't put on ring if gloves are in the way */
  74.                  if (!tried_gloves++)
  75.                      mayberem(uarmg, "gloves");
  76.                  if (uarmg)
  77.                      break; /* no point trying further rings */
  78.              }
  79.              if (rn2(20) < ACURR(A_CHA)) {
  80.                  (void) safe_qbuf(qbuf, "\"That ",
  81.                                  " looks pretty.  Would you wear it for me?\"",
  82.                                   ring, xname, simpleonames, "ring");
  83.                  makeknown(RIN_ADORNMENT);
  84.                  if (yn(qbuf) == 'n')
  85.                      continue;
  86.              } else {
  87.                  pline("%s decides you'd look prettier wearing %s,",
  88.                        Blind ? "He" : Monnam(mon), yname(ring));
  89.                  pline("and puts it on your finger.");
  90.              }
  91.              makeknown(RIN_ADORNMENT);
  92.              if (!uright) {
  93.                  pline("%s puts %s on your right %s.",
  94.                        Blind ? "He" : Monnam(mon), the(xname(ring)),
  95.                        body_part(HAND));
  96.                  setworn(ring, RIGHT_RING);
  97.              } else if (!uleft) {
  98.                  pline("%s puts %s on your left %s.",
  99.                        Blind ? "He" : Monnam(mon), the(xname(ring)),
  100.                        body_part(HAND));
  101.                  setworn(ring, LEFT_RING);
  102.              } else if (uright && uright->otyp != RIN_ADORNMENT) {
  103.                  pline("%s replaces %s with %s.", Blind ? "He" : Monnam(mon),
  104.                        yname(uright), yname(ring));
  105.                  Ring_gone(uright);
  106.                  setworn(ring, RIGHT_RING);
  107.              } else if (uleft && uleft->otyp != RIN_ADORNMENT) {
  108.                  pline("%s replaces %s with %s.", Blind ? "He" : Monnam(mon),
  109.                        yname(uleft), yname(ring));
  110.                  Ring_gone(uleft);
  111.                  setworn(ring, LEFT_RING);
  112.              } else
  113.                  impossible("ring replacement");
  114.              Ring_on(ring);
  115.              prinv((char *) 0, ring, 0L);
  116.          }
  117.      }
  118.  
  119.      if (!uarmc && !uarmf && !uarmg && !uarms && !uarmh && !uarmu)
  120.          pline("%s murmurs sweet nothings into your ear.",
  121.                Blind ? (fem ? "She" : "He") : Monnam(mon));
  122.      else
  123.          pline("%s murmurs in your ear, while helping you undress.",
  124.                Blind ? (fem ? "She" : "He") : Monnam(mon));
  125.      mayberem(uarmc, cloak_simple_name(uarmc));
  126.      if (!uarmc)
  127.          mayberem(uarm, "suit");
  128.      mayberem(uarmf, "boots");
  129.      if (!tried_gloves)
  130.          mayberem(uarmg, "gloves");
  131.      mayberem(uarms, "shield");
  132.      mayberem(uarmh, helm_simple_name(uarmh));
  133.      if (!uarmc && !uarm)
  134.          mayberem(uarmu, "shirt");
  135.  
  136.      if (uarm || uarmc) {
  137.          verbalize("You're such a %s; I wish...",
  138.                    flags.female ? "sweet lady" : "nice guy");
  139.          if (!tele_restrict(mon))
  140.              (void) rloc(mon, TRUE);
  141.          return 1;
  142.      }
  143.      if (u.ualign.type == A_CHAOTIC)
  144.          adjalign(1);
  145.  
  146.      /* by this point you have discovered mon's identity, blind or not... */
  147.      pline("Time stands still while you and %s lie in each other's arms...",
  148.            noit_mon_nam(mon));
  149.      if (rn2(35) > ACURR(A_CHA) + ACURR(A_INT)) {
  150.          /* Don't bother with mspec_used here... it didn't get tired! */
  151.          pline("%s seems to have enjoyed it more than you...",
  152.                noit_Monnam(mon));
  153.          switch (rn2(5)) {
  154.          case 0:
  155.              You_feel("drained of energy.");
  156.              u.uen = 0;
  157.              u.uenmax -= rnd(Half_physical_damage ? 5 : 10);
  158.              exercise(A_CON, FALSE);
  159.              if (u.uenmax < 0)
  160.                  u.uenmax = 0;
  161.              break;
  162.          case 1:
  163.              You("are down in the dumps.");
  164.              (void) adjattrib(A_CON, -1, TRUE);
  165.              exercise(A_CON, FALSE);
  166.              context.botl = 1;
  167.              break;
  168.          case 2:
  169.              Your("senses are dulled.");
  170.              (void) adjattrib(A_WIS, -1, TRUE);
  171.              exercise(A_WIS, FALSE);
  172.              context.botl = 1;
  173.              break;
  174.          case 3:
  175.              if (!resists_drli(&youmonst)) {
  176.                  You_feel("out of shape.");
  177.                  losexp("overexertion");
  178.              } else {
  179.                  You("have a curious feeling...");
  180.              }
  181.              break;
  182.          case 4: {
  183.              int tmp;
  184.              You_feel("exhausted.");
  185.              exercise(A_STR, FALSE);
  186.              tmp = rn1(10, 6);
  187.              losehp(Maybe_Half_Phys(tmp), "exhaustion", KILLED_BY);
  188.              break;
  189.          }
  190.          }
  191.      } else {
  192.          mon->mspec_used = rnd(100); /* monster is worn out */
  193.          You("seem to have enjoyed it more than %s...", noit_mon_nam(mon));
  194.          switch (rn2(5)) {
  195.          case 0:
  196.              You_feel("raised to your full potential.");
  197.              exercise(A_CON, TRUE);
  198.              u.uen = (u.uenmax += rnd(5));
  199.              break;
  200.          case 1:
  201.              You_feel("good enough to do it again.");
  202.              (void) adjattrib(A_CON, 1, TRUE);
  203.              exercise(A_CON, TRUE);
  204.              context.botl = 1;
  205.              break;
  206.          case 2:
  207.              You("will always remember %s...", noit_mon_nam(mon));
  208.              (void) adjattrib(A_WIS, 1, TRUE);
  209.              exercise(A_WIS, TRUE);
  210.              context.botl = 1;
  211.              break;
  212.          case 3:
  213.              pline("That was a very educational experience.");
  214.              pluslvl(FALSE);
  215.              exercise(A_WIS, TRUE);
  216.              break;
  217.          case 4:
  218.              You_feel("restored to health!");
  219.              u.uhp = u.uhpmax;
  220.              if (Upolyd)
  221.                  u.mh = u.mhmax;
  222.              exercise(A_STR, TRUE);
  223.              context.botl = 1;
  224.              break;
  225.          }
  226.      }
  227.  
  228.      if (mon->mtame) /* don't charge */
  229.          ;
  230.      else if (rn2(20) < ACURR(A_CHA)) {
  231.          pline("%s demands that you pay %s, but you refuse...",
  232.                noit_Monnam(mon), Blind ? (fem ? "her" : "him") : mhim(mon));
  233.      } else if (u.umonnum == PM_LEPRECHAUN)
  234.          pline("%s tries to take your money, but fails...", noit_Monnam(mon));
  235.      else {
  236.          long cost;
  237.          long umoney = money_cnt(invent);
  238.  
  239.          if (umoney > (long) LARGEST_INT - 10L)
  240.              cost = (long) rnd(LARGEST_INT) + 500L;
  241.          else
  242.              cost = (long) rnd((int) umoney + 10) + 500L;
  243.          if (mon->mpeaceful) {
  244.              cost /= 5L;
  245.              if (!cost)
  246.                  cost = 1L;
  247.          }
  248.          if (cost > umoney)
  249.              cost = umoney;
  250.          if (!cost)
  251.              verbalize("It's on the house!");
  252.          else {
  253.              pline("%s takes %ld %s for services rendered!", noit_Monnam(mon),
  254.                    cost, currency(cost));
  255.              money2mon(mon, cost);
  256.              context.botl = 1;
  257.          }
  258.      }
  259.      if (!rn2(25))
  260.          mon->mcan = 1; /* monster is worn out */
  261.      if (!tele_restrict(mon))
  262.          (void) rloc(mon, TRUE);
  263.      return 1;
  264.  }
  265.  

mayberem

  1.  STATIC_OVL void
  2.  mayberem(obj, str)
  3.  register struct obj *obj;
  4.  const char *str;
  5.  {
  6.      char qbuf[QBUFSZ];
  7.  
  8.      if (!obj || !obj->owornmask)
  9.          return;
  10.  
  11.      if (rn2(20) < ACURR(A_CHA)) {
  12.          Sprintf(qbuf, "\"Shall I remove your %s, %s?\"", str,
  13.                  (!rn2(2) ? "lover" : !rn2(2) ? "dear" : "sweetheart"));
  14.          if (yn(qbuf) == 'n')
  15.              return;
  16.      } else {
  17.          char hairbuf[BUFSZ];
  18.  
  19.          Sprintf(hairbuf, "let me run my fingers through your %s",
  20.                  body_part(HAIR));
  21.          verbalize("Take off your %s; %s.", str,
  22.                    (obj == uarm)
  23.                       ? "let's get a little closer"
  24.                       : (obj == uarmc || obj == uarms)
  25.                          ? "it's in the way"
  26.                          : (obj == uarmf)
  27.                             ? "let me rub your feet"
  28.                             : (obj == uarmg)
  29.                                ? "they're too clumsy"
  30.                                : (obj == uarmu)
  31.                                   ? "let me massage you"
  32.                                   /* obj == uarmh */
  33.                                   : hairbuf);
  34.      }
  35.      remove_worn_item(obj, TRUE);
  36.  }
  37.  

passiveum

  1.  STATIC_OVL int
  2.  passiveum(olduasmon, mtmp, mattk)
  3.  struct permonst *olduasmon;
  4.  register struct monst *mtmp;
  5.  register struct attack *mattk;
  6.  {
  7.      int i, tmp;
  8.  
  9.      for (i = 0;; i++) {
  10.          if (i >= NATTK)
  11.              return 1;
  12.          if (olduasmon->mattk[i].aatyp == AT_NONE
  13.              || olduasmon->mattk[i].aatyp == AT_BOOM)
  14.              break;
  15.      }
  16.      if (olduasmon->mattk[i].damn)
  17.          tmp =
  18.              d((int) olduasmon->mattk[i].damn, (int) olduasmon->mattk[i].damd);
  19.      else if (olduasmon->mattk[i].damd)
  20.          tmp = d((int) olduasmon->mlevel + 1, (int) olduasmon->mattk[i].damd);
  21.      else
  22.          tmp = 0;
  23.  
  24.      /* These affect the enemy even if you were "killed" (rehumanized) */
  25.      switch (olduasmon->mattk[i].adtyp) {
  26.      case AD_ACID:
  27.          if (!rn2(2)) {
  28.              pline("%s is splashed by your acid!", Monnam(mtmp));
  29.              if (resists_acid(mtmp)) {
  30.                  pline("%s is not affected.", Monnam(mtmp));
  31.                  tmp = 0;
  32.              }
  33.          } else
  34.              tmp = 0;
  35.          if (!rn2(30))
  36.              erode_armor(mtmp, ERODE_CORRODE);
  37.          if (!rn2(6))
  38.              acid_damage(MON_WEP(mtmp));
  39.          goto assess_dmg;
  40.      case AD_STON: /* cockatrice */
  41.      {
  42.          long protector = attk_protection((int) mattk->aatyp),
  43.               wornitems = mtmp->misc_worn_check;
  44.  
  45.          /* wielded weapon gives same protection as gloves here */
  46.          if (MON_WEP(mtmp) != 0)
  47.              wornitems |= W_ARMG;
  48.  
  49.          if (!resists_ston(mtmp)
  50.              && (protector == 0L
  51.                  || (protector != ~0L
  52.                      && (wornitems & protector) != protector))) {
  53.              if (poly_when_stoned(mtmp->data)) {
  54.                  mon_to_stone(mtmp);
  55.                  return 1;
  56.              }
  57.              pline("%s turns to stone!", Monnam(mtmp));
  58.              stoned = 1;
  59.              xkilled(mtmp, 0);
  60.              if (mtmp->mhp > 0)
  61.                  return 1;
  62.              return 2;
  63.          }
  64.          return 1;
  65.      }
  66.      case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
  67.          if (otmp) {
  68.              (void) drain_item(otmp);
  69.              /* No message */
  70.          }
  71.          return 1;
  72.      default:
  73.          break;
  74.      }
  75.      if (!Upolyd)
  76.          return 1;
  77.  
  78.      /* These affect the enemy only if you are still a monster */
  79.      if (rn2(3))
  80.          switch (youmonst.data->mattk[i].adtyp) {
  81.          case AD_PHYS:
  82.              if (youmonst.data->mattk[i].aatyp == AT_BOOM) {
  83.                  You("explode!");
  84.                  /* KMH, balance patch -- this is okay with unchanging */
  85.                  rehumanize();
  86.                  goto assess_dmg;
  87.              }
  88.              break;
  89.          case AD_PLYS: /* Floating eye */
  90.              if (tmp > 127)
  91.                  tmp = 127;
  92.              if (u.umonnum == PM_FLOATING_EYE) {
  93.                  if (!rn2(4))
  94.                      tmp = 127;
  95.                  if (mtmp->mcansee && haseyes(mtmp->data) && rn2(3)
  96.                      && (perceives(mtmp->data) || !Invis)) {
  97.                      if (Blind)
  98.                          pline("As a blind %s, you cannot defend yourself.",
  99.                                youmonst.data->mname);
  100.                      else {
  101.                          if (mon_reflects(mtmp,
  102.                                           "Your gaze is reflected by %s %s."))
  103.                              return 1;
  104.                          pline("%s is frozen by your gaze!", Monnam(mtmp));
  105.                          paralyze_monst(mtmp, tmp);
  106.                          return 3;
  107.                      }
  108.                  }
  109.              } else { /* gelatinous cube */
  110.                  pline("%s is frozen by you.", Monnam(mtmp));
  111.                  paralyze_monst(mtmp, tmp);
  112.                  return 3;
  113.              }
  114.              return 1;
  115.          case AD_COLD: /* Brown mold or blue jelly */
  116.              if (resists_cold(mtmp)) {
  117.                  shieldeff(mtmp->mx, mtmp->my);
  118.                  pline("%s is mildly chilly.", Monnam(mtmp));
  119.                  golemeffects(mtmp, AD_COLD, tmp);
  120.                  tmp = 0;
  121.                  break;
  122.              }
  123.              pline("%s is suddenly very cold!", Monnam(mtmp));
  124.              u.mh += tmp / 2;
  125.              if (u.mhmax < u.mh)
  126.                  u.mhmax = u.mh;
  127.              if (u.mhmax > ((youmonst.data->mlevel + 1) * 8))
  128.                  (void) split_mon(&youmonst, mtmp);
  129.              break;
  130.          case AD_STUN: /* Yellow mold */
  131.              if (!mtmp->mstun) {
  132.                  mtmp->mstun = 1;
  133.                  pline("%s %s.", Monnam(mtmp),
  134.                        makeplural(stagger(mtmp->data, "stagger")));
  135.              }
  136.              tmp = 0;
  137.              break;
  138.          case AD_FIRE: /* Red mold */
  139.              if (resists_fire(mtmp)) {
  140.                  shieldeff(mtmp->mx, mtmp->my);
  141.                  pline("%s is mildly warm.", Monnam(mtmp));
  142.                  golemeffects(mtmp, AD_FIRE, tmp);
  143.                  tmp = 0;
  144.                  break;
  145.              }
  146.              pline("%s is suddenly very hot!", Monnam(mtmp));
  147.              break;
  148.          case AD_ELEC:
  149.              if (resists_elec(mtmp)) {
  150.                  shieldeff(mtmp->mx, mtmp->my);
  151.                  pline("%s is slightly tingled.", Monnam(mtmp));
  152.                  golemeffects(mtmp, AD_ELEC, tmp);
  153.                  tmp = 0;
  154.                  break;
  155.              }
  156.              pline("%s is jolted with your electricity!", Monnam(mtmp));
  157.              break;
  158.          default:
  159.              tmp = 0;
  160.              break;
  161.          }
  162.      else
  163.          tmp = 0;
  164.  
  165.  assess_dmg:
  166.      if ((mtmp->mhp -= tmp) <= 0) {
  167.          pline("%s dies!", Monnam(mtmp));
  168.          xkilled(mtmp, 0);
  169.          if (mtmp->mhp > 0)
  170.              return 1;
  171.          return 2;
  172.      }
  173.      return 1;
  174.  }
  175.  

cloneu

  1.  struct monst *
  2.  cloneu()
  3.  {
  4.      register struct monst *mon;
  5.      int mndx = monsndx(youmonst.data);
  6.  
  7.      if (u.mh <= 1)
  8.          return (struct monst *) 0;
  9.      if (mvitals[mndx].mvflags & G_EXTINCT)
  10.          return (struct monst *) 0;
  11.      mon = makemon(youmonst.data, u.ux, u.uy, NO_MINVENT | MM_EDOG);
  12.      if (!mon)
  13.          return NULL;
  14.      mon->mcloned = 1;
  15.      mon = christen_monst(mon, plname);
  16.      initedog(mon);
  17.      mon->m_lev = youmonst.data->mlevel;
  18.      mon->mhpmax = u.mhmax;
  19.      mon->mhp = u.mh / 2;
  20.      u.mh -= mon->mhp;
  21.      context.botl = 1;
  22.      return mon;
  23.  }
  24.  
  25.  /*mhitu.c*/