| 238 | } |
| 239 | |
| 240 | boolean |
| 241 | onscary(coordxy x, coordxy y, struct monst *mtmp) |
| 242 | { |
| 243 | struct engr *ep; |
| 244 | /* <0,0> is used by musical scaring; |
| 245 | * it doesn't care about scrolls or engravings or dungeon branch */ |
| 246 | boolean auditory_scare = (x == 0 && y == 0), |
| 247 | magical_scare = !auditory_scare; |
| 248 | |
| 249 | /* creatures who are directly resistant to any type of scaring: |
| 250 | * Rodney, lawful minions, Angels, the Riders */ |
| 251 | if (mtmp->iswiz || is_lminion(mtmp) || mtmp->data == &mons[PM_ANGEL] |
| 252 | || is_rider(mtmp->data)) |
| 253 | return FALSE; |
| 254 | |
| 255 | /* creatures who are directly resistant to magical scaring |
| 256 | * based on the mere presence of something at a location: |
| 257 | * humans etc. |
| 258 | * uniques have ascended their base monster instincts */ |
| 259 | if (magical_scare |
| 260 | && (mtmp->data->mlet == S_HUMAN || unique_corpstat(mtmp->data))) |
| 261 | return FALSE; |
| 262 | |
| 263 | /* creatues who resist scaring under particular circumstances: |
| 264 | * shopkeepers inside their own shop |
| 265 | * priests inside their own temple */ |
| 266 | if ((mtmp->isshk && inhishop(mtmp)) |
| 267 | || (mtmp->ispriest && inhistemple(mtmp))) |
| 268 | return FALSE; |
| 269 | |
| 270 | if (auditory_scare) |
| 271 | return TRUE; |
| 272 | |
| 273 | /* should this still be true for defiled/molochian altars? */ |
| 274 | if (IS_ALTAR(levl[x][y].typ) |
| 275 | && (mtmp->data->mlet == S_VAMPIRE || is_vampshifter(mtmp))) |
| 276 | return TRUE; |
| 277 | |
| 278 | /* the scare monster scroll doesn't have any of the below |
| 279 | * restrictions, being its own source of power */ |
| 280 | if (sobj_at(SCR_SCARE_MONSTER, x, y)) |
| 281 | return TRUE; |
| 282 | |
| 283 | /* |
| 284 | * Creatures who don't (or can't) fear a written Elbereth: |
| 285 | * all the above plus shopkeepers (even if poly'd into non-human), |
| 286 | * vault guards (also even if poly'd), blind or peaceful monsters, |
| 287 | * humans and elves, and minotaurs. |
| 288 | * |
| 289 | * If the player isn't actually on the square OR the player's image |
| 290 | * isn't displaced to the square, no protection is being granted. |
| 291 | * |
| 292 | * Elbereth doesn't work in Gehennom, the Elemental Planes, or the |
| 293 | * Astral Plane; the influence of the Valar only reaches so far. |
| 294 | */ |
| 295 | return ((ep = sengr_at("Elbereth", x, y, TRUE)) != 0 |
| 296 | && (u_at(x, y) |
| 297 | || (Displaced && mtmp->mux == x && mtmp->muy == y) |
no test coverage detected