diff -rU 4 nethack-3.4.3/include/config.h nethack-elbconduct/include/config.h --- nethack-3.4.3/include/config.h Sun Dec 27 22:04:16 2009 +++ nethack-elbconduct/include/config.h Sun Dec 27 21:49:16 2009 @@ -332,8 +332,10 @@ #if !defined(MAC) # define CLIPPING /* allow smaller screens -- ERS */ #endif +#define ELBERETH_CONDUCT /* Track the number of times the player engraves Elbereth. */ + #ifdef REDO # define DOAGAIN '\001' /* ^A, the "redo" key used in cmd.c and getline.c */ #endif diff -rU 4 nethack-3.4.3/include/you.h nethack-elbconduct/include/you.h --- nethack-3.4.3/include/you.h Sun Dec 27 22:04:18 2009 +++ nethack-elbconduct/include/you.h Sun Dec 27 21:49:16 2009 @@ -68,8 +68,11 @@ long polypiles; /* polymorphed an object */ long polyselfs; /* transformed yourself */ long wishes; /* used a wish */ long wisharti; /* wished for an artifact */ +#ifdef ELBERETH_CONDUCT + long elbereths; /* engraved Elbereth */ +#endif /* genocides already listed at end of game */ }; /*** Unified structure containing role information ***/ diff -rU 4 nethack-3.4.3/src/cmd.c nethack-elbconduct/src/cmd.c --- nethack-3.4.3/src/cmd.c Sun Dec 27 22:04:18 2009 +++ nethack-elbconduct/src/cmd.c Sun Dec 27 21:49:18 2009 @@ -1335,8 +1335,24 @@ enl_msg(You_, "have not wished", "did not wish", " for any artifacts"); } +#ifdef ELBERETH_CONDUCT +#ifdef ELBERETH + /* no point displaying the conduct if Elbereth doesn't do anything */ + if (u.uconduct.elbereths) { + Sprintf(buf, "engraved Elbereth %ld time%s", + u.uconduct.elbereths, plur(u.uconduct.elbereths)); + you_have_X(buf); + } +#ifdef WIZARD + else if (wizard) { + you_have_never("engraved Elbereth"); + } +#endif /* WIZARD */ +#endif /* ELBERETH */ +#endif /* ELBERETH_CONDUCT */ + /* Pop up the window and wait for a key */ display_nhwindow(en_win, TRUE); destroy_nhwindow(en_win); } diff -rU 4 nethack-3.4.3/src/engrave.c nethack-elbconduct/src/engrave.c --- nethack-3.4.3/src/engrave.c Sun Dec 27 22:04:18 2009 +++ nethack-elbconduct/src/engrave.c Sun Dec 27 22:03:00 2009 @@ -235,8 +235,38 @@ ep->engr_time <= moves && strstri(ep->engr_txt, s) != 0); } #endif /* ELBERETH */ +#ifdef ELBERETH_CONDUCT +/* Return the number of distinct times Elbereth is engraved at + * the specified location. Case insensitive. Counts an engraving + * as being present even if it's still being written: if you're + * killed while trying to write Elbereth, it still violates the + * conduct (mainly because it's easier to implement that way). + */ +unsigned nengr_at(s, x, y) + const char *s; + xchar x, y; +{ + register struct engr *ep = engr_at(x, y); + unsigned count = 0; + const char *p; + + if (!ep || HEADSTONE == ep->engr_type) + return 0; + + p = ep->engr_txt; + while (strstri(p, s)) { + count++; + p += 8; + } + + return count; +} + +#endif /* ELBERETH_CONDUCT */ + + #endif /* OVL0 */ #ifdef OVL2 void @@ -851,10 +881,10 @@ } /* Something has changed the engraving here */ if (*buf) { - make_engr_at(u.ux, u.uy, buf, moves, type); - pline_The("engraving now reads: \"%s\".", buf); + make_engr_at(u.ux, u.uy, buf, moves, type); + pline_The("engraving now reads: \"%s\".", buf); ptext = FALSE; } if (zapwand && (otmp->spe < 0)) { @@ -1097,9 +1127,19 @@ if (oep) Strcpy(buf, oep->engr_txt); (void) strncat(buf, ebuf, (BUFSZ - (int)strlen(buf) - 1)); - make_engr_at(u.ux, u.uy, buf, (moves - multi), type); +#ifdef ELBERETH_CONDUCT + { + unsigned ecount1, ecount0 = nengr_at("Elbereth", u.ux, u.uy); + make_engr_at(u.ux, u.uy, buf, moves, type); + ecount1 = nengr_at("Elbereth", u.ux, u.uy); + if (ecount1 > ecount0) + u.uconduct.elbereths += (ecount1 - ecount0); + } +#else + make_engr_at(u.ux, u.uy, buf, moves, type); +#endif if (post_engr_text[0]) pline(post_engr_text); if (doblind && !resists_blnd(&youmonst)) {