@@ -181,6 +181,15 @@ is_db_wall(int x, int y)
181181 return (boolean ) (levl [x ][y ].typ == DBWALL );
182182}
183183
184+ boolean
185+ is_jammed_db (int x , int y )
186+ {
187+ if (!find_drawbridge (& x , & y ))
188+ return FALSE;
189+ else
190+ return ((levl [x ][y ].drawbridgemask & DB_JAM ) != 0 );
191+ }
192+
184193/*
185194 * Return true with x,y pointing to the drawbridge if x,y initially indicate
186195 * a drawbridge or drawbridge wall.
@@ -974,4 +983,47 @@ destroy_drawbridge(int x, int y)
974983 nokiller ();
975984}
976985
986+ int
987+ unjam_drawbridge (int x , int y )
988+ {
989+ boolean under_u = (!u .dx && !u .dy );
990+ struct monst * mtmp = m_at (x , y );
991+
992+ if (!is_jammed_db (x , y )) {
993+ impossible ("unjam_drawbridge: clearing nonexistant jam?" );
994+ return 0 ;
995+ }
996+
997+ /* Test for monster first, monsters are displayed instead of trap. */
998+ if (mtmp ) {
999+ pline ("%s is in the way." , Monnam (mtmp ));
1000+ return 0 ;
1001+ }
1002+ /* We might be forced to move onto the trap's location. */
1003+ if (sobj_at (BOULDER , x , y ) && !Passes_walls && !under_u ) {
1004+ There ("is a boulder in your way." );
1005+ return 0 ;
1006+ }
1007+ /* duplicate tight-space checks from test_move */
1008+ if (u .dx && u .dy && bad_rock (g .youmonst .data , u .ux , y )
1009+ && bad_rock (g .youmonst .data , x , u .uy )) {
1010+ if ((g .invent && (inv_weight () + weight_cap () > 600 ))
1011+ || bigmonst (g .youmonst .data )) {
1012+ /* don't allow untrap if they can't get thru to it */
1013+ You ("are unable to reach the mechanism!" );
1014+ return 0 ;
1015+ }
1016+ }
1017+ if (rn2 (3 )) {
1018+ You ("are having a difficult time clearing the jam." );
1019+ return 1 ;
1020+ }
1021+
1022+ /* ok, disarm it. */
1023+ You ("unjam the mechanism." );
1024+ (void ) find_drawbridge (& x , & y );
1025+ levl [x ][y ].drawbridgemask &= ~DB_JAM ;
1026+ return 1 ;
1027+ }
1028+
9771029/*dbridge.c*/
0 commit comments