MCPcopy Index your code
hub / github.com/NetHack/NetHack / use_stone

Function use_stone

src/apply.c:2679–2810  ·  view source on GitHub ↗

touchstones - by Ken Arnold */

Source from the content-addressed store, hash-verified

2677
2678/* touchstones - by Ken Arnold */
2679staticfn int
2680use_stone(struct obj *tstone)
2681{
2682 static const char scritch[] = "\"scritch, scritch\"";
2683 struct obj *obj;
2684 boolean do_scratch;
2685 const char *streak_color;
2686 char stonebuf[QBUFSZ];
2687 int oclass;
2688 boolean known;
2689
2690 /* in case it was acquired while blinded */
2691 if (!Blind)
2692 observe_object(tstone);
2693 known = (tstone->otyp == TOUCHSTONE && tstone->dknown
2694 && objects[TOUCHSTONE].oc_name_known);
2695 Sprintf(stonebuf, "rub on the stone%s", plur(tstone->quan));
2696 /* when the touchstone is fully known, don't bother listing extra
2697 junk as likely candidates for rubbing */
2698 if ((obj = getobj(stonebuf, known ? touchstone_ok : any_obj_ok,
2699 GETOBJ_PROMPT)) == 0)
2700 return ECMD_CANCEL;
2701
2702 if (obj == tstone && obj->quan == 1L) {
2703 You_cant("rub %s on itself.", the(xname(obj)));
2704 return ECMD_OK;
2705 }
2706
2707 if (tstone->otyp == TOUCHSTONE && tstone->cursed
2708 && obj->oclass == GEM_CLASS && !is_graystone(obj)
2709 && !obj_resists(obj, 80, 100)) {
2710 if (Blind)
2711 You_feel("something shatter.");
2712 else if (Hallucination)
2713 pline("Oh, wow, look at the pretty shards.");
2714 else
2715 pline("A sharp crack shatters %s%s.",
2716 (obj->quan > 1L) ? "one of " : "", the(xname(obj)));
2717 useup(obj);
2718 return ECMD_TIME;
2719 }
2720
2721 if (Blind) {
2722 pline(scritch);
2723 return ECMD_TIME;
2724 } else if (Hallucination) {
2725 pline("Oh wow, man: Fractals!");
2726 return ECMD_TIME;
2727 }
2728
2729 do_scratch = FALSE;
2730 streak_color = 0;
2731
2732 oclass = obj->oclass;
2733 /* prevent non-gemstone rings from being treated like gems */
2734 if (oclass == RING_CLASS
2735 && objects[obj->otyp].oc_material != GEMSTONE
2736 && objects[obj->otyp].oc_material != MINERAL)

Callers 2

dorubFunction · 0.85
doapplyFunction · 0.85

Calls 13

observe_objectFunction · 0.85
getobjFunction · 0.85
You_cantFunction · 0.85
theFunction · 0.85
xnameFunction · 0.85
obj_resistsFunction · 0.85
You_feelFunction · 0.85
useupFunction · 0.85
prinvFunction · 0.85
TobjnamFunction · 0.85
YouFunction · 0.85
You_seeFunction · 0.85

Tested by

no test coverage detected