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

Function touch_of_death

src/mcastu.c:322–354  ·  view source on GitHub ↗

unlike the finger of death spell which behaves like a wand of death, this monster spell only attacks the hero */

Source from the content-addressed store, hash-verified

320/* unlike the finger of death spell which behaves like a wand of death,
321 this monster spell only attacks the hero */
322void
323touch_of_death(struct monst *mtmp)
324{
325 char kbuf[BUFSZ];
326 int dmg = 50 + d(8, 6);
327 int drain = dmg / 2;
328
329 /* if we get here, we know that hero isn't magic resistant and isn't
330 poly'd into an undead or demon */
331 You_feel("drained...");
332 (void) death_inflicted_by(kbuf, "the touch of death", mtmp);
333
334 if (Upolyd) {
335 u.mh = 0;
336 rehumanize(); /* fatal iff Unchanging */
337 } else if (drain >= u.uhpmax) {
338 svk.killer.format = KILLED_BY;
339 Strcpy(svk.killer.name, kbuf);
340 done(DIED);
341 } else {
342 /* HP manipulation similar to poisoned(attrib.c) */
343 int olduhp = u.uhp,
344 uhpmin = minuhpmax(3),
345 newuhpmax = u.uhpmax - drain;
346
347 setuhpmax(max(newuhpmax, uhpmin), FALSE);
348 dmg = adjuhploss(dmg, olduhp); /* reduce pending damage if uhp has
349 * already been reduced due to drop
350 * in uhpmax */
351 losehp(dmg, kbuf, KILLED_BY);
352 }
353 svk.killer.name[0] = '\0'; /* not killed if we get here... */
354}
355
356/* give a reason for death by some monster spells */
357char *

Callers 2

mhitm_ad_dethFunction · 0.85
mcast_death_touchFunction · 0.85

Calls 9

dFunction · 0.85
You_feelFunction · 0.85
death_inflicted_byFunction · 0.85
rehumanizeFunction · 0.85
doneFunction · 0.85
minuhpmaxFunction · 0.85
setuhpmaxFunction · 0.85
adjuhplossFunction · 0.85
losehpFunction · 0.85

Tested by

no test coverage detected