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

Function mplayhorn

src/muse.c:194–233  ·  view source on GitHub ↗

similar to mzapwand() but for magical horns (only instrument mons play) */

Source from the content-addressed store, hash-verified

192
193/* similar to mzapwand() but for magical horns (only instrument mons play) */
194staticfn void
195mplayhorn(
196 struct monst *mtmp,
197 struct obj *otmp,
198 boolean self)
199{
200 char *objnamp, objbuf[BUFSZ];
201
202 if (!canseemon(mtmp)) {
203 int range = couldsee(mtmp->mx, mtmp->my) /* 9 or 5 */
204 ? (BOLT_LIM + 1) : (BOLT_LIM - 3);
205
206 Soundeffect(se_horn_being_played, 50);
207 You_hear("a horn being played %s.",
208 (mdistu(mtmp) <= range * range)
209 ? "nearby" : "in the distance");
210 unknow_object(otmp); /* hero loses info when unseen obj is used */
211 } else if (self) {
212 observe_object(otmp);
213 objnamp = xname(otmp);
214 if (strlen(objnamp) >= QBUFSZ)
215 objnamp = simpleonames(otmp);
216 Sprintf(objbuf, "a %s directed at", objnamp);
217 /* "<mon> plays a <horn> directed at himself!" */
218 pline("%s!", monverbself(mtmp, Monnam(mtmp), "play", objbuf));
219 makeknown(otmp->otyp); /* (wands handle this slightly differently) */
220 } else {
221 observe_object(otmp);
222 objnamp = xname(otmp);
223 if (strlen(objnamp) >= QBUFSZ)
224 objnamp = simpleonames(otmp);
225 pline("%s %s %s directed at you!",
226 /* monverbself() would adjust the verb if hallucination made
227 subject plural; stick with singular here, at least for now */
228 Monnam(mtmp), "plays", an(objnamp));
229 makeknown(otmp->otyp);
230 stop_occupation();
231 }
232 otmp->spe -= 1; /* use a charge */
233}
234
235/* see or hear a monster reading a scroll;
236 when scroll hasn't been seen, its label is revealed unless hero is deaf */

Callers 2

use_offensiveFunction · 0.85
muse_unslimeFunction · 0.85

Calls 11

canseemonFunction · 0.85
You_hearFunction · 0.85
unknow_objectFunction · 0.85
observe_objectFunction · 0.85
xnameFunction · 0.85
simpleonamesFunction · 0.85
monverbselfFunction · 0.85
MonnamFunction · 0.85
anFunction · 0.85
stop_occupationFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected