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

Function close_drawbridge

src/dbridge.c:774–834  ·  view source on GitHub ↗

* Close the drawbridge located at x,y */

Source from the content-addressed store, hash-verified

772 * Close the drawbridge located at x,y
773 */
774void
775close_drawbridge(coordxy x, coordxy y)
776{
777 struct rm *lev1, *lev2;
778 struct trap *t;
779 coordxy x2, y2;
780
781 lev1 = &levl[x][y];
782 if (lev1->typ != DRAWBRIDGE_DOWN)
783 return;
784 x2 = x;
785 y2 = y;
786 get_wall_for_db(&x2, &y2);
787 if (cansee(x, y) || cansee(x2, y2)) {
788 You_see("a drawbridge %s up!",
789 (((u.ux == x || u.uy == y) && !Underwater)
790 || distu(x2, y2) < distu(x, y))
791 ? "coming"
792 : "going");
793 } else { /* "5 gears turn" for castle drawbridge tune */
794 Soundeffect(se_chains_rattling_gears_turning, 75);
795 You_hear("chains rattling and gears turning.");
796 }
797 lev1->typ = DRAWBRIDGE_UP;
798 lev2 = &levl[x2][y2];
799 lev2->typ = DBWALL;
800 switch (lev1->drawbridgemask & DB_DIR) {
801 case DB_NORTH:
802 case DB_SOUTH:
803 lev2->horizontal = TRUE;
804 break;
805 case DB_WEST:
806 case DB_EAST:
807 lev2->horizontal = FALSE;
808 break;
809 }
810 lev2->wall_info = W_NONDIGGABLE;
811 set_entity(x, y, &(go.occupants[0]));
812 set_entity(x2, y2, &(go.occupants[1]));
813 do_entity(&(go.occupants[0])); /* Do set_entity after first */
814 set_entity(x2, y2, &(go.occupants[1])); /* do_entity for worm tail */
815 do_entity(&(go.occupants[1]));
816 if (OBJ_AT(x, y) && !Deaf) {
817 Soundeffect(se_smashing_and_crushing, 75);
818 You_hear("smashing and crushing.");
819 }
820 (void) revive_nasty(x, y, (char *) 0);
821 (void) revive_nasty(x2, y2, (char *) 0);
822 delallobj(x, y);
823 delallobj(x2, y2);
824 if ((t = t_at(x, y)) != 0)
825 deltrap(t);
826 if ((t = t_at(x2, y2)) != 0)
827 deltrap(t);
828 del_engr_at(x, y);
829 del_engr_at(x2, y2);
830 newsym(x, y);
831 newsym(x2, y2);

Callers 3

do_play_instrumentFunction · 0.85
zap_updownFunction · 0.85
zap_mapFunction · 0.85

Calls 13

get_wall_for_dbFunction · 0.85
You_seeFunction · 0.85
You_hearFunction · 0.85
set_entityFunction · 0.85
do_entityFunction · 0.85
revive_nastyFunction · 0.85
delallobjFunction · 0.85
t_atFunction · 0.85
deltrapFunction · 0.85
del_engr_atFunction · 0.85
newsymFunction · 0.85
block_pointFunction · 0.85

Tested by

no test coverage detected