MCPcopy Index your code
hub / github.com/NetHack/NetHack / lightdamage

Function lightdamage

src/zap.c:3025–3056  ·  view source on GitHub ↗

light damages hero in gremlin form */

Source from the content-addressed store, hash-verified

3023
3024/* light damages hero in gremlin form */
3025int
3026lightdamage(
3027 struct obj *obj, /* item making light (fake book if spell) */
3028 boolean ordinary, /* wand/camera zap vs wand destruction */
3029 int amt) /* pseudo-damage used to determine blindness duration */
3030{
3031 char buf[BUFSZ];
3032 const char *how;
3033 int dmg = amt;
3034
3035 if (dmg && gy.youmonst.data == &mons[PM_GREMLIN]) {
3036 /* reduce high values (from destruction of wand with many charges) */
3037 dmg = rnd(dmg);
3038 if (dmg > 10)
3039 dmg = 10 + rnd(dmg - 10);
3040 if (dmg > 20)
3041 dmg = 20;
3042 pline("Ow, that light hurts%c", (dmg > 2 || u.mh <= 5) ? '!' : '.');
3043 /* [composing killer/reason is superfluous here; if fatal, cause
3044 of death will always be "killed while stuck in creature form"] */
3045 if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS)
3046 ordinary = FALSE; /* say blasted rather than zapped */
3047 how = (obj->oclass == SPBOOK_CLASS) ? "spell of light"
3048 : (!obj->oartifact) ? ansimpleoname(obj)
3049 : bare_artifactname(obj);
3050 Sprintf(buf, "%s %sself with %s", ordinary ? "zapped" : "blasted",
3051 uhim(), how);
3052 /* might rehumanize(); could be fatal, but only for Unchanging */
3053 losehp(Maybe_Half_Phys(dmg), buf, NO_KILLER_PREFIX);
3054 }
3055 return dmg;
3056}
3057
3058/* light[ning] causes blindness */
3059boolean

Callers 5

invoke_blinding_rayFunction · 0.85
zapnodirFunction · 0.85
zapyourselfFunction · 0.85
use_offensiveFunction · 0.85
seffect_lightFunction · 0.85

Calls 5

rndFunction · 0.85
ansimpleonameFunction · 0.85
bare_artifactnameFunction · 0.85
losehpFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected