similar to mzapwand() but for magical horns (only instrument mons play) */
| 192 | |
| 193 | /* similar to mzapwand() but for magical horns (only instrument mons play) */ |
| 194 | staticfn void |
| 195 | mplayhorn( |
| 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 */ |
no test coverage detected