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

Function can_blnd

src/mondata.c:304–398  ·  view source on GitHub ↗

True iff monster can be blinded by the given attack; note: may return True when mdef is blind (e.g. new cream-pie attack) magr can be NULL. */

Source from the content-addressed store, hash-verified

302 magr can be NULL.
303*/
304boolean
305can_blnd(
306 struct monst *magr, /* NULL == no specific aggressor */
307 struct monst *mdef,
308 uchar aatyp,
309 struct obj *obj) /* aatyp == AT_WEAP, AT_SPIT */
310{
311 boolean is_you = (mdef == &gy.youmonst);
312 boolean check_visor = FALSE;
313 struct obj *o;
314
315 /* no eyes protect against all attacks for now */
316 if (!haseyes(mdef->data))
317 return FALSE;
318
319 /* if monster has been permanently blinded, the deed is already done */
320 if (!is_you && mon_perma_blind(mdef))
321 return FALSE;
322
323 /* /corvus oculum corvi non eruit/
324 a saying expressed in Latin rather than a zoological observation:
325 "a crow will not pluck out the eye of another crow"
326 so prevent ravens from blinding each other */
327 if (magr && magr->data == &mons[PM_RAVEN] && mdef->data == &mons[PM_RAVEN])
328 return FALSE;
329
330 switch (aatyp) {
331 case AT_EXPL:
332 case AT_BOOM:
333 case AT_GAZE:
334 case AT_MAGC:
335 case AT_BREA: /* assumed to be lightning */
336 /* light-based attacks may be cancelled or resisted */
337 if (magr && magr->mcan)
338 return FALSE;
339 return !resists_blnd(mdef);
340
341 case AT_WEAP:
342 case AT_SPIT:
343 case AT_NONE:
344 /* an object is used (thrown/spit/other) */
345 if (obj && (obj->otyp == CREAM_PIE)) {
346 if (is_you && Blindfolded)
347 return FALSE;
348 } else if (obj && (obj->otyp == BLINDING_VENOM)) {
349 /* all ublindf, including LENSES, protect, cream-pies too */
350 if (is_you && (ublindf || u.ucreamed))
351 return FALSE;
352 check_visor = TRUE;
353 } else if (obj && (obj->otyp == POT_BLINDNESS)) {
354 return TRUE; /* no defense */
355 } else
356 return FALSE; /* other objects cannot cause blindness yet */
357 if ((magr == &gy.youmonst) && u.uswallow)
358 return FALSE; /* can't affect eyes while inside monster */
359 break;
360
361 case AT_ENGL:

Callers 9

hmon_hitmon_misc_objFunction · 0.85
mhitm_ad_blndFunction · 0.85
gulpumFunction · 0.85
toss_upFunction · 0.85
ohitmonFunction · 0.85
mthrowu.cFile · 0.85
gulp_blnd_checkFunction · 0.85
gulpmuFunction · 0.85
use_cream_pieFunction · 0.85

Calls 2

resists_blndFunction · 0.85
objdescr_isFunction · 0.85

Tested by

no test coverage detected