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

Function punish

src/read.c:3018–3062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3016}
3017
3018void
3019punish(struct obj *sobj)
3020{
3021 /* angrygods() calls this with NULL sobj arg */
3022 struct obj *reuse_ball = (sobj && sobj->otyp == HEAVY_IRON_BALL)
3023 ? sobj : (struct obj *) 0;
3024 /* analyzer doesn't know that the one caller that passes a NULL
3025 * sobj (angrygods) checks !Punished first, so add a guard */
3026 int cursed_levy = (sobj && sobj->cursed) ? 1 : 0;
3027
3028 /* KMH -- Punishment is still okay when you are riding */
3029 if (!reuse_ball)
3030 You("are being punished for your misbehavior!");
3031 if (Punished) {
3032 Your("iron ball gets heavier.");
3033 uball->owt += WT_IRON_BALL_INCR * (1 + cursed_levy);
3034 return;
3035 }
3036 if (amorphous(gy.youmonst.data) || is_whirly(gy.youmonst.data)
3037 || unsolid(gy.youmonst.data)) {
3038 if (!reuse_ball) {
3039 pline("A ball and chain appears, then falls away.");
3040 dropy(mkobj(BALL_CLASS, TRUE));
3041 } else {
3042 dropy(reuse_ball);
3043 }
3044 return;
3045 }
3046 setworn(mkobj(CHAIN_CLASS, TRUE), W_CHAIN);
3047 if (!reuse_ball)
3048 setworn(mkobj(BALL_CLASS, TRUE), W_BALL);
3049 else
3050 setworn(reuse_ball, W_BALL);
3051
3052 /*
3053 * Place ball & chain if not swallowed. If swallowed, the ball & chain
3054 * variables will be set at the next call to placebc().
3055 */
3056 if (!u.uswallow) {
3057 placebc();
3058 if (Blind)
3059 set_bc(1); /* set up ball and chain variables */
3060 newsym(u.ux, u.uy); /* see ball&chain if can't see self */
3061 }
3062}
3063
3064/* remove the ball and chain */
3065void

Callers 3

angrygodsFunction · 0.85
seffect_punishmentFunction · 0.85

Calls 9

YouFunction · 0.85
YourFunction · 0.85
dropyFunction · 0.85
mkobjFunction · 0.85
setwornFunction · 0.85
placebcFunction · 0.85
set_bcFunction · 0.85
newsymFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected