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

Function flash_hits_mon

src/uhitm.c:6340–6422  ·  view source on GitHub ↗

returns 1 if light flash has noticeable effect on 'mtmp', 0 otherwise */

Source from the content-addressed store, hash-verified

6338
6339/* returns 1 if light flash has noticeable effect on 'mtmp', 0 otherwise */
6340int
6341flash_hits_mon(
6342 struct monst *mtmp,
6343 struct obj *otmp) /* source of flash */
6344{
6345 struct rm *lev;
6346 coordxy mx = mtmp->mx, my = mtmp->my;
6347 int tmp, amt, useeit, res = 0;
6348
6349 if (gn.notonhead)
6350 return 0;
6351 lev = &levl[mx][my];
6352 useeit = canseemon(mtmp);
6353
6354 if (M_AP_TYPE(mtmp) != M_AP_NOTHING) {
6355 char whatbuf[BUFSZ];
6356 int oldglyph = glyph_at(mx, my);
6357
6358 /* 'altmon' probably doesn't matter here because 'whatbuf' will
6359 only be shown if the glyph changes and wakeup() doesn't call
6360 seemimic() for M_AP_MONSTER */
6361 mhidden_description(mtmp, MHID_ALTMON, whatbuf);
6362
6363 wakeup(mtmp, FALSE); /* -> seemimic() -> newsym(); also calls
6364 * finish_meating() to end quickmimic */
6365
6366 /* if glyph has changed then hero saw something happen */
6367 if (glyph_at(mx, my) != oldglyph) {
6368 pline("That %s is really %s%c", whatbuf,
6369 /* y_monnam()+a_monnam() */
6370 x_monnam(mtmp, mtmp->mtame ? ARTICLE_YOUR : ARTICLE_A,
6371 (char *) 0, 0, FALSE),
6372 mtmp->mtame ? '.' : '!');
6373 res = 1;
6374 }
6375 }
6376
6377 if (mtmp->msleeping && haseyes(mtmp->data)) {
6378 mtmp->msleeping = 0;
6379 if (useeit) {
6380 pline_The("flash awakens %s.", mon_nam(mtmp));
6381 res = 1;
6382 }
6383 } else if (mtmp->data->mlet != S_LIGHT) {
6384 if (!resists_blnd(mtmp)) {
6385 tmp = dist2(otmp->ox, otmp->oy, mx, my);
6386 if (useeit) {
6387 pline("%s is blinded by the flash!", Monnam(mtmp));
6388 res = 1;
6389 }
6390 if (mtmp->data == &mons[PM_GREMLIN]) {
6391 /* Rule #1: Keep them out of the light. */
6392 amt = (otmp->otyp == WAN_LIGHT) ? d(1 + otmp->spe, 4)
6393 : rnd(min(mtmp->mhp, 4));
6394 light_hits_gremlin(mtmp, amt);
6395 }
6396 if (!DEADMONSTER(mtmp)) {
6397 if (!svc.context.mon_moving)

Callers 3

bhitmFunction · 0.85
bhitFunction · 0.85
do_blinding_rayFunction · 0.85

Calls 15

canseemonFunction · 0.85
glyph_atFunction · 0.85
mhidden_descriptionFunction · 0.85
wakeupFunction · 0.85
pline_TheFunction · 0.85
mon_namFunction · 0.85
resists_blndFunction · 0.85
dist2Function · 0.85
MonnamFunction · 0.85
dFunction · 0.85
rndFunction · 0.85
light_hits_gremlinFunction · 0.85

Tested by

no test coverage detected