touchstone again

Recent patches broke rubbing gold coins on touchstones; for the
!GOLDOBJ configuration, the character's money would be lost and the
program leaked memory.  That problem was already present for rubbing
gold on other gray stones.

     This also gives a gem advantage back to archeologists:  they
can comprehend touchstone results when the stone is uncursed rather
than require it to be blessed.  (I gave gnome characters that benefit
too.  Why gnomes and not dwarves?  I don't have a reasonable answer
for that....)  To go along with that, make A's initial touchstone
start uncursed rather than blessed, so that other characters finding
them in bones won't get an immediate benefit from them for the 20%
of the time that they're not cursed when saving bones.

     Much of this is whitespace cleanup.  I reformatted use_stone()
completely.
This commit is contained in:
nethack.rankin
2002-03-17 08:19:21 +00:00
parent 5811dbbcd5
commit fafbb60725
2 changed files with 147 additions and 141 deletions
+71 -66
View File
@@ -1821,36 +1821,47 @@ reset_trapset()
/* touchstones - by Ken Arnold */ /* touchstones - by Ken Arnold */
STATIC_OVL void STATIC_OVL void
use_stone(otmp) use_stone(tstone)
struct obj *otmp; struct obj *tstone;
{ {
struct obj *obj; struct obj *obj;
char allowall[3]; const char *streak_color = 0;
const char *color = 0; static const char scritch[] = "\"scritch, scritch\"",
static const char *ambiguous_scratch = "You make scratch marks on the stone."; ambiguous_scratch[] = "You make scratch marks on the stone.";
const char *scritch = "\"scritch, scritch\""; static char allowall[3] = { GOLD_CLASS, ALL_CLASSES, 0 };
unsigned material; #ifndef GOLDOBJ
struct obj goldobj;
#endif
allowall[0] = GOLD_CLASS; if ((obj = getobj(allowall, "rub on the stone")) == 0)
allowall[1] = ALL_CLASSES;
allowall[2] = '\0';
if (!(obj = getobj(allowall, "rub on the stone")))
return; return;
#ifndef GOLDOBJ
if (obj->oclass == GOLD_CLASS) {
u.ugold += obj->quan; /* keep botl up to date */
goldobj = *obj;
dealloc_obj(obj);
obj = &goldobj;
}
#endif
if (otmp == obj) { if (obj == tstone) {
You_cant("rub %s on itself.", the(xname(obj))); You_cant("rub %s on itself.", the(xname(obj)));
return; return;
} }
material = objects[obj->otyp].oc_material;
if (otmp->cursed && if (tstone->cursed &&
obj->oclass == GEM_CLASS && !is_graystone(obj) && !rn2(5)) { obj->oclass == GEM_CLASS && !is_graystone(obj) &&
pline( !obj_resists(obj, 80, 100)) {
(Blind ? "You feel something shatter." : if (Blind)
(Hallucination ? "Oh, wow, look at the pretty shards." : pline("You feel something shatter.");
"A sharp crack shatters %s %s.")), else if (Hallucination)
(obj->quan == 1 ? "the" : "a"), pline("Oh, wow, look at the pretty shards.");
lcase(makesingular(let_to_name(obj->oclass, FALSE)))); else
pline("A sharp crack shatters %s%s.",
(obj->quan > 1) ? "one of " : "", the(xname(obj)));
#ifndef GOLDOBJ
/* assert(obj != &goldobj); */
#endif
useup(obj); useup(obj);
return; return;
} }
@@ -1858,69 +1869,62 @@ struct obj *otmp;
if (Blind) { if (Blind) {
pline(scritch); pline(scritch);
return; return;
} } else if (Hallucination) {
if (Hallucination) {
pline("Oh wow, man: Fractals!"); pline("Oh wow, man: Fractals!");
return; return;
} }
if (material == LIQUID || material == WAX || switch (obj->oclass) {
material == CLOTH || material == WOOD || material == GOLD) { case GEM_CLASS: /* these have class-specific handling below */
switch(material) { case RING_CLASS:
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 */
/*NOTREACHED*/
break; break;
default:
switch (objects[obj->otyp].oc_material) {
case CLOTH: case CLOTH:
pline_The("stone looks a little more polished now."); pline_The("stone looks a little more polished now.");
break;
case WOOD:
color = "wooden";
goto see_streaks; /* okay even if not touchstone */
/*NOTREACHED*/
break;
}
return; return;
case LIQUID:
if (!obj->known) /* note: not "whetstone" */
You("must think this is a wetstone, do you?");
else
pline("%s a little wetter now.", Tobjnam(tstone, "are"));
return;
case WAX:
streak_color = "waxy";
goto see_streaks; /* okay even if not touchstone */
case WOOD:
streak_color = "wooden";
goto see_streaks; /* okay even if not touchstone */
case GOLD:
streak_color = "golden";
goto see_streaks;
case SILVER:
streak_color = "silvery";
goto see_streaks;
default:
break;
} }
break; /* default oclass */
}
if (is_flimsy(obj)) { if (is_flimsy(obj)) {
/* Objects passing the is_flimsy() test will not /* Objects passing the is_flimsy() test will not
scratch a stone. They will leave streaks on scratch a stone. They will leave streaks on
non-touchstones and touchstones alike */ non-touchstones and touchstones alike. */
color = c_obj_colors[objects[obj->otyp].oc_color]; streak_color = c_obj_colors[objects[obj->otyp].oc_color];
goto see_streaks; goto see_streaks;
} }
if (otmp->otyp != TOUCHSTONE) { if (tstone->otyp != TOUCHSTONE) {
pline(ambiguous_scratch); pline(ambiguous_scratch);
return; return;
} }
if (material == GOLD) {
color = "golden";
goto see_streaks;
}
switch (obj->oclass) { switch (obj->oclass) {
case GOLD_CLASS:
color = "golden";
#ifndef GOLDOBJ
/* goldobj back to u.ugold */
u.ugold = obj->quan;
obj->quan = 0L;
dealloc_obj(obj);
obj = (struct obj *)0;
#endif
break;
case GEM_CLASS: case GEM_CLASS:
if (otmp->blessed) { if (tstone->blessed || (!tstone->cursed &&
(Role_if(PM_ARCHEOLOGIST) || Race_if(PM_GNOME)))) {
makeknown(TOUCHSTONE); makeknown(TOUCHSTONE);
makeknown(obj->otyp); makeknown(obj->otyp);
prinv((char *)0, obj, 0L); prinv((char *)0, obj, 0L);
@@ -1932,14 +1936,15 @@ struct obj *otmp;
pline(ambiguous_scratch); /* yet not ambiguous if a known touchstone */ pline(ambiguous_scratch); /* yet not ambiguous if a known touchstone */
return; return;
} }
color = c_obj_colors[objects[obj->otyp].oc_color]; streak_color = c_obj_colors[objects[obj->otyp].oc_color];
break; break;
default: default:
pline(scritch); pline(scritch);
return; return;
} }
see_streaks:
pline("You see %s streaks on the stone.", color); see_streaks:
pline("You see %s streaks on the stone.", streak_color);
return; return;
} }
+2 -1
View File
@@ -33,7 +33,7 @@ static struct trobj Archeologist[] = {
{ FOOD_RATION, 0, FOOD_CLASS, 3, 0 }, { FOOD_RATION, 0, FOOD_CLASS, 3, 0 },
{ PICK_AXE, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS }, { PICK_AXE, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS },
{ TINNING_KIT, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS }, { TINNING_KIT, UNDEF_SPE, TOOL_CLASS, 1, UNDEF_BLESS },
{ TOUCHSTONE, 0, GEM_CLASS, 1, 1 }, { TOUCHSTONE, 0, GEM_CLASS, 1, 0 },
{ SACK, 0, TOOL_CLASS, 1, 0 }, { SACK, 0, TOOL_CLASS, 1, 0 },
{ 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0 }
}; };
@@ -219,6 +219,7 @@ static struct trobj Money[] = {
{ 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0 }
}; };
#endif #endif
/* race-based substitutions for initial inventory; /* race-based substitutions for initial inventory;
the weaker cloak for elven rangers is intentional--they shoot better */ the weaker cloak for elven rangers is intentional--they shoot better */
static struct inv_sub { short race_pm, item_otyp, subs_otyp; } inv_subs[] = { static struct inv_sub { short race_pm, item_otyp, subs_otyp; } inv_subs[] = {