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

Function set_bc

src/ball.c:379–424  ·  view source on GitHub ↗

* set_bc() * * The hero is either about to go blind or already blind and just punished. * Set up the ball and chain variables so that the ball and chain are "felt". */

Source from the content-addressed store, hash-verified

377 * Set up the ball and chain variables so that the ball and chain are "felt".
378 */
379void
380set_bc(int already_blind)
381{
382 int ball_on_floor = !carried(uball);
383
384 u.bc_order = bc_order(); /* get the order */
385 u.bc_felt = ball_on_floor ? BC_BALL | BC_CHAIN : BC_CHAIN; /* felt */
386
387 if (already_blind || u.uswallow) {
388 u.cglyph = u.bglyph = levl[u.ux][u.uy].glyph;
389 return;
390 }
391
392 /*
393 * Since we can still see, remove the ball&chain and get the glyph that
394 * would be beneath them. Then put the ball&chain back. This is pretty
395 * disgusting, but it will work.
396 */
397 remove_object(uchain);
398 if (ball_on_floor)
399 remove_object(uball);
400
401 newsym(uchain->ox, uchain->oy);
402 u.cglyph = levl[uchain->ox][uchain->oy].glyph;
403
404 if (u.bc_order == BCPOS_DIFFER) { /* different locations */
405 place_object(uchain, uchain->ox, uchain->oy);
406 newsym(uchain->ox, uchain->oy);
407 if (ball_on_floor) {
408 newsym(uball->ox, uball->oy); /* see under ball */
409 u.bglyph = levl[uball->ox][uball->oy].glyph;
410 place_object(uball, uball->ox, uball->oy);
411 newsym(uball->ox, uball->oy); /* restore ball */
412 }
413 } else {
414 u.bglyph = u.cglyph;
415 if (u.bc_order == BCPOS_CHAIN) {
416 place_object(uball, uball->ox, uball->oy);
417 place_object(uchain, uchain->ox, uchain->oy);
418 } else {
419 place_object(uchain, uchain->ox, uchain->oy);
420 place_object(uball, uball->ox, uball->oy);
421 }
422 newsym(uball->ox, uball->oy);
423 }
424}
425
426/*
427 * move_bc()

Callers 4

make_blindedFunction · 0.85
Blindf_onFunction · 0.85
Blindf_offFunction · 0.85
punishFunction · 0.85

Calls 4

bc_orderFunction · 0.85
remove_objectFunction · 0.85
newsymFunction · 0.85
place_objectFunction · 0.85

Tested by

no test coverage detected