Guest User

NetHack scroll of epitaph patch v1.2

a guest
Sep 2nd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 9.40 KB | None | 0 0
  1. diff --git c/include/extern.h w/include/extern.h
  2. index 6959e24..0b2a28e 100644
  3. --- c/include/extern.h
  4. +++ w/include/extern.h
  5. @@ -139,6 +139,7 @@ E void NDECL(bc_sanity_check);
  6.  
  7.  /* ### bones.c ### */
  8.  
  9. +E boolean FDECL(no_bones_level, (d_level *));
  10.  E void FDECL(sanitize_name, (char *));
  11.  E void FDECL(drop_upon_death, (struct monst *, struct obj *, int, int));
  12.  E boolean NDECL(can_make_bones);
  13. @@ -729,6 +730,7 @@ E void FDECL(engr_stats, (const char *, char *, long *, long *));
  14.  E void FDECL(del_engr, (struct engr *));
  15.  E void FDECL(rloc_engr, (struct engr *));
  16.  E void FDECL(make_grave, (int, int, const char *));
  17. +E void FDECL(engrave_on_upstairs, (struct obj *, BOOLEAN_P));
  18.  
  19.  /* ### exper.c ### */
  20.  
  21. diff --git c/src/bones.c w/src/bones.c
  22. index 0a7b817..e884242 100644
  23. --- c/src/bones.c
  24. +++ w/src/bones.c
  25. @@ -11,12 +11,11 @@ extern char bones[]; /* from files.c */
  26.  extern long bytes_counted;
  27.  #endif
  28.  
  29. -STATIC_DCL boolean FDECL(no_bones_level, (d_level *));
  30.  STATIC_DCL void FDECL(goodfruit, (int));
  31.  STATIC_DCL void FDECL(resetobjs, (struct obj *, BOOLEAN_P));
  32.  STATIC_DCL boolean FDECL(fixuporacle, (struct monst *));
  33.  
  34. -STATIC_OVL boolean
  35. +boolean
  36.  no_bones_level(lev)
  37.  d_level *lev;
  38.  {
  39. diff --git c/src/end.c w/src/end.c
  40. index ecf71a4..596f461 100644
  41. --- c/src/end.c
  42. +++ w/src/end.c
  43. @@ -1136,6 +1136,27 @@ int how;
  44.          killer.format = KILLED_BY_AN; /* reset to 0 */
  45.          return;
  46.      }
  47. +    /* not intended to be a comprehensive check */
  48. +    if (how < GENOCIDED && flags.bones
  49. +        && ledger_no(&u.uz) > 0 && !no_bones_level(&u.uz))
  50. +      {
  51. +        /* Logically some kinds of death should destroy your inventory, too,
  52. +         * but currently even disintegration preserves your stuff in bones.
  53. +         * So, we assume you do have a pack. */
  54. +        struct obj *otmp;
  55. +        for (otmp = invent; otmp; otmp = otmp->nobj)
  56. +            if (otmp->otyp == SCR_EPITAPH && otmp->blessed)
  57. +              {
  58. +                if (!rn2(2))
  59. +                  {
  60. +                    pline("%s in your pack unfurls and begins to glow...",
  61. +                          The(cxname_singular(otmp)));
  62. +                    engrave_on_upstairs(otmp, TRUE);
  63. +                    useup(otmp);
  64. +                  }
  65. +                break;
  66. +              }
  67. +      }
  68.      really_done(how);
  69.      /*NOTREACHED*/
  70.  }
  71. diff --git c/src/engrave.c w/src/engrave.c
  72. index d127c44..891e64a 100644
  73. --- c/src/engrave.c
  74. +++ w/src/engrave.c
  75. @@ -1326,4 +1326,153 @@ blengr(VOID_ARGS)
  76.      return blind_writing[rn2(SIZE(blind_writing))];
  77.  }
  78.  
  79. +void
  80. +engrave_on_upstairs(sobj, dead)
  81. +struct obj *sobj;
  82. +boolean dead;
  83. +{
  84. +    char buf[BUFSZ];
  85. +    int lth;
  86. +    int x, y;
  87. +    branch *br;
  88. +    int dist;
  89. +    struct trap *trap;
  90. +    struct dest_area *entr;
  91. +    int tries;
  92. +    int tryx, tryy;
  93. +    boolean blessed = sobj && sobj->blessed;
  94. +    boolean cursed = sobj && sobj->cursed;
  95. +
  96. +    if (In_endgame(&u.uz))
  97. +      {
  98. +        pline("This close to victory, "
  99. +              "you decide against leaving notes to others.");
  100. +        /* cannot leave bones anyway! */
  101. +        return;
  102. +      }
  103. +    if (dead)
  104. +        pline("From beyond the grave, "
  105. +              "you are allowed to leave one last message to your successors.");
  106. +    else
  107. +        You("may leave a message to your successors.");
  108. +    getlin("What do you want to convey?", buf);
  109. +    mungspaces(buf);
  110. +    lth = strlen(buf);
  111. +    if (lth == 0 || lth == 1 && buf[0] == ' ' || index(buf, '\033'))
  112. +      {
  113. +        pline1(Never_mind);
  114. +        return;
  115. +      }
  116. +    if (!blessed)
  117. +      {
  118. +        int divisor = cursed ? 4 : 16;
  119. +        int wipe = lth / divisor;
  120. +        if (wipe == 0)
  121. +            wipe = rn2(divisor) < lth;
  122. +        wipeout_text(buf, wipe, 0);
  123. +      }
  124. +
  125. +    x = y = 0;
  126. +    br = Is_branchlev(&u.uz);
  127. +    if (br && on_level(&u.uz, &br->end2))
  128. +        switch (br->type) {
  129. +        case BR_STAIR:
  130. +        case BR_NO_END1:
  131. +            x = sstairs.sx;
  132. +            y = sstairs.sy;
  133. +            break;
  134. +        case BR_PORTAL:
  135. +            for (trap = ftrap; trap; trap = trap->ntrap)
  136. +                if (trap->ttyp == MAGIC_PORTAL)
  137. +                  {
  138. +                    x = trap->tx;
  139. +                    y = trap->ty;
  140. +                    break;
  141. +                  }
  142. +            break;
  143. +        case BR_NO_END2:
  144. +            /* We're in a branch with no exit!
  145. +             * Only the planes normally do this,
  146. +             * and we checked for them above...
  147. +             * Let's try something anyway. */
  148. +            entr = builds_up(&u.uz) ? &dndest : &updest;
  149. +            for (tries = 0; tries < 100; tries++)
  150. +              {
  151. +                tryx = entr->lx ? rn1((entr->hx - entr->lx) + 1, entr->lx)
  152. +                                : rnd(COLNO - 1);
  153. +                tryy = entr->lx ? rn1((entr->hy - entr->ly) + 1, entr->ly)
  154. +                                : rn2(ROWNO);
  155. +                if (!bad_location(tryx, tryy, entr->nlx, entr->nly,
  156. +                                  entr->nhx, entr->nhy))
  157. +                  {
  158. +                    x = tryx;
  159. +                    y = tryy;
  160. +                    break;
  161. +                  }
  162. +              }
  163. +            break;
  164. +        }
  165. +    else if (u.uz.dnum == 0 && u.uz.dlevel == 1)
  166. +      {
  167. +        /* special case: the stair to the surface */
  168. +        x = sstairs.sx;
  169. +        y = sstairs.sy;
  170. +      }
  171. +    else if (builds_up(&u.uz))
  172. +      {
  173. +        /* We're assuming that existing stairs are the primary exit.
  174. +         * It can be argued that in the wizard's tower
  175. +         * the scroll should engrave on the downladder,
  176. +         * but the bones contain the entire level and the 'successor'
  177. +         * will most likely encounter the outside part first. */
  178. +        if (xdnstair)
  179. +          {
  180. +            x = xdnstair;
  181. +            y = ydnstair;
  182. +          }
  183. +        else
  184. +          {
  185. +            x = xdnladder;
  186. +            y = ydnladder;
  187. +          }
  188. +      }
  189. +    else
  190. +      {
  191. +        if (xupstair)
  192. +          {
  193. +            x = xupstair;
  194. +            y = yupstair;
  195. +          }
  196. +        else
  197. +          {
  198. +            x = xupladder;
  199. +            y = yupladder;
  200. +          }
  201. +      }
  202. +
  203. +    if (!x || !*buf)
  204. +      {
  205. +        /* something went wrong or the message was erased */
  206. +        Your("message went unheeded...");
  207. +        return;
  208. +      }
  209. +    make_engr_at(x, y, buf, moves,
  210. +                 blessed ? BURN : cursed ? ENGR_BLOOD : MARK);
  211. +    if (dead)
  212. +      {
  213. +        /* give some feedback */
  214. +        pline("Hopefully the others will be forewarned now.");
  215. +        return;
  216. +      }
  217. +    dist = distu(x, y);
  218. +    if (!dist && !Blind && !u.uswallow)
  219. +        pline("A message appears below you!");
  220. +    else if (cansee(x, y))
  221. +        You_see("a message appear on the %s nearby.",
  222. +                dfeature_at(x, y, buf) ? buf : surface(x, y));
  223. +    else if (!Deaf)
  224. +        You_hear("a %sscribing noise.", dist > 25 ? "faint " : "");
  225. +    return;
  226. +}
  227. +
  228.  /*engrave.c*/
  229. diff --git c/src/mklev.c w/src/mklev.c
  230. index 7448feb..e3ce3d2 100644
  231. --- c/src/mklev.c
  232. +++ w/src/mklev.c
  233. @@ -1673,6 +1673,9 @@ struct mkroom *croom;
  234.      /* Leave a bell, in case we accidentally buried someone alive */
  235.      if (dobell)
  236.          (void) mksobj_at(BELL, m.x, m.y, TRUE, FALSE);
  237. +    /* Some graves have extra epitaphs */
  238. +    else if (!rn2(9))
  239. +        (void) mksobj_at(SCR_EPITAPH, m.x, m.y, TRUE, FALSE);
  240.      return;
  241.  }
  242.  
  243. diff --git c/src/objects.c w/src/objects.c
  244. index fcca3b0..cc96fc9 100644
  245. --- c/src/objects.c
  246. +++ w/src/objects.c
  247. @@ -834,7 +834,8 @@ SCROLL("enchant weapon",         "DAIYEN FOOELS",  1,  80,  60),
  248.  SCROLL("create monster",       "LEP GEX VEN ZEA",  1,  45, 200),
  249.  SCROLL("taming",                   "PRIRUTSENIE",  1,  15, 200),
  250.  SCROLL("genocide",                  "ELBIB YLOH",  1,  15, 300),
  251. -SCROLL("light",                 "VERR YED HORRE",  1,  90,  50),
  252. +SCROLL("light",                 "VERR YED HORRE",  1,  70,  50),
  253. +SCROLL("epitaph",           "REQUIESCAT IN PACE",  1,  20,  50),
  254.  SCROLL("teleportation",        "VENZAR BORGAVVE",  1,  55, 100),
  255.  SCROLL("gold detection",                 "THARR",  1,  33, 100),
  256.  SCROLL("food detection",               "YUM YUM",  1,  25, 100),
  257. diff --git c/src/read.c w/src/read.c
  258. index 562b52b..87cbb7f 100644
  259. --- c/src/read.c
  260. +++ w/src/read.c
  261. @@ -1459,6 +1459,29 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
  262.                                     TRUE);
  263.          }
  264.          break;
  265. +    case SCR_EPITAPH:
  266. +        if (confused)
  267. +          {
  268. +            if (levl[u.ux][u.uy].typ != GRAVE)
  269. +                make_grave(u.ux, u.uy, (char *) 0);
  270. +            if (levl[u.ux][u.uy].typ == GRAVE)
  271. +              {
  272. +                You("spend a minute dwelling on the fate "
  273. +                    "of those who went before you.");
  274. +                newsym(u.ux, u.uy);
  275. +              }
  276. +            else
  277. +                pline("This is hardly the proper time " /* or place */
  278. +                      "to reminisce about the dead.");
  279. +          }
  280. +        else
  281. +          {
  282. +            known = 1;
  283. +            if (!already_known) /* "was" is intentional */
  284. +                pline("This was a scroll of epitaph.");
  285. +            engrave_on_upstairs(sobj, FALSE);
  286. +          }
  287. +        break;
  288.      case SCR_TELEPORTATION:
  289.          if (confused || scursed) {
  290.              level_tele();
Add Comment
Please, Sign In to add comment