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

Function losehp

src/hack.c:4255–4292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4253}
4254
4255void
4256losehp(int n, const char *knam, schar k_format)
4257{
4258#if 0 /* code below is prepared to handle negative 'loss' so don't add this
4259 * until we've verified that no callers intentionally rely on that */
4260 if (n <= 0) {
4261 impossible("hero losing %d hit points due to \"%s\"?", n, knam);
4262 return;
4263 }
4264#endif
4265 disp.botl = TRUE; /* u.uhp or u.mh is changing */
4266 end_running(TRUE);
4267 if (Upolyd) {
4268 u.mh -= n;
4269 showdamage(n);
4270 if (u.mhmax < u.mh)
4271 u.mhmax = u.mh;
4272 if (u.mh < 1)
4273 rehumanize();
4274 else if (n > 0 && u.mh * 10 < u.mhmax && Unchanging)
4275 maybe_wail();
4276 return;
4277 }
4278
4279 u.uhp -= n;
4280 showdamage(n);
4281 if (u.uhp > u.uhpmax)
4282 u.uhpmax = u.uhp; /* perhaps n was negative */
4283 if (u.uhp < 1) {
4284 svk.killer.format = k_format;
4285 if (svk.killer.name != knam) /* the thing that killed you */
4286 Strcpy(svk.killer.name, knam ? knam : "");
4287 urgent_pline("You die...");
4288 done(DIED);
4289 } else if (n > 0 && u.uhp * 10 < u.uhpmax) {
4290 maybe_wail();
4291 }
4292}
4293
4294int
4295weight_cap(void)

Callers 15

throne_sit_effectFunction · 0.85
special_throne_effectFunction · 0.85
dositFunction · 0.85
peffect_waterFunction · 0.85
peffect_sicknessFunction · 0.85
peffect_levitationFunction · 0.85
peffect_oilFunction · 0.85
peffect_acidFunction · 0.85
potionhitFunction · 0.85
dip_potion_explosionFunction · 0.85
use_crystal_ballFunction · 0.85
mount_steedFunction · 0.85

Calls 7

end_runningFunction · 0.85
showdamageFunction · 0.85
rehumanizeFunction · 0.85
maybe_wailFunction · 0.85
urgent_plineFunction · 0.85
doneFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected