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

Function learnwand

src/zap.c:122–151  ·  view source on GitHub ↗

wand discovery gets special handling when hero is blinded */

Source from the content-addressed store, hash-verified

120
121/* wand discovery gets special handling when hero is blinded */
122void
123learnwand(struct obj *obj)
124{
125 /* For a wand (or wand-like tool) zapped by the player, if the
126 effect was observable (determined by caller; usually seen, but
127 possibly heard or felt if the hero is blinded) then discover the
128 object type provided that the object itself is known (as more
129 than just "a wand"). If object type is already discovered and
130 we observed the effect, mark the individual wand as having been
131 seen. Suppress spells (which use fake spellbook object for `obj')
132 so that casting a spell won't re-discover its forgotten book. */
133 if (obj->oclass != SPBOOK_CLASS) {
134 /* if type already discovered, treat this item has having been seen
135 even if hero is currently blinded (skips redundant makeknown) */
136 if (objects[obj->otyp].oc_name_known) {
137 observe_object(obj); /* will usually be dknown already */
138
139 /* otherwise discover it if item itself has been or can be seen */
140 } else {
141 /* in case it was picked up while blind and then zapped without
142 examining inventory after regaining sight (bypassing xname) */
143 if (!Blind)
144 observe_object(obj);
145 /* make the discovery iff we know what we're manipulating */
146 if (obj->dknown)
147 makeknown(obj->otyp);
148 }
149 update_inventory();
150 }
151}
152
153/*
154 * Routines for IMMEDIATE wands and spells.

Callers 11

doengraveFunction · 0.85
mon_adjust_speedFunction · 0.85
bhitmFunction · 0.85
bhitoFunction · 0.85
bhitpileFunction · 0.85
zapnodirFunction · 0.85
zapyourselfFunction · 0.85
zap_steedFunction · 0.85
weffectsFunction · 0.85
zap_mapFunction · 0.85
bhitFunction · 0.85

Calls 2

observe_objectFunction · 0.85
update_inventoryFunction · 0.85

Tested by

no test coverage detected