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

Function move_bc

src/ball.c:436–556  ·  view source on GitHub ↗

* move_bc() * * Move the ball and chain. This is called twice for every move. The first * time to pick up the ball and chain before the move, the second time to * place the ball and chain after the move. If the ball is carried, this * function should never have BC_BALL as part of its control. * * Should not be called while swallowed. */

Source from the content-addressed store, hash-verified

434 * Should not be called while swallowed.
435 */
436void
437move_bc(int before, int control, coordxy ballx, coordxy bally,
438 coordxy chainx, coordxy chainy)
439{
440 if (Blind) {
441 /*
442 * The hero is blind. Time to work hard. The ball and chain that
443 * are attached to the hero are very special. The hero knows that
444 * they are attached, so when they move, the hero knows that they
445 * aren't at the last position remembered. This is complicated
446 * by the fact that the hero can "feel" the surrounding locations
447 * at any time, hence, making one or both of them show up again.
448 * So, we have to keep track of which is felt at any one time and
449 * act accordingly.
450 */
451 if (!before) {
452 if ((control & BC_CHAIN) && (control & BC_BALL)) {
453 /*
454 * Both ball and chain moved. If felt, drop glyph.
455 */
456 if (u.bc_felt & BC_BALL)
457 levl[uball->ox][uball->oy].glyph = u.bglyph;
458 if (u.bc_felt & BC_CHAIN)
459 levl[uchain->ox][uchain->oy].glyph = u.cglyph;
460 u.bc_felt = 0;
461
462 /* Pick up glyph at new location. */
463 u.bglyph = levl[ballx][bally].glyph;
464 u.cglyph = levl[chainx][chainy].glyph;
465
466 movobj(uball, ballx, bally);
467 movobj(uchain, chainx, chainy);
468 } else if (control & BC_BALL) {
469 if (u.bc_felt & BC_BALL) {
470 if (u.bc_order == BCPOS_DIFFER) { /* ball by itself */
471 levl[uball->ox][uball->oy].glyph = u.bglyph;
472 } else if (u.bc_order == BCPOS_BALL) {
473 if (u.bc_felt & BC_CHAIN) { /* know chain is there */
474 map_object(uchain, 0);
475 } else {
476 levl[uball->ox][uball->oy].glyph = u.bglyph;
477 }
478 }
479 u.bc_felt &= ~BC_BALL; /* no longer feel the ball */
480 }
481
482 /* Pick up glyph at new position. */
483 u.bglyph = (ballx != chainx || bally != chainy)
484 ? levl[ballx][bally].glyph
485 : u.cglyph;
486
487 movobj(uball, ballx, bally);
488 } else if (control & BC_CHAIN) {
489 if (u.bc_felt & BC_CHAIN) {
490 if (u.bc_order == BCPOS_DIFFER) {
491 levl[uchain->ox][uchain->oy].glyph = u.cglyph;
492 } else if (u.bc_order == BCPOS_CHAIN) {
493 if (u.bc_felt & BC_BALL) {

Callers 6

teledsFunction · 0.85
drag_ballFunction · 0.85
domove_coreFunction · 0.85
hurtle_stepFunction · 0.85
move_into_trapFunction · 0.85
litroomFunction · 0.85

Calls 7

movobjFunction · 0.85
map_objectFunction · 0.85
bc_orderFunction · 0.85
remove_objectFunction · 0.85
maybe_unhide_atFunction · 0.85
newsymFunction · 0.85
place_objectFunction · 0.85

Tested by

no test coverage detected