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

Function mcast_lightning

src/mcastu.c:565–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565staticfn int
566mcast_lightning(struct monst *mtmp, int dmg)
567{
568 int orig_dmg;
569 boolean reflects;
570
571 Soundeffect(se_bolt_of_lightning, 80);
572 pline("A bolt of lightning strikes down at you from above!");
573 reflects = ureflects("It bounces off your %s%s.", "");
574 orig_dmg = dmg = d(8, 6);
575 if (reflects || Shock_resistance) {
576 shieldeff(u.ux, u.uy);
577 dmg = 0;
578 if (reflects) {
579 monstseesu(M_SEEN_REFL);
580 return dmg;
581 }
582 monstunseesu(M_SEEN_REFL);
583 monstseesu(M_SEEN_ELEC);
584 } else {
585 monstunseesu(M_SEEN_ELEC | M_SEEN_REFL);
586 }
587 if (Half_spell_damage)
588 dmg = (dmg + 1) / 2;
589 (void) destroy_items(&gy.youmonst, AD_ELEC, orig_dmg);
590 /* lightning might destroy iron bars if hero is on such a spot;
591 reflection protects terrain here [execution won't get here due
592 to 'if (reflects) break' above] but hero resistance doesn't;
593 do this before maybe blinding the hero via flashburn() */
594 mon_spell_hits_spot(mtmp, AD_ELEC, u.ux, u.uy);
595 /* blind hero; no effect if already blind */
596 (void) flashburn((long) rnd(100), TRUE);
597 return dmg;
598}
599
600staticfn int
601mcast_psi_bolt(int dmg)

Callers 1

mcast_spellFunction · 0.85

Calls 10

ureflectsFunction · 0.85
dFunction · 0.85
shieldeffFunction · 0.85
monstseesuFunction · 0.85
monstunseesuFunction · 0.85
destroy_itemsFunction · 0.85
mon_spell_hits_spotFunction · 0.85
flashburnFunction · 0.85
rndFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected