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

Function mzapwand

src/muse.c:164–191  ·  view source on GitHub ↗

when a monster zaps a wand give a message, deduct a charge, and if it isn't directly seen, remove hero's memory of the number of charges */

Source from the content-addressed store, hash-verified

162/* when a monster zaps a wand give a message, deduct a charge, and if it
163 isn't directly seen, remove hero's memory of the number of charges */
164staticfn void
165mzapwand(
166 struct monst *mtmp,
167 struct obj *otmp,
168 boolean self)
169{
170 if (otmp->spe < 1) {
171 impossible("Mon zapping wand with %d charges?", otmp->spe);
172 return;
173 }
174 if (!canseemon(mtmp)) {
175 int range = couldsee(mtmp->mx, mtmp->my) /* 9 or 5 */
176 ? (BOLT_LIM + 1) : (BOLT_LIM - 3);
177
178 Soundeffect(se_zap, 100);
179 You_hear("a %s zap.", (mdistu(mtmp) <= range * range)
180 ? "nearby" : "distant");
181 unknow_object(otmp); /* hero loses info when unseen obj is used */
182 } else if (self) {
183 pline("%s with %s!",
184 monverbself(mtmp, Monnam(mtmp), "zap", (char *) 0),
185 doname(otmp));
186 } else {
187 pline_mon(mtmp, "%s zaps %s!", Monnam(mtmp), an(xname(otmp)));
188 stop_occupation();
189 }
190 otmp->spe -= 1;
191}
192
193/* similar to mzapwand() but for magical horns (only instrument mons play) */
194staticfn void

Callers 4

use_defensiveFunction · 0.85
use_offensiveFunction · 0.85
use_miscFunction · 0.85
muse_unslimeFunction · 0.85

Calls 12

canseemonFunction · 0.85
You_hearFunction · 0.85
unknow_objectFunction · 0.85
monverbselfFunction · 0.85
MonnamFunction · 0.85
donameFunction · 0.85
pline_monFunction · 0.85
anFunction · 0.85
xnameFunction · 0.85
stop_occupationFunction · 0.85
impossibleFunction · 0.70
plineFunction · 0.70

Tested by

no test coverage detected