From d01bec9fae5a025b40b32924dedc53b98bf93cf2 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 18 Mar 2015 21:47:18 -0400 Subject: [PATCH] rare books store tribute --- include/context.h | 11 +++++++++++ include/extern.h | 1 + src/allmain.c | 3 +++ src/do_name.c | 31 ++++++++++++++++++++++++++++++ src/mkobj.c | 2 ++ src/mon.c | 2 -- src/objects.c | 3 +++ src/objnam.c | 12 ++++++++++++ src/shknam.c | 44 +++++++++++++++++++++++++++++++++++++++---- src/spell.c | 24 ++++++++++++++++++++--- win/share/objects.txt | 19 +++++++++++++++++++ 11 files changed, 143 insertions(+), 9 deletions(-) diff --git a/include/context.h b/include/context.h index ebfe1ada7..22a43fa02 100644 --- a/include/context.h +++ b/include/context.h @@ -73,6 +73,16 @@ struct warntype_info { short speciesidx; /* index of above in mons[] (for save/restore) */ }; +struct tribute_info { + size_t tributesz; /* make it possible to skip this in future */ + char *name; /* what is this tribute for */ + boolean enabled; /* Do we have tributes turned on? */ + Bitfield(book,1); /* Have we completed the book tribute? */ + /* Markers for other tributes can go here */ + /* 31 free bits */ + int bookidx; +}; + struct context_info { unsigned ident; /* social security number for each monster */ unsigned no_of_wizards; /* 0, 1 or 2 (wizard and his shadow) */ @@ -103,6 +113,7 @@ struct context_info { struct book_info spbook; struct takeoff_info takeoff; struct warntype_info warntype; + struct tribute_info tribute; }; extern NEARDATA struct context_info context; diff --git a/include/extern.h b/include/extern.h index 23d10d324..f0c8e8c74 100644 --- a/include/extern.h +++ b/include/extern.h @@ -394,6 +394,7 @@ E const char *NDECL(roguename); E struct obj *FDECL(realloc_obj, (struct obj *, int, genericptr_t, int, const char *)); E char *FDECL(coyotename, (struct monst *,char *)); +E const char *FDECL(noveltitle, (int *)); /* ### do_wear.c ### */ diff --git a/src/allmain.c b/src/allmain.c index eb1f2b69b..7224dd284 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -487,6 +487,9 @@ newgame() context.stethoscope_move = -1L; context.warnlevel = 1; context.next_attrib_check = 600L; /* arbitrary first setting */ + context.tribute.enabled = TRUE; /* turn on 3.6 tributes */ + context.tribute.tributesz = sizeof(struct tribute_info); + context.tribute.bookidx = 0; for (i = 0; i < NUMMONS; i++) mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; diff --git a/src/do_name.c b/src/do_name.c index 0f837c9d4..6618b5802 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1123,4 +1123,35 @@ char *buf; return buf; } +static const char * const sir_Terry_novels[] = { + "The Colour of Magic", "The Light Fantastic", "Equal Rites", + "Mort", "Sourcery", "Wyrd Sisters", "Pyramids", "Guards! Guards!", + "Eric", "Moving Pictures", "Reaper Man", "Witches Abroad", + "Small Gods", "Lords and Ladies", "Men at Arms", "Soul Music", + "Interesting Times", "Maskerade", "Feet of Clay", "Hogfather", + "Jingo", "The Last Continent", "Carpe Jugulum", "The Fifth Elephant", + "The Truth", "Thief of Time", "The Last Hero", + "The Amazing Maurice and his Educated Rodents", "Night Watch", + "The Wee Free Men", "Monstrous Regiment", "A Hat Full of Sky", + "Going Postal", "Thud!", "Wintersmith", "Making Money", + "Unseen Academicals", "I Shall Wear Midnight", "Snuff", + "Raising Steam", "The Shepherd's Crown" +}; + +const char * +noveltitle(novidx) +int *novidx; +{ + int j, k = SIZE(sir_Terry_novels)-1; + + j = rn2(k); + if (novidx) { + if (*novidx == -1) *novidx = j; + else if ((*novidx >= 0) && (*novidx <= k)) j = *novidx; + } + return sir_Terry_novels[j]; +} + + + /*do_name.c*/ diff --git a/src/mkobj.c b/src/mkobj.c index 4092401cd..77c39ce7a 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -861,6 +861,8 @@ boolean artif; /* case TIN: */ set_corpsenm(otmp, otmp->corpsenm); break; + case SPE_NOVEL: + break; } /* unique objects may have an associated artifact entry */ diff --git a/src/mon.c b/src/mon.c index d9bc63d6d..fb0a75a57 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1604,8 +1604,6 @@ register struct monst *mtmp; } if(mtmp->iswiz) wizdead(); if(mtmp->data->msound == MS_NEMESIS) nemdead(); - if(mtmp->data == &mons[PM_MEDUSA]) - u.uachieve.killed_medusa = 1; if(glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) unmap_object(mtmp->mx, mtmp->my); m_detach(mtmp, mptr); diff --git a/src/objects.c b/src/objects.c index 4c015595d..b7fe5c86a 100644 --- a/src/objects.c +++ b/src/objects.c @@ -821,6 +821,9 @@ SPELL("freeze sphere", "hardcover", P_MATTER_SPELL, 20, 2, 1, 1, NODIR, CLR #endif /* blank spellbook must come last because it retains its description */ SPELL("blank paper", "plain", P_NONE, 18, 0, 0, 0, 0, HI_PAPER), +/* tribute book for 3.6 */ +OBJECT(OBJ("novel", "printed"), BITS(0,0,1,0,0,0,0,1,0,0,0,P_NONE,HI_PAPER), 0, + SPBOOK_CLASS, 0, 0, 0, 1, 0, 0, 0, 1, 20, CLR_BRIGHT_BLUE), /* a special, one of a kind, spellbook */ OBJECT(OBJ("Book of the Dead", "papyrus"), BITS(0,0,1,0,1,0,1,1,0,0,0,P_NONE,PAPER), 0, SPBOOK_CLASS, 0, 0,20, 10000, 0, 0, 0, 7, 20, HI_PAPER), diff --git a/src/objnam.c b/src/objnam.c index fe692b226..5a131fdf8 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -448,6 +448,18 @@ register struct obj *obj; Sprintf(buf, "%s wand", dn); break; case SPBOOK_CLASS: + if (typ == SPE_NOVEL) { /* 3.6 tribute */ + if (!dknown) { + Strcpy(buf, "book"); + } else if (nn) { + Strcpy(buf, actualn); + } else if (un) { + Sprintf(buf, "novel called %s", un); + } else + Sprintf(buf, "%s book", dn); + break; + } else + /* end of tribute */ if (!dknown) { Strcpy(buf, "spellbook"); } else if (nn) { diff --git a/src/shknam.c b/src/shknam.c index 645fc6b58..ae1776cc4 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -10,7 +10,7 @@ STATIC_DCL boolean FDECL(veggy_item, (struct obj *obj,int)); STATIC_DCL int NDECL(shkveg); STATIC_DCL void FDECL(mkveggy_at, (int,int)); -STATIC_DCL void FDECL(mkshobj_at, (const struct shclass *,int,int)); +STATIC_DCL void FDECL(mkshobj_at, (const struct shclass *,int,int,BOOLEAN_P)); STATIC_DCL void FDECL(nameshk, (struct monst *,const char * const *)); STATIC_DCL int FDECL(shkinit, (const struct shclass *,struct mkroom *)); @@ -357,15 +357,26 @@ int sx, sy; } STATIC_OVL void -mkshobj_at(shp, sx, sy) +mkshobj_at(shp, sx, sy, mkspecl) /* make an object of the appropriate type for a shop square */ const struct shclass *shp; int sx, sy; +boolean mkspecl; { struct monst *mtmp; int atype; struct permonst *ptr; + /* 3.6 tribute */ + if (mkspecl && !strcmp(shp->name, "rare books")) { + int novidx = -1; /* -1 triggers random noveltitle() */ + struct obj *novel=mksobj_at(SPE_NOVEL, sx, sy, FALSE, FALSE); + if (novel) novel = oname(novel, noveltitle(&novidx)); + context.tribute.bookidx = novidx; + context.tribute.book = 1; + return; + } + if (rn2(100) < depth(&u.uz) && !MON_AT(sx, sy) && (ptr = mkclass(S_MIMIC,0)) && (mtmp = makemon(ptr,sx,sy,NO_MM_FLAGS)) != 0) { @@ -572,7 +583,8 @@ register struct mkroom *sroom; * shop-style placement (all squares except a row nearest the first * door get objects). */ - register int sx, sy, sh; + int sx, sy, sh; + int stockcount = 0, specialspot = 0; char buf[BUFSZ]; int rmno = (int)((sroom - rooms) + ROOMOFFSET); const struct shclass *shp = &shtypes[shp_indx]; @@ -608,6 +620,29 @@ register struct mkroom *sroom; make_engr_at(m, n, buf, 0L, DUST); } + if (context.tribute.enabled && !context.tribute.book) { + /* + * Out of the number of spots where we're actually + * going to put stuff, randomly single out one in particular. + */ + for (sx = sroom->lx; sx <= sroom->hx; sx++) + for (sy = sroom->ly; sy <= sroom->hy; sy++) { + if (sroom->irregular) { + if (levl[sx][sy].edge || (int)levl[sx][sy].roomno != rmno || + distmin(sx, sy, doors[sh].x, doors[sh].y) <= 1) + continue; + } + else if ((sx == sroom->lx && doors[sh].x == sx - 1) || + (sx == sroom->hx && doors[sh].x == sx + 1) || + (sy == sroom->ly && doors[sh].y == sy - 1) || + (sy == sroom->hy && doors[sh].y == sy + 1)) continue; + stockcount++; + } + specialspot = rnd(stockcount); + stockcount = 0; + } + + for(sx = sroom->lx; sx <= sroom->hx; sx++) for(sy = sroom->ly; sy <= sroom->hy; sy++) { if(sroom->irregular) { @@ -618,7 +653,8 @@ register struct mkroom *sroom; (sx == sroom->hx && doors[sh].x == sx+1) || (sy == sroom->ly && doors[sh].y == sy-1) || (sy == sroom->hy && doors[sh].y == sy+1)) continue; - mkshobj_at(shp, sx, sy); + stockcount++; + mkshobj_at(shp, sx, sy, ((stockcount) && (stockcount == specialspot))); } /* diff --git a/src/spell.c b/src/spell.c index 53b8626f0..05782cbae 100644 --- a/src/spell.c +++ b/src/spell.c @@ -411,8 +411,9 @@ int study_book(spellbook) register struct obj *spellbook; { - register int booktype = spellbook->otyp; - register boolean confused = (Confusion != 0); + int booktype = spellbook->otyp; + boolean confused = (Confusion != 0); + const char *whatchadoin = "memorize the spell"; boolean too_hard = FALSE; /* attempting to read dull book may make hero fall asleep */ @@ -440,7 +441,8 @@ register struct obj *spellbook; /* handle the sequence: start reading, get interrupted, have context.spbook.book become erased somehow, resume reading it */ booktype != SPE_BLANK_PAPER) { - You("continue your efforts to memorize the spell."); + You("continue your efforts to %s.", (booktype == SPE_NOVEL) ? + "read the novel" : "memorize the spell"); } else { /* KMH -- Simplified this code */ if (booktype == SPE_BLANK_PAPER) { @@ -448,6 +450,22 @@ register struct obj *spellbook; makeknown(booktype); return(1); } + + /* 3.6 tribute */ + if (booktype == SPE_NOVEL) { + /* Obtain current Terry Pratchett book + title for the current game. */ + const char *tribtitle = noveltitle(&context.tribute.bookidx); + + /* + * Place code here to pull desireable + * random passages from somewhere (data.base?) + * using tribtitle as the key? + */ + pline("Reading \"%s.\"", tribtitle); /* debug confirmation */ + return(1); + } + switch (objects[booktype].oc_level) { case 1: case 2: diff --git a/win/share/objects.txt b/win/share/objects.txt index 0322de15f..780e7f463 100644 --- a/win/share/objects.txt +++ b/win/share/objects.txt @@ -6930,6 +6930,25 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } +# tile 363 (printed / novel) +{ + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMEEEEMMMMMMMM + MMMMEEEEEEMMMMMM + MMMEEEEEEEEEEMMM + MMMEEEEEEEEEBMMM + MMEEEEEEEEEEOAMM + MMEEEEEEEEEBOAAM + MEEEEEEEEEEOEAMM + MEEEEEEEEEBOAAMM + MEOOEEEEEEOEAMMM + MMEEOOOEEBOAAMMM + MMMMEEEOOOEAMMMM + MMMMMMMEEEAAMMMM + MMMMMMMMMMMMMMMM +} # tile 364 (papyrus / Book of the Dead) { MMMMMMMMMMMMMMMM