]> granicus.if.org Git - nethack/commitdiff
random initial drawbridge state (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 21 Apr 2007 01:54:56 +0000 (01:54 +0000)
committernethack.rankin <nethack.rankin>
Sat, 21 Apr 2007 01:54:56 +0000 (01:54 +0000)
     Suggested by <Someone>:  in the special level compiler, support
"random" in addition to "open" and "closed" for a drawbridge's inital
state.  Drawbridge shares code with door, so the necessary parsing was
already present.  This just treats random as valid for drawbridge instead
of explicitly rejecting it, and makes the special level loader process it.

     He also suggested that the two drawbridges on the bottom level of
the Valk's quest be changed from open to random, but this patch doesn't
go that far.  I think it's a good idea, but since the player can't use a
musicial instrument on those bridges, this has more impact on game play
than it might at first seem.  I don't really want to see Valkyries be
required to use magic for occasions where both bridges start out closed.

src/sp_lev.c
sys/share/lev_yacc.c
util/lev_comp.y

index 2194b384f271c46826f0aca14096db36dde6748f..2f276d6839f79ca41031f1f22c7b033f6ebbeaa1 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)sp_lev.c   3.5     2006/05/09      */
+/*     SCCS Id: @(#)sp_lev.c   3.5     2007/04/20      */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2405,7 +2405,9 @@ dlb *fd;
                x = tmpdb.x;  y = tmpdb.y;
                get_location(&x, &y, DRY|WET);
 
-               if (!create_drawbridge(x, y, tmpdb.dir, tmpdb.db_open))
+               typ = tmpdb.db_open;
+               if (typ == 127) typ = rn2(2);   /* 0 => closed, 1 => open */
+               if (!create_drawbridge(x, y, tmpdb.dir, typ))
                    impossible("Cannot create drawbridge.");
        }
 
index cf509bbf3db16a8d5fe97f3557f97ec78f95775f..d4f5ca57681e2f8ab736db4e70e007d60b2ddf63 100644 (file)
@@ -8,7 +8,7 @@ static char yysccsid[] = "@(#)yaccpar   1.9 (Berkeley) 02/21/93";
 #define yyerrok (yyerrflag=0)
 #define YYRECOVERING (yyerrflag!=0)
 #define YYPREFIX "yy"
-/*     SCCS Id: @(#)lev_yacc.c 3.5     2000/01/17      */
+/*     SCCS Id: @(#)lev_yacc.c 3.5     2007/04/20      */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1812,8 +1812,10 @@ case 151:
                            tmpdb[ndb]->db_open = 1;
                        else if ( yyvsp[0].i == D_CLOSED )
                            tmpdb[ndb]->db_open = 0;
+                       else if (yyvsp[0].i == -1)      /* RANDOM_TYPE */
+                           tmpdb[ndb]->db_open = 127;  /* random */
                        else
-                           yyerror("A drawbridge can only be open or closed!");
+                           yyerror("A drawbridge can only be open, closed, or random!");
                        ndb++;
                        if (ndb >= MAX_OF_TYPE) {
                                yyerror("Too many drawbridges in mazepart!");
index abc6233f3b42a7f6a2f1413e01991548b29e6403..2c47ecef8fcaa30e231248bd72f271765a44bf61 100644 (file)
@@ -1,5 +1,5 @@
 %{
-/*     SCCS Id: @(#)lev_yacc.c 3.5     2000/01/17      */
+/*     SCCS Id: @(#)lev_yacc.c 3.5     2007/04/20      */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1062,8 +1062,10 @@ drawbridge_detail: DRAWBRIDGE_ID ':' coordinate ',' DIRECTION ',' door_state
                            tmpdb[ndb]->db_open = 1;
                        else if ( $<i>7 == D_CLOSED )
                            tmpdb[ndb]->db_open = 0;
+                       else if ($<i>7 == -1)   /* RANDOM_TYPE */
+                           tmpdb[ndb]->db_open = 127;  /* random */
                        else
-                           yyerror("A drawbridge can only be open or closed!");
+                           yyerror("A drawbridge can only be open, closed, or random!");
                        ndb++;
                        if (ndb >= MAX_OF_TYPE) {
                                yyerror("Too many drawbridges in mazepart!");