MCPcopy Create free account
hub / github.com/NetHack/NetHack / observe_quantum_cat

Function observe_quantum_cat

src/pickup.c:2825–2897  ·  view source on GitHub ↗

used for #loot/apply, #tip, and final disclosure */

Source from the content-addressed store, hash-verified

2823
2824/* used for #loot/apply, #tip, and final disclosure */
2825void
2826observe_quantum_cat(struct obj *box, boolean makecat, boolean givemsg)
2827{
2828 static NEARDATA const char sc[] = "Schroedinger's Cat";
2829 struct obj *deadcat;
2830 struct monst *livecat = 0;
2831 coordxy ox, oy;
2832 boolean itsalive = !rn2(2);
2833
2834 if (get_obj_location(box, &ox, &oy, 0))
2835 box->ox = ox, box->oy = oy; /* in case it's being carried */
2836
2837 /* this isn't really right, since any form of observation
2838 (telepathic or monster/object/food detection) ought to
2839 force the determination of alive vs dead state; but basing it
2840 just on opening or disclosing the box is much simpler to cope with */
2841
2842 /* SchroedingersBox already has a cat corpse in it */
2843 deadcat = box->cobj;
2844 if (itsalive) {
2845 if (makecat)
2846 livecat = makemon(&mons[PM_HOUSECAT], box->ox, box->oy,
2847 NO_MINVENT | MM_ADJACENTOK | MM_NOMSG);
2848 if (livecat) {
2849 livecat->mpeaceful = 1;
2850 set_malign(livecat);
2851 if (givemsg) {
2852 if (!canspotmon(livecat))
2853 You("think %s brushed your %s.", something,
2854 body_part(FOOT));
2855 else
2856 pline("%s inside the box is still alive!",
2857 Monnam(livecat));
2858 }
2859 (void) christen_monst(livecat, sc);
2860 if (deadcat) {
2861 obj_extract_self(deadcat);
2862 obfree(deadcat, (struct obj *) 0), deadcat = 0;
2863 }
2864 box->owt = weight(box);
2865 box->spe = 0;
2866
2867 if (!svc.context.mon_moving) {
2868 /* give experience points for releasing live cat; slightly
2869 different amount from what is given for "killing" it */
2870 more_experienced(10, 20); /* 10:current exp; 20:score bonus */
2871 newexplevel();
2872 }
2873 }
2874 } else {
2875 box->spe = 0; /* now an ordinary box (with a cat corpse inside) */
2876 if (givemsg)
2877 pline_The("%s inside the box is dead!",
2878 Hallucination ? rndmonnam((char *) 0) : "housecat");
2879 if (deadcat) {
2880 /* set_corpsenm() will start the rot timer that was removed
2881 when makemon() created SchroedingersBox; start it from
2882 now rather than from when this special corpse got created */

Callers 3

really_doneFunction · 0.85
use_containerFunction · 0.85
tipcontainer_checksFunction · 0.85

Calls 15

rn2Function · 0.85
get_obj_locationFunction · 0.85
makemonFunction · 0.85
set_malignFunction · 0.85
YouFunction · 0.85
body_partFunction · 0.85
MonnamFunction · 0.85
christen_monstFunction · 0.85
obj_extract_selfFunction · 0.85
obfreeFunction · 0.85
weightFunction · 0.85
more_experiencedFunction · 0.85

Tested by

no test coverage detected