From cf37a7bac057b30e51292b81b1d7727cb0467b4b Mon Sep 17 00:00:00 2001 From: cohrs Date: Sat, 9 Feb 2002 00:16:35 +0000 Subject: [PATCH] verb agreement add and use new APIs, Tobjnam, otense and vtense, is_plural to determine tense/form of verbs and a few pronouns as well --- include/extern.h | 7 ++- include/obj.h | 4 ++ src/apply.c | 113 ++++++++++++++++++++++------------------------- src/artifact.c | 8 ++-- src/dbridge.c | 33 ++------------ src/detect.c | 17 ++++--- src/dig.c | 59 ++++++++++++++----------- src/do.c | 16 +++---- src/do_name.c | 2 +- 9 files changed, 121 insertions(+), 138 deletions(-) diff --git a/include/extern.h b/include/extern.h index 07621933a..5153ef252 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1309,13 +1309,16 @@ E char *FDECL(xname, (struct obj *)); E char *FDECL(mshot_xname, (struct obj *)); E char *FDECL(doname, (struct obj *)); E boolean FDECL(not_fully_identified, (struct obj *)); -E const char *FDECL(corpse_xname, (struct obj *,BOOLEAN_P)); +E char *FDECL(corpse_xname, (struct obj *,BOOLEAN_P)); E const char *FDECL(singular, (struct obj *,char *(*)(OBJ_P))); E char *FDECL(an, (const char *)); E char *FDECL(An, (const char *)); E char *FDECL(The, (const char *)); E char *FDECL(the, (const char *)); E char *FDECL(aobjnam, (struct obj *,const char *)); +E char *FDECL(Tobjnam, (struct obj *,const char *)); +E char *FDECL(otense, (struct obj *,const char *)); +E char *FDECL(vtense, (const char *,const char *)); E char *FDECL(Doname2, (struct obj *)); E char *FDECL(yname, (struct obj *)); E char *FDECL(Yname2, (struct obj *)); @@ -1927,7 +1930,7 @@ E coord *FDECL(gettrack, (int,int)); E boolean FDECL(burnarmor,(struct monst *)); E boolean FDECL(rust_dmg, (struct obj *,const char *,int,BOOLEAN_P,struct monst *)); -E void FDECL(grease_protect, (struct obj *,const char *,BOOLEAN_P,struct monst *)); +E void FDECL(grease_protect, (struct obj *,const char *,struct monst *)); E struct trap *FDECL(maketrap, (int,int,int)); E void FDECL(fall_through, (BOOLEAN_P)); E struct monst *FDECL(animate_statue, (struct obj *,XCHAR_P,XCHAR_P,int,int *)); diff --git a/include/obj.h b/include/obj.h index 5e93983ca..5313c2684 100644 --- a/include/obj.h +++ b/include/obj.h @@ -222,6 +222,10 @@ struct obj { (obj)->otyp == FLINT || \ (obj)->otyp == TOUCHSTONE) +/* helpers, simple enough to be macros */ +#define is_plural(o) ((o)->quan > 1 || \ + (o)->oartifact == ART_EYES_OF_THE_OVERWORLD) + /* Flags for get_obj_location(). */ #define CONTAINED_TOO 0x1 #define BURIED_TOO 0x2 diff --git a/src/apply.c b/src/apply.c index 0f6a83f71..88aa879bb 100644 --- a/src/apply.c +++ b/src/apply.c @@ -773,7 +773,7 @@ register struct obj *obj; u.ux, u.uy, NO_MINVENT)) != 0) { You("summon %s!", a_monnam(mtmp)); if (!obj_resists(obj, 93, 100)) { - pline("%s has shattered!", The(xname(obj))); + pline("%s shattered!", Tobjnam(obj, "have")); useup(obj); } else switch (rn2(3)) { default: @@ -809,8 +809,8 @@ register struct obj *obj; wakem = TRUE; } else if (invoking) { - pline("%s issues an unsettling shrill sound...", - The(xname(obj))); + pline("%s an unsettling shrill sound...", + Tobjnam(obj, "issue")); #ifdef AMIGA amii_speaker( obj, "aefeaefeaefeaefeaefe", AMII_LOUDER_VOLUME ); #endif @@ -858,50 +858,47 @@ STATIC_OVL void use_candelabrum(obj) register struct obj *obj; { + char *s = obj->spe != 1 ? "candles" : "candle"; + if(Underwater) { You("cannot make fire under water."); return; } if(obj->lamplit) { - You("snuff the candle%s.", obj->spe > 1 ? "s" : ""); + You("snuff the %s.", s); end_burn(obj, TRUE); return; } if(obj->spe <= 0) { - pline("This %s has no candles.", xname(obj)); + pline("This %s has no %s.", xname(obj), s); return; } if(u.uswallow || obj->cursed) { if (!Blind) - pline_The("candle%s flicker%s for a moment, then die%s.", - obj->spe > 1 ? "s" : "", - obj->spe > 1 ? "" : "s", - obj->spe > 1 ? "" : "s"); + pline_The("%s %s for a moment, then %s.", + s, vtense(s, "flicker"), vtense(s, "die")); return; } if(obj->spe < 7) { - There("%s only %d candle%s in %s.", - obj->spe == 1 ? "is" : "are", - obj->spe, - obj->spe > 1 ? "s" : "", - the(xname(obj))); + There("%s only %d %s in %s.", + vtense(s, "are"), obj->spe, s, the(xname(obj))); if (!Blind) - pline("%s lit. %s shines dimly.", - obj->spe == 1 ? "It is" : "They are", The(xname(obj))); + pline("%s lit. %s dimly.", + obj->spe == 1 ? "It is" : "They are", + Tobjnam(obj, "shine")); } else { - pline("%s's candles burn%s", The(xname(obj)), + pline("%s's %s burn%s", The(xname(obj)), s, (Blind ? "." : " brightly!")); } if (!invocation_pos(u.ux, u.uy)) { - pline_The("candle%s being rapidly consumed!", - (obj->spe > 1 ? "s are" : " is")); + pline_The("%s %s being rapidly consumed!", s, vtense(s, "are")); obj->age /= 2; } else { if(obj->spe == 7) { if (Blind) - pline("%s radiates a strange warmth!", The(xname(obj))); + pline("%s a strange warmth!", Tobjnam(obj, "radiate")); else - pline("%s glows with a strange light!", The(xname(obj))); + pline("%s with a strange light!", Tobjnam(obj, "glow")); } obj->known = 1; } @@ -913,6 +910,7 @@ use_candle(obj) register struct obj *obj; { register struct obj *otmp; + char *s = obj->quan != 1 ? "candles" : "candle"; char qbuf[QBUFSZ]; if(u.uswallow) { @@ -940,16 +938,14 @@ register struct obj *obj; } else { if ((long)otmp->spe + obj->quan > 7L) obj = splitobj(obj, 7L - (long)otmp->spe); - You("attach %ld%s candle%s to %s.", + You("attach %ld%s %s to %s.", obj->quan, !otmp->spe ? "" : " more", - plur(obj->quan), the(xname(otmp))); + s, the(xname(otmp))); if (!otmp->spe || otmp->age > obj->age) otmp->age = obj->age; otmp->spe += (int)obj->quan; if (otmp->lamplit && !obj->lamplit) - pline_The("new candle%s magically ignite%s!", - plur(obj->quan), - (obj->quan > 1L) ? "" : "s"); + pline_The("new %s magically %s!", s, vtense(s, "ignite")); else if (!otmp->lamplit && obj->lamplit) pline("%s out.", (obj->quan > 1L) ? "They go" : "It goes"); if (obj->unpaid) @@ -958,8 +954,8 @@ register struct obj *obj; (obj->quan > 1L) ? "them" : "it", (obj->quan > 1L) ? "them" : "it"); if (obj->quan < 7L && otmp->spe == 7) - pline("%s now has seven%s candles attached.", - The(xname(otmp)), otmp->lamplit ? " lit" : ""); + pline("%s now has seven%s %s attached.", + The(xname(otmp)), otmp->lamplit ? " lit" : "", s); /* candelabrum's light range might increase */ if (otmp->lamplit) obj_merge_light_sources(otmp, otmp); /* candles are no longer a separate light source */ @@ -1007,7 +1003,7 @@ struct obj *obj; obj->otyp == BRASS_LANTERN || obj->otyp == POT_OIL) { (void) get_obj_location(obj, &x, &y, 0); if (obj->where == OBJ_MINVENT ? cansee(x,y) : !Blind) - pline("%s goes out!", Yname2(obj)); + pline("%s %s out!", Yname2(obj), otense(obj, "go")); end_burn(obj, TRUE); return TRUE; } @@ -1035,7 +1031,7 @@ struct obj *obj; if (!get_obj_location(obj, &x, &y, 0)) return FALSE; if (obj->where == OBJ_MINVENT ? cansee(x,y) : !Blind) - pline("%s catches light!", Yname2(obj)); + pline("%s %s light!", Yname2(obj), otense(obj, "catch")); begin_burn(obj, TRUE); return TRUE; } @@ -1070,20 +1066,17 @@ struct obj *obj; return; } if (obj->cursed && !rn2(2)) { - pline("%s flicker%s for a moment, then die%s.", - The(xname(obj)), - obj->quan > 1L ? "" : "s", - obj->quan > 1L ? "" : "s"); + pline("%s for a moment, then %s.", + Tobjnam(obj, "flicker"), otense(obj, "die")); } else { if(obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP || obj->otyp == BRASS_LANTERN) { check_unpaid(obj); pline("%s lamp is now on.", Shk_Your(buf, obj)); } else { /* candle(s) */ - pline("%s flame%s burn%s%s", + pline("%s flame%s %s%s", s_suffix(Yname2(obj)), - plur(obj->quan), - obj->quan > 1L ? "" : "s", + plur(obj->quan), otense(obj, "burn"), Blind ? "." : " brightly!"); if (obj->unpaid && costly_spot(u.ux, u.uy) && obj->age == 20L * (long)objects[obj->otyp].oc_cost) { @@ -1725,7 +1718,7 @@ struct obj *obj; if (Glib) { dropx(obj); - pline("%s slips from your %s.", The(xname(obj)), + pline("%s from your %s.", Tobjnam(obj, "slip"), makeplural(body_part(FINGER))); return; } @@ -1735,7 +1728,7 @@ struct obj *obj; check_unpaid(obj); obj->spe--; dropx(obj); - pline("%s slips from your %s.", The(xname(obj)), + pline("%s from your %s.", Tobjnam(obj, "slip"), makeplural(body_part(FINGER))); return; } @@ -1772,8 +1765,10 @@ struct obj *obj; makeplural(body_part(FINGER))); } } else { - pline("%s %s empty.", The(xname(obj)), - obj->known ? "is" : "seems to be"); + if (obj->known) + pline("%s empty.", Tobjnam(obj, "are")); + else + pline("%s to be empty.", Tobjnam(obj, "seem")); } update_inventory(); } @@ -1837,27 +1832,27 @@ struct obj *otmp; if (material == LIQUID || material == WAX || material == CLOTH || material == WOOD) { switch(material) { - case LIQUID: - if (!obj->known) - You("must think this is a wetstone, do you?"); - else - pline("%s is a little wetter now.", The(xname(otmp))); - break; - case WAX: - color = "waxy"; - goto see_streaks; /* okay even if not touchstone */ - break; - case CLOTH: - pline_The("stone looks a little more polished now."); - break; - case WOOD: - color = "wooden"; - goto see_streaks; /* okay even if not touchstone */ - break; + case LIQUID: + if (!obj->known) + You("must think this is a wetstone, do you?"); + else + pline("%s a little wetter now.", Tobjnam(otmp, "are")); + break; + case WAX: + color = "waxy"; + goto see_streaks; /* okay even if not touchstone */ + break; + case CLOTH: + pline_The("stone looks a little more polished now."); + break; + case WOOD: + color = "wooden"; + goto see_streaks; /* okay even if not touchstone */ + break; } return; } - + if (otmp->otyp != TOUCHSTONE) { pline(ambiguous); return; diff --git a/src/artifact.c b/src/artifact.c index e57575f8d..1255362cc 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -513,7 +513,7 @@ touch_artifact(obj,mon) /* can pick it up unless you're totally non-synch'd with the artifact */ if (badclass && badalign && self_willed) { - if (yours) pline("%s evades your grasp!", The(xname(obj))); + if (yours) pline("%s your grasp!", Tobjnam(obj, "evade")); return 0; } @@ -750,7 +750,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */ if (attacks(AD_ELEC, otmp)) { if (realizes_damage) { if(youattack && otmp != uwep) - pline("%s hits %s!", The(xname(otmp)), hittee); + pline("%s %s!", Tobjnam(otmp, "hit"), hittee); pline("Lightning strikes %s!", hittee); if (!rn2(5)) (void) destroy_mitem(mdef, RING_CLASS, AD_ELEC); if (!rn2(5)) (void) destroy_mitem(mdef, WAND_CLASS, AD_ELEC); @@ -760,7 +760,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */ if (attacks(AD_MAGM, otmp)) { if (realizes_damage) { if(youattack && otmp != uwep) - pline("%s hits %s!", The(xname(otmp)), hittee); + pline("%s %s!", Tobjnam(otmp, "hit"), hittee); pline("A hail of magic missiles strikes %s!", hittee); return TRUE; } @@ -1327,7 +1327,7 @@ void arti_speak(obj) line = getrumor(bcsign(obj), buf, TRUE); if (!*line) line = "NetHack rumors file closed for renovation."; - pline("%s whispers:", The(xname(obj))); + pline("%s:", Tobjnam(obj, "whisper")); verbalize("%s", line); return; } diff --git a/src/dbridge.c b/src/dbridge.c index 6267620de..589d56963 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -336,39 +336,14 @@ struct entity *etmp; const char *verb; { static char wholebuf[80]; - char verbbuf[30]; Strcpy(wholebuf, is_u(etmp) ? "You" : Monnam(etmp->emon)); - if (!*verb) - return(wholebuf); + if (!*verb) return(wholebuf); Strcat(wholebuf, " "); - verbbuf[0] = '\0'; if (is_u(etmp)) - Strcpy(verbbuf, verb); - else { - if (!strcmp(verb, "are")) - Strcpy(verbbuf, "is"); - if (!strcmp(verb, "have")) - Strcpy(verbbuf, "has"); - if (!verbbuf[0]) { - Strcpy(verbbuf, verb); - switch (verbbuf[strlen(verbbuf) - 1]) { - case 'y': - verbbuf[strlen(verbbuf) - 1] = '\0'; - Strcat(verbbuf, "ies"); - break; - case 'h': - case 'o': - case 's': - Strcat(verbbuf, "es"); - break; - default: - Strcat(verbbuf, "s"); - break; - } - } - } - Strcat(wholebuf, verbbuf); + Strcat(wholebuf, verb); + else + Strcat(wholebuf, vtense((char *)0, verb)); return(wholebuf); } diff --git a/src/detect.c b/src/detect.c index fb3d5a450..190096df9 100644 --- a/src/detect.c +++ b/src/detect.c @@ -751,33 +751,32 @@ struct obj *obj; { char ch; int oops; - const char *bname = xname(obj); if (Blind) { - pline("Too bad you can't see %s", the(bname)); + pline("Too bad you can't see %s", the(xname(obj))); return; } oops = (rnd(20) > ACURR(A_INT) || obj->cursed); if (oops && (obj->spe > 0)) { switch (rnd(obj->oartifact ? 4 : 5)) { - case 1 : pline("%s is too much to comprehend!", The(bname)); + case 1 : pline("%s too much to comprehend!", Tobjnam(obj, "are")); break; - case 2 : pline("%s confuses you!", The(bname)); + case 2 : pline("%s you!", Tobjnam(obj, "confuse")); make_confused(HConfusion + rnd(100),FALSE); break; case 3 : if (!resists_blnd(&youmonst)) { - pline("%s damages your vision!", The(bname)); + pline("%s your vision!", Tobjnam(obj, "damage")); make_blinded(Blinded + rnd(100),FALSE); if (!Blind) Your(vision_clears); } else { - pline("%s assaults your vision.", The(bname)); + pline("%s your vision.", Tobjnam(obj, "assault")); You("are unaffected!"); } break; - case 4 : pline("%s zaps your mind!", The(bname)); + case 4 : pline("%s your mind!", Tobjnam(obj, "zap")); make_hallucinated(HHallucination + rnd(100),FALSE,0L); break; - case 5 : pline("%s explodes!", The(bname)); + case 5 : pline("%s!", Tobjnam(obj, "explode")); useup(obj); losehp(rnd(30), "exploding crystal ball", KILLED_BY_AN); break; @@ -820,7 +819,7 @@ struct obj *obj; if (flags.verbose) pline(Never_mind); return; } - You("peer into %s...", the(bname)); + You("peer into %s...", the(xname(obj))); nomul(-rnd(10)); nomovemsg = ""; if (obj->spe <= 0) diff --git a/src/dig.c b/src/dig.c index bf8b490af..d9aa5e5ea 100644 --- a/src/dig.c +++ b/src/dig.c @@ -220,29 +220,34 @@ dig() } } if(Fumbling && !rn2(3)) { - switch(rn2(3)) { - case 0: if(!welded(uwep)) { - You("fumble and drop your %s.", xname(uwep)); - dropx(uwep); - } else { + switch(rn2(3)) { + case 0: + if(!welded(uwep)) { + You("fumble and drop your %s.", xname(uwep)); + dropx(uwep); + } else { #ifdef STEED - if (u.usteed) - Your("%s bounces and hits %s!", - xname(uwep), mon_nam(u.usteed)); - else + if (u.usteed) + Your("%s %s and %s %s!", + xname(uwep), + otense(uwep, "bounce"), otense(uwep, "hit"), + mon_nam(u.usteed)); + else #endif - pline("Ouch! Your %s bounces and hits you!", - xname(uwep)); - set_wounded_legs(RIGHT_SIDE, 5 + rnd(5)); - } - break; - case 1: pline("Bang! You hit with the broad side of %s!", - the(xname(uwep))); - break; - default: Your("swing misses its mark."); - break; + pline("Ouch! Your %s %s and %s you!", + xname(uwep), + otense(uwep, "bounce"), otense(uwep, "hit")); + set_wounded_legs(RIGHT_SIDE, 5 + rnd(5)); } - return(0); + break; + case 1: + pline("Bang! You hit with the broad side of %s!", + the(xname(uwep))); + break; + default: Your("swing misses its mark."); + break; + } + return(0); } digging.effort += 10 + rn2(5) + abon() + @@ -863,8 +868,8 @@ struct obj *obj; seetrap(trap); There("is a spider web there!"); } - Your("%s becomes entangled in the web.", - aobjnam(obj, (char *)0)); + Your("%s entangled in the web.", + aobjnam(obj, "become")); /* you ought to be able to let go; tough luck */ /* (maybe `move_into_trap()' would be better) */ nomul(-d(2,2)); @@ -1343,10 +1348,12 @@ long timeout; /* unused */ x = obj->ox; y = obj->oy; } else if (in_invent) { - if (flags.verbose) - Your("%s%s rot%s away%c", - obj == uwep ? "wielded " : "", corpse_xname(obj, FALSE), - obj->quan == 1L ? "s" : "", obj == uwep ? '!' : '.'); + if (flags.verbose) { + char *cname = corpse_xname(obj, FALSE); + Your("%s%s %s away%c", + obj == uwep ? "wielded " : nul, cname, + vtense(cname, "rot"), obj == uwep ? '!' : '.'); + } if (obj == uwep) { uwepgone(); /* now bare handed */ stop_occupation(); diff --git a/src/do.c b/src/do.c index a26c4b0ea..ef261e787 100644 --- a/src/do.c +++ b/src/do.c @@ -166,7 +166,8 @@ const char *verb; if (((mtmp = m_at(x, y)) && mtmp->mtrapped) || (u.utrap && u.ux == x && u.uy == y)) { if (*verb) - pline_The("boulder %ss into the pit%s.", verb, + pline_The("boulder %s into the pit%s.", + vtense((const char *)0, verb), (mtmp) ? "" : " with you"); if (mtmp) { if (!passes_walls(mtmp->data) && @@ -228,14 +229,13 @@ doaltarobj(obj) /* obj is an object dropped on an altar */ u.uconduct.gnostic++; if (obj->blessed || obj->cursed) { - There("is %s flash as %s hit%s the altar.", + There("is %s flash as %s %s the altar.", an(hcolor(obj->blessed ? amber : Black)), - doname(obj), - (obj->quan == 1L) ? "s" : ""); + doname(obj), otense(obj, "hit")); if (!Hallucination) obj->bknown = 1; } else { - pline("%s land%s on the altar.", Doname2(obj), - (obj->quan == 1L) ? "s" : ""); + pline("%s %s on the altar.", Doname2(obj), + otense(obj, "land")); obj->bknown = 1; } } @@ -314,8 +314,8 @@ giveback: if (otmp != uball && otmp != uchain && !obj_resists(otmp, 1, 99)) { if (!Blind) { - pline("Suddenly, %s vanishes from the sink!", - doname(otmp)); + pline("Suddenly, %s %s from the sink!", + doname(otmp), otense(otmp, "vanish")); ideed = TRUE; } delobj(otmp); diff --git a/src/do_name.c b/src/do_name.c index 0a3962fff..ad1e022a7 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -296,7 +296,7 @@ register struct obj *obj; short objtyp; Sprintf(qbuf, "What do you want to name %s %s?", - (obj->quan > 1L) ? "these" : "this", xname(obj)); + is_plural(obj) ? "these" : "this", xname(obj)); getlin(qbuf, buf); if(!*buf || *buf == '\033') return; /* strip leading and trailing spaces; unnames item if all spaces */ -- 2.50.1