final(?) touchstone

Put back the "better gold handling" that was inadvertently
dropped from the previous rewrite.  Prevent gems rubbed on cursed
gray stones other than touchstones from being shattered.  Fix
several pluralization buglets, including allowing the player to
rub a stone against itself if the quantity is more than one (just
like potion dipping is handled).  Overall, streamline the rather
convoluted logic, eliminating the `goto's.
This commit is contained in:
nethack.rankin
2002-03-19 05:13:50 +00:00
parent e6c317835c
commit 49d84cffdb
+52 -49
View File
@@ -1825,15 +1825,17 @@ use_stone(tstone)
struct obj *tstone; struct obj *tstone;
{ {
struct obj *obj; struct obj *obj;
const char *streak_color = 0; boolean do_scratch;
static const char scritch[] = "\"scritch, scritch\"", const char *streak_color;
ambiguous_scratch[] = "You make scratch marks on the stone."; char stonebuf[QBUFSZ];
static const char scritch[] = "\"scritch, scritch\"";
static char allowall[3] = { GOLD_CLASS, ALL_CLASSES, 0 }; static char allowall[3] = { GOLD_CLASS, ALL_CLASSES, 0 };
#ifndef GOLDOBJ #ifndef GOLDOBJ
struct obj goldobj; struct obj goldobj;
#endif #endif
if ((obj = getobj(allowall, "rub on the stone")) == 0) Sprintf(stonebuf, "rub on the stone%s", plur(tstone->quan));
if ((obj = getobj(allowall, stonebuf)) == 0)
return; return;
#ifndef GOLDOBJ #ifndef GOLDOBJ
if (obj->oclass == GOLD_CLASS) { if (obj->oclass == GOLD_CLASS) {
@@ -1844,12 +1846,12 @@ struct obj *tstone;
} }
#endif #endif
if (obj == tstone) { if (obj == tstone && obj->quan == 1) {
You_cant("rub %s on itself.", the(xname(obj))); You_cant("rub %s on itself.", the(xname(obj)));
return; return;
} }
if (tstone->cursed && if (tstone->otyp == TOUCHSTONE && tstone->cursed &&
obj->oclass == GEM_CLASS && !is_graystone(obj) && obj->oclass == GEM_CLASS && !is_graystone(obj) &&
!obj_resists(obj, 80, 100)) { !obj_resists(obj, 80, 100)) {
if (Blind) if (Blind)
@@ -1874,15 +1876,35 @@ struct obj *tstone;
return; return;
} }
do_scratch = FALSE;
streak_color = 0;
switch (obj->oclass) { switch (obj->oclass) {
case GEM_CLASS: /* these have class-specific handling below */ case GEM_CLASS: /* these have class-specific handling below */
case RING_CLASS: case RING_CLASS:
break; if (tstone->otyp != TOUCHSTONE) {
do_scratch = TRUE;
} else if (obj->oclass == GEM_CLASS && (tstone->blessed ||
(!tstone->cursed &&
(Role_if(PM_ARCHEOLOGIST) || Race_if(PM_GNOME))))) {
makeknown(TOUCHSTONE);
makeknown(obj->otyp);
prinv((char *)0, obj, 0L);
return;
} else {
/* either a ring or the touchstone was not effective */
if (objects[obj->otyp].oc_material == GLASS) {
do_scratch = TRUE;
break;
}
}
streak_color = c_obj_colors[objects[obj->otyp].oc_color];
break; /* gem or ring */
default: default:
switch (objects[obj->otyp].oc_material) { switch (objects[obj->otyp].oc_material) {
case CLOTH: case CLOTH:
pline_The("stone looks a little more polished now."); pline("%s a little more polished now.", Tobjnam(tstone, "look"));
return; return;
case LIQUID: case LIQUID:
if (!obj->known) /* note: not "whetstone" */ if (!obj->known) /* note: not "whetstone" */
@@ -1892,59 +1914,40 @@ struct obj *tstone;
return; return;
case WAX: case WAX:
streak_color = "waxy"; streak_color = "waxy";
goto see_streaks; /* okay even if not touchstone */ break; /* okay even if not touchstone */
case WOOD: case WOOD:
streak_color = "wooden"; streak_color = "wooden";
goto see_streaks; /* okay even if not touchstone */ break; /* okay even if not touchstone */
case GOLD: case GOLD:
do_scratch = TRUE; /* scratching and streaks */
streak_color = "golden"; streak_color = "golden";
goto see_streaks; break;
case SILVER: case SILVER:
do_scratch = TRUE; /* scratching and streaks */
streak_color = "silvery"; streak_color = "silvery";
goto see_streaks; break;
default: default:
/* Objects passing the is_flimsy() test will not
scratch a stone. They will leave streaks on
non-touchstones and touchstones alike. */
if (is_flimsy(obj))
streak_color = c_obj_colors[objects[obj->otyp].oc_color];
else
do_scratch = (tstone->otyp != TOUCHSTONE);
break; break;
} }
break; /* default oclass */ break; /* default oclass */
} }
if (is_flimsy(obj)) { Sprintf(stonebuf, "stone%s", plur(tstone->quan));
/* Objects passing the is_flimsy() test will not if (do_scratch)
scratch a stone. They will leave streaks on pline("You make %s%sscratch marks on the %s.",
non-touchstones and touchstones alike. */ streak_color ? streak_color : (const char *)"",
streak_color = c_obj_colors[objects[obj->otyp].oc_color]; streak_color ? " " : "", stonebuf);
goto see_streaks; else if (streak_color)
} pline("You see %s streaks on the %s.", streak_color, stonebuf);
else
if (tstone->otyp != TOUCHSTONE) {
pline(ambiguous_scratch);
return;
}
switch (obj->oclass) {
case GEM_CLASS:
if (tstone->blessed || (!tstone->cursed &&
(Role_if(PM_ARCHEOLOGIST) || Race_if(PM_GNOME)))) {
makeknown(TOUCHSTONE);
makeknown(obj->otyp);
prinv((char *)0, obj, 0L);
return;
}
/* FALLTHROUGH */
case RING_CLASS:
if (objects[obj->otyp].oc_material == GLASS) {
pline(ambiguous_scratch); /* yet not ambiguous if a known touchstone */
return;
}
streak_color = c_obj_colors[objects[obj->otyp].oc_color];
break;
default:
pline(scritch); pline(scritch);
return;
}
see_streaks:
pline("You see %s streaks on the stone.", streak_color);
return; return;
} }