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

Function ballfall

src/ball.c:42–67  ·  view source on GitHub ↗

ball&chain might hit hero when falling through a trap door */

Source from the content-addressed store, hash-verified

40
41/* ball&chain might hit hero when falling through a trap door */
42void
43ballfall(void)
44{
45 boolean gets_hit;
46
47 if (!uball || (uball && carried(uball) && welded(uball)))
48 return;
49
50 gets_hit = (((uball->ox != u.ux) || (uball->oy != u.uy))
51 && ((uwep == uball) ? FALSE : (boolean) rn2(5)));
52 ballrelease(TRUE);
53 if (gets_hit) {
54 int dmg = rn1(7, 25);
55
56 pline_The("iron ball falls on your %s.", body_part(HEAD));
57 if (uarmh) {
58 if (hard_helmet(uarmh)) {
59 pline("Fortunately, you are wearing a hard helmet.");
60 dmg = 3;
61 } else if (flags.verbose)
62 pline("%s does not protect you.", Yname2(uarmh));
63 }
64 losehp(Maybe_Half_Phys(dmg), "crunched in the head by an iron ball",
65 NO_KILLER_PREFIX);
66 }
67}
68
69/*
70 * To make this work, we have to mess with the hero's mind. The rules for

Callers 2

goto_levelFunction · 0.85
trapeffect_pitFunction · 0.85

Calls 9

weldedFunction · 0.85
rn2Function · 0.85
ballreleaseFunction · 0.85
pline_TheFunction · 0.85
body_partFunction · 0.85
hard_helmetFunction · 0.85
Yname2Function · 0.85
losehpFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected