Guest User

NetHack scroll of epitaph patch v1.1

a guest
Nov 23rd, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 9.28 KB | None | 0 0
  1. diff --git i/include/extern.h w/include/extern.h
  2. index b6f4825..bd69e6a 100644
  3. --- i/include/extern.h
  4. +++ w/include/extern.h
  5. @@ -137,6 +137,7 @@ E void NDECL(drag_down);
  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. @@ -713,6 +714,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 i/src/bones.c w/src/bones.c
  22. index 33f5f2c..c8a9afb 100644
  23. --- i/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 i/src/end.c w/src/end.c
  40. index d0b51df..868c7af 100644
  41. --- i/src/end.c
  42. +++ w/src/end.c
  43. @@ -1068,6 +1068,27 @@ int how;
  44.          killer.format = 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.  }
  70.  
  71. diff --git i/src/engrave.c w/src/engrave.c
  72. index 48dc2bd..59eda37 100644
  73. --- i/src/engrave.c
  74. +++ w/src/engrave.c
  75. @@ -1286,4 +1286,151 @@ const char *str;
  76.      return;
  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 wipe = cursed ? lth / 4 : lth / 16;
  119. +        if (wipe == 0) wipe = cursed ? !rn2(4) : !rn2(16);
  120. +        wipeout_text(buf, wipe, 0);
  121. +      }
  122. +
  123. +    x = y = 0;
  124. +    br = Is_branchlev(&u.uz);
  125. +    if (br && on_level(&u.uz, &br->end2))
  126. +        switch (br->type) {
  127. +        case BR_STAIR:
  128. +        case BR_NO_END1:
  129. +            x = sstairs.sx;
  130. +            y = sstairs.sy;
  131. +            break;
  132. +        case BR_PORTAL:
  133. +            for (trap = ftrap; trap; trap = trap->ntrap)
  134. +                if (trap->ttyp == MAGIC_PORTAL)
  135. +                  {
  136. +                    x = trap->tx;
  137. +                    y = trap->ty;
  138. +                    break;
  139. +                  }
  140. +            break;
  141. +        case BR_NO_END2:
  142. +            /* We're in a branch with no exit!
  143. +             * Only the planes normally do this,
  144. +             * and we checked for them above...
  145. +             * Let's try something anyway. */
  146. +            entr = builds_up(&u.uz) ? &dndest : &updest;
  147. +            for (tries = 0; tries < 100; tries++)
  148. +              {
  149. +                tryx = entr->lx ? rn1((entr->hx - entr->lx) + 1, entr->lx)
  150. +                                : rnd(COLNO - 1);
  151. +                tryy = entr->lx ? rn1((entr->hy - entr->ly) + 1, entr->ly)
  152. +                                : rn2(ROWNO);
  153. +                if (!bad_location(tryx, tryy, entr->nlx, entr->nly,
  154. +                                  entr->nhx, entr->nhy))
  155. +                  {
  156. +                    x = tryx;
  157. +                    y = tryy;
  158. +                    break;
  159. +                  }
  160. +              }
  161. +            break;
  162. +        }
  163. +    else if (u.uz.dnum == 0 && u.uz.dlevel == 1)
  164. +      {
  165. +        /* special case: the stair to the surface */
  166. +        x = sstairs.sx;
  167. +        y = sstairs.sy;
  168. +      }
  169. +    else if (builds_up(&u.uz))
  170. +      {
  171. +        /* We're assuming that existing stairs are the primary exit.
  172. +         * It can be argued that in the wizard's tower
  173. +         * the scroll should engrave on the downladder,
  174. +         * but the bones contain the entire level and the 'successor'
  175. +         * will most likely encounter the outside part first. */
  176. +        if (xdnstair)
  177. +          {
  178. +            x = xdnstair;
  179. +            y = ydnstair;
  180. +          }
  181. +        else
  182. +          {
  183. +            x = xdnladder;
  184. +            y = ydnladder;
  185. +          }
  186. +      }
  187. +    else
  188. +      {
  189. +        if (xupstair)
  190. +          {
  191. +            x = xupstair;
  192. +            y = yupstair;
  193. +          }
  194. +        else
  195. +          {
  196. +            x = xupladder;
  197. +            y = yupladder;
  198. +          }
  199. +      }
  200. +
  201. +    if (!x || !*buf)
  202. +      {
  203. +        /* something went wrong or the message was erased */
  204. +        Your("message went unheeded...");
  205. +        return;
  206. +      }
  207. +    make_engr_at(x, y, buf, moves,
  208. +                 blessed ? BURN : cursed ? ENGR_BLOOD : MARK);
  209. +    if (dead)
  210. +      {
  211. +        /* give some feedback */
  212. +        pline("Hopefully the others will be forewarned now.");
  213. +        return;
  214. +      }
  215. +    dist = distu(x, y);
  216. +    if (!dist && !Blind && !u.uswallow)
  217. +        pline("A message appears below you!");
  218. +    else if (cansee(x, y))
  219. +        You_see("a message appear on the %s nearby.",
  220. +                dfeature_at(x, y, buf) ? buf : surface(x, y));
  221. +    else if (!Deaf)
  222. +        You_hear("a %sscribing noise.", dist > 25 ? "faint " : "");
  223. +    return;
  224. +}
  225. +
  226.  /*engrave.c*/
  227. diff --git i/src/mklev.c w/src/mklev.c
  228. index 5f6afff..96ef22f 100644
  229. --- i/src/mklev.c
  230. +++ w/src/mklev.c
  231. @@ -1645,6 +1645,9 @@ struct mkroom *croom;
  232.      /* Leave a bell, in case we accidentally buried someone alive */
  233.      if (dobell)
  234.          (void) mksobj_at(BELL, m.x, m.y, TRUE, FALSE);
  235. +    /* Some graves have extra epitaphs */
  236. +    else if (!rn2(9))
  237. +        (void) mksobj_at(SCR_EPITAPH, m.x, m.y, TRUE, FALSE);
  238.      return;
  239.  }
  240.  
  241. diff --git i/src/objects.c w/src/objects.c
  242. index 3a8db8d..efe4085 100644
  243. --- i/src/objects.c
  244. +++ w/src/objects.c
  245. @@ -834,7 +834,8 @@ SCROLL("enchant weapon",         "DAIYEN FOOELS",  1,  80,  60),
  246.  SCROLL("create monster",       "LEP GEX VEN ZEA",  1,  45, 200),
  247.  SCROLL("taming",                   "PRIRUTSENIE",  1,  15, 200),
  248.  SCROLL("genocide",                  "ELBIB YLOH",  1,  15, 300),
  249. -SCROLL("light",                 "VERR YED HORRE",  1,  90,  50),
  250. +SCROLL("light",                 "VERR YED HORRE",  1,  70,  50),
  251. +SCROLL("epitaph",           "REQUIESCAT IN PACE",  1,  20,  50),
  252.  SCROLL("teleportation",        "VENZAR BORGAVVE",  1,  55, 100),
  253.  SCROLL("gold detection",                 "THARR",  1,  33, 100),
  254.  SCROLL("food detection",               "YUM YUM",  1,  25, 100),
  255. diff --git i/src/read.c w/src/read.c
  256. index 02cb79b..397ea85 100644
  257. --- i/src/read.c
  258. +++ w/src/read.c
  259. @@ -1454,6 +1454,29 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
  260.                                     TRUE);
  261.          }
  262.          break;
  263. +    case SCR_EPITAPH:
  264. +        if (confused)
  265. +          {
  266. +            if (levl[u.ux][u.uy].typ != GRAVE)
  267. +                make_grave(u.ux, u.uy, (char *) 0);
  268. +            if (levl[u.ux][u.uy].typ == GRAVE)
  269. +              {
  270. +                You("spend a minute dwelling on the fate "
  271. +                    "of those who went before you.");
  272. +                newsym(u.ux, u.uy);
  273. +              }
  274. +            else
  275. +                pline("This is hardly the proper time " /* or place */
  276. +                      "to reminisce about the dead.");
  277. +          }
  278. +        else
  279. +          {
  280. +            known = 1;
  281. +            if (!already_known) /* "was" is intentional */
  282. +                pline("This was a scroll of epitaph.");
  283. +            engrave_on_upstairs(sobj, FALSE);
  284. +          }
  285. +        break;
  286.      case SCR_TELEPORTATION:
  287.          if (confused || scursed) {
  288.              level_tele();
Add Comment
Please, Sign In to add comment