see or hear a monster reading a scroll; when scroll hasn't been seen, its label is revealed unless hero is deaf */
| 235 | /* see or hear a monster reading a scroll; |
| 236 | when scroll hasn't been seen, its label is revealed unless hero is deaf */ |
| 237 | staticfn void |
| 238 | mreadmsg(struct monst *mtmp, struct obj *otmp) |
| 239 | { |
| 240 | char onambuf[BUFSZ]; |
| 241 | boolean vismon = canseemon(mtmp), |
| 242 | tpindicator = (!vismon && sensemon(mtmp)); |
| 243 | |
| 244 | if (!vismon && Deaf) |
| 245 | return; /* no feedback */ |
| 246 | |
| 247 | observe_object(otmp); /* seeing/hearing scroll read reveals its label */ |
| 248 | Strcpy(onambuf, singular(otmp, vismon ? doname : ansimpleoname)); |
| 249 | |
| 250 | if (vismon) { |
| 251 | /* directly see the monster reading the scroll */ |
| 252 | pline_mon(mtmp, "%s reads %s!", Monnam(mtmp), onambuf); |
| 253 | } else { /* !Deaf, otherwise we wouldn't reach here */ |
| 254 | char blindbuf[BUFSZ]; |
| 255 | boolean similar = same_race(gy.youmonst.data, mtmp->data), |
| 256 | uniqmon = ((mtmp->data->geno & G_UNIQ) != 0 |
| 257 | /* shopkeepers aren't unique monsters but since |
| 258 | they have distinct names, treat them as such */ |
| 259 | || mtmp->isshk), |
| 260 | recognize = (!Hallucination |
| 261 | && (mtmp->meverseen || (similar && !uniqmon))); |
| 262 | /* describe unseen monster accurately when not hallucinating if it |
| 263 | has ever been seen or is the same race as the hero (not yet seen |
| 264 | unique monsters excepted) */ |
| 265 | int mflags = (SUPPRESS_INVISIBLE | SUPPRESS_SADDLE |
| 266 | | (recognize ? SUPPRESS_IT : AUGMENT_IT)); |
| 267 | |
| 268 | if (sensemon(mtmp)) { |
| 269 | tpindicator = TRUE; |
| 270 | } else if (couldsee(mtmp->mx, mtmp->my) && mdistu(mtmp) <= 10 * 10) { |
| 271 | /* monster can't be seen or sensed; hero might be blind or monster |
| 272 | might be at a spot that isn't in view or might be invisible; |
| 273 | remember it if the spot is within line of sight and relatively |
| 274 | close */ |
| 275 | map_invisible(mtmp->mx, mtmp->my); |
| 276 | } |
| 277 | |
| 278 | Snprintf(blindbuf, sizeof blindbuf, "reading %s", onambuf); |
| 279 | strsubst(blindbuf, "reading a scroll labeled", |
| 280 | mtmp->mconf ? "attempting to incant" : "incant"); |
| 281 | You_hear("%s %s.", |
| 282 | x_monnam(mtmp, ARTICLE_A, (char *) 0, mflags, FALSE), |
| 283 | blindbuf); |
| 284 | if (tpindicator) |
| 285 | flash_mon(mtmp); |
| 286 | } |
| 287 | if (mtmp->mconf) /* (note: won't get if not seen and hero can't hear) */ |
| 288 | pline("Being confused, %s mispronounces the magic words...", |
| 289 | vismon ? mon_nam(mtmp) : mhe(mtmp)); |
| 290 | } |
| 291 | |
| 292 | staticfn void |
| 293 | mquaffmsg(struct monst *mtmp, struct obj *otmp) |
no test coverage detected