Source:NetHack 3.6.1/src/attrib.c

From NetHackWiki
(Redirected from Source:Ref/exercise)
Jump to: navigation, search

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

Top of file

  1.  /* NetHack 3.6	attrib.c	$NHDT-Date: 1494034337 2017/05/06 01:32:17 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.62 $ */
  2.  /*      Copyright 1988, 1989, 1990, 1992, M. Stephenson           */
  3.  /* NetHack may be freely redistributed.  See license for details. */

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

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

  1.  
  2.  /*  attribute modification routines. */
  3.  
  4.  #include "hack.h"
  5.  #include <ctype.h>
  6.  
  7.  /* part of the output on gain or loss of attribute */
  8.  static const char
  9.      *const plusattr[] = { "strong", "smart", "wise",
  10.                            "agile",  "tough", "charismatic" },
  11.      *const minusattr[] = { "weak",    "stupid",
  12.                             "foolish", "clumsy",
  13.                             "fragile", "repulsive" };
  14.  /* also used by enlightenment for non-abbreviated status info */
  15.  const char
  16.      *const attrname[] = { "strength", "intelligence", "wisdom",
  17.                            "dexterity", "constitution", "charisma" };
  18.  
  19.  static const struct innate {
  20.      schar ulevel;
  21.      long *ability;
  22.      const char *gainstr, *losestr;
  23.  } arc_abil[] = { { 1, &(HStealth), "", "" },
  24.                   { 1, &(HFast), "", "" },
  25.                   { 10, &(HSearching), "perceptive", "" },
  26.                   { 0, 0, 0, 0 } },
  27.  
  28.    bar_abil[] = { { 1, &(HPoison_resistance), "", "" },
  29.                   { 7, &(HFast), "quick", "slow" },
  30.                   { 15, &(HStealth), "stealthy", "" },
  31.                   { 0, 0, 0, 0 } },
  32.  
  33.    cav_abil[] = { { 7, &(HFast), "quick", "slow" },
  34.                   { 15, &(HWarning), "sensitive", "" },
  35.                   { 0, 0, 0, 0 } },
  36.  
  37.    hea_abil[] = { { 1, &(HPoison_resistance), "", "" },
  38.                   { 15, &(HWarning), "sensitive", "" },
  39.                   { 0, 0, 0, 0 } },
  40.  
  41.    kni_abil[] = { { 7, &(HFast), "quick", "slow" }, { 0, 0, 0, 0 } },
  42.  
  43.    mon_abil[] = { { 1, &(HFast), "", "" },
  44.                   { 1, &(HSleep_resistance), "", "" },
  45.                   { 1, &(HSee_invisible), "", "" },
  46.                   { 3, &(HPoison_resistance), "healthy", "" },
  47.                   { 5, &(HStealth), "stealthy", "" },
  48.                   { 7, &(HWarning), "sensitive", "" },
  49.                   { 9, &(HSearching), "perceptive", "unaware" },
  50.                   { 11, &(HFire_resistance), "cool", "warmer" },
  51.                   { 13, &(HCold_resistance), "warm", "cooler" },
  52.                   { 15, &(HShock_resistance), "insulated", "conductive" },
  53.                   { 17, &(HTeleport_control), "controlled", "uncontrolled" },
  54.                   { 0, 0, 0, 0 } },
  55.  
  56.    pri_abil[] = { { 15, &(HWarning), "sensitive", "" },
  57.                   { 20, &(HFire_resistance), "cool", "warmer" },
  58.                   { 0, 0, 0, 0 } },
  59.  
  60.    ran_abil[] = { { 1, &(HSearching), "", "" },
  61.                   { 7, &(HStealth), "stealthy", "" },
  62.                   { 15, &(HSee_invisible), "", "" },
  63.                   { 0, 0, 0, 0 } },
  64.  
  65.    rog_abil[] = { { 1, &(HStealth), "", "" },
  66.                   { 10, &(HSearching), "perceptive", "" },
  67.                   { 0, 0, 0, 0 } },
  68.  
  69.    sam_abil[] = { { 1, &(HFast), "", "" },
  70.                   { 15, &(HStealth), "stealthy", "" },
  71.                   { 0, 0, 0, 0 } },
  72.  
  73.    tou_abil[] = { { 10, &(HSearching), "perceptive", "" },
  74.                   { 20, &(HPoison_resistance), "hardy", "" },
  75.                   { 0, 0, 0, 0 } },
  76.  
  77.    val_abil[] = { { 1, &(HCold_resistance), "", "" },
  78.                   { 1, &(HStealth), "", "" },
  79.                   { 7, &(HFast), "quick", "slow" },
  80.                   { 0, 0, 0, 0 } },
  81.  
  82.    wiz_abil[] = { { 15, &(HWarning), "sensitive", "" },
  83.                   { 17, &(HTeleport_control), "controlled", "uncontrolled" },
  84.                   { 0, 0, 0, 0 } },
  85.  
  86.    /* Intrinsics conferred by race */
  87.    dwa_abil[] = { { 1, &HInfravision, "", "" },
  88.                   { 0, 0, 0, 0 } },
  89.  
  90.    elf_abil[] = { { 1, &HInfravision, "", "" },
  91.                   { 4, &HSleep_resistance, "awake", "tired" },
  92.                   { 0, 0, 0, 0 } },
  93.  
  94.    gno_abil[] = { { 1, &HInfravision, "", "" },
  95.                   { 0, 0, 0, 0 } },
  96.  
  97.    orc_abil[] = { { 1, &HInfravision, "", "" },
  98.                   { 1, &HPoison_resistance, "", "" },
  99.                   { 0, 0, 0, 0 } },
  100.  
  101.    hum_abil[] = { { 0, 0, 0, 0 } };
  102.  
  103.  STATIC_DCL void NDECL(exerper);
  104.  STATIC_DCL void FDECL(postadjabil, (long *));
  105.  STATIC_DCL const struct innate *FDECL(role_abil, (int));
  106.  STATIC_DCL const struct innate *FDECL(check_innate_abil, (long *, long));
  107.  STATIC_DCL int FDECL(innately, (long *));
  108.  

adjattrib

  1.  /* adjust an attribute; return TRUE if change is made, FALSE otherwise */
  2.  boolean
  3.  adjattrib(ndx, incr, msgflg)
  4.  int ndx, incr;
  5.  int msgflg; /* positive => no message, zero => message, and */
  6.  {           /* negative => conditional (msg if change made) */
  7.      int old_acurr, old_abase;
  8.      boolean abonflg;
  9.      const char *attrstr;
  10.  
  11.      if (Fixed_abil || !incr)
  12.          return FALSE;
  13.  
  14.      if ((ndx == A_INT || ndx == A_WIS) && uarmh && uarmh->otyp == DUNCE_CAP) {
  15.          if (msgflg == 0)
  16.              Your("cap constricts briefly, then relaxes again.");
  17.          return FALSE;
  18.      }
  19.  
  20.      old_acurr = ACURR(ndx);
  21.      old_abase = ABASE(ndx);
  22.      if (incr > 0) {
  23.          ABASE(ndx) += incr;
  24.          if (ABASE(ndx) > AMAX(ndx)) {
  25.              incr = ABASE(ndx) - AMAX(ndx);
  26.              AMAX(ndx) += incr;
  27.              if (AMAX(ndx) > ATTRMAX(ndx))
  28.                  AMAX(ndx) = ATTRMAX(ndx);
  29.              ABASE(ndx) = AMAX(ndx);
  30.          }
  31.          attrstr = plusattr[ndx];
  32.          abonflg = (ABON(ndx) < 0);
  33.      } else {
  34.          ABASE(ndx) += incr;
  35.          if (ABASE(ndx) < ATTRMIN(ndx)) {
  36.              incr = ABASE(ndx) - ATTRMIN(ndx);
  37.              ABASE(ndx) = ATTRMIN(ndx);
  38.              AMAX(ndx) += incr;
  39.              if (AMAX(ndx) < ATTRMIN(ndx))
  40.                  AMAX(ndx) = ATTRMIN(ndx);
  41.          }
  42.          attrstr = minusattr[ndx];
  43.          abonflg = (ABON(ndx) > 0);
  44.      }
  45.      if (ACURR(ndx) == old_acurr) {
  46.          if (msgflg == 0 && flags.verbose) {
  47.              if (ABASE(ndx) == old_abase)
  48.                  pline("You're %s as %s as you can get.",
  49.                        abonflg ? "currently" : "already", attrstr);
  50.              else /* current stayed the same but base value changed */
  51.                  Your("innate %s has %s.", attrname[ndx],
  52.                       (incr > 0) ? "improved" : "declined");
  53.          }
  54.          return FALSE;
  55.      }
  56.  
  57.      if (msgflg <= 0)
  58.          You_feel("%s%s!", (incr > 1 || incr < -1) ? "very " : "", attrstr);
  59.      context.botl = 1;
  60.      if (moves > 1 && (ndx == A_STR || ndx == A_CON))
  61.          (void) encumber_msg();
  62.      return TRUE;
  63.  }
  64.  

gainstr

  1.  void
  2.  gainstr(otmp, incr, givemsg)
  3.  struct obj *otmp;
  4.  int incr;
  5.  boolean givemsg;
  6.  {
  7.      int num = incr;
  8.  
  9.      if (!num) {
  10.          if (ABASE(A_STR) < 18)
  11.              num = (rn2(4) ? 1 : rnd(6));
  12.          else if (ABASE(A_STR) < STR18(85))
  13.              num = rnd(10);
  14.          else
  15.              num = 1;
  16.      }
  17.      (void) adjattrib(A_STR, (otmp && otmp->cursed) ? -num : num,
  18.                       givemsg ? -1 : 1);
  19.  }
  20.  

losestr

  1.  /* may kill you; cause may be poison or monster like 'a' */
  2.  void
  3.  losestr(num)
  4.  register int num;
  5.  {
  6.      int ustr = ABASE(A_STR) - num;
  7.  
  8.      while (ustr < 3) {
  9.          ++ustr;
  10.          --num;
  11.          if (Upolyd) {
  12.              u.mh -= 6;
  13.              u.mhmax -= 6;
  14.          } else {
  15.              u.uhp -= 6;
  16.              u.uhpmax -= 6;
  17.          }
  18.      }
  19.      (void) adjattrib(A_STR, -num, 1);
  20.  }
  21.  
  22.  static const struct poison_effect_message {
  23.      void VDECL((*delivery_func), (const char *, ...));
  24.      const char *effect_msg;
  25.  } poiseff[] = {
  26.      { You_feel, "weaker" },             /* A_STR */
  27.      { Your, "brain is on fire" },       /* A_INT */
  28.      { Your, "judgement is impaired" },  /* A_WIS */
  29.      { Your, "muscles won't obey you" }, /* A_DEX */
  30.      { You_feel, "very sick" },          /* A_CON */
  31.      { You, "break out in hives" }       /* A_CHA */
  32.  };
  33.  

poisontell

  1.  /* feedback for attribute loss due to poisoning */
  2.  void
  3.  poisontell(typ, exclaim)
  4.  int typ;         /* which attribute */
  5.  boolean exclaim; /* emphasis */
  6.  {
  7.      void VDECL((*func), (const char *, ...)) = poiseff[typ].delivery_func;
  8.      const char *msg_txt = poiseff[typ].effect_msg;
  9.  
  10.      /*
  11.       * "You feel weaker" or "you feel very sick" aren't appropriate when
  12.       * wearing or wielding something (gauntlets of power, Ogresmasher)
  13.       * which forces the attribute to maintain its maximum value.
  14.       * Phrasing for other attributes which might have fixed values
  15.       * (dunce cap) is such that we don't need message fixups for them.
  16.       */
  17.      if (typ == A_STR && ACURR(A_STR) == STR19(25))
  18.          msg_txt = "innately weaker";
  19.      else if (typ == A_CON && ACURR(A_CON) == 25)
  20.          msg_txt = "sick inside";
  21.  
  22.      (*func)("%s%c", msg_txt, exclaim ? '!' : '.');
  23.  }
  24.  

poisoned

  1.  /* called when an attack or trap has poisoned hero (used to be in mon.c) */
  2.  void
  3.  poisoned(reason, typ, pkiller, fatal, thrown_weapon)
  4.  const char *reason,    /* controls what messages we display */
  5.             *pkiller;   /* for score+log file if fatal */
  6.  int typ, fatal;        /* if fatal is 0, limit damage to adjattrib */
  7.  boolean thrown_weapon; /* thrown weapons are less deadly */
  8.  {
  9.      int i, loss, kprefix = KILLED_BY_AN;
  10.  
  11.      /* inform player about being poisoned unless that's already been done;
  12.         "blast" has given a "blast of poison gas" message; "poison arrow",
  13.         "poison dart", etc have implicitly given poison messages too... */
  14.      if (strcmp(reason, "blast") && !strstri(reason, "poison")) {
  15.          boolean plural = (reason[strlen(reason) - 1] == 's') ? 1 : 0;
  16.  
  17.          /* avoid "The" Orcus's sting was poisoned... */
  18.          pline("%s%s %s poisoned!",
  19.                isupper((uchar) *reason) ? "" : "The ", reason,
  20.                plural ? "were" : "was");
  21.      }
  22.      if (Poison_resistance) {
  23.          if (!strcmp(reason, "blast"))
  24.              shieldeff(u.ux, u.uy);
  25.          pline_The("poison doesn't seem to affect you.");
  26.          return;
  27.      }
  28.  
  29.      /* suppress killer prefix if it already has one */
  30.      i = name_to_mon(pkiller);
  31.      if (i >= LOW_PM && (mons[i].geno & G_UNIQ)) {
  32.          kprefix = KILLED_BY;
  33.          if (!type_is_pname(&mons[i]))
  34.              pkiller = the(pkiller);
  35.      } else if (!strncmpi(pkiller, "the ", 4) || !strncmpi(pkiller, "an ", 3)
  36.                 || !strncmpi(pkiller, "a ", 2)) {
  37.          /*[ does this need a plural check too? ]*/
  38.          kprefix = KILLED_BY;
  39.      }
  40.  
  41.      i = !fatal ? 1 : rn2(fatal + (thrown_weapon ? 20 : 0));
  42.      if (i == 0 && typ != A_CHA) {
  43.          /* instant kill */
  44.          u.uhp = -1;
  45.          context.botl = TRUE;
  46.          pline_The("poison was deadly...");
  47.      } else if (i > 5) {
  48.          /* HP damage; more likely--but less severe--with missiles */
  49.          loss = thrown_weapon ? rnd(6) : rn1(10, 6);
  50.          losehp(loss, pkiller, kprefix); /* poison damage */
  51.      } else {
  52.          /* attribute loss; if typ is A_STR, reduction in current and
  53.             maximum HP will occur once strength has dropped down to 3 */
  54.          loss = (thrown_weapon || !fatal) ? 1 : d(2, 2); /* was rn1(3,3) */
  55.          /* check that a stat change was made */
  56.          if (adjattrib(typ, -loss, 1))
  57.              poisontell(typ, TRUE);
  58.      }
  59.  
  60.      if (u.uhp < 1) {
  61.          killer.format = kprefix;
  62.          Strcpy(killer.name, pkiller);
  63.          /* "Poisoned by a poisoned ___" is redundant */
  64.          done(strstri(pkiller, "poison") ? DIED : POISONING);
  65.      }
  66.      (void) encumber_msg();
  67.  }
  68.  

change_luck

  1.  void
  2.  change_luck(n)
  3.  register schar n;
  4.  {
  5.      u.uluck += n;
  6.      if (u.uluck < 0 && u.uluck < LUCKMIN)
  7.          u.uluck = LUCKMIN;
  8.      if (u.uluck > 0 && u.uluck > LUCKMAX)
  9.          u.uluck = LUCKMAX;
  10.  }
  11.  

stone_luck

  1.  int
  2.  stone_luck(parameter)
  3.  boolean parameter; /* So I can't think up of a good name.  So sue me. --KAA */
  4.  {
  5.      register struct obj *otmp;
  6.      register long bonchance = 0;
  7.  
  8.      for (otmp = invent; otmp; otmp = otmp->nobj)
  9.          if (confers_luck(otmp)) {
  10.              if (otmp->cursed)
  11.                  bonchance -= otmp->quan;
  12.              else if (otmp->blessed)
  13.                  bonchance += otmp->quan;
  14.              else if (parameter)
  15.                  bonchance += otmp->quan;
  16.          }
  17.  
  18.      return sgn((int) bonchance);
  19.  }
  20.  

set_moreluck

  1.  /* there has just been an inventory change affecting a luck-granting item */
  2.  void
  3.  set_moreluck()
  4.  {
  5.      int luckbon = stone_luck(TRUE);
  6.  
  7.      if (!luckbon && !carrying(LUCKSTONE))
  8.          u.moreluck = 0;
  9.      else if (luckbon >= 0)
  10.          u.moreluck = LUCKADD;
  11.      else
  12.          u.moreluck = -LUCKADD;
  13.  }
  14.  

restore_attrib

  1.  void
  2.  restore_attrib()
  3.  {
  4.      int i, equilibrium;;
  5.  
  6.      /*
  7.       * Note:  this gets called on every turn but ATIME() is never set
  8.       * to non-zero anywhere, and ATEMP() is only used for strength loss
  9.       * from hunger, so it doesn't actually do anything.
  10.       */
  11.  
  12.      for (i = 0; i < A_MAX; i++) { /* all temporary losses/gains */
  13.          equilibrium = (i == A_STR && u.uhs >= WEAK) ? -1 : 0;
  14.          if (ATEMP(i) != equilibrium && ATIME(i) != 0) {
  15.              if (!(--(ATIME(i)))) { /* countdown for change */
  16.                  ATEMP(i) += (ATEMP(i) > 0) ? -1 : 1;
  17.                  context.botl = 1;
  18.                  if (ATEMP(i)) /* reset timer */
  19.                      ATIME(i) = 100 / ACURR(A_CON);
  20.              }
  21.          }
  22.      }
  23.      if (context.botl)
  24.          (void) encumber_msg();
  25.  }
  26.  
  27.  #define AVAL 50 /* tune value for exercise gains */
  28.  

exercise

  1.  void
  2.  exercise(i, inc_or_dec)
  3.  int i;
  4.  boolean inc_or_dec;
  5.  {
  6.      debugpline0("Exercise:");
  7.      if (i == A_INT || i == A_CHA)
  8.          return; /* can't exercise these */
  9.  
  10.      /* no physical exercise while polymorphed; the body's temporary */
  11.      if (Upolyd && i != A_WIS)
  12.          return;
  13.  
  14.      if (abs(AEXE(i)) < AVAL) {
  15.          /*
  16.           *      Law of diminishing returns (Part I):
  17.           *
  18.           *      Gain is harder at higher attribute values.
  19.           *      79% at "3" --> 0% at "18"
  20.           *      Loss is even at all levels (50%).
  21.           *
  22.           *      Note: *YES* ACURR is the right one to use.
  23.           */
  24.          AEXE(i) += (inc_or_dec) ? (rn2(19) > ACURR(i)) : -rn2(2);
  25.          debugpline3("%s, %s AEXE = %d",
  26.                      (i == A_STR) ? "Str" : (i == A_WIS) ? "Wis" : (i == A_DEX)
  27.                                                                        ? "Dex"
  28.                                                                        : "Con",
  29.                      (inc_or_dec) ? "inc" : "dec", AEXE(i));
  30.      }
  31.      if (moves > 0 && (i == A_STR || i == A_CON))
  32.          (void) encumber_msg();
  33.  }
  34.  

exerper

  1.  STATIC_OVL void
  2.  exerper()
  3.  {
  4.      if (!(moves % 10)) {
  5.          /* Hunger Checks */
  6.  
  7.          int hs = (u.uhunger > 1000) ? SATIATED : (u.uhunger > 150)
  8.                                                       ? NOT_HUNGRY
  9.                                                       : (u.uhunger > 50)
  10.                                                             ? HUNGRY
  11.                                                             : (u.uhunger > 0)
  12.                                                                   ? WEAK
  13.                                                                   : FAINTING;
  14.  
  15.          debugpline0("exerper: Hunger checks");
  16.          switch (hs) {
  17.          case SATIATED:
  18.              exercise(A_DEX, FALSE);
  19.              if (Role_if(PM_MONK))
  20.                  exercise(A_WIS, FALSE);
  21.              break;
  22.          case NOT_HUNGRY:
  23.              exercise(A_CON, TRUE);
  24.              break;
  25.          case WEAK:
  26.              exercise(A_STR, FALSE);
  27.              if (Role_if(PM_MONK)) /* fasting */
  28.                  exercise(A_WIS, TRUE);
  29.              break;
  30.          case FAINTING:
  31.          case FAINTED:
  32.              exercise(A_CON, FALSE);
  33.              break;
  34.          }
  35.  
  36.          /* Encumbrance Checks */
  37.          debugpline0("exerper: Encumber checks");
  38.          switch (near_capacity()) {
  39.          case MOD_ENCUMBER:
  40.              exercise(A_STR, TRUE);
  41.              break;
  42.          case HVY_ENCUMBER:
  43.              exercise(A_STR, TRUE);
  44.              exercise(A_DEX, FALSE);
  45.              break;
  46.          case EXT_ENCUMBER:
  47.              exercise(A_DEX, FALSE);
  48.              exercise(A_CON, FALSE);
  49.              break;
  50.          }
  51.      }
  52.  
  53.      /* status checks */
  54.      if (!(moves % 5)) {
  55.          debugpline0("exerper: Status checks");
  56.          if ((HClairvoyant & (INTRINSIC | TIMEOUT)) && !BClairvoyant)
  57.              exercise(A_WIS, TRUE);
  58.          if (HRegeneration)
  59.              exercise(A_STR, TRUE);
  60.  
  61.          if (Sick || Vomiting)
  62.              exercise(A_CON, FALSE);
  63.          if (Confusion || Hallucination)
  64.              exercise(A_WIS, FALSE);
  65.          if ((Wounded_legs && !u.usteed) || Fumbling || HStun)
  66.              exercise(A_DEX, FALSE);
  67.      }
  68.  }
  69.  
  70.  /* exercise/abuse text (must be in attribute order, not botl order);
  71.     phrased as "You must have been [][0]." or "You haven't been [][1]." */
  72.  static NEARDATA const char *const exertext[A_MAX][2] = {
  73.      { "exercising diligently", "exercising properly" },           /* Str */
  74.      { 0, 0 },                                                     /* Int */
  75.      { "very observant", "paying attention" },                     /* Wis */
  76.      { "working on your reflexes", "working on reflexes lately" }, /* Dex */
  77.      { "leading a healthy life-style", "watching your health" },   /* Con */
  78.      { 0, 0 },                                                     /* Cha */
  79.  };
  80.  

exerchk

  1.  void
  2.  exerchk()
  3.  {
  4.      int i, ax, mod_val, lolim, hilim;
  5.  
  6.      /*  Check out the periodic accumulations */
  7.      exerper();
  8.  
  9.      if (moves >= context.next_attrib_check) {
  10.          debugpline1("exerchk: ready to test. multi = %d.", multi);
  11.      }
  12.      /*  Are we ready for a test? */
  13.      if (moves >= context.next_attrib_check && !multi) {
  14.          debugpline0("exerchk: testing.");
  15.          /*
  16.           *      Law of diminishing returns (Part II):
  17.           *
  18.           *      The effects of "exercise" and "abuse" wear
  19.           *      off over time.  Even if you *don't* get an
  20.           *      increase/decrease, you lose some of the
  21.           *      accumulated effects.
  22.           */
  23.          for (i = 0; i < A_MAX; ++i) {
  24.              ax = AEXE(i);
  25.              /* nothing to do here if no exercise or abuse has occurred
  26.                 (Int and Cha always fall into this category) */
  27.              if (!ax)
  28.                  continue; /* ok to skip nextattrib */
  29.  
  30.              mod_val = sgn(ax); /* +1 or -1; used below */
  31.              /* no further effect for exercise if at max or abuse if at min;
  32.                 can't exceed 18 via exercise even if actual max is higher */
  33.              lolim = ATTRMIN(i); /* usually 3; might be higher */
  34.              hilim = ATTRMAX(i); /* usually 18; maybe lower or higher */
  35.              if (hilim > 18)
  36.                  hilim = 18;
  37.              if ((ax < 0) ? (ABASE(i) <= lolim) : (ABASE(i) >= hilim))
  38.                  goto nextattrib;
  39.              /* can't exercise non-Wisdom while polymorphed; previous
  40.                 exercise/abuse gradually wears off without impact then */
  41.              if (Upolyd && i != A_WIS)
  42.                  goto nextattrib;
  43.  
  44.              debugpline2("exerchk: testing %s (%d).",
  45.                          (i == A_STR)
  46.                              ? "Str"
  47.                              : (i == A_INT)
  48.                                    ? "Int?"
  49.                                    : (i == A_WIS)
  50.                                          ? "Wis"
  51.                                          : (i == A_DEX)
  52.                                                ? "Dex"
  53.                                                : (i == A_CON)
  54.                                                      ? "Con"
  55.                                                      : (i == A_CHA)
  56.                                                            ? "Cha?"
  57.                                                            : "???",
  58.                          ax);
  59.              /*
  60.               *  Law of diminishing returns (Part III):
  61.               *
  62.               *  You don't *always* gain by exercising.
  63.               *  [MRS 92/10/28 - Treat Wisdom specially for balance.]
  64.               */
  65.              if (rn2(AVAL) > ((i != A_WIS) ? (abs(ax) * 2 / 3) : abs(ax)))
  66.                  goto nextattrib;
  67.  
  68.              debugpline1("exerchk: changing %d.", i);
  69.              if (adjattrib(i, mod_val, -1)) {
  70.                  debugpline1("exerchk: changed %d.", i);
  71.                  /* if you actually changed an attrib - zero accumulation */
  72.                  AEXE(i) = ax = 0;
  73.                  /* then print an explanation */
  74.                  You("%s %s.",
  75.                      (mod_val > 0) ? "must have been" : "haven't been",
  76.                      exertext[i][(mod_val > 0) ? 0 : 1]);
  77.              }
  78.          nextattrib:
  79.              /* this used to be ``AEXE(i) /= 2'' but that would produce
  80.                 platform-dependent rounding/truncation for negative vals */
  81.              AEXE(i) = (abs(ax) / 2) * mod_val;
  82.          }
  83.          context.next_attrib_check += rn1(200, 800);
  84.          debugpline1("exerchk: next check at %ld.", context.next_attrib_check);
  85.      }
  86.  }
  87.  

init_attr

  1.  void
  2.  init_attr(np)
  3.  register int np;
  4.  {
  5.      register int i, x, tryct;
  6.  
  7.      for (i = 0; i < A_MAX; i++) {
  8.          ABASE(i) = AMAX(i) = urole.attrbase[i];
  9.          ATEMP(i) = ATIME(i) = 0;
  10.          np -= urole.attrbase[i];
  11.      }
  12.  
  13.      tryct = 0;
  14.      while (np > 0 && tryct < 100) {
  15.          x = rn2(100);
  16.          for (i = 0; (i < A_MAX) && ((x -= urole.attrdist[i]) > 0); i++)
  17.              ;
  18.          if (i >= A_MAX)
  19.              continue; /* impossible */
  20.  
  21.          if (ABASE(i) >= ATTRMAX(i)) {
  22.              tryct++;
  23.              continue;
  24.          }
  25.          tryct = 0;
  26.          ABASE(i)++;
  27.          AMAX(i)++;
  28.          np--;
  29.      }
  30.  
  31.      tryct = 0;
  32.      while (np < 0 && tryct < 100) { /* for redistribution */
  33.  
  34.          x = rn2(100);
  35.          for (i = 0; (i < A_MAX) && ((x -= urole.attrdist[i]) > 0); i++)
  36.              ;
  37.          if (i >= A_MAX)
  38.              continue; /* impossible */
  39.  
  40.          if (ABASE(i) <= ATTRMIN(i)) {
  41.              tryct++;
  42.              continue;
  43.          }
  44.          tryct = 0;
  45.          ABASE(i)--;
  46.          AMAX(i)--;
  47.          np++;
  48.      }
  49.  }
  50.  

redist_attr

  1.  void
  2.  redist_attr()
  3.  {
  4.      register int i, tmp;
  5.  
  6.      for (i = 0; i < A_MAX; i++) {
  7.          if (i == A_INT || i == A_WIS)
  8.              continue;
  9.          /* Polymorphing doesn't change your mind */
  10.          tmp = AMAX(i);
  11.          AMAX(i) += (rn2(5) - 2);
  12.          if (AMAX(i) > ATTRMAX(i))
  13.              AMAX(i) = ATTRMAX(i);
  14.          if (AMAX(i) < ATTRMIN(i))
  15.              AMAX(i) = ATTRMIN(i);
  16.          ABASE(i) = ABASE(i) * AMAX(i) / tmp;
  17.          /* ABASE(i) > ATTRMAX(i) is impossible */
  18.          if (ABASE(i) < ATTRMIN(i))
  19.              ABASE(i) = ATTRMIN(i);
  20.      }
  21.      (void) encumber_msg();
  22.  }
  23.  

postadjabil

  1.  STATIC_OVL
  2.  void
  3.  postadjabil(ability)
  4.  long *ability;
  5.  {
  6.      if (!ability)
  7.          return;
  8.      if (ability == &(HWarning) || ability == &(HSee_invisible))
  9.          see_monsters();
  10.  }
  11.  

role_abil

  1.  STATIC_OVL const struct innate *
  2.  role_abil(r)
  3.  int r;
  4.  {
  5.      const struct {
  6.          short role;
  7.          const struct innate *abil;
  8.      } roleabils[] = {
  9.          { PM_ARCHEOLOGIST, arc_abil },
  10.          { PM_BARBARIAN, bar_abil },
  11.          { PM_CAVEMAN, cav_abil },
  12.          { PM_HEALER, hea_abil },
  13.          { PM_KNIGHT, kni_abil },
  14.          { PM_MONK, mon_abil },
  15.          { PM_PRIEST, pri_abil },
  16.          { PM_RANGER, ran_abil },
  17.          { PM_ROGUE, rog_abil },
  18.          { PM_SAMURAI, sam_abil },
  19.          { PM_TOURIST, tou_abil },
  20.          { PM_VALKYRIE, val_abil },
  21.          { PM_WIZARD, wiz_abil },
  22.          { 0, 0 }
  23.      };
  24.      int i;
  25.  
  26.      for (i = 0; roleabils[i].abil && roleabils[i].role != r; i++)
  27.          continue;
  28.      return roleabils[i].abil;
  29.  }
  30.  

check_innate_abil

  1.  STATIC_OVL const struct innate *
  2.  check_innate_abil(ability, frommask)
  3.  long *ability;
  4.  long frommask;
  5.  {
  6.      const struct innate *abil = 0;
  7.  
  8.      if (frommask == FROMEXPER)
  9.          abil = role_abil(Role_switch);
  10.      else if (frommask == FROMRACE)
  11.          switch (Race_switch) {
  12.          case PM_DWARF:
  13.              abil = dwa_abil;
  14.              break;
  15.          case PM_ELF:
  16.              abil = elf_abil;
  17.              break;
  18.          case PM_GNOME:
  19.              abil = gno_abil;
  20.              break;
  21.          case PM_ORC:
  22.              abil = orc_abil;
  23.              break;
  24.          case PM_HUMAN:
  25.              abil = hum_abil;
  26.              break;
  27.          default:
  28.              break;
  29.          }
  30.  
  31.      while (abil && abil->ability) {
  32.          if ((abil->ability == ability) && (u.ulevel >= abil->ulevel))
  33.              return abil;
  34.          abil++;
  35.      }
  36.      return (struct innate *) 0;
  37.  }
  38.  
  39.  /* reasons for innate ability */
  40.  #define FROM_NONE 0
  41.  #define FROM_ROLE 1 /* from experience at level 1 */
  42.  #define FROM_RACE 2
  43.  #define FROM_INTR 3 /* intrinsically (eating some corpse or prayer reward) */
  44.  #define FROM_EXP  4 /* from experience for some level > 1 */
  45.  #define FROM_FORM 5
  46.  #define FROM_LYCN 6
  47.  

innately

  1.  /* check whether particular ability has been obtained via innate attribute */
  2.  STATIC_OVL int
  3.  innately(ability)
  4.  long *ability;
  5.  {
  6.      const struct innate *iptr;
  7.  
  8.      if ((iptr = check_innate_abil(ability, FROMEXPER)) != 0)
  9.          return (iptr->ulevel == 1) ? FROM_ROLE : FROM_EXP;
  10.      if ((iptr = check_innate_abil(ability, FROMRACE)) != 0)
  11.          return FROM_RACE;
  12.      if ((*ability & FROMOUTSIDE) != 0L)
  13.          return FROM_INTR;
  14.      if ((*ability & FROMFORM) != 0L)
  15.          return FROM_FORM;
  16.      return FROM_NONE;
  17.  }
  18.  

is_innate

  1.  int
  2.  is_innate(propidx)
  3.  int propidx;
  4.  {
  5.      int innateness;
  6.  
  7.      /* innately() would report FROM_FORM for this; caller wants specificity */
  8.      if (propidx == DRAIN_RES && u.ulycn >= LOW_PM)
  9.          return FROM_LYCN;
  10.      if (propidx == FAST && Very_fast)
  11.          return FROM_NONE; /* can't become very fast innately */
  12.      if ((innateness = innately(&u.uprops[propidx].intrinsic)) != FROM_NONE)
  13.          return innateness;
  14.      if (propidx == JUMPING && Role_if(PM_KNIGHT)
  15.          /* knight has intrinsic jumping, but extrinsic is more versatile so
  16.             ignore innateness if equipment is going to claim responsibility */
  17.          && !u.uprops[propidx].extrinsic)
  18.          return FROM_ROLE;
  19.      if (propidx == BLINDED && !haseyes(youmonst.data))
  20.          return FROM_FORM;
  21.      return FROM_NONE;
  22.  }
  23.  

from_what

  1.  char *
  2.  from_what(propidx)
  3.  int propidx; /* special cases can have negative values */
  4.  {
  5.      static char buf[BUFSZ];
  6.  
  7.      buf[0] = '\0';
  8.      /*
  9.       * Restrict the source of the attributes just to debug mode for now
  10.       */
  11.      if (wizard) {
  12.          static NEARDATA const char because_of[] = " because of %s";
  13.  
  14.          if (propidx >= 0) {
  15.              char *p;
  16.              struct obj *obj = (struct obj *) 0;
  17.              int innateness = is_innate(propidx);
  18.  
  19.              /*
  20.               * Properties can be obtained from multiple sources and we
  21.               * try to pick the most significant one.  Classification
  22.               * priority is not set in stone; current precedence is:
  23.               * "from the start" (from role or race at level 1),
  24.               * "from outside" (eating corpse, divine reward, blessed potion),
  25.               * "from experience" (from role or race at level 2+),
  26.               * "from current form" (while polymorphed),
  27.               * "from timed effect" (potion or spell),
  28.               * "from worn/wielded equipment" (Firebrand, elven boots, &c),
  29.               * "from carried equipment" (mainly quest artifacts).
  30.               * There are exceptions.  Versatile jumping from spell or boots
  31.               * takes priority over knight's innate but limited jumping.
  32.               */
  33.              if (propidx == BLINDED && u.uroleplay.blind)
  34.                  Sprintf(buf, " from birth");
  35.              else if (innateness == FROM_ROLE || innateness == FROM_RACE)
  36.                  Strcpy(buf, " innately");
  37.              else if (innateness == FROM_INTR) /* [].intrinsic & FROMOUTSIDE */
  38.                  Strcpy(buf, " intrinsically");
  39.              else if (innateness == FROM_EXP)
  40.                  Strcpy(buf, " because of your experience");
  41.              else if (innateness == FROM_LYCN)
  42.                  Strcpy(buf, " due to your lycanthropy");
  43.              else if (innateness == FROM_FORM)
  44.                  Strcpy(buf, " from current creature form");
  45.              else if (propidx == FAST && Very_fast)
  46.                  Sprintf(buf, because_of,
  47.                          ((HFast & TIMEOUT) != 0L) ? "a potion or spell"
  48.                            : ((EFast & W_ARMF) != 0L && uarmf->dknown
  49.                               && objects[uarmf->otyp].oc_name_known)
  50.                                ? ysimple_name(uarmf) /* speed boots */
  51.                                  : EFast ? "worn equipment"
  52.                                    : something);
  53.              else if (wizard
  54.                       && (obj = what_gives(&u.uprops[propidx].extrinsic)) != 0)
  55.                  Sprintf(buf, because_of, obj->oartifact
  56.                                               ? bare_artifactname(obj)
  57.                                               : ysimple_name(obj));
  58.              else if (propidx == BLINDED && Blindfolded_only)
  59.                  Sprintf(buf, because_of, ysimple_name(ublindf));
  60.  
  61.              /* remove some verbosity and/or redundancy */
  62.              if ((p = strstri(buf, " pair of ")) != 0)
  63.                  copynchars(p + 1, p + 9, BUFSZ); /* overlapping buffers ok */
  64.              else if (propidx == STRANGLED
  65.                       && (p = strstri(buf, " of strangulation")) != 0)
  66.                  *p = '\0';
  67.  
  68.          } else { /* negative property index */
  69.              /* if more blocking capabilities get implemented we'll need to
  70.                 replace this with what_blocks() comparable to what_gives() */
  71.              switch (-propidx) {
  72.              case BLINDED:
  73.                  if (ublindf
  74.                      && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD)
  75.                      Sprintf(buf, because_of, bare_artifactname(ublindf));
  76.                  break;
  77.              case INVIS:
  78.                  if (u.uprops[INVIS].blocked & W_ARMC)
  79.                      Sprintf(buf, because_of,
  80.                              ysimple_name(uarmc)); /* mummy wrapping */
  81.                  break;
  82.              case CLAIRVOYANT:
  83.                  if (wizard && (u.uprops[CLAIRVOYANT].blocked & W_ARMH))
  84.                      Sprintf(buf, because_of,
  85.                              ysimple_name(uarmh)); /* cornuthaum */
  86.                  break;
  87.              }
  88.          }
  89.  
  90.      } /*wizard*/
  91.      return buf;
  92.  }
  93.  

adjabil

  1.  void
  2.  adjabil(oldlevel, newlevel)
  3.  int oldlevel, newlevel;
  4.  {
  5.      register const struct innate *abil, *rabil;
  6.      long prevabil, mask = FROMEXPER;
  7.  
  8.      abil = role_abil(Role_switch);
  9.  
  10.      switch (Race_switch) {
  11.      case PM_ELF:
  12.          rabil = elf_abil;
  13.          break;
  14.      case PM_ORC:
  15.          rabil = orc_abil;
  16.          break;
  17.      case PM_HUMAN:
  18.      case PM_DWARF:
  19.      case PM_GNOME:
  20.      default:
  21.          rabil = 0;
  22.          break;
  23.      }
  24.  
  25.      while (abil || rabil) {
  26.          /* Have we finished with the intrinsics list? */
  27.          if (!abil || !abil->ability) {
  28.              /* Try the race intrinsics */
  29.              if (!rabil || !rabil->ability)
  30.                  break;
  31.              abil = rabil;
  32.              rabil = 0;
  33.              mask = FROMRACE;
  34.          }
  35.          prevabil = *(abil->ability);
  36.          if (oldlevel < abil->ulevel && newlevel >= abil->ulevel) {
  37.              /* Abilities gained at level 1 can never be lost
  38.               * via level loss, only via means that remove _any_
  39.               * sort of ability.  A "gain" of such an ability from
  40.               * an outside source is devoid of meaning, so we set
  41.               * FROMOUTSIDE to avoid such gains.
  42.               */
  43.              if (abil->ulevel == 1)
  44.                  *(abil->ability) |= (mask | FROMOUTSIDE);
  45.              else
  46.                  *(abil->ability) |= mask;
  47.              if (!(*(abil->ability) & INTRINSIC & ~mask)) {
  48.                  if (*(abil->gainstr))
  49.                      You_feel("%s!", abil->gainstr);
  50.              }
  51.          } else if (oldlevel >= abil->ulevel && newlevel < abil->ulevel) {
  52.              *(abil->ability) &= ~mask;
  53.              if (!(*(abil->ability) & INTRINSIC)) {
  54.                  if (*(abil->losestr))
  55.                      You_feel("%s!", abil->losestr);
  56.                  else if (*(abil->gainstr))
  57.                      You_feel("less %s!", abil->gainstr);
  58.              }
  59.          }
  60.          if (prevabil != *(abil->ability)) /* it changed */
  61.              postadjabil(abil->ability);
  62.          abil++;
  63.      }
  64.  
  65.      if (oldlevel > 0) {
  66.          if (newlevel > oldlevel)
  67.              add_weapon_skill(newlevel - oldlevel);
  68.          else
  69.              lose_weapon_skill(oldlevel - newlevel);
  70.      }
  71.  }
  72.  

newhp

  1.  int
  2.  newhp()
  3.  {
  4.      int hp, conplus;
  5.  
  6.      if (u.ulevel == 0) {
  7.          /* Initialize hit points */
  8.          hp = urole.hpadv.infix + urace.hpadv.infix;
  9.          if (urole.hpadv.inrnd > 0)
  10.              hp += rnd(urole.hpadv.inrnd);
  11.          if (urace.hpadv.inrnd > 0)
  12.              hp += rnd(urace.hpadv.inrnd);
  13.          if (moves <= 1L) { /* initial hero; skip for polyself to new man */
  14.              /* Initialize alignment stuff */
  15.              u.ualign.type = aligns[flags.initalign].value;
  16.              u.ualign.record = urole.initrecord;
  17.          }
  18.          /* no Con adjustment for initial hit points */
  19.      } else {
  20.          if (u.ulevel < urole.xlev) {
  21.              hp = urole.hpadv.lofix + urace.hpadv.lofix;
  22.              if (urole.hpadv.lornd > 0)
  23.                  hp += rnd(urole.hpadv.lornd);
  24.              if (urace.hpadv.lornd > 0)
  25.                  hp += rnd(urace.hpadv.lornd);
  26.          } else {
  27.              hp = urole.hpadv.hifix + urace.hpadv.hifix;
  28.              if (urole.hpadv.hirnd > 0)
  29.                  hp += rnd(urole.hpadv.hirnd);
  30.              if (urace.hpadv.hirnd > 0)
  31.                  hp += rnd(urace.hpadv.hirnd);
  32.          }
  33.          if (ACURR(A_CON) <= 3)
  34.              conplus = -2;
  35.          else if (ACURR(A_CON) <= 6)
  36.              conplus = -1;
  37.          else if (ACURR(A_CON) <= 14)
  38.              conplus = 0;
  39.          else if (ACURR(A_CON) <= 16)
  40.              conplus = 1;
  41.          else if (ACURR(A_CON) == 17)
  42.              conplus = 2;
  43.          else if (ACURR(A_CON) == 18)
  44.              conplus = 3;
  45.          else
  46.              conplus = 4;
  47.          hp += conplus;
  48.      }
  49.      if (hp <= 0)
  50.          hp = 1;
  51.      if (u.ulevel < MAXULEV)
  52.          u.uhpinc[u.ulevel] = (xchar) hp;
  53.      return hp;
  54.  }
  55.  

acurr

  1.  schar
  2.  acurr(x)
  3.  int x;
  4.  {
  5.      register int tmp = (u.abon.a[x] + u.atemp.a[x] + u.acurr.a[x]);
  6.  
  7.      if (x == A_STR) {
  8.          if (tmp >= 125 || (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER))
  9.              return (schar) 125;
  10.          else
  11.  #ifdef WIN32_BUG
  12.              return (x = ((tmp <= 3) ? 3 : tmp));
  13.  #else
  14.              return (schar) ((tmp <= 3) ? 3 : tmp);
  15.  #endif
  16.      } else if (x == A_CHA) {
  17.          if (tmp < 18
  18.              && (youmonst.data->mlet == S_NYMPH || u.umonnum == PM_SUCCUBUS
  19.                  || u.umonnum == PM_INCUBUS))
  20.              return (schar) 18;
  21.      } else if (x == A_CON) {
  22.          if (uwep && uwep->oartifact == ART_OGRESMASHER)
  23.              return (schar) 25;
  24.      } else if (x == A_INT || x == A_WIS) {
  25.          /* yes, this may raise int/wis if player is sufficiently
  26.           * stupid.  there are lower levels of cognition than "dunce".
  27.           */
  28.          if (uarmh && uarmh->otyp == DUNCE_CAP)
  29.              return (schar) 6;
  30.      }
  31.  #ifdef WIN32_BUG
  32.      return (x = ((tmp >= 25) ? 25 : (tmp <= 3) ? 3 : tmp));
  33.  #else
  34.      return (schar) ((tmp >= 25) ? 25 : (tmp <= 3) ? 3 : tmp);
  35.  #endif
  36.  }
  37.  

acurrstr

  1.  /* condense clumsy ACURR(A_STR) value into value that fits into game formulas
  2.   */
  3.  schar
  4.  acurrstr()
  5.  {
  6.      register int str = ACURR(A_STR);
  7.  
  8.      if (str <= 18)
  9.          return (schar) str;
  10.      if (str <= 121)
  11.          return (schar) (19 + str / 50); /* map to 19..21 */
  12.      else
  13.          return (schar) (min(str, 125) - 100); /* 22..25 */
  14.  }
  15.  

extremeattr

  1.  /* when wearing (or taking off) an unID'd item, this routine is used
  2.     to distinguish between observable +0 result and no-visible-effect
  3.     due to an attribute not being able to exceed maximum or minimum */
  4.  boolean
  5.  extremeattr(attrindx) /* does attrindx's value match its max or min? */
  6.  int attrindx;
  7.  {
  8.      /* Fixed_abil and racial MINATTR/MAXATTR aren't relevant here */
  9.      int lolimit = 3, hilimit = 25, curval = ACURR(attrindx);
  10.  
  11.      /* upper limit for Str is 25 but its value is encoded differently */
  12.      if (attrindx == A_STR) {
  13.          hilimit = STR19(25); /* 125 */
  14.          /* lower limit for Str can also be 25 */
  15.          if (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER)
  16.              lolimit = hilimit;
  17.      } else if (attrindx == A_CON) {
  18.          if (uwep && uwep->oartifact == ART_OGRESMASHER)
  19.              lolimit = hilimit;
  20.      }
  21.      /* this exception is hypothetical; the only other worn item affecting
  22.         Int or Wis is another helmet so can't be in use at the same time */
  23.      if (attrindx == A_INT || attrindx == A_WIS) {
  24.          if (uarmh && uarmh->otyp == DUNCE_CAP)
  25.              hilimit = lolimit = 6;
  26.      }
  27.  
  28.      /* are we currently at either limit? */
  29.      return (curval == lolimit || curval == hilimit) ? TRUE : FALSE;
  30.  }
  31.  

adjalign

  1.  /* avoid possible problems with alignment overflow, and provide a centralized
  2.     location for any future alignment limits */
  3.  void
  4.  adjalign(n)
  5.  int n;
  6.  {
  7.      int newalign = u.ualign.record + n;
  8.  
  9.      if (n < 0) {
  10.          if (newalign < u.ualign.record)
  11.              u.ualign.record = newalign;
  12.      } else if (newalign > u.ualign.record) {
  13.          u.ualign.record = newalign;
  14.          if (u.ualign.record > ALIGNLIM)
  15.              u.ualign.record = ALIGNLIM;
  16.      }
  17.  }
  18.  

uchangealign

  1.  /* change hero's alignment type, possibly losing use of artifacts */
  2.  void
  3.  uchangealign(newalign, reason)
  4.  int newalign;
  5.  int reason; /* 0==conversion, 1==helm-of-OA on, 2==helm-of-OA off */
  6.  {
  7.      aligntyp oldalign = u.ualign.type;
  8.  
  9.      u.ublessed = 0;   /* lose divine protection */
  10.      context.botl = 1; /* status line needs updating */
  11.      if (reason == 0) {
  12.          /* conversion via altar */
  13.          u.ualignbase[A_CURRENT] = (aligntyp) newalign;
  14.          /* worn helm of opposite alignment might block change */
  15.          if (!uarmh || uarmh->otyp != HELM_OF_OPPOSITE_ALIGNMENT)
  16.              u.ualign.type = u.ualignbase[A_CURRENT];
  17.          You("have a %ssense of a new direction.",
  18.              (u.ualign.type != oldalign) ? "sudden " : "");
  19.      } else {
  20.          /* putting on or taking off a helm of opposite alignment */
  21.          u.ualign.type = (aligntyp) newalign;
  22.          if (reason == 1)
  23.              Your("mind oscillates %s.", Hallucination ? "wildly" : "briefly");
  24.          else if (reason == 2)
  25.              Your("mind is %s.", Hallucination
  26.                                      ? "much of a muchness"
  27.                                      : "back in sync with your body");
  28.      }
  29.  
  30.      if (u.ualign.type != oldalign) {
  31.          u.ualign.record = 0; /* slate is wiped clean */
  32.          retouch_equipment(0);
  33.      }
  34.  }
  35.  
  36.  /*attrib.c*/