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

Function monhp_per_lvl

src/makemon.c:985–1007  ·  view source on GitHub ↗

amount of HP to lose from level drain (or gain from Stormbringer) */

Source from the content-addressed store, hash-verified

983
984/* amount of HP to lose from level drain (or gain from Stormbringer) */
985int
986monhp_per_lvl(struct monst *mon)
987{
988 struct permonst *ptr = mon->data;
989 int hp = rnd(8); /* default is d8 */
990
991 /* like newmonhp, but home elementals are ignored, riders use normal d8 */
992 if (is_golem(ptr)) {
993 /* draining usually won't be applicable for these critters */
994 hp = golemhp(monsndx(ptr)) / (int) ptr->mlevel;
995 } else if (ptr->mlevel > 49) {
996 /* arbitrary; such monsters won't be involved in draining anyway */
997 hp = 4 + rnd(4); /* 5..8 */
998 } else if (ptr->mlet == S_DRAGON && monsndx(ptr) >= PM_GRAY_DRAGON) {
999 /* adult dragons; newmonhp() uses In_endgame(&u.uz) ? 8 : 4 + rnd(4)
1000 */
1001 hp = 4 + rn2(5); /* 4..8 */
1002 } else if (!mon->m_lev) {
1003 /* level 0 monsters use 1d4 instead of Nd8 */
1004 hp = rnd(4);
1005 }
1006 return hp;
1007}
1008
1009/* set up a new monster's initial level and hit points;
1010 used by newcham() as well as by makemon() */

Callers 5

losexpFunction · 0.85
pluslvlFunction · 0.85
artifact_hitFunction · 0.85
bhitmFunction · 0.85
montraitsFunction · 0.85

Calls 3

rndFunction · 0.85
golemhpFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected